@nuskin/ns-product-lib 2.10.0-cx24-4696.2 → 2.10.0-cx24-4696.2.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,17 +1,28 @@
1
- # [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)
1
+ # [2.10.0-cx24-4696.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.9.3...v2.10.0-cx24-4696.2.1) (2023-08-07)
2
2
 
3
3
 
4
4
  ### New
5
5
 
6
- * Support for bundles ([dce4424](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/dce44249c9edb5ed264ff012ab9ffa6422fe1dca))
6
+ * 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
7
 
8
- # [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)
8
+ ## [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
9
 
10
10
 
11
- ### New
11
+ ### Fix
12
+
13
+ * 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)
14
+ * 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)
15
+
16
+ ### Release
17
+
18
+ * Automated changes by GitLab pipeline [skip ci] ([fb7c96c](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fb7c96c18c1994526a584ff0ad2da24daf013646))
19
+
20
+ ## [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)
21
+
22
+
23
+ ### Fix
12
24
 
13
- * Support for bundles ([9d696e9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9d696e94522397c2edcb2aa08d2b2755cda81792))
14
- * Support for bundles ([a945561](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a94556115f9113b934c6cc993f008b4d539dc965))
25
+ * 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)
15
26
 
16
27
  ## [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)
17
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.10.0-cx24-4696.2",
3
+ "version": "2.10.0-cx24-4696.2.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
  }
@@ -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
  /**
@@ -136,6 +136,26 @@ 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
+ * @param {obj} inventory
144
+ * @returns {number} qty
145
+ */
146
+ getAvailableQty: function(inventory) {
147
+ if (!inventory || (!inventory.hasOwnProperty('backOrdered')
148
+ || !inventory.hasOwnProperty('atpQty') || !inventory.hasOwnProperty('backOrderedQty'))) {
149
+ return 0;
150
+ }
151
+
152
+ if (inventory.backOrdered) {
153
+ return inventory.backOrderedQty;
154
+ }
155
+
156
+ return inventory.atpQty;
157
+ },
158
+
139
159
  /**
140
160
  * Map product variant
141
161
  * @todo remove unnecessary fields and do code refactoring
@@ -257,7 +277,7 @@ const ProductData = {
257
277
  }
258
278
  ],
259
279
  "scanQualified": eqVariant.properties.scanQualifiedCount,
260
- "availableQuantity": eqVariant.inventoryProperties.atpQty,
280
+ "availableQuantity": this.getAvailableQty(eqVariant.inventoryProperties),
261
281
  "maxQuantity": 999,
262
282
  "points": "",
263
283
  "cv": productCVPrice,
@@ -325,7 +345,6 @@ const ProductData = {
325
345
  * @returns {obj} promotion
326
346
  */
327
347
  getEqProductPromotions(product) {
328
- let defaultProductPrice;
329
348
 
330
349
  if (!Array.isArray(product.promotion)) {
331
350
  return {
@@ -335,11 +354,9 @@ const ProductData = {
335
354
  eventName: null
336
355
  }
337
356
  }
338
- if (product.type === "bundle") {
339
- defaultProductPrice = product.totalValue ? product.totalValue.priceFacets["Regular Price"] : 0;
340
- } else {
341
- defaultProductPrice = product.totalValue ? product.totalValue.originalPrice : 0;
342
- }
357
+
358
+ const defaultProductPrice = product.totalValue ? product.totalValue.originalPrice : 0;
359
+
343
360
  const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount
344
361
  ? product.totalValue.priceAfterDiscount
345
362
  : 0;
@@ -503,7 +520,7 @@ const ProductData = {
503
520
  },
504
521
  "restrictedMarkets": [],
505
522
  "addOns": [],
506
- "inventory": product.inventory || "", //inventory label
523
+ "inventory": product.inventory || product.properties.inventoryStatus || "", //inventory label,
507
524
  "equinoxProductId": productData.identifier,
508
525
  "properties": product.properties,
509
526
  equinox: {