washday-sdk 0.0.168 → 0.0.170

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/api/index.js CHANGED
@@ -81,6 +81,7 @@ const WashdayClient = function WashdayClient(apiToken) {
81
81
  closeRouteById: routesEndpoints.putModule.closeRouteById,
82
82
  updateRouteById: routesEndpoints.putModule.updateRouteById,
83
83
  getRoutesByDriver: routesEndpoints.getModule.getRoutesByDriver,
84
+ startRoute: routesEndpoints.postModule.startRoute,
84
85
  });
85
86
  this.auth = bindMethods(this, {
86
87
  customerLoginToken: authEndpoints.postModule.customerLoginToken,
@@ -51,3 +51,17 @@ export const createRouteV2 = function (data) {
51
51
  }
52
52
  });
53
53
  };
54
+ export const startRoute = function (routeId) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ try {
57
+ const config = {
58
+ headers: { Authorization: `Bearer ${this.apiToken}` }
59
+ };
60
+ return yield axiosInstance.post(`${GET_SET_ROUTES}/${routeId}/start`, {}, config);
61
+ }
62
+ catch (error) {
63
+ console.error('Error fetching startRoute:', error);
64
+ throw error;
65
+ }
66
+ });
67
+ };
@@ -17,7 +17,7 @@ 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.products.includes(current._id) && discount.isActive);
20
+ const discountsToApply = storeDiscounts.filter((discount) => discount.isActive && discount.products.some((p) => p._id === current._id));
21
21
  customerDiscount = ((_a = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.customer) === null || _a === void 0 ? void 0 : _a.discount) || 0;
22
22
  productPercentageDiscount = discountsToApply.reduce((prev, next) => {
23
23
  return next.type === 'percentage' ? prev + next.value : prev;
@@ -17,7 +17,7 @@ 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.products.includes(current._id) && discount.isActive);
20
+ const discountsToApply = storeDiscounts.filter((discount) => discount.isActive && discount.products.some((p) => p._id === current._id));
21
21
  customerDiscount = ((_a = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.customer) === null || _a === void 0 ? void 0 : _a.discount) || 0;
22
22
  productPercentageDiscount = discountsToApply.reduce((acc, discount) => {
23
23
  return discount.type === 'percentage' ? acc + discount.value : acc;
@@ -64,7 +64,7 @@ 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.products.includes(prod._id) && discount.isActive);
67
+ const discountsToApply = storeDiscounts.filter((discount) => discount.isActive && discount.products.some((p) => p._id === prod._id));
68
68
  const customerDiscount = (selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.discount) / 100 || 0;
69
69
  const productPercentageDiscount = discountsToApply.reduce((prev, next) => {
70
70
  if (next.type === 'percentage') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.168",
3
+ "version": "0.0.170",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/api/index.ts CHANGED
@@ -88,6 +88,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
88
88
  closeRouteById: routesEndpoints.putModule.closeRouteById,
89
89
  updateRouteById: routesEndpoints.putModule.updateRouteById,
90
90
  getRoutesByDriver: routesEndpoints.getModule.getRoutesByDriver,
91
+ startRoute: routesEndpoints.postModule.startRoute,
91
92
  });
92
93
  this.auth = bindMethods(this, {
93
94
  customerLoginToken: authEndpoints.postModule.customerLoginToken,
@@ -44,4 +44,17 @@ export const createRouteV2 = async function (this: WashdayClientInstance, data:
44
44
  console.error('Error fetching createRouteV2:', error);
45
45
  throw error;
46
46
  }
47
+ };
48
+
49
+
50
+ export const startRoute = async function (this: WashdayClientInstance, routeId: string): Promise<any> {
51
+ try {
52
+ const config = {
53
+ headers: { Authorization: `Bearer ${this.apiToken}` }
54
+ };
55
+ return await axiosInstance.post(`${GET_SET_ROUTES}/${routeId}/start`, {}, config);
56
+ } catch (error) {
57
+ console.error('Error fetching startRoute:', error);
58
+ throw error;
59
+ }
47
60
  };
@@ -88,6 +88,7 @@ export interface WashdayClientInstance {
88
88
  closeRouteById: typeof routesEndpoints.putModule.closeRouteById,
89
89
  updateRouteById: typeof routesEndpoints.putModule.updateRouteById,
90
90
  getRoutesByDriver: typeof routesEndpoints.getModule.getRoutesByDriver,
91
+ startRoute: typeof routesEndpoints.postModule.startRoute,
91
92
  },
92
93
  orders: {
93
94
  getList: typeof ordersEndpoints.getModule.getList;
@@ -29,7 +29,7 @@ export const calculateTotalTaxesIncluded = (
29
29
  let customerDiscount = 0;
30
30
  if (!order.discountCode) {
31
31
  const discountsToApply = storeDiscounts.filter(
32
- (discount) => discount.products.includes(current._id) && discount.isActive
32
+ (discount) => discount.isActive && discount.products.some((p: any) => p._id === current._id)
33
33
  );
34
34
  customerDiscount = selectedCustomer?.customer?.discount || 0;
35
35
  productPercentageDiscount = discountsToApply.reduce((prev, next) => {
@@ -28,7 +28,7 @@ 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) => discount.products.includes(current._id) && discount.isActive
31
+ (discount: any) => discount.isActive && discount.products.some((p: any) => p._id === current._id)
32
32
  );
33
33
  customerDiscount = selectedCustomer?.customer?.discount || 0;
34
34
  productPercentageDiscount = discountsToApply.reduce((acc, discount) => {
@@ -66,7 +66,7 @@ export const calculateTotalTaxesOverPrice = (
66
66
  // Resultados finales:
67
67
  const totalTaxesApplied = +taxes.toFixed(2);
68
68
  const lineDiscount = +(productDiscount * qty).toFixed(2);
69
-
69
+
70
70
  // Precio total con descuento, reaplicando impuestos
71
71
  const prodLinePriceWithDiscount = +((subtotal * (1 + taxPercentage))).toFixed(2);
72
72
 
@@ -94,7 +94,7 @@ export const applyDiscountToProducts = (
94
94
  return {
95
95
  newOrderProds: productsArr.map((prod: any) => {
96
96
  const discountsToApply = storeDiscounts.filter(
97
- (discount: any) => discount.products.includes(prod._id) && discount.isActive
97
+ (discount: any) => discount.isActive && discount.products.some((p: any) => p._id === prod._id)
98
98
  );
99
99
  const customerDiscount = selectedCustomer?.discount / 100 || 0;
100
100
  const productPercentageDiscount = discountsToApply.reduce((prev: number, next: any) => {