var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { JsonClassType, JsonProperty } from "jackson-js";
import _ from "lodash";
export var PurchaseOrderStatusType;
(function (PurchaseOrderStatusType) {
    PurchaseOrderStatusType["DRAFT"] = "DRAFT";
    PurchaseOrderStatusType["WORKING"] = "WORKING";
    PurchaseOrderStatusType["SHIPPING"] = "SHIPPING";
    PurchaseOrderStatusType["COMPLETED"] = "COMPLETED";
})(PurchaseOrderStatusType || (PurchaseOrderStatusType = {}));
export var PurchaseOrderExpenseType;
(function (PurchaseOrderExpenseType) {
    PurchaseOrderExpenseType["PRODUCTION"] = "PRODUCTION";
    PurchaseOrderExpenseType["DUTY"] = "DUTY";
    PurchaseOrderExpenseType["SHIPPING"] = "SHIPPING";
    PurchaseOrderExpenseType["TAX"] = "TAX";
    PurchaseOrderExpenseType["EXTRA"] = "EXTRA";
})(PurchaseOrderExpenseType || (PurchaseOrderExpenseType = {}));
export var ShippingMethod;
(function (ShippingMethod) {
    ShippingMethod["TRUCK"] = "TRUCK";
    ShippingMethod["SHIP"] = "SHIP";
    ShippingMethod["TRAIN"] = "TRAIN";
    ShippingMethod["PLANE"] = "PLANE";
})(ShippingMethod || (ShippingMethod = {}));
export class PurchaseOrderStatus {
}
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [String] })
], PurchaseOrderStatus.prototype, "status", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Date] })
], PurchaseOrderStatus.prototype, "date", void 0);
export class PurchaseOrderCost {
}
__decorate([
    JsonProperty()
], PurchaseOrderCost.prototype, "reference", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [String] })
], PurchaseOrderCost.prototype, "type", void 0);
__decorate([
    JsonProperty()
], PurchaseOrderCost.prototype, "transactionId", void 0);
export class ProductPurchase {
}
__decorate([
    JsonProperty()
], ProductPurchase.prototype, "id", void 0);
__decorate([
    JsonProperty()
], ProductPurchase.prototype, "bin", void 0);
__decorate([
    JsonProperty()
], ProductPurchase.prototype, "quantity", void 0);
export class PurchaseOrder {
    constructor() {
        this.productPurchases = [];
        this.statusHistory = [];
        this.costs = [];
    }
    getProductPurchaseQuantityBySku(bins) {
        const totalQuantity = _.reduce(this.productPurchases, (acc, i) => {
            if (_.includes(bins, i.bin)) {
                return acc + i.quantity;
            }
            return acc;
        }, 0);
        return totalQuantity;
    }
    getPurchasedBins() {
        return _.map(this.productPurchases, p => (p.bin));
    }
    getProductPurchaseBySku(bin) {
        return _.find(this.productPurchases, (p) => (p.bin == bin));
    }
}
__decorate([
    JsonProperty()
], PurchaseOrder.prototype, "id", void 0);
__decorate([
    JsonProperty()
], PurchaseOrder.prototype, "name", void 0);
__decorate([
    JsonProperty()
], PurchaseOrder.prototype, "notes", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [String] })
], PurchaseOrder.prototype, "vectorType", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [String] })
], PurchaseOrder.prototype, "status", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [ProductPurchase]] })
], PurchaseOrder.prototype, "productPurchases", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [PurchaseOrderStatus]] })
], PurchaseOrder.prototype, "statusHistory", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [PurchaseOrderCost]] })
], PurchaseOrder.prototype, "costs", void 0);
__decorate([
    JsonProperty({ required: false }),
    JsonClassType({ type: () => [Date] })
], PurchaseOrder.prototype, "availableAt", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Date] })
], PurchaseOrder.prototype, "createdAt", void 0);
//# sourceMappingURL=purchase_order.js.map