@things-factory/marketplace-base 4.3.284 → 4.3.291

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.
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateMultipleMarketplaceProductVariationQuantityResolver = void 0;
4
4
  const integration_marketplace_1 = require("@things-factory/integration-marketplace");
5
- const entities_1 = require("../../../entities");
6
5
  const constants_1 = require("../../../constants");
6
+ const entities_1 = require("../../../entities");
7
7
  exports.updateMultipleMarketplaceProductVariationQuantityResolver = {
8
8
  async updateMultipleMarketplaceProductVariationQuantity(_, { patches }, context) {
9
9
  try {
@@ -34,6 +34,62 @@ exports.updateMultipleMarketplaceProductVariationQuantityResolver = {
34
34
  let locationIds = JSON.parse(productVariationLocationId);
35
35
  productVariationLocationId = locationIds[0].location_id;
36
36
  }
37
+ let validMarketplaceDistributors = [];
38
+ if (marketplaceStore.marketplaceDistributors) {
39
+ validMarketplaceDistributors = marketplaceStore.marketplaceDistributors.filter(distributor => distributor.status === 'ACTIVE');
40
+ }
41
+ if (marketplaceStore.platform == 'magento' && (validMarketplaceDistributors === null || validMarketplaceDistributors === void 0 ? void 0 : validMarketplaceDistributors.length) > 0) {
42
+ if (hasVariation) {
43
+ await integration_marketplace_1.StoreAPI.updateStoreProductVariationInventoryItem(marketplaceStore, [
44
+ {
45
+ itemId: productVariation.marketplaceProduct.itemId,
46
+ variationId: productVariation.variationId,
47
+ variationSku: productVariation.variationSku,
48
+ qty: adjustQty,
49
+ locationId: productVariationLocationId,
50
+ inventoryItemId: productVariation.inventoryItemId,
51
+ distributors: validMarketplaceDistributors
52
+ }
53
+ ]);
54
+ }
55
+ else {
56
+ await integration_marketplace_1.StoreAPI.updateStoreProductInventoryItem(marketplaceStore, [
57
+ {
58
+ itemId: productVariation.marketplaceProduct.itemId,
59
+ variationId: productVariation.variationId,
60
+ variationSku: productVariation.variationSku,
61
+ qty: adjustQty,
62
+ distributors: validMarketplaceDistributors
63
+ }
64
+ ]);
65
+ }
66
+ }
67
+ else {
68
+ if (hasVariation) {
69
+ await integration_marketplace_1.StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
70
+ {
71
+ itemId: productVariation.marketplaceProduct.itemId,
72
+ variationId: productVariation.variationId,
73
+ variationSku: productVariation.variationSku,
74
+ qty: adjustQty,
75
+ locationId: productVariationLocationId,
76
+ inventoryItemId: productVariation.inventoryItemId,
77
+ distributors: validMarketplaceDistributors
78
+ }
79
+ ]);
80
+ }
81
+ else {
82
+ await integration_marketplace_1.StoreAPI.updateStoreProductStock(marketplaceStore, [
83
+ {
84
+ itemId: productVariation.marketplaceProduct.itemId,
85
+ variationId: productVariation.variationId,
86
+ variationSku: productVariation.variationSku,
87
+ qty: adjustQty,
88
+ distributors: validMarketplaceDistributors
89
+ }
90
+ ]);
91
+ }
92
+ }
37
93
  if (hasVariation) {
38
94
  await integration_marketplace_1.StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
39
95
  {
@@ -1 +1 @@
1
- {"version":3,"file":"update-multiple-marketplace-product-variation-quantity.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/marketplace-product-variation/update-multiple-marketplace-product-variation-quantity.ts"],"names":[],"mappings":";;;AAAA,qFAAkE;AAElE,gDAA+D;AAC/D,kDAAyD;AAE5C,QAAA,yDAAyD,GAAG;IACvE,KAAK,CAAC,iDAAiD,CAAC,CAAM,EAAE,EAAE,OAAO,EAAE,EAAE,OAAY;QACvF,IAAI;YACF,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gBACjC,MAAM,EAAE,EAAE,EAAE,GAA0B,OAAO,CAAC,KAAK,CAAA;gBAEnD,MAAM,OAAO,CAAC,GAAG,CACf,OAAO,CAAC,GAAG,CAAC,KAAK,EAAC,GAAG,EAAC,EAAE;;oBACtB,MAAM,oBAAoB,GAAG,EAAE,CAAC,aAAa,CAAC,sCAA2B,CAAC,CAAA;oBAE1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,uBAAuB,CAAC,gBAAgB,EAAE;gCACvD;oCACE,MAAM,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,MAAM;oCAClD,WAAW,EAAE,gBAAgB,CAAC,WAAW;oCACzC,YAAY,EAAE,gBAAgB,CAAC,YAAY;oCAC3C,GAAG,EAAE,SAAS;oCACd,YAAY,EAAE,gBAAgB,CAAC,uBAAuB;iCACvD;6BACF,CAAC,CAAA;yBACH;wBACD,MAAM,oBAAoB,CAAC,IAAI,iCAAM,gBAAgB,KAAE,GAAG,EAAE,GAAG,CAAC,GAAG,IAAG,CAAA;qBACvE;gBACH,CAAC,CAAC,CACH,CAAA;gBAED,OAAO,IAAI,CAAA;aACZ;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;aAClC;SACF;QAAC,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,CAAA;SACT;IACH,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"update-multiple-marketplace-product-variation-quantity.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/marketplace-product-variation/update-multiple-marketplace-product-variation-quantity.ts"],"names":[],"mappings":";;;AAEA,qFAAkE;AAElE,kDAAyD;AACzD,gDAA+D;AAElD,QAAA,yDAAyD,GAAG;IACvE,KAAK,CAAC,iDAAiD,CAAC,CAAM,EAAE,EAAE,OAAO,EAAE,EAAE,OAAY;QACvF,IAAI;YACF,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gBACjC,MAAM,EAAE,EAAE,EAAE,GAA0B,OAAO,CAAC,KAAK,CAAA;gBAEnD,MAAM,OAAO,CAAC,GAAG,CACf,OAAO,CAAC,GAAG,CAAC,KAAK,EAAC,GAAG,EAAC,EAAE;;oBACtB,MAAM,oBAAoB,GAAG,EAAE,CAAC,aAAa,CAAC,sCAA2B,CAAC,CAAA;oBAE1E,IAAI,gBAAgB,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC;wBACxD,KAAK,EAAE,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AE,4BAA4B;qCAC3C;iCACF,CAAC,CAAA;6BACH;yBACF;wBAED,IAAI,YAAY,EAAE;4BAChB,MAAM,kCAAQ,CAAC,gCAAgC,CAAC,gBAAgB,EAAE;gCAChE;oCACE,MAAM,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,MAAM;oCAClD,WAAW,EAAE,gBAAgB,CAAC,WAAW;oCACzC,GAAG,EAAE,SAAS;oCACd,UAAU,EAAE,0BAA0B;oCACtC,eAAe,EAAE,gBAAgB,CAAC,eAAe;iCAClD;6BACF,CAAC,CAAA;yBACH;6BAAM;4BACL,MAAM,kCAAQ,CAAC,uBAAuB,CAAC,gBAAgB,EAAE;gCACvD;oCACE,MAAM,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,MAAM;oCAClD,WAAW,EAAE,gBAAgB,CAAC,WAAW;oCACzC,YAAY,EAAE,gBAAgB,CAAC,YAAY;oCAC3C,GAAG,EAAE,SAAS;oCACd,YAAY,EAAE,gBAAgB,CAAC,uBAAuB;iCACvD;6BACF,CAAC,CAAA;yBACH;wBACD,MAAM,oBAAoB,CAAC,IAAI,iCAAM,gBAAgB,KAAE,GAAG,EAAE,GAAG,CAAC,GAAG,IAAG,CAAA;qBACvE;gBACH,CAAC,CAAC,CACH,CAAA;gBAED,OAAO,IAAI,CAAA;aACZ;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;aAClC;SACF;QAAC,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,CAAA;SACT;IACH,CAAC;CACF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/marketplace-base",
3
- "version": "4.3.284",
3
+ "version": "4.3.291",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,9 +24,9 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@things-factory/integration-fulfillment": "^4.3.281",
27
- "@things-factory/integration-marketplace": "^4.3.284",
28
- "@things-factory/product-base": "^4.3.281",
27
+ "@things-factory/integration-marketplace": "^4.3.286",
28
+ "@things-factory/product-base": "^4.3.291",
29
29
  "@things-factory/shell": "^4.3.281"
30
30
  },
31
- "gitHead": "a50c16ae136f288fc1a1bf02859b03c4bd82aaeb"
31
+ "gitHead": "9c051f9164b7068f75f386f3c013c24193c6ca5c"
32
32
  }
@@ -1,7 +1,9 @@
1
- import { StoreAPI } from '@things-factory/integration-marketplace'
2
1
  import { EntityManager } from 'typeorm'
3
- import { MarketplaceProductVariation } from '../../../entities'
2
+
3
+ import { StoreAPI } from '@things-factory/integration-marketplace'
4
+
4
5
  import { MARKETPLACE_PLATFORM } from '../../../constants'
6
+ import { MarketplaceProductVariation } from '../../../entities'
5
7
 
6
8
  export const updateMultipleMarketplaceProductVariationQuantityResolver = {
7
9
  async updateMultipleMarketplaceProductVariationQuantity(_: any, { patches }, context: any) {
@@ -39,6 +41,63 @@ export const updateMultipleMarketplaceProductVariationQuantityResolver = {
39
41
  productVariationLocationId = locationIds[0].location_id
40
42
  }
41
43
 
44
+ let validMarketplaceDistributors: any[] = []
45
+ if (marketplaceStore.marketplaceDistributors) {
46
+ validMarketplaceDistributors = marketplaceStore.marketplaceDistributors.filter(
47
+ distributor => distributor.status === 'ACTIVE'
48
+ )
49
+ }
50
+
51
+ if (marketplaceStore.platform == 'magento' && validMarketplaceDistributors?.length > 0) {
52
+ if (hasVariation) {
53
+ await StoreAPI.updateStoreProductVariationInventoryItem(marketplaceStore, [
54
+ {
55
+ itemId: productVariation.marketplaceProduct.itemId,
56
+ variationId: productVariation.variationId,
57
+ variationSku: productVariation.variationSku,
58
+ qty: adjustQty,
59
+ locationId: productVariationLocationId,
60
+ inventoryItemId: productVariation.inventoryItemId,
61
+ distributors: validMarketplaceDistributors
62
+ }
63
+ ])
64
+ } else {
65
+ await StoreAPI.updateStoreProductInventoryItem(marketplaceStore, [
66
+ {
67
+ itemId: productVariation.marketplaceProduct.itemId,
68
+ variationId: productVariation.variationId,
69
+ variationSku: productVariation.variationSku,
70
+ qty: adjustQty,
71
+ distributors: validMarketplaceDistributors
72
+ }
73
+ ])
74
+ }
75
+ } else {
76
+ if (hasVariation) {
77
+ await StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
78
+ {
79
+ itemId: productVariation.marketplaceProduct.itemId,
80
+ variationId: productVariation.variationId,
81
+ variationSku: productVariation.variationSku,
82
+ qty: adjustQty,
83
+ locationId: productVariationLocationId,
84
+ inventoryItemId: productVariation.inventoryItemId,
85
+ distributors: validMarketplaceDistributors
86
+ }
87
+ ])
88
+ } else {
89
+ await StoreAPI.updateStoreProductStock(marketplaceStore, [
90
+ {
91
+ itemId: productVariation.marketplaceProduct.itemId,
92
+ variationId: productVariation.variationId,
93
+ variationSku: productVariation.variationSku,
94
+ qty: adjustQty,
95
+ distributors: validMarketplaceDistributors
96
+ }
97
+ ])
98
+ }
99
+ }
100
+
42
101
  if (hasVariation) {
43
102
  await StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
44
103
  {