rerobe-js-orm 2.7.28 → 2.7.29
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.
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export default class ReRobeProductHelpers {
|
|
2
2
|
static calculateProductionFee(commission: number): number;
|
|
3
3
|
static calculateFulfillmentFee(commission: number): number;
|
|
4
|
+
static calculateSalePrice(productObj: CompleteProduct): string;
|
|
4
5
|
static isValidCommission(commission: any): boolean;
|
|
5
6
|
static commissionFixer(commisssion: any): string;
|
|
7
|
+
static isValidSalePrice(productObj: CompleteProduct): boolean;
|
|
6
8
|
static buildReRobeEarnings(arrayLike: CompleteProduct | CompleteProduct[]): number[];
|
|
7
9
|
static buildReRobeEarningsV2(arrayLike: CompleteProduct | CompleteProduct[], isCanonicalMerchant?: boolean): number[];
|
|
8
10
|
static materialCompJoinedString(materialComposition?: MaterialComposition): string;
|
|
@@ -20,6 +20,24 @@ class ReRobeProductHelpers {
|
|
|
20
20
|
}
|
|
21
21
|
return 0;
|
|
22
22
|
}
|
|
23
|
+
static calculateSalePrice(productObj) {
|
|
24
|
+
const { discountType, discountValue, price, isOnSale } = productObj;
|
|
25
|
+
const dt = discountType || 'percentage';
|
|
26
|
+
const dv = discountValue || '0';
|
|
27
|
+
if (!price) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
if (!isOnSale || isOnSale === 'no') {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
if (dt === 'percentage') {
|
|
34
|
+
return (Number(price) * (1 - Number(dv))).toFixed(2);
|
|
35
|
+
}
|
|
36
|
+
if (dt === 'amount') {
|
|
37
|
+
return (Number(price) - Number(dv)).toFixed(2);
|
|
38
|
+
}
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
23
41
|
static isValidCommission(commission) {
|
|
24
42
|
if (typeof commission === 'string' &&
|
|
25
43
|
!!commission &&
|
|
@@ -42,6 +60,14 @@ class ReRobeProductHelpers {
|
|
|
42
60
|
}
|
|
43
61
|
return String(Math.abs(Number(fix)));
|
|
44
62
|
}
|
|
63
|
+
static isValidSalePrice(productObj) {
|
|
64
|
+
const { salePrice } = productObj;
|
|
65
|
+
const calculatedSalePrice = this.calculateSalePrice(productObj);
|
|
66
|
+
if (salePrice !== calculatedSalePrice) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
45
71
|
static buildReRobeEarnings(arrayLike) {
|
|
46
72
|
const products = Array.isArray(arrayLike) ? arrayLike : [arrayLike];
|
|
47
73
|
return products.reduce((acc, cur) => {
|