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.
- package/README.md +126 -0
- package/babel.config.js +8 -0
- package/dist/api/attendance/delete.js +2 -0
- package/dist/api/attendance/get.js +83 -0
- package/dist/api/attendance/index.js +4 -0
- package/dist/api/attendance/post.js +39 -0
- package/dist/api/attendance/put.js +25 -0
- package/dist/api/auth/index.js +3 -0
- package/dist/api/auth/post.js +170 -0
- package/dist/api/axiosInstance.js +15 -11
- package/dist/api/cashierbox/delete.js +40 -0
- package/dist/api/cashierbox/get.js +63 -0
- package/dist/api/cashierbox/post.js +42 -0
- package/dist/api/cashierbox/put.js +42 -0
- package/dist/api/cashups/delete.js +25 -0
- package/dist/api/cashups/get.js +60 -0
- package/dist/api/cashups/index.js +4 -0
- package/dist/api/cashups/post.js +25 -0
- package/dist/api/cashups/put.js +52 -0
- package/dist/api/cfdi/delete.js +25 -0
- package/dist/api/cfdi/get.js +126 -0
- package/dist/api/cfdi/index.js +4 -0
- package/dist/api/cfdi/post.js +41 -0
- package/dist/api/cfdi/put.js +52 -0
- package/dist/api/companies/get.js +29 -0
- package/dist/api/companies/post.js +41 -0
- package/dist/api/companies/put.js +57 -0
- package/dist/api/countries/get.js +29 -0
- package/dist/api/countries/post.js +1 -0
- package/dist/api/countries/put.js +1 -0
- package/dist/api/csv/get.js +325 -0
- package/dist/api/csv/index.js +1 -0
- package/dist/api/customers/delete.js +40 -0
- package/dist/api/customers/get.js +75 -20
- package/dist/api/customers/index.js +4 -1
- package/dist/api/customers/post.js +41 -0
- package/dist/api/customers/put.js +52 -0
- package/dist/api/discounts/get.js +120 -0
- package/dist/api/discounts/post.js +40 -0
- package/dist/api/discounts/put.js +68 -0
- package/dist/api/index.js +316 -8
- package/dist/api/inventory/delete.js +26 -0
- package/dist/api/inventory/get.js +62 -0
- package/dist/api/inventory/index.js +4 -0
- package/dist/api/inventory/post.js +26 -0
- package/dist/api/inventory/put.js +41 -0
- package/dist/api/order/delete.js +40 -0
- package/dist/api/order/get.js +181 -0
- package/dist/api/order/index.js +4 -0
- package/dist/api/order/post.js +115 -0
- package/dist/api/order/put.js +202 -0
- package/dist/api/outsourcedOrders/delete.js +25 -0
- package/dist/api/outsourcedOrders/get.js +62 -0
- package/dist/api/outsourcedOrders/index.js +4 -0
- package/dist/api/outsourcedOrders/post.js +25 -0
- package/dist/api/outsourcedOrders/put.js +25 -0
- package/dist/api/partners/delete.js +25 -0
- package/dist/api/partners/get.js +40 -0
- package/dist/api/partners/index.js +4 -0
- package/dist/api/partners/post.js +25 -0
- package/dist/api/partners/put.js +25 -0
- package/dist/api/pdf/get.js +43 -0
- package/dist/api/pdf/index.js +1 -0
- package/dist/api/products/delete.js +40 -0
- package/dist/api/products/get.js +25 -0
- package/dist/api/products/index.js +4 -0
- package/dist/api/products/post.js +60 -0
- package/dist/api/products/put.js +40 -0
- package/dist/api/publics/get.js +26 -0
- package/dist/api/publics/index.js +1 -0
- package/dist/api/reports/get.js +303 -0
- package/dist/api/reports/index.js +1 -0
- package/dist/api/reviews/delete.js +15 -0
- package/dist/api/reviews/get.js +41 -0
- package/dist/api/reviews/index.js +4 -0
- package/dist/api/reviews/post.js +20 -0
- package/dist/api/reviews/put.js +52 -0
- package/dist/api/routes/delete.js +25 -0
- package/dist/api/routes/get.js +95 -0
- package/dist/api/routes/index.js +4 -0
- package/dist/api/routes/post.js +67 -0
- package/dist/api/routes/put.js +54 -0
- package/dist/api/sections/delete.js +25 -0
- package/dist/api/sections/get.js +71 -0
- package/dist/api/sections/index.js +4 -0
- package/dist/api/sections/post.js +26 -0
- package/dist/api/sections/put.js +25 -0
- package/dist/api/staff/delete.js +26 -0
- package/dist/api/staff/get.js +40 -0
- package/dist/api/staff/post.js +26 -0
- package/dist/api/staff/put.js +26 -0
- package/dist/api/stores/get.js +110 -0
- package/dist/api/stores/post.js +61 -0
- package/dist/api/stores/put.js +44 -0
- package/dist/api/stripe/get.js +1 -0
- package/dist/api/stripe/post.js +71 -0
- package/dist/api/stripe/put.js +1 -0
- package/dist/api/supplies/delete.js +26 -0
- package/dist/api/supplies/get.js +62 -0
- package/dist/api/supplies/post.js +26 -0
- package/dist/api/supplies/put.js +41 -0
- package/dist/api/users/delete.js +26 -0
- package/dist/api/users/post.js +25 -0
- package/dist/api/users/put.js +29 -0
- package/dist/enum/index.js +12 -7
- package/dist/index.js +3 -33
- package/dist/interfaces/Api.js +1 -3
- package/dist/interfaces/Apple.js +16 -0
- package/dist/interfaces/Attendance.js +1 -0
- package/dist/interfaces/Customer.js +1 -2
- package/dist/interfaces/Order.js +1 -2
- package/dist/interfaces/Permission.js +1 -2
- package/dist/interfaces/Product.js +1 -2
- package/dist/interfaces/Section.js +1 -2
- package/dist/interfaces/Store.js +1 -2
- package/dist/interfaces/StoreImage.js +1 -2
- package/dist/interfaces/User.js +1 -2
- package/dist/utils/apiUtils.js +9 -0
- package/dist/utils/index.js +2 -17
- package/dist/utils/orders/calculateOrderTotal.js +30 -21
- package/dist/utils/orders/calculateTotalTaxesIncluded.js +55 -29
- package/dist/utils/orders/calculateTotalTaxesOverPrice.js +56 -45
- package/dist/utils/orders/helpers.js +126 -17
- package/dist/utils/orders/index.js +3 -5
- package/dist/utils/receipt/generateReceiptHTML.js +157 -0
- package/dist/utils/util.js +63 -0
- package/docs/README.md +66 -0
- package/docs/examples/common-use-cases.md +487 -0
- package/docs/getting-started.md +237 -0
- package/docs/modules/attendance.md +404 -0
- package/jest.config.js +0 -0
- package/package.json +12 -4
- package/src/api/attendance/delete.ts +1 -0
- package/src/api/attendance/get.ts +81 -0
- package/src/api/attendance/index.ts +4 -0
- package/src/api/attendance/post.ts +37 -0
- package/src/api/attendance/put.ts +20 -0
- package/src/api/auth/index.ts +3 -0
- package/src/api/auth/post.ts +198 -0
- package/src/api/axiosInstance.ts +13 -3
- package/src/api/cashierbox/delete.ts +28 -0
- package/src/api/cashierbox/get.ts +53 -0
- package/src/api/cashierbox/post.ts +39 -0
- package/src/api/cashierbox/put.ts +32 -0
- package/src/api/cashups/delete.ts +15 -0
- package/src/api/cashups/get.ts +52 -0
- package/src/api/cashups/index.ts +4 -0
- package/src/api/cashups/post.ts +23 -0
- package/src/api/cashups/put.ts +53 -0
- package/src/api/cfdi/delete.ts +21 -0
- package/src/api/cfdi/get.ts +119 -0
- package/src/api/cfdi/index.ts +4 -0
- package/src/api/cfdi/post.ts +60 -0
- package/src/api/cfdi/put.ts +53 -0
- package/src/api/companies/get.ts +23 -0
- package/src/api/companies/post.ts +29 -0
- package/src/api/companies/put.ts +43 -0
- package/src/api/countries/get.ts +23 -0
- package/src/api/countries/post.ts +0 -0
- package/src/api/countries/put.ts +0 -0
- package/src/api/csv/get.ts +354 -0
- package/src/api/csv/index.ts +1 -0
- package/src/api/customers/delete.ts +29 -0
- package/src/api/customers/get.ts +80 -8
- package/src/api/customers/index.ts +4 -0
- package/src/api/customers/post.ts +48 -0
- package/src/api/customers/put.ts +68 -0
- package/src/api/discounts/get.ts +100 -0
- package/src/api/discounts/post.ts +35 -0
- package/src/api/discounts/put.ts +66 -0
- package/src/api/index.ts +318 -11
- package/src/api/inventory/delete.ts +16 -0
- package/src/api/inventory/get.ts +53 -0
- package/src/api/inventory/index.ts +4 -0
- package/src/api/inventory/post.ts +22 -0
- package/src/api/inventory/put.ts +35 -0
- package/src/api/order/delete.ts +29 -0
- package/src/api/order/get.ts +207 -0
- package/src/api/order/index.ts +4 -0
- package/src/api/order/post.ts +118 -0
- package/src/api/order/put.ts +224 -0
- package/src/api/outsourcedOrders/delete.ts +15 -0
- package/src/api/outsourcedOrders/get.ts +54 -0
- package/src/api/outsourcedOrders/index.ts +4 -0
- package/src/api/outsourcedOrders/post.ts +24 -0
- package/src/api/outsourcedOrders/put.ts +21 -0
- package/src/api/partners/delete.ts +15 -0
- package/src/api/partners/get.ts +28 -0
- package/src/api/partners/index.ts +4 -0
- package/src/api/partners/post.ts +21 -0
- package/src/api/partners/put.ts +21 -0
- package/src/api/pdf/get.ts +43 -0
- package/src/api/pdf/index.ts +1 -0
- package/src/api/products/delete.ts +28 -0
- package/src/api/products/get.ts +16 -0
- package/src/api/products/index.ts +4 -0
- package/src/api/products/post.ts +73 -0
- package/src/api/products/put.ts +49 -0
- package/src/api/publics/get.ts +16 -0
- package/src/api/publics/index.ts +1 -0
- package/src/api/reports/get.ts +329 -0
- package/src/api/reports/index.ts +1 -0
- package/src/api/reviews/delete.ts +15 -0
- package/src/api/reviews/get.ts +31 -0
- package/src/api/reviews/index.ts +4 -0
- package/src/api/reviews/post.ts +20 -0
- package/src/api/reviews/put.ts +53 -0
- package/src/api/routes/delete.ts +15 -0
- package/src/api/routes/get.ts +86 -0
- package/src/api/routes/index.ts +4 -0
- package/src/api/routes/post.ts +60 -0
- package/src/api/routes/put.ts +44 -0
- package/src/api/sections/delete.ts +15 -0
- package/src/api/sections/get.ts +67 -0
- package/src/api/sections/index.ts +4 -0
- package/src/api/sections/post.ts +22 -0
- package/src/api/sections/put.ts +23 -0
- package/src/api/staff/delete.ts +16 -0
- package/src/api/staff/get.ts +29 -0
- package/src/api/staff/post.ts +17 -0
- package/src/api/staff/put.ts +17 -0
- package/src/api/stores/get.ts +93 -0
- package/src/api/stores/post.ts +49 -0
- package/src/api/stores/put.ts +35 -0
- package/src/api/stripe/get.ts +0 -0
- package/src/api/stripe/post.ts +59 -0
- package/src/api/stripe/put.ts +0 -0
- package/src/api/supplies/delete.ts +16 -0
- package/src/api/supplies/get.ts +53 -0
- package/src/api/supplies/post.ts +26 -0
- package/src/api/supplies/put.ts +33 -0
- package/src/api/users/delete.ts +16 -0
- package/src/api/users/post.ts +18 -0
- package/src/api/users/put.ts +36 -0
- package/src/enum/index.ts +9 -1
- package/src/index.ts +1 -4
- package/src/interfaces/Api.ts +307 -2
- package/src/interfaces/Apple.ts +74 -0
- package/src/interfaces/Attendance.ts +45 -0
- package/src/interfaces/Customer.ts +15 -11
- package/src/interfaces/Order.ts +38 -1
- package/src/interfaces/Product.ts +1 -0
- package/src/interfaces/Store.ts +41 -0
- package/src/utils/apiUtils.ts +11 -0
- package/src/utils/index.ts +6 -1
- package/src/utils/orders/calculateOrderTotal.test.js +930 -0
- package/src/utils/orders/calculateOrderTotal.ts +60 -15
- package/src/utils/orders/calculateTotalTaxesIncluded.ts +57 -25
- package/src/utils/orders/calculateTotalTaxesOverPrice.ts +57 -41
- package/src/utils/orders/helpers.ts +195 -47
- package/src/utils/orders/index.ts +3 -1
- package/src/utils/receipt/generateReceiptHTML.ts +163 -0
- package/src/utils/util.ts +65 -0
- package/tsconfig.json +13 -9
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_SET_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
|
|
12
|
+
export const getSupplies = function (storeId, queryParams) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const config = {
|
|
16
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
17
|
+
};
|
|
18
|
+
const response = yield axiosInstance.get(`${GET_SET_SUPPLY(storeId)}?${queryParams}`, config);
|
|
19
|
+
return response;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error('Error fetching getSupplies:', error);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export const getSupplyById = function (storeId, id) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
try {
|
|
30
|
+
const config = {
|
|
31
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
32
|
+
};
|
|
33
|
+
return yield axiosInstance.get(`${GET_SET_SUPPLY(storeId)}/${id}`, config);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error fetching getStoreSupplyById:', error);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
export const getSupplyHistory = function (storeId, id, params) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
try {
|
|
44
|
+
const config = {
|
|
45
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
46
|
+
};
|
|
47
|
+
let queryParams = '';
|
|
48
|
+
if (params === null || params === void 0 ? void 0 : params.hasOwnProperty('pageNum')) {
|
|
49
|
+
queryParams += `pageNum=${params === null || params === void 0 ? void 0 : params.pageNum}`;
|
|
50
|
+
}
|
|
51
|
+
if (params === null || params === void 0 ? void 0 : params.hasOwnProperty('limit')) {
|
|
52
|
+
queryParams += `&limit=${params === null || params === void 0 ? void 0 : params.limit}`;
|
|
53
|
+
}
|
|
54
|
+
const response = yield axiosInstance.get(`${GET_SET_SUPPLY(storeId)}/${id}/history?${queryParams}`, config);
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error('Error fetching getCashierBoxMovementsHistory:', error);
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_SET_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
|
|
12
|
+
export const createSupply = function (storeId, data) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const config = {
|
|
16
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
17
|
+
};
|
|
18
|
+
const response = yield axiosInstance.post(`${GET_SET_SUPPLY(storeId)}`, data, config);
|
|
19
|
+
return response;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error('Error fetching createSupply:', error);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_SET_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
|
|
12
|
+
export const updateSupplyById = function (storeId, id, data) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const config = {
|
|
16
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
17
|
+
};
|
|
18
|
+
const response = yield axiosInstance.put(`${GET_SET_SUPPLY(storeId)}/${id}`, data, config);
|
|
19
|
+
return response;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error('Error fetching getStoreById:', error);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export const addSupplyStock = function (storeId, id, data) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
try {
|
|
30
|
+
const config = {
|
|
31
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
32
|
+
};
|
|
33
|
+
const response = yield axiosInstance.put(`${GET_SET_SUPPLY(storeId)}/${id}/addStock`, data, config);
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error('Error fetching addSupplyStock:', error);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_SET_USER = 'api/user';
|
|
12
|
+
export const deleteUserById = function (id) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const config = {
|
|
16
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
17
|
+
};
|
|
18
|
+
const response = yield axiosInstance.delete(`${GET_SET_USER}/${id}`, config);
|
|
19
|
+
return response;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error('Error fetching deleteUserById:', error);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_SET_USER = 'api/users';
|
|
12
|
+
export const validateUserPin = function (data) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const config = {
|
|
16
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
17
|
+
};
|
|
18
|
+
return yield axiosInstance.post(`${GET_SET_USER}/validate-pin`, data, config);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error('Error fetching validateUserPin:', error);
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_SET_USER = 'api/user';
|
|
12
|
+
const REQUEST_PARAMS = {
|
|
13
|
+
token: 'LOGGED_USER_TOKEN',
|
|
14
|
+
};
|
|
15
|
+
export const updateUserById = function (userId, data) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
try {
|
|
18
|
+
const config = {
|
|
19
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
20
|
+
};
|
|
21
|
+
const response = yield axiosInstance.put(`${GET_SET_USER}/${userId}`, data, config);
|
|
22
|
+
return response.data || {};
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error('Error fetching updateUserById:', error);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
package/dist/enum/index.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BuyAndGetConditionsTypes = exports.DiscountCodeTypes = void 0;
|
|
4
|
-
var DiscountCodeTypes;
|
|
1
|
+
export var DiscountCodeTypes;
|
|
5
2
|
(function (DiscountCodeTypes) {
|
|
6
3
|
DiscountCodeTypes["PERCENTAGE"] = "percentage";
|
|
7
4
|
DiscountCodeTypes["NUMBER"] = "number";
|
|
8
5
|
DiscountCodeTypes["FREE_DELIVERY"] = "freeDelivery";
|
|
9
6
|
DiscountCodeTypes["BUY_X_GET_Y"] = "buyXGetY";
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
DiscountCodeTypes["FREE_ITEM"] = "freeItem";
|
|
8
|
+
})(DiscountCodeTypes || (DiscountCodeTypes = {}));
|
|
9
|
+
export var BuyAndGetConditionsTypes;
|
|
12
10
|
(function (BuyAndGetConditionsTypes) {
|
|
13
11
|
BuyAndGetConditionsTypes["PERCENTAGE"] = "percentage";
|
|
14
12
|
BuyAndGetConditionsTypes["FREE"] = "free";
|
|
15
|
-
})(BuyAndGetConditionsTypes || (
|
|
13
|
+
})(BuyAndGetConditionsTypes || (BuyAndGetConditionsTypes = {}));
|
|
14
|
+
export var PaymentMethodsEnum;
|
|
15
|
+
(function (PaymentMethodsEnum) {
|
|
16
|
+
PaymentMethodsEnum["Cash"] = "cash";
|
|
17
|
+
PaymentMethodsEnum["Card"] = "card";
|
|
18
|
+
PaymentMethodsEnum["Delivery"] = "delivery";
|
|
19
|
+
PaymentMethodsEnum["Transfer"] = "transfer";
|
|
20
|
+
})(PaymentMethodsEnum || (PaymentMethodsEnum = {}));
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.WashdayClient = exports.utils = void 0;
|
|
30
|
-
const utils = __importStar(require("./utils"));
|
|
31
|
-
exports.utils = utils;
|
|
32
|
-
const api_1 = __importDefault(require("./api"));
|
|
33
|
-
exports.WashdayClient = api_1.default;
|
|
1
|
+
import * as utils from './utils';
|
|
2
|
+
import WashdayClient from './api';
|
|
3
|
+
export { WashdayClient, utils };
|
package/dist/interfaces/Api.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var AppleAuthenticationUserDetectionStatus;
|
|
2
|
+
(function (AppleAuthenticationUserDetectionStatus) {
|
|
3
|
+
/**
|
|
4
|
+
* The system does not support this determination and there is no data.
|
|
5
|
+
*/
|
|
6
|
+
AppleAuthenticationUserDetectionStatus[AppleAuthenticationUserDetectionStatus["UNSUPPORTED"] = 0] = "UNSUPPORTED";
|
|
7
|
+
/**
|
|
8
|
+
* The system has not determined whether the user might be a real person.
|
|
9
|
+
*/
|
|
10
|
+
AppleAuthenticationUserDetectionStatus[AppleAuthenticationUserDetectionStatus["UNKNOWN"] = 1] = "UNKNOWN";
|
|
11
|
+
/**
|
|
12
|
+
* The user appears to be a real person.
|
|
13
|
+
*/
|
|
14
|
+
AppleAuthenticationUserDetectionStatus[AppleAuthenticationUserDetectionStatus["LIKELY_REAL"] = 2] = "LIKELY_REAL";
|
|
15
|
+
})(AppleAuthenticationUserDetectionStatus || (AppleAuthenticationUserDetectionStatus = {}));
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/interfaces/Order.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/interfaces/Store.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/interfaces/User.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const generateQueryParamsStr = (availableQueryParamsList = [], receivedParamsObj = {}) => {
|
|
2
|
+
let queryParams = [];
|
|
3
|
+
for (let availableParam of availableQueryParamsList) {
|
|
4
|
+
if (receivedParamsObj.hasOwnProperty(availableParam)) {
|
|
5
|
+
queryParams.push(`${availableParam}=${receivedParamsObj[availableParam]}`);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return queryParams.join('&');
|
|
9
|
+
};
|
package/dist/utils/index.js
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./orders"), exports);
|
|
1
|
+
export { applyDiscountToProducts, calculateOrderTotal } from './orders';
|
|
2
|
+
export { getFormattedAddress } from './util';
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const helpers_1 = require("./helpers");
|
|
8
|
-
const calculateOrderTotal = (order, selectedCustomer, storeSettings, hasShippingCost, storeDiscounts = [], discountCodeObj) => {
|
|
1
|
+
import { DiscountCodeTypes } from "../../enum";
|
|
2
|
+
import { calculateTotalTaxesIncluded } from "./calculateTotalTaxesIncluded";
|
|
3
|
+
import { calculateTotalTaxesOverPrice } from "./calculateTotalTaxesOverPrice";
|
|
4
|
+
import { getCreditApplied, getProductLineTotals, getShippingCost } from "./helpers";
|
|
5
|
+
export const calculateOrderTotal = (order, selectedCustomer, storeSettings, hasShippingCost, storeDiscounts = [], discountCodeObj, redeemPointsDiscount = 0 // 💡 NUEVO parámetro
|
|
6
|
+
) => {
|
|
9
7
|
var _a;
|
|
10
8
|
try {
|
|
11
9
|
const appliedOrderDiscounts = {};
|
|
12
|
-
const productTableCalculator = (storeSettings === null || storeSettings === void 0 ? void 0 : storeSettings.taxesType) === 'over_price'
|
|
10
|
+
const productTableCalculator = (storeSettings === null || storeSettings === void 0 ? void 0 : storeSettings.taxesType) === 'over_price'
|
|
11
|
+
? calculateTotalTaxesOverPrice
|
|
12
|
+
: calculateTotalTaxesIncluded;
|
|
13
13
|
const productTableImports = productTableCalculator(order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj);
|
|
14
|
-
// PRODUCT LINE TOTALS
|
|
15
|
-
const { totalQuantity, totalImportWithDiscount, totalImportWithoutDiscount, totalImporTaxes, totalDiscountAmount } =
|
|
16
|
-
// DISCOUNT
|
|
14
|
+
// === PRODUCT LINE TOTALS ===
|
|
15
|
+
const { totalQuantity, totalImportWithDiscount, totalImportWithoutDiscount, totalImporTaxes, totalDiscountAmount, totalSubtotalAmount } = getProductLineTotals(productTableImports);
|
|
16
|
+
// === DISCOUNT CODE (monetario tipo NUMBER que se aplica una sola vez) ===
|
|
17
17
|
let discountCodeAmount = 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (discountCodeObj &&
|
|
19
|
+
discountCodeObj.type === DiscountCodeTypes.NUMBER &&
|
|
20
|
+
discountCodeObj.applyOnceOnOrder) {
|
|
21
|
+
const includesProducts = discountCodeObj.applyToAllProducts ||
|
|
22
|
+
order.products.some((curr) => discountCodeObj.products.includes(curr._id));
|
|
21
23
|
discountCodeAmount = includesProducts ? discountCodeObj.value : 0;
|
|
22
24
|
}
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// === SHIPPING COST ===
|
|
26
|
+
const shippingCost = getShippingCost(discountCodeObj, hasShippingCost, storeSettings);
|
|
27
|
+
// === TOTAL ANTES DE CRÉDITOS/PUNTOS ===
|
|
28
|
+
const orderTotalWithOutCredit = +(totalImportWithDiscount +
|
|
29
|
+
shippingCost -
|
|
30
|
+
discountCodeAmount).toFixed(2);
|
|
31
|
+
// === APLICAR CRÉDITO Y PUNTOS REDIMIDOS ===
|
|
32
|
+
const creditApplied = getCreditApplied(selectedCustomer, orderTotalWithOutCredit);
|
|
33
|
+
const orderTotal = +(orderTotalWithOutCredit -
|
|
34
|
+
creditApplied -
|
|
35
|
+
redeemPointsDiscount).toFixed(2);
|
|
36
|
+
// === RETURN FINAL OBJECT ===
|
|
37
|
+
return Object.assign(Object.assign({}, order), { totalQuantity, customerDiscount: order.discountCode ? 0 : (_a = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.customer) === null || _a === void 0 ? void 0 : _a.discount, productTotal: totalImportWithDiscount, taxesTotal: totalImporTaxes, total: orderTotal, creditApplied, redeemPointsApplied: redeemPointsDiscount, productTotalWithoutDiscount: totalImportWithoutDiscount, totalDiscountAmount: totalDiscountAmount + discountCodeAmount, shippingServiceTotal: shippingCost, appliedOrderDiscounts, subtotal: totalSubtotalAmount });
|
|
28
38
|
}
|
|
29
39
|
catch (error) {
|
|
30
40
|
throw error;
|
|
31
41
|
}
|
|
32
42
|
};
|
|
33
|
-
exports.calculateOrderTotal = calculateOrderTotal;
|
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const helpers_1 = require("./helpers");
|
|
5
|
-
const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
|
|
1
|
+
import { DiscountCodeTypes } from "../../enum";
|
|
2
|
+
import { getProductTaxesPercentage } from "./helpers";
|
|
3
|
+
export const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
|
|
6
4
|
const productTableImports = [...order.products, ...order.buyAndGetProducts].map((current) => {
|
|
7
5
|
var _a, _b;
|
|
6
|
+
const qty = current.qty || 0;
|
|
7
|
+
const taxPercentage = getProductTaxesPercentage(current, storeSettings);
|
|
8
|
+
const taxFactor = 1 + taxPercentage / 100;
|
|
9
|
+
// Convertir extraAmount de bruto a neto
|
|
10
|
+
const extraAmountGross = current.extraAmount || 0;
|
|
11
|
+
const extraAmountNet = extraAmountGross / taxFactor;
|
|
12
|
+
// Precio bruto del producto (sin extraAmount)
|
|
13
|
+
const productGrossPrice = order.express ? current.expressPrice : current.price;
|
|
14
|
+
// Convertir precio bruto a neto
|
|
15
|
+
const unitNetPrice = productGrossPrice / taxFactor;
|
|
16
|
+
// Determinar el porcentaje de descuento (si aplica)
|
|
8
17
|
let discPercentageInteger = 0;
|
|
9
18
|
let productPercentageDiscount = 0;
|
|
10
19
|
let customerDiscount = 0;
|
|
11
|
-
let qty = current.qty || 0;
|
|
12
|
-
const extraAmountPerUnit = current.extraAmount / qty;
|
|
13
|
-
const prodPrice = (order.express ? current.expressPrice : current.price) + extraAmountPerUnit;
|
|
14
20
|
if (!order.discountCode) {
|
|
15
|
-
const discountsToApply = storeDiscounts.filter((discount) => discount.products.
|
|
21
|
+
const discountsToApply = storeDiscounts.filter((discount) => discount.isActive && discount.products.some((p) => {
|
|
22
|
+
if (typeof p === 'string') {
|
|
23
|
+
return p === current._id;
|
|
24
|
+
}
|
|
25
|
+
else if (typeof p === 'object') {
|
|
26
|
+
return p._id === current._id;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}));
|
|
16
30
|
customerDiscount = ((_a = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.customer) === null || _a === void 0 ? void 0 : _a.discount) || 0;
|
|
17
31
|
productPercentageDiscount = discountsToApply.reduce((prev, next) => {
|
|
18
|
-
|
|
19
|
-
return prev + next.value;
|
|
20
|
-
}
|
|
21
|
-
return prev;
|
|
32
|
+
return next.type === 'percentage' ? prev + next.value : prev;
|
|
22
33
|
}, 0);
|
|
23
34
|
discPercentageInteger = +((productPercentageDiscount + customerDiscount) / 100).toFixed(2);
|
|
24
35
|
discountsToApply.forEach((discount) => (appliedOrderDiscounts[discount._id] = discount));
|
|
@@ -38,28 +49,43 @@ const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, sto
|
|
|
38
49
|
if (discountType === 'percentage' && current.isBuyAndGetProduct) {
|
|
39
50
|
discPercentageInteger = +(discountValue / 100).toFixed(2);
|
|
40
51
|
}
|
|
52
|
+
if (discountType === 'free' && current.isBuyAndGetProduct) {
|
|
53
|
+
discPercentageInteger = 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (discountCodeObj.type === DiscountCodeTypes.FREE_ITEM && (current.isFreeItem)) {
|
|
57
|
+
discPercentageInteger = 1;
|
|
41
58
|
}
|
|
42
59
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
// === NUEVO: Aplicar descuento sobre el precio total ajustado (producto base + extra prorrateado) ===
|
|
61
|
+
// Si hay cantidad, repartir el extra neto entre cada unidad
|
|
62
|
+
const unitExtraNet = qty > 0 ? extraAmountNet / qty : 0;
|
|
63
|
+
// Precio neto ajustado: precio base + extra (por unidad)
|
|
64
|
+
const adjustedUnitNetPrice = unitNetPrice + unitExtraNet;
|
|
65
|
+
// Calcular el descuento sobre el precio ajustado
|
|
66
|
+
const discountAmountPerUnit = discPercentageInteger ? adjustedUnitNetPrice * discPercentageInteger : 0;
|
|
67
|
+
// Precio neto con descuento aplicado por unidad
|
|
68
|
+
const discountedUnitNetPrice = adjustedUnitNetPrice - discountAmountPerUnit;
|
|
69
|
+
// === Totales de la línea ===
|
|
70
|
+
// Total neto sin descuento: precio base total + extra (ya prorrateado en el total)
|
|
71
|
+
const productNetTotalWithoutDiscount = (unitNetPrice * qty) + extraAmountNet;
|
|
72
|
+
// Total neto con descuento: se aplica el descuento sobre el precio ajustado por unidad
|
|
73
|
+
const productNetTotalWithDiscount = discountedUnitNetPrice * qty;
|
|
74
|
+
// Reaplicar IVA a ambos totales
|
|
75
|
+
const productLineImportTotal = +(productNetTotalWithoutDiscount * taxFactor).toFixed(2);
|
|
76
|
+
const productLineTotalWithDiscount = +(productNetTotalWithDiscount * taxFactor).toFixed(2);
|
|
77
|
+
// Calcular el total de impuestos como la diferencia entre bruto y neto con descuento
|
|
78
|
+
const totalTaxesApplied = +(productLineTotalWithDiscount - productNetTotalWithDiscount).toFixed(2);
|
|
79
|
+
const lineDiscount = +(discountAmountPerUnit * qty).toFixed(2);
|
|
54
80
|
return {
|
|
55
81
|
product: current,
|
|
56
|
-
qty
|
|
57
|
-
productLineImportTotal
|
|
58
|
-
productLineTotalWithDiscount
|
|
82
|
+
qty,
|
|
83
|
+
productLineImportTotal, // Total bruto sin descuento (incluye extra y IVA)
|
|
84
|
+
productLineTotalWithDiscount, // Total bruto con descuento aplicado sobre el precio ajustado
|
|
59
85
|
productLineTaxesTotal: totalTaxesApplied,
|
|
60
|
-
lineDiscountAmount: lineDiscount
|
|
86
|
+
lineDiscountAmount: lineDiscount,
|
|
87
|
+
productLineSubtotal: productNetTotalWithoutDiscount // Subtotal neto (sin IVA)
|
|
61
88
|
};
|
|
62
89
|
});
|
|
63
90
|
return productTableImports;
|
|
64
91
|
};
|
|
65
|
-
exports.calculateTotalTaxesIncluded = calculateTotalTaxesIncluded;
|