@klardaten/n8n-nodes-datevconnect 1.0.2 → 1.0.3

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.
Files changed (79) hide show
  1. package/README.md +7 -10
  2. package/dist/credentials/DatevConnectApi.credentials.js +68 -95
  3. package/dist/nodes/Accounting/Accounting.config.js +1373 -0
  4. package/dist/nodes/Accounting/Accounting.node.js +180 -5153
  5. package/dist/nodes/Accounting/handlers/AccountPostingResourceHandler.js +40 -0
  6. package/dist/nodes/Accounting/handlers/AccountingSequenceResourceHandler.js +72 -0
  7. package/dist/nodes/Accounting/handlers/AccountingStatisticsResourceHandler.js +38 -0
  8. package/dist/nodes/Accounting/handlers/AccountingSumsAndBalancesResourceHandler.js +52 -0
  9. package/dist/nodes/Accounting/handlers/AccountingTransactionKeysResourceHandler.js +53 -0
  10. package/dist/nodes/Accounting/handlers/AccountsPayableResourceHandler.js +67 -0
  11. package/dist/nodes/Accounting/handlers/AccountsReceivableResourceHandler.js +48 -0
  12. package/dist/nodes/Accounting/handlers/BaseResourceHandler.js +148 -0
  13. package/dist/nodes/Accounting/handlers/BusinessPartnersResourceHandler.js +207 -0
  14. package/dist/nodes/Accounting/handlers/ClientResourceHandler.js +52 -0
  15. package/dist/nodes/Accounting/handlers/CostCenterPropertiesResourceHandler.js +55 -0
  16. package/dist/nodes/Accounting/handlers/CostCentersUnitsResourceHandler.js +55 -0
  17. package/dist/nodes/Accounting/handlers/CostSequencesResourceHandler.js +88 -0
  18. package/dist/nodes/Accounting/handlers/CostSystemsResourceHandler.js +62 -0
  19. package/dist/nodes/Accounting/handlers/FiscalYearResourceHandler.js +49 -0
  20. package/dist/nodes/Accounting/handlers/GeneralLedgerAccountsResourceHandler.js +67 -0
  21. package/dist/nodes/Accounting/handlers/InternalCostServicesResourceHandler.js +40 -0
  22. package/dist/nodes/Accounting/handlers/PostingProposalsResourceHandler.js +98 -0
  23. package/dist/nodes/Accounting/handlers/StocktakingDataResourceHandler.js +57 -0
  24. package/dist/nodes/Accounting/handlers/TermsOfPaymentResourceHandler.js +69 -0
  25. package/dist/nodes/Accounting/handlers/VariousAddressesResourceHandler.js +56 -0
  26. package/dist/nodes/Accounting/handlers/index.js +45 -0
  27. package/dist/nodes/Accounting/types.js +5 -0
  28. package/dist/nodes/DocumentManagement/DocumentManagement.config.js +598 -0
  29. package/dist/nodes/DocumentManagement/DocumentManagement.node.js +96 -3513
  30. package/dist/nodes/DocumentManagement/handlers/BaseResourceHandler.js +121 -0
  31. package/dist/nodes/DocumentManagement/handlers/DocumentFileResourceHandler.js +126 -0
  32. package/dist/nodes/DocumentManagement/handlers/DocumentResourceHandler.js +184 -0
  33. package/dist/nodes/DocumentManagement/handlers/DocumentStateResourceHandler.js +58 -0
  34. package/dist/nodes/DocumentManagement/handlers/DomainResourceHandler.js +32 -0
  35. package/dist/nodes/DocumentManagement/handlers/IndividualPropertyResourceHandler.js +32 -0
  36. package/dist/nodes/DocumentManagement/handlers/IndividualReference1ResourceHandler.js +49 -0
  37. package/dist/nodes/DocumentManagement/handlers/IndividualReference2ResourceHandler.js +49 -0
  38. package/dist/nodes/DocumentManagement/handlers/InfoResourceHandler.js +30 -0
  39. package/dist/nodes/DocumentManagement/handlers/PropertyTemplateResourceHandler.js +34 -0
  40. package/dist/nodes/DocumentManagement/handlers/SecureAreaResourceHandler.js +32 -0
  41. package/dist/nodes/DocumentManagement/types.js +2 -0
  42. package/dist/nodes/DocumentManagement/utils.js +116 -0
  43. package/dist/nodes/IdentityAndAccessManagement/IdentityAndAccessManagement.config.js +368 -0
  44. package/dist/nodes/IdentityAndAccessManagement/IdentityAndAccessManagement.node.js +77 -2774
  45. package/dist/nodes/IdentityAndAccessManagement/handlers/BaseResourceHandler.js +87 -0
  46. package/dist/nodes/IdentityAndAccessManagement/handlers/CurrentUserResourceHandler.js +17 -0
  47. package/dist/nodes/IdentityAndAccessManagement/handlers/GroupResourceHandler.js +63 -0
  48. package/dist/nodes/IdentityAndAccessManagement/handlers/ResourceTypeResourceHandler.js +17 -0
  49. package/dist/nodes/IdentityAndAccessManagement/handlers/SchemaResourceHandler.js +30 -0
  50. package/dist/nodes/IdentityAndAccessManagement/handlers/ServiceProviderConfigResourceHandler.js +17 -0
  51. package/dist/nodes/IdentityAndAccessManagement/handlers/UserResourceHandler.js +73 -0
  52. package/dist/nodes/IdentityAndAccessManagement/types.js +2 -0
  53. package/dist/nodes/IdentityAndAccessManagement/utils.js +89 -0
  54. package/dist/nodes/MasterData/MasterData.config.js +902 -0
  55. package/dist/nodes/MasterData/MasterData.node.js +107 -3561
  56. package/dist/nodes/MasterData/handlers/AddresseeResourceHandler.js +98 -0
  57. package/dist/nodes/MasterData/handlers/AreaOfResponsibilityResourceHandler.js +42 -0
  58. package/dist/nodes/MasterData/handlers/BankResourceHandler.js +42 -0
  59. package/dist/nodes/MasterData/handlers/BaseResourceHandler.js +91 -0
  60. package/dist/nodes/MasterData/handlers/ClientCategoryTypeResourceHandler.js +78 -0
  61. package/dist/nodes/MasterData/handlers/ClientGroupTypeResourceHandler.js +78 -0
  62. package/dist/nodes/MasterData/handlers/ClientResourceHandler.js +183 -0
  63. package/dist/nodes/MasterData/handlers/CorporateStructureResourceHandler.js +68 -0
  64. package/dist/nodes/MasterData/handlers/CountryCodeResourceHandler.js +42 -0
  65. package/dist/nodes/MasterData/handlers/EmployeeResourceHandler.js +78 -0
  66. package/dist/nodes/MasterData/handlers/LegalFormResourceHandler.js +42 -0
  67. package/dist/nodes/MasterData/handlers/RelationshipResourceHandler.js +54 -0
  68. package/dist/nodes/MasterData/handlers/TaxAuthorityResourceHandler.js +42 -0
  69. package/dist/nodes/MasterData/types.js +2 -0
  70. package/dist/nodes/MasterData/utils.js +92 -0
  71. package/dist/src/services/accountingClient.js +766 -0
  72. package/dist/src/services/datevConnectClient.js +1809 -0
  73. package/dist/src/services/documentManagementClient.js +546 -0
  74. package/dist/src/services/identityAndAccessManagementClient.js +293 -0
  75. package/package.json +38 -39
  76. package/dist/nodes/Accounting/Accounting.node.json +0 -25
  77. package/dist/nodes/DocumentManagement/DocumentManagement.node.json +0 -25
  78. package/dist/nodes/IdentityAndAccessManagement/IdentityAndAccessManagement.node.json +0 -25
  79. package/dist/nodes/MasterData/MasterData.node.json +0 -25
@@ -1,3562 +1,108 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __moduleCache = /* @__PURE__ */ new WeakMap;
6
- var __toCommonJS = (from) => {
7
- var entry = __moduleCache.get(from), desc;
8
- if (entry)
9
- return entry;
10
- entry = __defProp({}, "__esModule", { value: true });
11
- if (from && typeof from === "object" || typeof from === "function")
12
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- }));
16
- __moduleCache.set(from, entry);
17
- return entry;
18
- };
19
- var __export = (target, all) => {
20
- for (var name in all)
21
- __defProp(target, name, {
22
- get: all[name],
23
- enumerable: true,
24
- configurable: true,
25
- set: (newValue) => all[name] = () => newValue
26
- });
27
- };
28
-
29
- // nodes/MasterData/MasterData.node.ts
30
- var exports_MasterData_node = {};
31
- __export(exports_MasterData_node, {
32
- MasterData: () => MasterData
33
- });
34
- module.exports = __toCommonJS(exports_MasterData_node);
35
- var import_n8n_workflow15 = require("n8n-workflow");
36
-
37
- // src/services/datevConnectClient.ts
38
- var JSON_CONTENT_TYPE = "application/json";
39
- var DEFAULT_ERROR_PREFIX = "DATEVconnect request failed";
40
- function normaliseBaseUrl(host) {
41
- if (!host) {
42
- throw new Error("DATEVconnect host must be provided");
43
- }
44
- return host.endsWith("/") ? host : `${host}/`;
45
- }
46
- function buildHeaders(headers) {
47
- return Object.entries(headers).reduce((acc, [key, value]) => {
48
- if (value) {
49
- acc[key] = value;
50
- }
51
- return acc;
52
- }, {});
53
- }
54
- async function readResponseBody(response) {
55
- const contentType = response.headers.get("content-type") ?? "";
56
- if (contentType.toLowerCase().includes(JSON_CONTENT_TYPE)) {
57
- try {
58
- return await response.json();
59
- } catch {
60
- return;
61
- }
62
- }
63
- try {
64
- const text = await response.text();
65
- return text.length > 0 ? text : undefined;
66
- } catch {
67
- return;
68
- }
69
- }
70
- function extractErrorMessage(response, body) {
71
- const statusPart = `${response.status}${response.statusText ? ` ${response.statusText}` : ""}`.trim();
72
- const prefix = `${DEFAULT_ERROR_PREFIX}${statusPart ? ` (${statusPart})` : ""}`;
73
- if (typeof body === "string" && body.trim().length > 0) {
74
- return `${prefix}: ${body.trim()}`;
75
- }
76
- if (body && typeof body === "object") {
77
- const errorDescription = "error_description" in body && typeof body.error_description === "string" ? body.error_description : undefined;
78
- const message = ("message" in body && typeof body.message === "string" ? body.message : undefined) || ("error" in body && typeof body.error === "string" ? body.error : undefined);
79
- if (message) {
80
- return `${prefix}: ${message}${errorDescription ? `: ${errorDescription}` : ""}`;
81
- }
82
- }
83
- return prefix;
84
- }
85
- async function ensureSuccess(response) {
86
- const body = await readResponseBody(response);
87
- if (!response.ok) {
88
- throw new Error(extractErrorMessage(response, body));
89
- }
90
- if (body && typeof body === "object") {
91
- return body;
92
- }
93
- if (body === undefined) {
94
- return;
95
- }
96
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected JSON response body.`);
97
- }
98
- async function authenticate(options) {
99
- const { host, email, password, fetchImpl = fetch } = options;
100
- const baseUrl = normaliseBaseUrl(host);
101
- const url = new URL("api/auth/login", baseUrl);
102
- const response = await fetchImpl(url, {
103
- method: "POST",
104
- headers: buildHeaders({
105
- "content-type": JSON_CONTENT_TYPE
106
- }),
107
- body: JSON.stringify({ email, password })
108
- });
109
- const body = await ensureSuccess(response);
110
- if (!body || typeof body !== "object" || !("access_token" in body) || typeof body.access_token !== "string") {
111
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Authentication response missing access_token.`);
112
- }
113
- return body;
114
- }
115
- var MASTER_DATA_BASE_PATH = "datevconnect/master-data/v1";
116
- var CLIENTS_PATH = `${MASTER_DATA_BASE_PATH}/clients`;
117
- var TAX_AUTHORITIES_PATH = `${MASTER_DATA_BASE_PATH}/tax-authorities`;
118
- var RELATIONSHIPS_PATH = `${MASTER_DATA_BASE_PATH}/relationships`;
119
- var RELATIONSHIP_TYPES_PATH = `${MASTER_DATA_BASE_PATH}/relationship-types`;
120
- var LEGAL_FORMS_PATH = `${MASTER_DATA_BASE_PATH}/legal-forms`;
121
- var CORPORATE_STRUCTURES_PATH = `${MASTER_DATA_BASE_PATH}/corporate-structures`;
122
- var EMPLOYEES_PATH = `${MASTER_DATA_BASE_PATH}/employees`;
123
- var COUNTRY_CODES_PATH = `${MASTER_DATA_BASE_PATH}/country-codes`;
124
- var CLIENT_GROUP_TYPES_PATH = `${MASTER_DATA_BASE_PATH}/client-group-types`;
125
- var CLIENT_CATEGORY_TYPES_PATH = `${MASTER_DATA_BASE_PATH}/client-category-types`;
126
- var BANKS_PATH = `${MASTER_DATA_BASE_PATH}/banks`;
127
- var AREA_OF_RESPONSIBILITIES_PATH = `${MASTER_DATA_BASE_PATH}/area-of-responsibilities`;
128
- var ADDRESSEES_PATH = `${MASTER_DATA_BASE_PATH}/addressees`;
129
- var ADDRESSEES_DELETION_LOG_PATH = `${ADDRESSEES_PATH}/deletion-log`;
130
- function buildApiUrl(host, path) {
131
- const baseUrl = normaliseBaseUrl(host);
132
- const trimmedPath = path.startsWith("/") ? path.slice(1) : path;
133
- return new URL(trimmedPath, baseUrl);
134
- }
135
- async function sendMasterDataRequest(options) {
136
- const { host, token, clientInstanceId, path, method, query, body, fetchImpl = fetch } = options;
137
- const url = buildApiUrl(host, path);
138
- if (query) {
139
- for (const [key, value] of Object.entries(query)) {
140
- if (value === undefined || value === null) {
141
- continue;
142
- }
143
- url.searchParams.set(key, String(value));
144
- }
145
- }
146
- const response = await fetchImpl(url, {
147
- method,
148
- headers: buildHeaders({
149
- accept: JSON_CONTENT_TYPE,
150
- authorization: `Bearer ${token}`,
151
- "content-type": JSON_CONTENT_TYPE,
152
- "x-client-instance-id": clientInstanceId
153
- }),
154
- body: body === undefined ? undefined : JSON.stringify(body)
155
- });
156
- return ensureSuccess(response);
157
- }
158
- async function fetchClients(options) {
159
- const { top, skip, select, filter } = options;
160
- const body = await sendMasterDataRequest({
161
- ...options,
162
- path: CLIENTS_PATH,
163
- method: "GET",
164
- query: {
165
- top,
166
- skip,
167
- select,
168
- filter
169
- }
170
- });
171
- if (body === undefined) {
172
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected clients payload.`);
173
- }
174
- return body;
175
- }
176
- async function fetchClient(options) {
177
- const { clientId, select } = options;
178
- const body = await sendMasterDataRequest({
179
- ...options,
180
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}`,
181
- method: "GET",
182
- query: {
183
- select
184
- }
185
- });
186
- if (body === undefined) {
187
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client payload.`);
188
- }
189
- return body;
190
- }
191
- async function createClient(options) {
192
- const { client, maxNumber } = options;
193
- return sendMasterDataRequest({
194
- ...options,
195
- path: CLIENTS_PATH,
196
- method: "POST",
197
- query: {
198
- "max-number": maxNumber
199
- },
200
- body: client
201
- });
202
- }
203
- async function updateClient(options) {
204
- const { clientId, client } = options;
205
- return sendMasterDataRequest({
206
- ...options,
207
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}`,
208
- method: "PUT",
209
- body: client
210
- });
211
- }
212
- async function fetchClientResponsibilities(options) {
213
- const { clientId, select } = options;
214
- const body = await sendMasterDataRequest({
215
- ...options,
216
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/responsibilities`,
217
- method: "GET",
218
- query: {
219
- select
220
- }
221
- });
222
- if (body === undefined) {
223
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected responsibilities payload.`);
224
- }
225
- return body;
226
- }
227
- async function updateClientResponsibilities(options) {
228
- const { clientId, responsibilities } = options;
229
- return sendMasterDataRequest({
230
- ...options,
231
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/responsibilities`,
232
- method: "PUT",
233
- body: responsibilities
234
- });
235
- }
236
- async function fetchClientCategories(options) {
237
- const { clientId, select } = options;
238
- const body = await sendMasterDataRequest({
239
- ...options,
240
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-categories`,
241
- method: "GET",
242
- query: {
243
- select
244
- }
245
- });
246
- if (body === undefined) {
247
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client categories payload.`);
248
- }
249
- return body;
250
- }
251
- async function updateClientCategories(options) {
252
- const { clientId, categories } = options;
253
- return sendMasterDataRequest({
254
- ...options,
255
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-categories`,
256
- method: "PUT",
257
- body: categories
258
- });
259
- }
260
- async function fetchClientGroups(options) {
261
- const { clientId, select } = options;
262
- const body = await sendMasterDataRequest({
263
- ...options,
264
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-groups`,
265
- method: "GET",
266
- query: {
267
- select
268
- }
269
- });
270
- if (body === undefined) {
271
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client groups payload.`);
272
- }
273
- return body;
274
- }
275
- async function updateClientGroups(options) {
276
- const { clientId, groups } = options;
277
- return sendMasterDataRequest({
278
- ...options,
279
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-groups`,
280
- method: "PUT",
281
- body: groups
282
- });
283
- }
284
- async function fetchClientDeletionLog(options) {
285
- const { select, filter, top, skip } = options;
286
- const body = await sendMasterDataRequest({
287
- ...options,
288
- path: `${CLIENTS_PATH}/deletion-log`,
289
- method: "GET",
290
- query: {
291
- select,
292
- filter,
293
- top,
294
- skip
295
- }
296
- });
297
- if (body === undefined) {
298
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client deletion log payload.`);
299
- }
300
- return body;
301
- }
302
- async function fetchNextFreeClientNumber(options) {
303
- const { start, range } = options;
304
- const body = await sendMasterDataRequest({
305
- ...options,
306
- path: `${CLIENTS_PATH}/next-free-number`,
307
- method: "GET",
308
- query: {
309
- start,
310
- range
311
- }
312
- });
313
- if (body === undefined) {
314
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected next free number payload.`);
315
- }
316
- return body;
317
- }
318
- async function fetchTaxAuthorities(options) {
319
- const { select, filter, top, skip } = options;
320
- const body = await sendMasterDataRequest({
321
- ...options,
322
- path: TAX_AUTHORITIES_PATH,
323
- method: "GET",
324
- query: {
325
- select,
326
- filter,
327
- top,
328
- skip
329
- }
330
- });
331
- if (body === undefined) {
332
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected tax authorities payload.`);
333
- }
334
- return body;
335
- }
336
- async function fetchRelationships(options) {
337
- const { select, filter, top, skip } = options;
338
- const body = await sendMasterDataRequest({
339
- ...options,
340
- path: RELATIONSHIPS_PATH,
341
- method: "GET",
342
- query: {
343
- select,
344
- filter,
345
- top,
346
- skip
347
- }
348
- });
349
- if (body === undefined) {
350
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected relationships payload.`);
351
- }
352
- return body;
353
- }
354
- async function fetchRelationshipTypes(options) {
355
- const { select, filter } = options;
356
- const body = await sendMasterDataRequest({
357
- ...options,
358
- path: RELATIONSHIP_TYPES_PATH,
359
- method: "GET",
360
- query: {
361
- select,
362
- filter
363
- }
364
- });
365
- if (body === undefined) {
366
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected relationship types payload.`);
367
- }
368
- return body;
369
- }
370
- async function fetchLegalForms(options) {
371
- const { select, nationalRight, top, skip } = options;
372
- const body = await sendMasterDataRequest({
373
- ...options,
374
- path: LEGAL_FORMS_PATH,
375
- method: "GET",
376
- query: {
377
- select,
378
- "national-right": nationalRight,
379
- top,
380
- skip
381
- }
382
- });
383
- if (body === undefined) {
384
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected legal forms payload.`);
385
- }
386
- return body;
387
- }
388
- async function fetchCorporateStructures(options) {
389
- const { select, filter, top, skip } = options;
390
- const body = await sendMasterDataRequest({
391
- ...options,
392
- path: CORPORATE_STRUCTURES_PATH,
393
- method: "GET",
394
- query: {
395
- select,
396
- filter,
397
- top,
398
- skip
399
- }
400
- });
401
- if (body === undefined) {
402
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected corporate structures payload.`);
403
- }
404
- return body;
405
- }
406
- async function fetchCorporateStructure(options) {
407
- const { organizationId, select } = options;
408
- const body = await sendMasterDataRequest({
409
- ...options,
410
- path: `${CORPORATE_STRUCTURES_PATH}/${encodeURIComponent(organizationId)}`,
411
- method: "GET",
412
- query: {
413
- select
414
- }
415
- });
416
- if (body === undefined) {
417
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected corporate structure payload.`);
418
- }
419
- return body;
420
- }
421
- async function fetchEstablishment(options) {
422
- const { organizationId, establishmentId, select } = options;
423
- const body = await sendMasterDataRequest({
424
- ...options,
425
- path: `${CORPORATE_STRUCTURES_PATH}/${encodeURIComponent(organizationId)}/establishments/${encodeURIComponent(establishmentId)}`,
426
- method: "GET",
427
- query: {
428
- select
429
- }
430
- });
431
- if (body === undefined) {
432
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected establishment payload.`);
433
- }
434
- return body;
435
- }
436
- async function fetchEmployees(options) {
437
- const { select, filter, top, skip } = options;
438
- const body = await sendMasterDataRequest({
439
- ...options,
440
- path: EMPLOYEES_PATH,
441
- method: "GET",
442
- query: {
443
- select,
444
- filter,
445
- top,
446
- skip
447
- }
448
- });
449
- if (body === undefined) {
450
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected employees payload.`);
451
- }
452
- return body;
453
- }
454
- async function fetchEmployee(options) {
455
- const { employeeId, select } = options;
456
- const body = await sendMasterDataRequest({
457
- ...options,
458
- path: `${EMPLOYEES_PATH}/${encodeURIComponent(employeeId)}`,
459
- method: "GET",
460
- query: {
461
- select
462
- }
463
- });
464
- if (body === undefined) {
465
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected employee payload.`);
466
- }
467
- return body;
468
- }
469
- async function createEmployee(options) {
470
- const { employee } = options;
471
- return sendMasterDataRequest({
472
- ...options,
473
- path: EMPLOYEES_PATH,
474
- method: "POST",
475
- body: employee
476
- });
477
- }
478
- async function updateEmployee(options) {
479
- const { employeeId, employee } = options;
480
- return sendMasterDataRequest({
481
- ...options,
482
- path: `${EMPLOYEES_PATH}/${encodeURIComponent(employeeId)}`,
483
- method: "PUT",
484
- body: employee
485
- });
486
- }
487
- async function fetchCountryCodes(options) {
488
- const { select, filter, top, skip } = options;
489
- const body = await sendMasterDataRequest({
490
- ...options,
491
- path: COUNTRY_CODES_PATH,
492
- method: "GET",
493
- query: {
494
- select,
495
- filter,
496
- top,
497
- skip
498
- }
499
- });
500
- if (body === undefined) {
501
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected country codes payload.`);
502
- }
503
- return body;
504
- }
505
- async function fetchClientGroupTypes(options) {
506
- const { select, filter, top, skip } = options;
507
- const body = await sendMasterDataRequest({
508
- ...options,
509
- path: CLIENT_GROUP_TYPES_PATH,
510
- method: "GET",
511
- query: {
512
- select,
513
- filter,
514
- top,
515
- skip
516
- }
517
- });
518
- if (body === undefined) {
519
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client group types payload.`);
520
- }
521
- return body;
522
- }
523
- async function fetchClientGroupType(options) {
524
- const { clientGroupTypeId, select } = options;
525
- const body = await sendMasterDataRequest({
526
- ...options,
527
- path: `${CLIENT_GROUP_TYPES_PATH}/${clientGroupTypeId}`,
528
- method: "GET",
529
- query: {
530
- select
531
- }
532
- });
533
- if (body === undefined) {
534
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client group type payload.`);
535
- }
536
- return body;
537
- }
538
- async function createClientGroupType(options) {
539
- const { clientGroupType } = options;
540
- const body = await sendMasterDataRequest({
541
- ...options,
542
- path: CLIENT_GROUP_TYPES_PATH,
543
- method: "POST",
544
- body: clientGroupType
545
- });
546
- return body;
547
- }
548
- async function updateClientGroupType(options) {
549
- const { clientGroupTypeId, clientGroupType } = options;
550
- const body = await sendMasterDataRequest({
551
- ...options,
552
- path: `${CLIENT_GROUP_TYPES_PATH}/${clientGroupTypeId}`,
553
- method: "PUT",
554
- body: clientGroupType
555
- });
556
- return body;
557
- }
558
- async function fetchClientCategoryTypes(options) {
559
- const { select, filter, top, skip } = options;
560
- const body = await sendMasterDataRequest({
561
- ...options,
562
- path: CLIENT_CATEGORY_TYPES_PATH,
563
- method: "GET",
564
- query: {
565
- select,
566
- filter,
567
- top,
568
- skip
569
- }
570
- });
571
- if (body === undefined) {
572
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client category types payload.`);
573
- }
574
- return body;
575
- }
576
- async function fetchClientCategoryType(options) {
577
- const { clientCategoryTypeId, select } = options;
578
- const body = await sendMasterDataRequest({
579
- ...options,
580
- path: `${CLIENT_CATEGORY_TYPES_PATH}/${clientCategoryTypeId}`,
581
- method: "GET",
582
- query: {
583
- select
584
- }
585
- });
586
- if (body === undefined) {
587
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client category type payload.`);
588
- }
589
- return body;
590
- }
591
- async function createClientCategoryType(options) {
592
- const { clientCategoryType } = options;
593
- const body = await sendMasterDataRequest({
594
- ...options,
595
- path: CLIENT_CATEGORY_TYPES_PATH,
596
- method: "POST",
597
- body: clientCategoryType
598
- });
599
- return body;
600
- }
601
- async function updateClientCategoryType(options) {
602
- const { clientCategoryTypeId, clientCategoryType } = options;
603
- const body = await sendMasterDataRequest({
604
- ...options,
605
- path: `${CLIENT_CATEGORY_TYPES_PATH}/${clientCategoryTypeId}`,
606
- method: "PUT",
607
- body: clientCategoryType
608
- });
609
- return body;
610
- }
611
- async function fetchBanks(options) {
612
- const { select, filter, top, skip } = options;
613
- const body = await sendMasterDataRequest({
614
- ...options,
615
- path: BANKS_PATH,
616
- method: "GET",
617
- query: {
618
- select,
619
- filter,
620
- top,
621
- skip
622
- }
623
- });
624
- if (body === undefined) {
625
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected banks payload.`);
626
- }
627
- return body;
628
- }
629
- async function fetchAreaOfResponsibilities(options) {
630
- const { select, filter, top, skip } = options;
631
- const body = await sendMasterDataRequest({
632
- ...options,
633
- path: AREA_OF_RESPONSIBILITIES_PATH,
634
- method: "GET",
635
- query: {
636
- select,
637
- filter,
638
- top,
639
- skip
640
- }
641
- });
642
- if (body === undefined) {
643
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected area of responsibilities payload.`);
644
- }
645
- return body;
646
- }
647
- async function fetchAddressees(options) {
648
- const { select, filter, top, skip } = options;
649
- const body = await sendMasterDataRequest({
650
- ...options,
651
- path: ADDRESSEES_PATH,
652
- method: "GET",
653
- query: {
654
- select,
655
- filter,
656
- top,
657
- skip
658
- }
659
- });
660
- if (body === undefined) {
661
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected addressees payload.`);
662
- }
663
- return body;
664
- }
665
- async function fetchAddressee(options) {
666
- const { addresseeId, select, expand } = options;
667
- const body = await sendMasterDataRequest({
668
- ...options,
669
- path: `${ADDRESSEES_PATH}/${addresseeId}`,
670
- method: "GET",
671
- query: {
672
- select,
673
- expand
674
- }
675
- });
676
- if (body === undefined) {
677
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected addressee payload.`);
678
- }
679
- return body;
680
- }
681
- async function createAddressee(options) {
682
- const { addressee, nationalRight } = options;
683
- const body = await sendMasterDataRequest({
684
- ...options,
685
- path: ADDRESSEES_PATH,
686
- method: "POST",
687
- query: {
688
- "national-right": nationalRight
689
- },
690
- body: addressee
691
- });
692
- return body;
693
- }
694
- async function updateAddressee(options) {
695
- const { addresseeId, addressee } = options;
696
- const body = await sendMasterDataRequest({
697
- ...options,
698
- path: `${ADDRESSEES_PATH}/${addresseeId}`,
699
- method: "PUT",
700
- body: addressee
701
- });
702
- return body;
703
- }
704
- async function fetchAddresseesDeletionLog(options) {
705
- const { select, filter, top, skip } = options;
706
- const body = await sendMasterDataRequest({
707
- ...options,
708
- path: ADDRESSEES_DELETION_LOG_PATH,
709
- method: "GET",
710
- query: {
711
- select,
712
- filter,
713
- top,
714
- skip
715
- }
716
- });
717
- if (body === undefined) {
718
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected addressees deletion log payload.`);
719
- }
720
- return body;
721
- }
722
- var ACCOUNTING_BASE_PATH = "datevconnect/accounting/v1";
723
- async function sendAccountingRequest(options) {
724
- const { host, token, clientInstanceId, path, method, query, body, fetchImpl = fetch } = options;
725
- const url = buildApiUrl(host, path);
726
- if (query) {
727
- for (const [key, value] of Object.entries(query)) {
728
- if (value === undefined || value === null) {
729
- continue;
730
- }
731
- url.searchParams.set(key, String(value));
732
- }
733
- }
734
- const response = await fetchImpl(url, {
735
- method,
736
- headers: buildHeaders({
737
- accept: JSON_CONTENT_TYPE,
738
- authorization: `Bearer ${token}`,
739
- "content-type": JSON_CONTENT_TYPE,
740
- "x-client-instance-id": clientInstanceId
741
- }),
742
- body: body === undefined ? undefined : JSON.stringify(body)
743
- });
744
- return ensureSuccess(response);
745
- }
746
- async function fetchAccountingClients(options) {
747
- const { select, filter, top, skip, expand } = options;
748
- const body = await sendAccountingRequest({
749
- ...options,
750
- path: `${ACCOUNTING_BASE_PATH}/clients`,
751
- method: "GET",
752
- query: {
753
- select,
754
- filter,
755
- top,
756
- skip,
757
- expand
758
- }
759
- });
760
- if (body === undefined) {
761
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting clients payload.`);
762
- }
763
- return body;
764
- }
765
- async function fetchAccountingClient(options) {
766
- const { clientId, select, expand } = options;
767
- const body = await sendAccountingRequest({
768
- ...options,
769
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}`,
770
- method: "GET",
771
- query: {
772
- select,
773
- expand
774
- }
775
- });
776
- if (body === undefined) {
777
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting client payload.`);
778
- }
779
- return body;
780
- }
781
- async function fetchFiscalYears(options) {
782
- const { clientId, select, filter, top, skip } = options;
783
- const body = await sendAccountingRequest({
784
- ...options,
785
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years`,
786
- method: "GET",
787
- query: {
788
- select,
789
- filter,
790
- top,
791
- skip
792
- }
793
- });
794
- if (body === undefined) {
795
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected fiscal years payload.`);
796
- }
797
- return body;
798
- }
799
- async function fetchFiscalYear(options) {
800
- const { clientId, fiscalYearId, select } = options;
801
- const body = await sendAccountingRequest({
802
- ...options,
803
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}`,
804
- method: "GET",
805
- query: {
806
- select
807
- }
808
- });
809
- if (body === undefined) {
810
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected fiscal year payload.`);
811
- }
812
- return body;
813
- }
814
- async function fetchAccountsReceivable(options) {
815
- const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
816
- const body = await sendAccountingRequest({
817
- ...options,
818
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-receivable`,
819
- method: "GET",
820
- query: {
821
- select,
822
- filter,
823
- top,
824
- skip,
825
- expand
826
- }
827
- });
828
- if (body === undefined) {
829
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounts receivable payload.`);
830
- }
831
- return body;
832
- }
833
- async function fetchAccountsReceivableCondensed(options) {
834
- const { clientId, fiscalYearId, select, filter, top, skip } = options;
835
- const body = await sendAccountingRequest({
836
- ...options,
837
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-receivable/condensed`,
838
- method: "GET",
839
- query: {
840
- select,
841
- filter,
842
- top,
843
- skip
844
- }
845
- });
846
- if (body === undefined) {
847
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected condensed accounts receivable payload.`);
848
- }
849
- return body;
850
- }
851
- async function fetchAccountReceivable(options) {
852
- const { clientId, fiscalYearId, accountsReceivableId, select, expand } = options;
853
- const body = await sendAccountingRequest({
854
- ...options,
855
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-receivable/${encodeURIComponent(accountsReceivableId)}`,
856
- method: "GET",
857
- query: {
858
- select,
859
- expand
860
- }
861
- });
862
- if (body === undefined) {
863
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account receivable payload.`);
864
- }
865
- return body;
866
- }
867
- async function fetchAccountsPayable(options) {
868
- const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
869
- const body = await sendAccountingRequest({
870
- ...options,
871
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-payable`,
872
- method: "GET",
873
- query: {
874
- select,
875
- filter,
876
- top,
877
- skip,
878
- expand
879
- }
880
- });
881
- if (body === undefined) {
882
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounts payable payload.`);
883
- }
884
- return body;
885
- }
886
- async function fetchAccountsPayableCondensed(options) {
887
- const { clientId, fiscalYearId, select, filter, top, skip } = options;
888
- const body = await sendAccountingRequest({
889
- ...options,
890
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-payable/condense`,
891
- method: "GET",
892
- query: {
893
- select,
894
- filter,
895
- top,
896
- skip
897
- }
898
- });
899
- if (body === undefined) {
900
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected condensed accounts payable payload.`);
901
- }
902
- return body;
903
- }
904
- async function fetchAccountPayable(options) {
905
- const { clientId, fiscalYearId, accountsPayableId, select, expand } = options;
906
- const body = await sendAccountingRequest({
907
- ...options,
908
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-payable/${encodeURIComponent(accountsPayableId)}`,
909
- method: "GET",
910
- query: {
911
- select,
912
- expand
913
- }
914
- });
915
- if (body === undefined) {
916
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account payable payload.`);
917
- }
918
- return body;
919
- }
920
- async function fetchAccountPostings(options) {
921
- const { clientId, fiscalYearId, select, filter, top, skip } = options;
922
- const body = await sendAccountingRequest({
923
- ...options,
924
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/account-postings`,
925
- method: "GET",
926
- query: {
927
- select,
928
- filter,
929
- top,
930
- skip
931
- }
932
- });
933
- if (body === undefined) {
934
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account postings payload.`);
935
- }
936
- return body;
937
- }
938
- async function fetchAccountPosting(options) {
939
- const { clientId, fiscalYearId, accountPostingId, select } = options;
940
- const body = await sendAccountingRequest({
941
- ...options,
942
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/account-postings/${encodeURIComponent(accountPostingId)}`,
943
- method: "GET",
944
- query: {
945
- select
946
- }
947
- });
948
- if (body === undefined) {
949
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account posting payload.`);
950
- }
951
- return body;
952
- }
953
- async function fetchAccountingSequences(options) {
954
- const { clientId, fiscalYearId, select, top, skip } = options;
955
- const body = await sendAccountingRequest({
956
- ...options,
957
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed`,
958
- method: "GET",
959
- query: {
960
- select,
961
- top,
962
- skip
963
- }
964
- });
965
- if (body === undefined) {
966
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sequences payload.`);
967
- }
968
- return body;
969
- }
970
- async function fetchAccountingSequence(options) {
971
- const { clientId, fiscalYearId, accountingSequenceId, select } = options;
972
- const body = await sendAccountingRequest({
973
- ...options,
974
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed/${encodeURIComponent(accountingSequenceId)}`,
975
- method: "GET",
976
- query: {
977
- select
978
- }
979
- });
980
- if (body === undefined) {
981
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sequence payload.`);
982
- }
983
- return body;
984
- }
985
- async function createAccountingSequence(options) {
986
- const { clientId, fiscalYearId, accountingSequence } = options;
987
- return sendAccountingRequest({
988
- ...options,
989
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences`,
990
- method: "POST",
991
- body: accountingSequence
992
- });
993
- }
994
- async function fetchAccountingRecords(options) {
995
- const { clientId, fiscalYearId, accountingSequenceId, select, filter, top, skip } = options;
996
- const body = await sendAccountingRequest({
997
- ...options,
998
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed/${encodeURIComponent(accountingSequenceId)}/accounting-records`,
999
- method: "GET",
1000
- query: {
1001
- select,
1002
- filter,
1003
- top,
1004
- skip
1005
- }
1006
- });
1007
- if (body === undefined) {
1008
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting records payload.`);
1009
- }
1010
- return body;
1011
- }
1012
- async function fetchAccountingRecord(options) {
1013
- const { clientId, fiscalYearId, accountingSequenceId, accountingRecordId, select } = options;
1014
- const body = await sendAccountingRequest({
1015
- ...options,
1016
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed/${encodeURIComponent(accountingSequenceId)}/accounting-records/${encodeURIComponent(accountingRecordId)}`,
1017
- method: "GET",
1018
- query: {
1019
- select
1020
- }
1021
- });
1022
- if (body === undefined) {
1023
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting record payload.`);
1024
- }
1025
- return body;
1026
- }
1027
- async function fetchPostingProposalRulesIncoming(options) {
1028
- const { clientId, fiscalYearId, select, top, skip } = options;
1029
- const body = await sendAccountingRequest({
1030
- ...options,
1031
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-incoming-invoices`,
1032
- method: "GET",
1033
- query: {
1034
- select,
1035
- top,
1036
- skip
1037
- }
1038
- });
1039
- if (body === undefined) {
1040
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rules incoming payload.`);
1041
- }
1042
- return body;
1043
- }
1044
- async function fetchPostingProposalRulesOutgoing(options) {
1045
- const { clientId, fiscalYearId, select, top, skip } = options;
1046
- const body = await sendAccountingRequest({
1047
- ...options,
1048
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-outgoing-invoices`,
1049
- method: "GET",
1050
- query: {
1051
- select,
1052
- top,
1053
- skip
1054
- }
1055
- });
1056
- if (body === undefined) {
1057
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rules outgoing payload.`);
1058
- }
1059
- return body;
1060
- }
1061
- async function fetchPostingProposalRulesCashRegister(options) {
1062
- const { clientId, fiscalYearId, select, top, skip } = options;
1063
- const body = await sendAccountingRequest({
1064
- ...options,
1065
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-cash-register`,
1066
- method: "GET",
1067
- query: {
1068
- select,
1069
- top,
1070
- skip
1071
- }
1072
- });
1073
- if (body === undefined) {
1074
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rules cash register payload.`);
1075
- }
1076
- return body;
1077
- }
1078
- async function fetchPostingProposalRuleIncoming(options) {
1079
- const { clientId, fiscalYearId, ruleId, select } = options;
1080
- const body = await sendAccountingRequest({
1081
- ...options,
1082
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-incoming-invoices/${encodeURIComponent(ruleId)}`,
1083
- method: "GET",
1084
- query: {
1085
- select
1086
- }
1087
- });
1088
- if (body === undefined) {
1089
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rule incoming payload.`);
1090
- }
1091
- return body;
1092
- }
1093
- async function fetchPostingProposalRuleOutgoing(options) {
1094
- const { clientId, fiscalYearId, ruleId, select } = options;
1095
- const body = await sendAccountingRequest({
1096
- ...options,
1097
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-outgoing-invoices/${encodeURIComponent(ruleId)}`,
1098
- method: "GET",
1099
- query: {
1100
- select
1101
- }
1102
- });
1103
- if (body === undefined) {
1104
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rule outgoing payload.`);
1105
- }
1106
- return body;
1107
- }
1108
- async function fetchPostingProposalRuleCashRegister(options) {
1109
- const { clientId, fiscalYearId, ruleId, select } = options;
1110
- const body = await sendAccountingRequest({
1111
- ...options,
1112
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-cash-register/${encodeURIComponent(ruleId)}`,
1113
- method: "GET",
1114
- query: {
1115
- select
1116
- }
1117
- });
1118
- if (body === undefined) {
1119
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rule cash register payload.`);
1120
- }
1121
- return body;
1122
- }
1123
- async function batchPostingProposalsIncoming(options) {
1124
- const { clientId, fiscalYearId, postingProposals } = options;
1125
- return sendAccountingRequest({
1126
- ...options,
1127
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposals-incoming-invoices/batch`,
1128
- method: "POST",
1129
- body: postingProposals
1130
- });
1131
- }
1132
- async function batchPostingProposalsOutgoing(options) {
1133
- const { clientId, fiscalYearId, postingProposals } = options;
1134
- return sendAccountingRequest({
1135
- ...options,
1136
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposals-outgoing-invoices/batch`,
1137
- method: "POST",
1138
- body: postingProposals
1139
- });
1140
- }
1141
- async function batchPostingProposalsCashRegister(options) {
1142
- const { clientId, fiscalYearId, postingProposals } = options;
1143
- return sendAccountingRequest({
1144
- ...options,
1145
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposals-cash-register/batch`,
1146
- method: "POST",
1147
- body: postingProposals
1148
- });
1149
- }
1150
- async function fetchAccountingSumsAndBalances(options) {
1151
- const { clientId, fiscalYearId, select, filter, top, skip } = options;
1152
- const body = await sendAccountingRequest({
1153
- ...options,
1154
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sums-and-balances`,
1155
- method: "GET",
1156
- query: {
1157
- select,
1158
- filter,
1159
- top,
1160
- skip
1161
- }
1162
- });
1163
- if (body === undefined) {
1164
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sums and balances payload.`);
1165
- }
1166
- return body;
1167
- }
1168
- async function fetchAccountingSumsAndBalance(options) {
1169
- const { clientId, fiscalYearId, accountingSumsAndBalancesId } = options;
1170
- const body = await sendAccountingRequest({
1171
- ...options,
1172
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sums-and-balances/${encodeURIComponent(accountingSumsAndBalancesId)}`,
1173
- method: "GET"
1174
- });
1175
- if (body === undefined) {
1176
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sums and balance payload.`);
1177
- }
1178
- return body;
1179
- }
1180
- async function fetchDebitors(options) {
1181
- const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
1182
- const body = await sendAccountingRequest({
1183
- ...options,
1184
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors`,
1185
- method: "GET",
1186
- query: {
1187
- select,
1188
- filter,
1189
- top,
1190
- skip,
1191
- expand
1192
- }
1193
- });
1194
- if (body === undefined) {
1195
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected debitors payload.`);
1196
- }
1197
- return body;
1198
- }
1199
- async function fetchDebitor(options) {
1200
- const { clientId, fiscalYearId, debitorId, select, expand } = options;
1201
- const body = await sendAccountingRequest({
1202
- ...options,
1203
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors/${encodeURIComponent(debitorId)}`,
1204
- method: "GET",
1205
- query: {
1206
- select,
1207
- expand
1208
- }
1209
- });
1210
- if (body === undefined) {
1211
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected debitor payload.`);
1212
- }
1213
- return body;
1214
- }
1215
- async function createDebitor(options) {
1216
- const { clientId, fiscalYearId, debitor } = options;
1217
- return sendAccountingRequest({
1218
- ...options,
1219
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors`,
1220
- method: "POST",
1221
- body: debitor
1222
- });
1223
- }
1224
- async function updateDebitor(options) {
1225
- const { clientId, fiscalYearId, debitorId, debitor } = options;
1226
- return sendAccountingRequest({
1227
- ...options,
1228
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors/${encodeURIComponent(debitorId)}`,
1229
- method: "PUT",
1230
- body: debitor
1231
- });
1232
- }
1233
- async function fetchNextAvailableDebitor(options) {
1234
- const { clientId, fiscalYearId, startAt } = options;
1235
- const body = await sendAccountingRequest({
1236
- ...options,
1237
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors/next-available`,
1238
- method: "GET",
1239
- query: {
1240
- "start-at": startAt
1241
- }
1242
- });
1243
- if (body === undefined) {
1244
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected next available debitor payload.`);
1245
- }
1246
- return body;
1247
- }
1248
- async function fetchCreditors(options) {
1249
- const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
1250
- const body = await sendAccountingRequest({
1251
- ...options,
1252
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors`,
1253
- method: "GET",
1254
- query: {
1255
- select,
1256
- filter,
1257
- top,
1258
- skip,
1259
- expand
1260
- }
1261
- });
1262
- if (body === undefined) {
1263
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected creditors payload.`);
1264
- }
1265
- return body;
1266
- }
1267
- async function fetchCreditor(options) {
1268
- const { clientId, fiscalYearId, creditorId, select, expand } = options;
1269
- const body = await sendAccountingRequest({
1270
- ...options,
1271
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors/${encodeURIComponent(creditorId)}`,
1272
- method: "GET",
1273
- query: {
1274
- select,
1275
- expand
1276
- }
1277
- });
1278
- if (body === undefined) {
1279
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected creditor payload.`);
1280
- }
1281
- return body;
1282
- }
1283
- async function createCreditor(options) {
1284
- const { clientId, fiscalYearId, creditor } = options;
1285
- return sendAccountingRequest({
1286
- ...options,
1287
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors`,
1288
- method: "POST",
1289
- body: creditor
1290
- });
1291
- }
1292
- async function updateCreditor(options) {
1293
- const { clientId, fiscalYearId, creditorId, creditor } = options;
1294
- return sendAccountingRequest({
1295
- ...options,
1296
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors/${encodeURIComponent(creditorId)}`,
1297
- method: "PUT",
1298
- body: creditor
1299
- });
1300
- }
1301
- async function fetchNextAvailableCreditor(options) {
1302
- const { clientId, fiscalYearId, startAt } = options;
1303
- const body = await sendAccountingRequest({
1304
- ...options,
1305
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors/next-available`,
1306
- method: "GET",
1307
- query: {
1308
- "start-at": startAt
1309
- }
1310
- });
1311
- if (body === undefined) {
1312
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected next available creditor payload.`);
1313
- }
1314
- return body;
1315
- }
1316
- async function fetchGeneralLedgerAccounts(options) {
1317
- const { clientId, fiscalYearId, select, filter, top, skip } = options;
1318
- const body = await sendAccountingRequest({
1319
- ...options,
1320
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/general-ledger-accounts`,
1321
- method: "GET",
1322
- query: {
1323
- select,
1324
- filter,
1325
- top,
1326
- skip
1327
- }
1328
- });
1329
- if (body === undefined) {
1330
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected general ledger accounts payload.`);
1331
- }
1332
- return body;
1333
- }
1334
- async function fetchGeneralLedgerAccount(options) {
1335
- const { clientId, fiscalYearId, generalLedgerAccountId, select } = options;
1336
- const body = await sendAccountingRequest({
1337
- ...options,
1338
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/general-ledger-accounts/${encodeURIComponent(generalLedgerAccountId)}`,
1339
- method: "GET",
1340
- query: {
1341
- select
1342
- }
1343
- });
1344
- if (body === undefined) {
1345
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected general ledger account payload.`);
1346
- }
1347
- return body;
1348
- }
1349
- async function fetchUtilizedGeneralLedgerAccounts(options) {
1350
- const { clientId, fiscalYearId, select, top, skip } = options;
1351
- const body = await sendAccountingRequest({
1352
- ...options,
1353
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/general-ledger-accounts/utilized`,
1354
- method: "GET",
1355
- query: {
1356
- select,
1357
- top,
1358
- skip
1359
- }
1360
- });
1361
- if (body === undefined) {
1362
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected utilized general ledger accounts payload.`);
1363
- }
1364
- return body;
1365
- }
1366
- async function fetchTermsOfPayment(options) {
1367
- const { clientId, fiscalYearId, select, filter, skip, top } = options;
1368
- const body = await sendAccountingRequest({
1369
- ...options,
1370
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment`,
1371
- method: "GET",
1372
- query: {
1373
- select,
1374
- filter,
1375
- skip,
1376
- top
1377
- }
1378
- });
1379
- if (body === undefined) {
1380
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected terms of payment payload.`);
1381
- }
1382
- return body;
1383
- }
1384
- async function fetchTermOfPayment(options) {
1385
- const { clientId, fiscalYearId, termOfPaymentId, select } = options;
1386
- const body = await sendAccountingRequest({
1387
- ...options,
1388
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment/${encodeURIComponent(termOfPaymentId)}`,
1389
- method: "GET",
1390
- query: {
1391
- select
1392
- }
1393
- });
1394
- if (body === undefined) {
1395
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected term of payment payload.`);
1396
- }
1397
- return body;
1398
- }
1399
- async function createTermOfPayment(options) {
1400
- const { clientId, fiscalYearId, termOfPaymentData } = options;
1401
- return sendAccountingRequest({
1402
- ...options,
1403
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment`,
1404
- method: "POST",
1405
- body: termOfPaymentData
1406
- });
1407
- }
1408
- async function updateTermOfPayment(options) {
1409
- const { clientId, fiscalYearId, termOfPaymentId, termOfPaymentData } = options;
1410
- return sendAccountingRequest({
1411
- ...options,
1412
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment/${encodeURIComponent(termOfPaymentId)}`,
1413
- method: "PUT",
1414
- body: termOfPaymentData
1415
- });
1416
- }
1417
- async function fetchStocktakingData(options) {
1418
- const { clientId, fiscalYearId, filter, select, skip, top } = options;
1419
- const body = await sendAccountingRequest({
1420
- ...options,
1421
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/assets/stocktakings`,
1422
- method: "GET",
1423
- query: {
1424
- filter,
1425
- select,
1426
- skip,
1427
- top
1428
- }
1429
- });
1430
- if (body === undefined) {
1431
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected stocktaking data payload.`);
1432
- }
1433
- return body;
1434
- }
1435
- async function fetchStocktakingDataByAsset(options) {
1436
- const { clientId, fiscalYearId, assetId, select, skip, top } = options;
1437
- const body = await sendAccountingRequest({
1438
- ...options,
1439
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/assets/${encodeURIComponent(assetId)}/stocktaking/`,
1440
- method: "GET",
1441
- query: {
1442
- select,
1443
- skip,
1444
- top
1445
- }
1446
- });
1447
- if (body === undefined) {
1448
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected stocktaking data by asset payload.`);
1449
- }
1450
- return body;
1451
- }
1452
- async function updateStocktakingData(options) {
1453
- const { clientId, fiscalYearId, assetId, stocktakingData } = options;
1454
- return sendAccountingRequest({
1455
- ...options,
1456
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/assets/${encodeURIComponent(assetId)}/stocktaking/`,
1457
- method: "PUT",
1458
- body: stocktakingData
1459
- });
1460
- }
1461
- async function fetchCostSystems(options) {
1462
- const { clientId, fiscalYearId, select, skip, top } = options;
1463
- const body = await sendAccountingRequest({
1464
- ...options,
1465
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems`,
1466
- method: "GET",
1467
- query: {
1468
- select,
1469
- skip,
1470
- top
1471
- }
1472
- });
1473
- if (body === undefined) {
1474
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost systems payload.`);
1475
- }
1476
- return body;
1477
- }
1478
- async function fetchCostSystem(options) {
1479
- const { clientId, fiscalYearId, costSystemId, select } = options;
1480
- const body = await sendAccountingRequest({
1481
- ...options,
1482
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}`,
1483
- method: "GET",
1484
- query: {
1485
- select
1486
- }
1487
- });
1488
- if (body === undefined) {
1489
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost system payload.`);
1490
- }
1491
- return body;
1492
- }
1493
- async function fetchCostCenters(options) {
1494
- const { clientId, fiscalYearId, costSystemId, select, top, skip } = options;
1495
- const body = await sendAccountingRequest({
1496
- ...options,
1497
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-centers`,
1498
- method: "GET",
1499
- query: {
1500
- select,
1501
- top,
1502
- skip
1503
- }
1504
- });
1505
- if (body === undefined) {
1506
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost centers payload.`);
1507
- }
1508
- return body;
1509
- }
1510
- async function fetchCostCenter(options) {
1511
- const { clientId, fiscalYearId, costSystemId, costCenterId, select } = options;
1512
- const body = await sendAccountingRequest({
1513
- ...options,
1514
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-centers/${encodeURIComponent(costCenterId)}`,
1515
- method: "GET",
1516
- query: {
1517
- select
1518
- }
1519
- });
1520
- if (body === undefined) {
1521
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost center payload.`);
1522
- }
1523
- return body;
1524
- }
1525
- async function fetchCostCenterProperties(options) {
1526
- const { clientId, fiscalYearId, costSystemId, select, skip, top } = options;
1527
- const body = await sendAccountingRequest({
1528
- ...options,
1529
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-center-properties`,
1530
- method: "GET",
1531
- query: {
1532
- select,
1533
- skip,
1534
- top
1535
- }
1536
- });
1537
- if (body === undefined) {
1538
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost center properties payload.`);
1539
- }
1540
- return body;
1541
- }
1542
- async function fetchCostCenterProperty(options) {
1543
- const { clientId, fiscalYearId, costSystemId, costCenterPropertyId, select } = options;
1544
- const body = await sendAccountingRequest({
1545
- ...options,
1546
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-center-properties/${encodeURIComponent(costCenterPropertyId)}`,
1547
- method: "GET",
1548
- query: {
1549
- select
1550
- }
1551
- });
1552
- if (body === undefined) {
1553
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost center property payload.`);
1554
- }
1555
- return body;
1556
- }
1557
- async function createInternalCostService(options) {
1558
- const { clientId, fiscalYearId, costSystemId, internalCostServiceData } = options;
1559
- return sendAccountingRequest({
1560
- ...options,
1561
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/internal-cost-services`,
1562
- method: "POST",
1563
- body: internalCostServiceData
1564
- });
1565
- }
1566
- async function fetchCostSequences(options) {
1567
- const { clientId, fiscalYearId, costSystemId, select, skip, top } = options;
1568
- const body = await sendAccountingRequest({
1569
- ...options,
1570
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences`,
1571
- method: "GET",
1572
- query: {
1573
- select,
1574
- skip,
1575
- top
1576
- }
1577
- });
1578
- if (body === undefined) {
1579
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost sequences payload.`);
1580
- }
1581
- return body;
1582
- }
1583
- async function fetchCostSequence(options) {
1584
- const { clientId, fiscalYearId, costSystemId, costSequenceId, select } = options;
1585
- const body = await sendAccountingRequest({
1586
- ...options,
1587
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences/${encodeURIComponent(costSequenceId)}`,
1588
- method: "GET",
1589
- query: {
1590
- select
1591
- }
1592
- });
1593
- if (body === undefined) {
1594
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost sequence payload.`);
1595
- }
1596
- return body;
1597
- }
1598
- async function createCostSequence(options) {
1599
- const { clientId, fiscalYearId, costSystemId, costSequenceId, costSequenceData } = options;
1600
- return sendAccountingRequest({
1601
- ...options,
1602
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences/${encodeURIComponent(costSequenceId)}`,
1603
- method: "POST",
1604
- body: costSequenceData
1605
- });
1606
- }
1607
- async function fetchCostAccountingRecords(options) {
1608
- const { clientId, fiscalYearId, costSystemId, costSequenceId, select, skip, top } = options;
1609
- const body = await sendAccountingRequest({
1610
- ...options,
1611
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences/${encodeURIComponent(costSequenceId)}/cost-accounting-records`,
1612
- method: "GET",
1613
- query: {
1614
- select,
1615
- skip,
1616
- top
1617
- }
1618
- });
1619
- if (body === undefined) {
1620
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost accounting records payload.`);
1621
- }
1622
- return body;
1623
- }
1624
- async function fetchAccountingStatistics(options) {
1625
- const { clientId, fiscalYearId, select, filter, skip, top } = options;
1626
- const body = await sendAccountingRequest({
1627
- ...options,
1628
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-statistics`,
1629
- method: "GET",
1630
- query: {
1631
- select,
1632
- filter,
1633
- skip,
1634
- top
1635
- }
1636
- });
1637
- if (body === undefined) {
1638
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting statistics payload.`);
1639
- }
1640
- return body;
1641
- }
1642
- async function fetchAccountingTransactionKeys(options) {
1643
- const { clientId, fiscalYearId, select, skip, top } = options;
1644
- const body = await sendAccountingRequest({
1645
- ...options,
1646
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-transaction-keys`,
1647
- method: "GET",
1648
- query: {
1649
- select,
1650
- skip,
1651
- top
1652
- }
1653
- });
1654
- if (body === undefined) {
1655
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting transaction keys payload.`);
1656
- }
1657
- return body;
1658
- }
1659
- async function fetchAccountingTransactionKey(options) {
1660
- const { clientId, fiscalYearId, accountingTransactionKeyId, select, filter, skip, top } = options;
1661
- const body = await sendAccountingRequest({
1662
- ...options,
1663
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-transaction-keys/${encodeURIComponent(accountingTransactionKeyId)}`,
1664
- method: "GET",
1665
- query: {
1666
- select,
1667
- filter,
1668
- skip,
1669
- top
1670
- }
1671
- });
1672
- if (body === undefined) {
1673
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting transaction key payload.`);
1674
- }
1675
- return body;
1676
- }
1677
- async function fetchVariousAddresses(options) {
1678
- const { clientId, fiscalYearId, select, skip, top, expand } = options;
1679
- const body = await sendAccountingRequest({
1680
- ...options,
1681
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/various-addresses`,
1682
- method: "GET",
1683
- query: {
1684
- select,
1685
- skip,
1686
- top,
1687
- expand
1688
- }
1689
- });
1690
- if (body === undefined) {
1691
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected various addresses payload.`);
1692
- }
1693
- return body;
1694
- }
1695
- async function fetchVariousAddress(options) {
1696
- const { clientId, fiscalYearId, variousAddressId, select, skip, top, expand } = options;
1697
- const body = await sendAccountingRequest({
1698
- ...options,
1699
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/various-addresses/${encodeURIComponent(variousAddressId)}`,
1700
- method: "GET",
1701
- query: {
1702
- select,
1703
- skip,
1704
- top,
1705
- expand
1706
- }
1707
- });
1708
- if (body === undefined) {
1709
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected various address payload.`);
1710
- }
1711
- return body;
1712
- }
1713
- async function createVariousAddress(options) {
1714
- const { clientId, fiscalYearId, variousAddressData } = options;
1715
- return sendAccountingRequest({
1716
- ...options,
1717
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/various-addresses`,
1718
- method: "POST",
1719
- body: variousAddressData
1720
- });
1721
- }
1722
-
1723
- // nodes/MasterData/MasterData.config.ts
1724
- var masterDataNodeDescription = {
1725
- displayName: "Klardaten DATEVconnect: Master Data",
1726
- name: "masterData",
1727
- icon: "file:../klardaten.svg",
1728
- group: ["transform"],
1729
- version: 1,
1730
- description: "Interact with master data resources",
1731
- defaults: {
1732
- name: "Master Data"
1733
- },
1734
- inputs: ["main"],
1735
- outputs: ["main"],
1736
- credentials: [
1737
- {
1738
- name: "datevConnectApi",
1739
- required: true
1740
- }
1741
- ],
1742
- properties: [
1743
- {
1744
- displayName: "Resource",
1745
- name: "resource",
1746
- type: "options",
1747
- options: [
1748
- {
1749
- name: "Client",
1750
- value: "client"
1751
- },
1752
- {
1753
- name: "Tax Authority",
1754
- value: "taxAuthority"
1755
- },
1756
- {
1757
- name: "Relationship",
1758
- value: "relationship"
1759
- },
1760
- {
1761
- name: "Legal Form",
1762
- value: "legalForm"
1763
- },
1764
- {
1765
- name: "Corporate Structure",
1766
- value: "corporateStructure"
1767
- },
1768
- {
1769
- name: "Employee",
1770
- value: "employee"
1771
- },
1772
- {
1773
- name: "Country Code",
1774
- value: "countryCode"
1775
- },
1776
- {
1777
- name: "Client Group Type",
1778
- value: "clientGroupType"
1779
- },
1780
- {
1781
- name: "Client Category Type",
1782
- value: "clientCategoryType"
1783
- },
1784
- {
1785
- name: "Bank",
1786
- value: "bank"
1787
- },
1788
- {
1789
- name: "Area of Responsibility",
1790
- value: "areaOfResponsibility"
1791
- },
1792
- {
1793
- name: "Addressee",
1794
- value: "addressee"
1795
- }
1796
- ],
1797
- default: "client"
1798
- },
1799
- {
1800
- displayName: "Operation",
1801
- name: "operation",
1802
- type: "options",
1803
- displayOptions: {
1804
- show: {
1805
- resource: ["client"]
1806
- }
1807
- },
1808
- options: [
1809
- {
1810
- name: "Get Many",
1811
- value: "getAll",
1812
- description: "Retrieve a list of clients",
1813
- action: "Get many clients"
1814
- },
1815
- {
1816
- name: "Get",
1817
- value: "get",
1818
- description: "Retrieve a specific client",
1819
- action: "Get a client"
1820
- },
1821
- {
1822
- name: "Create",
1823
- value: "create",
1824
- description: "Create a new client",
1825
- action: "Create a client"
1826
- },
1827
- {
1828
- name: "Update",
1829
- value: "update",
1830
- description: "Update a specific client",
1831
- action: "Update a client"
1832
- },
1833
- {
1834
- name: "Get Responsibilities",
1835
- value: "getResponsibilities",
1836
- description: "Retrieve responsibilities for a client",
1837
- action: "Get client responsibilities"
1838
- },
1839
- {
1840
- name: "Update Responsibilities",
1841
- value: "updateResponsibilities",
1842
- description: "Replace a client's responsibilities",
1843
- action: "Update client responsibilities"
1844
- },
1845
- {
1846
- name: "Get Categories",
1847
- value: "getClientCategories",
1848
- description: "Retrieve client categories",
1849
- action: "Get client categories"
1850
- },
1851
- {
1852
- name: "Update Categories",
1853
- value: "updateClientCategories",
1854
- description: "Replace a client's category assignments",
1855
- action: "Update client categories"
1856
- },
1857
- {
1858
- name: "Get Groups",
1859
- value: "getClientGroups",
1860
- description: "Retrieve client groups",
1861
- action: "Get client groups"
1862
- },
1863
- {
1864
- name: "Update Groups",
1865
- value: "updateClientGroups",
1866
- description: "Replace a client's group assignments",
1867
- action: "Update client groups"
1868
- },
1869
- {
1870
- name: "Get Deletion Log",
1871
- value: "getDeletionLog",
1872
- description: "Retrieve deleted clients",
1873
- action: "Get client deletion log"
1874
- },
1875
- {
1876
- name: "Get Next Free Number",
1877
- value: "getNextFreeNumber",
1878
- description: "Retrieve the next available client number",
1879
- action: "Get next free client number"
1880
- }
1881
- ],
1882
- default: "getAll"
1883
- },
1884
- {
1885
- displayName: "Operation",
1886
- name: "operation",
1887
- type: "options",
1888
- displayOptions: {
1889
- show: {
1890
- resource: ["taxAuthority"]
1891
- }
1892
- },
1893
- options: [
1894
- {
1895
- name: "Get Many",
1896
- value: "getAll",
1897
- description: "Retrieve a list of tax authorities",
1898
- action: "Get many tax authorities"
1899
- }
1900
- ],
1901
- default: "getAll"
1902
- },
1903
- {
1904
- displayName: "Operation",
1905
- name: "operation",
1906
- type: "options",
1907
- displayOptions: {
1908
- show: {
1909
- resource: ["relationship"]
1910
- }
1911
- },
1912
- options: [
1913
- {
1914
- name: "Get Many",
1915
- value: "getAll",
1916
- description: "Retrieve a list of relationships",
1917
- action: "Get many relationships"
1918
- },
1919
- {
1920
- name: "Get Types",
1921
- value: "getTypes",
1922
- description: "Retrieve a list of relationship types",
1923
- action: "Get relationship types"
1924
- }
1925
- ],
1926
- default: "getAll"
1927
- },
1928
- {
1929
- displayName: "Operation",
1930
- name: "operation",
1931
- type: "options",
1932
- displayOptions: {
1933
- show: {
1934
- resource: ["legalForm"]
1935
- }
1936
- },
1937
- options: [
1938
- {
1939
- name: "Get Many",
1940
- value: "getAll",
1941
- description: "Retrieve a list of legal forms",
1942
- action: "Get many legal forms"
1943
- }
1944
- ],
1945
- default: "getAll"
1946
- },
1947
- {
1948
- displayName: "Operation",
1949
- name: "operation",
1950
- type: "options",
1951
- displayOptions: {
1952
- show: {
1953
- resource: ["corporateStructure"]
1954
- }
1955
- },
1956
- options: [
1957
- {
1958
- name: "Get Many",
1959
- value: "getAll",
1960
- description: "Retrieve a list of corporate structures",
1961
- action: "Get many corporate structures"
1962
- },
1963
- {
1964
- name: "Get Organization",
1965
- value: "get",
1966
- description: "Retrieve a specific organization",
1967
- action: "Get an organization"
1968
- },
1969
- {
1970
- name: "Get Establishment",
1971
- value: "getEstablishment",
1972
- description: "Retrieve a specific establishment",
1973
- action: "Get an establishment"
1974
- }
1975
- ],
1976
- default: "getAll"
1977
- },
1978
- {
1979
- displayName: "Operation",
1980
- name: "operation",
1981
- type: "options",
1982
- displayOptions: {
1983
- show: {
1984
- resource: ["employee"]
1985
- }
1986
- },
1987
- options: [
1988
- {
1989
- name: "Get Many",
1990
- value: "getAll",
1991
- description: "Retrieve a list of employees",
1992
- action: "Get many employees"
1993
- },
1994
- {
1995
- name: "Get",
1996
- value: "get",
1997
- description: "Retrieve a specific employee",
1998
- action: "Get an employee"
1999
- },
2000
- {
2001
- name: "Create",
2002
- value: "create",
2003
- description: "Create a new employee",
2004
- action: "Create an employee"
2005
- },
2006
- {
2007
- name: "Update",
2008
- value: "update",
2009
- description: "Update a specific employee",
2010
- action: "Update an employee"
2011
- }
2012
- ],
2013
- default: "getAll"
2014
- },
2015
- {
2016
- displayName: "Operation",
2017
- name: "operation",
2018
- type: "options",
2019
- displayOptions: {
2020
- show: {
2021
- resource: ["countryCode"]
2022
- }
2023
- },
2024
- options: [
2025
- {
2026
- name: "Get Many",
2027
- value: "getAll",
2028
- description: "Retrieve a list of countries",
2029
- action: "Get many countries"
2030
- }
2031
- ],
2032
- default: "getAll"
2033
- },
2034
- {
2035
- displayName: "Operation",
2036
- name: "operation",
2037
- type: "options",
2038
- displayOptions: {
2039
- show: {
2040
- resource: ["clientGroupType"]
2041
- }
2042
- },
2043
- options: [
2044
- {
2045
- name: "Get Many",
2046
- value: "getAll",
2047
- description: "Retrieve a list of client group types",
2048
- action: "Get many client group types"
2049
- },
2050
- {
2051
- name: "Get",
2052
- value: "get",
2053
- description: "Retrieve a specific client group type",
2054
- action: "Get a client group type"
2055
- },
2056
- {
2057
- name: "Create",
2058
- value: "create",
2059
- description: "Create a new client group type",
2060
- action: "Create a client group type"
2061
- },
2062
- {
2063
- name: "Update",
2064
- value: "update",
2065
- description: "Update a specific client group type",
2066
- action: "Update a client group type"
2067
- }
2068
- ],
2069
- default: "getAll"
2070
- },
2071
- {
2072
- displayName: "Operation",
2073
- name: "operation",
2074
- type: "options",
2075
- displayOptions: {
2076
- show: {
2077
- resource: ["clientCategoryType"]
2078
- }
2079
- },
2080
- options: [
2081
- {
2082
- name: "Get Many",
2083
- value: "getAll",
2084
- description: "Retrieve a list of client category types",
2085
- action: "Get many client category types"
2086
- },
2087
- {
2088
- name: "Get",
2089
- value: "get",
2090
- description: "Retrieve a specific client category type",
2091
- action: "Get a client category type"
2092
- },
2093
- {
2094
- name: "Create",
2095
- value: "create",
2096
- description: "Create a new client category type",
2097
- action: "Create a client category type"
2098
- },
2099
- {
2100
- name: "Update",
2101
- value: "update",
2102
- description: "Update a specific client category type",
2103
- action: "Update a client category type"
2104
- }
2105
- ],
2106
- default: "getAll"
2107
- },
2108
- {
2109
- displayName: "Operation",
2110
- name: "operation",
2111
- type: "options",
2112
- displayOptions: {
2113
- show: {
2114
- resource: ["bank"]
2115
- }
2116
- },
2117
- options: [
2118
- {
2119
- name: "Get Many",
2120
- value: "getAll",
2121
- description: "Retrieve a list of banks",
2122
- action: "Get many banks"
2123
- }
2124
- ],
2125
- default: "getAll"
2126
- },
2127
- {
2128
- displayName: "Operation",
2129
- name: "operation",
2130
- type: "options",
2131
- displayOptions: {
2132
- show: {
2133
- resource: ["areaOfResponsibility"]
2134
- }
2135
- },
2136
- options: [
2137
- {
2138
- name: "Get Many",
2139
- value: "getAll",
2140
- description: "Retrieve a list of areas of responsibility",
2141
- action: "Get many areas of responsibility"
2142
- }
2143
- ],
2144
- default: "getAll"
2145
- },
2146
- {
2147
- displayName: "Operation",
2148
- name: "operation",
2149
- type: "options",
2150
- displayOptions: {
2151
- show: {
2152
- resource: ["addressee"]
2153
- }
2154
- },
2155
- options: [
2156
- {
2157
- name: "Get Many",
2158
- value: "getAll",
2159
- description: "Retrieve a list of addressees",
2160
- action: "Get many addressees"
2161
- },
2162
- {
2163
- name: "Get",
2164
- value: "get",
2165
- description: "Retrieve a specific addressee",
2166
- action: "Get an addressee"
2167
- },
2168
- {
2169
- name: "Create",
2170
- value: "create",
2171
- description: "Create a new addressee",
2172
- action: "Create an addressee"
2173
- },
2174
- {
2175
- name: "Update",
2176
- value: "update",
2177
- description: "Update a specific addressee",
2178
- action: "Update an addressee"
2179
- },
2180
- {
2181
- name: "Get Deletion Log",
2182
- value: "getDeletionLog",
2183
- description: "Retrieve a list of deleted addressees",
2184
- action: "Get addressee deletion log"
2185
- }
2186
- ],
2187
- default: "getAll"
2188
- },
2189
- {
2190
- displayName: "Limit",
2191
- name: "top",
2192
- type: "number",
2193
- displayOptions: {
2194
- show: {
2195
- resource: ["client"],
2196
- operation: ["getAll", "getDeletionLog"]
2197
- }
2198
- },
2199
- typeOptions: {
2200
- minValue: 1
2201
- },
2202
- default: 100,
2203
- description: "Maximum number of records to return"
2204
- },
2205
- {
2206
- displayName: "Skip",
2207
- name: "skip",
2208
- type: "number",
2209
- displayOptions: {
2210
- show: {
2211
- resource: ["client"],
2212
- operation: ["getAll", "getDeletionLog"]
2213
- }
2214
- },
2215
- typeOptions: {
2216
- minValue: 0
2217
- },
2218
- default: 0,
2219
- description: "Number of records to skip from the start"
2220
- },
2221
- {
2222
- displayName: "Limit",
2223
- name: "top",
2224
- type: "number",
2225
- displayOptions: {
2226
- show: {
2227
- resource: ["taxAuthority", "relationship", "legalForm", "corporateStructure", "employee", "countryCode", "clientGroupType", "clientCategoryType", "bank", "areaOfResponsibility", "addressee"],
2228
- operation: ["getAll", "getDeletionLog"]
2229
- }
2230
- },
2231
- typeOptions: {
2232
- minValue: 1
2233
- },
2234
- default: 100,
2235
- description: "Maximum number of records to return"
2236
- },
2237
- {
2238
- displayName: "Skip",
2239
- name: "skip",
2240
- type: "number",
2241
- displayOptions: {
2242
- show: {
2243
- resource: ["taxAuthority", "relationship", "legalForm", "corporateStructure", "employee", "countryCode", "clientGroupType", "clientCategoryType", "bank", "areaOfResponsibility", "addressee"],
2244
- operation: ["getAll", "getDeletionLog"]
2245
- }
2246
- },
2247
- typeOptions: {
2248
- minValue: 0
2249
- },
2250
- default: 0,
2251
- description: "Number of records to skip from the start"
2252
- },
2253
- {
2254
- displayName: "Select Fields",
2255
- name: "select",
2256
- type: "string",
2257
- displayOptions: {
2258
- show: {
2259
- resource: ["client", "taxAuthority", "relationship", "legalForm", "corporateStructure", "employee", "countryCode", "clientGroupType", "clientCategoryType", "bank", "areaOfResponsibility", "addressee"],
2260
- operation: [
2261
- "getAll",
2262
- "get",
2263
- "getResponsibilities",
2264
- "getClientCategories",
2265
- "getClientGroups",
2266
- "getDeletionLog",
2267
- "getEstablishment",
2268
- "getTypes"
2269
- ]
2270
- }
2271
- },
2272
- default: "",
2273
- description: "Comma-separated list of fields to include in the response"
2274
- },
2275
- {
2276
- displayName: "Filter",
2277
- name: "filter",
2278
- type: "string",
2279
- displayOptions: {
2280
- show: {
2281
- resource: ["client", "taxAuthority", "relationship", "corporateStructure", "employee", "countryCode", "clientGroupType", "clientCategoryType", "bank", "areaOfResponsibility", "addressee"],
2282
- operation: ["getAll", "getDeletionLog", "getTypes"]
2283
- }
2284
- },
2285
- default: "",
2286
- description: "Filter expression as defined by the DATEV API"
2287
- },
2288
- {
2289
- displayName: "Client ID",
2290
- name: "clientId",
2291
- type: "string",
2292
- required: true,
2293
- displayOptions: {
2294
- show: {
2295
- resource: ["client"],
2296
- operation: [
2297
- "get",
2298
- "update",
2299
- "getResponsibilities",
2300
- "updateResponsibilities",
2301
- "getClientCategories",
2302
- "updateClientCategories",
2303
- "getClientGroups",
2304
- "updateClientGroups"
2305
- ]
2306
- }
2307
- },
2308
- default: ""
2309
- },
2310
- {
2311
- displayName: "Client Data",
2312
- name: "clientData",
2313
- type: "json",
2314
- displayOptions: {
2315
- show: {
2316
- resource: ["client"],
2317
- operation: ["create", "update"]
2318
- }
2319
- },
2320
- default: "{}",
2321
- description: "Client payload to send to the API"
2322
- },
2323
- {
2324
- displayName: "Max Number",
2325
- name: "maxNumber",
2326
- type: "number",
2327
- displayOptions: {
2328
- show: {
2329
- resource: ["client"],
2330
- operation: ["create"]
2331
- }
2332
- },
2333
- typeOptions: {
2334
- minValue: 1
2335
- },
2336
- default: 0,
2337
- description: "Optional max-number parameter when letting the API allocate a number"
2338
- },
2339
- {
2340
- displayName: "Responsibilities",
2341
- name: "responsibilitiesData",
2342
- type: "json",
2343
- displayOptions: {
2344
- show: {
2345
- resource: ["client"],
2346
- operation: ["updateResponsibilities"]
2347
- }
2348
- },
2349
- default: "[]",
2350
- description: "Array of responsibilities to set for the client"
2351
- },
2352
- {
2353
- displayName: "Client Categories",
2354
- name: "categoriesData",
2355
- type: "json",
2356
- displayOptions: {
2357
- show: {
2358
- resource: ["client"],
2359
- operation: ["updateClientCategories"]
2360
- }
2361
- },
2362
- default: "[]",
2363
- description: "Array of client categories to set for the client"
2364
- },
2365
- {
2366
- displayName: "Client Groups",
2367
- name: "groupsData",
2368
- type: "json",
2369
- displayOptions: {
2370
- show: {
2371
- resource: ["client"],
2372
- operation: ["updateClientGroups"]
2373
- }
2374
- },
2375
- default: "[]",
2376
- description: "Array of client groups to set for the client"
2377
- },
2378
- {
2379
- displayName: "Start Number",
2380
- name: "start",
2381
- type: "number",
2382
- displayOptions: {
2383
- show: {
2384
- resource: ["client"],
2385
- operation: ["getNextFreeNumber"]
2386
- }
2387
- },
2388
- typeOptions: {
2389
- minValue: 1
2390
- },
2391
- default: 1,
2392
- description: "Starting number for the search"
2393
- },
2394
- {
2395
- displayName: "Range",
2396
- name: "range",
2397
- type: "number",
2398
- displayOptions: {
2399
- show: {
2400
- resource: ["client"],
2401
- operation: ["getNextFreeNumber"]
2402
- }
2403
- },
2404
- typeOptions: {
2405
- minValue: 0
2406
- },
2407
- default: 0,
2408
- description: "Optional range for the next free number search"
2409
- },
2410
- {
2411
- displayName: "National Right",
2412
- name: "nationalRight",
2413
- type: "options",
2414
- displayOptions: {
2415
- show: {
2416
- resource: ["legalForm"],
2417
- operation: ["getAll"]
2418
- }
2419
- },
2420
- options: [
2421
- {
2422
- name: "German",
2423
- value: "german"
2424
- },
2425
- {
2426
- name: "Austrian",
2427
- value: "austrian"
2428
- }
2429
- ],
2430
- default: "",
2431
- description: "Filter legal forms by national law (German or Austrian)"
2432
- },
2433
- {
2434
- displayName: "Organization ID",
2435
- name: "organizationId",
2436
- type: "string",
2437
- required: true,
2438
- displayOptions: {
2439
- show: {
2440
- resource: ["corporateStructure"],
2441
- operation: ["get", "getEstablishment"]
2442
- }
2443
- },
2444
- default: "",
2445
- description: "The GUID of the organization"
2446
- },
2447
- {
2448
- displayName: "Establishment ID",
2449
- name: "establishmentId",
2450
- type: "string",
2451
- required: true,
2452
- displayOptions: {
2453
- show: {
2454
- resource: ["corporateStructure"],
2455
- operation: ["getEstablishment"]
2456
- }
2457
- },
2458
- default: "",
2459
- description: "The GUID of the establishment"
2460
- },
2461
- {
2462
- displayName: "Employee ID",
2463
- name: "employeeId",
2464
- type: "string",
2465
- required: true,
2466
- displayOptions: {
2467
- show: {
2468
- resource: ["employee"],
2469
- operation: ["get", "update"]
2470
- }
2471
- },
2472
- default: "",
2473
- description: "The GUID of the employee"
2474
- },
2475
- {
2476
- displayName: "Employee Data",
2477
- name: "employeeData",
2478
- type: "json",
2479
- displayOptions: {
2480
- show: {
2481
- resource: ["employee"],
2482
- operation: ["create", "update"]
2483
- }
2484
- },
2485
- default: "{}",
2486
- description: "Employee payload to send to the API"
2487
- },
2488
- {
2489
- displayName: "Addressee ID",
2490
- name: "addresseeId",
2491
- type: "string",
2492
- required: true,
2493
- displayOptions: {
2494
- show: {
2495
- resource: ["addressee"],
2496
- operation: ["get", "update"]
2497
- }
2498
- },
2499
- default: "",
2500
- description: "The GUID of the addressee"
2501
- },
2502
- {
2503
- displayName: "Addressee Data",
2504
- name: "addresseeData",
2505
- type: "json",
2506
- displayOptions: {
2507
- show: {
2508
- resource: ["addressee"],
2509
- operation: ["create", "update"]
2510
- }
2511
- },
2512
- default: "{}",
2513
- description: "Addressee payload to send to the API"
2514
- },
2515
- {
2516
- displayName: "National Right",
2517
- name: "nationalRight",
2518
- type: "options",
2519
- options: [
2520
- {
2521
- name: "German",
2522
- value: "german"
2523
- },
2524
- {
2525
- name: "Austrian",
2526
- value: "austrian"
2527
- }
2528
- ],
2529
- displayOptions: {
2530
- show: {
2531
- resource: ["addressee"],
2532
- operation: ["create"]
2533
- }
2534
- },
2535
- default: "",
2536
- description: "Parameter defines the national law that will be saved with the addressee"
2537
- },
2538
- {
2539
- displayName: "Expand",
2540
- name: "expand",
2541
- type: "string",
2542
- displayOptions: {
2543
- show: {
2544
- resource: ["addressee"],
2545
- operation: ["get"]
2546
- }
2547
- },
2548
- default: "",
2549
- description: "Parameter to include subordinate objects (e.g., 'detail,addresses' or '*' for all)"
2550
- },
2551
- {
2552
- displayName: "Client Group Type ID",
2553
- name: "clientGroupTypeId",
2554
- type: "string",
2555
- required: true,
2556
- displayOptions: {
2557
- show: {
2558
- resource: ["clientGroupType"],
2559
- operation: ["get", "update"]
2560
- }
2561
- },
2562
- default: "",
2563
- description: "The GUID of the client group type"
2564
- },
2565
- {
2566
- displayName: "Client Group Type Data",
2567
- name: "clientGroupTypeData",
2568
- type: "json",
2569
- displayOptions: {
2570
- show: {
2571
- resource: ["clientGroupType"],
2572
- operation: ["create", "update"]
2573
- }
2574
- },
2575
- default: "{}",
2576
- description: "Client group type payload to send to the API"
2577
- },
2578
- {
2579
- displayName: "Client Category Type ID",
2580
- name: "clientCategoryTypeId",
2581
- type: "string",
2582
- required: true,
2583
- displayOptions: {
2584
- show: {
2585
- resource: ["clientCategoryType"],
2586
- operation: ["get", "update"]
2587
- }
2588
- },
2589
- default: "",
2590
- description: "The GUID of the client category type"
2591
- },
2592
- {
2593
- displayName: "Client Category Type Data",
2594
- name: "clientCategoryTypeData",
2595
- type: "json",
2596
- displayOptions: {
2597
- show: {
2598
- resource: ["clientCategoryType"],
2599
- operation: ["create", "update"]
2600
- }
2601
- },
2602
- default: "{}",
2603
- description: "Client category type payload to send to the API"
2604
- }
2605
- ]
2606
- };
2607
-
2608
- // nodes/MasterData/handlers/ClientResourceHandler.ts
2609
- var import_n8n_workflow3 = require("n8n-workflow");
2610
-
2611
- // nodes/MasterData/handlers/BaseResourceHandler.ts
2612
- var import_n8n_workflow2 = require("n8n-workflow");
2613
-
2614
- // nodes/MasterData/utils.ts
2615
- var import_n8n_workflow = require("n8n-workflow");
2616
- function toErrorObject(error) {
2617
- if (error && typeof error === "object") {
2618
- return error;
2619
- }
2620
- const message = error instanceof Error ? error.message : String(error ?? "Unknown error");
2621
- return { message };
2622
- }
2623
- function toErrorMessage(error) {
2624
- if (error instanceof Error) {
2625
- return error.message;
2626
- }
2627
- if (error === null || error === undefined) {
2628
- return "Unknown error";
2629
- }
2630
- return typeof error === "string" ? error : JSON.stringify(error);
2631
- }
2632
- function normaliseToObjects(data) {
2633
- if (Array.isArray(data)) {
2634
- return data.map((entry) => {
2635
- if (entry && typeof entry === "object") {
2636
- return entry;
2637
- }
2638
- return { value: entry ?? null };
2639
- });
2640
- }
2641
- if (data && typeof data === "object") {
2642
- return [data];
2643
- }
2644
- return [{ value: data ?? null }];
2645
- }
2646
- function parseJsonParameter(rawValue, parameterLabel, context, itemIndex) {
2647
- if (rawValue === null || rawValue === undefined) {
2648
- throw new import_n8n_workflow.NodeOperationError(context.getNode(), `Parameter "${parameterLabel}" must be provided.`, { itemIndex });
2649
- }
2650
- if (typeof rawValue === "string") {
2651
- try {
2652
- return JSON.parse(rawValue);
2653
- } catch (error) {
2654
- throw new import_n8n_workflow.NodeOperationError(context.getNode(), `Parameter "${parameterLabel}" contains invalid JSON: ${toErrorMessage(error)}`, { itemIndex });
2655
- }
2656
- }
2657
- return rawValue;
2658
- }
2659
- function getOptionalString(context, name, itemIndex) {
2660
- const value = context.getNodeParameter(name, itemIndex, "");
2661
- if (typeof value !== "string" || value.trim().length === 0) {
2662
- return;
2663
- }
2664
- return value;
2665
- }
2666
- function getRequiredString(context, name, itemIndex) {
2667
- const value = context.getNodeParameter(name, itemIndex);
2668
- if (typeof value !== "string" || value.trim().length === 0) {
2669
- throw new import_n8n_workflow.NodeOperationError(context.getNode(), `Parameter "${name}" is required.`, { itemIndex });
2670
- }
2671
- return value;
2672
- }
2673
- function getNumberParameter(context, name, itemIndex, defaultValue) {
2674
- return context.getNodeParameter(name, itemIndex, defaultValue);
2675
- }
2676
-
2677
- // nodes/MasterData/handlers/BaseResourceHandler.ts
2678
- class BaseResourceHandler {
2679
- context;
2680
- itemIndex;
2681
- constructor(context, itemIndex) {
2682
- this.context = context;
2683
- this.itemIndex = itemIndex;
2684
- }
2685
- async getCredentials() {
2686
- const credentials = await this.context.getCredentials("datevConnectApi");
2687
- if (!credentials) {
2688
- throw new import_n8n_workflow2.NodeOperationError(this.context.getNode(), "DATEVconnect credentials are missing");
2689
- }
2690
- const { host, email, password, clientInstanceId } = credentials;
2691
- if (!host || !email || !password || !clientInstanceId) {
2692
- throw new import_n8n_workflow2.NodeOperationError(this.context.getNode(), "All DATEVconnect credential fields must be provided");
2693
- }
2694
- return credentials;
2695
- }
2696
- createAuthContext(credentials, token) {
2697
- return {
2698
- host: credentials.host,
2699
- token,
2700
- clientInstanceId: credentials.clientInstanceId
2701
- };
2702
- }
2703
- getOptionalString(name) {
2704
- return getOptionalString(this.context, name, this.itemIndex);
2705
- }
2706
- getRequiredString(name) {
2707
- return getRequiredString(this.context, name, this.itemIndex);
2708
- }
2709
- getNumberParameter(name, defaultValue) {
2710
- return getNumberParameter(this.context, name, this.itemIndex, defaultValue);
2711
- }
2712
- parseJsonParameter(rawValue, parameterLabel) {
2713
- return parseJsonParameter(rawValue, parameterLabel, this.context, this.itemIndex);
2714
- }
2715
- createSendSuccess(returnData) {
2716
- return (payload) => {
2717
- const formattedItems = normaliseToObjects(payload ?? { success: true });
2718
- const executionData = this.context.helpers.constructExecutionMetaData(this.context.helpers.returnJsonArray(formattedItems), { itemData: { item: this.itemIndex } });
2719
- returnData.push(...executionData);
2720
- };
2721
- }
2722
- handleError(error, returnData) {
2723
- if (this.context.continueOnFail()) {
2724
- returnData.push({
2725
- json: {
2726
- error: toErrorMessage(error)
2727
- },
2728
- pairedItem: { item: this.itemIndex }
2729
- });
2730
- return;
2731
- }
2732
- throw new import_n8n_workflow2.NodeApiError(this.context.getNode(), toErrorObject(error), {
2733
- itemIndex: this.itemIndex
2734
- });
2735
- }
2736
- }
2737
-
2738
- // nodes/MasterData/handlers/ClientResourceHandler.ts
2739
- class ClientResourceHandler extends BaseResourceHandler {
2740
- async execute(operation, authContext, returnData) {
2741
- const sendSuccess = this.createSendSuccess(returnData);
2742
- try {
2743
- let response;
2744
- switch (operation) {
2745
- case "getAll":
2746
- response = await this.handleGetAll(authContext);
2747
- break;
2748
- case "get":
2749
- response = await this.handleGet(authContext);
2750
- break;
2751
- case "create":
2752
- response = await this.handleCreate(authContext);
2753
- break;
2754
- case "update":
2755
- response = await this.handleUpdate(authContext);
2756
- break;
2757
- case "getResponsibilities":
2758
- response = await this.handleGetResponsibilities(authContext);
2759
- break;
2760
- case "updateResponsibilities":
2761
- response = await this.handleUpdateResponsibilities(authContext);
2762
- break;
2763
- case "getClientCategories":
2764
- response = await this.handleGetClientCategories(authContext);
2765
- break;
2766
- case "updateClientCategories":
2767
- response = await this.handleUpdateClientCategories(authContext);
2768
- break;
2769
- case "getClientGroups":
2770
- response = await this.handleGetClientGroups(authContext);
2771
- break;
2772
- case "updateClientGroups":
2773
- response = await this.handleUpdateClientGroups(authContext);
2774
- break;
2775
- case "getDeletionLog":
2776
- response = await this.handleGetDeletionLog(authContext);
2777
- break;
2778
- case "getNextFreeNumber":
2779
- response = await this.handleGetNextFreeNumber(authContext);
2780
- break;
2781
- default:
2782
- throw new import_n8n_workflow3.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "client".`, { itemIndex: this.itemIndex });
2783
- }
2784
- sendSuccess(response);
2785
- } catch (error) {
2786
- this.handleError(error, returnData);
2787
- }
2788
- }
2789
- async handleGetAll(authContext) {
2790
- const top = this.getNumberParameter("top", 100);
2791
- const skip = this.getNumberParameter("skip", 0);
2792
- const select = this.getOptionalString("select");
2793
- const filter = this.getOptionalString("filter");
2794
- return await fetchClients({
2795
- ...authContext,
2796
- top,
2797
- skip,
2798
- select,
2799
- filter
2800
- });
2801
- }
2802
- async handleGet(authContext) {
2803
- const clientId = this.getRequiredString("clientId");
2804
- const select = this.getOptionalString("select");
2805
- return await fetchClient({
2806
- ...authContext,
2807
- clientId,
2808
- select
2809
- });
2810
- }
2811
- async handleCreate(authContext) {
2812
- const rawClient = this.context.getNodeParameter("clientData", this.itemIndex);
2813
- const clientPayload = this.parseJsonParameter(rawClient, "Client Data");
2814
- const maxNumber = this.getNumberParameter("maxNumber", 0);
2815
- return await createClient({
2816
- ...authContext,
2817
- client: clientPayload,
2818
- maxNumber: typeof maxNumber === "number" && maxNumber > 0 ? maxNumber : undefined
2819
- });
2820
- }
2821
- async handleUpdate(authContext) {
2822
- const clientId = this.getRequiredString("clientId");
2823
- const rawClient = this.context.getNodeParameter("clientData", this.itemIndex);
2824
- const clientPayload = this.parseJsonParameter(rawClient, "Client Data");
2825
- return await updateClient({
2826
- ...authContext,
2827
- clientId,
2828
- client: clientPayload
2829
- });
2830
- }
2831
- async handleGetResponsibilities(authContext) {
2832
- const clientId = this.getRequiredString("clientId");
2833
- const select = this.getOptionalString("select");
2834
- return await fetchClientResponsibilities({
2835
- ...authContext,
2836
- clientId,
2837
- select
2838
- });
2839
- }
2840
- async handleUpdateResponsibilities(authContext) {
2841
- const clientId = this.getRequiredString("clientId");
2842
- const rawResponsibilities = this.context.getNodeParameter("responsibilitiesData", this.itemIndex);
2843
- const responsibilitiesPayload = this.parseJsonParameter(rawResponsibilities, "Responsibilities");
2844
- return await updateClientResponsibilities({
2845
- ...authContext,
2846
- clientId,
2847
- responsibilities: responsibilitiesPayload
2848
- });
2849
- }
2850
- async handleGetClientCategories(authContext) {
2851
- const clientId = this.getRequiredString("clientId");
2852
- const select = this.getOptionalString("select");
2853
- return await fetchClientCategories({
2854
- ...authContext,
2855
- clientId,
2856
- select
2857
- });
2858
- }
2859
- async handleUpdateClientCategories(authContext) {
2860
- const clientId = this.getRequiredString("clientId");
2861
- const rawCategories = this.context.getNodeParameter("categoriesData", this.itemIndex);
2862
- const categoriesPayload = this.parseJsonParameter(rawCategories, "Client Categories");
2863
- return await updateClientCategories({
2864
- ...authContext,
2865
- clientId,
2866
- categories: categoriesPayload
2867
- });
2868
- }
2869
- async handleGetClientGroups(authContext) {
2870
- const clientId = this.getRequiredString("clientId");
2871
- const select = this.getOptionalString("select");
2872
- return await fetchClientGroups({
2873
- ...authContext,
2874
- clientId,
2875
- select
2876
- });
2877
- }
2878
- async handleUpdateClientGroups(authContext) {
2879
- const clientId = this.getRequiredString("clientId");
2880
- const rawGroups = this.context.getNodeParameter("groupsData", this.itemIndex);
2881
- const groupsPayload = this.parseJsonParameter(rawGroups, "Client Groups");
2882
- return await updateClientGroups({
2883
- ...authContext,
2884
- clientId,
2885
- groups: groupsPayload
2886
- });
2887
- }
2888
- async handleGetDeletionLog(authContext) {
2889
- const top = this.getNumberParameter("top", 100);
2890
- const skip = this.getNumberParameter("skip", 0);
2891
- const select = this.getOptionalString("select");
2892
- const filter = this.getOptionalString("filter");
2893
- return await fetchClientDeletionLog({
2894
- ...authContext,
2895
- top,
2896
- skip,
2897
- select,
2898
- filter
2899
- });
2900
- }
2901
- async handleGetNextFreeNumber(authContext) {
2902
- const start = this.getNumberParameter("start", 1);
2903
- const range = this.getNumberParameter("range", 0);
2904
- return await fetchNextFreeClientNumber({
2905
- ...authContext,
2906
- start,
2907
- range: typeof range === "number" && range > 0 ? range : undefined
2908
- });
2909
- }
2910
- }
2911
-
2912
- // nodes/MasterData/handlers/TaxAuthorityResourceHandler.ts
2913
- var import_n8n_workflow4 = require("n8n-workflow");
2914
- class TaxAuthorityResourceHandler extends BaseResourceHandler {
2915
- async execute(operation, authContext, returnData) {
2916
- const sendSuccess = this.createSendSuccess(returnData);
2917
- try {
2918
- let response;
2919
- switch (operation) {
2920
- case "getAll":
2921
- response = await this.handleGetAll(authContext);
2922
- break;
2923
- default:
2924
- throw new import_n8n_workflow4.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "taxAuthority".`, { itemIndex: this.itemIndex });
2925
- }
2926
- sendSuccess(response);
2927
- } catch (error) {
2928
- this.handleError(error, returnData);
2929
- }
2930
- }
2931
- async handleGetAll(authContext) {
2932
- const top = this.getNumberParameter("top", 100);
2933
- const skip = this.getNumberParameter("skip", 0);
2934
- const select = this.getOptionalString("select");
2935
- const filter = this.getOptionalString("filter");
2936
- return await fetchTaxAuthorities({
2937
- ...authContext,
2938
- top,
2939
- skip,
2940
- select,
2941
- filter
2942
- });
2943
- }
2944
- }
2945
-
2946
- // nodes/MasterData/handlers/RelationshipResourceHandler.ts
2947
- var import_n8n_workflow5 = require("n8n-workflow");
2948
- class RelationshipResourceHandler extends BaseResourceHandler {
2949
- async execute(operation, authContext, returnData) {
2950
- const sendSuccess = this.createSendSuccess(returnData);
2951
- try {
2952
- let response;
2953
- switch (operation) {
2954
- case "getAll":
2955
- response = await this.handleGetAll(authContext);
2956
- break;
2957
- case "getTypes":
2958
- response = await this.handleGetTypes(authContext);
2959
- break;
2960
- default:
2961
- throw new import_n8n_workflow5.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "relationship".`, { itemIndex: this.itemIndex });
2962
- }
2963
- sendSuccess(response);
2964
- } catch (error) {
2965
- this.handleError(error, returnData);
2966
- }
2967
- }
2968
- async handleGetAll(authContext) {
2969
- const top = this.getNumberParameter("top", 100);
2970
- const skip = this.getNumberParameter("skip", 0);
2971
- const select = this.getOptionalString("select");
2972
- const filter = this.getOptionalString("filter");
2973
- return await fetchRelationships({
2974
- ...authContext,
2975
- top,
2976
- skip,
2977
- select,
2978
- filter
2979
- });
2980
- }
2981
- async handleGetTypes(authContext) {
2982
- const select = this.getOptionalString("select");
2983
- const filter = this.getOptionalString("filter");
2984
- return await fetchRelationshipTypes({
2985
- ...authContext,
2986
- select,
2987
- filter
2988
- });
2989
- }
2990
- }
2991
-
2992
- // nodes/MasterData/handlers/LegalFormResourceHandler.ts
2993
- var import_n8n_workflow6 = require("n8n-workflow");
2994
- class LegalFormResourceHandler extends BaseResourceHandler {
2995
- async execute(operation, authContext, returnData) {
2996
- const sendSuccess = this.createSendSuccess(returnData);
2997
- try {
2998
- let response;
2999
- switch (operation) {
3000
- case "getAll":
3001
- response = await this.handleGetAll(authContext);
3002
- break;
3003
- default:
3004
- throw new import_n8n_workflow6.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "legalForm".`, { itemIndex: this.itemIndex });
3005
- }
3006
- sendSuccess(response);
3007
- } catch (error) {
3008
- this.handleError(error, returnData);
3009
- }
3010
- }
3011
- async handleGetAll(authContext) {
3012
- const top = this.getNumberParameter("top", 100);
3013
- const skip = this.getNumberParameter("skip", 0);
3014
- const select = this.getOptionalString("select");
3015
- const nationalRight = this.getOptionalString("nationalRight");
3016
- return await fetchLegalForms({
3017
- ...authContext,
3018
- top,
3019
- skip,
3020
- select,
3021
- nationalRight
3022
- });
3023
- }
3024
- }
3025
-
3026
- // nodes/MasterData/handlers/CorporateStructureResourceHandler.ts
3027
- var import_n8n_workflow7 = require("n8n-workflow");
3028
- class CorporateStructureResourceHandler extends BaseResourceHandler {
3029
- async execute(operation, authContext, returnData) {
3030
- const sendSuccess = this.createSendSuccess(returnData);
3031
- try {
3032
- let response;
3033
- switch (operation) {
3034
- case "getAll":
3035
- response = await this.handleGetAll(authContext);
3036
- break;
3037
- case "get":
3038
- response = await this.handleGet(authContext);
3039
- break;
3040
- case "getEstablishment":
3041
- response = await this.handleGetEstablishment(authContext);
3042
- break;
3043
- default:
3044
- throw new import_n8n_workflow7.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "corporateStructure".`, { itemIndex: this.itemIndex });
3045
- }
3046
- sendSuccess(response);
3047
- } catch (error) {
3048
- this.handleError(error, returnData);
3049
- }
3050
- }
3051
- async handleGetAll(authContext) {
3052
- const top = this.getNumberParameter("top", 100);
3053
- const skip = this.getNumberParameter("skip", 0);
3054
- const select = this.getOptionalString("select");
3055
- const filter = this.getOptionalString("filter");
3056
- return await fetchCorporateStructures({
3057
- ...authContext,
3058
- top,
3059
- skip,
3060
- select,
3061
- filter
3062
- });
3063
- }
3064
- async handleGet(authContext) {
3065
- const organizationId = this.getRequiredString("organizationId");
3066
- const select = this.getOptionalString("select");
3067
- return await fetchCorporateStructure({
3068
- ...authContext,
3069
- organizationId,
3070
- select
3071
- });
3072
- }
3073
- async handleGetEstablishment(authContext) {
3074
- const organizationId = this.getRequiredString("organizationId");
3075
- const establishmentId = this.getRequiredString("establishmentId");
3076
- const select = this.getOptionalString("select");
3077
- return await fetchEstablishment({
3078
- ...authContext,
3079
- organizationId,
3080
- establishmentId,
3081
- select
3082
- });
3083
- }
3084
- }
3085
-
3086
- // nodes/MasterData/handlers/EmployeeResourceHandler.ts
3087
- var import_n8n_workflow8 = require("n8n-workflow");
3088
- class EmployeeResourceHandler extends BaseResourceHandler {
3089
- async execute(operation, authContext, returnData) {
3090
- const sendSuccess = this.createSendSuccess(returnData);
3091
- try {
3092
- let response;
3093
- switch (operation) {
3094
- case "getAll":
3095
- response = await this.handleGetAll(authContext);
3096
- break;
3097
- case "get":
3098
- response = await this.handleGet(authContext);
3099
- break;
3100
- case "create":
3101
- response = await this.handleCreate(authContext);
3102
- break;
3103
- case "update":
3104
- response = await this.handleUpdate(authContext);
3105
- break;
3106
- default:
3107
- throw new import_n8n_workflow8.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "employee".`, { itemIndex: this.itemIndex });
3108
- }
3109
- sendSuccess(response);
3110
- } catch (error) {
3111
- this.handleError(error, returnData);
3112
- }
3113
- }
3114
- async handleGetAll(authContext) {
3115
- const top = this.getNumberParameter("top", 100);
3116
- const skip = this.getNumberParameter("skip", 0);
3117
- const select = this.getOptionalString("select");
3118
- const filter = this.getOptionalString("filter");
3119
- return await fetchEmployees({
3120
- ...authContext,
3121
- top,
3122
- skip,
3123
- select,
3124
- filter
3125
- });
3126
- }
3127
- async handleGet(authContext) {
3128
- const employeeId = this.getRequiredString("employeeId");
3129
- const select = this.getOptionalString("select");
3130
- return await fetchEmployee({
3131
- ...authContext,
3132
- employeeId,
3133
- select
3134
- });
3135
- }
3136
- async handleCreate(authContext) {
3137
- const rawEmployee = this.context.getNodeParameter("employeeData", this.itemIndex);
3138
- const employeePayload = this.parseJsonParameter(rawEmployee, "Employee Data");
3139
- return await createEmployee({
3140
- ...authContext,
3141
- employee: employeePayload
3142
- });
3143
- }
3144
- async handleUpdate(authContext) {
3145
- const employeeId = this.getRequiredString("employeeId");
3146
- const rawEmployee = this.context.getNodeParameter("employeeData", this.itemIndex);
3147
- const employeePayload = this.parseJsonParameter(rawEmployee, "Employee Data");
3148
- return await updateEmployee({
3149
- ...authContext,
3150
- employeeId,
3151
- employee: employeePayload
3152
- });
3153
- }
3154
- }
3155
-
3156
- // nodes/MasterData/handlers/CountryCodeResourceHandler.ts
3157
- var import_n8n_workflow9 = require("n8n-workflow");
3158
- class CountryCodeResourceHandler extends BaseResourceHandler {
3159
- async execute(operation, authContext, returnData) {
3160
- const sendSuccess = this.createSendSuccess(returnData);
3161
- try {
3162
- let response;
3163
- switch (operation) {
3164
- case "getAll":
3165
- response = await this.handleGetAll(authContext);
3166
- break;
3167
- default:
3168
- throw new import_n8n_workflow9.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "countryCode".`, { itemIndex: this.itemIndex });
3169
- }
3170
- sendSuccess(response);
3171
- } catch (error) {
3172
- this.handleError(error, returnData);
3173
- }
3174
- }
3175
- async handleGetAll(authContext) {
3176
- const top = this.getNumberParameter("top", 100);
3177
- const skip = this.getNumberParameter("skip", 0);
3178
- const select = this.getOptionalString("select");
3179
- const filter = this.getOptionalString("filter");
3180
- return await fetchCountryCodes({
3181
- ...authContext,
3182
- top,
3183
- skip,
3184
- select,
3185
- filter
3186
- });
3187
- }
3188
- }
3189
-
3190
- // nodes/MasterData/handlers/ClientGroupTypeResourceHandler.ts
3191
- var import_n8n_workflow10 = require("n8n-workflow");
3192
- class ClientGroupTypeResourceHandler extends BaseResourceHandler {
3193
- async execute(operation, authContext, returnData) {
3194
- const sendSuccess = this.createSendSuccess(returnData);
3195
- try {
3196
- let response;
3197
- switch (operation) {
3198
- case "getAll":
3199
- response = await this.handleGetAll(authContext);
3200
- break;
3201
- case "get":
3202
- response = await this.handleGet(authContext);
3203
- break;
3204
- case "create":
3205
- response = await this.handleCreate(authContext);
3206
- break;
3207
- case "update":
3208
- response = await this.handleUpdate(authContext);
3209
- break;
3210
- default:
3211
- throw new import_n8n_workflow10.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "clientGroupType".`, { itemIndex: this.itemIndex });
3212
- }
3213
- sendSuccess(response);
3214
- } catch (error) {
3215
- this.handleError(error, returnData);
3216
- }
3217
- }
3218
- async handleGetAll(authContext) {
3219
- const top = this.getNumberParameter("top", 100);
3220
- const skip = this.getNumberParameter("skip", 0);
3221
- const select = this.getOptionalString("select");
3222
- const filter = this.getOptionalString("filter");
3223
- return await fetchClientGroupTypes({
3224
- ...authContext,
3225
- top,
3226
- skip,
3227
- select,
3228
- filter
3229
- });
3230
- }
3231
- async handleGet(authContext) {
3232
- const clientGroupTypeId = this.getRequiredString("clientGroupTypeId");
3233
- const select = this.getOptionalString("select");
3234
- return await fetchClientGroupType({
3235
- ...authContext,
3236
- clientGroupTypeId,
3237
- select
3238
- });
3239
- }
3240
- async handleCreate(authContext) {
3241
- const rawClientGroupType = this.context.getNodeParameter("clientGroupTypeData", this.itemIndex);
3242
- const clientGroupTypePayload = this.parseJsonParameter(rawClientGroupType, "Client Group Type Data");
3243
- return await createClientGroupType({
3244
- ...authContext,
3245
- clientGroupType: clientGroupTypePayload
3246
- });
3247
- }
3248
- async handleUpdate(authContext) {
3249
- const clientGroupTypeId = this.getRequiredString("clientGroupTypeId");
3250
- const rawClientGroupType = this.context.getNodeParameter("clientGroupTypeData", this.itemIndex);
3251
- const clientGroupTypePayload = this.parseJsonParameter(rawClientGroupType, "Client Group Type Data");
3252
- return await updateClientGroupType({
3253
- ...authContext,
3254
- clientGroupTypeId,
3255
- clientGroupType: clientGroupTypePayload
3256
- });
3257
- }
3258
- }
3259
-
3260
- // nodes/MasterData/handlers/ClientCategoryTypeResourceHandler.ts
3261
- var import_n8n_workflow11 = require("n8n-workflow");
3262
- class ClientCategoryTypeResourceHandler extends BaseResourceHandler {
3263
- async execute(operation, authContext, returnData) {
3264
- const sendSuccess = this.createSendSuccess(returnData);
3265
- try {
3266
- let response;
3267
- switch (operation) {
3268
- case "getAll":
3269
- response = await this.handleGetAll(authContext);
3270
- break;
3271
- case "get":
3272
- response = await this.handleGet(authContext);
3273
- break;
3274
- case "create":
3275
- response = await this.handleCreate(authContext);
3276
- break;
3277
- case "update":
3278
- response = await this.handleUpdate(authContext);
3279
- break;
3280
- default:
3281
- throw new import_n8n_workflow11.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "clientCategoryType".`, { itemIndex: this.itemIndex });
3282
- }
3283
- sendSuccess(response);
3284
- } catch (error) {
3285
- this.handleError(error, returnData);
3286
- }
3287
- }
3288
- async handleGetAll(authContext) {
3289
- const top = this.getNumberParameter("top", 100);
3290
- const skip = this.getNumberParameter("skip", 0);
3291
- const select = this.getOptionalString("select");
3292
- const filter = this.getOptionalString("filter");
3293
- return await fetchClientCategoryTypes({
3294
- ...authContext,
3295
- top,
3296
- skip,
3297
- select,
3298
- filter
3299
- });
3300
- }
3301
- async handleGet(authContext) {
3302
- const clientCategoryTypeId = this.getRequiredString("clientCategoryTypeId");
3303
- const select = this.getOptionalString("select");
3304
- return await fetchClientCategoryType({
3305
- ...authContext,
3306
- clientCategoryTypeId,
3307
- select
3308
- });
3309
- }
3310
- async handleCreate(authContext) {
3311
- const rawClientCategoryType = this.context.getNodeParameter("clientCategoryTypeData", this.itemIndex);
3312
- const clientCategoryTypePayload = this.parseJsonParameter(rawClientCategoryType, "Client Category Type Data");
3313
- return await createClientCategoryType({
3314
- ...authContext,
3315
- clientCategoryType: clientCategoryTypePayload
3316
- });
3317
- }
3318
- async handleUpdate(authContext) {
3319
- const clientCategoryTypeId = this.getRequiredString("clientCategoryTypeId");
3320
- const rawClientCategoryType = this.context.getNodeParameter("clientCategoryTypeData", this.itemIndex);
3321
- const clientCategoryTypePayload = this.parseJsonParameter(rawClientCategoryType, "Client Category Type Data");
3322
- return await updateClientCategoryType({
3323
- ...authContext,
3324
- clientCategoryTypeId,
3325
- clientCategoryType: clientCategoryTypePayload
3326
- });
3327
- }
3328
- }
3329
-
3330
- // nodes/MasterData/handlers/BankResourceHandler.ts
3331
- var import_n8n_workflow12 = require("n8n-workflow");
3332
- class BankResourceHandler extends BaseResourceHandler {
3333
- async execute(operation, authContext, returnData) {
3334
- const sendSuccess = this.createSendSuccess(returnData);
3335
- try {
3336
- let response;
3337
- switch (operation) {
3338
- case "getAll":
3339
- response = await this.handleGetAll(authContext);
3340
- break;
3341
- default:
3342
- throw new import_n8n_workflow12.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "bank".`, { itemIndex: this.itemIndex });
3343
- }
3344
- sendSuccess(response);
3345
- } catch (error) {
3346
- this.handleError(error, returnData);
3347
- }
3348
- }
3349
- async handleGetAll(authContext) {
3350
- const top = this.getNumberParameter("top", 100);
3351
- const skip = this.getNumberParameter("skip", 0);
3352
- const select = this.getOptionalString("select");
3353
- const filter = this.getOptionalString("filter");
3354
- return await fetchBanks({
3355
- ...authContext,
3356
- top,
3357
- skip,
3358
- select,
3359
- filter
3360
- });
3361
- }
3362
- }
3363
-
3364
- // nodes/MasterData/handlers/AreaOfResponsibilityResourceHandler.ts
3365
- var import_n8n_workflow13 = require("n8n-workflow");
3366
- class AreaOfResponsibilityResourceHandler extends BaseResourceHandler {
3367
- async execute(operation, authContext, returnData) {
3368
- const sendSuccess = this.createSendSuccess(returnData);
3369
- try {
3370
- let response;
3371
- switch (operation) {
3372
- case "getAll":
3373
- response = await this.handleGetAll(authContext);
3374
- break;
3375
- default:
3376
- throw new import_n8n_workflow13.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "areaOfResponsibility".`, { itemIndex: this.itemIndex });
3377
- }
3378
- sendSuccess(response);
3379
- } catch (error) {
3380
- this.handleError(error, returnData);
3381
- }
3382
- }
3383
- async handleGetAll(authContext) {
3384
- const top = this.getNumberParameter("top", 100);
3385
- const skip = this.getNumberParameter("skip", 0);
3386
- const select = this.getOptionalString("select");
3387
- const filter = this.getOptionalString("filter");
3388
- return await fetchAreaOfResponsibilities({
3389
- ...authContext,
3390
- top,
3391
- skip,
3392
- select,
3393
- filter
3394
- });
3395
- }
3396
- }
3397
-
3398
- // nodes/MasterData/handlers/AddresseeResourceHandler.ts
3399
- var import_n8n_workflow14 = require("n8n-workflow");
3400
- class AddresseeResourceHandler extends BaseResourceHandler {
3401
- async execute(operation, authContext, returnData) {
3402
- const sendSuccess = this.createSendSuccess(returnData);
3403
- try {
3404
- let response;
3405
- switch (operation) {
3406
- case "getAll":
3407
- response = await this.handleGetAll(authContext);
3408
- break;
3409
- case "get":
3410
- response = await this.handleGet(authContext);
3411
- break;
3412
- case "create":
3413
- response = await this.handleCreate(authContext);
3414
- break;
3415
- case "update":
3416
- response = await this.handleUpdate(authContext);
3417
- break;
3418
- case "getDeletionLog":
3419
- response = await this.handleGetDeletionLog(authContext);
3420
- break;
3421
- default:
3422
- throw new import_n8n_workflow14.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resource "addressee".`, { itemIndex: this.itemIndex });
3423
- }
3424
- sendSuccess(response);
3425
- } catch (error) {
3426
- this.handleError(error, returnData);
3427
- }
3428
- }
3429
- async handleGetAll(authContext) {
3430
- const top = this.getNumberParameter("top", 100);
3431
- const skip = this.getNumberParameter("skip", 0);
3432
- const select = this.getOptionalString("select");
3433
- const filter = this.getOptionalString("filter");
3434
- return await fetchAddressees({
3435
- ...authContext,
3436
- top,
3437
- skip,
3438
- select,
3439
- filter
3440
- });
3441
- }
3442
- async handleGet(authContext) {
3443
- const addresseeId = this.getRequiredString("addresseeId");
3444
- const select = this.getOptionalString("select");
3445
- const expand = this.getOptionalString("expand");
3446
- return await fetchAddressee({
3447
- ...authContext,
3448
- addresseeId,
3449
- select,
3450
- expand
3451
- });
3452
- }
3453
- async handleCreate(authContext) {
3454
- const rawAddressee = this.context.getNodeParameter("addresseeData", this.itemIndex);
3455
- const addresseePayload = this.parseJsonParameter(rawAddressee, "Addressee Data");
3456
- const nationalRight = this.getOptionalString("nationalRight");
3457
- return await createAddressee({
3458
- ...authContext,
3459
- addressee: addresseePayload,
3460
- nationalRight
3461
- });
3462
- }
3463
- async handleUpdate(authContext) {
3464
- const addresseeId = this.getRequiredString("addresseeId");
3465
- const rawAddressee = this.context.getNodeParameter("addresseeData", this.itemIndex);
3466
- const addresseePayload = this.parseJsonParameter(rawAddressee, "Addressee Data");
3467
- return await updateAddressee({
3468
- ...authContext,
3469
- addresseeId,
3470
- addressee: addresseePayload
3471
- });
3472
- }
3473
- async handleGetDeletionLog(authContext) {
3474
- const top = this.getNumberParameter("top", 100);
3475
- const skip = this.getNumberParameter("skip", 0);
3476
- const select = this.getOptionalString("select");
3477
- const filter = this.getOptionalString("filter");
3478
- return await fetchAddresseesDeletionLog({
3479
- ...authContext,
3480
- top,
3481
- skip,
3482
- select,
3483
- filter
3484
- });
3485
- }
3486
- }
3487
-
3488
- // nodes/MasterData/MasterData.node.ts
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MasterData = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const datevConnectClient_1 = require("../../src/services/datevConnectClient");
6
+ const MasterData_config_1 = require("./MasterData.config");
7
+ const ClientResourceHandler_1 = require("./handlers/ClientResourceHandler");
8
+ const TaxAuthorityResourceHandler_1 = require("./handlers/TaxAuthorityResourceHandler");
9
+ const RelationshipResourceHandler_1 = require("./handlers/RelationshipResourceHandler");
10
+ const LegalFormResourceHandler_1 = require("./handlers/LegalFormResourceHandler");
11
+ const CorporateStructureResourceHandler_1 = require("./handlers/CorporateStructureResourceHandler");
12
+ const EmployeeResourceHandler_1 = require("./handlers/EmployeeResourceHandler");
13
+ const CountryCodeResourceHandler_1 = require("./handlers/CountryCodeResourceHandler");
14
+ const ClientGroupTypeResourceHandler_1 = require("./handlers/ClientGroupTypeResourceHandler");
15
+ const ClientCategoryTypeResourceHandler_1 = require("./handlers/ClientCategoryTypeResourceHandler");
16
+ const BankResourceHandler_1 = require("./handlers/BankResourceHandler");
17
+ const AreaOfResponsibilityResourceHandler_1 = require("./handlers/AreaOfResponsibilityResourceHandler");
18
+ const AddresseeResourceHandler_1 = require("./handlers/AddresseeResourceHandler");
19
+ const utils_1 = require("./utils");
3489
20
  class MasterData {
3490
- description = masterDataNodeDescription;
3491
- async execute() {
3492
- const items = this.getInputData();
3493
- const returnData = [];
3494
- const credentials = await this.getCredentials("datevConnectApi");
3495
- if (!credentials) {
3496
- throw new import_n8n_workflow15.NodeOperationError(this.getNode(), "DATEVconnect credentials are missing");
3497
- }
3498
- const { host, email, password, clientInstanceId } = credentials;
3499
- if (!host || !email || !password || !clientInstanceId) {
3500
- throw new import_n8n_workflow15.NodeOperationError(this.getNode(), "All DATEVconnect credential fields must be provided");
3501
- }
3502
- let token;
3503
- try {
3504
- const authResponse = await authenticate({
3505
- host,
3506
- email,
3507
- password
3508
- });
3509
- token = authResponse.access_token;
3510
- } catch (error) {
3511
- throw new import_n8n_workflow15.NodeApiError(this.getNode(), toErrorObject(error));
3512
- }
3513
- const authContext = { host, token, clientInstanceId };
3514
- for (let itemIndex = 0;itemIndex < items.length; itemIndex++) {
3515
- const resource = this.getNodeParameter("resource", itemIndex);
3516
- const operation = this.getNodeParameter("operation", itemIndex);
3517
- let handler;
3518
- switch (resource) {
3519
- case "client":
3520
- handler = new ClientResourceHandler(this, itemIndex);
3521
- break;
3522
- case "taxAuthority":
3523
- handler = new TaxAuthorityResourceHandler(this, itemIndex);
3524
- break;
3525
- case "relationship":
3526
- handler = new RelationshipResourceHandler(this, itemIndex);
3527
- break;
3528
- case "legalForm":
3529
- handler = new LegalFormResourceHandler(this, itemIndex);
3530
- break;
3531
- case "corporateStructure":
3532
- handler = new CorporateStructureResourceHandler(this, itemIndex);
3533
- break;
3534
- case "employee":
3535
- handler = new EmployeeResourceHandler(this, itemIndex);
3536
- break;
3537
- case "countryCode":
3538
- handler = new CountryCodeResourceHandler(this, itemIndex);
3539
- break;
3540
- case "clientGroupType":
3541
- handler = new ClientGroupTypeResourceHandler(this, itemIndex);
3542
- break;
3543
- case "clientCategoryType":
3544
- handler = new ClientCategoryTypeResourceHandler(this, itemIndex);
3545
- break;
3546
- case "bank":
3547
- handler = new BankResourceHandler(this, itemIndex);
3548
- break;
3549
- case "areaOfResponsibility":
3550
- handler = new AreaOfResponsibilityResourceHandler(this, itemIndex);
3551
- break;
3552
- case "addressee":
3553
- handler = new AddresseeResourceHandler(this, itemIndex);
3554
- break;
3555
- default:
3556
- throw new import_n8n_workflow15.NodeOperationError(this.getNode(), `The resource "${resource}" is not supported.`, { itemIndex });
3557
- }
3558
- await handler.execute(operation, authContext, returnData);
3559
- }
3560
- return [returnData];
3561
- }
3562
- }
21
+ constructor() {
22
+ var _a;
23
+ this.description = {
24
+ ...MasterData_config_1.masterDataNodeDescription,
25
+ icon: (_a = MasterData_config_1.masterDataNodeDescription.icon) !== null && _a !== void 0 ? _a : "file:../klardaten.svg",
26
+ usableAsTool: true,
27
+ };
28
+ }
29
+ async execute() {
30
+ const items = this.getInputData();
31
+ const returnData = [];
32
+ // Get and validate credentials
33
+ const credentials = (await this.getCredentials("datevConnectApi"));
34
+ if (!credentials) {
35
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "DATEVconnect credentials are missing");
36
+ }
37
+ const { host, email, password, clientInstanceId } = credentials;
38
+ if (!host || !email || !password || !clientInstanceId) {
39
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "All DATEVconnect credential fields must be provided");
40
+ }
41
+ // Authenticate once for all items
42
+ let token;
43
+ try {
44
+ const authResponse = await (0, datevConnectClient_1.authenticate)({
45
+ host,
46
+ email,
47
+ password,
48
+ });
49
+ token = authResponse.access_token;
50
+ }
51
+ catch (error) {
52
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), (0, utils_1.toErrorObject)(error));
53
+ }
54
+ // Create authentication context
55
+ const authContext = { host, token, clientInstanceId };
56
+ // Process each input item
57
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
58
+ const resource = this.getNodeParameter("resource", itemIndex);
59
+ const operation = this.getNodeParameter("operation", itemIndex);
60
+ // Create appropriate resource handler
61
+ let handler;
62
+ switch (resource) {
63
+ case "client":
64
+ handler = new ClientResourceHandler_1.ClientResourceHandler(this, itemIndex);
65
+ break;
66
+ case "taxAuthority":
67
+ handler = new TaxAuthorityResourceHandler_1.TaxAuthorityResourceHandler(this, itemIndex);
68
+ break;
69
+ case "relationship":
70
+ handler = new RelationshipResourceHandler_1.RelationshipResourceHandler(this, itemIndex);
71
+ break;
72
+ case "legalForm":
73
+ handler = new LegalFormResourceHandler_1.LegalFormResourceHandler(this, itemIndex);
74
+ break;
75
+ case "corporateStructure":
76
+ handler = new CorporateStructureResourceHandler_1.CorporateStructureResourceHandler(this, itemIndex);
77
+ break;
78
+ case "employee":
79
+ handler = new EmployeeResourceHandler_1.EmployeeResourceHandler(this, itemIndex);
80
+ break;
81
+ case "countryCode":
82
+ handler = new CountryCodeResourceHandler_1.CountryCodeResourceHandler(this, itemIndex);
83
+ break;
84
+ case "clientGroupType":
85
+ handler = new ClientGroupTypeResourceHandler_1.ClientGroupTypeResourceHandler(this, itemIndex);
86
+ break;
87
+ case "clientCategoryType":
88
+ handler = new ClientCategoryTypeResourceHandler_1.ClientCategoryTypeResourceHandler(this, itemIndex);
89
+ break;
90
+ case "bank":
91
+ handler = new BankResourceHandler_1.BankResourceHandler(this, itemIndex);
92
+ break;
93
+ case "areaOfResponsibility":
94
+ handler = new AreaOfResponsibilityResourceHandler_1.AreaOfResponsibilityResourceHandler(this, itemIndex);
95
+ break;
96
+ case "addressee":
97
+ handler = new AddresseeResourceHandler_1.AddresseeResourceHandler(this, itemIndex);
98
+ break;
99
+ default:
100
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The resource "${resource}" is not supported.`, { itemIndex });
101
+ }
102
+ // Execute the operation using the handler
103
+ await handler.execute(operation, authContext, returnData);
104
+ }
105
+ return [returnData];
106
+ }
107
+ }
108
+ exports.MasterData = MasterData;