@chift/chift-nodejs 1.0.0 → 1.0.2
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/.eslintcache +1 -0
- package/CHANGELOG.md +13 -2
- package/coverage/clover.xml +1645 -0
- package/coverage/coverage-final.json +19 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +146 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/helpers/index.html +131 -0
- package/coverage/lcov-report/src/helpers/openapi.ts.html +151 -0
- package/coverage/lcov-report/src/helpers/settings.ts.html +94 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/index.ts.html +88 -0
- package/coverage/lcov-report/src/modules/accounting.ts.html +1156 -0
- package/coverage/lcov-report/src/modules/api.ts.html +190 -0
- package/coverage/lcov-report/src/modules/consumer.ts.html +616 -0
- package/coverage/lcov-report/src/modules/consumers.ts.html +331 -0
- package/coverage/lcov-report/src/modules/custom.ts.html +193 -0
- package/coverage/lcov-report/src/modules/datastores.ts.html +142 -0
- package/coverage/lcov-report/src/modules/ecommerce.ts.html +331 -0
- package/coverage/lcov-report/src/modules/flow.ts.html +589 -0
- package/coverage/lcov-report/src/modules/index.html +326 -0
- package/coverage/lcov-report/src/modules/integrations.ts.html +151 -0
- package/coverage/lcov-report/src/modules/internalApi.ts.html +586 -0
- package/coverage/lcov-report/src/modules/invoicing.ts.html +391 -0
- package/coverage/lcov-report/src/modules/pos.ts.html +421 -0
- package/coverage/lcov-report/src/modules/sync.ts.html +316 -0
- package/coverage/lcov-report/src/modules/syncs.ts.html +169 -0
- package/coverage/lcov-report/src/modules/webhooks.ts.html +343 -0
- package/coverage/lcov.info +1976 -0
- package/dist/src/modules/sync.js +2 -0
- package/dist/test/modules/flow.test.d.ts +1 -0
- package/dist/test/modules/flow.test.js +69 -0
- package/dist/test/modules/pos.test.js +4 -4
- package/package.json +1 -1
- package/src/modules/accounting.ts +26 -1
- package/src/types/public-api/schema.d.ts +218 -5
- package/test/modules/accounting.test.ts +117 -16
- package/test/modules/consumers.test.ts +3 -1
|
@@ -40,6 +40,19 @@ test('getJournals', async () => {
|
|
|
40
40
|
expect(journals[0]).toHaveProperty('journal_type', expect.any(String));
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
let vatCodes: components['schemas']['app__routers__accounting__VatCode'][];
|
|
44
|
+
test('getVatCodes', async () => {
|
|
45
|
+
vatCodes = await consumer.accounting.getVatCodes();
|
|
46
|
+
expect(vatCodes).toBeInstanceOf(Array);
|
|
47
|
+
expect(vatCodes.length).toBeGreaterThan(0);
|
|
48
|
+
expect(vatCodes[0]).toHaveProperty('id', expect.any(String));
|
|
49
|
+
expect(vatCodes[0]).toHaveProperty('code');
|
|
50
|
+
expect(vatCodes[0]).toHaveProperty('label', expect.any(String));
|
|
51
|
+
expect(vatCodes[0]).toHaveProperty('scope', expect.any(String));
|
|
52
|
+
expect(vatCodes[0]).toHaveProperty('rate', expect.any(Number));
|
|
53
|
+
expect(vatCodes[0]).toHaveProperty('type', expect.any(String));
|
|
54
|
+
});
|
|
55
|
+
|
|
43
56
|
test('createClient', async () => {
|
|
44
57
|
const body: components['schemas']['ClientItemIn'] = {
|
|
45
58
|
external_reference: 'sdk test',
|
|
@@ -164,6 +177,16 @@ test('updateSupplier', async () => {
|
|
|
164
177
|
});
|
|
165
178
|
|
|
166
179
|
test('createInvoice', async () => {
|
|
180
|
+
const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
|
|
181
|
+
if (!journal) {
|
|
182
|
+
throw new Error('No journal with type "customer_invoice" found to create invoice');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const vatCode = vatCodes.find((vatCode) => vatCode.type === 'sale' && vatCode.rate === 21);
|
|
186
|
+
if (!vatCode?.id) {
|
|
187
|
+
throw new Error('No vat code with type "sale" and rate 21 found to create invoice');
|
|
188
|
+
}
|
|
189
|
+
|
|
167
190
|
const body: components['schemas']['InvoiceItemInMonoAnalyticPlan'] = {
|
|
168
191
|
invoice_type: 'customer_invoice',
|
|
169
192
|
invoice_date: '2022-12-01',
|
|
@@ -173,7 +196,7 @@ test('createInvoice', async () => {
|
|
|
173
196
|
tax_amount: 21,
|
|
174
197
|
total: 121,
|
|
175
198
|
partner_id: clients[0]?.id as string,
|
|
176
|
-
journal_id:
|
|
199
|
+
journal_id: journal.id,
|
|
177
200
|
lines: [
|
|
178
201
|
{
|
|
179
202
|
description: 'Test',
|
|
@@ -184,7 +207,7 @@ test('createInvoice', async () => {
|
|
|
184
207
|
tax_amount: 21,
|
|
185
208
|
total: 121,
|
|
186
209
|
account_number: '700000',
|
|
187
|
-
tax_code:
|
|
210
|
+
tax_code: vatCode.id,
|
|
188
211
|
},
|
|
189
212
|
],
|
|
190
213
|
};
|
|
@@ -243,6 +266,18 @@ test('getInvoice', async () => {
|
|
|
243
266
|
});
|
|
244
267
|
|
|
245
268
|
test('createInvoiceWithMultiplePlans', async () => {
|
|
269
|
+
const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
|
|
270
|
+
if (!journal) {
|
|
271
|
+
throw new Error(
|
|
272
|
+
'No journal with type customer_invoice found to create Invoice With Multiple Plans'
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const vatCode = vatCodes.find((vatCode) => vatCode.type === 'sale' && vatCode.rate === 21);
|
|
277
|
+
if (!vatCode?.id) {
|
|
278
|
+
throw new Error('No vat code with type "sale" and rate 21 found to create invoice');
|
|
279
|
+
}
|
|
280
|
+
|
|
246
281
|
const body: components['schemas']['InvoiceItemInMonoAnalyticPlan'] = {
|
|
247
282
|
invoice_type: 'customer_invoice',
|
|
248
283
|
invoice_date: '2022-12-01',
|
|
@@ -252,7 +287,7 @@ test('createInvoiceWithMultiplePlans', async () => {
|
|
|
252
287
|
tax_amount: 21,
|
|
253
288
|
total: 121,
|
|
254
289
|
partner_id: clients[0]?.id as string,
|
|
255
|
-
journal_id:
|
|
290
|
+
journal_id: journal.id,
|
|
256
291
|
lines: [
|
|
257
292
|
{
|
|
258
293
|
description: 'Test',
|
|
@@ -263,7 +298,7 @@ test('createInvoiceWithMultiplePlans', async () => {
|
|
|
263
298
|
tax_amount: 21,
|
|
264
299
|
total: 121,
|
|
265
300
|
account_number: '700000',
|
|
266
|
-
tax_code:
|
|
301
|
+
tax_code: vatCode.id,
|
|
267
302
|
},
|
|
268
303
|
],
|
|
269
304
|
};
|
|
@@ -374,6 +409,35 @@ test('getAnalyticLinesOfAccount', async () => {
|
|
|
374
409
|
}
|
|
375
410
|
});
|
|
376
411
|
|
|
412
|
+
test('createJournalEntry', async () => {
|
|
413
|
+
const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
|
|
414
|
+
if (!journal) {
|
|
415
|
+
throw new Error('No journal with type "customer_invoice" found to create journal entry');
|
|
416
|
+
}
|
|
417
|
+
const journalEntry = await consumer.accounting.createJournalEntry({
|
|
418
|
+
journal_id: journal.id,
|
|
419
|
+
name: Date.now().toString(),
|
|
420
|
+
date: '2022-01-01',
|
|
421
|
+
items: [
|
|
422
|
+
{
|
|
423
|
+
account_number: clients[0].account_number,
|
|
424
|
+
credit: 0,
|
|
425
|
+
debit: 10,
|
|
426
|
+
partner_id: clients[0].id,
|
|
427
|
+
currency: 'EUR',
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
account_number: '700000',
|
|
431
|
+
credit: 10,
|
|
432
|
+
debit: 0,
|
|
433
|
+
currency: 'EUR',
|
|
434
|
+
},
|
|
435
|
+
],
|
|
436
|
+
});
|
|
437
|
+
expect(journalEntry).toBeTruthy();
|
|
438
|
+
expect(journalEntry).toHaveProperty('journal_id', journal.id);
|
|
439
|
+
});
|
|
440
|
+
|
|
377
441
|
test('getJournalEntries', async () => {
|
|
378
442
|
const journalEntries = await consumer.accounting.getJournalEntries({
|
|
379
443
|
unposted_allowed: true,
|
|
@@ -399,18 +463,6 @@ test('getPaymentsByInvoiceId', async () => {
|
|
|
399
463
|
expect(payments).toBeInstanceOf(Array);
|
|
400
464
|
});
|
|
401
465
|
|
|
402
|
-
test('getVatCodes', async () => {
|
|
403
|
-
const vatCodes = await consumer.accounting.getVatCodes();
|
|
404
|
-
expect(vatCodes).toBeInstanceOf(Array);
|
|
405
|
-
expect(vatCodes.length).toBeGreaterThan(0);
|
|
406
|
-
expect(vatCodes[0]).toHaveProperty('id', expect.any(String));
|
|
407
|
-
expect(vatCodes[0]).toHaveProperty('code');
|
|
408
|
-
expect(vatCodes[0]).toHaveProperty('label', expect.any(String));
|
|
409
|
-
expect(vatCodes[0]).toHaveProperty('scope', expect.any(String));
|
|
410
|
-
expect(vatCodes[0]).toHaveProperty('rate', expect.any(Number));
|
|
411
|
-
expect(vatCodes[0]).toHaveProperty('type', expect.any(String));
|
|
412
|
-
});
|
|
413
|
-
|
|
414
466
|
let miscOperations: components['schemas']['MiscellaneousOperationOut'][];
|
|
415
467
|
test('getMiscOperations', async () => {
|
|
416
468
|
miscOperations = await consumer.accounting.getMiscOperations();
|
|
@@ -481,3 +533,52 @@ test('getBalanceOfAccounts', async () => {
|
|
|
481
533
|
expect(balanceOfAccounts).toHaveProperty('items');
|
|
482
534
|
expect(balanceOfAccounts.items).toBeInstanceOf(Array);
|
|
483
535
|
});
|
|
536
|
+
|
|
537
|
+
test('getEmployees', async () => {
|
|
538
|
+
const employees = await consumer.accounting.getEmployees();
|
|
539
|
+
expect(employees).toBeTruthy();
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
test('getOutstandings', async () => {
|
|
543
|
+
expect.assertions(1);
|
|
544
|
+
try {
|
|
545
|
+
const outstandings = await consumer.accounting.getOutstandings({
|
|
546
|
+
type: 'client',
|
|
547
|
+
unposted_allowed: true,
|
|
548
|
+
});
|
|
549
|
+
expect(outstandings).toBeTruthy();
|
|
550
|
+
expect(outstandings.items).toBeInstanceOf(Array);
|
|
551
|
+
} catch (e: any) {
|
|
552
|
+
if (e?.error?.error_code) {
|
|
553
|
+
expect(e.error.error_code).toMatch('ERROR_API_RESOURCE_NOT_FOUND');
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
throw e;
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
test('createFinancialEntry', async () => {
|
|
562
|
+
const journal = journals.find((journal) => journal.journal_type === 'financial_operation');
|
|
563
|
+
if (!journal) {
|
|
564
|
+
throw new Error(
|
|
565
|
+
'No journal with type "financial_operation" found to create financial entry'
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
const financialEntry = await consumer.accounting.createFinancialEntry({
|
|
570
|
+
date: '2022-01-01',
|
|
571
|
+
journal_id: journal.id,
|
|
572
|
+
currency: 'EUR',
|
|
573
|
+
items: [
|
|
574
|
+
{
|
|
575
|
+
type: 'customer_account',
|
|
576
|
+
account_number: clients[0].account_number,
|
|
577
|
+
partner_id: clients[0].id,
|
|
578
|
+
amount: 10,
|
|
579
|
+
},
|
|
580
|
+
],
|
|
581
|
+
});
|
|
582
|
+
expect(financialEntry).toBeTruthy();
|
|
583
|
+
expect(financialEntry).toHaveProperty('journal_id', journal.id);
|
|
584
|
+
});
|
|
@@ -51,7 +51,9 @@ test('getConsumers', async () => {
|
|
|
51
51
|
test('getConsumersByName', async () => {
|
|
52
52
|
const consumersWithName = await client.Consumers.getConsumersByName(consumerName);
|
|
53
53
|
expect(consumersWithName).toBeInstanceOf(Array);
|
|
54
|
-
expect(consumersWithName
|
|
54
|
+
expect(consumersWithName.some((consumer: any) => consumer.name.includes(consumerName))).toBe(
|
|
55
|
+
true
|
|
56
|
+
);
|
|
55
57
|
});
|
|
56
58
|
|
|
57
59
|
test('getConsumerById', async () => {
|