@nuskin/ns-product-lib 2.10.0-cx24-4696.3 → 2.10.0-cx24-4922.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,24 +1,32 @@
1
- # [2.10.0-cx24-4696.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.10.0-cx24-4696.2...v2.10.0-cx24-4696.3) (2023-07-28)
1
+ # [2.10.0-cx24-4922.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.9.3...v2.10.0-cx24-4922.1) (2023-08-25)
2
2
 
3
3
 
4
+ ### Fix
5
+
6
+ * [EQ] backOrderDate is not showing in MySite/PO product card (#CX24-4922) ([9973e46](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9973e46b79f752e982589fbc9072fe343023b656)), closes [#CX24-4922](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-4922)
7
+
4
8
  ### New
5
9
 
6
- * Support for bundles ([98a77ca](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/98a77ca4cc7792fe7cfdf85097fc36b65f32a5c3))
10
+ * Support for EQ product bundles (#CX24-4696) ([70156b2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/70156b2120c692c5023ec6b74fdfdabd18f74b73)), closes [#CX24-4696](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-4696)
7
11
 
8
- # [2.10.0-cx24-4696.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.10.0-cx24-4696.1...v2.10.0-cx24-4696.2) (2023-07-27)
12
+ ## [2.9.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.9.2...v2.9.3) (2023-08-03)
9
13
 
10
14
 
11
- ### New
15
+ ### Fix
12
16
 
13
- * Support for bundles ([dce4424](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/dce44249c9edb5ed264ff012ab9ffa6422fe1dca))
17
+ * backorder Qty for single product and kits (#CX24-4771) ([23715f2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/23715f22728edef2f5936405e7d567e44a2a8cf8)), closes [#CX24-4771](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-4771)
18
+ * backorder Qty for single product and kits (#CX24-4771) ([98f44ec](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/98f44ec2eb1013bb484feeda6b27d111971e3e16)), closes [#CX24-4771](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-4771)
14
19
 
15
- # [2.10.0-cx24-4696.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.9.1...v2.10.0-cx24-4696.1) (2023-07-18)
20
+ ### Release
16
21
 
22
+ * Automated changes by GitLab pipeline [skip ci] ([fb7c96c](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fb7c96c18c1994526a584ff0ad2da24daf013646))
17
23
 
18
- ### New
24
+ ## [2.9.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.9.1...v2.9.2) (2023-07-31)
25
+
26
+
27
+ ### Fix
19
28
 
20
- * Support for bundles ([9d696e9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9d696e94522397c2edcb2aa08d2b2755cda81792))
21
- * Support for bundles ([a945561](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a94556115f9113b934c6cc993f008b4d539dc965))
29
+ * product backordered quantity (#CX24-4771) ([5efc8cc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/5efc8ccde4967ee50504f449ac818139f4416a75)), closes [#CX24-4771](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-4771)
22
30
 
23
31
  ## [2.9.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.9.0...v2.9.1) (2023-07-17)
24
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.10.0-cx24-4696.3",
3
+ "version": "2.10.0-cx24-4922.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": {
@@ -5,13 +5,13 @@
5
5
  */
6
6
  function availableQuantity(product) {
7
7
  if (product.inventoryProperties) {
8
- return product.inventoryProperties.atpQty;
8
+ return product.inventoryProperties.backOrdered ? product.inventoryProperties.backOrderedQty : product.inventoryProperties.atpQty;
9
9
  }
10
10
 
11
11
  if (product.childSkus && product.childSkus.length > 0) {
12
12
  const quantities = product.childSkus
13
13
  .filter(cs => cs.inventory !== undefined)
14
- .map(cs => cs.inventory.atpQty);
14
+ .map(cs => cs.inventory.backOrdered ? cs.inventory.backOrderedQty : cs.inventory.atpQty);
15
15
 
16
16
  return Math.min(...quantities);
17
17
  }
@@ -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,8 +1,8 @@
1
1
  /**
2
2
  * childSKU maps a product variant. Used mainly in subscription.
3
3
  *
4
- * @param {import('.').KitSKUQuantity[]} kits
5
- * @param {import('.').EquinoxNormalProduct} product
4
+ * @param {import('.').KitSKUQuantity[]} kits
5
+ * @param {import('.').EquinoxNormalProduct} product
6
6
  */
7
7
  function childSKU(kits, product) {
8
8
  const sku = product.sku.filter(sku => sku.default)[0];
@@ -23,7 +23,8 @@ function childSKU(kits, product) {
23
23
  availableChannels: sku.properties.availableChannels,
24
24
  inventory: {
25
25
  atpQty: sku.inventoryProperties.atpQty,
26
- backOrdered: sku.inventoryProperties.backOrdered
26
+ backOrdered: sku.inventoryProperties.backOrdered,
27
+ backOrderedQty: sku.inventoryProperties.backOrderedQty
27
28
  }
28
29
  }
29
30
  }
@@ -23,6 +23,7 @@
23
23
  * @type {object}
24
24
  * @property {number} atpQty
25
25
  * @property {boolean} backOrdered
26
+ * @property {number} backOrderedQty
26
27
  */
27
28
 
28
29
  /**
@@ -197,11 +198,13 @@
197
198
  * @property {string} sku
198
199
  * @property {number} qty
199
200
  */
201
+ const backOrderDate = require('./backOrderDate');
200
202
  const availableQuantity = require('./availableQuantity');
201
203
  const childSKU = require('./childSKU');
202
204
  const childSKUBundles = require('./childSKUBundles');
203
205
 
204
206
  module.exports = {
207
+ mapBackOrderDate: backOrderDate,
205
208
  mapAvailableQuantity: availableQuantity,
206
209
  mapChildSKU: childSKU,
207
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 = {
@@ -136,6 +136,27 @@ const ProductData = {
136
136
  };
137
137
  },
138
138
 
139
+ /**
140
+ * Get available product quantity
141
+ * If backOrdered === true, use backOrderedQty
142
+ * else use atpQty
143
+ * @todo deprecate this and try using equinox-helpers/availableQuantity.js
144
+ * @param {obj} inventory
145
+ * @returns {number} qty
146
+ */
147
+ getAvailableQty: function(inventory) {
148
+ if (!inventory || (!inventory.hasOwnProperty('backOrdered')
149
+ || !inventory.hasOwnProperty('atpQty') || !inventory.hasOwnProperty('backOrderedQty'))) {
150
+ return 0;
151
+ }
152
+
153
+ if (inventory.backOrdered) {
154
+ return inventory.backOrderedQty;
155
+ }
156
+
157
+ return inventory.atpQty;
158
+ },
159
+
139
160
  /**
140
161
  * Map product variant
141
162
  * @todo remove unnecessary fields and do code refactoring
@@ -257,7 +278,7 @@ const ProductData = {
257
278
  }
258
279
  ],
259
280
  "scanQualified": eqVariant.properties.scanQualifiedCount,
260
- "availableQuantity": eqVariant.inventoryProperties.atpQty,
281
+ "availableQuantity": this.getAvailableQty(eqVariant.inventoryProperties),
261
282
  "maxQuantity": 999,
262
283
  "points": "",
263
284
  "cv": productCVPrice,
@@ -286,7 +307,7 @@ const ProductData = {
286
307
  "orderTypes": this._setOrderType(eqVariant.properties),
287
308
  "custTypes": this.switchCustType(eqVariant.properties.customerTypes),
288
309
  "division": eqVariant.properties.division,
289
- "backOrderDate": null,
310
+ "backOrderDate": mapBackOrderDate(eqVariant),
290
311
  "locallyProduced": false,
291
312
  "agelocme": null,
292
313
  "count": "",
@@ -471,7 +492,7 @@ const ProductData = {
471
492
  "orderTypes": this._setOrderType(product.properties),
472
493
  "custTypes": this.switchCustType(product.properties.customerTypes),
473
494
  "division": productData.properties.division,
474
- "backOrderDate": null,
495
+ "backOrderDate": mapBackOrderDate(product),
475
496
  "locallyProduced": false,
476
497
  "agelocme": null,
477
498
  "count": "",
@@ -500,7 +521,7 @@ const ProductData = {
500
521
  },
501
522
  "restrictedMarkets": [],
502
523
  "addOns": [],
503
- "inventory": product.inventory || "", //inventory label
524
+ "inventory": product.inventory || product.properties.inventoryStatus || "", //inventory label,
504
525
  "equinoxProductId": productData.identifier,
505
526
  "properties": product.properties,
506
527
  equinox: {