sahab-utils 1.2.3 → 1.2.5
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/constants/types.ts +6 -1
- package/package.json +1 -1
- package/ts/calcs.ts +25 -4
package/constants/types.ts
CHANGED
|
@@ -77,6 +77,11 @@ export enum OrderPaymentType {
|
|
|
77
77
|
APPLE_PAY,
|
|
78
78
|
CREDIT,
|
|
79
79
|
CASH,
|
|
80
|
+
GOOGLE_PAY,
|
|
81
|
+
SAMSUNG_PAY,
|
|
82
|
+
STC_PAY,
|
|
83
|
+
TABBY,
|
|
84
|
+
TAMARA,
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
export type Location = {
|
|
@@ -718,7 +723,7 @@ export type PlaceOrder = {
|
|
|
718
723
|
ar: string;
|
|
719
724
|
en: string;
|
|
720
725
|
};
|
|
721
|
-
|
|
726
|
+
paymentAmount: number;
|
|
722
727
|
usedBalance: number;
|
|
723
728
|
providerPhoneNumber: string;
|
|
724
729
|
isAddonStructure: boolean;
|
package/package.json
CHANGED
package/ts/calcs.ts
CHANGED
|
@@ -35,9 +35,19 @@ export function getSahabDiscountsAmount(order: Order) {
|
|
|
35
35
|
discounts += 0.05 * orderTotal;
|
|
36
36
|
} else if (order?.promoCode?.amount && order?.promoCode?.amount > 0 && !order?.promoCode?.createdByProvider) {
|
|
37
37
|
if (order?.promoCode?.isPercentage) {
|
|
38
|
-
|
|
38
|
+
const amount = (preventNaN(order?.promoCode?.amount) / 100) * orderTotal;
|
|
39
|
+
if (order?.promoCode?.maxAmount && order?.promoCode?.maxAmount > 0) {
|
|
40
|
+
discounts += Math.min(amount, order?.promoCode?.maxAmount);
|
|
41
|
+
} else {
|
|
42
|
+
discounts += amount;
|
|
43
|
+
}
|
|
39
44
|
} else {
|
|
40
|
-
|
|
45
|
+
const amount = preventNaN(order?.promoCode?.amount);
|
|
46
|
+
if (order?.promoCode?.maxAmount && order?.promoCode?.maxAmount > 0) {
|
|
47
|
+
discounts += Math.min(amount, order?.promoCode?.maxAmount);
|
|
48
|
+
} else {
|
|
49
|
+
discounts += amount;
|
|
50
|
+
}
|
|
41
51
|
}
|
|
42
52
|
}
|
|
43
53
|
|
|
@@ -77,9 +87,20 @@ export function getProviderDiscountsAmount(order: Order) {
|
|
|
77
87
|
discounts += 0.05 * orderTotal;
|
|
78
88
|
} else if (order?.promoCode?.amount && order?.promoCode?.amount > 0 && order?.promoCode?.createdByProvider) {
|
|
79
89
|
if (order?.promoCode?.isPercentage) {
|
|
80
|
-
|
|
90
|
+
const amount = (preventNaN(order?.promoCode?.amount) / 100) * orderTotal;
|
|
91
|
+
if (order?.promoCode?.maxAmount && order?.promoCode?.maxAmount > 0) {
|
|
92
|
+
discounts += Math.min(amount, order?.promoCode?.maxAmount);
|
|
93
|
+
} else {
|
|
94
|
+
discounts += amount;
|
|
95
|
+
}
|
|
81
96
|
} else {
|
|
82
|
-
|
|
97
|
+
const amount = preventNaN(order?.promoCode?.amount);
|
|
98
|
+
|
|
99
|
+
if (order?.promoCode?.maxAmount && order?.promoCode?.maxAmount > 0) {
|
|
100
|
+
discounts += Math.min(amount, order?.promoCode?.maxAmount);
|
|
101
|
+
} else {
|
|
102
|
+
discounts += amount;
|
|
103
|
+
}
|
|
83
104
|
}
|
|
84
105
|
}
|
|
85
106
|
|