@things-factory/operato-mms 3.8.8 → 3.8.12

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.
@@ -183,6 +183,15 @@ class ProductVariations extends localize(i18next)(PageView) {
183
183
  record: { align: 'center' },
184
184
  width: 150
185
185
  },
186
+ {
187
+ type: 'float',
188
+ name: 'reserveQty',
189
+ header: i18next.t('field.variation_reserve_qty'),
190
+ sortable: true,
191
+ imex: { header: i18next.t('field.variation_reserve_qty'), key: 'reserveQty', width: 25, type: 'string' },
192
+ record: { align: 'center' },
193
+ width: 150
194
+ },
186
195
  {
187
196
  type: 'float',
188
197
  name: 'costPrice',
@@ -305,6 +314,7 @@ class ProductVariations extends localize(i18next)(PageView) {
305
314
  variationSku
306
315
  channelSku
307
316
  qty
317
+ reserveQty
308
318
  bufferQty
309
319
  thresholdQty
310
320
  name
@@ -1,12 +1,14 @@
1
1
  import '@things-factory/form-ui'
2
2
  import '@things-factory/grist-ui'
3
- import { i18next, localize } from '@things-factory/i18n-base'
4
- import { client, PageView, gqlContext } from '@things-factory/shell'
5
- import { ScrollbarStyles, CommonButtonStyles } from '@things-factory/styles'
6
- import { gqlBuilder, isMobileDevice } from '@things-factory/utils'
3
+
7
4
  import gql from 'graphql-tag'
8
5
  import { css, html } from 'lit-element'
9
6
 
7
+ import { i18next, localize } from '@things-factory/i18n-base'
8
+ import { client, gqlContext, PageView } from '@things-factory/shell'
9
+ import { CommonButtonStyles, ScrollbarStyles } from '@things-factory/styles'
10
+ import { gqlBuilder, isMobileDevice } from '@things-factory/utils'
11
+
10
12
  class InventoryByProduct extends localize(i18next)(PageView) {
11
13
  static get styles() {
12
14
  return [
@@ -170,6 +172,7 @@ class InventoryByProduct extends localize(i18next)(PageView) {
170
172
  id
171
173
  name
172
174
  qty
175
+ reserveQty
173
176
  }
174
177
  }
175
178
  warehouseInventory{
@@ -214,6 +217,7 @@ class InventoryByProduct extends localize(i18next)(PageView) {
214
217
  if (existingGroup) {
215
218
  existingGroup[mp.marketplaceStore.id + '_store'] = mpv.name
216
219
  existingGroup[mp.marketplaceStore.id + '_qty'] = mpv.qty
220
+ existingGroup[mp.marketplaceStore.id + '_reserveQty'] = mpv.reserveQty
217
221
  existingGroup[mp.marketplaceStore.id + '_variationId'] = mpv.id
218
222
  } else {
219
223
  data.push({
@@ -223,6 +227,7 @@ class InventoryByProduct extends localize(i18next)(PageView) {
223
227
  name: item.name,
224
228
  [mp.marketplaceStore.id + '_store']: mpv.name,
225
229
  [mp.marketplaceStore.id + '_qty']: mpv.qty,
230
+ [mp.marketplaceStore.id + '_reserveQty']: mpv.reserveQty,
226
231
  [mp.marketplaceStore.id + '_variationId']: mpv.id
227
232
  })
228
233
  }
@@ -348,6 +353,14 @@ class InventoryByProduct extends localize(i18next)(PageView) {
348
353
  record: { editable: true, align: 'left' },
349
354
  width: 60
350
355
  })
356
+ stores.push({
357
+ type: 'number',
358
+ name: store.id.toString() + '_reserveQty',
359
+ header: i18next.t('field.reserve_qty'),
360
+ sortable: false,
361
+ record: { align: 'left' },
362
+ width: 60
363
+ })
351
364
  })
352
365
 
353
366
  this.config = {
@@ -252,7 +252,7 @@ class OrderByStore extends localize(i18next)(PageView) {
252
252
  {
253
253
  type: 'boolean',
254
254
  name: 'isSplitted',
255
- header: i18next.t('field.splitted'),
255
+ header: i18next.t('field.is_splitted'),
256
256
  record: { align: 'center' },
257
257
  width: 40
258
258
  },
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.autoUpdateAllMarketplaceProductVariationQuantityResolver = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const integration_fulfillment_1 = require("@things-factory/integration-fulfillment");
6
+ const integration_marketplace_1 = require("@things-factory/integration-marketplace");
7
+ const marketplace_base_1 = require("@things-factory/marketplace-base");
8
+ const product_base_1 = require("@things-factory/product-base");
9
+ const shell_1 = require("@things-factory/shell");
10
+ const warehouse_base_1 = require("@things-factory/warehouse-base");
11
+ exports.autoUpdateAllMarketplaceProductVariationQuantityResolver = {
12
+ async autoUpdateAllMarketplaceProductVariationQuantity(_, { companyDomainId, warehouseId }, context) {
13
+ var _a, _b;
14
+ try {
15
+ const { tx } = context.state;
16
+ const companyDomain = await (0, typeorm_1.getRepository)(shell_1.Domain).findOne(companyDomainId);
17
+ const productVariations = await (0, typeorm_1.getRepository)(marketplace_base_1.MarketplaceProductVariation).find({
18
+ where: { domain: companyDomain },
19
+ relations: [
20
+ 'marketplaceProduct',
21
+ 'marketplaceProduct.marketplaceStore',
22
+ 'marketplaceProduct.marketplaceStore.marketplaceDistributors',
23
+ 'creator',
24
+ 'updater'
25
+ ]
26
+ });
27
+ for (var i = 0; i < productVariations.length; i++) {
28
+ const productVariation = productVariations[i];
29
+ const sku = productVariation.sku;
30
+ let warehouseProductQty = 0;
31
+ if (sku) {
32
+ const fulfilmentCenter = await integration_fulfillment_1.FulfillmentAPI.getFulfillmentCenter(warehouseId);
33
+ const centerId = fulfilmentCenter.centerId;
34
+ const warehouseDomain = await (0, typeorm_1.getRepository)(shell_1.Domain).findOne({ where: { subdomain: centerId } });
35
+ const product = await (0, typeorm_1.getRepository)(product_base_1.Product).findOne({ where: { domain: companyDomain, sku } });
36
+ const qb = await (0, typeorm_1.getRepository)(warehouse_base_1.Inventory).createQueryBuilder('INV');
37
+ qb.select('SUM(INV.qty - INV.locked_qty)', 'remainQty')
38
+ .where('"INV"."domain_id" = :domainId', { domainId: warehouseDomain.id })
39
+ .andWhere('"INV"."product_id" = :productId', { productId: product.id })
40
+ .andWhere('"INV"."status" = :invStatus', { invStatus: 'STORED' })
41
+ .groupBy('"INV".product_id');
42
+ const item = await qb.getRawOne();
43
+ if (item)
44
+ warehouseProductQty += parseFloat(item.remainQty) || 0;
45
+ }
46
+ const marketplaceStore = (_a = productVariation === null || productVariation === void 0 ? void 0 : productVariation.marketplaceProduct) === null || _a === void 0 ? void 0 : _a.marketplaceStore;
47
+ const hasVariation = (_b = productVariation === null || productVariation === void 0 ? void 0 : productVariation.marketplaceProduct) === null || _b === void 0 ? void 0 : _b.hasVariation;
48
+ if (marketplaceStore) {
49
+ //Lazada Product quantity data update -> {sku, qty}
50
+ //Shopee Product quantity data update -> variation = false: {itemId, qty} | variation = true: {itemId, variationId, qty}
51
+ const productVariationQty = productVariation.qty || 0;
52
+ const productVariationReserveQty = productVariation.reserveQty || 0;
53
+ let adjustQty = productVariationQty == warehouseProductQty
54
+ ? productVariationQty - productVariationReserveQty
55
+ : warehouseProductQty - productVariationReserveQty;
56
+ let productVariationLocationId = productVariation.locationId;
57
+ if (marketplaceStore.platform === 'SHOPIFY') {
58
+ adjustQty = productVariationReserveQty;
59
+ let locationIds = JSON.parse(productVariationLocationId);
60
+ productVariationLocationId = locationIds[0].location_id;
61
+ }
62
+ if (hasVariation) {
63
+ await integration_marketplace_1.StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
64
+ {
65
+ itemId: productVariation.marketplaceProduct.itemId,
66
+ variationId: productVariation.variationId,
67
+ qty: adjustQty,
68
+ locationId: productVariationLocationId,
69
+ inventoryItemId: productVariation.inventoryItemId
70
+ }
71
+ ]);
72
+ }
73
+ else {
74
+ await integration_marketplace_1.StoreAPI.updateStoreProductStock(marketplaceStore, [
75
+ {
76
+ itemId: productVariation.marketplaceProduct.itemId,
77
+ variationId: productVariation.variationId,
78
+ variationSku: productVariation.variationSku,
79
+ qty: adjustQty,
80
+ distributors: marketplaceStore.marketplaceDistributors
81
+ }
82
+ ]);
83
+ }
84
+ }
85
+ }
86
+ return true;
87
+ }
88
+ catch (ex) { }
89
+ }
90
+ };
91
+ //# sourceMappingURL=auto-update-all-marketplace-product-variation-quantity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-update-all-marketplace-product-variation-quantity.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/interface-with-hub/auto-update-all-marketplace-product-variation-quantity.ts"],"names":[],"mappings":";;;AAAA,qCAA0E;AAE1E,qFAAw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mB,GAAG,0BAA0B,CAAA;oBACtD,IAAI,0BAA0B,GAAG,gBAAgB,CAAC,UAAU,CAAA;oBAC5D,IAAI,gBAAgB,CAAC,QAAQ,KAAK,SAAS,EAAE;wBAC3C,SAAS,GAAG,0BAA0B,CAAA;wBAEtC,IAAI,WAAW,GAAU,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;wBAC/D,0BAA0B,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;qBACxD;oBAED,IAAI,YAAY,EAAE;wBAChB,MAAM,kCAAQ,CAAC,gCAAgC,CAAC,gBAAgB,EAAE;4BAChE;gCACE,MAAM,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,MAAM;gCAClD,WAAW,EAAE,gBAAgB,CAAC,WAAW;gCACzC,GAAG,EAAE,SAAS;gCACd,UAAU,EAAE,0BAA0B;gCACtC,eAAe,EAAE,gBAAgB,CAAC,eAAe;6BAClD;yBACF,CAAC,CAAA;qBACH;yBAAM;wBACL,MAAM,kCAAQ,CAAC,uBAAuB,CAAC,gBAAgB,EAAE;4BACvD;gCACE,MAAM,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,MAAM;gCAClD,WAAW,EAAE,gBAAgB,CAAC,WAAW;gCACzC,YAAY,EAAE,gBAAgB,CAAC,YAAY;gCAC3C,GAAG,EAAE,SAAS;gCACd,YAAY,EAAE,gBAAgB,CAAC,uBAAuB;6BACvD;yBACF,CAAC,CAAA;qBACH;iBACF;aACF;YAED,OAAO,IAAI,CAAA;SACZ;QAAC,OAAO,EAAE,EAAE,GAAE;IACjB,CAAC;CACF,CAAA"}
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.warehouseMarketplaceProduct = exports.Mutation = exports.Query = void 0;
4
4
  const add_release_order_1 = require("./add-release-order");
5
5
  const auto_add_release_order_1 = require("./auto-add-release-order");
6
+ const auto_update_all_marketplace_product_variation_quantity_1 = require("./auto-update-all-marketplace-product-variation-quantity");
6
7
  const generate_replenishment_order_1 = require("./generate-replenishment-order");
7
8
  const warehouse_marketplace_products_1 = require("./warehouse-marketplace-products");
8
9
  Object.defineProperty(exports, "warehouseMarketplaceProduct", { enumerable: true, get: function () { return warehouse_marketplace_products_1.warehouseMarketplaceProduct; } });
9
10
  exports.Query = Object.assign({}, warehouse_marketplace_products_1.warehouseMarketplaceProductsResolver);
10
- exports.Mutation = Object.assign(Object.assign(Object.assign({}, add_release_order_1.addReleaseOrderResolver), auto_add_release_order_1.autoAddReleaseOrderResolver), generate_replenishment_order_1.generateReplenishmentOrderResolver);
11
+ exports.Mutation = Object.assign(Object.assign(Object.assign(Object.assign({}, add_release_order_1.addReleaseOrderResolver), auto_add_release_order_1.autoAddReleaseOrderResolver), generate_replenishment_order_1.generateReplenishmentOrderResolver), auto_update_all_marketplace_product_variation_quantity_1.autoUpdateAllMarketplaceProductVariationQuantityResolver);
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/interface-with-hub/index.ts"],"names":[],"mappings":";;;AAAA,2DAA6D;AAC7D,qEAAsE;AACtE,iFAAmF;AACnF,qFAAoH;AAY3G,4GAZA,4DAA2B,OAYA;AAVvB,QAAA,KAAK,qBACb,qEAAoC,EACxC;AAEY,QAAA,QAAQ,iDAChB,2CAAuB,GACvB,oDAA2B,GAC3B,iEAAkC,EACtC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/interface-with-hub/index.ts"],"names":[],"mappings":";;;AAAA,2DAA6D;AAC7D,qEAAsE;AACtE,qIAAmI;AACnI,iFAAmF;AACnF,qFAAoH;AAa3G,4GAbA,4DAA2B,OAaA;AAXvB,QAAA,KAAK,qBACb,qEAAoC,EACxC;AAEY,QAAA,QAAQ,+DAChB,2CAAuB,GACvB,oDAA2B,GAC3B,iEAAkC,GAClC,iHAAwD,EAC5D"}
@@ -64,7 +64,7 @@ async function warehouseMarketplaceProduct(params, domain, user, tx) {
64
64
  select "dt"."marketplace_store_id", "dt"."product_id", "dt"."sku", array_agg(row_to_json(dt)) as product_variation
65
65
  from (
66
66
  select "mp"."marketplace_store_id" as "marketplace_store_id", "mpv"."sku", "mpv"."id" as "marketplace_product_variation_id",
67
- concat("mpv"."variation_sku", ' (', "mpv"."name", ')') as "name", "mpv"."qty" as "qty",
67
+ concat("mpv"."variation_sku", ' (', "mpv"."name", ')') as "name", "mpv"."qty" as "qty", "mpv"."reserve_qty" as "reserve_qty",
68
68
  "Product"."product_id" AS "product_id"
69
69
  from marketplace_product_variations "mpv"
70
70
  inner join marketplace_products "mp" on "mp"."id" = "mpv"."marketplace_product_id"
@@ -146,7 +146,8 @@ async function warehouseMarketplaceProduct(params, domain, user, tx) {
146
146
  return {
147
147
  id: variation.marketplace_product_variation_id,
148
148
  name: variation.name,
149
- qty: variation.qty
149
+ qty: variation.qty,
150
+ reserveQty: variation.reserve_qty
150
151
  };
151
152
  })
152
153
  };
@@ -1 +1 @@
1
- {"version":3,"file":"warehouse-marketplace-products.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.ts"],"names":[],"mappings":";;;AACA,uDAAsF;AACtF,+DAAsD;AAIzC,QAAA,oCAAoC,GAAG;IAClD,KAAK,CAAC,4BAA4B,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QACxE,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;YAC7F,OAAO,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;SAC7D;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CACF,CAAA;AAEM,KAAK,UAAU,2BAA2B,CAAC,MAAiB,EAAE,MAAc,EAAE,IAAU,EAAE,EAAkB;IACjH,MAAM,cAAc,GA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tB,CAAA;AACH,CAAC;AA3KD,kEA2KC"}
1
+ {"version":3,"file":"warehouse-marketplace-products.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.ts"],"names":[],"mappings":";;;AAGA,uDAAsF;AACtF,+DAAsD;AAGzC,QAAA,oCAAoC,GAAG;IAClD,KAAK,CAAC,4BAA4B,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QACxE,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;YAC7F,OAAO,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;SAC7D;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CACF,CAAA;AAEM,KAAK,UAAU,2BAA2B,CAAC,MAAiB,EAAE,MAAc,EAAE,IAAU,EAAE,EAAkB;IACjH,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,cAAc,CAAC,CAAA;IAC3E,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,cAAc,CAAC,CAAA;IAEpE,MAAM,eAAe,GAAa,MAAM,IAAA,6BAAkB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACxE,MAAM,UAAU,GAAa,MAAM,IAAA,wBAAa,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAE9D,MAAM,CAAC,OAAO,GAAG,CAAC,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,eAAe,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IAElH,MAAM,WA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,CAAC,CAAC,GAAG,CAAC,uBAAuB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;wBAC1C,OAAO;4BACL,QAAQ,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,gBAAgB,EAAE;4BAC5E,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,UAAU,EAAE;4BACrC,GAAG,EAAE,SAAS,CAAC,aAAa;4BAC5B,SAAS,EAAE,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;4BAC9E,SAAS,EACP,SAAS,CAAC,aAAa,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;yBAClG,CAAA;oBACH,CAAC,CAAC;oBACJ,CAAC,CAAC,IAAI;aACT,CAAA;QACH,CAAC,CAAC;QACF,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;KACtB,CAAA;AACH,CAAC;AA5KD,kEA4KC"}
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Types = exports.Query = exports.Mutation = void 0;
4
+ const new_stock_replenishment_1 = require("./new-stock-replenishment");
5
+ const replenishment_order_product_1 = require("./replenishment-order-product");
6
+ const stock_replenishment_1 = require("./stock-replenishment");
7
+ const stock_replenishment_list_1 = require("./stock-replenishment-list");
4
8
  const warehouse_inventory_1 = require("./warehouse-inventory");
5
9
  const warehouse_marketplace_product_1 = require("./warehouse-marketplace-product");
6
10
  const warehouse_marketplace_product_list_1 = require("./warehouse-marketplace-product-list");
7
- const stock_replenishment_1 = require("./stock-replenishment");
8
- const new_stock_replenishment_1 = require("./new-stock-replenishment");
9
- const stock_replenishment_list_1 = require("./stock-replenishment-list");
10
- const replenishment_order_product_1 = require("./replenishment-order-product");
11
11
  exports.Mutation = `
12
12
  addReleaseOrder(marketplaceOrderIds: [String]!, warehouseId: String!): Boolean @transaction
13
13
  autoAddReleaseOrder(warehouseId: String): Boolean @transaction
14
14
  generateReplenishmentOrder(stockReplenishmentId: String!, warehouseId: String!): StockReplenishment @transaction
15
+ autoUpdateAllMarketplaceProductVariationQuantity(companyDomainId: String, warehouseId: String): Boolean @transaction
15
16
  `;
16
17
  exports.Query = `
17
18
  warehouseMarketplaceProducts(filters: [Filter], pagination: Pagination, sortings: [Sorting]): WarehouseMarketplaceProductList @transaction
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/interface-with-hub/index.ts"],"names":[],"mappings":";;;AAAA,+DAA0D;AAC1D,mFAA6E;AAC7E,6FAAsF;AACtF,+DAA0D;AAC1D,uEAAiE;AACjE,yEAAmE;AACnE,+EAAyE;AAE5D,QAAA,QAAQ,GAAiB;;;;CAIrC,CAAA;AAEY,QAAA,KAAK,GAAiB;;CAElC,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,wCAAkB;IAClB,+CAAqB;IACrB,uDAAyB;IACzB,iDAAsB;IACtB,wCAAkB;IAClB,2DAA2B;IAC3B,oEAA+B;CAChC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/interface-with-hub/index.ts"],"names":[],"mappings":";;;AAAA,uEAAiE;AACjE,+EAAyE;AACzE,+DAA0D;AAC1D,yEAAmE;AACnE,+DAA0D;AAC1D,mFAA6E;AAC7E,6FAAsF;AAEzE,QAAA,QAAQ,GAAiB;;;;;CAKrC,CAAA;AAEY,QAAA,KAAK,GAAiB;;CAElC,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,wCAAkB;IAClB,+CAAqB;IACrB,uDAAyB;IACzB,iDAAsB;IACtB,wCAAkB;IAClB,2DAA2B;IAC3B,oEAA+B;CAChC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-mms",
3
- "version": "3.8.8",
3
+ "version": "3.8.12",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -61,12 +61,12 @@
61
61
  "@things-factory/integration-fulfillment": "^3.8.3",
62
62
  "@things-factory/integration-lmd": "^3.8.0",
63
63
  "@things-factory/lite-menu": "^3.8.0",
64
- "@things-factory/marketplace-base": "^3.8.5",
64
+ "@things-factory/marketplace-base": "^3.8.12",
65
65
  "@things-factory/more-ui": "^3.8.0",
66
66
  "@things-factory/notification": "^3.8.0",
67
67
  "@things-factory/oauth2-client": "^3.8.0",
68
68
  "@things-factory/pdf": "^3.7.5",
69
- "@things-factory/product-base": "^3.8.3",
69
+ "@things-factory/product-base": "^3.8.9",
70
70
  "@things-factory/resource-ui": "^3.8.0",
71
71
  "@things-factory/scene-chartjs": "^3.7.5",
72
72
  "@things-factory/scene-clock": "^3.7.5",
@@ -99,11 +99,11 @@
99
99
  "@things-factory/scene-wheel-sorter": "^3.7.5",
100
100
  "@things-factory/setting-ui": "^3.8.0",
101
101
  "@things-factory/system-ui": "^3.8.0",
102
- "@things-factory/warehouse-base": "^3.8.8"
102
+ "@things-factory/warehouse-base": "^3.8.12"
103
103
  },
104
104
  "devDependencies": {
105
105
  "@things-factory/builder": "^3.7.5",
106
106
  "@types/node-fetch": "^2.5.7"
107
107
  },
108
- "gitHead": "3f0cf4cd9eba27f4b4a7688c462cc3183dd9df00"
108
+ "gitHead": "8c183f820cce8f335d326ddbc8c7922fb6cf4bde"
109
109
  }
@@ -0,0 +1,99 @@
1
+ import { EntityManager, getRepository, SelectQueryBuilder } from 'typeorm'
2
+
3
+ import { FulfillmentAPI } from '@things-factory/integration-fulfillment'
4
+ import { StoreAPI } from '@things-factory/integration-marketplace'
5
+ import { MarketplaceProductVariation } from '@things-factory/marketplace-base'
6
+ import { Product } from '@things-factory/product-base'
7
+ import { Domain } from '@things-factory/shell'
8
+ import { Inventory } from '@things-factory/warehouse-base'
9
+
10
+ export const autoUpdateAllMarketplaceProductVariationQuantityResolver = {
11
+ async autoUpdateAllMarketplaceProductVariationQuantity(_: any, { companyDomainId, warehouseId }, context: any) {
12
+ try {
13
+ const { tx }: { tx: EntityManager } = context.state
14
+
15
+ const companyDomain: Domain = await getRepository(Domain).findOne(companyDomainId)
16
+
17
+ const productVariations: MarketplaceProductVariation[] = await getRepository(MarketplaceProductVariation).find({
18
+ where: { domain: companyDomain },
19
+ relations: [
20
+ 'marketplaceProduct',
21
+ 'marketplaceProduct.marketplaceStore',
22
+ 'marketplaceProduct.marketplaceStore.marketplaceDistributors',
23
+ 'creator',
24
+ 'updater'
25
+ ]
26
+ })
27
+
28
+ for (var i = 0; i < productVariations.length; i++) {
29
+ const productVariation: MarketplaceProductVariation = productVariations[i]
30
+
31
+ const sku: string = productVariation.sku
32
+
33
+ let warehouseProductQty: number = 0
34
+ if (sku) {
35
+ const fulfilmentCenter = await FulfillmentAPI.getFulfillmentCenter(warehouseId)
36
+ const centerId: string = fulfilmentCenter.centerId
37
+ const warehouseDomain: Domain = await getRepository(Domain).findOne({ where: { subdomain: centerId } })
38
+ const product: Product = await getRepository(Product).findOne({ where: { domain: companyDomain, sku } })
39
+ const qb: SelectQueryBuilder<Inventory> = await getRepository(Inventory).createQueryBuilder('INV')
40
+ qb.select('SUM(INV.qty - INV.locked_qty)', 'remainQty')
41
+ .where('"INV"."domain_id" = :domainId', { domainId: warehouseDomain.id })
42
+ .andWhere('"INV"."product_id" = :productId', { productId: product.id })
43
+ .andWhere('"INV"."status" = :invStatus', { invStatus: 'STORED' })
44
+ .groupBy('"INV".product_id')
45
+
46
+ const item: any = await qb.getRawOne()
47
+ if (item) warehouseProductQty += parseFloat(item.remainQty) || 0
48
+ }
49
+
50
+ const marketplaceStore = productVariation?.marketplaceProduct?.marketplaceStore
51
+ const hasVariation = productVariation?.marketplaceProduct?.hasVariation
52
+
53
+ if (marketplaceStore) {
54
+ //Lazada Product quantity data update -> {sku, qty}
55
+ //Shopee Product quantity data update -> variation = false: {itemId, qty} | variation = true: {itemId, variationId, qty}
56
+
57
+ const productVariationQty: number = productVariation.qty || 0
58
+ const productVariationReserveQty: number = productVariation.reserveQty || 0
59
+
60
+ let adjustQty =
61
+ productVariationQty == warehouseProductQty
62
+ ? productVariationQty - productVariationReserveQty
63
+ : warehouseProductQty - productVariationReserveQty
64
+ let productVariationLocationId = productVariation.locationId
65
+ if (marketplaceStore.platform === 'SHOPIFY') {
66
+ adjustQty = productVariationReserveQty
67
+
68
+ let locationIds: any[] = JSON.parse(productVariationLocationId)
69
+ productVariationLocationId = locationIds[0].location_id
70
+ }
71
+
72
+ if (hasVariation) {
73
+ await StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
74
+ {
75
+ itemId: productVariation.marketplaceProduct.itemId,
76
+ variationId: productVariation.variationId,
77
+ qty: adjustQty,
78
+ locationId: productVariationLocationId,
79
+ inventoryItemId: productVariation.inventoryItemId
80
+ }
81
+ ])
82
+ } else {
83
+ await StoreAPI.updateStoreProductStock(marketplaceStore, [
84
+ {
85
+ itemId: productVariation.marketplaceProduct.itemId,
86
+ variationId: productVariation.variationId,
87
+ variationSku: productVariation.variationSku,
88
+ qty: adjustQty,
89
+ distributors: marketplaceStore.marketplaceDistributors
90
+ }
91
+ ])
92
+ }
93
+ }
94
+ }
95
+
96
+ return true
97
+ } catch (ex) {}
98
+ }
99
+ }
@@ -1,5 +1,6 @@
1
1
  import { addReleaseOrderResolver } from './add-release-order'
2
2
  import { autoAddReleaseOrderResolver } from './auto-add-release-order'
3
+ import { autoUpdateAllMarketplaceProductVariationQuantityResolver } from './auto-update-all-marketplace-product-variation-quantity'
3
4
  import { generateReplenishmentOrderResolver } from './generate-replenishment-order'
4
5
  import { warehouseMarketplaceProduct, warehouseMarketplaceProductsResolver } from './warehouse-marketplace-products'
5
6
 
@@ -10,7 +11,8 @@ export const Query = {
10
11
  export const Mutation = {
11
12
  ...addReleaseOrderResolver,
12
13
  ...autoAddReleaseOrderResolver,
13
- ...generateReplenishmentOrderResolver
14
+ ...generateReplenishmentOrderResolver,
15
+ ...autoUpdateAllMarketplaceProductVariationQuantityResolver
14
16
  }
15
17
 
16
18
  export { warehouseMarketplaceProduct }
@@ -1,8 +1,9 @@
1
+ import { EntityManager } from 'typeorm'
2
+
1
3
  import { User } from '@things-factory/auth-base'
2
4
  import { Bizplace, getCompanyBizplace, getMyBizplace } from '@things-factory/biz-base'
3
5
  import { Product } from '@things-factory/product-base'
4
6
  import { Domain, ListParam } from '@things-factory/shell'
5
- import { EntityManager } from 'typeorm'
6
7
 
7
8
  export const warehouseMarketplaceProductsResolver = {
8
9
  async warehouseMarketplaceProducts(_: any, params: ListParam, context: any): Promise<any> {
@@ -71,7 +72,7 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
71
72
  select "dt"."marketplace_store_id", "dt"."product_id", "dt"."sku", array_agg(row_to_json(dt)) as product_variation
72
73
  from (
73
74
  select "mp"."marketplace_store_id" as "marketplace_store_id", "mpv"."sku", "mpv"."id" as "marketplace_product_variation_id",
74
- concat("mpv"."variation_sku", ' (', "mpv"."name", ')') as "name", "mpv"."qty" as "qty",
75
+ concat("mpv"."variation_sku", ' (', "mpv"."name", ')') as "name", "mpv"."qty" as "qty", "mpv"."reserve_qty" as "reserve_qty",
75
76
  "Product"."product_id" AS "product_id"
76
77
  from marketplace_product_variations "mpv"
77
78
  inner join marketplace_products "mp" on "mp"."id" = "mpv"."marketplace_product_id"
@@ -164,7 +165,8 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
164
165
  return {
165
166
  id: variation.marketplace_product_variation_id,
166
167
  name: variation.name,
167
- qty: variation.qty
168
+ qty: variation.qty,
169
+ reserveQty: variation.reserve_qty
168
170
  }
169
171
  })
170
172
  }
@@ -1,15 +1,16 @@
1
+ import { NewStockReplenishment } from './new-stock-replenishment'
2
+ import { ReplenishmentOrderProduct } from './replenishment-order-product'
3
+ import { StockReplenishment } from './stock-replenishment'
4
+ import { StockReplenishmentList } from './stock-replenishment-list'
1
5
  import { WarehouseInventory } from './warehouse-inventory'
2
6
  import { WarehouseMarketplaceProduct } from './warehouse-marketplace-product'
3
7
  import { WarehouseMarketplaceProductList } from './warehouse-marketplace-product-list'
4
- import { StockReplenishment } from './stock-replenishment'
5
- import { NewStockReplenishment } from './new-stock-replenishment'
6
- import { StockReplenishmentList } from './stock-replenishment-list'
7
- import { ReplenishmentOrderProduct } from './replenishment-order-product'
8
8
 
9
9
  export const Mutation = /* GraphQL */ `
10
10
  addReleaseOrder(marketplaceOrderIds: [String]!, warehouseId: String!): Boolean @transaction
11
11
  autoAddReleaseOrder(warehouseId: String): Boolean @transaction
12
12
  generateReplenishmentOrder(stockReplenishmentId: String!, warehouseId: String!): StockReplenishment @transaction
13
+ autoUpdateAllMarketplaceProductVariationQuantity(companyDomainId: String, warehouseId: String): Boolean @transaction
13
14
  `
14
15
 
15
16
  export const Query = /* GraphQL */ `
@@ -114,6 +114,7 @@
114
114
  "field.required_branch": "required branch",
115
115
  "field.required_sender": "required sender",
116
116
  "field.required_tracking": "required tracking",
117
+ "field.reserve_qty": "reserve qty",
117
118
  "field.ro_created": "ro created",
118
119
  "field.save": "save",
119
120
  "field.seller_shipping_fee_voucher": "seller shipping fee voucher",
@@ -152,6 +153,7 @@
152
153
  "field.variation_marketplace_status": "variation marketplace status",
153
154
  "field.variation_name": "variation name",
154
155
  "field.variation_qty": "variation qty",
156
+ "field.variation_reserve_qty": "variation reserve qty",
155
157
  "field.variation_selling_price": "variation selling price",
156
158
  "field.variation_sku": "variation sku",
157
159
  "field.variation_uom_value": "variation uom value",
@@ -114,6 +114,7 @@
114
114
  "field.required_branch": "[ko] required branch",
115
115
  "field.required_sender": "[ko] required sender",
116
116
  "field.required_tracking": "[ko] required tracking",
117
+ "field.reserve_qty": "[ko] reserve qty",
117
118
  "field.ro_created": "[ko] ro created",
118
119
  "field.save": "[ko] save",
119
120
  "field.seller_shipping_fee_voucher": "[ko] seller shipping fee voucher",
@@ -151,6 +152,7 @@
151
152
  "field.variation_marketplace_status": "[ko] variation marketplace status",
152
153
  "field.variation_name": "[ko] variation name",
153
154
  "field.variation_qty": "[ko] variation qty",
155
+ "field.variation_reserve_qty": "[ko] variation reserve qty",
154
156
  "field.variation_selling_price": "[ko] variation selling price",
155
157
  "field.variation_sku": "[ko] variation sku",
156
158
  "field.variation_uom_value": "[ko] variation uom value",
@@ -114,6 +114,7 @@
114
114
  "field.required_branch": "[ms] required branch",
115
115
  "field.required_sender": "[ms] required sender",
116
116
  "field.required_tracking": "[ms] required tracking",
117
+ "field.reserve_qty": "[ms] reserve qty",
117
118
  "field.ro_created": "[ms] ro created",
118
119
  "field.save": "[ms] save",
119
120
  "field.seller_shipping_fee_voucher": "[ms] seller shipping fee voucher",
@@ -151,6 +152,7 @@
151
152
  "field.variation_marketplace_status": "[ms] variation marketplace status",
152
153
  "field.variation_name": "[ms] variation name",
153
154
  "field.variation_qty": "[ms] variation qty",
155
+ "field.variation_reserve_qty": "[ms] variation reserve qty",
154
156
  "field.variation_selling_price": "[ms] variation selling price",
155
157
  "field.variation_sku": "[ms] variation sku",
156
158
  "field.variation_uom_value": "[ms] variation uom value",
@@ -114,6 +114,7 @@
114
114
  "field.required_branch": "[zh] required branch",
115
115
  "field.required_sender": "[zh] required sender",
116
116
  "field.required_tracking": "[zh] required tracking",
117
+ "field.reserve_qty": "[zh] reserve qty",
117
118
  "field.ro_created": "[zh] ro created",
118
119
  "field.save": "[zh] save",
119
120
  "field.seller_shipping_fee_voucher": "[zh] seller shipping fee voucher",
@@ -151,6 +152,7 @@
151
152
  "field.variation_marketplace_status": "[zh] variation marketplace status",
152
153
  "field.variation_name": "[zh] variation name",
153
154
  "field.variation_qty": "[zh] variation qty",
155
+ "field.variation_reserve_qty": "[zh] variation reserve qty",
154
156
  "field.variation_selling_price": "[zh] variation selling price",
155
157
  "field.variation_sku": "[zh] variation sku",
156
158
  "field.variation_uom_value": "[zh] variation uom value",