@nuskin/ns-product-lib 2.10.0 → 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,17 @@
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
+
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)
9
+
10
+
11
+ ### Fix
12
+
13
+ * [EQ] backOrderDate is not showing in MySite/PO product card (#CX24-4922) ([99e54dd](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/99e54dd58f8e6f2509d50b1440b94a097ae406c4)), closes [#CX24-4922](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-4922)
14
+
1
15
  # [2.10.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.9.3...v2.10.0) (2023-08-09)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.10.0",
3
+ "version": "2.10.2-cx24-5155.1",
4
4
  "description": "This project contains shared Product models and code between the backend and frontend.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,18 @@
1
+
2
+
3
+ /**
4
+ * backOrderDate returns backorder date if product inventory status is BACKORDER.
5
+ * @param {import('./').Product} product
6
+ * @param {*} product
7
+ * @returns {number}
8
+ */
9
+ function backOrderDate(product) {
10
+ if (product.inventoryProperties && product.inventoryProperties.hasOwnProperty('expectedBackOrderAvailabilityDate')) {
11
+ return product.inventoryProperties.expectedBackOrderAvailabilityDate;
12
+ }
13
+
14
+ return 0;
15
+ }
16
+
17
+
18
+ module.exports = backOrderDate;
@@ -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
  }
@@ -198,11 +198,13 @@
198
198
  * @property {string} sku
199
199
  * @property {number} qty
200
200
  */
201
+ const backOrderDate = require('./backOrderDate');
201
202
  const availableQuantity = require('./availableQuantity');
202
203
  const childSKU = require('./childSKU');
203
204
  const childSKUBundles = require('./childSKUBundles');
204
205
 
205
206
  module.exports = {
207
+ mapBackOrderDate: backOrderDate,
206
208
  mapAvailableQuantity: availableQuantity,
207
209
  mapChildSKU: childSKU,
208
210
  mapChildSKUBundle: childSKUBundles
@@ -5,7 +5,7 @@ const contentstack = require('./contentstack/contentstack');
5
5
  const Product = require("./product");
6
6
  const CustomerTypes = require('./models/customerTypes');
7
7
  const ProductStatus = require("./models/productStatus");
8
- const { mapAvailableQuantity, mapChildSKU, mapChildSKUBundle } = require('./equinox-helpers');
8
+ const { mapBackOrderDate, mapAvailableQuantity, mapChildSKU, mapChildSKUBundle } = require('./equinox-helpers');
9
9
  const { productNotFoundInterceptor } = require('./equinox-helpers/interceptors');
10
10
 
11
11
  const productTypes = {
@@ -140,6 +140,7 @@ const ProductData = {
140
140
  * Get available product quantity
141
141
  * If backOrdered === true, use backOrderedQty
142
142
  * else use atpQty
143
+ * @todo deprecate this and try using equinox-helpers/availableQuantity.js
143
144
  * @param {obj} inventory
144
145
  * @returns {number} qty
145
146
  */
@@ -156,6 +157,24 @@ const ProductData = {
156
157
  return inventory.atpQty;
157
158
  },
158
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
+
159
178
  /**
160
179
  * Map product variant
161
180
  * @todo remove unnecessary fields and do code refactoring
@@ -306,7 +325,7 @@ const ProductData = {
306
325
  "orderTypes": this._setOrderType(eqVariant.properties),
307
326
  "custTypes": this.switchCustType(eqVariant.properties.customerTypes),
308
327
  "division": eqVariant.properties.division,
309
- "backOrderDate": null,
328
+ "backOrderDate": this.getBackOrderDate(eqVariant),
310
329
  "locallyProduced": false,
311
330
  "agelocme": null,
312
331
  "count": "",
@@ -491,7 +510,7 @@ const ProductData = {
491
510
  "orderTypes": this._setOrderType(product.properties),
492
511
  "custTypes": this.switchCustType(product.properties.customerTypes),
493
512
  "division": productData.properties.division,
494
- "backOrderDate": null,
513
+ "backOrderDate": this.getBackOrderDate(product),
495
514
  "locallyProduced": false,
496
515
  "agelocme": null,
497
516
  "count": "",