washday-sdk 0.0.195 → 0.0.197

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.
@@ -90,3 +90,17 @@ export const getCustomerByIdCustomersApp = function (customerId) {
90
90
  }
91
91
  });
92
92
  };
93
+ export const getCustomerLoyaltyHistory = function (customerId) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ try {
96
+ const config = {
97
+ headers: { Authorization: `Bearer ${this.apiToken}` }
98
+ };
99
+ return yield axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/loyalty-history`, config);
100
+ }
101
+ catch (error) {
102
+ console.error('Error fetching getCustomerLoyaltyHistory:', error);
103
+ throw error;
104
+ }
105
+ });
106
+ };
package/dist/api/index.js CHANGED
@@ -141,6 +141,7 @@ const WashdayClient = function WashdayClient(apiToken) {
141
141
  getCustomerHighlightsById: customersEndpoints.getModule.getCustomerHighlightsById,
142
142
  getCustomerOrders: customersEndpoints.getModule.getCustomerOrders,
143
143
  getCustomerByIdCustomersApp: customersEndpoints.getModule.getCustomerByIdCustomersApp,
144
+ getCustomerLoyaltyHistory: customersEndpoints.getModule.getCustomerLoyaltyHistory,
144
145
  create: customersEndpoints.postModule.create,
145
146
  bulkCreate: customersEndpoints.postModule.bulkCreate,
146
147
  updateById: customersEndpoints.putModule.updateById,
@@ -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.197",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -88,4 +88,17 @@ export const getCustomerByIdCustomersApp = async function (this: WashdayClientIn
88
88
  console.error('Error fetching customer:', error);
89
89
  throw error;
90
90
  }
91
+ };
92
+
93
+
94
+ export const getCustomerLoyaltyHistory = async function (this: WashdayClientInstance, customerId: string): Promise<any> {
95
+ try {
96
+ const config = {
97
+ headers: { Authorization: `Bearer ${this.apiToken}` }
98
+ };
99
+ return await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/loyalty-history`, config);
100
+ } catch (error) {
101
+ console.error('Error fetching getCustomerLoyaltyHistory:', error);
102
+ throw error;
103
+ }
91
104
  };
package/src/api/index.ts CHANGED
@@ -148,6 +148,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
148
148
  getCustomerHighlightsById: customersEndpoints.getModule.getCustomerHighlightsById,
149
149
  getCustomerOrders: customersEndpoints.getModule.getCustomerOrders,
150
150
  getCustomerByIdCustomersApp: customersEndpoints.getModule.getCustomerByIdCustomersApp,
151
+ getCustomerLoyaltyHistory: customersEndpoints.getModule.getCustomerLoyaltyHistory,
151
152
  create: customersEndpoints.postModule.create,
152
153
  bulkCreate: customersEndpoints.postModule.bulkCreate,
153
154
  updateById: customersEndpoints.putModule.updateById,
@@ -133,6 +133,7 @@ export interface WashdayClientInstance {
133
133
  getCustomerHighlightsById: typeof customersEndpoints.getModule.getCustomerHighlightsById;
134
134
  getCustomerOrders: typeof customersEndpoints.getModule.getCustomerOrders;
135
135
  getCustomerByIdCustomersApp: typeof customersEndpoints.getModule.getCustomerByIdCustomersApp;
136
+ getCustomerLoyaltyHistory: typeof customersEndpoints.getModule.getCustomerLoyaltyHistory;
136
137
  create: typeof customersEndpoints.postModule.create;
137
138
  bulkCreate: typeof customersEndpoints.postModule.bulkCreate;
138
139
  updateById: typeof customersEndpoints.putModule.updateById;
@@ -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