washday-sdk 0.0.70 → 0.0.72

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.
Files changed (145) hide show
  1. package/dist/api/axiosInstance.d.ts +2 -0
  2. package/dist/api/axiosInstance.js +4 -8
  3. package/dist/api/cashierbox/delete.d.ts +2 -0
  4. package/dist/api/cashierbox/delete.js +3 -10
  5. package/dist/api/cashierbox/get.d.ts +7 -0
  6. package/dist/api/cashierbox/get.js +7 -16
  7. package/dist/api/cashierbox/post.d.ts +11 -0
  8. package/dist/api/cashierbox/post.js +5 -13
  9. package/dist/api/cashierbox/put.d.ts +4 -0
  10. package/dist/api/cashierbox/put.js +3 -10
  11. package/dist/api/companies/get.d.ts +2 -0
  12. package/dist/api/companies/get.js +3 -10
  13. package/dist/api/companies/post.d.ts +3 -0
  14. package/dist/api/companies/post.js +5 -13
  15. package/dist/api/companies/put.d.ts +4 -0
  16. package/dist/api/companies/put.js +7 -16
  17. package/dist/api/countries/get.d.ts +2 -0
  18. package/dist/api/countries/get.js +3 -10
  19. package/dist/api/countries/post.d.ts +0 -0
  20. package/dist/api/countries/put.d.ts +0 -0
  21. package/dist/api/csv/get.d.ts +11 -0
  22. package/dist/api/csv/get.js +5 -12
  23. package/dist/api/csv/index.d.ts +1 -0
  24. package/dist/api/csv/index.js +1 -27
  25. package/dist/api/customers/delete.d.ts +2 -0
  26. package/dist/api/customers/delete.js +3 -10
  27. package/dist/api/customers/get.d.ts +28 -0
  28. package/dist/api/customers/get.js +12 -21
  29. package/dist/api/customers/index.d.ts +4 -0
  30. package/dist/api/customers/index.js +4 -30
  31. package/dist/api/customers/post.d.ts +18 -0
  32. package/dist/api/customers/post.js +3 -10
  33. package/dist/api/customers/put.d.ts +18 -0
  34. package/dist/api/customers/put.js +3 -10
  35. package/dist/api/discounts/get.d.ts +6 -0
  36. package/dist/api/discounts/get.js +11 -22
  37. package/dist/api/discounts/post.d.ts +3 -0
  38. package/dist/api/discounts/post.js +5 -13
  39. package/dist/api/discounts/put.d.ts +3 -0
  40. package/dist/api/discounts/put.js +5 -13
  41. package/dist/api/index.d.ts +7 -0
  42. package/dist/api/index.js +78 -103
  43. package/dist/api/inventory/delete.d.ts +2 -0
  44. package/dist/api/inventory/delete.js +3 -10
  45. package/dist/api/inventory/get.d.ts +7 -0
  46. package/dist/api/inventory/get.js +7 -16
  47. package/dist/api/inventory/index.d.ts +4 -0
  48. package/dist/api/inventory/index.js +4 -30
  49. package/dist/api/inventory/post.d.ts +7 -0
  50. package/dist/api/inventory/post.js +3 -10
  51. package/dist/api/inventory/put.d.ts +8 -0
  52. package/dist/api/inventory/put.js +5 -13
  53. package/dist/api/products/delete.d.ts +3 -0
  54. package/dist/api/products/delete.js +5 -13
  55. package/dist/api/products/get.d.ts +2 -0
  56. package/dist/api/products/get.js +3 -10
  57. package/dist/api/products/index.d.ts +4 -0
  58. package/dist/api/products/index.js +4 -30
  59. package/dist/api/products/post.d.ts +27 -0
  60. package/dist/api/products/post.js +5 -13
  61. package/dist/api/products/put.d.ts +21 -0
  62. package/dist/api/products/put.js +5 -13
  63. package/dist/api/sections/delete.d.ts +2 -0
  64. package/dist/api/sections/delete.js +3 -10
  65. package/dist/api/sections/get.d.ts +7 -0
  66. package/dist/api/sections/get.js +5 -13
  67. package/dist/api/sections/index.d.ts +4 -0
  68. package/dist/api/sections/index.js +4 -30
  69. package/dist/api/sections/post.d.ts +7 -0
  70. package/dist/api/sections/post.js +3 -10
  71. package/dist/api/sections/put.d.ts +8 -0
  72. package/dist/api/sections/put.js +3 -10
  73. package/dist/api/staff/delete.d.ts +2 -0
  74. package/dist/api/staff/delete.js +3 -10
  75. package/dist/api/staff/get.d.ts +3 -0
  76. package/dist/api/staff/get.js +5 -13
  77. package/dist/api/staff/post.d.ts +2 -0
  78. package/dist/api/staff/post.js +3 -10
  79. package/dist/api/staff/put.d.ts +2 -0
  80. package/dist/api/staff/put.js +3 -10
  81. package/dist/api/stores/get.d.ts +12 -0
  82. package/dist/api/stores/get.js +9 -19
  83. package/dist/api/stores/post.d.ts +4 -0
  84. package/dist/api/stores/post.js +7 -16
  85. package/dist/api/stores/put.d.ts +6 -0
  86. package/dist/api/stores/put.js +5 -13
  87. package/dist/api/stripe/get.d.ts +0 -0
  88. package/dist/api/stripe/post.d.ts +6 -0
  89. package/dist/api/stripe/post.js +7 -16
  90. package/dist/api/stripe/put.d.ts +0 -0
  91. package/dist/api/supplies/delete.d.ts +2 -0
  92. package/dist/api/supplies/delete.js +3 -10
  93. package/dist/api/supplies/get.d.ts +7 -0
  94. package/dist/api/supplies/get.js +7 -16
  95. package/dist/api/supplies/post.d.ts +11 -0
  96. package/dist/api/supplies/post.js +3 -10
  97. package/dist/api/supplies/put.d.ts +6 -0
  98. package/dist/api/supplies/put.js +5 -13
  99. package/dist/api/users/put.d.ts +10 -0
  100. package/dist/api/users/put.js +3 -10
  101. package/dist/enum/index.d.ts +10 -0
  102. package/dist/enum/index.js +4 -7
  103. package/dist/index.d.ts +3 -0
  104. package/dist/index.js +3 -33
  105. package/dist/interfaces/Api.d.ts +3 -0
  106. package/dist/interfaces/Api.js +1 -2
  107. package/dist/interfaces/Company.d.ts +0 -0
  108. package/dist/interfaces/Customer.d.ts +47 -0
  109. package/dist/interfaces/Customer.js +1 -2
  110. package/dist/interfaces/Order.d.ts +91 -0
  111. package/dist/interfaces/Order.js +1 -2
  112. package/dist/interfaces/Permission.d.ts +22 -0
  113. package/dist/interfaces/Permission.js +1 -2
  114. package/dist/interfaces/Product.d.ts +51 -0
  115. package/dist/interfaces/Product.js +1 -2
  116. package/dist/interfaces/Section.d.ts +13 -0
  117. package/dist/interfaces/Section.js +1 -2
  118. package/dist/interfaces/Store.d.ts +323 -0
  119. package/dist/interfaces/Store.js +1 -2
  120. package/dist/interfaces/StoreImage.d.ts +8 -0
  121. package/dist/interfaces/StoreImage.js +1 -2
  122. package/dist/interfaces/User.d.ts +38 -0
  123. package/dist/interfaces/User.js +1 -2
  124. package/dist/utils/apiUtils.d.ts +3 -0
  125. package/dist/utils/apiUtils.js +2 -6
  126. package/dist/utils/index.d.ts +1 -0
  127. package/dist/utils/index.js +1 -17
  128. package/dist/utils/orders/calculateOrderTotal.d.ts +5 -0
  129. package/dist/utils/orders/calculateOrderTotal.js +10 -14
  130. package/dist/utils/orders/calculateTotalTaxesIncluded.d.ts +9 -0
  131. package/dist/utils/orders/calculateTotalTaxesIncluded.js +3 -7
  132. package/dist/utils/orders/calculateTotalTaxesOverPrice.d.ts +8 -0
  133. package/dist/utils/orders/calculateTotalTaxesOverPrice.js +7 -11
  134. package/dist/utils/orders/helpers.d.ts +15 -0
  135. package/dist/utils/orders/helpers.js +6 -13
  136. package/dist/utils/orders/index.d.ts +2 -0
  137. package/dist/utils/orders/index.js +2 -5
  138. package/dist/utils/receipt/generateReceiptHTML.d.ts +0 -0
  139. package/dist/utils/util.d.ts +0 -0
  140. package/package.json +2 -1
  141. package/src/api/axiosInstance.ts +1 -0
  142. package/src/api/customers/get.ts +3 -2
  143. package/src/api/index.ts +0 -10
  144. package/src/utils/apiUtils.ts +1 -1
  145. package/tsconfig.json +10 -9
@@ -0,0 +1,9 @@
1
+ import { IOrderProduct } from "../../interfaces/Product";
2
+ export declare const calculateTotalTaxesIncluded: (order: any, selectedCustomer: any, storeSettings: any, storeDiscounts: any[], appliedOrderDiscounts: any, discountCodeObj: any | null) => {
3
+ product: IOrderProduct;
4
+ qty: number;
5
+ productLineImportTotal: number;
6
+ productLineTotalWithDiscount: number;
7
+ productLineTaxesTotal: number;
8
+ lineDiscountAmount: number;
9
+ }[];
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateTotalTaxesIncluded = void 0;
4
- const helpers_1 = require("./helpers");
5
- const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
1
+ import { getProductTaxesPercentage } from "./helpers";
2
+ export const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
6
3
  const productTableImports = [...order.products, ...order.buyAndGetProducts].map((current) => {
7
4
  var _a, _b;
8
5
  let discPercentageInteger = 0;
@@ -40,7 +37,7 @@ const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, sto
40
37
  }
41
38
  }
42
39
  }
43
- const taxPercentage = (0, helpers_1.getProductTaxesPercentage)(current, storeSettings);
40
+ const taxPercentage = getProductTaxesPercentage(current, storeSettings);
44
41
  const taxPercentageInteger = taxPercentage / 100;
45
42
  const unitPrice = prodPrice / (1 + taxPercentageInteger);
46
43
  const discountAmountPerUnit = discPercentageInteger
@@ -62,4 +59,3 @@ const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, sto
62
59
  });
63
60
  return productTableImports;
64
61
  };
65
- exports.calculateTotalTaxesIncluded = calculateTotalTaxesIncluded;
@@ -0,0 +1,8 @@
1
+ export declare const calculateTotalTaxesOverPrice: (order: any, selectedCustomer: any, storeSettings: any, storeDiscounts: any[], appliedOrderDiscounts: any, discountCodeObj: any | null) => {
2
+ product: any;
3
+ qty: any;
4
+ productLineImportTotal: number;
5
+ productLineTotalWithDiscount: number;
6
+ productLineTaxesTotal: number;
7
+ lineDiscountAmount: number;
8
+ }[];
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateTotalTaxesOverPrice = void 0;
4
- const enum_1 = require("../../enum");
5
- const helpers_1 = require("./helpers");
6
- const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
1
+ import { BuyAndGetConditionsTypes, DiscountCodeTypes } from "../../enum";
2
+ import { getProductTaxesPercentage } from "./helpers";
3
+ export const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
7
4
  const productTableImports = [...order.products, ...order.buyAndGetProducts].map((current) => {
8
5
  var _a;
9
6
  let discPercentageInteger = 0;
@@ -30,7 +27,7 @@ const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, st
30
27
  discountsToApply.forEach((discount) => (appliedOrderDiscounts[discount._id] = discount)); // it will do this for every product, if two products has the same discount it will just overwrite
31
28
  }
32
29
  else {
33
- if (discountCodeObj.type === enum_1.DiscountCodeTypes.PERCENTAGE) {
30
+ if (discountCodeObj.type === DiscountCodeTypes.PERCENTAGE) {
34
31
  discPercentageInteger = +(discountCodeObj.value / 100).toFixed(2);
35
32
  if (!discountCodeObj.applyToAllProducts) {
36
33
  discPercentageInteger = discountCodeObj.products.includes(current._id)
@@ -38,10 +35,10 @@ const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, st
38
35
  : 0;
39
36
  }
40
37
  }
41
- if (discountCodeObj.type === enum_1.DiscountCodeTypes.BUY_X_GET_Y) {
38
+ if (discountCodeObj.type === DiscountCodeTypes.BUY_X_GET_Y) {
42
39
  const discountType = discountCodeObj.buyAndGetConditions[0].getDiscountType;
43
40
  const discountValue = discountCodeObj.buyAndGetConditions[0].discountValue;
44
- if (discountType === enum_1.BuyAndGetConditionsTypes.PERCENTAGE && current.isBuyAndGetProduct) {
41
+ if (discountType === BuyAndGetConditionsTypes.PERCENTAGE && current.isBuyAndGetProduct) {
45
42
  discPercentageInteger = +(discountValue / 100).toFixed(2);
46
43
  }
47
44
  }
@@ -53,7 +50,7 @@ const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, st
53
50
  //GET PRODUCT PRICE WITH DISCOUNT
54
51
  const prodPriceWithDiscountPerUnit = prodPrice - discountAmountPerUnit;
55
52
  //GET PRODUCT TAXES APPLIED TO FINAL PRICE PER UNIT
56
- const taxPercentage = (0, helpers_1.getProductTaxesPercentage)(current, storeSettings);
53
+ const taxPercentage = getProductTaxesPercentage(current, storeSettings);
57
54
  const taxPercentageInteger = taxPercentage / 100;
58
55
  const prodPriceWithoutTaxesPerUnit = prodPriceWithDiscountPerUnit;
59
56
  const taxesAmountPerUnit = prodPriceWithoutTaxesPerUnit * taxPercentageInteger;
@@ -71,4 +68,3 @@ const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, st
71
68
  });
72
69
  return productTableImports;
73
70
  };
74
- exports.calculateTotalTaxesOverPrice = calculateTotalTaxesOverPrice;
@@ -0,0 +1,15 @@
1
+ import { ICustomer } from "../../interfaces/Customer";
2
+ import { IOrderProduct, ProductLineTotals } from "../../interfaces/Product";
3
+ import { IStore } from "../../interfaces/Store";
4
+ export declare const getProductTaxesPercentage: (productObj: IOrderProduct, store: IStore) => number;
5
+ export declare const getProductLineTotals: (productLinesTotals: ProductLineTotals[]) => {
6
+ totalQuantity: number;
7
+ totalImportWithDiscount: number;
8
+ totalImportWithoutDiscount: number;
9
+ totalImporTaxes: number;
10
+ totalDiscountAmount: number;
11
+ };
12
+ export declare const getShippingCost: (discountObject: any, requireShippingService: boolean, store: IStore) => number;
13
+ export declare const getCreditApplied: (selectedCustomer: {
14
+ customer: ICustomer;
15
+ } | undefined, orderTotal: number) => number;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCreditApplied = exports.getShippingCost = exports.getProductLineTotals = exports.getProductTaxesPercentage = void 0;
4
- const enum_1 = require("../../enum");
5
- const getProductTaxesPercentage = (productObj, store) => {
1
+ import { DiscountCodeTypes } from "../../enum";
2
+ export const getProductTaxesPercentage = (productObj, store) => {
6
3
  const getTaxValue = (tax, isTaxExempt) => {
7
4
  if (!tax) {
8
5
  // If no store tax configured, always return 0
@@ -20,8 +17,7 @@ const getProductTaxesPercentage = (productObj, store) => {
20
17
  const tax3 = getTaxValue(store.taxThree, productObj.taxExemptThree);
21
18
  return tax1 + tax2 + tax3;
22
19
  };
23
- exports.getProductTaxesPercentage = getProductTaxesPercentage;
24
- const getProductLineTotals = (productLinesTotals) => {
20
+ export const getProductLineTotals = (productLinesTotals) => {
25
21
  const totalQuantity = +productLinesTotals.reduce((acum, line) => acum + line.qty, 0).toFixed(2);
26
22
  const totalImportWithDiscount = +productLinesTotals
27
23
  .reduce((acum, line) => acum + line.productLineTotalWithDiscount, 0)
@@ -43,17 +39,15 @@ const getProductLineTotals = (productLinesTotals) => {
43
39
  totalDiscountAmount
44
40
  };
45
41
  };
46
- exports.getProductLineTotals = getProductLineTotals;
47
- const getShippingCost = (discountObject, requireShippingService, store) => {
42
+ export const getShippingCost = (discountObject, requireShippingService, store) => {
48
43
  var _a, _b;
49
44
  const shippingCost = requireShippingService ? (_b = (_a = store === null || store === void 0 ? void 0 : store.orderPageConfig) === null || _a === void 0 ? void 0 : _a.shippingServiceCost) !== null && _b !== void 0 ? _b : 0 : 0;
50
- if ((discountObject === null || discountObject === void 0 ? void 0 : discountObject.type) === enum_1.DiscountCodeTypes.FREE_DELIVERY) {
45
+ if ((discountObject === null || discountObject === void 0 ? void 0 : discountObject.type) === DiscountCodeTypes.FREE_DELIVERY) {
51
46
  return 0;
52
47
  }
53
48
  return shippingCost;
54
49
  };
55
- exports.getShippingCost = getShippingCost;
56
- const getCreditApplied = (selectedCustomer, orderTotal) => {
50
+ export const getCreditApplied = (selectedCustomer, orderTotal) => {
57
51
  var _a, _b;
58
52
  const customerCredit = (_b = (_a = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.customer) === null || _a === void 0 ? void 0 : _a.credit) !== null && _b !== void 0 ? _b : 0;
59
53
  if (customerCredit === 0 || !selectedCustomer) {
@@ -61,4 +55,3 @@ const getCreditApplied = (selectedCustomer, orderTotal) => {
61
55
  }
62
56
  return Math.min(customerCredit, orderTotal);
63
57
  };
64
- exports.getCreditApplied = getCreditApplied;
@@ -0,0 +1,2 @@
1
+ import { calculateOrderTotal } from './calculateOrderTotal';
2
+ export { calculateOrderTotal };
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateOrderTotal = void 0;
4
- const calculateOrderTotal_1 = require("./calculateOrderTotal");
5
- Object.defineProperty(exports, "calculateOrderTotal", { enumerable: true, get: function () { return calculateOrderTotal_1.calculateOrderTotal; } });
1
+ import { calculateOrderTotal } from './calculateOrderTotal';
2
+ export { calculateOrderTotal };
File without changes
File without changes
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.70",
3
+ "version": "0.0.72",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
+ "type": "module",
6
7
  "scripts": {
7
8
  "test": "jest",
8
9
  "build": "tsc",
@@ -3,6 +3,7 @@ import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
3
3
  // Define the type for the Axios instance
4
4
  let axiosInstance: AxiosInstance | null = null;
5
5
 
6
+ // const BASE_URL: string = 'http://localhost:5555/';
6
7
  const BASE_URL: string = 'https://washday-backend.herokuapp.com/';
7
8
 
8
9
  // Function to create or return the singleton instance
@@ -20,7 +20,7 @@ export const getList = async function (this: WashdayClientInstance, params: {
20
20
  const config = {
21
21
  headers: { Authorization: `Bearer ${this.apiToken}` }
22
22
  };
23
- const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params)
23
+ const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params);
24
24
  return await axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
25
25
  } catch (error) {
26
26
  console.error('Error fetching getStoreStaff:', error);
@@ -62,7 +62,8 @@ export const getCustomerOrders = async function (this: WashdayClientInstance, cu
62
62
  const config = {
63
63
  headers: { Authorization: `Bearer ${this.apiToken}` }
64
64
  };
65
- return await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/orders`, config);
65
+ const queryParams = generateQueryParamsStr(['limit', 'pageNum'], params);
66
+ return await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/orders?${queryParams}`, config);
66
67
  } catch (error) {
67
68
  console.error('Error fetching getCustomerHighlightsById:', error);
68
69
  throw error;
package/src/api/index.ts CHANGED
@@ -177,14 +177,4 @@ WashdayClient.prototype.csv = {
177
177
  exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
178
178
  };
179
179
 
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
180
  export default WashdayClient;
@@ -2,7 +2,7 @@ export const generateQueryParamsStr = (availableQueryParamsList: Array<string> =
2
2
  [key: string]: any
3
3
  } = {}) => {
4
4
  let queryParams = [];
5
- for (let availableParam in availableQueryParamsList) {
5
+ for (let availableParam of availableQueryParamsList) {
6
6
  if (receivedParamsObj.hasOwnProperty(availableParam)) {
7
7
  queryParams.push(`${availableParam}=${receivedParamsObj[availableParam]}`)
8
8
  }
package/tsconfig.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "es6",
4
- "module": "commonjs",
5
- "outDir": "./dist",
6
- "strict": true,
7
- "esModuleInterop": true
8
- },
9
- "include": ["src/**/*.ts"]
10
- }
2
+ "compilerOptions": {
3
+ "target": "ES6",
4
+ "module": "ESNext",
5
+ "strict": true,
6
+ "esModuleInterop": true,
7
+ "moduleResolution": "node",
8
+ "outDir": "dist" // Specify the output directory for JavaScript files
9
+ },
10
+ "include": ["src/**/*.ts"]
11
+ }