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

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,24 +1,28 @@
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](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.9.3...v2.10.0) (2023-08-09)
2
2
 
3
3
 
4
4
  ### New
5
5
 
6
- * Support for bundles ([98a77ca](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/98a77ca4cc7792fe7cfdf85097fc36b65f32a5c3))
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.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)
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
12
 
13
- * Support for bundles ([dce4424](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/dce44249c9edb5ed264ff012ab9ffa6422fe1dca))
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)
14
15
 
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)
16
+ ### Release
16
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))
17
19
 
18
- ### New
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
19
24
 
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))
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)
22
26
 
23
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)
24
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.3",
3
+ "version": "2.10.0",
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,
@@ -500,7 +520,7 @@ const ProductData = {
500
520
  },
501
521
  "restrictedMarkets": [],
502
522
  "addOns": [],
503
- "inventory": product.inventory || "", //inventory label
523
+ "inventory": product.inventory || product.properties.inventoryStatus || "", //inventory label,
504
524
  "equinoxProductId": productData.identifier,
505
525
  "properties": product.properties,
506
526
  equinox: {