washday-sdk 1.6.78 → 1.6.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +15 -0
- package/dist/api/invoiceModule/delete.js +24 -0
- package/dist/api/invoiceModule/get.js +133 -0
- package/dist/api/invoiceModule/index.js +3 -0
- package/dist/api/invoiceModule/post.js +66 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/InvoiceModule.js +1 -0
- package/package.json +1 -1
- package/src/api/index.ts +15 -0
- package/src/api/invoiceModule/delete.ts +19 -0
- package/src/api/invoiceModule/get.ts +118 -0
- package/src/api/invoiceModule/index.ts +3 -0
- package/src/api/invoiceModule/post.ts +65 -0
- package/src/index.ts +1 -0
- package/src/interfaces/Api.ts +15 -0
- package/src/interfaces/InvoiceModule.ts +135 -0
- package/test/api/invoiceModule.test.ts +206 -0
- package/tsconfig.json +1 -1
- package/dist/interfaces/Company.garmentAttributeCatalogs.test.js +0 -21
- package/dist/interfaces/Product.description.test.js +0 -37
- package/dist/interfaces/Store.ticketStructurePresets.test.js +0 -73
- package/dist/interfaces/StoreReceptionValidation.contract.test.js +0 -62
package/dist/api/index.js
CHANGED
|
@@ -37,6 +37,7 @@ import * as attendanceEndpoints from './attendance';
|
|
|
37
37
|
import * as routesEndpoints from './routes';
|
|
38
38
|
import * as reviewsEndpoints from './reviews';
|
|
39
39
|
import * as cfdiEndpoints from './cfdi';
|
|
40
|
+
import * as invoiceModuleEndpoints from './invoiceModule';
|
|
40
41
|
import * as cashupsEndpoints from './cashups';
|
|
41
42
|
import { deleteUserById } from "./users/delete";
|
|
42
43
|
import * as partnersEndpoints from './partners';
|
|
@@ -84,6 +85,20 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
|
|
|
84
85
|
createGlobalByPaymentMethodCFDI: cfdiEndpoints.postModule.createGlobalByPaymentMethodCFDI,
|
|
85
86
|
cancelCFDI: cfdiEndpoints.deleteModule.cancelCFDI
|
|
86
87
|
});
|
|
88
|
+
this.invoiceModule = bindMethods(this, {
|
|
89
|
+
getCapabilities: invoiceModuleEndpoints.getModule.getCapabilities,
|
|
90
|
+
getCFDIList: invoiceModuleEndpoints.getModule.getCFDIList,
|
|
91
|
+
getCFDIPreview: invoiceModuleEndpoints.getModule.getCFDIPreview,
|
|
92
|
+
downloadCFDIPDF: invoiceModuleEndpoints.getModule.downloadCFDIPDF,
|
|
93
|
+
downloadCFDIZIP: invoiceModuleEndpoints.getModule.downloadCFDIZIP,
|
|
94
|
+
sendCFDIByEmail: invoiceModuleEndpoints.getModule.sendCFDIByEmail,
|
|
95
|
+
getCFDIProductCatalogs: invoiceModuleEndpoints.getModule.getCFDIProductCatalogs,
|
|
96
|
+
createCFDI: invoiceModuleEndpoints.postModule.createCFDI,
|
|
97
|
+
searchGlobalByPaymentMethodCandidates: invoiceModuleEndpoints.postModule.searchGlobalByPaymentMethodCandidates,
|
|
98
|
+
previewGlobalByPaymentMethodCFDI: invoiceModuleEndpoints.postModule.previewGlobalByPaymentMethodCFDI,
|
|
99
|
+
createGlobalByPaymentMethodCFDI: invoiceModuleEndpoints.postModule.createGlobalByPaymentMethodCFDI,
|
|
100
|
+
cancelCFDI: invoiceModuleEndpoints.deleteModule.cancelCFDI,
|
|
101
|
+
});
|
|
87
102
|
this.review = bindMethods(this, {
|
|
88
103
|
getList: reviewsEndpoints.getModule.getList,
|
|
89
104
|
requestStoreReviewByCustomerId: reviewsEndpoints.getModule.requestStoreReviewByCustomerId,
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
const GET_SET_INVOICE_MODULE_CFDI = "api/invoice-module/cfdi";
|
|
11
|
+
export const cancelCFDI = function (invoiceID, data) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
try {
|
|
14
|
+
const config = {
|
|
15
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
16
|
+
};
|
|
17
|
+
return yield this.axiosInstance.delete(`${GET_SET_INVOICE_MODULE_CFDI}/${invoiceID}`, Object.assign(Object.assign({}, config), { data }));
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error("Error canceling invoice module CFDI:", error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
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 { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
11
|
+
const GET_SET_INVOICE_MODULE_CFDI = "api/invoice-module/cfdi";
|
|
12
|
+
const GET_INVOICE_MODULE_CAPABILITIES = "api/invoice-module/capabilities";
|
|
13
|
+
export const getCapabilities = function () {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
try {
|
|
16
|
+
const config = {
|
|
17
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
18
|
+
};
|
|
19
|
+
return yield this.axiosInstance.get(GET_INVOICE_MODULE_CAPABILITIES, config);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error("Error fetching invoice module capabilities:", error);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export const getCFDIList = function () {
|
|
28
|
+
return __awaiter(this, arguments, void 0, function* (params = {}) {
|
|
29
|
+
try {
|
|
30
|
+
const config = {
|
|
31
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
32
|
+
};
|
|
33
|
+
const queryParams = generateQueryParamsStr([
|
|
34
|
+
"query",
|
|
35
|
+
"storeId",
|
|
36
|
+
"fromDate",
|
|
37
|
+
"toDate",
|
|
38
|
+
"limit",
|
|
39
|
+
"pageNum"
|
|
40
|
+
], params);
|
|
41
|
+
return yield this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}?${queryParams}`, config);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error("Error fetching invoice module CFDI list:", error);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
export const getCFDIPreview = function () {
|
|
50
|
+
return __awaiter(this, arguments, void 0, function* (params = {}) {
|
|
51
|
+
try {
|
|
52
|
+
const config = {
|
|
53
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
54
|
+
};
|
|
55
|
+
const queryParams = generateQueryParamsStr([
|
|
56
|
+
"ordersID",
|
|
57
|
+
"customer",
|
|
58
|
+
], params);
|
|
59
|
+
return yield this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}/preview?${queryParams}`, config);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error("Error fetching invoice module CFDI preview:", error);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
export const sendCFDIByEmail = function (invoiceID) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
try {
|
|
70
|
+
const config = {
|
|
71
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
72
|
+
};
|
|
73
|
+
return yield this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}/${invoiceID}/email`, config);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error("Error sending invoice module CFDI by email:", error);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
export const downloadCFDIPDF = function (invoiceID) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
try {
|
|
84
|
+
const config = {
|
|
85
|
+
headers: {
|
|
86
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
87
|
+
},
|
|
88
|
+
responseType: "arraybuffer"
|
|
89
|
+
};
|
|
90
|
+
return yield this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}/${invoiceID}/download/pdf`, config);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
console.error("Error fetching invoice module CFDI PDF:", error);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
export const downloadCFDIZIP = function (invoiceID) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
try {
|
|
101
|
+
const config = {
|
|
102
|
+
headers: {
|
|
103
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
104
|
+
},
|
|
105
|
+
responseType: "arraybuffer"
|
|
106
|
+
};
|
|
107
|
+
return yield this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}/${invoiceID}/download/zip`, config);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.error("Error fetching invoice module CFDI ZIP:", error);
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
export const getCFDIProductCatalogs = function () {
|
|
116
|
+
return __awaiter(this, arguments, void 0, function* (params = {}) {
|
|
117
|
+
try {
|
|
118
|
+
const config = {
|
|
119
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
120
|
+
};
|
|
121
|
+
const queryParams = generateQueryParamsStr([
|
|
122
|
+
"search",
|
|
123
|
+
"q",
|
|
124
|
+
], params);
|
|
125
|
+
const queryParamsSuffix = queryParams ? `?${queryParams}` : "";
|
|
126
|
+
return yield this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}/catalogs/products${queryParamsSuffix}`, config);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
console.error("Error fetching invoice module CFDI product catalogs:", error);
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
const GET_SET_INVOICE_MODULE_CFDI = "api/invoice-module/cfdi";
|
|
11
|
+
export const createCFDI = function (data) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
try {
|
|
14
|
+
const config = {
|
|
15
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
16
|
+
};
|
|
17
|
+
return yield this.axiosInstance.post(GET_SET_INVOICE_MODULE_CFDI, data, config);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error("Error creating invoice module CFDI:", error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export const searchGlobalByPaymentMethodCandidates = function (data) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
try {
|
|
28
|
+
const config = {
|
|
29
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
30
|
+
};
|
|
31
|
+
return yield this.axiosInstance.post(`${GET_SET_INVOICE_MODULE_CFDI}/global-by-payment-method/search`, data, config);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error("Error searching invoice module global payment method candidates:", error);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export const previewGlobalByPaymentMethodCFDI = function (data) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
try {
|
|
42
|
+
const config = {
|
|
43
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
44
|
+
};
|
|
45
|
+
return yield this.axiosInstance.post(`${GET_SET_INVOICE_MODULE_CFDI}/global-by-payment-method/preview`, data, config);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error("Error previewing invoice module global payment method CFDI:", error);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export const createGlobalByPaymentMethodCFDI = function (data) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
try {
|
|
56
|
+
const config = {
|
|
57
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
58
|
+
};
|
|
59
|
+
return yield this.axiosInstance.post(`${GET_SET_INVOICE_MODULE_CFDI}/global-by-payment-method`, data, config);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error("Error creating invoice module global payment method CFDI:", error);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import WashdayClient from './api';
|
|
|
3
3
|
export * from './interfaces/Company';
|
|
4
4
|
export * from './interfaces/Config';
|
|
5
5
|
export * from './interfaces/Cfdi';
|
|
6
|
+
export * from './interfaces/InvoiceModule';
|
|
6
7
|
export * from './interfaces/Auth';
|
|
7
8
|
export * from './interfaces/Customer';
|
|
8
9
|
export * from './interfaces/DomainUrls';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -38,6 +38,7 @@ import * as attendanceEndpoints from './attendance';
|
|
|
38
38
|
import * as routesEndpoints from './routes';
|
|
39
39
|
import * as reviewsEndpoints from './reviews';
|
|
40
40
|
import * as cfdiEndpoints from './cfdi';
|
|
41
|
+
import * as invoiceModuleEndpoints from './invoiceModule';
|
|
41
42
|
import * as cashupsEndpoints from './cashups';
|
|
42
43
|
import { deleteUserById } from "./users/delete";
|
|
43
44
|
import { customersAppChangePassword } from './auth/post';
|
|
@@ -91,6 +92,20 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
91
92
|
createGlobalByPaymentMethodCFDI: cfdiEndpoints.postModule.createGlobalByPaymentMethodCFDI,
|
|
92
93
|
cancelCFDI: cfdiEndpoints.deleteModule.cancelCFDI
|
|
93
94
|
});
|
|
95
|
+
this.invoiceModule = bindMethods(this, {
|
|
96
|
+
getCapabilities: invoiceModuleEndpoints.getModule.getCapabilities,
|
|
97
|
+
getCFDIList: invoiceModuleEndpoints.getModule.getCFDIList,
|
|
98
|
+
getCFDIPreview: invoiceModuleEndpoints.getModule.getCFDIPreview,
|
|
99
|
+
downloadCFDIPDF: invoiceModuleEndpoints.getModule.downloadCFDIPDF,
|
|
100
|
+
downloadCFDIZIP: invoiceModuleEndpoints.getModule.downloadCFDIZIP,
|
|
101
|
+
sendCFDIByEmail: invoiceModuleEndpoints.getModule.sendCFDIByEmail,
|
|
102
|
+
getCFDIProductCatalogs: invoiceModuleEndpoints.getModule.getCFDIProductCatalogs,
|
|
103
|
+
createCFDI: invoiceModuleEndpoints.postModule.createCFDI,
|
|
104
|
+
searchGlobalByPaymentMethodCandidates: invoiceModuleEndpoints.postModule.searchGlobalByPaymentMethodCandidates,
|
|
105
|
+
previewGlobalByPaymentMethodCFDI: invoiceModuleEndpoints.postModule.previewGlobalByPaymentMethodCFDI,
|
|
106
|
+
createGlobalByPaymentMethodCFDI: invoiceModuleEndpoints.postModule.createGlobalByPaymentMethodCFDI,
|
|
107
|
+
cancelCFDI: invoiceModuleEndpoints.deleteModule.cancelCFDI,
|
|
108
|
+
});
|
|
94
109
|
this.review = bindMethods(this, {
|
|
95
110
|
getList: reviewsEndpoints.getModule.getList,
|
|
96
111
|
requestStoreReviewByCustomerId: reviewsEndpoints.getModule.requestStoreReviewByCustomerId,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { InvoiceModuleCancelCFDIRequest } from "../../interfaces/InvoiceModule";
|
|
3
|
+
|
|
4
|
+
const GET_SET_INVOICE_MODULE_CFDI = "api/invoice-module/cfdi";
|
|
5
|
+
|
|
6
|
+
export const cancelCFDI = async function (this: WashdayClientInstance, invoiceID: string, data: InvoiceModuleCancelCFDIRequest): Promise<any> {
|
|
7
|
+
try {
|
|
8
|
+
const config = {
|
|
9
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
10
|
+
};
|
|
11
|
+
return await this.axiosInstance.delete(`${GET_SET_INVOICE_MODULE_CFDI}/${invoiceID}`, {
|
|
12
|
+
...config,
|
|
13
|
+
data
|
|
14
|
+
});
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error("Error canceling invoice module CFDI:", error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import {
|
|
3
|
+
InvoiceModuleCFDIListParams,
|
|
4
|
+
InvoiceModuleCFDIProductCatalogsParams,
|
|
5
|
+
InvoiceModuleCFDIPreviewParams,
|
|
6
|
+
} from "../../interfaces/InvoiceModule";
|
|
7
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
8
|
+
|
|
9
|
+
const GET_SET_INVOICE_MODULE_CFDI = "api/invoice-module/cfdi";
|
|
10
|
+
const GET_INVOICE_MODULE_CAPABILITIES = "api/invoice-module/capabilities";
|
|
11
|
+
|
|
12
|
+
export const getCapabilities = async function (this: WashdayClientInstance): Promise<any> {
|
|
13
|
+
try {
|
|
14
|
+
const config = {
|
|
15
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
16
|
+
};
|
|
17
|
+
return await this.axiosInstance.get(GET_INVOICE_MODULE_CAPABILITIES, config);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error("Error fetching invoice module capabilities:", error);
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const getCFDIList = async function (this: WashdayClientInstance, params: InvoiceModuleCFDIListParams = {}): Promise<any> {
|
|
25
|
+
try {
|
|
26
|
+
const config = {
|
|
27
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
28
|
+
};
|
|
29
|
+
const queryParams = generateQueryParamsStr([
|
|
30
|
+
"query",
|
|
31
|
+
"storeId",
|
|
32
|
+
"fromDate",
|
|
33
|
+
"toDate",
|
|
34
|
+
"limit",
|
|
35
|
+
"pageNum"
|
|
36
|
+
], params);
|
|
37
|
+
|
|
38
|
+
return await this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}?${queryParams}`, config);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error("Error fetching invoice module CFDI list:", error);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const getCFDIPreview = async function (this: WashdayClientInstance, params: InvoiceModuleCFDIPreviewParams = {}): Promise<any> {
|
|
46
|
+
try {
|
|
47
|
+
const config = {
|
|
48
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
49
|
+
};
|
|
50
|
+
const queryParams = generateQueryParamsStr([
|
|
51
|
+
"ordersID",
|
|
52
|
+
"customer",
|
|
53
|
+
], params);
|
|
54
|
+
return await this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}/preview?${queryParams}`, config);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error("Error fetching invoice module CFDI preview:", error);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const sendCFDIByEmail = async function (this: WashdayClientInstance, invoiceID: string): Promise<any> {
|
|
62
|
+
try {
|
|
63
|
+
const config = {
|
|
64
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
65
|
+
};
|
|
66
|
+
return await this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}/${invoiceID}/email`, config);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error("Error sending invoice module CFDI by email:", error);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const downloadCFDIPDF = async function (this: WashdayClientInstance, invoiceID: string): Promise<any> {
|
|
74
|
+
try {
|
|
75
|
+
const config = {
|
|
76
|
+
headers: {
|
|
77
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
78
|
+
},
|
|
79
|
+
responseType: "arraybuffer" as const
|
|
80
|
+
};
|
|
81
|
+
return await this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}/${invoiceID}/download/pdf`, config);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error("Error fetching invoice module CFDI PDF:", error);
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const downloadCFDIZIP = async function (this: WashdayClientInstance, invoiceID: string): Promise<any> {
|
|
89
|
+
try {
|
|
90
|
+
const config = {
|
|
91
|
+
headers: {
|
|
92
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
93
|
+
},
|
|
94
|
+
responseType: "arraybuffer" as const
|
|
95
|
+
};
|
|
96
|
+
return await this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}/${invoiceID}/download/zip`, config);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error("Error fetching invoice module CFDI ZIP:", error);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const getCFDIProductCatalogs = async function (this: WashdayClientInstance, params: InvoiceModuleCFDIProductCatalogsParams = {}): Promise<any> {
|
|
104
|
+
try {
|
|
105
|
+
const config = {
|
|
106
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
107
|
+
};
|
|
108
|
+
const queryParams = generateQueryParamsStr([
|
|
109
|
+
"search",
|
|
110
|
+
"q",
|
|
111
|
+
], params);
|
|
112
|
+
const queryParamsSuffix = queryParams ? `?${queryParams}` : "";
|
|
113
|
+
return await this.axiosInstance.get(`${GET_SET_INVOICE_MODULE_CFDI}/catalogs/products${queryParamsSuffix}`, config);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error("Error fetching invoice module CFDI product catalogs:", error);
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import {
|
|
3
|
+
InvoiceModuleCreateCFDIRequest,
|
|
4
|
+
InvoiceModuleGlobalByPaymentMethodCFDIRequest,
|
|
5
|
+
InvoiceModuleSearchGlobalByPaymentMethodCandidatesRequest,
|
|
6
|
+
} from "../../interfaces/InvoiceModule";
|
|
7
|
+
|
|
8
|
+
const GET_SET_INVOICE_MODULE_CFDI = "api/invoice-module/cfdi";
|
|
9
|
+
|
|
10
|
+
export const createCFDI = async function (this: WashdayClientInstance, data: InvoiceModuleCreateCFDIRequest): Promise<any> {
|
|
11
|
+
try {
|
|
12
|
+
const config = {
|
|
13
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
14
|
+
};
|
|
15
|
+
return await this.axiosInstance.post(GET_SET_INVOICE_MODULE_CFDI, data, config);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error("Error creating invoice module CFDI:", error);
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const searchGlobalByPaymentMethodCandidates = async function (
|
|
23
|
+
this: WashdayClientInstance,
|
|
24
|
+
data: InvoiceModuleSearchGlobalByPaymentMethodCandidatesRequest
|
|
25
|
+
): Promise<any> {
|
|
26
|
+
try {
|
|
27
|
+
const config = {
|
|
28
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
29
|
+
};
|
|
30
|
+
return await this.axiosInstance.post(`${GET_SET_INVOICE_MODULE_CFDI}/global-by-payment-method/search`, data, config);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error("Error searching invoice module global payment method candidates:", error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const previewGlobalByPaymentMethodCFDI = async function (
|
|
38
|
+
this: WashdayClientInstance,
|
|
39
|
+
data: InvoiceModuleGlobalByPaymentMethodCFDIRequest
|
|
40
|
+
): Promise<any> {
|
|
41
|
+
try {
|
|
42
|
+
const config = {
|
|
43
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
44
|
+
};
|
|
45
|
+
return await this.axiosInstance.post(`${GET_SET_INVOICE_MODULE_CFDI}/global-by-payment-method/preview`, data, config);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error("Error previewing invoice module global payment method CFDI:", error);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const createGlobalByPaymentMethodCFDI = async function (
|
|
53
|
+
this: WashdayClientInstance,
|
|
54
|
+
data: InvoiceModuleGlobalByPaymentMethodCFDIRequest
|
|
55
|
+
): Promise<any> {
|
|
56
|
+
try {
|
|
57
|
+
const config = {
|
|
58
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
59
|
+
};
|
|
60
|
+
return await this.axiosInstance.post(`${GET_SET_INVOICE_MODULE_CFDI}/global-by-payment-method`, data, config);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error("Error creating invoice module global payment method CFDI:", error);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import WashdayClient from './api';
|
|
|
3
3
|
export * from './interfaces/Company';
|
|
4
4
|
export * from './interfaces/Config';
|
|
5
5
|
export * from './interfaces/Cfdi';
|
|
6
|
+
export * from './interfaces/InvoiceModule';
|
|
6
7
|
export * from './interfaces/Auth';
|
|
7
8
|
export * from './interfaces/Customer';
|
|
8
9
|
export * from './interfaces/DomainUrls';
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -35,6 +35,7 @@ import * as ordersEndpoints from '../api/order';
|
|
|
35
35
|
import * as routesEndpoints from '../api/routes';
|
|
36
36
|
import * as reviewsEndpoints from '../api/reviews';
|
|
37
37
|
import * as cfdiEndpoints from '../api/cfdi';
|
|
38
|
+
import * as invoiceModuleEndpoints from '../api/invoiceModule';
|
|
38
39
|
import * as cashupsEndpoints from '../api/cashups';
|
|
39
40
|
import * as authEndpoints from '../api/auth';
|
|
40
41
|
import * as attendanceEndpoints from '../api/attendance';
|
|
@@ -76,6 +77,20 @@ export interface WashdayClientInstance {
|
|
|
76
77
|
createGlobalByPaymentMethodCFDI: typeof cfdiEndpoints.postModule.createGlobalByPaymentMethodCFDI,
|
|
77
78
|
cancelCFDI: typeof cfdiEndpoints.deleteModule.cancelCFDI
|
|
78
79
|
}
|
|
80
|
+
invoiceModule: {
|
|
81
|
+
getCapabilities: typeof invoiceModuleEndpoints.getModule.getCapabilities,
|
|
82
|
+
getCFDIList: typeof invoiceModuleEndpoints.getModule.getCFDIList,
|
|
83
|
+
getCFDIPreview: typeof invoiceModuleEndpoints.getModule.getCFDIPreview,
|
|
84
|
+
downloadCFDIPDF: typeof invoiceModuleEndpoints.getModule.downloadCFDIPDF,
|
|
85
|
+
downloadCFDIZIP: typeof invoiceModuleEndpoints.getModule.downloadCFDIZIP,
|
|
86
|
+
sendCFDIByEmail: typeof invoiceModuleEndpoints.getModule.sendCFDIByEmail,
|
|
87
|
+
getCFDIProductCatalogs: typeof invoiceModuleEndpoints.getModule.getCFDIProductCatalogs,
|
|
88
|
+
createCFDI: typeof invoiceModuleEndpoints.postModule.createCFDI,
|
|
89
|
+
searchGlobalByPaymentMethodCandidates: typeof invoiceModuleEndpoints.postModule.searchGlobalByPaymentMethodCandidates,
|
|
90
|
+
previewGlobalByPaymentMethodCFDI: typeof invoiceModuleEndpoints.postModule.previewGlobalByPaymentMethodCFDI,
|
|
91
|
+
createGlobalByPaymentMethodCFDI: typeof invoiceModuleEndpoints.postModule.createGlobalByPaymentMethodCFDI,
|
|
92
|
+
cancelCFDI: typeof invoiceModuleEndpoints.deleteModule.cancelCFDI,
|
|
93
|
+
}
|
|
79
94
|
auth: {
|
|
80
95
|
customerLoginToken: typeof authEndpoints.postModule.customerLoginToken;
|
|
81
96
|
googleLogin: typeof authEndpoints.postModule.googleLogin;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export type InvoiceModuleCountryCode = "MX" | "PE" | string;
|
|
2
|
+
export type InvoiceModuleStandard = "cfdi" | "sunat" | string;
|
|
3
|
+
export type InvoiceModuleProvider = "facturapi" | string;
|
|
4
|
+
export type InvoiceModuleProviderStatus =
|
|
5
|
+
| "not_configured"
|
|
6
|
+
| "test"
|
|
7
|
+
| "active"
|
|
8
|
+
| "suspended"
|
|
9
|
+
| string;
|
|
10
|
+
export type InvoiceModuleIssuerProfileStatus =
|
|
11
|
+
| "missing"
|
|
12
|
+
| "incomplete"
|
|
13
|
+
| "ready"
|
|
14
|
+
| "invalid"
|
|
15
|
+
| string;
|
|
16
|
+
export type InvoiceModulePlanStatus = "active" | "grace" | "suspended" | string;
|
|
17
|
+
|
|
18
|
+
export type InvoiceModuleDocumentType =
|
|
19
|
+
| "income_invoice"
|
|
20
|
+
| "global_invoice"
|
|
21
|
+
| "payment_complement"
|
|
22
|
+
| "global_payment_method_invoice"
|
|
23
|
+
| "cancellation"
|
|
24
|
+
| string;
|
|
25
|
+
|
|
26
|
+
export interface InvoiceModuleCapabilitiesResponse {
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
country?: {
|
|
29
|
+
code?: InvoiceModuleCountryCode | null;
|
|
30
|
+
supported?: boolean;
|
|
31
|
+
standard?: InvoiceModuleStandard | null;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
provider?: {
|
|
35
|
+
provider?: InvoiceModuleProvider | null;
|
|
36
|
+
status?: InvoiceModuleProviderStatus;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
};
|
|
39
|
+
issuerProfile?: {
|
|
40
|
+
status?: InvoiceModuleIssuerProfileStatus;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
};
|
|
43
|
+
permissions?: {
|
|
44
|
+
canView?: boolean;
|
|
45
|
+
canMutate?: boolean;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
};
|
|
48
|
+
plan?: {
|
|
49
|
+
status?: InvoiceModulePlanStatus;
|
|
50
|
+
allowed?: boolean;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
};
|
|
53
|
+
legacy?: {
|
|
54
|
+
canUseCFDIInvoicing?: boolean;
|
|
55
|
+
canUseInvoiceModule?: boolean;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
};
|
|
58
|
+
reasons?: string[];
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface InvoiceModuleCFDIListParams {
|
|
63
|
+
query?: string;
|
|
64
|
+
storeId?: string;
|
|
65
|
+
fromDate?: string;
|
|
66
|
+
toDate?: string;
|
|
67
|
+
limit?: string | number;
|
|
68
|
+
pageNum?: string | number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface InvoiceModuleCFDIPreviewParams {
|
|
72
|
+
ordersID?: string[];
|
|
73
|
+
customer?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface InvoiceModuleCFDIProductCatalogsParams {
|
|
77
|
+
search?: string;
|
|
78
|
+
q?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface InvoiceModuleCreateCFDIRequest {
|
|
82
|
+
provider?: InvoiceModuleProvider;
|
|
83
|
+
documentType?: InvoiceModuleDocumentType;
|
|
84
|
+
providerPayload?: Record<string, unknown>;
|
|
85
|
+
metadata?: Record<string, unknown>;
|
|
86
|
+
[key: string]: unknown;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type InvoiceModuleGlobalPaymentMethod =
|
|
90
|
+
| "cash"
|
|
91
|
+
| "card"
|
|
92
|
+
| "transfer"
|
|
93
|
+
| "mercadopago"
|
|
94
|
+
| string;
|
|
95
|
+
|
|
96
|
+
export interface InvoiceModuleGlobalPaymentMethodStoreFilters {
|
|
97
|
+
storeIds?: string[];
|
|
98
|
+
includeAllStores?: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface InvoiceModuleSearchGlobalByPaymentMethodCandidatesRequest
|
|
102
|
+
extends InvoiceModuleGlobalPaymentMethodStoreFilters {
|
|
103
|
+
paymentMethod?: InvoiceModuleGlobalPaymentMethod;
|
|
104
|
+
dateFrom?: string;
|
|
105
|
+
dateTo?: string;
|
|
106
|
+
providerPayload?: Record<string, unknown>;
|
|
107
|
+
metadata?: Record<string, unknown>;
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface InvoiceModuleGlobalByPaymentMethodSelectedLine {
|
|
112
|
+
paymentLineId: string;
|
|
113
|
+
description?: string;
|
|
114
|
+
[key: string]: unknown;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface InvoiceModuleGlobalByPaymentMethodCFDIRequest
|
|
118
|
+
extends InvoiceModuleSearchGlobalByPaymentMethodCandidatesRequest {
|
|
119
|
+
provider?: InvoiceModuleProvider;
|
|
120
|
+
documentType?: InvoiceModuleDocumentType;
|
|
121
|
+
date?: string;
|
|
122
|
+
sendEmailInvoice?: boolean;
|
|
123
|
+
global?: {
|
|
124
|
+
periodicity: string;
|
|
125
|
+
months: string;
|
|
126
|
+
year: string;
|
|
127
|
+
[key: string]: unknown;
|
|
128
|
+
};
|
|
129
|
+
paymentLines?: InvoiceModuleGlobalByPaymentMethodSelectedLine[];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface InvoiceModuleCancelCFDIRequest {
|
|
133
|
+
motive: string;
|
|
134
|
+
substitution?: string;
|
|
135
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import WashdayClient from "../../src/api";
|
|
2
|
+
|
|
3
|
+
const TOKEN = "token-123";
|
|
4
|
+
const authConfig = {
|
|
5
|
+
headers: { Authorization: `Bearer ${TOKEN}` },
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
describe("WashdayClient invoiceModule namespace", () => {
|
|
9
|
+
it("binds invoiceModule without removing the legacy cfdi namespace", () => {
|
|
10
|
+
const client = new (WashdayClient as any)(TOKEN, "DEV");
|
|
11
|
+
|
|
12
|
+
expect(client.invoiceModule).toBeDefined();
|
|
13
|
+
expect(typeof client.invoiceModule.getCapabilities).toBe("function");
|
|
14
|
+
expect(typeof client.cfdi.createCFDI).toBe("function");
|
|
15
|
+
expect(typeof client.cfdi.getList).toBe("function");
|
|
16
|
+
expect(typeof client.cfdi.cancelCFDI).toBe("function");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("calls invoice-module routes with authorization headers", async () => {
|
|
20
|
+
const get = jest.fn().mockResolvedValue({ data: { data: {} } });
|
|
21
|
+
const post = jest.fn().mockResolvedValue({ data: { data: {} } });
|
|
22
|
+
const deleteRequest = jest.fn().mockResolvedValue({ data: { data: {} } });
|
|
23
|
+
const client = new (WashdayClient as any)(TOKEN, "DEV");
|
|
24
|
+
client.axiosInstance = { get, post, delete: deleteRequest };
|
|
25
|
+
|
|
26
|
+
await client.invoiceModule.getCapabilities();
|
|
27
|
+
await client.invoiceModule.getCFDIList({
|
|
28
|
+
query: "folio-1",
|
|
29
|
+
storeId: "store-1",
|
|
30
|
+
fromDate: "2026-01-01",
|
|
31
|
+
toDate: "2026-01-31",
|
|
32
|
+
limit: 25,
|
|
33
|
+
pageNum: 2,
|
|
34
|
+
});
|
|
35
|
+
await client.invoiceModule.getCFDIPreview({
|
|
36
|
+
ordersID: ["order-1", "order-2"],
|
|
37
|
+
customer: "customer-1",
|
|
38
|
+
});
|
|
39
|
+
await client.invoiceModule.sendCFDIByEmail("invoice-1");
|
|
40
|
+
await client.invoiceModule.downloadCFDIPDF("invoice-1");
|
|
41
|
+
await client.invoiceModule.downloadCFDIZIP("invoice-1");
|
|
42
|
+
await client.invoiceModule.getCFDIProductCatalogs({ search: "detergente" });
|
|
43
|
+
|
|
44
|
+
await client.invoiceModule.createCFDI({
|
|
45
|
+
provider: "facturapi",
|
|
46
|
+
documentType: "income_invoice",
|
|
47
|
+
providerPayload: { ordersID: ["order-1"] },
|
|
48
|
+
});
|
|
49
|
+
await client.invoiceModule.searchGlobalByPaymentMethodCandidates({
|
|
50
|
+
paymentMethod: "cash",
|
|
51
|
+
dateFrom: "2026-01-01",
|
|
52
|
+
dateTo: "2026-01-31",
|
|
53
|
+
});
|
|
54
|
+
await client.invoiceModule.previewGlobalByPaymentMethodCFDI({
|
|
55
|
+
paymentMethod: "cash",
|
|
56
|
+
dateFrom: "2026-01-01",
|
|
57
|
+
dateTo: "2026-01-31",
|
|
58
|
+
global: {
|
|
59
|
+
periodicity: "01",
|
|
60
|
+
months: "01",
|
|
61
|
+
year: "2026",
|
|
62
|
+
},
|
|
63
|
+
paymentLines: [{ paymentLineId: "payment-line-1" }],
|
|
64
|
+
});
|
|
65
|
+
await client.invoiceModule.createGlobalByPaymentMethodCFDI({
|
|
66
|
+
paymentMethod: "cash",
|
|
67
|
+
dateFrom: "2026-01-01",
|
|
68
|
+
dateTo: "2026-01-31",
|
|
69
|
+
global: {
|
|
70
|
+
periodicity: "01",
|
|
71
|
+
months: "01",
|
|
72
|
+
year: "2026",
|
|
73
|
+
},
|
|
74
|
+
paymentLines: [{ paymentLineId: "payment-line-1" }],
|
|
75
|
+
});
|
|
76
|
+
await client.invoiceModule.cancelCFDI("invoice-1", {
|
|
77
|
+
motive: "02",
|
|
78
|
+
substitution: "replacement-uuid",
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
expect(get).toHaveBeenNthCalledWith(1, "api/invoice-module/capabilities", authConfig);
|
|
82
|
+
expect(get).toHaveBeenNthCalledWith(
|
|
83
|
+
2,
|
|
84
|
+
"api/invoice-module/cfdi?query=folio-1&storeId=store-1&fromDate=2026-01-01&toDate=2026-01-31&limit=25&pageNum=2",
|
|
85
|
+
authConfig,
|
|
86
|
+
);
|
|
87
|
+
expect(get).toHaveBeenNthCalledWith(
|
|
88
|
+
3,
|
|
89
|
+
"api/invoice-module/cfdi/preview?ordersID=order-1,order-2&customer=customer-1",
|
|
90
|
+
authConfig,
|
|
91
|
+
);
|
|
92
|
+
expect(get).toHaveBeenNthCalledWith(4, "api/invoice-module/cfdi/invoice-1/email", authConfig);
|
|
93
|
+
expect(get).toHaveBeenNthCalledWith(5, "api/invoice-module/cfdi/invoice-1/download/pdf", {
|
|
94
|
+
headers: { Authorization: `Bearer ${TOKEN}` },
|
|
95
|
+
responseType: "arraybuffer",
|
|
96
|
+
});
|
|
97
|
+
expect(get).toHaveBeenNthCalledWith(6, "api/invoice-module/cfdi/invoice-1/download/zip", {
|
|
98
|
+
headers: { Authorization: `Bearer ${TOKEN}` },
|
|
99
|
+
responseType: "arraybuffer",
|
|
100
|
+
});
|
|
101
|
+
expect(get).toHaveBeenNthCalledWith(
|
|
102
|
+
7,
|
|
103
|
+
"api/invoice-module/cfdi/catalogs/products?search=detergente",
|
|
104
|
+
authConfig,
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
expect(post).toHaveBeenNthCalledWith(
|
|
108
|
+
1,
|
|
109
|
+
"api/invoice-module/cfdi",
|
|
110
|
+
{
|
|
111
|
+
provider: "facturapi",
|
|
112
|
+
documentType: "income_invoice",
|
|
113
|
+
providerPayload: { ordersID: ["order-1"] },
|
|
114
|
+
},
|
|
115
|
+
authConfig,
|
|
116
|
+
);
|
|
117
|
+
expect(post).toHaveBeenNthCalledWith(
|
|
118
|
+
2,
|
|
119
|
+
"api/invoice-module/cfdi/global-by-payment-method/search",
|
|
120
|
+
{
|
|
121
|
+
paymentMethod: "cash",
|
|
122
|
+
dateFrom: "2026-01-01",
|
|
123
|
+
dateTo: "2026-01-31",
|
|
124
|
+
},
|
|
125
|
+
authConfig,
|
|
126
|
+
);
|
|
127
|
+
expect(post).toHaveBeenNthCalledWith(
|
|
128
|
+
3,
|
|
129
|
+
"api/invoice-module/cfdi/global-by-payment-method/preview",
|
|
130
|
+
{
|
|
131
|
+
paymentMethod: "cash",
|
|
132
|
+
dateFrom: "2026-01-01",
|
|
133
|
+
dateTo: "2026-01-31",
|
|
134
|
+
global: {
|
|
135
|
+
periodicity: "01",
|
|
136
|
+
months: "01",
|
|
137
|
+
year: "2026",
|
|
138
|
+
},
|
|
139
|
+
paymentLines: [{ paymentLineId: "payment-line-1" }],
|
|
140
|
+
},
|
|
141
|
+
authConfig,
|
|
142
|
+
);
|
|
143
|
+
expect(post).toHaveBeenNthCalledWith(
|
|
144
|
+
4,
|
|
145
|
+
"api/invoice-module/cfdi/global-by-payment-method",
|
|
146
|
+
{
|
|
147
|
+
paymentMethod: "cash",
|
|
148
|
+
dateFrom: "2026-01-01",
|
|
149
|
+
dateTo: "2026-01-31",
|
|
150
|
+
global: {
|
|
151
|
+
periodicity: "01",
|
|
152
|
+
months: "01",
|
|
153
|
+
year: "2026",
|
|
154
|
+
},
|
|
155
|
+
paymentLines: [{ paymentLineId: "payment-line-1" }],
|
|
156
|
+
},
|
|
157
|
+
authConfig,
|
|
158
|
+
);
|
|
159
|
+
expect(deleteRequest).toHaveBeenCalledWith("api/invoice-module/cfdi/invoice-1", {
|
|
160
|
+
...authConfig,
|
|
161
|
+
data: {
|
|
162
|
+
motive: "02",
|
|
163
|
+
substitution: "replacement-uuid",
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("keeps legacy cfdi endpoint mappings intact", async () => {
|
|
169
|
+
const get = jest.fn().mockResolvedValue({ data: { data: {} } });
|
|
170
|
+
const post = jest.fn().mockResolvedValue({ data: { data: {} } });
|
|
171
|
+
const deleteRequest = jest.fn().mockResolvedValue({ data: { data: {} } });
|
|
172
|
+
const client = new (WashdayClient as any)(TOKEN, "DEV");
|
|
173
|
+
client.axiosInstance = { get, post, delete: deleteRequest };
|
|
174
|
+
|
|
175
|
+
await client.cfdi.getList({ query: "folio-1" });
|
|
176
|
+
await client.cfdi.createCFDI({
|
|
177
|
+
ordersID: ["order-1"],
|
|
178
|
+
CFDIInfo: {
|
|
179
|
+
use: "G03",
|
|
180
|
+
payment_method: "PUE",
|
|
181
|
+
payment_form: "01",
|
|
182
|
+
date: "2026-01-01",
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
await client.cfdi.cancelCFDI("invoice-1", { motive: "02" });
|
|
186
|
+
|
|
187
|
+
expect(get).toHaveBeenCalledWith("api/cfdi?query=folio-1", authConfig);
|
|
188
|
+
expect(post).toHaveBeenCalledWith(
|
|
189
|
+
"api/cfdi",
|
|
190
|
+
{
|
|
191
|
+
ordersID: ["order-1"],
|
|
192
|
+
CFDIInfo: {
|
|
193
|
+
use: "G03",
|
|
194
|
+
payment_method: "PUE",
|
|
195
|
+
payment_form: "01",
|
|
196
|
+
date: "2026-01-01",
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
authConfig,
|
|
200
|
+
);
|
|
201
|
+
expect(deleteRequest).toHaveBeenCalledWith("api/cfdi/invoice-1", {
|
|
202
|
+
...authConfig,
|
|
203
|
+
data: { motive: "02" },
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const type = "brand";
|
|
2
|
-
const catalog = {
|
|
3
|
-
type,
|
|
4
|
-
values: ["Nike"],
|
|
5
|
-
};
|
|
6
|
-
const getResponse = {
|
|
7
|
-
garmentAttributeCatalogs: [catalog],
|
|
8
|
-
};
|
|
9
|
-
const updateRequest = {
|
|
10
|
-
garmentAttributeCatalogs: [catalog],
|
|
11
|
-
};
|
|
12
|
-
const updateResponse = {
|
|
13
|
-
garmentAttributeCatalogs: updateRequest.garmentAttributeCatalogs,
|
|
14
|
-
};
|
|
15
|
-
if (getResponse.garmentAttributeCatalogs[0].type !== "brand") {
|
|
16
|
-
throw new Error("Garment attribute catalog type export was not preserved");
|
|
17
|
-
}
|
|
18
|
-
if (updateResponse.garmentAttributeCatalogs[0].values[0] !== "Nike") {
|
|
19
|
-
throw new Error("Garment attribute catalog response export was not preserved");
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
const variant = {
|
|
3
|
-
_id: "option-1",
|
|
4
|
-
label: "XL",
|
|
5
|
-
description: "Incluye tratamiento premium",
|
|
6
|
-
price: 130,
|
|
7
|
-
expressPrice: 190,
|
|
8
|
-
isDefault: true,
|
|
9
|
-
isActive: true,
|
|
10
|
-
};
|
|
11
|
-
const product = {
|
|
12
|
-
_id: "product-1",
|
|
13
|
-
name: "Camisa",
|
|
14
|
-
description: "Lavado y planchado",
|
|
15
|
-
price: 120,
|
|
16
|
-
expressPrice: 180,
|
|
17
|
-
overlayText: "",
|
|
18
|
-
sku: "",
|
|
19
|
-
pieces: "1",
|
|
20
|
-
taxExemptOne: false,
|
|
21
|
-
taxExemptTwo: false,
|
|
22
|
-
taxExemptThree: false,
|
|
23
|
-
type: "normal",
|
|
24
|
-
isActive: true,
|
|
25
|
-
showInApp: true,
|
|
26
|
-
owner: "user-1",
|
|
27
|
-
store: "store-1",
|
|
28
|
-
order: 1,
|
|
29
|
-
priceOptions: [variant],
|
|
30
|
-
};
|
|
31
|
-
if (product.description !== "Lavado y planchado") {
|
|
32
|
-
throw new Error("Product description was not preserved");
|
|
33
|
-
}
|
|
34
|
-
if (((_a = product.priceOptions) === null || _a === void 0 ? void 0 : _a[0].description) !== "Incluye tratamiento premium") {
|
|
35
|
-
throw new Error("Variant description was not preserved");
|
|
36
|
-
}
|
|
37
|
-
export {};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const folioPreset = "large";
|
|
2
|
-
const spacingPreset = "medium";
|
|
3
|
-
const ticketStructure = {
|
|
4
|
-
showTotalPieces: false,
|
|
5
|
-
showEmisionDate: true,
|
|
6
|
-
showEmisionTime: true,
|
|
7
|
-
showLegend: true,
|
|
8
|
-
showPaymentMethod: true,
|
|
9
|
-
showStorePhone: true,
|
|
10
|
-
showCustomerPoints: false,
|
|
11
|
-
showDeliveryDate: true,
|
|
12
|
-
showDeliveryTime: true,
|
|
13
|
-
ticketLegendText: "Gracias",
|
|
14
|
-
showStoreName: true,
|
|
15
|
-
showCustomerName: true,
|
|
16
|
-
showCreatedByName: true,
|
|
17
|
-
showOrderNotes: false,
|
|
18
|
-
showTaxes: false,
|
|
19
|
-
showDiscounts: true,
|
|
20
|
-
showCredit: true,
|
|
21
|
-
customerNameFontSize: "small",
|
|
22
|
-
orderFolioFontSizePreset: folioPreset,
|
|
23
|
-
ticketLineSpacingPreset: spacingPreset,
|
|
24
|
-
ticketPrintFormat: "escpos",
|
|
25
|
-
tax_id: "J-507138330",
|
|
26
|
-
tax_id_label: "RIF",
|
|
27
|
-
};
|
|
28
|
-
const labelTicketStructure = Object.assign({}, ticketStructure);
|
|
29
|
-
const ticketForLaundryStructure = {
|
|
30
|
-
showTotalPieces: false,
|
|
31
|
-
showEmisionDate: true,
|
|
32
|
-
showEmisionTime: true,
|
|
33
|
-
showLegend: true,
|
|
34
|
-
showPaymentMethod: true,
|
|
35
|
-
showStorePhone: true,
|
|
36
|
-
showCustomerPoints: false,
|
|
37
|
-
showDeliveryDate: true,
|
|
38
|
-
showDeliveryTime: true,
|
|
39
|
-
ticketLegendText: "Gracias",
|
|
40
|
-
printLogoOnTicket: false,
|
|
41
|
-
showStoreName: true,
|
|
42
|
-
showCustomerName: true,
|
|
43
|
-
showCreatedByName: true,
|
|
44
|
-
showOrderNotes: false,
|
|
45
|
-
showTaxes: false,
|
|
46
|
-
showDiscounts: true,
|
|
47
|
-
showCredit: true,
|
|
48
|
-
customerNameFontSize: "medium",
|
|
49
|
-
orderFolioFontSizePreset: "large",
|
|
50
|
-
ticketLineSpacingPreset: "small",
|
|
51
|
-
ticketPrintFormat: "html",
|
|
52
|
-
tax_id: "ABC123",
|
|
53
|
-
tax_id_label: "RFC",
|
|
54
|
-
};
|
|
55
|
-
if (ticketStructure.orderFolioFontSizePreset !== "large") {
|
|
56
|
-
throw new Error("Ticket structure folio preset was not preserved");
|
|
57
|
-
}
|
|
58
|
-
if (labelTicketStructure.ticketLineSpacingPreset !== "medium") {
|
|
59
|
-
throw new Error("Label ticket structure spacing preset was not preserved");
|
|
60
|
-
}
|
|
61
|
-
if (ticketForLaundryStructure.customerNameFontSize !== "medium") {
|
|
62
|
-
throw new Error("Laundry ticket structure customer font size was not preserved");
|
|
63
|
-
}
|
|
64
|
-
if (ticketStructure.tax_id_label !== "RIF") {
|
|
65
|
-
throw new Error("Ticket structure tax ID label was not preserved");
|
|
66
|
-
}
|
|
67
|
-
if (labelTicketStructure.tax_id !== "J-507138330") {
|
|
68
|
-
throw new Error("Label ticket structure tax ID value was not preserved");
|
|
69
|
-
}
|
|
70
|
-
if (ticketForLaundryStructure.tax_id_label !== "RFC") {
|
|
71
|
-
throw new Error("Laundry ticket structure tax ID label was not preserved");
|
|
72
|
-
}
|
|
73
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
var _a, _b, _c;
|
|
2
|
-
import { OrderStatusEnum } from "../index";
|
|
3
|
-
const updatePayload = {
|
|
4
|
-
notes: "Peso confirmado en sucursal",
|
|
5
|
-
updateMode: "store_reception_validation",
|
|
6
|
-
};
|
|
7
|
-
const order = {
|
|
8
|
-
status: OrderStatusEnum.PENDING_STORE_RECEPTION_VALIDATION,
|
|
9
|
-
storeReceptionValidation: {
|
|
10
|
-
validatedAt: "2026-06-01T18:00:00.000Z",
|
|
11
|
-
validatedBy: "user-1",
|
|
12
|
-
source: "store_reception",
|
|
13
|
-
notes: "Validado en mostrador",
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
const permission = {
|
|
17
|
-
validateStoreReception: {
|
|
18
|
-
canMutate: true,
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
const store = {
|
|
22
|
-
storeReceptionValidationConfig: {
|
|
23
|
-
enabled: true,
|
|
24
|
-
restrictCloseRouteUntilStoreValidation: false,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
const preview = {
|
|
28
|
-
routeId: "route-1",
|
|
29
|
-
canClose: true,
|
|
30
|
-
summary: {
|
|
31
|
-
confirmed: 0,
|
|
32
|
-
failed: 0,
|
|
33
|
-
cancelled: 0,
|
|
34
|
-
pendingActive: 0,
|
|
35
|
-
},
|
|
36
|
-
pendingActiveOrders: [],
|
|
37
|
-
requiresExplicitConfirmation: false,
|
|
38
|
-
hasPendingStoreReceptionValidations: true,
|
|
39
|
-
pendingStoreReceptionValidationOrdersCount: 1,
|
|
40
|
-
restrictCloseRouteUntilStoreValidation: false,
|
|
41
|
-
warnings: [
|
|
42
|
-
"Esta ruta tiene pedidos pendientes de validar en sucursal.",
|
|
43
|
-
],
|
|
44
|
-
};
|
|
45
|
-
if (OrderStatusEnum.PENDING_STORE_RECEPTION_VALIDATION !== "pending_store_reception_validation") {
|
|
46
|
-
throw new Error("Pending store reception validation order status is not exported");
|
|
47
|
-
}
|
|
48
|
-
if (updatePayload.updateMode !== "store_reception_validation") {
|
|
49
|
-
throw new Error("Store reception validation update mode is not accepted");
|
|
50
|
-
}
|
|
51
|
-
if (((_a = order.storeReceptionValidation) === null || _a === void 0 ? void 0 : _a.source) !== "store_reception") {
|
|
52
|
-
throw new Error("Order store reception validation source was not preserved");
|
|
53
|
-
}
|
|
54
|
-
if (((_b = permission.validateStoreReception) === null || _b === void 0 ? void 0 : _b.canMutate) !== true) {
|
|
55
|
-
throw new Error("Validate store reception permission was not preserved");
|
|
56
|
-
}
|
|
57
|
-
if (((_c = store.storeReceptionValidationConfig) === null || _c === void 0 ? void 0 : _c.enabled) !== true) {
|
|
58
|
-
throw new Error("Store reception validation config was not preserved");
|
|
59
|
-
}
|
|
60
|
-
if (preview.pendingStoreReceptionValidationOrdersCount !== 1) {
|
|
61
|
-
throw new Error("Route close preview pending validation count was not preserved");
|
|
62
|
-
}
|