@things-factory/operato-mms 4.1.19 → 4.1.22
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.
- package/client/pages/order/logistics/request-ro-popup.js +7 -4
- package/dist-server/graphql/resolvers/interface-with-hub/auto-update-all-marketplace-product-variation-quantity.js +36 -31
- package/dist-server/graphql/resolvers/interface-with-hub/auto-update-all-marketplace-product-variation-quantity.js.map +1 -1
- package/dist-server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.js.map +1 -1
- package/package.json +31 -31
- package/server/graphql/resolvers/interface-with-hub/auto-update-all-marketplace-product-variation-quantity.ts +43 -38
- package/server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.ts +31 -26
|
@@ -451,11 +451,14 @@ class RequestROPopup extends LitElement {
|
|
|
451
451
|
let marketplaceOrderShippings = []
|
|
452
452
|
|
|
453
453
|
marketplaceOrderItems.map(item => {
|
|
454
|
-
const
|
|
454
|
+
const marketplaceOrderShippingItems = item.marketplaceOrderShippingItems
|
|
455
|
+
marketplaceOrderShippingItems.map(itm => {
|
|
456
|
+
const marketplaceOrderShipping = itm.marketplaceOrderShipping
|
|
455
457
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
458
|
+
if (marketplaceOrderShipping) {
|
|
459
|
+
marketplaceOrderShippings.push(marketplaceOrderShipping)
|
|
460
|
+
}
|
|
461
|
+
})
|
|
459
462
|
})
|
|
460
463
|
|
|
461
464
|
const uniqueMarketplaceOrderShippings = Array.from(new Set(marketplaceOrderShippings.map(a => a.id))).map(id => {
|
|
@@ -65,7 +65,7 @@ exports.autoUpdateAllMarketplaceProductVariationQuantityResolver = {
|
|
|
65
65
|
for (let i = 0; i < marketplaceStores.length; i++) {
|
|
66
66
|
try {
|
|
67
67
|
const marketplaceStore = marketplaceStores[i];
|
|
68
|
-
const marketplaceSetting = await (0, typeorm_1.getRepository)(
|
|
68
|
+
const marketplaceSetting = await (0, typeorm_1.getRepository)(integration_marketplace_1.MarketplaceSetting).findOne({
|
|
69
69
|
where: { marketplaceStore, category: 'stock_allocation' }
|
|
70
70
|
});
|
|
71
71
|
for (let j = 0; j < inventoryProducts.length; j++) {
|
|
@@ -78,42 +78,47 @@ exports.autoUpdateAllMarketplaceProductVariationQuantityResolver = {
|
|
|
78
78
|
where: { domain: companyDomain, sku: inventoryProduct.sku },
|
|
79
79
|
relations: ['marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
80
80
|
});
|
|
81
|
-
let
|
|
81
|
+
let storeProductVariations = marketplaceProductVariations.filter(productVariation => productVariation.marketplaceProduct.marketplaceStore.id === marketplaceStore.id);
|
|
82
82
|
let percentageValue = 100;
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
let
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (marketplaceStore.marketplaceDistributors) {
|
|
97
|
-
validMarketplaceDistributors = marketplaceStore.marketplaceDistributors.filter(distributor => distributor.status === 'ACTIVE');
|
|
98
|
-
}
|
|
99
|
-
await integration_marketplace_1.StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
|
|
100
|
-
{
|
|
101
|
-
itemId: marketplaceProductVariation.marketplaceProduct.itemId,
|
|
102
|
-
variationId: marketplaceProductVariation.variationId,
|
|
103
|
-
variationSku: marketplaceProductVariation.variationSku,
|
|
104
|
-
qty: adjustQty,
|
|
105
|
-
locationId: productVariationLocationId,
|
|
106
|
-
inventoryItemId: marketplaceProductVariation.inventoryItemId,
|
|
107
|
-
distributors: validMarketplaceDistributors
|
|
83
|
+
if (storeProductVariations) {
|
|
84
|
+
for (let k = 0; k < storeProductVariations.length; k++) {
|
|
85
|
+
let storeProductVariation = storeProductVariations[k];
|
|
86
|
+
if (marketplaceSetting) {
|
|
87
|
+
percentageValue = parseInt(marketplaceSetting.value);
|
|
88
|
+
}
|
|
89
|
+
let productVariationLocationId = storeProductVariation === null || storeProductVariation === void 0 ? void 0 : storeProductVariation.locationId;
|
|
90
|
+
let adjustQty = Math.floor((inventoryProduct.qty - storeProductVariation.reserveQty) * (percentageValue / 100));
|
|
91
|
+
if (marketplaceStore.platform === 'shopify') {
|
|
92
|
+
let locationIds = JSON.parse(productVariationLocationId);
|
|
93
|
+
adjustQty = adjustQty - storeProductVariation.qty;
|
|
94
|
+
if ((_a = locationIds[0]) === null || _a === void 0 ? void 0 : _a.location_id)
|
|
95
|
+
productVariationLocationId = locationIds[0].location_id;
|
|
108
96
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
97
|
+
let validMarketplaceDistributors = [];
|
|
98
|
+
if (marketplaceStore.marketplaceDistributors) {
|
|
99
|
+
validMarketplaceDistributors = marketplaceStore.marketplaceDistributors.filter(distributor => distributor.status === 'ACTIVE');
|
|
100
|
+
}
|
|
101
|
+
await integration_marketplace_1.StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
|
|
102
|
+
{
|
|
103
|
+
itemId: storeProductVariation.marketplaceProduct.itemId,
|
|
104
|
+
variationId: storeProductVariation.variationId,
|
|
105
|
+
variationSku: storeProductVariation.variationSku,
|
|
106
|
+
qty: adjustQty,
|
|
107
|
+
locationId: productVariationLocationId,
|
|
108
|
+
inventoryItemId: storeProductVariation.inventoryItemId,
|
|
109
|
+
distributors: validMarketplaceDistributors
|
|
110
|
+
}
|
|
111
|
+
]);
|
|
112
|
+
storeProductVariation.qty = Math.floor(inventoryProduct.qty * (percentageValue / 100));
|
|
113
|
+
await tx.getRepository(marketplace_base_1.MarketplaceProductVariation).save(storeProductVariation);
|
|
114
|
+
}
|
|
112
115
|
}
|
|
113
116
|
});
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
|
-
catch (e) {
|
|
119
|
+
catch (e) {
|
|
120
|
+
console.log(e);
|
|
121
|
+
}
|
|
117
122
|
}
|
|
118
123
|
return true;
|
|
119
124
|
}
|
|
@@ -1 +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,qCAAsD;AAEtD,qFAAwE;AACxE,
|
|
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,qCAAsD;AAEtD,qFAAwE;AACxE,qFAAwG;AACxG,uEAA8E;AAC9E,+DAAqE;AACrE,iDAA8C;AAC9C,mEAAsH;AAEzG,QAAA,wDAAwD,GAAG;IACtE,KAAK,CAAC,gDAAgD,CAAC,CAAM,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE,EAAE,OAAY;QAC3G,MAAM,aAAa,GAAW,MAAM,IAAA,uBAAa,EAAC,cAAM,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QAElF,MAAM,iBAAiB,GAAuB,MAAM,IAAA,uBAAa,EAAC,0CAAgB,CAAC,CAAC,IAAI,CAAC;YACvF,KAAK,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE;YAClD,SAAS,EAAE,CAAC,yBAAyB,CAAC;SACvC,CAAC,CAAA;QAEF,MAAM,gBAAgB,GAAG,MAAM,wCAAc,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAA;QAC/E,MAAM,QAAQ,GAAW,gBAAgB,CAAC,QAAQ,CAAA;QAClD,MAAM,eAAe,GAAW,MAAM,IAAA,uBAAa,EAAC,cAAM,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;QAEvG,IAAI,QAAQ,GAAc,MAAM,IAAA,uBAAa,EAAC,sBAAO,CAAC,CAAC,IAAI,CA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1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warehouse-marketplace-products.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.ts"],"names":[],"mappings":";;;AAGA,uDAAsF;
|
|
1
|
+
{"version":3,"file":"warehouse-marketplace-products.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.ts"],"names":[],"mappings":";;;AAGA,uDAAsF;AAGzE,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,EAA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,EAAE,SAAS,CAAC,GAAG;oCAClB,UAAU,EAAE,SAAS,CAAC,WAAW;iCAClC,CAAA;4BACH,CAAC,CAAC;yBACH,CAAA;oBACH,CAAC,CAAC;oBACJ,CAAC,CAAC,IAAI;gBACR,kBAAkB,EAAE,GAAG,CAAC,uBAAuB;oBAC7C,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;AAzND,kEAyNC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-mms",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.22",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -60,50 +60,50 @@
|
|
|
60
60
|
"@operato/scene-table": "^0.1.5",
|
|
61
61
|
"@operato/scene-timer": "^0.1.5",
|
|
62
62
|
"@operato/scene-wheel-sorter": "^0.1.5",
|
|
63
|
-
"@things-factory/apptool-ui": "^4.1.
|
|
64
|
-
"@things-factory/attachment-base": "^4.1.
|
|
65
|
-
"@things-factory/auth-ui": "^4.1.
|
|
66
|
-
"@things-factory/biz-base": "^4.1.
|
|
67
|
-
"@things-factory/board-service": "^4.1.
|
|
68
|
-
"@things-factory/board-ui": "^4.1.
|
|
69
|
-
"@things-factory/code-ui": "^4.1.
|
|
70
|
-
"@things-factory/context-ui": "^4.1.
|
|
71
|
-
"@things-factory/dashboard": "^4.1.
|
|
72
|
-
"@things-factory/export-ui": "^4.1.
|
|
73
|
-
"@things-factory/export-ui-csv": "^4.1.
|
|
74
|
-
"@things-factory/export-ui-excel": "^4.1.
|
|
75
|
-
"@things-factory/geography": "^4.1.
|
|
76
|
-
"@things-factory/grist-ui": "^4.1.
|
|
77
|
-
"@things-factory/help": "^4.1.
|
|
78
|
-
"@things-factory/i18n-base": "^4.1.
|
|
79
|
-
"@things-factory/integration-fulfillment": "^4.1.
|
|
80
|
-
"@things-factory/integration-lmd": "^4.1.
|
|
81
|
-
"@things-factory/lite-menu": "^4.1.
|
|
82
|
-
"@things-factory/marketplace-base": "^4.1.
|
|
83
|
-
"@things-factory/more-ui": "^4.1.
|
|
84
|
-
"@things-factory/notification": "^4.1.
|
|
85
|
-
"@things-factory/oauth2-client": "^4.1.
|
|
63
|
+
"@things-factory/apptool-ui": "^4.1.22",
|
|
64
|
+
"@things-factory/attachment-base": "^4.1.22",
|
|
65
|
+
"@things-factory/auth-ui": "^4.1.22",
|
|
66
|
+
"@things-factory/biz-base": "^4.1.22",
|
|
67
|
+
"@things-factory/board-service": "^4.1.22",
|
|
68
|
+
"@things-factory/board-ui": "^4.1.22",
|
|
69
|
+
"@things-factory/code-ui": "^4.1.22",
|
|
70
|
+
"@things-factory/context-ui": "^4.1.22",
|
|
71
|
+
"@things-factory/dashboard": "^4.1.22",
|
|
72
|
+
"@things-factory/export-ui": "^4.1.22",
|
|
73
|
+
"@things-factory/export-ui-csv": "^4.1.22",
|
|
74
|
+
"@things-factory/export-ui-excel": "^4.1.22",
|
|
75
|
+
"@things-factory/geography": "^4.1.22",
|
|
76
|
+
"@things-factory/grist-ui": "^4.1.22",
|
|
77
|
+
"@things-factory/help": "^4.1.22",
|
|
78
|
+
"@things-factory/i18n-base": "^4.1.22",
|
|
79
|
+
"@things-factory/integration-fulfillment": "^4.1.22",
|
|
80
|
+
"@things-factory/integration-lmd": "^4.1.22",
|
|
81
|
+
"@things-factory/lite-menu": "^4.1.22",
|
|
82
|
+
"@things-factory/marketplace-base": "^4.1.22",
|
|
83
|
+
"@things-factory/more-ui": "^4.1.22",
|
|
84
|
+
"@things-factory/notification": "^4.1.22",
|
|
85
|
+
"@things-factory/oauth2-client": "^4.1.22",
|
|
86
86
|
"@things-factory/pdf": "^4.1.19",
|
|
87
|
-
"@things-factory/product-base": "^4.1.
|
|
88
|
-
"@things-factory/resource-ui": "^4.1.
|
|
87
|
+
"@things-factory/product-base": "^4.1.22",
|
|
88
|
+
"@things-factory/resource-ui": "^4.1.22",
|
|
89
89
|
"@things-factory/scene-data-transform": "^4.1.19",
|
|
90
90
|
"@things-factory/scene-excel": "^4.1.19",
|
|
91
91
|
"@things-factory/scene-firebase": "^4.1.19",
|
|
92
92
|
"@things-factory/scene-form": "^4.1.19",
|
|
93
93
|
"@things-factory/scene-google-map": "^4.1.19",
|
|
94
94
|
"@things-factory/scene-graphql": "^4.1.19",
|
|
95
|
-
"@things-factory/scene-label": "^4.1.
|
|
95
|
+
"@things-factory/scene-label": "^4.1.22",
|
|
96
96
|
"@things-factory/scene-marker": "^4.1.19",
|
|
97
97
|
"@things-factory/scene-mqtt": "^4.1.19",
|
|
98
98
|
"@things-factory/scene-restful": "^4.1.19",
|
|
99
99
|
"@things-factory/scene-visualizer": "^4.1.19",
|
|
100
|
-
"@things-factory/setting-ui": "^4.1.
|
|
101
|
-
"@things-factory/system-ui": "^4.1.
|
|
102
|
-
"@things-factory/warehouse-base": "^4.1.
|
|
100
|
+
"@things-factory/setting-ui": "^4.1.22",
|
|
101
|
+
"@things-factory/system-ui": "^4.1.22",
|
|
102
|
+
"@things-factory/warehouse-base": "^4.1.22"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@things-factory/builder": "^4.1.19",
|
|
106
106
|
"@types/node-fetch": "^2.5.7"
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "e40b890d9a573562872298a6b79b26f600f607bf"
|
|
109
109
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getConnection, getRepository } from 'typeorm'
|
|
2
2
|
|
|
3
3
|
import { FulfillmentAPI } from '@things-factory/integration-fulfillment'
|
|
4
|
-
import { MarketplaceStore, StoreAPI } from '@things-factory/integration-marketplace'
|
|
5
|
-
import { MarketplaceProductVariation
|
|
4
|
+
import { MarketplaceSetting, MarketplaceStore, StoreAPI } from '@things-factory/integration-marketplace'
|
|
5
|
+
import { MarketplaceProductVariation } from '@things-factory/marketplace-base'
|
|
6
6
|
import { Product, ProductDetail } from '@things-factory/product-base'
|
|
7
7
|
import { Domain } from '@things-factory/shell'
|
|
8
8
|
import { getProductBundleInventory, Inventory, INVENTORY_STATUS, LOCATION_TYPE } from '@things-factory/warehouse-base'
|
|
@@ -17,7 +17,6 @@ export const autoUpdateAllMarketplaceProductVariationQuantityResolver = {
|
|
|
17
17
|
})
|
|
18
18
|
|
|
19
19
|
const fulfilmentCenter = await FulfillmentAPI.getFulfillmentCenter(warehouseId)
|
|
20
|
-
|
|
21
20
|
const centerId: string = fulfilmentCenter.centerId
|
|
22
21
|
const warehouseDomain: Domain = await getRepository(Domain).findOne({ where: { subdomain: centerId } })
|
|
23
22
|
|
|
@@ -84,6 +83,7 @@ export const autoUpdateAllMarketplaceProductVariationQuantityResolver = {
|
|
|
84
83
|
for (let i = 0; i < marketplaceStores.length; i++) {
|
|
85
84
|
try {
|
|
86
85
|
const marketplaceStore: MarketplaceStore = marketplaceStores[i]
|
|
86
|
+
|
|
87
87
|
const marketplaceSetting: MarketplaceSetting = await getRepository(MarketplaceSetting).findOne({
|
|
88
88
|
where: { marketplaceStore, category: 'stock_allocation' }
|
|
89
89
|
})
|
|
@@ -98,52 +98,57 @@ export const autoUpdateAllMarketplaceProductVariationQuantityResolver = {
|
|
|
98
98
|
relations: ['marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
99
99
|
})
|
|
100
100
|
|
|
101
|
-
let
|
|
101
|
+
let storeProductVariations: MarketplaceProductVariation[] = marketplaceProductVariations.filter(
|
|
102
102
|
productVariation => productVariation.marketplaceProduct.marketplaceStore.id === marketplaceStore.id
|
|
103
|
-
)
|
|
103
|
+
)
|
|
104
104
|
|
|
105
105
|
let percentageValue: number = 100
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
let adjustQty: number = Math.floor(
|
|
113
|
-
(inventoryProduct.qty - marketplaceProductVariation.reserveQty) * (percentageValue / 100)
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
if (marketplaceStore.platform === 'shopify') {
|
|
117
|
-
let locationIds: any[] = JSON.parse(productVariationLocationId)
|
|
118
|
-
adjustQty = adjustQty - marketplaceProductVariation.qty
|
|
119
|
-
if (locationIds[0]?.location_id) productVariationLocationId = locationIds[0].location_id
|
|
120
|
-
}
|
|
106
|
+
if (storeProductVariations) {
|
|
107
|
+
for (let k = 0; k < storeProductVariations.length; k++) {
|
|
108
|
+
let storeProductVariation: MarketplaceProductVariation = storeProductVariations[k]
|
|
109
|
+
if (marketplaceSetting) {
|
|
110
|
+
percentageValue = parseInt(marketplaceSetting.value)
|
|
111
|
+
}
|
|
121
112
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
distributor => distributor.status === 'ACTIVE'
|
|
113
|
+
let productVariationLocationId = storeProductVariation?.locationId
|
|
114
|
+
let adjustQty: number = Math.floor(
|
|
115
|
+
(inventoryProduct.qty - storeProductVariation.reserveQty) * (percentageValue / 100)
|
|
126
116
|
)
|
|
127
|
-
}
|
|
128
117
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
variationSku: marketplaceProductVariation.variationSku,
|
|
134
|
-
qty: adjustQty,
|
|
135
|
-
locationId: productVariationLocationId,
|
|
136
|
-
inventoryItemId: marketplaceProductVariation.inventoryItemId,
|
|
137
|
-
distributors: validMarketplaceDistributors
|
|
118
|
+
if (marketplaceStore.platform === 'shopify') {
|
|
119
|
+
let locationIds: any[] = JSON.parse(productVariationLocationId)
|
|
120
|
+
adjustQty = adjustQty - storeProductVariation.qty
|
|
121
|
+
if (locationIds[0]?.location_id) productVariationLocationId = locationIds[0].location_id
|
|
138
122
|
}
|
|
139
|
-
])
|
|
140
123
|
|
|
141
|
-
|
|
142
|
-
|
|
124
|
+
let validMarketplaceDistributors: any[] = []
|
|
125
|
+
if (marketplaceStore.marketplaceDistributors) {
|
|
126
|
+
validMarketplaceDistributors = marketplaceStore.marketplaceDistributors.filter(
|
|
127
|
+
distributor => distributor.status === 'ACTIVE'
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
await StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
|
|
132
|
+
{
|
|
133
|
+
itemId: storeProductVariation.marketplaceProduct.itemId,
|
|
134
|
+
variationId: storeProductVariation.variationId,
|
|
135
|
+
variationSku: storeProductVariation.variationSku,
|
|
136
|
+
qty: adjustQty,
|
|
137
|
+
locationId: productVariationLocationId,
|
|
138
|
+
inventoryItemId: storeProductVariation.inventoryItemId,
|
|
139
|
+
distributors: validMarketplaceDistributors
|
|
140
|
+
}
|
|
141
|
+
])
|
|
142
|
+
|
|
143
|
+
storeProductVariation.qty = Math.floor(inventoryProduct.qty * (percentageValue / 100))
|
|
144
|
+
await tx.getRepository(MarketplaceProductVariation).save(storeProductVariation)
|
|
145
|
+
}
|
|
143
146
|
}
|
|
144
147
|
})
|
|
145
148
|
}
|
|
146
|
-
} catch (e) {
|
|
149
|
+
} catch (e) {
|
|
150
|
+
console.log(e)
|
|
151
|
+
}
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
return true
|
|
@@ -2,7 +2,6 @@ import { EntityManager } from 'typeorm'
|
|
|
2
2
|
|
|
3
3
|
import { User } from '@things-factory/auth-base'
|
|
4
4
|
import { Bizplace, getCompanyBizplace, getMyBizplace } from '@things-factory/biz-base'
|
|
5
|
-
import { Product } from '@things-factory/product-base'
|
|
6
5
|
import { Domain, ListParam } from '@things-factory/shell'
|
|
7
6
|
|
|
8
7
|
export const warehouseMarketplaceProductsResolver = {
|
|
@@ -66,7 +65,8 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
|
|
|
66
65
|
)
|
|
67
66
|
`)
|
|
68
67
|
|
|
69
|
-
await tx.query(
|
|
68
|
+
await tx.query(
|
|
69
|
+
`
|
|
70
70
|
CREATE TEMP TABLE "temp_inventory" ON COMMIT DROP AS (
|
|
71
71
|
select "fc"."id" as "fulfillment_id", "fc"."name" as "fulfillment_name",
|
|
72
72
|
"i2"."product_id", SUM(greatest(coalesce("locked_qty",0),0) + greatest(coalesce(oi.release_qty,0),0)) as "inventory_locked_qty", sum(coalesce("qty",0)) as "inventory_qty",
|
|
@@ -108,7 +108,9 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
|
|
|
108
108
|
and "i2"."status" = 'STORED'
|
|
109
109
|
group by "i2"."domain_id", "fc"."id", "fc"."name", "i2"."product_id"
|
|
110
110
|
)
|
|
111
|
-
`,
|
|
111
|
+
`,
|
|
112
|
+
[domain.id]
|
|
113
|
+
)
|
|
112
114
|
|
|
113
115
|
await tx.query(`
|
|
114
116
|
CREATE TEMP TABLE "temp_json_warehouse_marketplace_products" ON COMMIT DROP AS (
|
|
@@ -127,7 +129,8 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
|
|
|
127
129
|
)
|
|
128
130
|
`)
|
|
129
131
|
|
|
130
|
-
await tx.query(
|
|
132
|
+
await tx.query(
|
|
133
|
+
`
|
|
131
134
|
CREATE TEMP TABLE temp_json_warehouse_inventory ON COMMIT DROP AS (
|
|
132
135
|
select "product_id", array_to_json(array_agg((row_to_json("dt")))) AS "Json_warehouseInventory" from(
|
|
133
136
|
select "domain_id", "fulfillment_id", "fulfillment_name",
|
|
@@ -152,7 +155,9 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
|
|
|
152
155
|
group by "domain_id","fulfillment_id","fulfillment_name","product_id"
|
|
153
156
|
) "dt" group by "dt"."product_id"
|
|
154
157
|
)
|
|
155
|
-
`,
|
|
158
|
+
`,
|
|
159
|
+
[domain.id]
|
|
160
|
+
)
|
|
156
161
|
|
|
157
162
|
await tx.query(`
|
|
158
163
|
CREATE TEMP TABLE temp_warehouse_marketplace_products ON COMMIT DROP as (
|
|
@@ -198,30 +203,30 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
|
|
|
198
203
|
description: itm.Product_description,
|
|
199
204
|
marketplaceProduct: itm.Json_marketplaceProducts
|
|
200
205
|
? itm.Json_marketplaceProducts.map(product => {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
206
|
+
return {
|
|
207
|
+
marketplaceStore: { id: product.marketplace_store_id },
|
|
208
|
+
marketplaceProductVariations: product.product_variation.map(variation => {
|
|
209
|
+
return {
|
|
210
|
+
id: variation.marketplace_product_variation_id,
|
|
211
|
+
name: variation.name,
|
|
212
|
+
qty: variation.qty,
|
|
213
|
+
reserveQty: variation.reserve_qty
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
}
|
|
217
|
+
})
|
|
213
218
|
: null,
|
|
214
219
|
warehouseInventory: itm.Json_warehouseInventory
|
|
215
220
|
? itm.Json_warehouseInventory.map(inventory => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
return {
|
|
222
|
+
bizplace: { id: inventory.fulfillment_id, name: inventory.fulfillment_name },
|
|
223
|
+
product: { id: inventory.product_id },
|
|
224
|
+
qty: inventory.inventory_qty,
|
|
225
|
+
lockedQty: inventory.inventory_locked_qty ? inventory.inventory_locked_qty : 0,
|
|
226
|
+
remainQty:
|
|
227
|
+
inventory.inventory_qty - (inventory.inventory_locked_qty ? inventory.inventory_locked_qty : 0)
|
|
228
|
+
}
|
|
229
|
+
})
|
|
225
230
|
: null
|
|
226
231
|
}
|
|
227
232
|
}),
|