@things-factory/operato-mms 3.8.10 → 3.8.11

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
@@ -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,qFAAwE;AACxE,qFAAkE;AAClE,uEAA8E;AAC9E,+DAAsD;AACtD,iDAA8C;AAC9C,mEAA0D;AAE7C,QAAA,wDAAwD,GAAG;IACtE,KAAK,CAAC,gDAAgD,CAAC,CAAM,EAAE,EAAE,eAAe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,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"}
@@ -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.10",
3
+ "version": "3.8.11",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -61,7 +61,7 @@
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.10",
64
+ "@things-factory/marketplace-base": "^3.8.11",
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",
@@ -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.10"
102
+ "@things-factory/warehouse-base": "^3.8.11"
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": "94812199ec2098fe7f9ea7ad362399b09263ebf7"
108
+ "gitHead": "51a06e6d4eb042a47f8ef82b44bec4568feba1f0"
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,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 */ `
@@ -152,6 +152,7 @@
152
152
  "field.variation_marketplace_status": "variation marketplace status",
153
153
  "field.variation_name": "variation name",
154
154
  "field.variation_qty": "variation qty",
155
+ "field.variation_reserve_qty": "variation reserve qty",
155
156
  "field.variation_selling_price": "variation selling price",
156
157
  "field.variation_sku": "variation sku",
157
158
  "field.variation_uom_value": "variation uom value",
@@ -151,6 +151,7 @@
151
151
  "field.variation_marketplace_status": "[ko] variation marketplace status",
152
152
  "field.variation_name": "[ko] variation name",
153
153
  "field.variation_qty": "[ko] variation qty",
154
+ "field.variation_reserve_qty": "[ko] variation reserve qty",
154
155
  "field.variation_selling_price": "[ko] variation selling price",
155
156
  "field.variation_sku": "[ko] variation sku",
156
157
  "field.variation_uom_value": "[ko] variation uom value",
@@ -151,6 +151,7 @@
151
151
  "field.variation_marketplace_status": "[ms] variation marketplace status",
152
152
  "field.variation_name": "[ms] variation name",
153
153
  "field.variation_qty": "[ms] variation qty",
154
+ "field.variation_reserve_qty": "[ms] variation reserve qty",
154
155
  "field.variation_selling_price": "[ms] variation selling price",
155
156
  "field.variation_sku": "[ms] variation sku",
156
157
  "field.variation_uom_value": "[ms] variation uom value",
@@ -151,6 +151,7 @@
151
151
  "field.variation_marketplace_status": "[zh] variation marketplace status",
152
152
  "field.variation_name": "[zh] variation name",
153
153
  "field.variation_qty": "[zh] variation qty",
154
+ "field.variation_reserve_qty": "[zh] variation reserve qty",
154
155
  "field.variation_selling_price": "[zh] variation selling price",
155
156
  "field.variation_sku": "[zh] variation sku",
156
157
  "field.variation_uom_value": "[zh] variation uom value",