@things-factory/warehouse-base 3.8.23 → 3.8.24

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.
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SellercraftController = void 0;
4
- const typeorm_1 = require("typeorm");
5
4
  const integration_sellercraft_1 = require("@things-factory/integration-sellercraft");
6
5
  const constants_1 = require("../../constants");
7
6
  const inventory_1 = require("../../service/inventory/inventory");
@@ -10,9 +9,19 @@ class SellercraftController extends warehouse_controller_1.WarehouseController {
10
9
  async updateSellercraftStock(sellercraft, inventory) {
11
10
  let product = inventory.product;
12
11
  const productDetails = product.productDetails;
13
- const inventories = await this.trxMgr.getRepository(inventory_1.Inventory).find({
14
- where: { domain: this.domain, product, status: (0, typeorm_1.Not)((0, typeorm_1.Equal)(constants_1.INVENTORY_STATUS.TERMINATED)) }
12
+ let qb = await this.trxMgr.getRepository(inventory_1.Inventory).createQueryBuilder('inv');
13
+ qb.leftJoinAndSelect('inv.location', 'loc')
14
+ .andWhere('"inv"."domain_id" = :domainId')
15
+ .andWhere('"inv"."product_id" = :productId')
16
+ .andWhere('"inv"."status" != :status')
17
+ .andWhere('"loc"."type" NOT IN (:...locationTypes)')
18
+ .setParameters({
19
+ domainId: this.domain.id,
20
+ productId: product.id,
21
+ status: constants_1.INVENTORY_STATUS.TERMINATED,
22
+ locationTypes: [constants_1.LOCATION_TYPE.QUARANTINE, constants_1.LOCATION_TYPE.RESERVE]
15
23
  });
24
+ let inventories = await qb.getMany();
16
25
  let defaultProductDetail;
17
26
  const sellercraftInvs = await Promise.all(inventories.map(async (inventory) => {
18
27
  const inventoryPackingType = inventory.packingType;
@@ -24,24 +33,27 @@ class SellercraftController extends warehouse_controller_1.WarehouseController {
24
33
  }
25
34
  return { quantity: inventory.qty * packingSize - inventory.lockedQty * packingSize };
26
35
  }));
27
- const totalQty = sellercraftInvs.reduce((total, currentValue) => {
36
+ let inventoryTotalQty = sellercraftInvs.reduce((total, currentValue) => {
28
37
  total += currentValue.quantity;
29
38
  return total;
30
39
  }, 0);
31
- const sellercraftInv = {
32
- accountId: sellercraft.accountId,
33
- sku: product.sku,
34
- uom: 'EA',
35
- quantity: totalQty,
36
- gtin: defaultProductDetail.gtin,
37
- weight: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
38
- packageDimension: {
39
- length: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
40
- width: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
41
- height: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
40
+ const sellercraftInv = [
41
+ {
42
+ sku: product.sku,
43
+ gtin: defaultProductDetail.gtin,
44
+ stock: {
45
+ quantity: inventoryTotalQty,
46
+ unit_of_measure: 'EA'
47
+ },
48
+ package_weight_gm: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
49
+ package_dimensions: {
50
+ length_mm: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
51
+ width_mm: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
52
+ height_mm: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
53
+ }
42
54
  }
43
- };
44
- await integration_sellercraft_1.SellercraftAPI.updateProduct(sellercraft, { sellercraftInv });
55
+ ];
56
+ await integration_sellercraft_1.SellercraftAPI.updateProduct(sellercraft, { accountId: sellercraft.accountId, sellercraftInv });
45
57
  }
46
58
  }
47
59
  exports.SellercraftController = SellercraftController;
@@ -1 +1 @@
1
- {"version":3,"file":"sellercraft-controller.js","sourceRoot":"","sources":["../../../server/controllers/ecommerce/sellercraft-controller.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAEpC,qFAAqF;AAGrF,+CAAkD;AAClD,iEAA6D;AAC7D,kEAA6D;AAE7D,MAAa,qBAAsB,SAAQ,0CAAmB;IAC5D,KAAK,CAAC,sBAAsB,CAAC,WAAwB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AAE,EAAE;YACtE,KAAK,IAAI,YAAY,CAAC,QAAQ,CAAA;YAC9B,OAAO,KAAK,CAAA;QACd,CAAC,EAAE,CAAC,CAAC,CAAA;QAEL,MAAM,cAAc,GAAQ;YAC1B,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,GAAG,EAAE,IAAI;YACT,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,oBAAoB,CAAC,IAAI;YAC/B,MAAM,EAAE,oBAAoB,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,UAAU;YACjF,gBAAgB,EAAE;gBAChB,MAAM,EAAE,oBAAoB,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK;gBACvE,KAAK,EAAE,oBAAoB,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK;gBACtE,MAAM,EAAE,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM;aAC1E;SACF,CAAA;QAED,MAAM,wCAAc,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,cAAc,EAAE,CAAC,CAAA;IACrE,CAAC;CACF;AAhDD,sDAgDC"}
1
+ {"version":3,"file":"sellercraft-controller.js","sourceRoot":"","sources":["../../../server/controllers/ecommerce/sellercraft-controller.ts"],"names":[],"mappings":";;;AAAA,qFAAqF;AAGrF,+CAAiE;AACjE,iEAA6D;AAC7D,kEAA6D;AAE7D,MAAa,qBAAsB,SAAQ,0CAAmB;IAC5D,KAAK,CAAC,sBAAsB,CAAC,WAAwB,EAAE,SAAoB;QACzE,IAAI,OAAO,GAAY,SAAS,CAAC,OAAO,CAAA;QACxC,MAAM,cAAc,GAAoB,OA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 @@
1
1
  {
2
2
  "name": "@things-factory/warehouse-base",
3
- "version": "3.8.23",
3
+ "version": "3.8.24",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -31,5 +31,5 @@
31
31
  "@things-factory/product-base": "^3.8.9",
32
32
  "@things-factory/setting-base": "^3.8.0"
33
33
  },
34
- "gitHead": "13d86eb25cc3bd591064b5c126569fc35333357e"
34
+ "gitHead": "f5ac602fd1c55aa59f3b04b6b3819d7ec32dd91b"
35
35
  }
@@ -1,9 +1,7 @@
1
- import { Equal, Not } from 'typeorm'
2
-
3
1
  import { Sellercraft, SellercraftAPI } from '@things-factory/integration-sellercraft'
4
2
  import { Product, ProductDetail } from '@things-factory/product-base'
5
3
 
6
- import { INVENTORY_STATUS } from '../../constants'
4
+ import { INVENTORY_STATUS, LOCATION_TYPE } from '../../constants'
7
5
  import { Inventory } from '../../service/inventory/inventory'
8
6
  import { WarehouseController } from '../warehouse-controller'
9
7
 
@@ -11,9 +9,21 @@ export class SellercraftController extends WarehouseController {
11
9
  async updateSellercraftStock(sellercraft: Sellercraft, inventory: Inventory): Promise<void> {
12
10
  let product: Product = inventory.product
13
11
  const productDetails: ProductDetail[] = product.productDetails
14
- const inventories: Inventory[] = await this.trxMgr.getRepository(Inventory).find({
15
- where: { domain: this.domain, product, status: Not(Equal(INVENTORY_STATUS.TERMINATED)) }
16
- })
12
+
13
+ let qb = await this.trxMgr.getRepository(Inventory).createQueryBuilder('inv')
14
+ qb.leftJoinAndSelect('inv.location', 'loc')
15
+ .andWhere('"inv"."domain_id" = :domainId')
16
+ .andWhere('"inv"."product_id" = :productId')
17
+ .andWhere('"inv"."status" != :status')
18
+ .andWhere('"loc"."type" NOT IN (:...locationTypes)')
19
+ .setParameters({
20
+ domainId: this.domain.id,
21
+ productId: product.id,
22
+ status: INVENTORY_STATUS.TERMINATED,
23
+ locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
24
+ })
25
+
26
+ let inventories: Inventory[] = await qb.getMany()
17
27
 
18
28
  let defaultProductDetail: ProductDetail
19
29
  const sellercraftInvs: any[] = await Promise.all(
@@ -34,25 +44,28 @@ export class SellercraftController extends WarehouseController {
34
44
  })
35
45
  )
36
46
 
37
- const totalQty: number = sellercraftInvs.reduce((total, currentValue) => {
47
+ let inventoryTotalQty: number = sellercraftInvs.reduce((total, currentValue) => {
38
48
  total += currentValue.quantity
39
49
  return total
40
50
  }, 0)
41
51
 
42
- const sellercraftInv: any = {
43
- accountId: sellercraft.accountId,
44
- sku: product.sku,
45
- uom: 'EA',
46
- quantity: totalQty,
47
- gtin: defaultProductDetail.gtin,
48
- weight: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
49
- packageDimension: {
50
- length: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
51
- width: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
52
- height: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
52
+ const sellercraftInv: any[] = [
53
+ {
54
+ sku: product.sku,
55
+ gtin: defaultProductDetail.gtin,
56
+ stock: {
57
+ quantity: inventoryTotalQty,
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
+ }
53
66
  }
54
- }
67
+ ]
55
68
 
56
- await SellercraftAPI.updateProduct(sellercraft, { sellercraftInv })
69
+ await SellercraftAPI.updateProduct(sellercraft, { accountId: sellercraft.accountId, sellercraftInv })
57
70
  }
58
71
  }