washday-sdk 0.0.195 → 0.0.196

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,3 +1,4 @@
1
+ import { DiscountCodeTypes } from "../../enum";
1
2
  import { getProductTaxesPercentage } from "./helpers";
2
3
  export const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
3
4
  const productTableImports = [...order.products, ...order.buyAndGetProducts].map((current) => {
@@ -52,6 +53,9 @@ export const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettin
52
53
  discPercentageInteger = 1;
53
54
  }
54
55
  }
56
+ else if (discountCodeObj.type === DiscountCodeTypes.FREE_ITEM && (current.isFreeItem)) {
57
+ discPercentageInteger = 1;
58
+ }
55
59
  }
56
60
  // === NUEVO: Aplicar descuento sobre el precio total ajustado (producto base + extra prorrateado) ===
57
61
  // Si hay cantidad, repartir el extra neto entre cada unidad
@@ -51,6 +51,9 @@ export const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSetti
51
51
  discPercentageInteger = 1;
52
52
  }
53
53
  }
54
+ else if (discountCodeObj.type === DiscountCodeTypes.FREE_ITEM && current.isFreeItem) {
55
+ discPercentageInteger = 1;
56
+ }
54
57
  }
55
58
  // Calcular el descuento por unidad sobre el precio ajustado
56
59
  const productDiscount = adjustedPrice * discPercentageInteger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.195",
3
+ "version": "0.0.196",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1,3 +1,4 @@
1
+ import { DiscountCodeTypes } from "../../enum";
1
2
  import { IOrderProduct } from "../../interfaces/Product";
2
3
  import { getProductTaxesPercentage } from "./helpers";
3
4
 
@@ -62,6 +63,8 @@ export const calculateTotalTaxesIncluded = (
62
63
  if (discountType === 'free' && current.isBuyAndGetProduct) {
63
64
  discPercentageInteger = 1;
64
65
  }
66
+ } else if (discountCodeObj.type === DiscountCodeTypes.FREE_ITEM && ((current as any).isFreeItem)) {
67
+ discPercentageInteger = 1;
65
68
  }
66
69
  }
67
70
 
@@ -29,9 +29,9 @@ export const calculateTotalTaxesOverPrice = (
29
29
  if (!order.discountCode) {
30
30
  const discountsToApply = storeDiscounts.filter(
31
31
  (discount: any) => discount.isActive && discount.products.some((p: any) => {
32
- if(typeof p === 'string') {
32
+ if (typeof p === 'string') {
33
33
  return p === current._id
34
- } else if(typeof p === 'object') {
34
+ } else if (typeof p === 'object') {
35
35
  return p._id === current._id
36
36
  }
37
37
  return false
@@ -59,6 +59,8 @@ export const calculateTotalTaxesOverPrice = (
59
59
  if (condition.getDiscountType === BuyAndGetConditionsTypes.FREE && current.isBuyAndGetProduct) {
60
60
  discPercentageInteger = 1;
61
61
  }
62
+ } else if (discountCodeObj.type === DiscountCodeTypes.FREE_ITEM && current.isFreeItem) {
63
+ discPercentageInteger = 1;
62
64
  }
63
65
  }
64
66