washday-sdk 0.0.170 → 0.0.171
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/dist/utils/orders/calculateTotalTaxesIncluded.js +9 -1
- package/dist/utils/orders/calculateTotalTaxesOverPrice.js +9 -1
- package/dist/utils/orders/helpers.js +9 -1
- package/package.json +1 -1
- package/src/utils/orders/calculateTotalTaxesIncluded.ts +8 -1
- package/src/utils/orders/calculateTotalTaxesOverPrice.ts +8 -1
- package/src/utils/orders/helpers.ts +8 -1
|
@@ -17,7 +17,15 @@ export const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettin
|
|
|
17
17
|
let productPercentageDiscount = 0;
|
|
18
18
|
let customerDiscount = 0;
|
|
19
19
|
if (!order.discountCode) {
|
|
20
|
-
const discountsToApply = storeDiscounts.filter((discount) => discount.isActive && discount.products.some((p) =>
|
|
20
|
+
const discountsToApply = storeDiscounts.filter((discount) => discount.isActive && discount.products.some((p) => {
|
|
21
|
+
if (typeof p === 'string') {
|
|
22
|
+
return p === current._id;
|
|
23
|
+
}
|
|
24
|
+
else if (typeof p === 'object') {
|
|
25
|
+
return p._id === current._id;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}));
|
|
21
29
|
customerDiscount = ((_a = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.customer) === null || _a === void 0 ? void 0 : _a.discount) || 0;
|
|
22
30
|
productPercentageDiscount = discountsToApply.reduce((prev, next) => {
|
|
23
31
|
return next.type === 'percentage' ? prev + next.value : prev;
|
|
@@ -17,7 +17,15 @@ export const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSetti
|
|
|
17
17
|
const adjustedPrice = productBasePrice + unitExtra;
|
|
18
18
|
// Cálculo de descuento sobre el precio ajustado
|
|
19
19
|
if (!order.discountCode) {
|
|
20
|
-
const discountsToApply = storeDiscounts.filter((discount) => discount.isActive && discount.products.some((p) =>
|
|
20
|
+
const discountsToApply = storeDiscounts.filter((discount) => discount.isActive && discount.products.some((p) => {
|
|
21
|
+
if (typeof p === 'string') {
|
|
22
|
+
return p === current._id;
|
|
23
|
+
}
|
|
24
|
+
else if (typeof p === 'object') {
|
|
25
|
+
return p._id === current._id;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}));
|
|
21
29
|
customerDiscount = ((_a = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.customer) === null || _a === void 0 ? void 0 : _a.discount) || 0;
|
|
22
30
|
productPercentageDiscount = discountsToApply.reduce((acc, discount) => {
|
|
23
31
|
return discount.type === 'percentage' ? acc + discount.value : acc;
|
|
@@ -64,7 +64,15 @@ export const applyDiscountToProducts = (discountCode, productsArr, isExpress, st
|
|
|
64
64
|
// Caso sin discountCode: se aplican descuentos automáticos solo sobre el precio del producto
|
|
65
65
|
return {
|
|
66
66
|
newOrderProds: productsArr.map((prod) => {
|
|
67
|
-
const discountsToApply = storeDiscounts.filter((discount) => discount.isActive && discount.products.some((p) =>
|
|
67
|
+
const discountsToApply = storeDiscounts.filter((discount) => discount.isActive && discount.products.some((p) => {
|
|
68
|
+
if (typeof p === 'string') {
|
|
69
|
+
return p === prod._id;
|
|
70
|
+
}
|
|
71
|
+
else if (typeof p === 'object') {
|
|
72
|
+
return p._id === prod._id;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}));
|
|
68
76
|
const customerDiscount = (selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.discount) / 100 || 0;
|
|
69
77
|
const productPercentageDiscount = discountsToApply.reduce((prev, next) => {
|
|
70
78
|
if (next.type === 'percentage') {
|
package/package.json
CHANGED
|
@@ -29,7 +29,14 @@ export const calculateTotalTaxesIncluded = (
|
|
|
29
29
|
let customerDiscount = 0;
|
|
30
30
|
if (!order.discountCode) {
|
|
31
31
|
const discountsToApply = storeDiscounts.filter(
|
|
32
|
-
(discount) => discount.isActive && discount.products.some((p: any) =>
|
|
32
|
+
(discount: any) => discount.isActive && discount.products.some((p: any) => {
|
|
33
|
+
if(typeof p === 'string') {
|
|
34
|
+
return p === current._id
|
|
35
|
+
} else if(typeof p === 'object') {
|
|
36
|
+
return p._id === current._id
|
|
37
|
+
}
|
|
38
|
+
return false
|
|
39
|
+
})
|
|
33
40
|
);
|
|
34
41
|
customerDiscount = selectedCustomer?.customer?.discount || 0;
|
|
35
42
|
productPercentageDiscount = discountsToApply.reduce((prev, next) => {
|
|
@@ -28,7 +28,14 @@ export const calculateTotalTaxesOverPrice = (
|
|
|
28
28
|
// Cálculo de descuento sobre el precio ajustado
|
|
29
29
|
if (!order.discountCode) {
|
|
30
30
|
const discountsToApply = storeDiscounts.filter(
|
|
31
|
-
(discount: any) => discount.isActive && discount.products.some((p: any) =>
|
|
31
|
+
(discount: any) => discount.isActive && discount.products.some((p: any) => {
|
|
32
|
+
if(typeof p === 'string') {
|
|
33
|
+
return p === current._id
|
|
34
|
+
} else if(typeof p === 'object') {
|
|
35
|
+
return p._id === current._id
|
|
36
|
+
}
|
|
37
|
+
return false
|
|
38
|
+
})
|
|
32
39
|
);
|
|
33
40
|
customerDiscount = selectedCustomer?.customer?.discount || 0;
|
|
34
41
|
productPercentageDiscount = discountsToApply.reduce((acc, discount) => {
|
|
@@ -94,7 +94,14 @@ export const applyDiscountToProducts = (
|
|
|
94
94
|
return {
|
|
95
95
|
newOrderProds: productsArr.map((prod: any) => {
|
|
96
96
|
const discountsToApply = storeDiscounts.filter(
|
|
97
|
-
(discount: any) => discount.isActive && discount.products.some((p: any) =>
|
|
97
|
+
(discount: any) => discount.isActive && discount.products.some((p: any) =>{
|
|
98
|
+
if(typeof p === 'string') {
|
|
99
|
+
return p === prod._id
|
|
100
|
+
} else if(typeof p === 'object') {
|
|
101
|
+
return p._id === prod._id
|
|
102
|
+
}
|
|
103
|
+
return false
|
|
104
|
+
})
|
|
98
105
|
);
|
|
99
106
|
const customerDiscount = selectedCustomer?.discount / 100 || 0;
|
|
100
107
|
const productPercentageDiscount = discountsToApply.reduce((prev: number, next: any) => {
|