@chift/chift-nodejs 1.0.7 → 1.0.8
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/.github/workflows/ci.yml +1 -1
- package/CHANGELOG.md +24 -0
- package/dist/src/modules/accounting.d.ts +21 -18
- package/dist/src/modules/accounting.js +59 -20
- package/dist/src/modules/api.d.ts +465 -90
- package/dist/src/modules/consumer.d.ts +93 -18
- package/dist/src/modules/consumers.d.ts +465 -90
- package/dist/src/modules/sync.d.ts +372 -72
- package/dist/test/modules/accounting.test.js +28 -0
- package/package.json +1 -1
- package/src/modules/accounting.ts +95 -22
- package/test/modules/accounting.test.ts +31 -0
|
@@ -552,3 +552,31 @@ let miscOperations;
|
|
|
552
552
|
(0, globals_1.expect)(financialEntry).toBeTruthy();
|
|
553
553
|
(0, globals_1.expect)(financialEntry).toHaveProperty('journal_id', journal.id);
|
|
554
554
|
}));
|
|
555
|
+
let folders = [];
|
|
556
|
+
(0, globals_1.test)('getFolders', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
557
|
+
folders = yield consumer.accounting.getFolders();
|
|
558
|
+
(0, globals_1.expect)(folders).toBeInstanceOf(Array);
|
|
559
|
+
(0, globals_1.expect)(folders.length).toBeGreaterThan(0);
|
|
560
|
+
(0, globals_1.expect)(folders[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
561
|
+
(0, globals_1.expect)(folders[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
562
|
+
}));
|
|
563
|
+
globals_1.test.skip('getAttachments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
564
|
+
const attachments = yield consumer.accounting.getAttachments({
|
|
565
|
+
// TODO: Add documentId from test account
|
|
566
|
+
documentId: '',
|
|
567
|
+
type: 'invoice',
|
|
568
|
+
});
|
|
569
|
+
(0, globals_1.expect)(attachments).toBeInstanceOf(Array);
|
|
570
|
+
(0, globals_1.expect)(attachments.length).toBeGreaterThan(0);
|
|
571
|
+
(0, globals_1.expect)(attachments[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
572
|
+
(0, globals_1.expect)(attachments[0]).toHaveProperty('base64_string', globals_1.expect.any(String));
|
|
573
|
+
}));
|
|
574
|
+
globals_1.test.skip('matchEntries', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
575
|
+
const match = yield consumer.accounting.matchEntries({
|
|
576
|
+
// TODO: Change params with test account values
|
|
577
|
+
entries: [],
|
|
578
|
+
partner_id: '',
|
|
579
|
+
});
|
|
580
|
+
(0, globals_1.expect)(match).toHaveProperty('matching_number', globals_1.expect.any(String));
|
|
581
|
+
(0, globals_1.expect)(match).toHaveProperty('balance', globals_1.expect.any(Number));
|
|
582
|
+
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chift/chift-nodejs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "The Chift NodeJS library provides convenient access to the Chift API from applications written in the NodeJS language (Javascript/Typescript).",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -37,14 +37,20 @@ type getOutstandingsParams = Omit<
|
|
|
37
37
|
>;
|
|
38
38
|
|
|
39
39
|
const accountingFactory = {
|
|
40
|
-
getAnalyticPlans(
|
|
40
|
+
getAnalyticPlans(
|
|
41
|
+
params: operations['accounting_get_analytic_plans']['parameters']['query']
|
|
42
|
+
): RequestData<components['schemas']['AnalyticPlanItem'][]> {
|
|
41
43
|
return {
|
|
44
|
+
params,
|
|
42
45
|
method: 'get',
|
|
43
46
|
url: '/consumers/{consumer_id}/accounting/analytic-plans',
|
|
44
47
|
};
|
|
45
48
|
},
|
|
46
|
-
getClients(
|
|
49
|
+
getClients(
|
|
50
|
+
params: operations['accounting_get_clients']['parameters']['query']
|
|
51
|
+
): RequestData<components['schemas']['ClientItemOut'][]> {
|
|
47
52
|
return {
|
|
53
|
+
params,
|
|
48
54
|
method: 'get',
|
|
49
55
|
url: '/consumers/{consumer_id}/accounting/clients',
|
|
50
56
|
};
|
|
@@ -54,30 +60,39 @@ const accountingFactory = {
|
|
|
54
60
|
params: operations['accounting_create_client']['parameters']['query']
|
|
55
61
|
): RequestData<components['schemas']['ClientItemOut']> {
|
|
56
62
|
return {
|
|
63
|
+
params,
|
|
57
64
|
method: 'post',
|
|
58
65
|
url: '/consumers/{consumer_id}/accounting/clients',
|
|
59
66
|
body: client,
|
|
60
|
-
params: params,
|
|
61
67
|
};
|
|
62
68
|
},
|
|
63
|
-
getClient(
|
|
69
|
+
getClient(
|
|
70
|
+
clientId: string,
|
|
71
|
+
params: operations['accounting_get_client']['parameters']['query']
|
|
72
|
+
): RequestData<components['schemas']['ClientItemOut']> {
|
|
64
73
|
return {
|
|
74
|
+
params,
|
|
65
75
|
method: 'get',
|
|
66
76
|
url: `/consumers/{consumer_id}/accounting/clients/${clientId}`,
|
|
67
77
|
};
|
|
68
78
|
},
|
|
69
79
|
updateClient(
|
|
70
80
|
clientId: string,
|
|
71
|
-
client: components['schemas']['ClientItemUpdate']
|
|
81
|
+
client: components['schemas']['ClientItemUpdate'],
|
|
82
|
+
params: operations['accounting_update_client']['parameters']['query']
|
|
72
83
|
): RequestData<components['schemas']['ClientItemOut']> {
|
|
73
84
|
return {
|
|
85
|
+
params,
|
|
74
86
|
method: 'patch',
|
|
75
87
|
url: `/consumers/{consumer_id}/accounting/clients/${clientId}`,
|
|
76
88
|
body: client,
|
|
77
89
|
};
|
|
78
90
|
},
|
|
79
|
-
getSuppliers(
|
|
91
|
+
getSuppliers(
|
|
92
|
+
params: operations['accounting_get_suppliers']['parameters']['query']
|
|
93
|
+
): RequestData<components['schemas']['SupplierItemOut'][]> {
|
|
80
94
|
return {
|
|
95
|
+
params,
|
|
81
96
|
method: 'get',
|
|
82
97
|
url: '/consumers/{consumer_id}/accounting/suppliers',
|
|
83
98
|
};
|
|
@@ -87,23 +102,29 @@ const accountingFactory = {
|
|
|
87
102
|
params: operations['accounting_create_supplier']['parameters']['query']
|
|
88
103
|
): RequestData<components['schemas']['SupplierItemOut']> {
|
|
89
104
|
return {
|
|
105
|
+
params,
|
|
90
106
|
method: 'post',
|
|
91
107
|
url: '/consumers/{consumer_id}/accounting/suppliers',
|
|
92
108
|
body: supplier,
|
|
93
|
-
params: params,
|
|
94
109
|
};
|
|
95
110
|
},
|
|
96
|
-
getSupplier(
|
|
111
|
+
getSupplier(
|
|
112
|
+
supplierId: string,
|
|
113
|
+
params: operations['accounting_get_supplier']['parameters']['query']
|
|
114
|
+
): RequestData<components['schemas']['SupplierItemOut']> {
|
|
97
115
|
return {
|
|
116
|
+
params,
|
|
98
117
|
method: 'get',
|
|
99
118
|
url: `/consumers/{consumer_id}/accounting/suppliers/${supplierId}`,
|
|
100
119
|
};
|
|
101
120
|
},
|
|
102
121
|
updateSupplier(
|
|
103
122
|
supplierId: string,
|
|
104
|
-
supplier: components['schemas']['SupplierItemUpdate']
|
|
123
|
+
supplier: components['schemas']['SupplierItemUpdate'],
|
|
124
|
+
params: operations['accounting_update_supplier']['parameters']['query']
|
|
105
125
|
): RequestData<components['schemas']['SupplierItemOut']> {
|
|
106
126
|
return {
|
|
127
|
+
params,
|
|
107
128
|
method: 'patch',
|
|
108
129
|
url: `/consumers/{consumer_id}/accounting/suppliers/${supplierId}`,
|
|
109
130
|
body: supplier,
|
|
@@ -172,43 +193,54 @@ const accountingFactory = {
|
|
|
172
193
|
};
|
|
173
194
|
},
|
|
174
195
|
createAnalyticAccount(
|
|
175
|
-
analyticAccount: components['schemas']['AnalyticAccountItemIn']
|
|
196
|
+
analyticAccount: components['schemas']['AnalyticAccountItemIn'],
|
|
197
|
+
params: operations['accounting_create_analytic_account']['parameters']['query']
|
|
176
198
|
): RequestData<components['schemas']['AnalyticAccountItemOut']> {
|
|
177
199
|
return {
|
|
200
|
+
params,
|
|
178
201
|
method: 'post',
|
|
179
202
|
url: '/consumers/{consumer_id}/accounting/analytic-accounts',
|
|
180
203
|
body: analyticAccount,
|
|
181
204
|
};
|
|
182
205
|
},
|
|
183
|
-
getAnalyticAccounts(
|
|
206
|
+
getAnalyticAccounts(
|
|
207
|
+
params: operations['accounting_get_analytic_accounts']['parameters']['query']
|
|
208
|
+
): RequestData<components['schemas']['AnalyticAccountItemOut'][]> {
|
|
184
209
|
return {
|
|
210
|
+
params,
|
|
185
211
|
method: 'get',
|
|
186
212
|
url: '/consumers/{consumer_id}/accounting/analytic-accounts',
|
|
187
213
|
};
|
|
188
214
|
},
|
|
189
215
|
createAnalyticAccountWithMultiplePlans(
|
|
190
216
|
analytic_plan: string,
|
|
191
|
-
analyticAccount: components['schemas']['AnalyticAccountItemIn']
|
|
217
|
+
analyticAccount: components['schemas']['AnalyticAccountItemIn'],
|
|
218
|
+
params: operations['accounting_create_analytic_account_multi_plans']['parameters']['query']
|
|
192
219
|
): RequestData<components['schemas']['AnalyticAccountItemOutMultiAnalyticPlans']> {
|
|
193
220
|
return {
|
|
221
|
+
params,
|
|
194
222
|
method: 'post',
|
|
195
223
|
url: `/consumers/{consumer_id}/accounting/analytic-accounts/multi-analytic-plans/${analytic_plan}`,
|
|
196
224
|
body: analyticAccount,
|
|
197
225
|
};
|
|
198
226
|
},
|
|
199
227
|
getAnalyticAccount(
|
|
200
|
-
analytic_account_id: string
|
|
228
|
+
analytic_account_id: string,
|
|
229
|
+
params: operations['accounting_get_analytic_account']['parameters']['query']
|
|
201
230
|
): RequestData<components['schemas']['AnalyticAccountItemOut']> {
|
|
202
231
|
return {
|
|
232
|
+
params,
|
|
203
233
|
method: 'get',
|
|
204
234
|
url: `/consumers/{consumer_id}/accounting/analytic-accounts/${analytic_account_id}`,
|
|
205
235
|
};
|
|
206
236
|
},
|
|
207
237
|
updateAnalyticAccount(
|
|
208
238
|
analytic_account_id: string,
|
|
209
|
-
analyticAccount: components['schemas']['AnalyticAccountItemUpdate']
|
|
239
|
+
analyticAccount: components['schemas']['AnalyticAccountItemUpdate'],
|
|
240
|
+
params: operations['accounting_update_analytic_account']['parameters']['query']
|
|
210
241
|
): RequestData<components['schemas']['AnalyticAccountItemOut']> {
|
|
211
242
|
return {
|
|
243
|
+
params,
|
|
212
244
|
method: 'patch',
|
|
213
245
|
url: `/consumers/{consumer_id}/accounting/analytic-accounts/${analytic_account_id}`,
|
|
214
246
|
body: analyticAccount,
|
|
@@ -216,9 +248,11 @@ const accountingFactory = {
|
|
|
216
248
|
},
|
|
217
249
|
getAnalyticAccountWithMultiplePlans(
|
|
218
250
|
analytic_account_id: string,
|
|
219
|
-
analytic_plan: string
|
|
251
|
+
analytic_plan: string,
|
|
252
|
+
params: operations['accounting_get_analytic_account_multi_plans']['parameters']['query']
|
|
220
253
|
): RequestData<components['schemas']['AnalyticAccountItemOutMultiAnalyticPlans']> {
|
|
221
254
|
return {
|
|
255
|
+
params,
|
|
222
256
|
method: 'get',
|
|
223
257
|
url: `/consumers/{consumer_id}/accounting/analytic-accounts/${analytic_account_id}/multi-analytic-plans/${analytic_plan}`,
|
|
224
258
|
};
|
|
@@ -226,18 +260,21 @@ const accountingFactory = {
|
|
|
226
260
|
updateAnalyticAccountWithMultiplePlans(
|
|
227
261
|
analytic_account_id: string,
|
|
228
262
|
analytic_plan: string,
|
|
229
|
-
analyticAccount: components['schemas']['AnalyticAccountItemUpdate']
|
|
263
|
+
analyticAccount: components['schemas']['AnalyticAccountItemUpdate'],
|
|
264
|
+
params: operations['accounting_update_analytic_account_multi_plans']['parameters']['query']
|
|
230
265
|
): RequestData<components['schemas']['AnalyticAccountItemOutMultiAnalyticPlans']> {
|
|
231
266
|
return {
|
|
267
|
+
params,
|
|
232
268
|
method: 'patch',
|
|
233
269
|
url: `/consumers/{consumer_id}/accounting/analytic-accounts/${analytic_account_id}/multi-analytic-plans/${analytic_plan}`,
|
|
234
270
|
body: analyticAccount,
|
|
235
271
|
};
|
|
236
272
|
},
|
|
237
|
-
getAnalyticAccountsWithMultiplePlans(
|
|
238
|
-
|
|
239
|
-
> {
|
|
273
|
+
getAnalyticAccountsWithMultiplePlans(
|
|
274
|
+
params: operations['accounting_get_analytic_accounts_multi_plans']['parameters']['query']
|
|
275
|
+
): RequestData<components['schemas']['AnalyticAccountItemOutMultiAnalyticPlans'][]> {
|
|
240
276
|
return {
|
|
277
|
+
params,
|
|
241
278
|
method: 'get',
|
|
242
279
|
url: '/consumers/{consumer_id}/accounting/analytic-accounts/multi-analytic-plans',
|
|
243
280
|
};
|
|
@@ -260,20 +297,30 @@ const accountingFactory = {
|
|
|
260
297
|
url: `/consumers/{consumer_id}/accounting/journal/entries/multi-analytic-plans`,
|
|
261
298
|
};
|
|
262
299
|
},
|
|
263
|
-
getPaymentsByInvoiceId(
|
|
300
|
+
getPaymentsByInvoiceId(
|
|
301
|
+
invoice_id: string,
|
|
302
|
+
params: operations['accounting_get_payments_by_invoice']['parameters']['query']
|
|
303
|
+
): RequestData<components['schemas']['Payment'][]> {
|
|
264
304
|
return {
|
|
305
|
+
params,
|
|
265
306
|
method: 'get',
|
|
266
307
|
url: `/consumers/{consumer_id}/accounting/invoices/id/${invoice_id}/payments`,
|
|
267
308
|
};
|
|
268
309
|
},
|
|
269
|
-
getJournals(
|
|
310
|
+
getJournals(
|
|
311
|
+
params: operations['accounting_get_journals']['parameters']['query']
|
|
312
|
+
): RequestData<components['schemas']['Journal'][]> {
|
|
270
313
|
return {
|
|
314
|
+
params,
|
|
271
315
|
method: 'get',
|
|
272
316
|
url: `/consumers/{consumer_id}/accounting/journals`,
|
|
273
317
|
};
|
|
274
318
|
},
|
|
275
|
-
getVatCodes(
|
|
319
|
+
getVatCodes(
|
|
320
|
+
params: operations['accounting_get_vat_codes']['parameters']['query']
|
|
321
|
+
): RequestData<components['schemas']['app__routers__accounting__VatCode'][]> {
|
|
276
322
|
return {
|
|
323
|
+
params,
|
|
277
324
|
method: 'get',
|
|
278
325
|
url: `/consumers/{consumer_id}/accounting/vat-codes`,
|
|
279
326
|
};
|
|
@@ -320,6 +367,15 @@ const accountingFactory = {
|
|
|
320
367
|
body: attachment,
|
|
321
368
|
};
|
|
322
369
|
},
|
|
370
|
+
getAttachments(
|
|
371
|
+
params: operations['accounting_get_attachments']['parameters']['query']
|
|
372
|
+
): RequestData<components['schemas']['AttachmentItem'][]> {
|
|
373
|
+
return {
|
|
374
|
+
params,
|
|
375
|
+
method: 'get',
|
|
376
|
+
url: `/consumers/{consumer_id}/accounting/attachments`,
|
|
377
|
+
};
|
|
378
|
+
},
|
|
323
379
|
getChartOfAccounts(
|
|
324
380
|
params: getChartOfAccountsParams
|
|
325
381
|
): RequestData<components['schemas']['AccountItem'][]> {
|
|
@@ -403,6 +459,23 @@ const accountingFactory = {
|
|
|
403
459
|
body: journal_entry,
|
|
404
460
|
};
|
|
405
461
|
},
|
|
462
|
+
matchEntries(
|
|
463
|
+
body: components['schemas']['MatchingIn'],
|
|
464
|
+
params: operations['accounting_match_entries']['parameters']['query']
|
|
465
|
+
): RequestData<components['schemas']['MatchingOut']> {
|
|
466
|
+
return {
|
|
467
|
+
params,
|
|
468
|
+
body,
|
|
469
|
+
method: 'post',
|
|
470
|
+
url: '/consumers/{consumer_id}/accounting/matching',
|
|
471
|
+
};
|
|
472
|
+
},
|
|
473
|
+
getFolders(): RequestData<components['schemas']['FolderItem'][]> {
|
|
474
|
+
return {
|
|
475
|
+
method: 'get',
|
|
476
|
+
url: '/consumers/{consumer_id}/accounting/folders',
|
|
477
|
+
};
|
|
478
|
+
},
|
|
406
479
|
};
|
|
407
480
|
|
|
408
481
|
export { accountingFactory };
|
|
@@ -595,3 +595,34 @@ test('createFinancialEntryOld', async () => {
|
|
|
595
595
|
expect(financialEntry).toBeTruthy();
|
|
596
596
|
expect(financialEntry).toHaveProperty('journal_id', journal.id);
|
|
597
597
|
});
|
|
598
|
+
|
|
599
|
+
let folders: components['schemas']['FolderItem'][] = [];
|
|
600
|
+
test('getFolders', async () => {
|
|
601
|
+
folders = await consumer.accounting.getFolders();
|
|
602
|
+
expect(folders).toBeInstanceOf(Array);
|
|
603
|
+
expect(folders.length).toBeGreaterThan(0);
|
|
604
|
+
expect(folders[0]).toHaveProperty('id', expect.any(String));
|
|
605
|
+
expect(folders[0]).toHaveProperty('name', expect.any(String));
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
test.skip('getAttachments', async () => {
|
|
609
|
+
const attachments = await consumer.accounting.getAttachments({
|
|
610
|
+
// TODO: Add documentId from test account
|
|
611
|
+
documentId: '',
|
|
612
|
+
type: 'invoice',
|
|
613
|
+
});
|
|
614
|
+
expect(attachments).toBeInstanceOf(Array);
|
|
615
|
+
expect(attachments.length).toBeGreaterThan(0);
|
|
616
|
+
expect(attachments[0]).toHaveProperty('id', expect.any(String));
|
|
617
|
+
expect(attachments[0]).toHaveProperty('base64_string', expect.any(String));
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
test.skip('matchEntries', async () => {
|
|
621
|
+
const match = await consumer.accounting.matchEntries({
|
|
622
|
+
// TODO: Change params with test account values
|
|
623
|
+
entries: [],
|
|
624
|
+
partner_id: '',
|
|
625
|
+
});
|
|
626
|
+
expect(match).toHaveProperty('matching_number', expect.any(String));
|
|
627
|
+
expect(match).toHaveProperty('balance', expect.any(Number));
|
|
628
|
+
});
|