@nuskin/ns-product-lib 2.10.1 → 2.10.2-cx24-5155.1
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [2.10.2-cx24-5155.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.10.1...v2.10.2-cx24-5155.1) (2023-09-08)
|
2
|
+
|
3
|
+
|
4
|
+
### Fix
|
5
|
+
|
6
|
+
* backorder support for product bundle/kit (#CX24-5155) ([0ea8e0d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0ea8e0d96718545890e1590568ba63896fe3ba19)), closes [#CX24-5155](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-5155)
|
7
|
+
|
1
8
|
## [2.10.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.10.0...v2.10.1) (2023-08-31)
|
2
9
|
|
3
10
|
|
package/package.json
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
const mapBackOrderDate = require('./backOrderDate');
|
2
|
+
|
1
3
|
/**
|
2
4
|
* childSKU maps a product variant. Used mainly in subscription.
|
3
5
|
*
|
@@ -24,7 +26,8 @@ function childSKU(kits, product) {
|
|
24
26
|
inventory: {
|
25
27
|
atpQty: sku.inventoryProperties.atpQty,
|
26
28
|
backOrdered: sku.inventoryProperties.backOrdered,
|
27
|
-
backOrderedQty: sku.inventoryProperties.backOrderedQty
|
29
|
+
backOrderedQty: sku.inventoryProperties.backOrderedQty,
|
30
|
+
backOrderDate: mapBackOrderDate(sku)
|
28
31
|
}
|
29
32
|
}
|
30
33
|
}
|
@@ -1,8 +1,10 @@
|
|
1
|
+
const mapBackOrderDate = require('./backOrderDate');
|
2
|
+
|
1
3
|
/**
|
2
4
|
* childSKU maps a product variant. Used mainly in subscription.
|
3
5
|
*
|
4
|
-
* @param {import('.').KitSKUQuantity[]} kits
|
5
|
-
* @param {import('.').EquinoxNormalProduct} product
|
6
|
+
* @param {import('.').KitSKUQuantity[]} kits
|
7
|
+
* @param {import('.').EquinoxNormalProduct} product
|
6
8
|
*/
|
7
9
|
function childSKUBundle(kits, product) {
|
8
10
|
const sku = product.sku.filter(sku => sku.default)[0];
|
@@ -23,7 +25,8 @@ function childSKUBundle(kits, product) {
|
|
23
25
|
availableChannels: sku.properties.availableChannels,
|
24
26
|
inventory: {
|
25
27
|
atpQty: sku.inventoryProperties.atpQty,
|
26
|
-
backOrdered: sku.inventoryProperties.backOrdered
|
28
|
+
backOrdered: sku.inventoryProperties.backOrdered,
|
29
|
+
backOrderDate: mapBackOrderDate(sku)
|
27
30
|
}
|
28
31
|
}
|
29
32
|
}
|
package/src/productData.js
CHANGED
@@ -157,6 +157,24 @@ const ProductData = {
|
|
157
157
|
return inventory.atpQty;
|
158
158
|
},
|
159
159
|
|
160
|
+
/**
|
161
|
+
* Get backorder date for normal, kit, bundle product
|
162
|
+
* @param {*} product
|
163
|
+
* @returns {number} backOrderDate
|
164
|
+
*/
|
165
|
+
getBackOrderDate: function(product) {
|
166
|
+
|
167
|
+
if ((product.type === productTypes.kit || product.type === productTypes.bundle) && product.childSkus) {
|
168
|
+
|
169
|
+
//return max epoch time since childSkus already mapped in fetchChildSkus
|
170
|
+
if (product.childSkus.some(sku => sku.inventory && sku.inventory.backOrderDate)) {
|
171
|
+
return Math.max(...product.childSkus.map(sku => sku.inventory.backOrderDate || 0));
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
return mapBackOrderDate(product);
|
176
|
+
},
|
177
|
+
|
160
178
|
/**
|
161
179
|
* Map product variant
|
162
180
|
* @todo remove unnecessary fields and do code refactoring
|
@@ -307,7 +325,7 @@ const ProductData = {
|
|
307
325
|
"orderTypes": this._setOrderType(eqVariant.properties),
|
308
326
|
"custTypes": this.switchCustType(eqVariant.properties.customerTypes),
|
309
327
|
"division": eqVariant.properties.division,
|
310
|
-
"backOrderDate":
|
328
|
+
"backOrderDate": this.getBackOrderDate(eqVariant),
|
311
329
|
"locallyProduced": false,
|
312
330
|
"agelocme": null,
|
313
331
|
"count": "",
|
@@ -492,7 +510,7 @@ const ProductData = {
|
|
492
510
|
"orderTypes": this._setOrderType(product.properties),
|
493
511
|
"custTypes": this.switchCustType(product.properties.customerTypes),
|
494
512
|
"division": productData.properties.division,
|
495
|
-
"backOrderDate":
|
513
|
+
"backOrderDate": this.getBackOrderDate(product),
|
496
514
|
"locallyProduced": false,
|
497
515
|
"agelocme": null,
|
498
516
|
"count": "",
|