@chift/chift-nodejs 1.0.16 → 1.0.18
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/README.md +3 -3
- package/package.json +5 -2
- package/src/types/public-api/schema.d.ts +4071 -850
- package/src/types/sync.ts +20 -5
- package/.eslintcache +0 -1
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -25
- package/.github/workflows/ci.yml +0 -75
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -1
- package/.prettierrc.json +0 -7
- package/CHANGELOG.md +0 -98
- 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/src/helpers/openapi.d.ts +0 -3
- package/dist/src/helpers/openapi.js +0 -18
- package/dist/src/helpers/settings.d.ts +0 -4
- package/dist/src/helpers/settings.js +0 -5
- package/dist/src/index.d.ts +0 -1
- package/dist/src/modules/accounting.d.ts +0 -68
- package/dist/src/modules/accounting.js +0 -326
- package/dist/src/modules/api.d.ts +0 -16795
- package/dist/src/modules/api.js +0 -36
- package/dist/src/modules/consumer.d.ts +0 -3313
- package/dist/src/modules/consumer.js +0 -139
- package/dist/src/modules/consumers.d.ts +0 -16684
- package/dist/src/modules/consumers.js +0 -51
- package/dist/src/modules/custom.d.ts +0 -8
- package/dist/src/modules/custom.js +0 -36
- package/dist/src/modules/datastores.d.ts +0 -18
- package/dist/src/modules/datastores.js +0 -23
- package/dist/src/modules/ecommerce.d.ts +0 -24
- package/dist/src/modules/ecommerce.js +0 -97
- package/dist/src/modules/flow.d.ts +0 -15
- package/dist/src/modules/flow.js +0 -156
- package/dist/src/modules/integrations.d.ts +0 -23
- package/dist/src/modules/integrations.js +0 -23
- package/dist/src/modules/internalApi.d.ts +0 -24
- package/dist/src/modules/internalApi.js +0 -175
- package/dist/src/modules/invoicing.d.ts +0 -20
- package/dist/src/modules/invoicing.js +0 -90
- package/dist/src/modules/pms.d.ts +0 -15
- package/dist/src/modules/pms.js +0 -47
- package/dist/src/modules/pos.d.ts +0 -26
- package/dist/src/modules/pos.js +0 -101
- package/dist/src/modules/sync.d.ts +0 -13414
- package/dist/src/modules/sync.js +0 -73
- package/dist/src/modules/syncs.d.ts +0 -11
- package/dist/src/modules/syncs.js +0 -39
- package/dist/src/modules/webhooks.d.ts +0 -55
- package/dist/src/modules/webhooks.js +0 -53
- package/dist/src/types/api.d.ts +0 -29
- package/dist/src/types/api.js +0 -2
- package/dist/src/types/consumers.d.ts +0 -8
- package/dist/src/types/consumers.js +0 -2
- package/dist/src/types/public-api/mappings.d.ts +0 -21
- package/dist/src/types/public-api/mappings.js +0 -2
- package/dist/src/types/public-api/schema.d.ts +0 -12003
- package/dist/src/types/public-api/schema.js +0 -6
- package/dist/src/types/sync.d.ts +0 -20
- package/dist/src/types/sync.js +0 -2
- package/dist/test/modules/accounting.test.d.ts +0 -1
- package/dist/test/modules/accounting.test.js +0 -582
- package/dist/test/modules/consumer.test.d.ts +0 -1
- package/dist/test/modules/consumer.test.js +0 -89
- package/dist/test/modules/consumers.test.d.ts +0 -1
- package/dist/test/modules/consumers.test.js +0 -109
- package/dist/test/modules/ecommerce.test.d.ts +0 -1
- package/dist/test/modules/ecommerce.test.js +0 -220
- package/dist/test/modules/integrations.test.d.ts +0 -1
- package/dist/test/modules/integrations.test.js +0 -54
- package/dist/test/modules/invoicing.test.d.ts +0 -1
- package/dist/test/modules/invoicing.test.js +0 -108
- package/dist/test/modules/pos.test.d.ts +0 -1
- package/dist/test/modules/pos.test.js +0 -182
- package/dist/test/modules/sync.test.d.ts +0 -1
- package/dist/test/modules/sync.test.js +0 -81
- package/dist/test/modules/syncs.test.d.ts +0 -1
- package/dist/test/modules/syncs.test.js +0 -53
- package/dist/test/modules/webhooks.test.d.ts +0 -1
- package/dist/test/modules/webhooks.test.js +0 -120
- package/jest.config.ts +0 -195
- package/src/helpers/openapi.ts +0 -22
- package/src/helpers/settings.ts +0 -3
- package/src/index.ts +0 -1
- package/src/modules/accounting.ts +0 -510
- package/src/modules/api.ts +0 -35
- package/src/modules/consumer.ts +0 -213
- package/src/modules/consumers.ts +0 -82
- package/src/modules/custom.ts +0 -36
- package/src/modules/datastores.ts +0 -19
- package/src/modules/ecommerce.ts +0 -127
- package/src/modules/flow.ts +0 -168
- package/src/modules/integrations.ts +0 -24
- package/src/modules/internalApi.ts +0 -182
- package/src/modules/invoicing.ts +0 -114
- package/src/modules/pms.ts +0 -67
- package/src/modules/pos.ts +0 -144
- package/src/modules/sync.ts +0 -77
- package/src/modules/syncs.ts +0 -59
- package/src/modules/webhooks.ts +0 -86
- package/src/types/public-api/schema.ts +0 -12073
- package/test/data/accounting_invoice.pdf +0 -0
- package/test/modules/accounting.test.ts +0 -628
- package/test/modules/consumer.test.ts +0 -68
- package/test/modules/consumers.test.ts +0 -85
- package/test/modules/ecommerce.test.ts +0 -208
- package/test/modules/integrations.test.ts +0 -22
- package/test/modules/invoicing.test.ts +0 -88
- package/test/modules/pos.test.ts +0 -166
- package/test/modules/sync.test.ts +0 -60
- package/test/modules/syncs.test.ts +0 -23
- package/test/modules/webhooks.test.ts +0 -92
- package/test/set_envs.sh +0 -14
- package/tsconfig.json +0 -107
package/dist/src/types/sync.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface TriggerType {
|
|
2
|
-
type: 'timer' | 'event';
|
|
3
|
-
data?: any;
|
|
4
|
-
}
|
|
5
|
-
export interface ExecutionType {
|
|
6
|
-
type: 'code' | 'module';
|
|
7
|
-
data?: any;
|
|
8
|
-
}
|
|
9
|
-
export interface ContextType {
|
|
10
|
-
name: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
trigger: TriggerType;
|
|
13
|
-
execution: ExecutionType;
|
|
14
|
-
config?: any;
|
|
15
|
-
}
|
|
16
|
-
export interface SimpleResponseModel {
|
|
17
|
-
status: string;
|
|
18
|
-
message: string;
|
|
19
|
-
data?: any;
|
|
20
|
-
}
|
package/dist/src/types/sync.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,582 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const globals_1 = require("@jest/globals");
|
|
39
|
-
const chift = __importStar(require("../../src/index"));
|
|
40
|
-
const dotenv = __importStar(require("dotenv"));
|
|
41
|
-
const fs_1 = __importDefault(require("fs"));
|
|
42
|
-
dotenv.config();
|
|
43
|
-
const client = new chift.API({
|
|
44
|
-
baseUrl: process.env.CHIFT_BASE_URL,
|
|
45
|
-
clientId: process.env.CHIFT_CLIENT_ID,
|
|
46
|
-
clientSecret: process.env.CHIFT_CLIENT_SECRET,
|
|
47
|
-
accountId: process.env.CHIFT_ACCOUNT_ID,
|
|
48
|
-
});
|
|
49
|
-
const consumerId = process.env.CHIFT_ODOO_CONSUMER_ID;
|
|
50
|
-
let consumer;
|
|
51
|
-
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
consumer = yield client.Consumers.getConsumerById(consumerId);
|
|
53
|
-
}));
|
|
54
|
-
let analyticPlans;
|
|
55
|
-
(0, globals_1.test)('getAnalyticPlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
analyticPlans = yield consumer.accounting.getAnalyticPlans();
|
|
57
|
-
(0, globals_1.expect)(analyticPlans).toBeInstanceOf(Array);
|
|
58
|
-
(0, globals_1.expect)(analyticPlans.length).toBeGreaterThan(0);
|
|
59
|
-
(0, globals_1.expect)(analyticPlans[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
60
|
-
(0, globals_1.expect)(analyticPlans[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
61
|
-
(0, globals_1.expect)(analyticPlans[0]).toHaveProperty('active', globals_1.expect.any(Boolean));
|
|
62
|
-
}));
|
|
63
|
-
let journals;
|
|
64
|
-
(0, globals_1.test)('getJournals', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
-
journals = yield consumer.accounting.getJournals();
|
|
66
|
-
(0, globals_1.expect)(journals).toBeInstanceOf(Array);
|
|
67
|
-
(0, globals_1.expect)(journals.length).toBeGreaterThan(0);
|
|
68
|
-
(0, globals_1.expect)(journals[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
69
|
-
(0, globals_1.expect)(journals[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
70
|
-
(0, globals_1.expect)(journals[0]).toHaveProperty('journal_type', globals_1.expect.any(String));
|
|
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
|
-
}));
|
|
84
|
-
(0, globals_1.test)('createClient', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
-
const body = {
|
|
86
|
-
external_reference: 'sdk test',
|
|
87
|
-
name: 'John Doe',
|
|
88
|
-
currency: 'EUR',
|
|
89
|
-
active: false,
|
|
90
|
-
addresses: [
|
|
91
|
-
{
|
|
92
|
-
address_type: 'main',
|
|
93
|
-
street: 'Main Street',
|
|
94
|
-
city: 'Brussels',
|
|
95
|
-
postal_code: '1000',
|
|
96
|
-
country: 'BE',
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
};
|
|
100
|
-
const client = yield consumer.accounting.createClient(body);
|
|
101
|
-
(0, globals_1.expect)(client).toBeTruthy();
|
|
102
|
-
(0, globals_1.expect)(client).toHaveProperty('name', 'John Doe');
|
|
103
|
-
}));
|
|
104
|
-
let clients;
|
|
105
|
-
(0, globals_1.test)('getClients', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
clients = yield consumer.accounting.getClients();
|
|
107
|
-
(0, globals_1.expect)(clients).toBeInstanceOf(Array);
|
|
108
|
-
(0, globals_1.expect)(clients.length).toBeGreaterThan(0);
|
|
109
|
-
(0, globals_1.expect)(clients[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
110
|
-
}));
|
|
111
|
-
(0, globals_1.test)('getClient', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
-
const client = yield consumer.accounting.getClient(clients[0].id);
|
|
113
|
-
(0, globals_1.expect)(client).toBeTruthy();
|
|
114
|
-
(0, globals_1.expect)(client).toHaveProperty('external_reference');
|
|
115
|
-
(0, globals_1.expect)(client).toHaveProperty('first_name');
|
|
116
|
-
(0, globals_1.expect)(client).toHaveProperty('last_name');
|
|
117
|
-
(0, globals_1.expect)(client).toHaveProperty('name');
|
|
118
|
-
(0, globals_1.expect)(client).toHaveProperty('function');
|
|
119
|
-
(0, globals_1.expect)(client).toHaveProperty('is_company');
|
|
120
|
-
(0, globals_1.expect)(client).toHaveProperty('company_id');
|
|
121
|
-
(0, globals_1.expect)(client).toHaveProperty('phone');
|
|
122
|
-
(0, globals_1.expect)(client).toHaveProperty('mobile');
|
|
123
|
-
(0, globals_1.expect)(client).toHaveProperty('email');
|
|
124
|
-
(0, globals_1.expect)(client).toHaveProperty('language');
|
|
125
|
-
(0, globals_1.expect)(client).toHaveProperty('internal_notes');
|
|
126
|
-
(0, globals_1.expect)(client).toHaveProperty('website');
|
|
127
|
-
(0, globals_1.expect)(client).toHaveProperty('vat');
|
|
128
|
-
(0, globals_1.expect)(client).toHaveProperty('iban');
|
|
129
|
-
(0, globals_1.expect)(client).toHaveProperty('bank_account');
|
|
130
|
-
(0, globals_1.expect)(client).toHaveProperty('currency');
|
|
131
|
-
(0, globals_1.expect)(client).toHaveProperty('active', globals_1.expect.any(Boolean));
|
|
132
|
-
(0, globals_1.expect)(client).toHaveProperty('addresses', globals_1.expect.any(Array));
|
|
133
|
-
}));
|
|
134
|
-
(0, globals_1.test)('updateClient', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
-
const client = clients.find((client) => client.external_reference === 'sdk test');
|
|
136
|
-
const updatedClient = yield consumer.accounting.updateClient(client === null || client === void 0 ? void 0 : client.id, {
|
|
137
|
-
name: 'John Updated Doe',
|
|
138
|
-
});
|
|
139
|
-
(0, globals_1.expect)(updatedClient).toBeTruthy();
|
|
140
|
-
(0, globals_1.expect)(updatedClient).toHaveProperty('name', 'John Updated Doe');
|
|
141
|
-
}));
|
|
142
|
-
(0, globals_1.test)('createSupplier', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
|
-
const body = {
|
|
144
|
-
external_reference: 'sdk test',
|
|
145
|
-
name: 'Jane Doe',
|
|
146
|
-
currency: 'EUR',
|
|
147
|
-
active: false,
|
|
148
|
-
addresses: [
|
|
149
|
-
{
|
|
150
|
-
address_type: 'main',
|
|
151
|
-
street: 'Main Street',
|
|
152
|
-
city: 'Brussels',
|
|
153
|
-
postal_code: '1000',
|
|
154
|
-
country: 'BE',
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
};
|
|
158
|
-
const supplier = yield consumer.accounting.createSupplier(body);
|
|
159
|
-
(0, globals_1.expect)(supplier).toBeTruthy();
|
|
160
|
-
(0, globals_1.expect)(supplier).toHaveProperty('name', 'Jane Doe');
|
|
161
|
-
}));
|
|
162
|
-
let suppliers;
|
|
163
|
-
(0, globals_1.test)('getSuppliers', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
-
suppliers = yield consumer.accounting.getSuppliers();
|
|
165
|
-
(0, globals_1.expect)(suppliers).toBeInstanceOf(Array);
|
|
166
|
-
(0, globals_1.expect)(suppliers.length).toBeGreaterThan(0);
|
|
167
|
-
}));
|
|
168
|
-
(0, globals_1.test)('getSupplier', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
169
|
-
const supplier = yield consumer.accounting.getSupplier(suppliers[0].id);
|
|
170
|
-
(0, globals_1.expect)(supplier).toBeTruthy();
|
|
171
|
-
(0, globals_1.expect)(supplier).toHaveProperty('external_reference');
|
|
172
|
-
(0, globals_1.expect)(supplier).toHaveProperty('first_name');
|
|
173
|
-
(0, globals_1.expect)(supplier).toHaveProperty('last_name');
|
|
174
|
-
(0, globals_1.expect)(supplier).toHaveProperty('name');
|
|
175
|
-
(0, globals_1.expect)(supplier).toHaveProperty('function');
|
|
176
|
-
(0, globals_1.expect)(supplier).toHaveProperty('is_company');
|
|
177
|
-
(0, globals_1.expect)(supplier).toHaveProperty('company_id');
|
|
178
|
-
(0, globals_1.expect)(supplier).toHaveProperty('phone');
|
|
179
|
-
(0, globals_1.expect)(supplier).toHaveProperty('mobile');
|
|
180
|
-
(0, globals_1.expect)(supplier).toHaveProperty('email');
|
|
181
|
-
(0, globals_1.expect)(supplier).toHaveProperty('language');
|
|
182
|
-
(0, globals_1.expect)(supplier).toHaveProperty('internal_notes');
|
|
183
|
-
(0, globals_1.expect)(supplier).toHaveProperty('website');
|
|
184
|
-
(0, globals_1.expect)(supplier).toHaveProperty('vat');
|
|
185
|
-
(0, globals_1.expect)(supplier).toHaveProperty('iban');
|
|
186
|
-
(0, globals_1.expect)(supplier).toHaveProperty('bank_account');
|
|
187
|
-
(0, globals_1.expect)(supplier).toHaveProperty('currency');
|
|
188
|
-
(0, globals_1.expect)(supplier).toHaveProperty('active', globals_1.expect.any(Boolean));
|
|
189
|
-
(0, globals_1.expect)(supplier).toHaveProperty('addresses', globals_1.expect.any(Array));
|
|
190
|
-
}));
|
|
191
|
-
(0, globals_1.test)('updateSupplier', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
192
|
-
const supplier = suppliers.find((supplier) => supplier.external_reference === 'sdk test');
|
|
193
|
-
const updatedSupplier = yield consumer.accounting.updateSupplier(supplier === null || supplier === void 0 ? void 0 : supplier.id, {
|
|
194
|
-
name: 'Jane Updated Doe',
|
|
195
|
-
});
|
|
196
|
-
(0, globals_1.expect)(updatedSupplier).toBeTruthy();
|
|
197
|
-
(0, globals_1.expect)(updatedSupplier).toHaveProperty('name', 'Jane Updated Doe');
|
|
198
|
-
}));
|
|
199
|
-
(0, globals_1.test)('createInvoice', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
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
|
-
}
|
|
209
|
-
const body = {
|
|
210
|
-
invoice_type: 'customer_invoice',
|
|
211
|
-
invoice_date: '2022-12-01',
|
|
212
|
-
due_date: '2022-12-31',
|
|
213
|
-
currency: 'EUR',
|
|
214
|
-
untaxed_amount: 100,
|
|
215
|
-
tax_amount: 21,
|
|
216
|
-
total: 121,
|
|
217
|
-
partner_id: (_a = clients[0]) === null || _a === void 0 ? void 0 : _a.id,
|
|
218
|
-
journal_id: journal.id,
|
|
219
|
-
lines: [
|
|
220
|
-
{
|
|
221
|
-
description: 'Test',
|
|
222
|
-
unit_price: 100,
|
|
223
|
-
quantity: 1,
|
|
224
|
-
untaxed_amount: 100,
|
|
225
|
-
tax_rate: 21,
|
|
226
|
-
tax_amount: 21,
|
|
227
|
-
total: 121,
|
|
228
|
-
account_number: '700000',
|
|
229
|
-
tax_code: vatCode.id,
|
|
230
|
-
},
|
|
231
|
-
],
|
|
232
|
-
};
|
|
233
|
-
const invoice = yield consumer.accounting.createInvoice(body);
|
|
234
|
-
(0, globals_1.expect)(invoice).toBeTruthy();
|
|
235
|
-
(0, globals_1.expect)(invoice).toHaveProperty('total', 121);
|
|
236
|
-
}));
|
|
237
|
-
let invoices;
|
|
238
|
-
(0, globals_1.test)('getInvoicesByType', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
239
|
-
invoices = yield consumer.accounting.getInvoicesByType('customer_invoice', {
|
|
240
|
-
date_from: '2022-12-01',
|
|
241
|
-
date_to: '2022-12-31',
|
|
242
|
-
});
|
|
243
|
-
(0, globals_1.expect)(invoices).toBeInstanceOf(Array);
|
|
244
|
-
(0, globals_1.expect)(invoices.length).toBeGreaterThan(0);
|
|
245
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
246
|
-
}));
|
|
247
|
-
(0, globals_1.test)('getInvoicesByTypeWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
248
|
-
const invoicesWithMultiplePlans = yield consumer.accounting.getInvoicesByTypeWithMultiplePlans('customer_invoice', {
|
|
249
|
-
date_from: '2022-12-01',
|
|
250
|
-
date_to: '2022-12-31',
|
|
251
|
-
});
|
|
252
|
-
(0, globals_1.expect)(invoicesWithMultiplePlans).toBeInstanceOf(Array);
|
|
253
|
-
(0, globals_1.expect)(invoicesWithMultiplePlans.length).toBeGreaterThan(0);
|
|
254
|
-
(0, globals_1.expect)(invoicesWithMultiplePlans[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
255
|
-
}));
|
|
256
|
-
(0, globals_1.test)('getInvoice', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
257
|
-
const invoice = yield consumer.accounting.getInvoice(invoices[0].id, {
|
|
258
|
-
include_payments: true,
|
|
259
|
-
});
|
|
260
|
-
(0, globals_1.expect)(invoice).toBeTruthy();
|
|
261
|
-
(0, globals_1.expect)(invoice).toHaveProperty('id', invoices[0].id);
|
|
262
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('invoice_type', globals_1.expect.any(String));
|
|
263
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('invoice_number');
|
|
264
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('partner_id', globals_1.expect.any(String));
|
|
265
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('invoice_date', globals_1.expect.any(String));
|
|
266
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('due_date', globals_1.expect.any(String));
|
|
267
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('currency', globals_1.expect.any(String));
|
|
268
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('untaxed_amount', globals_1.expect.any(Number));
|
|
269
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('tax_amount', globals_1.expect.any(Number));
|
|
270
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('total', globals_1.expect.any(Number));
|
|
271
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('reference');
|
|
272
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('payment_communication');
|
|
273
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('customer_memo');
|
|
274
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('id');
|
|
275
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('journal_id', globals_1.expect.any(String));
|
|
276
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('payments');
|
|
277
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('status');
|
|
278
|
-
(0, globals_1.expect)(invoices[0]).toHaveProperty('lines', globals_1.expect.any(Array));
|
|
279
|
-
}));
|
|
280
|
-
(0, globals_1.test)('createInvoiceWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
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
|
-
}
|
|
290
|
-
const body = {
|
|
291
|
-
invoice_type: 'customer_invoice',
|
|
292
|
-
invoice_date: '2022-12-01',
|
|
293
|
-
due_date: '2022-12-31',
|
|
294
|
-
currency: 'EUR',
|
|
295
|
-
untaxed_amount: 100,
|
|
296
|
-
tax_amount: 21,
|
|
297
|
-
total: 121,
|
|
298
|
-
partner_id: (_b = clients[0]) === null || _b === void 0 ? void 0 : _b.id,
|
|
299
|
-
journal_id: journal.id,
|
|
300
|
-
lines: [
|
|
301
|
-
{
|
|
302
|
-
description: 'Test',
|
|
303
|
-
unit_price: 100,
|
|
304
|
-
quantity: 1,
|
|
305
|
-
untaxed_amount: 100,
|
|
306
|
-
tax_rate: 21,
|
|
307
|
-
tax_amount: 21,
|
|
308
|
-
total: 121,
|
|
309
|
-
account_number: '700000',
|
|
310
|
-
tax_code: vatCode.id,
|
|
311
|
-
},
|
|
312
|
-
],
|
|
313
|
-
};
|
|
314
|
-
const invoice = yield consumer.accounting.createInvoiceWithMultiplePlans(body);
|
|
315
|
-
(0, globals_1.expect)(invoice).toBeTruthy();
|
|
316
|
-
}));
|
|
317
|
-
(0, globals_1.test)('getInvoiceWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
318
|
-
const invoice = yield consumer.accounting.getInvoiceWithMultiplePlans(invoices[0].id, {
|
|
319
|
-
include_payments: true,
|
|
320
|
-
});
|
|
321
|
-
(0, globals_1.expect)(invoice).toBeTruthy();
|
|
322
|
-
}));
|
|
323
|
-
(0, globals_1.test)('createAnalyticAccount', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
324
|
-
const body = {
|
|
325
|
-
active: false,
|
|
326
|
-
code: '4000',
|
|
327
|
-
name: 'sdk test',
|
|
328
|
-
currency: 'EUR',
|
|
329
|
-
};
|
|
330
|
-
const analyticAccount = yield consumer.accounting.createAnalyticAccount(body);
|
|
331
|
-
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
332
|
-
(0, globals_1.expect)(analyticAccount).toHaveProperty('name', 'sdk test');
|
|
333
|
-
}));
|
|
334
|
-
let analyticAccounts;
|
|
335
|
-
(0, globals_1.test)('getAnalyticAccounts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
336
|
-
analyticAccounts = yield consumer.accounting.getAnalyticAccounts();
|
|
337
|
-
(0, globals_1.expect)(analyticAccounts).toBeInstanceOf(Array);
|
|
338
|
-
(0, globals_1.expect)(analyticAccounts.length).toBeGreaterThan(0);
|
|
339
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('active', globals_1.expect.any(Boolean));
|
|
340
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('code', globals_1.expect.any(String));
|
|
341
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
342
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('currency', globals_1.expect.any(String));
|
|
343
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
344
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('balance', globals_1.expect.any(Number));
|
|
345
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('debit', globals_1.expect.any(Number));
|
|
346
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('credit', globals_1.expect.any(Number));
|
|
347
|
-
}));
|
|
348
|
-
(0, globals_1.test)('createAnalyticAccountWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
349
|
-
const analyticAccount = yield consumer.accounting.createAnalyticAccountWithMultiplePlans(analyticPlans[0].id, {
|
|
350
|
-
code: '4000',
|
|
351
|
-
name: 'sdk test',
|
|
352
|
-
currency: 'EUR',
|
|
353
|
-
});
|
|
354
|
-
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
355
|
-
}));
|
|
356
|
-
(0, globals_1.test)('getAnalyticAccount', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
357
|
-
const analyticAccount = yield consumer.accounting.getAnalyticAccount(analyticAccounts[0].id);
|
|
358
|
-
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
359
|
-
}));
|
|
360
|
-
(0, globals_1.test)('updateAnalyticAccount', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
361
|
-
const testAnalyticAccount = analyticAccounts.find((account) => account.name === 'sdk test');
|
|
362
|
-
const analyticAccount = yield consumer.accounting.updateAnalyticAccount(testAnalyticAccount === null || testAnalyticAccount === void 0 ? void 0 : testAnalyticAccount.id, { name: 'test sdk update' });
|
|
363
|
-
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
364
|
-
(0, globals_1.expect)(analyticAccount).toHaveProperty('name', 'test sdk update');
|
|
365
|
-
}));
|
|
366
|
-
(0, globals_1.test)('getAnalyticAccountWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
367
|
-
const analyticAccount = yield consumer.accounting.getAnalyticAccountWithMultiplePlans(analyticAccounts[0].id, analyticPlans[0].id);
|
|
368
|
-
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
369
|
-
}));
|
|
370
|
-
(0, globals_1.test)('updateAnalyticAccountWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
371
|
-
const testAnalyticAccount = analyticAccounts.find((account) => account.name === 'test sdk update');
|
|
372
|
-
const analyticAccount = yield consumer.accounting.updateAnalyticAccountWithMultiplePlans(testAnalyticAccount === null || testAnalyticAccount === void 0 ? void 0 : testAnalyticAccount.id, '1', { name: 'test sdk update 2' });
|
|
373
|
-
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
374
|
-
(0, globals_1.expect)(analyticAccount).toHaveProperty('name', 'test sdk update 2');
|
|
375
|
-
}));
|
|
376
|
-
(0, globals_1.test)('getAnalyticAccountsWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
377
|
-
const analyticAccountsWithMultiplePlans = yield consumer.accounting.getAnalyticAccountsWithMultiplePlans();
|
|
378
|
-
(0, globals_1.expect)(analyticAccountsWithMultiplePlans).toBeInstanceOf(Array);
|
|
379
|
-
}));
|
|
380
|
-
(0, globals_1.test)('createJournalEntry', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
381
|
-
const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
|
|
382
|
-
if (!journal) {
|
|
383
|
-
throw new Error('No journal with type "customer_invoice" found to create journal entry');
|
|
384
|
-
}
|
|
385
|
-
const journalEntry = yield consumer.accounting.createJournalEntry({
|
|
386
|
-
journal_id: journal.id,
|
|
387
|
-
name: Date.now().toString(),
|
|
388
|
-
date: '2022-01-01',
|
|
389
|
-
items: [
|
|
390
|
-
{
|
|
391
|
-
account_number: clients[0].account_number,
|
|
392
|
-
credit: 0,
|
|
393
|
-
debit: 10,
|
|
394
|
-
partner_id: clients[0].id,
|
|
395
|
-
currency: 'EUR',
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
account_number: '700000',
|
|
399
|
-
credit: 10,
|
|
400
|
-
debit: 0,
|
|
401
|
-
currency: 'EUR',
|
|
402
|
-
},
|
|
403
|
-
],
|
|
404
|
-
});
|
|
405
|
-
(0, globals_1.expect)(journalEntry).toBeTruthy();
|
|
406
|
-
(0, globals_1.expect)(journalEntry).toHaveProperty('journal_id', journal.id);
|
|
407
|
-
}));
|
|
408
|
-
(0, globals_1.test)('getJournalEntries', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
409
|
-
const journalEntries = yield consumer.accounting.getJournalEntries({
|
|
410
|
-
unposted_allowed: true,
|
|
411
|
-
date_from: '2022-01-01',
|
|
412
|
-
date_to: '2022-01-31',
|
|
413
|
-
journal_id: journals[0].id,
|
|
414
|
-
});
|
|
415
|
-
(0, globals_1.expect)(journalEntries).toBeInstanceOf(Array);
|
|
416
|
-
}));
|
|
417
|
-
(0, globals_1.test)('getJournalEntriesWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
418
|
-
const journalEntries = yield consumer.accounting.getJournalEntriesWithMultiplePlans({
|
|
419
|
-
unposted_allowed: true,
|
|
420
|
-
date_from: '2022-01-01',
|
|
421
|
-
date_to: '2022-01-31',
|
|
422
|
-
journal_id: journals[0].id,
|
|
423
|
-
});
|
|
424
|
-
(0, globals_1.expect)(journalEntries).toBeInstanceOf(Array);
|
|
425
|
-
}));
|
|
426
|
-
(0, globals_1.test)('getPaymentsByInvoiceId', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
427
|
-
const payments = yield consumer.accounting.getPaymentsByInvoiceId(invoices[0].id);
|
|
428
|
-
(0, globals_1.expect)(payments).toBeInstanceOf(Array);
|
|
429
|
-
}));
|
|
430
|
-
let miscOperations;
|
|
431
|
-
(0, globals_1.test)('getMiscOperations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
432
|
-
miscOperations = yield consumer.accounting.getMiscOperations();
|
|
433
|
-
(0, globals_1.expect)(miscOperations).toBeInstanceOf(Array);
|
|
434
|
-
(0, globals_1.expect)(miscOperations.length).toBeGreaterThan(0);
|
|
435
|
-
(0, globals_1.expect)(miscOperations[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
436
|
-
}));
|
|
437
|
-
(0, globals_1.test)('createMiscOperation', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
438
|
-
var _c;
|
|
439
|
-
const data = {
|
|
440
|
-
operation_date: '2023-04-29',
|
|
441
|
-
currency: 'EUR',
|
|
442
|
-
lines: [
|
|
443
|
-
{
|
|
444
|
-
line_number: 1,
|
|
445
|
-
description: 'test line',
|
|
446
|
-
amount: 0,
|
|
447
|
-
type: 'general_account',
|
|
448
|
-
account_number: '400000',
|
|
449
|
-
},
|
|
450
|
-
],
|
|
451
|
-
journal_id: (_c = journals === null || journals === void 0 ? void 0 : journals.find((journal) => journal.journal_type === 'miscellaneous_operation')) === null || _c === void 0 ? void 0 : _c.id,
|
|
452
|
-
status: 'draft',
|
|
453
|
-
};
|
|
454
|
-
const miscOperation = yield consumer.accounting.createMiscOperation(data);
|
|
455
|
-
(0, globals_1.expect)(miscOperation).toBeTruthy();
|
|
456
|
-
}));
|
|
457
|
-
(0, globals_1.test)('getMiscOperation', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
458
|
-
const miscOperation = yield consumer.accounting.getMiscOperation(miscOperations[0].id);
|
|
459
|
-
(0, globals_1.expect)(miscOperation).toBeTruthy();
|
|
460
|
-
(0, globals_1.expect)(miscOperation).toHaveProperty('operation_number');
|
|
461
|
-
(0, globals_1.expect)(miscOperation).toHaveProperty('operation_date', globals_1.expect.any(String));
|
|
462
|
-
(0, globals_1.expect)(miscOperation).toHaveProperty('currency', globals_1.expect.any(String));
|
|
463
|
-
(0, globals_1.expect)(miscOperation).toHaveProperty('lines', globals_1.expect.any(Array));
|
|
464
|
-
(0, globals_1.expect)(miscOperation).toHaveProperty('journal_id', globals_1.expect.any(String));
|
|
465
|
-
(0, globals_1.expect)(miscOperation).toHaveProperty('status', globals_1.expect.any(String));
|
|
466
|
-
(0, globals_1.expect)(miscOperation).toHaveProperty('id', globals_1.expect.any(String));
|
|
467
|
-
}));
|
|
468
|
-
(0, globals_1.test)('attachPDF', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
469
|
-
const pdfData = fs_1.default.readFileSync('test/data/accounting_invoice.pdf');
|
|
470
|
-
yield consumer.accounting.attachPDF(invoices[0].id, { base64_string: pdfData.toString('base64') }, { overwrite_existing: true });
|
|
471
|
-
}));
|
|
472
|
-
(0, globals_1.test)('getChartOfAccounts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
473
|
-
const chartOfAccounts = yield consumer.accounting.getChartOfAccounts({
|
|
474
|
-
classes: '6,7',
|
|
475
|
-
});
|
|
476
|
-
(0, globals_1.expect)(chartOfAccounts).toBeTruthy();
|
|
477
|
-
}));
|
|
478
|
-
(0, globals_1.test)('getBalanceOfAccounts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
479
|
-
const balanceOfAccounts = yield consumer.accounting.getBalanceOfAccounts({
|
|
480
|
-
accounts: ['7'],
|
|
481
|
-
start: '2022-01-01',
|
|
482
|
-
end: '2022-12-31',
|
|
483
|
-
});
|
|
484
|
-
(0, globals_1.expect)(balanceOfAccounts).toBeTruthy();
|
|
485
|
-
(0, globals_1.expect)(balanceOfAccounts).toHaveProperty('items');
|
|
486
|
-
(0, globals_1.expect)(balanceOfAccounts.items).toBeInstanceOf(Array);
|
|
487
|
-
}));
|
|
488
|
-
(0, globals_1.test)('getEmployees', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
489
|
-
const employees = yield consumer.accounting.getEmployees();
|
|
490
|
-
(0, globals_1.expect)(employees).toBeTruthy();
|
|
491
|
-
}));
|
|
492
|
-
(0, globals_1.test)('getOutstandings', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
493
|
-
var _d;
|
|
494
|
-
globals_1.expect.assertions(1);
|
|
495
|
-
try {
|
|
496
|
-
const outstandings = yield consumer.accounting.getOutstandings({
|
|
497
|
-
type: 'client',
|
|
498
|
-
unposted_allowed: true,
|
|
499
|
-
});
|
|
500
|
-
(0, globals_1.expect)(outstandings).toBeTruthy();
|
|
501
|
-
(0, globals_1.expect)(outstandings.items).toBeInstanceOf(Array);
|
|
502
|
-
}
|
|
503
|
-
catch (e) {
|
|
504
|
-
if ((_d = e === null || e === void 0 ? void 0 : e.error) === null || _d === void 0 ? void 0 : _d.error_code) {
|
|
505
|
-
(0, globals_1.expect)(e.error.error_code).toMatch('ERROR_API_RESOURCE_NOT_FOUND');
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
throw e;
|
|
509
|
-
}
|
|
510
|
-
}));
|
|
511
|
-
(0, globals_1.test)('createFinancialEntry', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
512
|
-
const journal = journals.find((journal) => journal.journal_type === 'financial_operation');
|
|
513
|
-
if (!journal) {
|
|
514
|
-
throw new Error('No journal with type "financial_operation" found to create financial entry');
|
|
515
|
-
}
|
|
516
|
-
const financialEntry = yield consumer.accounting.createFinancialEntry({
|
|
517
|
-
date: '2022-01-01',
|
|
518
|
-
journal_id: journal.id,
|
|
519
|
-
currency: 'EUR',
|
|
520
|
-
items: [
|
|
521
|
-
{
|
|
522
|
-
account_type: 'customer_account',
|
|
523
|
-
account: clients[0].id,
|
|
524
|
-
amount: 10,
|
|
525
|
-
},
|
|
526
|
-
],
|
|
527
|
-
});
|
|
528
|
-
(0, globals_1.expect)(financialEntry).toBeTruthy();
|
|
529
|
-
(0, globals_1.expect)(financialEntry).toHaveProperty('journal_id', journal.id);
|
|
530
|
-
}));
|
|
531
|
-
/**
|
|
532
|
-
* @deprecated replaced by createFinancialEntry
|
|
533
|
-
*/
|
|
534
|
-
(0, globals_1.test)('createFinancialEntryOld', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
535
|
-
const journal = journals.find((journal) => journal.journal_type === 'financial_operation');
|
|
536
|
-
if (!journal) {
|
|
537
|
-
throw new Error('No journal with type "financial_operation" found to create financial entry');
|
|
538
|
-
}
|
|
539
|
-
const financialEntry = yield consumer.accounting.createFinancialEntryOld({
|
|
540
|
-
date: '2022-01-01',
|
|
541
|
-
journal_id: journal.id,
|
|
542
|
-
currency: 'EUR',
|
|
543
|
-
items: [
|
|
544
|
-
{
|
|
545
|
-
type: 'customer_account',
|
|
546
|
-
account_number: clients[0].account_number,
|
|
547
|
-
partner_id: clients[0].id,
|
|
548
|
-
amount: 10,
|
|
549
|
-
},
|
|
550
|
-
],
|
|
551
|
-
});
|
|
552
|
-
(0, globals_1.expect)(financialEntry).toBeTruthy();
|
|
553
|
-
(0, globals_1.expect)(financialEntry).toHaveProperty('journal_id', journal.id);
|
|
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
|
-
}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|