washday-sdk 1.0.2 → 1.1.0

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 (254) hide show
  1. package/README.md +126 -0
  2. package/babel.config.js +8 -0
  3. package/dist/api/attendance/delete.js +2 -0
  4. package/dist/api/attendance/get.js +83 -0
  5. package/dist/api/attendance/index.js +4 -0
  6. package/dist/api/attendance/post.js +39 -0
  7. package/dist/api/attendance/put.js +25 -0
  8. package/dist/api/auth/index.js +3 -0
  9. package/dist/api/auth/post.js +170 -0
  10. package/dist/api/axiosInstance.js +15 -11
  11. package/dist/api/cashierbox/delete.js +40 -0
  12. package/dist/api/cashierbox/get.js +63 -0
  13. package/dist/api/cashierbox/post.js +42 -0
  14. package/dist/api/cashierbox/put.js +42 -0
  15. package/dist/api/cashups/delete.js +25 -0
  16. package/dist/api/cashups/get.js +60 -0
  17. package/dist/api/cashups/index.js +4 -0
  18. package/dist/api/cashups/post.js +25 -0
  19. package/dist/api/cashups/put.js +52 -0
  20. package/dist/api/cfdi/delete.js +25 -0
  21. package/dist/api/cfdi/get.js +126 -0
  22. package/dist/api/cfdi/index.js +4 -0
  23. package/dist/api/cfdi/post.js +41 -0
  24. package/dist/api/cfdi/put.js +52 -0
  25. package/dist/api/companies/get.js +29 -0
  26. package/dist/api/companies/post.js +41 -0
  27. package/dist/api/companies/put.js +57 -0
  28. package/dist/api/countries/get.js +29 -0
  29. package/dist/api/countries/post.js +1 -0
  30. package/dist/api/countries/put.js +1 -0
  31. package/dist/api/csv/get.js +325 -0
  32. package/dist/api/csv/index.js +1 -0
  33. package/dist/api/customers/delete.js +40 -0
  34. package/dist/api/customers/get.js +75 -20
  35. package/dist/api/customers/index.js +4 -1
  36. package/dist/api/customers/post.js +41 -0
  37. package/dist/api/customers/put.js +52 -0
  38. package/dist/api/discounts/get.js +120 -0
  39. package/dist/api/discounts/post.js +40 -0
  40. package/dist/api/discounts/put.js +68 -0
  41. package/dist/api/index.js +316 -8
  42. package/dist/api/inventory/delete.js +26 -0
  43. package/dist/api/inventory/get.js +62 -0
  44. package/dist/api/inventory/index.js +4 -0
  45. package/dist/api/inventory/post.js +26 -0
  46. package/dist/api/inventory/put.js +41 -0
  47. package/dist/api/order/delete.js +40 -0
  48. package/dist/api/order/get.js +181 -0
  49. package/dist/api/order/index.js +4 -0
  50. package/dist/api/order/post.js +115 -0
  51. package/dist/api/order/put.js +202 -0
  52. package/dist/api/outsourcedOrders/delete.js +25 -0
  53. package/dist/api/outsourcedOrders/get.js +62 -0
  54. package/dist/api/outsourcedOrders/index.js +4 -0
  55. package/dist/api/outsourcedOrders/post.js +25 -0
  56. package/dist/api/outsourcedOrders/put.js +25 -0
  57. package/dist/api/partners/delete.js +25 -0
  58. package/dist/api/partners/get.js +40 -0
  59. package/dist/api/partners/index.js +4 -0
  60. package/dist/api/partners/post.js +25 -0
  61. package/dist/api/partners/put.js +25 -0
  62. package/dist/api/pdf/get.js +43 -0
  63. package/dist/api/pdf/index.js +1 -0
  64. package/dist/api/products/delete.js +40 -0
  65. package/dist/api/products/get.js +25 -0
  66. package/dist/api/products/index.js +4 -0
  67. package/dist/api/products/post.js +60 -0
  68. package/dist/api/products/put.js +40 -0
  69. package/dist/api/publics/get.js +26 -0
  70. package/dist/api/publics/index.js +1 -0
  71. package/dist/api/reports/get.js +303 -0
  72. package/dist/api/reports/index.js +1 -0
  73. package/dist/api/reviews/delete.js +15 -0
  74. package/dist/api/reviews/get.js +41 -0
  75. package/dist/api/reviews/index.js +4 -0
  76. package/dist/api/reviews/post.js +20 -0
  77. package/dist/api/reviews/put.js +52 -0
  78. package/dist/api/routes/delete.js +25 -0
  79. package/dist/api/routes/get.js +95 -0
  80. package/dist/api/routes/index.js +4 -0
  81. package/dist/api/routes/post.js +67 -0
  82. package/dist/api/routes/put.js +54 -0
  83. package/dist/api/sections/delete.js +25 -0
  84. package/dist/api/sections/get.js +71 -0
  85. package/dist/api/sections/index.js +4 -0
  86. package/dist/api/sections/post.js +26 -0
  87. package/dist/api/sections/put.js +25 -0
  88. package/dist/api/staff/delete.js +26 -0
  89. package/dist/api/staff/get.js +40 -0
  90. package/dist/api/staff/post.js +26 -0
  91. package/dist/api/staff/put.js +26 -0
  92. package/dist/api/stores/get.js +110 -0
  93. package/dist/api/stores/post.js +61 -0
  94. package/dist/api/stores/put.js +44 -0
  95. package/dist/api/stripe/get.js +1 -0
  96. package/dist/api/stripe/post.js +71 -0
  97. package/dist/api/stripe/put.js +1 -0
  98. package/dist/api/supplies/delete.js +26 -0
  99. package/dist/api/supplies/get.js +62 -0
  100. package/dist/api/supplies/post.js +26 -0
  101. package/dist/api/supplies/put.js +41 -0
  102. package/dist/api/users/delete.js +26 -0
  103. package/dist/api/users/post.js +25 -0
  104. package/dist/api/users/put.js +29 -0
  105. package/dist/enum/index.js +12 -7
  106. package/dist/index.js +3 -33
  107. package/dist/interfaces/Api.js +1 -3
  108. package/dist/interfaces/Apple.js +16 -0
  109. package/dist/interfaces/Attendance.js +1 -0
  110. package/dist/interfaces/Customer.js +1 -2
  111. package/dist/interfaces/Order.js +1 -2
  112. package/dist/interfaces/Permission.js +1 -2
  113. package/dist/interfaces/Product.js +1 -2
  114. package/dist/interfaces/Section.js +1 -2
  115. package/dist/interfaces/Store.js +1 -2
  116. package/dist/interfaces/StoreImage.js +1 -2
  117. package/dist/interfaces/User.js +1 -2
  118. package/dist/utils/apiUtils.js +9 -0
  119. package/dist/utils/index.js +2 -17
  120. package/dist/utils/orders/calculateOrderTotal.js +30 -21
  121. package/dist/utils/orders/calculateTotalTaxesIncluded.js +55 -29
  122. package/dist/utils/orders/calculateTotalTaxesOverPrice.js +56 -45
  123. package/dist/utils/orders/helpers.js +126 -17
  124. package/dist/utils/orders/index.js +3 -5
  125. package/dist/utils/receipt/generateReceiptHTML.js +157 -0
  126. package/dist/utils/util.js +63 -0
  127. package/docs/README.md +66 -0
  128. package/docs/examples/common-use-cases.md +487 -0
  129. package/docs/getting-started.md +237 -0
  130. package/docs/modules/attendance.md +404 -0
  131. package/jest.config.js +0 -0
  132. package/package.json +12 -4
  133. package/src/api/attendance/delete.ts +1 -0
  134. package/src/api/attendance/get.ts +81 -0
  135. package/src/api/attendance/index.ts +4 -0
  136. package/src/api/attendance/post.ts +37 -0
  137. package/src/api/attendance/put.ts +20 -0
  138. package/src/api/auth/index.ts +3 -0
  139. package/src/api/auth/post.ts +198 -0
  140. package/src/api/axiosInstance.ts +13 -3
  141. package/src/api/cashierbox/delete.ts +28 -0
  142. package/src/api/cashierbox/get.ts +53 -0
  143. package/src/api/cashierbox/post.ts +39 -0
  144. package/src/api/cashierbox/put.ts +32 -0
  145. package/src/api/cashups/delete.ts +15 -0
  146. package/src/api/cashups/get.ts +52 -0
  147. package/src/api/cashups/index.ts +4 -0
  148. package/src/api/cashups/post.ts +23 -0
  149. package/src/api/cashups/put.ts +53 -0
  150. package/src/api/cfdi/delete.ts +21 -0
  151. package/src/api/cfdi/get.ts +119 -0
  152. package/src/api/cfdi/index.ts +4 -0
  153. package/src/api/cfdi/post.ts +60 -0
  154. package/src/api/cfdi/put.ts +53 -0
  155. package/src/api/companies/get.ts +23 -0
  156. package/src/api/companies/post.ts +29 -0
  157. package/src/api/companies/put.ts +43 -0
  158. package/src/api/countries/get.ts +23 -0
  159. package/src/api/countries/post.ts +0 -0
  160. package/src/api/countries/put.ts +0 -0
  161. package/src/api/csv/get.ts +354 -0
  162. package/src/api/csv/index.ts +1 -0
  163. package/src/api/customers/delete.ts +29 -0
  164. package/src/api/customers/get.ts +80 -8
  165. package/src/api/customers/index.ts +4 -0
  166. package/src/api/customers/post.ts +48 -0
  167. package/src/api/customers/put.ts +68 -0
  168. package/src/api/discounts/get.ts +100 -0
  169. package/src/api/discounts/post.ts +35 -0
  170. package/src/api/discounts/put.ts +66 -0
  171. package/src/api/index.ts +318 -11
  172. package/src/api/inventory/delete.ts +16 -0
  173. package/src/api/inventory/get.ts +53 -0
  174. package/src/api/inventory/index.ts +4 -0
  175. package/src/api/inventory/post.ts +22 -0
  176. package/src/api/inventory/put.ts +35 -0
  177. package/src/api/order/delete.ts +29 -0
  178. package/src/api/order/get.ts +207 -0
  179. package/src/api/order/index.ts +4 -0
  180. package/src/api/order/post.ts +118 -0
  181. package/src/api/order/put.ts +224 -0
  182. package/src/api/outsourcedOrders/delete.ts +15 -0
  183. package/src/api/outsourcedOrders/get.ts +54 -0
  184. package/src/api/outsourcedOrders/index.ts +4 -0
  185. package/src/api/outsourcedOrders/post.ts +24 -0
  186. package/src/api/outsourcedOrders/put.ts +21 -0
  187. package/src/api/partners/delete.ts +15 -0
  188. package/src/api/partners/get.ts +28 -0
  189. package/src/api/partners/index.ts +4 -0
  190. package/src/api/partners/post.ts +21 -0
  191. package/src/api/partners/put.ts +21 -0
  192. package/src/api/pdf/get.ts +43 -0
  193. package/src/api/pdf/index.ts +1 -0
  194. package/src/api/products/delete.ts +28 -0
  195. package/src/api/products/get.ts +16 -0
  196. package/src/api/products/index.ts +4 -0
  197. package/src/api/products/post.ts +73 -0
  198. package/src/api/products/put.ts +49 -0
  199. package/src/api/publics/get.ts +16 -0
  200. package/src/api/publics/index.ts +1 -0
  201. package/src/api/reports/get.ts +329 -0
  202. package/src/api/reports/index.ts +1 -0
  203. package/src/api/reviews/delete.ts +15 -0
  204. package/src/api/reviews/get.ts +31 -0
  205. package/src/api/reviews/index.ts +4 -0
  206. package/src/api/reviews/post.ts +20 -0
  207. package/src/api/reviews/put.ts +53 -0
  208. package/src/api/routes/delete.ts +15 -0
  209. package/src/api/routes/get.ts +86 -0
  210. package/src/api/routes/index.ts +4 -0
  211. package/src/api/routes/post.ts +60 -0
  212. package/src/api/routes/put.ts +44 -0
  213. package/src/api/sections/delete.ts +15 -0
  214. package/src/api/sections/get.ts +67 -0
  215. package/src/api/sections/index.ts +4 -0
  216. package/src/api/sections/post.ts +22 -0
  217. package/src/api/sections/put.ts +23 -0
  218. package/src/api/staff/delete.ts +16 -0
  219. package/src/api/staff/get.ts +29 -0
  220. package/src/api/staff/post.ts +17 -0
  221. package/src/api/staff/put.ts +17 -0
  222. package/src/api/stores/get.ts +93 -0
  223. package/src/api/stores/post.ts +49 -0
  224. package/src/api/stores/put.ts +35 -0
  225. package/src/api/stripe/get.ts +0 -0
  226. package/src/api/stripe/post.ts +59 -0
  227. package/src/api/stripe/put.ts +0 -0
  228. package/src/api/supplies/delete.ts +16 -0
  229. package/src/api/supplies/get.ts +53 -0
  230. package/src/api/supplies/post.ts +26 -0
  231. package/src/api/supplies/put.ts +33 -0
  232. package/src/api/users/delete.ts +16 -0
  233. package/src/api/users/post.ts +18 -0
  234. package/src/api/users/put.ts +36 -0
  235. package/src/enum/index.ts +9 -1
  236. package/src/index.ts +1 -4
  237. package/src/interfaces/Api.ts +307 -2
  238. package/src/interfaces/Apple.ts +74 -0
  239. package/src/interfaces/Attendance.ts +45 -0
  240. package/src/interfaces/Customer.ts +15 -11
  241. package/src/interfaces/Order.ts +38 -1
  242. package/src/interfaces/Product.ts +1 -0
  243. package/src/interfaces/Store.ts +41 -0
  244. package/src/utils/apiUtils.ts +11 -0
  245. package/src/utils/index.ts +6 -1
  246. package/src/utils/orders/calculateOrderTotal.test.js +930 -0
  247. package/src/utils/orders/calculateOrderTotal.ts +60 -15
  248. package/src/utils/orders/calculateTotalTaxesIncluded.ts +57 -25
  249. package/src/utils/orders/calculateTotalTaxesOverPrice.ts +57 -41
  250. package/src/utils/orders/helpers.ts +195 -47
  251. package/src/utils/orders/index.ts +3 -1
  252. package/src/utils/receipt/generateReceiptHTML.ts +163 -0
  253. package/src/utils/util.ts +65 -0
  254. package/tsconfig.json +13 -9
@@ -0,0 +1,198 @@
1
+
2
+ import { WashdayClientInstance } from "../../interfaces/Api";
3
+ import { AppleAuthenticationCredential } from "../../interfaces/Apple";
4
+ import axiosInstance from "../axiosInstance";
5
+ const CUSTOMERSAPP_GET_AUTH = "api/v2/washdayapp/auth"
6
+ const REGULAR_USER_AUTH = "api/auth"
7
+
8
+ export const customerLoginToken = async function (this: WashdayClientInstance, params: {
9
+ token: string;
10
+ }): Promise<any> {
11
+ try {
12
+ const config = {};
13
+ return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/tokenLogin`, params, config);
14
+ } catch (error) {
15
+ console.error('Error fetching customerLoginToken:', error);
16
+ throw error;
17
+ }
18
+ };
19
+
20
+ export const appleLogin = async function (this: WashdayClientInstance, params: {
21
+ companyId: string;
22
+ storeId: string;
23
+ credentials: AppleAuthenticationCredential,
24
+ }): Promise<any> {
25
+ try {
26
+ const config = {};
27
+ return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/apple`, params, config);
28
+ } catch (error) {
29
+ console.error('Error fetching appleLogin:', error);
30
+ throw error;
31
+ }
32
+ };
33
+
34
+ export const facebookLogin = async function (this: WashdayClientInstance, params: {
35
+ companyId: string;
36
+ storeId: string;
37
+ accessToken: string,
38
+ authToken: string;
39
+ }): Promise<any> {
40
+ try {
41
+ const config = {};
42
+ return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/facebook`, params, config);
43
+ } catch (error) {
44
+ console.error('Error fetching facebookLogin:', error);
45
+ throw error;
46
+ }
47
+ };
48
+
49
+ export const customerRegularLogin = async function (this: WashdayClientInstance, params: {
50
+ companyId: string;
51
+ storeId: string;
52
+ email: string;
53
+ password: string;
54
+ }): Promise<any> {
55
+ try {
56
+ const config = {};
57
+ return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/login`, params, config);
58
+ } catch (error) {
59
+ console.error('Error fetching customerRegularLogin:', error);
60
+ throw error;
61
+ }
62
+ };
63
+
64
+ export const customerSignUp = async function (this: WashdayClientInstance, params: {
65
+ storeId: string;
66
+ companyId: string;
67
+ name: string;
68
+ phone: string;
69
+ email: string;
70
+ password: string;
71
+ }): Promise<any> {
72
+ try {
73
+ const config = {};
74
+ return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/signUp`, params, config);
75
+ } catch (error) {
76
+ console.error('Error fetching customerSignUp:', error);
77
+ throw error;
78
+ }
79
+ };
80
+
81
+ export const googleLogin = async function (this: WashdayClientInstance, params: {
82
+ companyId: string;
83
+ storeId: string;
84
+ credentials: {
85
+ email: string;
86
+ verified_email: boolean;
87
+ name: string;
88
+ give_name: string;
89
+ locale: string;
90
+ },
91
+ }): Promise<any> {
92
+ try {
93
+ const config = {};
94
+ return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/google`, params, config);
95
+ } catch (error) {
96
+ console.error('Error fetching googleLogin:', error);
97
+ throw error;
98
+ }
99
+ };
100
+
101
+ export const regularUserLogin = async function (this: WashdayClientInstance, params: {
102
+ email: string
103
+ password: string
104
+ }): Promise<any> {
105
+ try {
106
+ const config = {};
107
+ return await axiosInstance.post(`${REGULAR_USER_AUTH}/login`, params, config);
108
+ } catch (error) {
109
+ console.error('Error fetching regularUserLogin:', error);
110
+ throw error;
111
+ }
112
+ };
113
+
114
+ export const companySignUp = async function (this: WashdayClientInstance, params: {
115
+ email: string,
116
+ password: string,
117
+ companyName: string,
118
+ name: string,
119
+ phoneNumber: string,
120
+ country: string,
121
+ city: string,
122
+ languagePreference: string,
123
+ isActive: boolean
124
+ }): Promise<any> {
125
+ try {
126
+ const config = {};
127
+ return await axiosInstance.post(`${REGULAR_USER_AUTH}/register`, params, config);
128
+ } catch (error) {
129
+ console.error('Error fetching companySignUp:', error);
130
+ throw error;
131
+ }
132
+ };
133
+
134
+
135
+ export const regularUserTokenLogin = async function (this: WashdayClientInstance, params: {
136
+ token: string
137
+ }): Promise<any> {
138
+ try {
139
+ const config = {};
140
+ return await axiosInstance.post(`${REGULAR_USER_AUTH}/tokenLogin`, params, config);
141
+ } catch (error) {
142
+ console.error('Error fetching regularUserTokenLogin:', error);
143
+ throw error;
144
+ }
145
+ };
146
+
147
+
148
+ export const forgotPassword = async function (this: WashdayClientInstance, params: {
149
+ email: string;
150
+ }): Promise<any> {
151
+ try {
152
+ const config = {};
153
+ return await axiosInstance.post(`${REGULAR_USER_AUTH}/forget-password`, params, config);
154
+ } catch (error) {
155
+ console.error('Error fetching forgotPassword:', error);
156
+ throw error;
157
+ }
158
+ };
159
+
160
+
161
+ export const customersAppForgotPassword = async function (this: WashdayClientInstance, companyId: string, params: {
162
+ email: string;
163
+ }): Promise<any> {
164
+ try {
165
+ const config = {};
166
+ return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/${companyId}/forget-password`, params, config);
167
+ } catch (error) {
168
+ console.error('Error fetching customersAppForgotPassword:', error);
169
+ throw error;
170
+ }
171
+ };
172
+
173
+ export const customersAppChangePassword = async function (this: WashdayClientInstance, params: {
174
+ password: string
175
+ token: string | null
176
+ }): Promise<any> {
177
+ try {
178
+ const config = {};
179
+ return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/change-password`, params, config);
180
+ } catch (error) {
181
+ console.error('Error fetching customerSignUp:', error);
182
+ throw error;
183
+ }
184
+ };
185
+
186
+ export const pinLogin = async function (this: WashdayClientInstance, data: {
187
+ pinCode: string;
188
+ }): Promise<any> {
189
+ try {
190
+ const config = {
191
+ headers: { Authorization: `Bearer ${this.apiToken}` }
192
+ };
193
+ return await axiosInstance.post(`${REGULAR_USER_AUTH}/pin-login`, data, config);
194
+ } catch (error) {
195
+ console.error('Error fetching pinLogin:', error);
196
+ throw error;
197
+ }
198
+ };
@@ -1,8 +1,11 @@
1
1
  import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
2
+ import { v4 } from 'uuid';
2
3
 
3
4
  // Define the type for the Axios instance
4
5
  let axiosInstance: AxiosInstance | null = null;
5
6
 
7
+ // const BASE_URL: string = 'http://localhost:5555/';
8
+ // const BASE_URL: string = 'https://washday-backend-development.herokuapp.com/';
6
9
  const BASE_URL: string = 'https://washday-backend.herokuapp.com/';
7
10
 
8
11
  // Function to create or return the singleton instance
@@ -19,9 +22,14 @@ const getAxiosInstance = (): AxiosInstance => {
19
22
  // Add interceptor to set token and other options for every request
20
23
  axiosInstance.interceptors.request.use(
21
24
  (config) => {
22
- const { token, contentType = 'application/json', responseType = 'json', contentDisposition } = config.params || {};
23
- if (token) {
24
- config.headers.Authorization = `Bearer ${token}`;
25
+ const { token, responseType = 'json', contentDisposition } = config.params || {};
26
+ const { Authorization } = config.headers || {};
27
+ let contentType = config.headers['Content-Type'];
28
+ if (contentType === null || contentType === undefined) {
29
+ contentType = 'application/json';
30
+ }
31
+ if (Authorization || token) {
32
+ config.headers.Authorization = Authorization || `Bearer ${token}`;
25
33
  }
26
34
  if (contentType) {
27
35
  config.headers['Content-Type'] = contentType;
@@ -32,6 +40,8 @@ const getAxiosInstance = (): AxiosInstance => {
32
40
  if (contentDisposition) {
33
41
  config.headers['Content-Disposition'] = contentDisposition;
34
42
  }
43
+
44
+ config.headers['x-request-id'] = v4(); // used to track requests in the backend
35
45
  return config;
36
46
  },
37
47
  (error) => {
@@ -0,0 +1,28 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+ const GET_SET_CASHIER_BOX = (storeId: string) => `api/store/${storeId}/cashierbox`;
4
+ const GET_SET_CASHIER_BOX_MOVEMENT = (storeId: string, cashierBoxId: string) => `/api/store/cashierbox/movement/${storeId}/${cashierBoxId}`;
5
+
6
+ export const deleteCashierBoxById = async function (this: WashdayClientInstance, storeId: string, id: string): Promise<any> {
7
+ try {
8
+ const config = {
9
+ headers: { Authorization: `Bearer ${this.apiToken}` }
10
+ };
11
+ return await axiosInstance.delete(`${GET_SET_CASHIER_BOX(storeId)}/${id}`, config);
12
+ } catch (error) {
13
+ console.error('Error fetching getStoreStaff:', error);
14
+ throw error;
15
+ }
16
+ };
17
+
18
+ export const deleteCashierBoxMovementById = async function (this: WashdayClientInstance, { storeId, cashierBoxId, movementId }: { storeId: string, cashierBoxId: string, movementId: string }): Promise<any> {
19
+ try {
20
+ const config = {
21
+ headers: { Authorization: `Bearer ${this.apiToken}` }
22
+ };
23
+ return await axiosInstance.delete(`${GET_SET_CASHIER_BOX_MOVEMENT(storeId, cashierBoxId)}/${movementId}`, config);
24
+ } catch (error) {
25
+ console.error('Error fetching getStoreStaff:', error);
26
+ throw error;
27
+ }
28
+ };
@@ -0,0 +1,53 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+
4
+ const GET_SET_CASHIER_BOX = (storeId: string) => `api/store/${storeId}/cashierbox`;
5
+
6
+ export const getCashierboxesByStoreId = async function (this: WashdayClientInstance, storeId: string, queryParams?: string): Promise<any> {
7
+ try {
8
+ const config = {
9
+ headers: { Authorization: `Bearer ${this.apiToken}` }
10
+ };
11
+ const response = await axiosInstance.get(`${GET_SET_CASHIER_BOX(storeId)}?${queryParams || ''}`, config);
12
+ return response;
13
+ } catch (error) {
14
+ console.error('Error fetching getCashierboxesByStoreId:', error);
15
+ throw error;
16
+ }
17
+ };
18
+
19
+ export const getCashierboxesById = async function (this: WashdayClientInstance, storeId: string, id: string, queryParams?: string): Promise<any> {
20
+ try {
21
+ const config = {
22
+ headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ };
24
+ const response = await axiosInstance.get(`${GET_SET_CASHIER_BOX(storeId)}/${id}?${queryParams}`, config);
25
+ return response;
26
+ } catch (error) {
27
+ console.error('Error fetching getCashierboxesById:', error);
28
+ throw error;
29
+ }
30
+ };
31
+
32
+ export const getCashierBoxMovementsHistory = async function (this: WashdayClientInstance, storeId: string, id: string, params?: {
33
+ pageNum: number;
34
+ limit: number
35
+ }): Promise<any> {
36
+ try {
37
+ const config = {
38
+ headers: { Authorization: `Bearer ${this.apiToken}` }
39
+ };
40
+ let queryParams = '';
41
+ if (params?.hasOwnProperty('pageNum')) {
42
+ queryParams += `pageNum=${params?.pageNum}`
43
+ }
44
+ if (params?.hasOwnProperty('limit')) {
45
+ queryParams += `&limit=${params?.limit}`
46
+ }
47
+ const response = await axiosInstance.get(`${GET_SET_CASHIER_BOX(storeId)}/${id}/history?${queryParams}`, config);
48
+ return response;
49
+ } catch (error) {
50
+ console.error('Error fetching getCashierBoxMovementsHistory:', error);
51
+ throw error;
52
+ }
53
+ };
@@ -0,0 +1,39 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+
4
+ const GET_SET_CASHIER_BOX = (storeId: string) => `api/store/${storeId}/cashierbox`;
5
+ const GET_SET_CASHIER_BOX_MOVEMENT = (storeId: string, cashierBoxId: string) => `/api/store/cashierbox/movement/${storeId}/${cashierBoxId}`;
6
+
7
+ export const createCashierBox = async function (this: WashdayClientInstance, storeId: string, data: {
8
+ name: string
9
+ }): Promise<any> {
10
+ try {
11
+ const config = {
12
+ headers: { Authorization: `Bearer ${this.apiToken}` }
13
+ };
14
+ const response = await axiosInstance.post(`${GET_SET_CASHIER_BOX(storeId)}`, data, config);
15
+ return response;
16
+ } catch (error) {
17
+ console.error('Error fetching getStoreStaff:', error);
18
+ throw error;
19
+ }
20
+ };
21
+
22
+ export const addCashierBoxMovement = async function (this: WashdayClientInstance, storeId: string, id: string, data: {
23
+ type: string;
24
+ date: Date;
25
+ amount: number,
26
+ notes?: string;
27
+ paymentMethod: string;
28
+ }): Promise<any> {
29
+ try {
30
+ const config = {
31
+ headers: { Authorization: `Bearer ${this.apiToken}` }
32
+ };
33
+ const response = await axiosInstance.post(`${GET_SET_CASHIER_BOX(storeId)}/${id}/add-movement`, data, config);
34
+ return response;
35
+ } catch (error) {
36
+ console.error('Error fetching createStoreImage:', error);
37
+ throw error;
38
+ }
39
+ };
@@ -0,0 +1,32 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+
4
+ const GET_SET_CASHIER_BOX = (storeId: string) => `api/store/${storeId}/cashierbox`;
5
+ const GET_SET_CASHIER_BOX_MOVEMENT = (storeId: string, cashierBoxId: string) => `/api/store/cashierbox/movement/${storeId}/${cashierBoxId}`;
6
+
7
+ export const updateCashierBoxById = async function (this: WashdayClientInstance, storeId: string, id: string, data: { name: string }): Promise<any> {
8
+ try {
9
+ const config = {
10
+ headers: { Authorization: `Bearer ${this.apiToken}` }
11
+ };
12
+ const response = await axiosInstance.put(`${GET_SET_CASHIER_BOX(storeId)}/${id}`, data, config);
13
+ return response;
14
+ } catch (error) {
15
+ console.error('Error fetching getStoreById:', error);
16
+ throw error;
17
+ }
18
+ };
19
+
20
+ export const updateCashierBoxMovementById = async function (this: WashdayClientInstance, { storeId, cashierBoxId, id }: { storeId: string, cashierBoxId: string, id: string }, data: { name: string }): Promise<any> {
21
+ try {
22
+ const config = {
23
+ headers: { Authorization: `Bearer ${this.apiToken}` }
24
+ };
25
+ const response = await axiosInstance.put(`${GET_SET_CASHIER_BOX_MOVEMENT(storeId, cashierBoxId)}/${id}`, data, config);
26
+ return response;
27
+ } catch (error) {
28
+ console.error('Error fetching getStoreById:', error);
29
+ throw error;
30
+ }
31
+ };
32
+
@@ -0,0 +1,15 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+ const GET_CASH_UP_REPORTS = 'api/cashupreports';
4
+
5
+ export const deleteCashUpReport = async function (this: WashdayClientInstance, storeId: string, id: string): Promise<any> {
6
+ try {
7
+ const config = {
8
+ headers: { Authorization: `Bearer ${this.apiToken}` }
9
+ };
10
+ return await axiosInstance.delete(`${GET_CASH_UP_REPORTS}/${storeId}/${id}`, config);
11
+ } catch (error) {
12
+ console.error('Error fetching:', error);
13
+ throw error;
14
+ }
15
+ }
@@ -0,0 +1,52 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { IOrder } from "../../interfaces/Order";
3
+ import { ICashUpReport } from "../../interfaces/Store";
4
+ import { generateQueryParamsStr } from "../../utils/apiUtils";
5
+ import axiosInstance from "../axiosInstance";
6
+ const GET_CASH_UP = 'api/cashup';
7
+ const GET_CASH_UP_REPORTS = 'api/cashupreports';
8
+
9
+ export const getList = async function (this: WashdayClientInstance, storeId: string, params: {
10
+ pageNum?: string;
11
+ limit?: string;
12
+ cashierBoxId?: string;
13
+ }): Promise<any> {
14
+ try {
15
+ const config = {
16
+ headers: { Authorization: `Bearer ${this.apiToken}` }
17
+ };
18
+ const queryParams = generateQueryParamsStr([
19
+ 'pageNum',
20
+ 'limit',
21
+ 'cashierBoxId'
22
+ ], params);
23
+ return await axiosInstance.get(`${GET_CASH_UP_REPORTS}/${storeId}?${queryParams}`, config);
24
+ } catch (error) {
25
+ console.error('Error fetching getList orders:', error);
26
+ throw error;
27
+ }
28
+ };
29
+
30
+ export const getById = async function (this: WashdayClientInstance, storeId: string, id: string): Promise<any> {
31
+ try {
32
+ const config = {
33
+ headers: { Authorization: `Bearer ${this.apiToken}` }
34
+ };
35
+ return await axiosInstance.get(`${GET_CASH_UP_REPORTS}/${storeId}/${id}`, config);
36
+ } catch (error) {
37
+ console.error('Error fetching:', error);
38
+ throw error;
39
+ }
40
+ }
41
+
42
+ export const getPreviewDataForCashClose = async function (this: WashdayClientInstance, storeId: string, id: string): Promise<any> {
43
+ try {
44
+ const config = {
45
+ headers: { Authorization: `Bearer ${this.apiToken}` }
46
+ };
47
+ return await axiosInstance.get(`${GET_CASH_UP}/${storeId}/${id}`, config);
48
+ } catch (error) {
49
+ console.error('Error fetching:', error);
50
+ throw error;
51
+ }
52
+ }
@@ -0,0 +1,4 @@
1
+ export * as deleteModule from './delete';
2
+ export * as getModule from './get';
3
+ export * as postModule from './post';
4
+ // export * as putModule from './put';
@@ -0,0 +1,23 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+ const GET_CASH_UP = 'api/cashup';
4
+
5
+ export const create = async function (this: WashdayClientInstance, storeId: string, id: string, data: {
6
+ cashierBox: string;
7
+ startingCash: number;
8
+ declaredCash: number;
9
+ declaredCard: number;
10
+ declaredTransfer: number;
11
+ cashToBank: number;
12
+ notes: string;
13
+ }): Promise<any> {
14
+ try {
15
+ const config = {
16
+ headers: { Authorization: `Bearer ${this.apiToken}` }
17
+ };
18
+ return await axiosInstance.post(`${GET_CASH_UP}/${storeId}/${id}`, data, config);
19
+ } catch (error) {
20
+ console.error('Error fetching create:', error);
21
+ throw error;
22
+ }
23
+ };
@@ -0,0 +1,53 @@
1
+ // import { WashdayClientInstance } from "../../interfaces/Api";
2
+ // import axiosInstance from "../axiosInstance";
3
+ // const GET_SET_ORDER = 'api/v2/order';
4
+ // const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
5
+
6
+ // export const updateById = async function (this: WashdayClientInstance, id: string, data: {
7
+ // status?: string,
8
+ // products?: any[],
9
+ // buyAndGetProducts?: any[],
10
+ // customer?: string,
11
+ // discountCode?: string | null,
12
+ // notes?: string,
13
+ // privateNotes?: string,
14
+ // delivery?: boolean,
15
+ // pickup?: boolean,
16
+ // express?: boolean,
17
+ // deliveryInfo?: {
18
+ // date: Date,
19
+ // fromTime: string,
20
+ // toTime?: string
21
+ // },
22
+ // pickupInfo?: {
23
+ // date: Date,
24
+ // fromTime: string,
25
+ // toTime?: string
26
+ // },
27
+ // notifyBy?: string,
28
+ // }): Promise<any> {
29
+ // try {
30
+ // const config = {
31
+ // headers: { Authorization: `Bearer ${this.apiToken}` }
32
+ // };
33
+ // return await axiosInstance.put(`${GET_SET_ORDER}/${id}`, data, config);
34
+ // } catch (error) {
35
+ // console.error('Error fetching updateById:', error);
36
+ // throw error;
37
+ // }
38
+ // };
39
+
40
+ // export const updatePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string, data: {
41
+ // amountPaid: number
42
+ // updatedDate: Date
43
+ // }): Promise<any> {
44
+ // try {
45
+ // const config = {
46
+ // headers: { Authorization: `Bearer ${this.apiToken}` }
47
+ // };
48
+ // return await axiosInstance.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
49
+ // } catch (error) {
50
+ // console.error('Error fetching updateById:', error);
51
+ // throw error;
52
+ // }
53
+ // };
@@ -0,0 +1,21 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+ const GET_SET_CFDI = 'api/cfdi';
4
+
5
+ export const cancelCFDI = async function (this: WashdayClientInstance, id: string, data: {
6
+ motive: string
7
+ substitution?: string
8
+ }): Promise<any> {
9
+ try {
10
+ const config = {
11
+ headers: { Authorization: `Bearer ${this.apiToken}` }
12
+ };
13
+ return await axiosInstance.delete(`${GET_SET_CFDI}/${id}`, {
14
+ ...config,
15
+ data
16
+ });
17
+ } catch (error) {
18
+ console.error('Error fetching deleteById:', error);
19
+ throw error;
20
+ }
21
+ };
@@ -0,0 +1,119 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { generateQueryParamsStr } from "../../utils/apiUtils";
3
+ import axiosInstance from "../axiosInstance";
4
+ const GET_ORDERS_CFDI_PREVIEW = (orderID: string) => `api/order/${orderID}/preview/cfdi`;
5
+ const GET_SET_CFDI = 'api/cfdi';
6
+
7
+ export const getList = async function (this: WashdayClientInstance, params: {
8
+ query?: string;
9
+ storeId?: string;
10
+ fromDate?: string;
11
+ toDate?: string;
12
+ limit?: string;
13
+ pageNum?: string;
14
+ }): Promise<any> {
15
+ try {
16
+ const config = {
17
+ headers: { Authorization: `Bearer ${this.apiToken}` }
18
+ };
19
+ const queryParams = generateQueryParamsStr([
20
+ 'query',
21
+ 'storeId',
22
+ 'fromDate',
23
+ 'toDate',
24
+ 'limit',
25
+ 'pageNum'
26
+ ], params);
27
+
28
+ return await axiosInstance.get(`${GET_SET_CFDI}?${queryParams}`, config);
29
+ } catch (error) {
30
+ console.error('Error fetching getList CFDI:', error);
31
+ throw error;
32
+ }
33
+ };
34
+
35
+ //todo: remove
36
+ //@DEPRECATED USE getCFDIPreview instead
37
+ export const getCFDIPreviewByOrderId = async function (this: WashdayClientInstance, id: string): Promise<any> {
38
+ try {
39
+ const config = {
40
+ headers: { Authorization: `Bearer ${this.apiToken}` }
41
+ };
42
+ return await axiosInstance.get(`${GET_ORDERS_CFDI_PREVIEW(id)}`, config);
43
+ } catch (error) {
44
+ console.error('Error fetching:', error);
45
+ throw error;
46
+ }
47
+ }
48
+
49
+
50
+ export const downloadCFDIPDF = async function (this: WashdayClientInstance, id: string): Promise<any> {
51
+ try {
52
+ const config = {
53
+ headers: {
54
+ Authorization: `Bearer ${this.apiToken}`,
55
+ 'Content-Type': 'multipart/form-data',
56
+ 'Content-disposition': 'attachment; filename=[file.pdf]',
57
+ },
58
+ params: {
59
+ responseType: 'arraybuffer'
60
+ }
61
+ };
62
+ return await axiosInstance.get(`${GET_SET_CFDI}/${id}/download/pdf`, config);
63
+ } catch (error) {
64
+ console.error('Error fetching downloadCFDIPDF:', error);
65
+ throw error;
66
+ }
67
+ };
68
+
69
+ export const downloadCFDIZIP = async function (this: WashdayClientInstance, id: string): Promise<any> {
70
+ try {
71
+ const config = {
72
+ headers: {
73
+ Authorization: `Bearer ${this.apiToken}`,
74
+ 'Content-Type': 'multipart/form-data',
75
+ 'Content-disposition': 'attachment; filename=[file.zip]',
76
+ },
77
+ params: {
78
+ responseType: 'arraybuffer'
79
+ }
80
+ };
81
+ return await axiosInstance.get(`${GET_SET_CFDI}/${id}/download/zip`, config);
82
+ } catch (error) {
83
+ console.error('Error fetching downloadCFDIZIP:', error);
84
+ throw error;
85
+ }
86
+ };
87
+
88
+
89
+ export const sendCFDIByEmail = async function (this: WashdayClientInstance, id: string): Promise<any> {
90
+ try {
91
+ const config = {
92
+ headers: { Authorization: `Bearer ${this.apiToken}` }
93
+ };
94
+ return await axiosInstance.get(`${GET_SET_CFDI}/${id}/email`, config);
95
+ } catch (error) {
96
+ console.error('Error fetching:', error);
97
+ throw error;
98
+ }
99
+ }
100
+
101
+ // THIS IS FOR WHEN MODAL OPENS AND WE WANT TO GET PREVIEW DATA
102
+ export const getCFDIPreview = async function (this: WashdayClientInstance, params: {
103
+ ordersID?: string[];
104
+ customer?: string
105
+ }): Promise<any> {
106
+ try {
107
+ const config = {
108
+ headers: { Authorization: `Bearer ${this.apiToken}` }
109
+ };
110
+ const queryParams = generateQueryParamsStr([
111
+ 'ordersID',
112
+ 'customer',
113
+ ], params);
114
+ return await axiosInstance.get(`${GET_SET_CFDI}/preview?${queryParams}`, config);
115
+ } catch (error) {
116
+ console.error('Error fetching:', error);
117
+ throw error;
118
+ }
119
+ }