@nuskin/ns-product-lib 2.9.0 → 2.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [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)
2
+
3
+
4
+ ### Fix
5
+
6
+ * 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)
7
+
8
+ ## [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)
9
+
10
+
11
+ ### Fix
12
+
13
+ * map AEM author url for test and prod (#CX24-4101) ([ade7ecc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ade7ecc6a29d4af4a3448a9113c016b5749fb148)), closes [#CX24-4101](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-4101)
14
+
1
15
  # [2.9.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.8.2...v2.9.0) (2023-07-05)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.9.0",
3
+ "version": "2.9.2",
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": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@nuskin/configuration-sdk": "2.2.3",
35
- "@nuskin/ns-common-lib": "1.4.5",
35
+ "@nuskin/ns-common-lib": "1.4.7",
36
36
  "@nuskin/ns-util": "4.3.2",
37
37
  "axios": "0.27.2",
38
38
  "qs": "6.11.0"
@@ -135,6 +135,27 @@ const ProductData = {
135
135
  };
136
136
  },
137
137
 
138
+ /**
139
+ * Get available product quantity
140
+ * If backOrdered === true, use backOrderedQty
141
+ * else use atpQty
142
+ * @param {obj} inventory
143
+ * @returns {number} qty
144
+ */
145
+ getAvailableQty: function(inventory) {
146
+ // const inventory = Object.create(inventoryProperties);
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
+
138
159
  /**
139
160
  * Map product variant
140
161
  * @todo remove unnecessary fields and do code refactoring
@@ -256,7 +277,7 @@ const ProductData = {
256
277
  }
257
278
  ],
258
279
  "scanQualified": eqVariant.properties.scanQualifiedCount,
259
- "availableQuantity": eqVariant.inventoryProperties.atpQty,
280
+ "availableQuantity": this.getAvailableQty(eqVariant.inventoryProperties),
260
281
  "maxQuantity": 999,
261
282
  "points": "",
262
283
  "cv": productCVPrice,