@nuskin/ns-product-lib 2.9.0 → 2.9.2-cx24-4771.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,18 @@
|
|
1
|
+
## [2.9.2-cx24-4771.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.9.1...v2.9.2-cx24-4771.1) (2023-07-31)
|
2
|
+
|
3
|
+
|
4
|
+
### Fix
|
5
|
+
|
6
|
+
* backorder Qty for single product and kits (#CX24-4771) ([5ee943a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/5ee943a4bcb98c4f2f4826b8e43e65ae28bd38d6)), closes [#CX24-4771](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-4771)
|
7
|
+
* 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)
|
8
|
+
|
9
|
+
## [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)
|
10
|
+
|
11
|
+
|
12
|
+
### Fix
|
13
|
+
|
14
|
+
* 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)
|
15
|
+
|
1
16
|
# [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
17
|
|
3
18
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.9.
|
3
|
+
"version": "2.9.2-cx24-4771.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": {
|
@@ -32,7 +32,7 @@
|
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
34
|
"@nuskin/configuration-sdk": "2.2.3",
|
35
|
-
"@nuskin/ns-common-lib": "1.4.
|
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"
|
@@ -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
|
}
|
package/src/productData.js
CHANGED
@@ -135,6 +135,26 @@ 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
|
+
if (!inventory || (!inventory.hasOwnProperty('backOrdered')
|
147
|
+
|| !inventory.hasOwnProperty('atpQty') || !inventory.hasOwnProperty('backOrderedQty'))) {
|
148
|
+
return 0;
|
149
|
+
}
|
150
|
+
|
151
|
+
if (inventory.backOrdered) {
|
152
|
+
return inventory.backOrderedQty;
|
153
|
+
}
|
154
|
+
|
155
|
+
return inventory.atpQty;
|
156
|
+
},
|
157
|
+
|
138
158
|
/**
|
139
159
|
* Map product variant
|
140
160
|
* @todo remove unnecessary fields and do code refactoring
|
@@ -256,7 +276,7 @@ const ProductData = {
|
|
256
276
|
}
|
257
277
|
],
|
258
278
|
"scanQualified": eqVariant.properties.scanQualifiedCount,
|
259
|
-
"availableQuantity": eqVariant.inventoryProperties
|
279
|
+
"availableQuantity": this.getAvailableQty(eqVariant.inventoryProperties),
|
260
280
|
"maxQuantity": 999,
|
261
281
|
"points": "",
|
262
282
|
"cv": productCVPrice,
|