@things-factory/warehouse-base 4.3.46 → 4.3.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,68 +8,72 @@ const inventory_1 = require("../../service/inventory/inventory");
|
|
|
8
8
|
const warehouse_controller_1 = require("../warehouse-controller");
|
|
9
9
|
class SellercraftController extends warehouse_controller_1.WarehouseController {
|
|
10
10
|
async updateSellercraftStock(sellercraft, inventory) {
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
packingSize =
|
|
11
|
+
let sellercraftSetting = sellercraft.sellercraftSetting;
|
|
12
|
+
let disableUpdateStock = (sellercraftSetting === null || sellercraftSetting === void 0 ? void 0 : sellercraftSetting.disableUpdateStock) && (sellercraftSetting === null || sellercraftSetting === void 0 ? void 0 : sellercraftSetting.disableUpdateStock) == 1 ? true : false;
|
|
13
|
+
if (!disableUpdateStock) {
|
|
14
|
+
const bizplace = await this.trxMgr.getRepository(biz_base_1.Bizplace).findOne({ domain: sellercraft.domain });
|
|
15
|
+
let product = inventory.product;
|
|
16
|
+
const productDetails = product.productDetails;
|
|
17
|
+
let qb = await this.trxMgr.getRepository(inventory_1.Inventory).createQueryBuilder('inv');
|
|
18
|
+
qb.leftJoinAndSelect('inv.location', 'loc')
|
|
19
|
+
.andWhere('"inv"."domain_id" = :domainId')
|
|
20
|
+
.andWhere('"inv"."bizplace_id" = :bizplaceId')
|
|
21
|
+
.andWhere('"inv"."product_id" = :productId')
|
|
22
|
+
.andWhere('"inv"."status" = :status')
|
|
23
|
+
.andWhere('"loc"."type" NOT IN (:...locationTypes)')
|
|
24
|
+
.setParameters({
|
|
25
|
+
domainId: this.domain.id,
|
|
26
|
+
bizplaceId: bizplace.id,
|
|
27
|
+
productId: product.id,
|
|
28
|
+
status: constants_1.INVENTORY_STATUS.STORED,
|
|
29
|
+
locationTypes: [constants_1.LOCATION_TYPE.QUARANTINE, constants_1.LOCATION_TYPE.RESERVE]
|
|
30
|
+
});
|
|
31
|
+
let inventories = await qb.getMany();
|
|
32
|
+
let defaultProductDetail = product.productDetails.find(productDetail => productDetail.isDefault);
|
|
33
|
+
let inventoryTotalQty = 0;
|
|
34
|
+
let inventoryTotalLockedQty = 0;
|
|
35
|
+
if ((inventories === null || inventories === void 0 ? void 0 : inventories.length) > 0) {
|
|
36
|
+
const sellercraftInvs = await Promise.all(inventories.map(async (inventory) => {
|
|
37
|
+
const inventoryPackingType = inventory.packingType;
|
|
38
|
+
let packingSize = 1;
|
|
39
|
+
if (inventoryPackingType !== defaultProductDetail.packingType) {
|
|
40
|
+
const unmatchingProductDetail = product.productDetails.find(productDetail => productDetail.packingType === inventoryPackingType);
|
|
41
|
+
packingSize = await this.getChildPackingSize(productDetails, defaultProductDetail, unmatchingProductDetail);
|
|
42
|
+
}
|
|
43
|
+
return { totalQty: inventory.qty * packingSize, totalLockedQty: inventory.lockedQty * packingSize };
|
|
44
|
+
}));
|
|
45
|
+
inventoryTotalQty = sellercraftInvs.reduce((total, currentValue) => {
|
|
46
|
+
total += currentValue.totalQty;
|
|
47
|
+
return total;
|
|
48
|
+
}, 0);
|
|
49
|
+
inventoryTotalLockedQty = sellercraftInvs.reduce((total, currentValue) => {
|
|
50
|
+
total += currentValue.totalLockedQty;
|
|
51
|
+
return total;
|
|
52
|
+
}, 0);
|
|
53
|
+
}
|
|
54
|
+
const sellercraftInv = [
|
|
55
|
+
{
|
|
56
|
+
sku: product.sku,
|
|
57
|
+
gtin: defaultProductDetail.gtin,
|
|
58
|
+
stock: {
|
|
59
|
+
quantity_total: inventoryTotalQty,
|
|
60
|
+
quantity_reserved: inventoryTotalLockedQty,
|
|
61
|
+
unit_of_measure: 'EA'
|
|
62
|
+
},
|
|
63
|
+
package_weight_gm: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
64
|
+
package_dimensions: {
|
|
65
|
+
length_mm: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
66
|
+
width_mm: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
67
|
+
height_mm: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
68
|
+
}
|
|
39
69
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
inventoryTotalLockedQty = sellercraftInvs.reduce((total, currentValue) => {
|
|
47
|
-
total += currentValue.totalLockedQty;
|
|
48
|
-
return total;
|
|
49
|
-
}, 0);
|
|
70
|
+
];
|
|
71
|
+
await integration_sellercraft_1.SellercraftAPI.updateProduct(sellercraft, {
|
|
72
|
+
context: { state: { domain: this === null || this === void 0 ? void 0 : this.domain, user: this === null || this === void 0 ? void 0 : this.user } },
|
|
73
|
+
accountId: sellercraft.accountId,
|
|
74
|
+
sellercraftInv
|
|
75
|
+
});
|
|
50
76
|
}
|
|
51
|
-
const sellercraftInv = [
|
|
52
|
-
{
|
|
53
|
-
sku: product.sku,
|
|
54
|
-
gtin: defaultProductDetail.gtin,
|
|
55
|
-
stock: {
|
|
56
|
-
quantity_total: inventoryTotalQty,
|
|
57
|
-
quantity_reserved: inventoryTotalLockedQty,
|
|
58
|
-
unit_of_measure: 'EA'
|
|
59
|
-
},
|
|
60
|
-
package_weight_gm: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
61
|
-
package_dimensions: {
|
|
62
|
-
length_mm: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
63
|
-
width_mm: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
64
|
-
height_mm: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
];
|
|
68
|
-
await integration_sellercraft_1.SellercraftAPI.updateProduct(sellercraft, {
|
|
69
|
-
context: { state: { domain: this === null || this === void 0 ? void 0 : this.domain, user: this === null || this === void 0 ? void 0 : this.user } },
|
|
70
|
-
accountId: sellercraft.accountId,
|
|
71
|
-
sellercraftInv
|
|
72
|
-
});
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
exports.SellercraftController = SellercraftController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sellercraft-controller.js","sourceRoot":"","sources":["../../../server/controllers/ecommerce/sellercraft-controller.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,qFAAqF;AAGrF,+CAAiE;AACjE,iEAA6D;AAC7D,kEAA6D;AAE7D,MAAa,qBAAsB,SAAQ,0CAAmB;IAC5D,KAAK,CAAC,sBAAsB,CAAC,WAAwB,EAAE,SAAoB;QACzE,MAAM,QAAQ,GAAa,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"sellercraft-controller.js","sourceRoot":"","sources":["../../../server/controllers/ecommerce/sellercraft-controller.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,qFAAqF;AAGrF,+CAAiE;AACjE,iEAA6D;AAC7D,kEAA6D;AAE7D,MAAa,qBAAsB,SAAQ,0CAAmB;IAC5D,KAAK,CAAC,sBAAsB,CAAC,WAAwB,EAAE,SAAoB;QACzE,IAAI,kBAAkB,GAAQ,WAAW,CAAC,kBAAkB,CAAA;QAC5D,IAAI,kBAAkB,GACpB,CAAA,kBAAkB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|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/biz-base": "^4.3.
|
|
28
|
-
"@things-factory/id-rule-base": "^4.3.
|
|
29
|
-
"@things-factory/integration-sellercraft": "^4.3.
|
|
30
|
-
"@things-factory/marketplace-base": "^4.3.
|
|
31
|
-
"@things-factory/product-base": "^4.3.
|
|
32
|
-
"@things-factory/setting-base": "^4.3.
|
|
27
|
+
"@things-factory/biz-base": "^4.3.47",
|
|
28
|
+
"@things-factory/id-rule-base": "^4.3.47",
|
|
29
|
+
"@things-factory/integration-sellercraft": "^4.3.47",
|
|
30
|
+
"@things-factory/marketplace-base": "^4.3.47",
|
|
31
|
+
"@things-factory/product-base": "^4.3.47",
|
|
32
|
+
"@things-factory/setting-base": "^4.3.47"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "2abf3aa51954ef43fde410c44e854495422e6612"
|
|
35
35
|
}
|
|
@@ -8,83 +8,93 @@ import { WarehouseController } from '../warehouse-controller'
|
|
|
8
8
|
|
|
9
9
|
export class SellercraftController extends WarehouseController {
|
|
10
10
|
async updateSellercraftStock(sellercraft: Sellercraft, inventory: Inventory): Promise<void> {
|
|
11
|
-
|
|
11
|
+
let sellercraftSetting: any = sellercraft.sellercraftSetting
|
|
12
|
+
let disableUpdateStock: boolean =
|
|
13
|
+
sellercraftSetting?.disableUpdateStock && sellercraftSetting?.disableUpdateStock == 1 ? true : false
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
if (!disableUpdateStock) {
|
|
16
|
+
const bizplace: Bizplace = await this.trxMgr.getRepository(Bizplace).findOne({ domain: sellercraft.domain })
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.andWhere('"inv"."domain_id" = :domainId')
|
|
19
|
-
.andWhere('"inv"."bizplace_id" = :bizplaceId')
|
|
20
|
-
.andWhere('"inv"."product_id" = :productId')
|
|
21
|
-
.andWhere('"inv"."status" = :status')
|
|
22
|
-
.andWhere('"loc"."type" NOT IN (:...locationTypes)')
|
|
23
|
-
.setParameters({
|
|
24
|
-
domainId: this.domain.id,
|
|
25
|
-
bizplaceId: bizplace.id,
|
|
26
|
-
productId: product.id,
|
|
27
|
-
status: INVENTORY_STATUS.STORED,
|
|
28
|
-
locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
|
|
29
|
-
})
|
|
18
|
+
let product: Product = inventory.product
|
|
19
|
+
const productDetails: ProductDetail[] = product.productDetails
|
|
30
20
|
|
|
31
|
-
|
|
21
|
+
let qb = await this.trxMgr.getRepository(Inventory).createQueryBuilder('inv')
|
|
22
|
+
qb.leftJoinAndSelect('inv.location', 'loc')
|
|
23
|
+
.andWhere('"inv"."domain_id" = :domainId')
|
|
24
|
+
.andWhere('"inv"."bizplace_id" = :bizplaceId')
|
|
25
|
+
.andWhere('"inv"."product_id" = :productId')
|
|
26
|
+
.andWhere('"inv"."status" = :status')
|
|
27
|
+
.andWhere('"loc"."type" NOT IN (:...locationTypes)')
|
|
28
|
+
.setParameters({
|
|
29
|
+
domainId: this.domain.id,
|
|
30
|
+
bizplaceId: bizplace.id,
|
|
31
|
+
productId: product.id,
|
|
32
|
+
status: INVENTORY_STATUS.STORED,
|
|
33
|
+
locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
|
|
34
|
+
})
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
let inventoryTotalQty: number = 0
|
|
35
|
-
let inventoryTotalLockedQty: number = 0
|
|
36
|
+
let inventories: Inventory[] = await qb.getMany()
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const inventoryPackingType: string = inventory.packingType
|
|
38
|
+
let defaultProductDetail: ProductDetail = product.productDetails.find(productDetail => productDetail.isDefault)
|
|
39
|
+
let inventoryTotalQty: number = 0
|
|
40
|
+
let inventoryTotalLockedQty: number = 0
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
42
|
+
if (inventories?.length > 0) {
|
|
43
|
+
const sellercraftInvs: any[] = await Promise.all(
|
|
44
|
+
inventories.map(async (inventory: Inventory) => {
|
|
45
|
+
const inventoryPackingType: string = inventory.packingType
|
|
47
46
|
|
|
48
|
-
packingSize =
|
|
49
|
-
|
|
47
|
+
let packingSize: number = 1
|
|
48
|
+
if (inventoryPackingType !== defaultProductDetail.packingType) {
|
|
49
|
+
const unmatchingProductDetail: ProductDetail = product.productDetails.find(
|
|
50
|
+
productDetail => productDetail.packingType === inventoryPackingType
|
|
51
|
+
)
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
packingSize = await this.getChildPackingSize(
|
|
54
|
+
productDetails,
|
|
55
|
+
defaultProductDetail,
|
|
56
|
+
unmatchingProductDetail
|
|
57
|
+
)
|
|
58
|
+
}
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}, 0)
|
|
60
|
+
return { totalQty: inventory.qty * packingSize, totalLockedQty: inventory.lockedQty * packingSize }
|
|
61
|
+
})
|
|
62
|
+
)
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
64
|
+
inventoryTotalQty = sellercraftInvs.reduce((total, currentValue) => {
|
|
65
|
+
total += currentValue.totalQty
|
|
66
|
+
return total
|
|
67
|
+
}, 0)
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
stock: {
|
|
71
|
-
quantity_total: inventoryTotalQty,
|
|
72
|
-
quantity_reserved: inventoryTotalLockedQty,
|
|
73
|
-
unit_of_measure: 'EA'
|
|
74
|
-
},
|
|
75
|
-
package_weight_gm: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
76
|
-
package_dimensions: {
|
|
77
|
-
length_mm: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
78
|
-
width_mm: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
79
|
-
height_mm: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
80
|
-
}
|
|
69
|
+
inventoryTotalLockedQty = sellercraftInvs.reduce((total, currentValue) => {
|
|
70
|
+
total += currentValue.totalLockedQty
|
|
71
|
+
return total
|
|
72
|
+
}, 0)
|
|
81
73
|
}
|
|
82
|
-
]
|
|
83
74
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
const sellercraftInv: any[] = [
|
|
76
|
+
{
|
|
77
|
+
sku: product.sku,
|
|
78
|
+
gtin: defaultProductDetail.gtin,
|
|
79
|
+
stock: {
|
|
80
|
+
quantity_total: inventoryTotalQty,
|
|
81
|
+
quantity_reserved: inventoryTotalLockedQty,
|
|
82
|
+
unit_of_measure: 'EA'
|
|
83
|
+
},
|
|
84
|
+
package_weight_gm: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
85
|
+
package_dimensions: {
|
|
86
|
+
length_mm: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
87
|
+
width_mm: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
88
|
+
height_mm: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
await SellercraftAPI.updateProduct(sellercraft, {
|
|
94
|
+
context: { state: { domain: this?.domain, user: this?.user } },
|
|
95
|
+
accountId: sellercraft.accountId,
|
|
96
|
+
sellercraftInv
|
|
97
|
+
})
|
|
98
|
+
}
|
|
89
99
|
}
|
|
90
100
|
}
|