@chift/chift-nodejs 1.0.2 → 1.0.4
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/CHANGELOG.md +9 -0
- package/dist/src/modules/accounting.d.ts +8 -1
- package/dist/src/modules/accounting.js +27 -1
- package/dist/src/modules/api.d.ts +2699 -912
- package/dist/src/modules/consumer.d.ts +146 -27
- package/dist/src/modules/consumers.d.ts +731 -136
- package/dist/src/modules/datastores.d.ts +1 -1
- package/dist/src/modules/integrations.d.ts +2 -0
- package/dist/src/modules/sync.d.ts +584 -108
- package/dist/src/modules/sync.js +0 -2
- package/dist/src/modules/syncs.d.ts +1464 -274
- package/dist/test/modules/accounting.test.js +127 -15
- package/dist/test/modules/consumers.test.js +1 -1
- package/dist/test/modules/pos.test.js +4 -4
- package/package.json +1 -1
- package/src/modules/accounting.ts +17 -3
- package/src/types/public-api/schema.d.ts +343 -33
- package/test/modules/accounting.test.ts +27 -0
- package/.eslintcache +0 -1
- package/coverage/clover.xml +0 -1645
- package/coverage/coverage-final.json +0 -19
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/helpers/index.html +0 -131
- package/coverage/lcov-report/src/helpers/openapi.ts.html +0 -151
- package/coverage/lcov-report/src/helpers/settings.ts.html +0 -94
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/src/index.ts.html +0 -88
- package/coverage/lcov-report/src/modules/accounting.ts.html +0 -1156
- package/coverage/lcov-report/src/modules/api.ts.html +0 -190
- package/coverage/lcov-report/src/modules/consumer.ts.html +0 -616
- package/coverage/lcov-report/src/modules/consumers.ts.html +0 -331
- package/coverage/lcov-report/src/modules/custom.ts.html +0 -193
- package/coverage/lcov-report/src/modules/datastores.ts.html +0 -142
- package/coverage/lcov-report/src/modules/ecommerce.ts.html +0 -331
- package/coverage/lcov-report/src/modules/flow.ts.html +0 -589
- package/coverage/lcov-report/src/modules/index.html +0 -326
- package/coverage/lcov-report/src/modules/integrations.ts.html +0 -151
- package/coverage/lcov-report/src/modules/internalApi.ts.html +0 -586
- package/coverage/lcov-report/src/modules/invoicing.ts.html +0 -391
- package/coverage/lcov-report/src/modules/pos.ts.html +0 -421
- package/coverage/lcov-report/src/modules/sync.ts.html +0 -316
- package/coverage/lcov-report/src/modules/syncs.ts.html +0 -169
- package/coverage/lcov-report/src/modules/webhooks.ts.html +0 -343
- package/coverage/lcov.info +0 -1976
- package/dist/test/modules/flow.test.d.ts +0 -1
- package/dist/test/modules/flow.test.js +0 -69
|
@@ -69,6 +69,18 @@ let journals;
|
|
|
69
69
|
(0, globals_1.expect)(journals[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
70
70
|
(0, globals_1.expect)(journals[0]).toHaveProperty('journal_type', globals_1.expect.any(String));
|
|
71
71
|
}));
|
|
72
|
+
let vatCodes;
|
|
73
|
+
(0, globals_1.test)('getVatCodes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
vatCodes = yield consumer.accounting.getVatCodes();
|
|
75
|
+
(0, globals_1.expect)(vatCodes).toBeInstanceOf(Array);
|
|
76
|
+
(0, globals_1.expect)(vatCodes.length).toBeGreaterThan(0);
|
|
77
|
+
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
78
|
+
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('code');
|
|
79
|
+
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('label', globals_1.expect.any(String));
|
|
80
|
+
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('scope', globals_1.expect.any(String));
|
|
81
|
+
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('rate', globals_1.expect.any(Number));
|
|
82
|
+
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('type', globals_1.expect.any(String));
|
|
83
|
+
}));
|
|
72
84
|
(0, globals_1.test)('createClient', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
85
|
const body = {
|
|
74
86
|
external_reference: 'sdk test',
|
|
@@ -186,6 +198,14 @@ let suppliers;
|
|
|
186
198
|
}));
|
|
187
199
|
(0, globals_1.test)('createInvoice', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
188
200
|
var _a;
|
|
201
|
+
const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
|
|
202
|
+
if (!journal) {
|
|
203
|
+
throw new Error('No journal with type "customer_invoice" found to create invoice');
|
|
204
|
+
}
|
|
205
|
+
const vatCode = vatCodes.find((vatCode) => vatCode.type === 'sale' && vatCode.rate === 21);
|
|
206
|
+
if (!(vatCode === null || vatCode === void 0 ? void 0 : vatCode.id)) {
|
|
207
|
+
throw new Error('No vat code with type "sale" and rate 21 found to create invoice');
|
|
208
|
+
}
|
|
189
209
|
const body = {
|
|
190
210
|
invoice_type: 'customer_invoice',
|
|
191
211
|
invoice_date: '2022-12-01',
|
|
@@ -195,7 +215,7 @@ let suppliers;
|
|
|
195
215
|
tax_amount: 21,
|
|
196
216
|
total: 121,
|
|
197
217
|
partner_id: (_a = clients[0]) === null || _a === void 0 ? void 0 : _a.id,
|
|
198
|
-
journal_id:
|
|
218
|
+
journal_id: journal.id,
|
|
199
219
|
lines: [
|
|
200
220
|
{
|
|
201
221
|
description: 'Test',
|
|
@@ -206,7 +226,7 @@ let suppliers;
|
|
|
206
226
|
tax_amount: 21,
|
|
207
227
|
total: 121,
|
|
208
228
|
account_number: '700000',
|
|
209
|
-
tax_code:
|
|
229
|
+
tax_code: vatCode.id,
|
|
210
230
|
},
|
|
211
231
|
],
|
|
212
232
|
};
|
|
@@ -259,6 +279,14 @@ let invoices;
|
|
|
259
279
|
}));
|
|
260
280
|
(0, globals_1.test)('createInvoiceWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
261
281
|
var _b;
|
|
282
|
+
const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
|
|
283
|
+
if (!journal) {
|
|
284
|
+
throw new Error('No journal with type customer_invoice found to create Invoice With Multiple Plans');
|
|
285
|
+
}
|
|
286
|
+
const vatCode = vatCodes.find((vatCode) => vatCode.type === 'sale' && vatCode.rate === 21);
|
|
287
|
+
if (!(vatCode === null || vatCode === void 0 ? void 0 : vatCode.id)) {
|
|
288
|
+
throw new Error('No vat code with type "sale" and rate 21 found to create invoice');
|
|
289
|
+
}
|
|
262
290
|
const body = {
|
|
263
291
|
invoice_type: 'customer_invoice',
|
|
264
292
|
invoice_date: '2022-12-01',
|
|
@@ -268,7 +296,7 @@ let invoices;
|
|
|
268
296
|
tax_amount: 21,
|
|
269
297
|
total: 121,
|
|
270
298
|
partner_id: (_b = clients[0]) === null || _b === void 0 ? void 0 : _b.id,
|
|
271
|
-
journal_id:
|
|
299
|
+
journal_id: journal.id,
|
|
272
300
|
lines: [
|
|
273
301
|
{
|
|
274
302
|
description: 'Test',
|
|
@@ -279,7 +307,7 @@ let invoices;
|
|
|
279
307
|
tax_amount: 21,
|
|
280
308
|
total: 121,
|
|
281
309
|
account_number: '700000',
|
|
282
|
-
tax_code:
|
|
310
|
+
tax_code: vatCode.id,
|
|
283
311
|
},
|
|
284
312
|
],
|
|
285
313
|
};
|
|
@@ -360,6 +388,34 @@ let analyticAccounts;
|
|
|
360
388
|
(0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
361
389
|
}
|
|
362
390
|
}));
|
|
391
|
+
(0, globals_1.test)('createJournalEntry', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
392
|
+
const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
|
|
393
|
+
if (!journal) {
|
|
394
|
+
throw new Error('No journal with type "customer_invoice" found to create journal entry');
|
|
395
|
+
}
|
|
396
|
+
const journalEntry = yield consumer.accounting.createJournalEntry({
|
|
397
|
+
journal_id: journal.id,
|
|
398
|
+
name: Date.now().toString(),
|
|
399
|
+
date: '2022-01-01',
|
|
400
|
+
items: [
|
|
401
|
+
{
|
|
402
|
+
account_number: clients[0].account_number,
|
|
403
|
+
credit: 0,
|
|
404
|
+
debit: 10,
|
|
405
|
+
partner_id: clients[0].id,
|
|
406
|
+
currency: 'EUR',
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
account_number: '700000',
|
|
410
|
+
credit: 10,
|
|
411
|
+
debit: 0,
|
|
412
|
+
currency: 'EUR',
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
});
|
|
416
|
+
(0, globals_1.expect)(journalEntry).toBeTruthy();
|
|
417
|
+
(0, globals_1.expect)(journalEntry).toHaveProperty('journal_id', journal.id);
|
|
418
|
+
}));
|
|
363
419
|
(0, globals_1.test)('getJournalEntries', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
364
420
|
const journalEntries = yield consumer.accounting.getJournalEntries({
|
|
365
421
|
unposted_allowed: true,
|
|
@@ -382,17 +438,6 @@ let analyticAccounts;
|
|
|
382
438
|
const payments = yield consumer.accounting.getPaymentsByInvoiceId(invoices[0].id);
|
|
383
439
|
(0, globals_1.expect)(payments).toBeInstanceOf(Array);
|
|
384
440
|
}));
|
|
385
|
-
(0, globals_1.test)('getVatCodes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
386
|
-
const vatCodes = yield consumer.accounting.getVatCodes();
|
|
387
|
-
(0, globals_1.expect)(vatCodes).toBeInstanceOf(Array);
|
|
388
|
-
(0, globals_1.expect)(vatCodes.length).toBeGreaterThan(0);
|
|
389
|
-
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
390
|
-
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('code');
|
|
391
|
-
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('label', globals_1.expect.any(String));
|
|
392
|
-
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('scope', globals_1.expect.any(String));
|
|
393
|
-
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('rate', globals_1.expect.any(Number));
|
|
394
|
-
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('type', globals_1.expect.any(String));
|
|
395
|
-
}));
|
|
396
441
|
let miscOperations;
|
|
397
442
|
(0, globals_1.test)('getMiscOperations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
398
443
|
miscOperations = yield consumer.accounting.getMiscOperations();
|
|
@@ -451,3 +496,70 @@ let miscOperations;
|
|
|
451
496
|
(0, globals_1.expect)(balanceOfAccounts).toHaveProperty('items');
|
|
452
497
|
(0, globals_1.expect)(balanceOfAccounts.items).toBeInstanceOf(Array);
|
|
453
498
|
}));
|
|
499
|
+
(0, globals_1.test)('getEmployees', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
500
|
+
const employees = yield consumer.accounting.getEmployees();
|
|
501
|
+
(0, globals_1.expect)(employees).toBeTruthy();
|
|
502
|
+
}));
|
|
503
|
+
(0, globals_1.test)('getOutstandings', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
504
|
+
var _d;
|
|
505
|
+
globals_1.expect.assertions(1);
|
|
506
|
+
try {
|
|
507
|
+
const outstandings = yield consumer.accounting.getOutstandings({
|
|
508
|
+
type: 'client',
|
|
509
|
+
unposted_allowed: true,
|
|
510
|
+
});
|
|
511
|
+
(0, globals_1.expect)(outstandings).toBeTruthy();
|
|
512
|
+
(0, globals_1.expect)(outstandings.items).toBeInstanceOf(Array);
|
|
513
|
+
}
|
|
514
|
+
catch (e) {
|
|
515
|
+
if ((_d = e === null || e === void 0 ? void 0 : e.error) === null || _d === void 0 ? void 0 : _d.error_code) {
|
|
516
|
+
(0, globals_1.expect)(e.error.error_code).toMatch('ERROR_API_RESOURCE_NOT_FOUND');
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
throw e;
|
|
520
|
+
}
|
|
521
|
+
}));
|
|
522
|
+
(0, globals_1.test)('createFinancialEntry', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
523
|
+
const journal = journals.find((journal) => journal.journal_type === 'financial_operation');
|
|
524
|
+
if (!journal) {
|
|
525
|
+
throw new Error('No journal with type "financial_operation" found to create financial entry');
|
|
526
|
+
}
|
|
527
|
+
const financialEntry = yield consumer.accounting.createFinancialEntry({
|
|
528
|
+
date: '2022-01-01',
|
|
529
|
+
journal_id: journal.id,
|
|
530
|
+
currency: 'EUR',
|
|
531
|
+
items: [
|
|
532
|
+
{
|
|
533
|
+
account_type: 'customer_account',
|
|
534
|
+
account: clients[0].id,
|
|
535
|
+
amount: 10,
|
|
536
|
+
},
|
|
537
|
+
],
|
|
538
|
+
});
|
|
539
|
+
(0, globals_1.expect)(financialEntry).toBeTruthy();
|
|
540
|
+
(0, globals_1.expect)(financialEntry).toHaveProperty('journal_id', journal.id);
|
|
541
|
+
}));
|
|
542
|
+
/**
|
|
543
|
+
* @deprecated replaced by createFinancialEntry
|
|
544
|
+
*/
|
|
545
|
+
(0, globals_1.test)('createFinancialEntryOld', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
546
|
+
const journal = journals.find((journal) => journal.journal_type === 'financial_operation');
|
|
547
|
+
if (!journal) {
|
|
548
|
+
throw new Error('No journal with type "financial_operation" found to create financial entry');
|
|
549
|
+
}
|
|
550
|
+
const financialEntry = yield consumer.accounting.createFinancialEntryOld({
|
|
551
|
+
date: '2022-01-01',
|
|
552
|
+
journal_id: journal.id,
|
|
553
|
+
currency: 'EUR',
|
|
554
|
+
items: [
|
|
555
|
+
{
|
|
556
|
+
type: 'customer_account',
|
|
557
|
+
account_number: clients[0].account_number,
|
|
558
|
+
partner_id: clients[0].id,
|
|
559
|
+
amount: 10,
|
|
560
|
+
},
|
|
561
|
+
],
|
|
562
|
+
});
|
|
563
|
+
(0, globals_1.expect)(financialEntry).toBeTruthy();
|
|
564
|
+
(0, globals_1.expect)(financialEntry).toHaveProperty('journal_id', journal.id);
|
|
565
|
+
}));
|
|
@@ -80,7 +80,7 @@ let consumer;
|
|
|
80
80
|
(0, globals_1.test)('getConsumersByName', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
81
|
const consumersWithName = yield client.Consumers.getConsumersByName(consumerName);
|
|
82
82
|
(0, globals_1.expect)(consumersWithName).toBeInstanceOf(Array);
|
|
83
|
-
(0, globals_1.expect)(consumersWithName
|
|
83
|
+
(0, globals_1.expect)(consumersWithName.some((consumer) => consumer.name.includes(consumerName))).toBe(true);
|
|
84
84
|
}));
|
|
85
85
|
(0, globals_1.test)('getConsumerById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
86
|
const consumerWithId = yield client.Consumers.getConsumerById(consumer.consumerId);
|
|
@@ -61,8 +61,8 @@ let lightspeedConsumer;
|
|
|
61
61
|
let orders;
|
|
62
62
|
(0, globals_1.test)('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
63
|
orders = yield lightspeedConsumer.pos.getOrders({
|
|
64
|
-
date_from: '
|
|
65
|
-
date_to: '
|
|
64
|
+
date_from: '2023-01-11',
|
|
65
|
+
date_to: '2023-02-28',
|
|
66
66
|
});
|
|
67
67
|
(0, globals_1.expect)(orders).toBeInstanceOf(Array);
|
|
68
68
|
(0, globals_1.expect)(orders.length).toBeGreaterThan(0);
|
|
@@ -142,8 +142,8 @@ globals_1.test.skip('getCustomer', () => __awaiter(void 0, void 0, void 0, funct
|
|
|
142
142
|
}));
|
|
143
143
|
(0, globals_1.test)('getPayments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
144
|
const payments = yield lightspeedConsumer.pos.getPayments({
|
|
145
|
-
date_from: '
|
|
146
|
-
date_to: '
|
|
145
|
+
date_from: '2023-01-11',
|
|
146
|
+
date_to: '2023-02-28',
|
|
147
147
|
});
|
|
148
148
|
(0, globals_1.expect)(payments).toBeInstanceOf(Array);
|
|
149
149
|
(0, globals_1.expect)(payments.length).toBeGreaterThan(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chift/chift-nodejs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
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",
|
|
@@ -357,10 +357,13 @@ const accountingFactory = {
|
|
|
357
357
|
url: '/consumers/{consumer_id}/accounting/outstandings',
|
|
358
358
|
};
|
|
359
359
|
},
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
/**
|
|
361
|
+
* @deprecated replaced by createFinancialEntry
|
|
362
|
+
*/
|
|
363
|
+
createFinancialEntryOld(
|
|
364
|
+
financial_entry: components['schemas']['FinancialEntryItemInOld'],
|
|
362
365
|
params: operations['accounting_create_financial_entry']['parameters']['query']
|
|
363
|
-
): RequestData<components['schemas']['
|
|
366
|
+
): RequestData<components['schemas']['FinancialEntryItemOutOld']> {
|
|
364
367
|
return {
|
|
365
368
|
params,
|
|
366
369
|
method: 'post',
|
|
@@ -368,6 +371,17 @@ const accountingFactory = {
|
|
|
368
371
|
body: financial_entry,
|
|
369
372
|
};
|
|
370
373
|
},
|
|
374
|
+
createFinancialEntry(
|
|
375
|
+
financial_entry: components['schemas']['FinancialEntryItemIn'],
|
|
376
|
+
params: operations['accounting_create_financial_entries']['parameters']['query']
|
|
377
|
+
): RequestData<components['schemas']['FinancialEntryItemOut'][]> {
|
|
378
|
+
return {
|
|
379
|
+
params,
|
|
380
|
+
method: 'post',
|
|
381
|
+
url: '/consumers/{consumer_id}/accounting/financial-entries',
|
|
382
|
+
body: financial_entry,
|
|
383
|
+
};
|
|
384
|
+
},
|
|
371
385
|
createJournalEntry(
|
|
372
386
|
journal_entry: components['schemas']['JournalEntryIn']
|
|
373
387
|
): RequestData<components['schemas']['JournalEntryMultiAnalyticPlan']> {
|