washday-sdk 1.6.78 → 1.6.80
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 +17 -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/api/routes/get.ts +61 -0
- package/src/index.ts +1 -0
- package/src/interfaces/Api.ts +17 -0
- package/src/interfaces/Company.ts +27 -0
- package/src/interfaces/InvoiceModule.ts +135 -0
- package/src/interfaces/Product.ts +16 -0
- package/test/api/invoiceModule.test.ts +206 -0
- package/test/routes.multistore.test.ts +61 -1
- 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
|
@@ -174,6 +174,13 @@ export interface ApplySubscriptionPlanChangeResponse {
|
|
|
174
174
|
|
|
175
175
|
export interface IStripeSettings {
|
|
176
176
|
planPriceId?: string | null;
|
|
177
|
+
/**
|
|
178
|
+
* Legacy/subscription billing CFDI fields.
|
|
179
|
+
* Operational Invoice Module usage billing should prefer
|
|
180
|
+
* InvoiceModuleProviderSettings.billingConfig.stripeSubscriptionItemId,
|
|
181
|
+
* then fall back to company.stripeSettings.stripeCFDISubItemID.
|
|
182
|
+
* Do not mix operational module country with subscription billing fiscal country.
|
|
183
|
+
*/
|
|
177
184
|
stripeCFDISubID: string | null;
|
|
178
185
|
stripeCFDISubItemID: string | null;
|
|
179
186
|
cfdiBillingMode?: CFDIBillingMode;
|
|
@@ -187,12 +194,27 @@ export interface IStripeSettings {
|
|
|
187
194
|
|
|
188
195
|
export interface ICompanyTaxInfo {
|
|
189
196
|
name?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Legacy CFDI issuer legal name.
|
|
199
|
+
* Forward replacement: InvoiceModuleIssuerProfile.cfdi.legalName.
|
|
200
|
+
* Still used as fallback for CFDI issuer/profile compatibility.
|
|
201
|
+
*/
|
|
190
202
|
legal_name?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Legacy CFDI issuer tax system.
|
|
205
|
+
* Forward replacement: InvoiceModuleIssuerProfile.cfdi.taxSystem.
|
|
206
|
+
* Still used as fallback for CFDI issuer/profile compatibility.
|
|
207
|
+
*/
|
|
191
208
|
tax_system?: string;
|
|
192
209
|
website?: string;
|
|
193
210
|
support_email?: string;
|
|
194
211
|
phone?: string;
|
|
195
212
|
address?: {
|
|
213
|
+
/**
|
|
214
|
+
* Legacy CFDI issuer postal code.
|
|
215
|
+
* Forward replacement: InvoiceModuleIssuerProfile.cfdi.zip.
|
|
216
|
+
* Still used as fallback for CFDI issuer/profile compatibility.
|
|
217
|
+
*/
|
|
196
218
|
zip?: string;
|
|
197
219
|
street?: string;
|
|
198
220
|
exterior?: string;
|
|
@@ -201,5 +223,10 @@ export interface ICompanyTaxInfo {
|
|
|
201
223
|
enabled: boolean;
|
|
202
224
|
email: string;
|
|
203
225
|
};
|
|
226
|
+
/**
|
|
227
|
+
* Legacy global-payment-method CFDI product defaults.
|
|
228
|
+
* Future target: provider/standard-specific Invoice Module settings.
|
|
229
|
+
* Keep until global CFDI settings are migrated.
|
|
230
|
+
*/
|
|
204
231
|
globalPaymentMethodCfdiSettings?: GlobalPaymentMethodCfdiSettings;
|
|
205
232
|
}
|
|
@@ -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
|
+
}
|
|
@@ -30,6 +30,10 @@ export interface IPriceOption {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface IProductCfdiInvoiceModuleSettings {
|
|
33
|
+
/**
|
|
34
|
+
* Forward per-standard fiscal metadata for Mexico CFDI.
|
|
35
|
+
* Current Mexico runtime should prefer these fields over legacy product invoice_* fields.
|
|
36
|
+
*/
|
|
33
37
|
description?: string,
|
|
34
38
|
productKey?: string,
|
|
35
39
|
unitKey?: string,
|
|
@@ -37,6 +41,9 @@ export interface IProductCfdiInvoiceModuleSettings {
|
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
export interface IProductSunatInvoiceModuleSettings {
|
|
44
|
+
/**
|
|
45
|
+
* Forward per-standard fiscal metadata reserved/prepared for Peru SUNAT provider runtime.
|
|
46
|
+
*/
|
|
40
47
|
enabled?: boolean,
|
|
41
48
|
}
|
|
42
49
|
|
|
@@ -67,6 +74,15 @@ export interface IProduct {
|
|
|
67
74
|
store: IStore | string,
|
|
68
75
|
order: number,
|
|
69
76
|
productSupplies?: [IProductSupplies],
|
|
77
|
+
/**
|
|
78
|
+
* Legacy CFDI product fiscal metadata.
|
|
79
|
+
* Forward replacements:
|
|
80
|
+
* - invoiceModuleSettings.cfdi.description
|
|
81
|
+
* - invoiceModuleSettings.cfdi.productKey
|
|
82
|
+
* - invoiceModuleSettings.cfdi.unitKey
|
|
83
|
+
* - invoiceModuleSettings.cfdi.unitName
|
|
84
|
+
* Still used as fallback by CFDI builders/resolvers.
|
|
85
|
+
*/
|
|
70
86
|
invoice_description?: string,
|
|
71
87
|
invoice_product_key?: string,
|
|
72
88
|
invoice_product_unit_key?: string,
|
|
@@ -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
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRoutes, getRoutesByDriver } from "../src/api/routes/get";
|
|
1
|
+
import { getRoutes, getRoutesByDriver, getRoutesByStorePage, getRoutesPage } from "../src/api/routes/get";
|
|
2
2
|
import { createRouteV2 } from "../src/api/routes/post";
|
|
3
3
|
import { WashdayClient } from "../src";
|
|
4
4
|
|
|
@@ -95,6 +95,47 @@ describe("routes multi-store api", () => {
|
|
|
95
95
|
);
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
+
it("lists paginated company routes through the root routes endpoint", async () => {
|
|
99
|
+
const get = jest.fn().mockResolvedValue({ data: { data: { routes: [] } } });
|
|
100
|
+
const client = {
|
|
101
|
+
apiToken: "token-123",
|
|
102
|
+
axiosInstance: { get },
|
|
103
|
+
} as any;
|
|
104
|
+
|
|
105
|
+
await getRoutesPage.call(client, {
|
|
106
|
+
scope: "company",
|
|
107
|
+
pageNum: 1,
|
|
108
|
+
limit: 9,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
expect(get).toHaveBeenCalledWith(
|
|
112
|
+
"api/routes?scope=company&pageNum=1&limit=9",
|
|
113
|
+
{
|
|
114
|
+
headers: { Authorization: "Bearer token-123" },
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("lists paginated store routes through the store routes endpoint", async () => {
|
|
120
|
+
const get = jest.fn().mockResolvedValue({ data: { data: { routes: [] } } });
|
|
121
|
+
const client = {
|
|
122
|
+
apiToken: "token-123",
|
|
123
|
+
axiosInstance: { get },
|
|
124
|
+
} as any;
|
|
125
|
+
|
|
126
|
+
await getRoutesByStorePage.call(client, "store-a", {
|
|
127
|
+
pageNum: 2,
|
|
128
|
+
limit: 9,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
expect(get).toHaveBeenCalledWith(
|
|
132
|
+
"api/stores/store-a/routes?pageNum=2&limit=9",
|
|
133
|
+
{
|
|
134
|
+
headers: { Authorization: "Bearer token-123" },
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
98
139
|
it("exposes getRoutes through the WashdayClient routes module", async () => {
|
|
99
140
|
const get = jest.fn().mockResolvedValue({ data: { data: [] } });
|
|
100
141
|
const client = new WashdayClient("token-123", "DEV") as any;
|
|
@@ -108,4 +149,23 @@ describe("routes multi-store api", () => {
|
|
|
108
149
|
headers: { Authorization: "Bearer token-123" },
|
|
109
150
|
});
|
|
110
151
|
});
|
|
152
|
+
|
|
153
|
+
it("exposes paginated route list helpers through the WashdayClient routes module", async () => {
|
|
154
|
+
const get = jest.fn().mockResolvedValue({ data: { data: { routes: [] } } });
|
|
155
|
+
const client = new WashdayClient("token-123", "DEV") as any;
|
|
156
|
+
client.axiosInstance = { get };
|
|
157
|
+
|
|
158
|
+
expect(typeof client.routes.getRoutesPage).toBe("function");
|
|
159
|
+
expect(typeof client.routes.getRoutesByStorePage).toBe("function");
|
|
160
|
+
|
|
161
|
+
await client.routes.getRoutesPage({ scope: "company", pageNum: 0, limit: 9 });
|
|
162
|
+
await client.routes.getRoutesByStorePage("store-a", { pageNum: 0, limit: 9 });
|
|
163
|
+
|
|
164
|
+
expect(get).toHaveBeenNthCalledWith(1, "api/routes?scope=company&pageNum=0&limit=9", {
|
|
165
|
+
headers: { Authorization: "Bearer token-123" },
|
|
166
|
+
});
|
|
167
|
+
expect(get).toHaveBeenNthCalledWith(2, "api/stores/store-a/routes?pageNum=0&limit=9", {
|
|
168
|
+
headers: { Authorization: "Bearer token-123" },
|
|
169
|
+
});
|
|
170
|
+
});
|
|
111
171
|
});
|
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 {};
|