@klardaten/n8n-nodes-datevconnect 1.0.1 → 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
@@ -0,0 +1,1809 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.authenticate = authenticate;
4
+ exports.fetchClients = fetchClients;
5
+ exports.fetchClient = fetchClient;
6
+ exports.createClient = createClient;
7
+ exports.updateClient = updateClient;
8
+ exports.fetchClientResponsibilities = fetchClientResponsibilities;
9
+ exports.updateClientResponsibilities = updateClientResponsibilities;
10
+ exports.fetchClientCategories = fetchClientCategories;
11
+ exports.updateClientCategories = updateClientCategories;
12
+ exports.fetchClientGroups = fetchClientGroups;
13
+ exports.updateClientGroups = updateClientGroups;
14
+ exports.fetchClientDeletionLog = fetchClientDeletionLog;
15
+ exports.fetchNextFreeClientNumber = fetchNextFreeClientNumber;
16
+ exports.fetchTaxAuthorities = fetchTaxAuthorities;
17
+ exports.fetchRelationships = fetchRelationships;
18
+ exports.fetchRelationshipTypes = fetchRelationshipTypes;
19
+ exports.fetchLegalForms = fetchLegalForms;
20
+ exports.fetchCorporateStructures = fetchCorporateStructures;
21
+ exports.fetchCorporateStructure = fetchCorporateStructure;
22
+ exports.fetchEstablishment = fetchEstablishment;
23
+ exports.fetchEmployees = fetchEmployees;
24
+ exports.fetchEmployee = fetchEmployee;
25
+ exports.createEmployee = createEmployee;
26
+ exports.updateEmployee = updateEmployee;
27
+ exports.fetchCountryCodes = fetchCountryCodes;
28
+ exports.fetchClientGroupTypes = fetchClientGroupTypes;
29
+ exports.fetchClientGroupType = fetchClientGroupType;
30
+ exports.createClientGroupType = createClientGroupType;
31
+ exports.updateClientGroupType = updateClientGroupType;
32
+ exports.fetchClientCategoryTypes = fetchClientCategoryTypes;
33
+ exports.fetchClientCategoryType = fetchClientCategoryType;
34
+ exports.createClientCategoryType = createClientCategoryType;
35
+ exports.updateClientCategoryType = updateClientCategoryType;
36
+ exports.fetchBanks = fetchBanks;
37
+ exports.fetchAreaOfResponsibilities = fetchAreaOfResponsibilities;
38
+ exports.fetchAddressees = fetchAddressees;
39
+ exports.fetchAddressee = fetchAddressee;
40
+ exports.createAddressee = createAddressee;
41
+ exports.updateAddressee = updateAddressee;
42
+ exports.fetchAddresseesDeletionLog = fetchAddresseesDeletionLog;
43
+ exports.fetchAccountingClients = fetchAccountingClients;
44
+ exports.fetchAccountingClient = fetchAccountingClient;
45
+ exports.fetchFiscalYears = fetchFiscalYears;
46
+ exports.fetchFiscalYear = fetchFiscalYear;
47
+ exports.fetchAccountsReceivable = fetchAccountsReceivable;
48
+ exports.fetchAccountsReceivableCondensed = fetchAccountsReceivableCondensed;
49
+ exports.fetchAccountReceivable = fetchAccountReceivable;
50
+ exports.fetchAccountsPayable = fetchAccountsPayable;
51
+ exports.fetchAccountsPayableCondensed = fetchAccountsPayableCondensed;
52
+ exports.fetchAccountPayable = fetchAccountPayable;
53
+ exports.fetchAccountPostings = fetchAccountPostings;
54
+ exports.fetchAccountPosting = fetchAccountPosting;
55
+ exports.fetchAccountingSequences = fetchAccountingSequences;
56
+ exports.fetchAccountingSequence = fetchAccountingSequence;
57
+ exports.createAccountingSequence = createAccountingSequence;
58
+ exports.fetchAccountingRecords = fetchAccountingRecords;
59
+ exports.fetchAccountingRecord = fetchAccountingRecord;
60
+ exports.fetchPostingProposalRulesIncoming = fetchPostingProposalRulesIncoming;
61
+ exports.fetchPostingProposalRulesOutgoing = fetchPostingProposalRulesOutgoing;
62
+ exports.fetchPostingProposalRulesCashRegister = fetchPostingProposalRulesCashRegister;
63
+ exports.fetchPostingProposalRuleIncoming = fetchPostingProposalRuleIncoming;
64
+ exports.fetchPostingProposalRuleOutgoing = fetchPostingProposalRuleOutgoing;
65
+ exports.fetchPostingProposalRuleCashRegister = fetchPostingProposalRuleCashRegister;
66
+ exports.batchPostingProposalsIncoming = batchPostingProposalsIncoming;
67
+ exports.batchPostingProposalsOutgoing = batchPostingProposalsOutgoing;
68
+ exports.batchPostingProposalsCashRegister = batchPostingProposalsCashRegister;
69
+ exports.fetchAccountingSumsAndBalances = fetchAccountingSumsAndBalances;
70
+ exports.fetchAccountingSumsAndBalance = fetchAccountingSumsAndBalance;
71
+ exports.fetchDebitors = fetchDebitors;
72
+ exports.fetchDebitor = fetchDebitor;
73
+ exports.createDebitor = createDebitor;
74
+ exports.updateDebitor = updateDebitor;
75
+ exports.fetchNextAvailableDebitor = fetchNextAvailableDebitor;
76
+ exports.fetchCreditors = fetchCreditors;
77
+ exports.fetchCreditor = fetchCreditor;
78
+ exports.createCreditor = createCreditor;
79
+ exports.updateCreditor = updateCreditor;
80
+ exports.fetchNextAvailableCreditor = fetchNextAvailableCreditor;
81
+ exports.fetchGeneralLedgerAccounts = fetchGeneralLedgerAccounts;
82
+ exports.fetchGeneralLedgerAccount = fetchGeneralLedgerAccount;
83
+ exports.fetchUtilizedGeneralLedgerAccounts = fetchUtilizedGeneralLedgerAccounts;
84
+ exports.fetchTermsOfPayment = fetchTermsOfPayment;
85
+ exports.fetchTermOfPayment = fetchTermOfPayment;
86
+ exports.createTermOfPayment = createTermOfPayment;
87
+ exports.updateTermOfPayment = updateTermOfPayment;
88
+ exports.fetchStocktakingData = fetchStocktakingData;
89
+ exports.fetchStocktakingDataByAsset = fetchStocktakingDataByAsset;
90
+ exports.updateStocktakingData = updateStocktakingData;
91
+ exports.fetchCostSystems = fetchCostSystems;
92
+ exports.fetchCostSystem = fetchCostSystem;
93
+ exports.fetchCostCenters = fetchCostCenters;
94
+ exports.fetchCostCenter = fetchCostCenter;
95
+ exports.fetchCostCenterProperties = fetchCostCenterProperties;
96
+ exports.fetchCostCenterProperty = fetchCostCenterProperty;
97
+ exports.createInternalCostService = createInternalCostService;
98
+ exports.fetchCostSequences = fetchCostSequences;
99
+ exports.fetchCostSequence = fetchCostSequence;
100
+ exports.createCostSequence = createCostSequence;
101
+ exports.fetchCostAccountingRecords = fetchCostAccountingRecords;
102
+ exports.fetchAccountingStatistics = fetchAccountingStatistics;
103
+ exports.fetchAccountingTransactionKeys = fetchAccountingTransactionKeys;
104
+ exports.fetchAccountingTransactionKey = fetchAccountingTransactionKey;
105
+ exports.fetchVariousAddresses = fetchVariousAddresses;
106
+ exports.fetchVariousAddress = fetchVariousAddress;
107
+ exports.createVariousAddress = createVariousAddress;
108
+ const JSON_CONTENT_TYPE = "application/json";
109
+ const DEFAULT_ERROR_PREFIX = "DATEVconnect request failed";
110
+ function normaliseBaseUrl(host) {
111
+ if (!host) {
112
+ throw new Error("DATEVconnect host must be provided");
113
+ }
114
+ return host.endsWith("/") ? host : `${host}/`;
115
+ }
116
+ function buildHeaders(headers) {
117
+ return Object.entries(headers).reduce((acc, [key, value]) => {
118
+ if (value) {
119
+ acc[key] = value;
120
+ }
121
+ return acc;
122
+ }, {});
123
+ }
124
+ async function readResponseBody(response) {
125
+ var _a;
126
+ const contentType = (_a = response.headers.get("content-type")) !== null && _a !== void 0 ? _a : "";
127
+ if (contentType.toLowerCase().includes(JSON_CONTENT_TYPE)) {
128
+ try {
129
+ return (await response.json());
130
+ }
131
+ catch {
132
+ return undefined;
133
+ }
134
+ }
135
+ try {
136
+ const text = await response.text();
137
+ return text.length > 0 ? text : undefined;
138
+ }
139
+ catch {
140
+ return undefined;
141
+ }
142
+ }
143
+ function extractErrorMessage(response, body) {
144
+ const statusPart = `${response.status}${response.statusText ? ` ${response.statusText}` : ""}`.trim();
145
+ const prefix = `${DEFAULT_ERROR_PREFIX}${statusPart ? ` (${statusPart})` : ""}`;
146
+ if (typeof body === "string" && body.trim().length > 0) {
147
+ return `${prefix}: ${body.trim()}`;
148
+ }
149
+ if (body && typeof body === "object") {
150
+ const errorDescription = "error_description" in body && typeof body.error_description === "string"
151
+ ? body.error_description
152
+ : undefined;
153
+ const message = ("message" in body && typeof body.message === "string"
154
+ ? body.message
155
+ : undefined) ||
156
+ ("error" in body && typeof body.error === "string" ? body.error : undefined);
157
+ if (message) {
158
+ return `${prefix}: ${message}${errorDescription ? `: ${errorDescription}` : ""}`;
159
+ }
160
+ }
161
+ return prefix;
162
+ }
163
+ async function ensureSuccess(response) {
164
+ const body = await readResponseBody(response);
165
+ if (!response.ok) {
166
+ throw new Error(extractErrorMessage(response, body));
167
+ }
168
+ if (body && typeof body === "object") {
169
+ return body;
170
+ }
171
+ if (body === undefined) {
172
+ return undefined;
173
+ }
174
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected JSON response body.`);
175
+ }
176
+ async function authenticate(options) {
177
+ const { host, email, password, fetchImpl = fetch } = options;
178
+ const baseUrl = normaliseBaseUrl(host);
179
+ const url = new URL("api/auth/login", baseUrl);
180
+ const response = await fetchImpl(url, {
181
+ method: "POST",
182
+ headers: buildHeaders({
183
+ "content-type": JSON_CONTENT_TYPE,
184
+ }),
185
+ body: JSON.stringify({ email, password }),
186
+ });
187
+ const body = await ensureSuccess(response);
188
+ if (!body || typeof body !== "object" || !("access_token" in body) || typeof body.access_token !== "string") {
189
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Authentication response missing access_token.`);
190
+ }
191
+ return body;
192
+ }
193
+ const MASTER_DATA_BASE_PATH = "datevconnect/master-data/v1";
194
+ const CLIENTS_PATH = `${MASTER_DATA_BASE_PATH}/clients`;
195
+ const TAX_AUTHORITIES_PATH = `${MASTER_DATA_BASE_PATH}/tax-authorities`;
196
+ const RELATIONSHIPS_PATH = `${MASTER_DATA_BASE_PATH}/relationships`;
197
+ const RELATIONSHIP_TYPES_PATH = `${MASTER_DATA_BASE_PATH}/relationship-types`;
198
+ const LEGAL_FORMS_PATH = `${MASTER_DATA_BASE_PATH}/legal-forms`;
199
+ const CORPORATE_STRUCTURES_PATH = `${MASTER_DATA_BASE_PATH}/corporate-structures`;
200
+ const EMPLOYEES_PATH = `${MASTER_DATA_BASE_PATH}/employees`;
201
+ const COUNTRY_CODES_PATH = `${MASTER_DATA_BASE_PATH}/country-codes`;
202
+ const CLIENT_GROUP_TYPES_PATH = `${MASTER_DATA_BASE_PATH}/client-group-types`;
203
+ const CLIENT_CATEGORY_TYPES_PATH = `${MASTER_DATA_BASE_PATH}/client-category-types`;
204
+ const BANKS_PATH = `${MASTER_DATA_BASE_PATH}/banks`;
205
+ const AREA_OF_RESPONSIBILITIES_PATH = `${MASTER_DATA_BASE_PATH}/area-of-responsibilities`;
206
+ const ADDRESSEES_PATH = `${MASTER_DATA_BASE_PATH}/addressees`;
207
+ const ADDRESSEES_DELETION_LOG_PATH = `${ADDRESSEES_PATH}/deletion-log`;
208
+ function buildApiUrl(host, path) {
209
+ const baseUrl = normaliseBaseUrl(host);
210
+ const trimmedPath = path.startsWith("/") ? path.slice(1) : path;
211
+ return new URL(trimmedPath, baseUrl);
212
+ }
213
+ async function sendMasterDataRequest(options) {
214
+ const { host, token, clientInstanceId, path, method, query, body, fetchImpl = fetch } = options;
215
+ const url = buildApiUrl(host, path);
216
+ if (query) {
217
+ for (const [key, value] of Object.entries(query)) {
218
+ if (value === undefined || value === null) {
219
+ continue;
220
+ }
221
+ url.searchParams.set(key, String(value));
222
+ }
223
+ }
224
+ const response = await fetchImpl(url, {
225
+ method,
226
+ headers: buildHeaders({
227
+ accept: JSON_CONTENT_TYPE,
228
+ authorization: `Bearer ${token}`,
229
+ "content-type": JSON_CONTENT_TYPE,
230
+ "x-client-instance-id": clientInstanceId,
231
+ }),
232
+ body: body === undefined ? undefined : JSON.stringify(body),
233
+ });
234
+ return ensureSuccess(response);
235
+ }
236
+ async function fetchClients(options) {
237
+ const { top, skip, select, filter } = options;
238
+ const body = await sendMasterDataRequest({
239
+ ...options,
240
+ path: CLIENTS_PATH,
241
+ method: "GET",
242
+ query: {
243
+ top,
244
+ skip,
245
+ select,
246
+ filter,
247
+ },
248
+ });
249
+ if (body === undefined) {
250
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected clients payload.`);
251
+ }
252
+ return body;
253
+ }
254
+ async function fetchClient(options) {
255
+ const { clientId, select } = options;
256
+ const body = await sendMasterDataRequest({
257
+ ...options,
258
+ path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}`,
259
+ method: "GET",
260
+ query: {
261
+ select,
262
+ },
263
+ });
264
+ if (body === undefined) {
265
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client payload.`);
266
+ }
267
+ return body;
268
+ }
269
+ async function createClient(options) {
270
+ const { client, maxNumber } = options;
271
+ return sendMasterDataRequest({
272
+ ...options,
273
+ path: CLIENTS_PATH,
274
+ method: "POST",
275
+ query: {
276
+ "max-number": maxNumber,
277
+ },
278
+ body: client,
279
+ });
280
+ }
281
+ async function updateClient(options) {
282
+ const { clientId, client } = options;
283
+ return sendMasterDataRequest({
284
+ ...options,
285
+ path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}`,
286
+ method: "PUT",
287
+ body: client,
288
+ });
289
+ }
290
+ async function fetchClientResponsibilities(options) {
291
+ const { clientId, select } = options;
292
+ const body = await sendMasterDataRequest({
293
+ ...options,
294
+ path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/responsibilities`,
295
+ method: "GET",
296
+ query: {
297
+ select,
298
+ },
299
+ });
300
+ if (body === undefined) {
301
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected responsibilities payload.`);
302
+ }
303
+ return body;
304
+ }
305
+ async function updateClientResponsibilities(options) {
306
+ const { clientId, responsibilities } = options;
307
+ return sendMasterDataRequest({
308
+ ...options,
309
+ path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/responsibilities`,
310
+ method: "PUT",
311
+ body: responsibilities,
312
+ });
313
+ }
314
+ async function fetchClientCategories(options) {
315
+ const { clientId, select } = options;
316
+ const body = await sendMasterDataRequest({
317
+ ...options,
318
+ path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-categories`,
319
+ method: "GET",
320
+ query: {
321
+ select,
322
+ },
323
+ });
324
+ if (body === undefined) {
325
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client categories payload.`);
326
+ }
327
+ return body;
328
+ }
329
+ async function updateClientCategories(options) {
330
+ const { clientId, categories } = options;
331
+ return sendMasterDataRequest({
332
+ ...options,
333
+ path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-categories`,
334
+ method: "PUT",
335
+ body: categories,
336
+ });
337
+ }
338
+ async function fetchClientGroups(options) {
339
+ const { clientId, select } = options;
340
+ const body = await sendMasterDataRequest({
341
+ ...options,
342
+ path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-groups`,
343
+ method: "GET",
344
+ query: {
345
+ select,
346
+ },
347
+ });
348
+ if (body === undefined) {
349
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client groups payload.`);
350
+ }
351
+ return body;
352
+ }
353
+ async function updateClientGroups(options) {
354
+ const { clientId, groups } = options;
355
+ return sendMasterDataRequest({
356
+ ...options,
357
+ path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-groups`,
358
+ method: "PUT",
359
+ body: groups,
360
+ });
361
+ }
362
+ async function fetchClientDeletionLog(options) {
363
+ const { select, filter, top, skip } = options;
364
+ const body = await sendMasterDataRequest({
365
+ ...options,
366
+ path: `${CLIENTS_PATH}/deletion-log`,
367
+ method: "GET",
368
+ query: {
369
+ select,
370
+ filter,
371
+ top,
372
+ skip,
373
+ },
374
+ });
375
+ if (body === undefined) {
376
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client deletion log payload.`);
377
+ }
378
+ return body;
379
+ }
380
+ async function fetchNextFreeClientNumber(options) {
381
+ const { start, range } = options;
382
+ const body = await sendMasterDataRequest({
383
+ ...options,
384
+ path: `${CLIENTS_PATH}/next-free-number`,
385
+ method: "GET",
386
+ query: {
387
+ start,
388
+ range,
389
+ },
390
+ });
391
+ if (body === undefined) {
392
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected next free number payload.`);
393
+ }
394
+ return body;
395
+ }
396
+ async function fetchTaxAuthorities(options) {
397
+ const { select, filter, top, skip } = options;
398
+ const body = await sendMasterDataRequest({
399
+ ...options,
400
+ path: TAX_AUTHORITIES_PATH,
401
+ method: "GET",
402
+ query: {
403
+ select,
404
+ filter,
405
+ top,
406
+ skip,
407
+ },
408
+ });
409
+ if (body === undefined) {
410
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected tax authorities payload.`);
411
+ }
412
+ return body;
413
+ }
414
+ async function fetchRelationships(options) {
415
+ const { select, filter, top, skip } = options;
416
+ const body = await sendMasterDataRequest({
417
+ ...options,
418
+ path: RELATIONSHIPS_PATH,
419
+ method: "GET",
420
+ query: {
421
+ select,
422
+ filter,
423
+ top,
424
+ skip,
425
+ },
426
+ });
427
+ if (body === undefined) {
428
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected relationships payload.`);
429
+ }
430
+ return body;
431
+ }
432
+ async function fetchRelationshipTypes(options) {
433
+ const { select, filter } = options;
434
+ const body = await sendMasterDataRequest({
435
+ ...options,
436
+ path: RELATIONSHIP_TYPES_PATH,
437
+ method: "GET",
438
+ query: {
439
+ select,
440
+ filter,
441
+ },
442
+ });
443
+ if (body === undefined) {
444
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected relationship types payload.`);
445
+ }
446
+ return body;
447
+ }
448
+ async function fetchLegalForms(options) {
449
+ const { select, nationalRight, top, skip } = options;
450
+ const body = await sendMasterDataRequest({
451
+ ...options,
452
+ path: LEGAL_FORMS_PATH,
453
+ method: "GET",
454
+ query: {
455
+ select,
456
+ "national-right": nationalRight,
457
+ top,
458
+ skip,
459
+ },
460
+ });
461
+ if (body === undefined) {
462
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected legal forms payload.`);
463
+ }
464
+ return body;
465
+ }
466
+ async function fetchCorporateStructures(options) {
467
+ const { select, filter, top, skip } = options;
468
+ const body = await sendMasterDataRequest({
469
+ ...options,
470
+ path: CORPORATE_STRUCTURES_PATH,
471
+ method: "GET",
472
+ query: {
473
+ select,
474
+ filter,
475
+ top,
476
+ skip,
477
+ },
478
+ });
479
+ if (body === undefined) {
480
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected corporate structures payload.`);
481
+ }
482
+ return body;
483
+ }
484
+ async function fetchCorporateStructure(options) {
485
+ const { organizationId, select } = options;
486
+ const body = await sendMasterDataRequest({
487
+ ...options,
488
+ path: `${CORPORATE_STRUCTURES_PATH}/${encodeURIComponent(organizationId)}`,
489
+ method: "GET",
490
+ query: {
491
+ select,
492
+ },
493
+ });
494
+ if (body === undefined) {
495
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected corporate structure payload.`);
496
+ }
497
+ return body;
498
+ }
499
+ async function fetchEstablishment(options) {
500
+ const { organizationId, establishmentId, select } = options;
501
+ const body = await sendMasterDataRequest({
502
+ ...options,
503
+ path: `${CORPORATE_STRUCTURES_PATH}/${encodeURIComponent(organizationId)}/establishments/${encodeURIComponent(establishmentId)}`,
504
+ method: "GET",
505
+ query: {
506
+ select,
507
+ },
508
+ });
509
+ if (body === undefined) {
510
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected establishment payload.`);
511
+ }
512
+ return body;
513
+ }
514
+ async function fetchEmployees(options) {
515
+ const { select, filter, top, skip } = options;
516
+ const body = await sendMasterDataRequest({
517
+ ...options,
518
+ path: EMPLOYEES_PATH,
519
+ method: "GET",
520
+ query: {
521
+ select,
522
+ filter,
523
+ top,
524
+ skip,
525
+ },
526
+ });
527
+ if (body === undefined) {
528
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected employees payload.`);
529
+ }
530
+ return body;
531
+ }
532
+ async function fetchEmployee(options) {
533
+ const { employeeId, select } = options;
534
+ const body = await sendMasterDataRequest({
535
+ ...options,
536
+ path: `${EMPLOYEES_PATH}/${encodeURIComponent(employeeId)}`,
537
+ method: "GET",
538
+ query: {
539
+ select,
540
+ },
541
+ });
542
+ if (body === undefined) {
543
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected employee payload.`);
544
+ }
545
+ return body;
546
+ }
547
+ async function createEmployee(options) {
548
+ const { employee } = options;
549
+ return sendMasterDataRequest({
550
+ ...options,
551
+ path: EMPLOYEES_PATH,
552
+ method: "POST",
553
+ body: employee,
554
+ });
555
+ }
556
+ async function updateEmployee(options) {
557
+ const { employeeId, employee } = options;
558
+ return sendMasterDataRequest({
559
+ ...options,
560
+ path: `${EMPLOYEES_PATH}/${encodeURIComponent(employeeId)}`,
561
+ method: "PUT",
562
+ body: employee,
563
+ });
564
+ }
565
+ async function fetchCountryCodes(options) {
566
+ const { select, filter, top, skip } = options;
567
+ const body = await sendMasterDataRequest({
568
+ ...options,
569
+ path: COUNTRY_CODES_PATH,
570
+ method: "GET",
571
+ query: {
572
+ select,
573
+ filter,
574
+ top,
575
+ skip,
576
+ },
577
+ });
578
+ if (body === undefined) {
579
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected country codes payload.`);
580
+ }
581
+ return body;
582
+ }
583
+ async function fetchClientGroupTypes(options) {
584
+ const { select, filter, top, skip } = options;
585
+ const body = await sendMasterDataRequest({
586
+ ...options,
587
+ path: CLIENT_GROUP_TYPES_PATH,
588
+ method: "GET",
589
+ query: {
590
+ select,
591
+ filter,
592
+ top,
593
+ skip,
594
+ },
595
+ });
596
+ if (body === undefined) {
597
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client group types payload.`);
598
+ }
599
+ return body;
600
+ }
601
+ async function fetchClientGroupType(options) {
602
+ const { clientGroupTypeId, select } = options;
603
+ const body = await sendMasterDataRequest({
604
+ ...options,
605
+ path: `${CLIENT_GROUP_TYPES_PATH}/${clientGroupTypeId}`,
606
+ method: "GET",
607
+ query: {
608
+ select,
609
+ },
610
+ });
611
+ if (body === undefined) {
612
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client group type payload.`);
613
+ }
614
+ return body;
615
+ }
616
+ async function createClientGroupType(options) {
617
+ const { clientGroupType } = options;
618
+ const body = await sendMasterDataRequest({
619
+ ...options,
620
+ path: CLIENT_GROUP_TYPES_PATH,
621
+ method: "POST",
622
+ body: clientGroupType,
623
+ });
624
+ return body;
625
+ }
626
+ async function updateClientGroupType(options) {
627
+ const { clientGroupTypeId, clientGroupType } = options;
628
+ const body = await sendMasterDataRequest({
629
+ ...options,
630
+ path: `${CLIENT_GROUP_TYPES_PATH}/${clientGroupTypeId}`,
631
+ method: "PUT",
632
+ body: clientGroupType,
633
+ });
634
+ return body;
635
+ }
636
+ async function fetchClientCategoryTypes(options) {
637
+ const { select, filter, top, skip } = options;
638
+ const body = await sendMasterDataRequest({
639
+ ...options,
640
+ path: CLIENT_CATEGORY_TYPES_PATH,
641
+ method: "GET",
642
+ query: {
643
+ select,
644
+ filter,
645
+ top,
646
+ skip,
647
+ },
648
+ });
649
+ if (body === undefined) {
650
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client category types payload.`);
651
+ }
652
+ return body;
653
+ }
654
+ async function fetchClientCategoryType(options) {
655
+ const { clientCategoryTypeId, select } = options;
656
+ const body = await sendMasterDataRequest({
657
+ ...options,
658
+ path: `${CLIENT_CATEGORY_TYPES_PATH}/${clientCategoryTypeId}`,
659
+ method: "GET",
660
+ query: {
661
+ select,
662
+ },
663
+ });
664
+ if (body === undefined) {
665
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client category type payload.`);
666
+ }
667
+ return body;
668
+ }
669
+ async function createClientCategoryType(options) {
670
+ const { clientCategoryType } = options;
671
+ const body = await sendMasterDataRequest({
672
+ ...options,
673
+ path: CLIENT_CATEGORY_TYPES_PATH,
674
+ method: "POST",
675
+ body: clientCategoryType,
676
+ });
677
+ return body;
678
+ }
679
+ async function updateClientCategoryType(options) {
680
+ const { clientCategoryTypeId, clientCategoryType } = options;
681
+ const body = await sendMasterDataRequest({
682
+ ...options,
683
+ path: `${CLIENT_CATEGORY_TYPES_PATH}/${clientCategoryTypeId}`,
684
+ method: "PUT",
685
+ body: clientCategoryType,
686
+ });
687
+ return body;
688
+ }
689
+ async function fetchBanks(options) {
690
+ const { select, filter, top, skip } = options;
691
+ const body = await sendMasterDataRequest({
692
+ ...options,
693
+ path: BANKS_PATH,
694
+ method: "GET",
695
+ query: {
696
+ select,
697
+ filter,
698
+ top,
699
+ skip,
700
+ },
701
+ });
702
+ if (body === undefined) {
703
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected banks payload.`);
704
+ }
705
+ return body;
706
+ }
707
+ async function fetchAreaOfResponsibilities(options) {
708
+ const { select, filter, top, skip } = options;
709
+ const body = await sendMasterDataRequest({
710
+ ...options,
711
+ path: AREA_OF_RESPONSIBILITIES_PATH,
712
+ method: "GET",
713
+ query: {
714
+ select,
715
+ filter,
716
+ top,
717
+ skip,
718
+ },
719
+ });
720
+ if (body === undefined) {
721
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected area of responsibilities payload.`);
722
+ }
723
+ return body;
724
+ }
725
+ async function fetchAddressees(options) {
726
+ const { select, filter, top, skip } = options;
727
+ const body = await sendMasterDataRequest({
728
+ ...options,
729
+ path: ADDRESSEES_PATH,
730
+ method: "GET",
731
+ query: {
732
+ select,
733
+ filter,
734
+ top,
735
+ skip,
736
+ },
737
+ });
738
+ if (body === undefined) {
739
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected addressees payload.`);
740
+ }
741
+ return body;
742
+ }
743
+ async function fetchAddressee(options) {
744
+ const { addresseeId, select, expand } = options;
745
+ const body = await sendMasterDataRequest({
746
+ ...options,
747
+ path: `${ADDRESSEES_PATH}/${addresseeId}`,
748
+ method: "GET",
749
+ query: {
750
+ select,
751
+ expand,
752
+ },
753
+ });
754
+ if (body === undefined) {
755
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected addressee payload.`);
756
+ }
757
+ return body;
758
+ }
759
+ async function createAddressee(options) {
760
+ const { addressee, nationalRight } = options;
761
+ const body = await sendMasterDataRequest({
762
+ ...options,
763
+ path: ADDRESSEES_PATH,
764
+ method: "POST",
765
+ query: {
766
+ "national-right": nationalRight,
767
+ },
768
+ body: addressee,
769
+ });
770
+ return body;
771
+ }
772
+ async function updateAddressee(options) {
773
+ const { addresseeId, addressee } = options;
774
+ const body = await sendMasterDataRequest({
775
+ ...options,
776
+ path: `${ADDRESSEES_PATH}/${addresseeId}`,
777
+ method: "PUT",
778
+ body: addressee,
779
+ });
780
+ return body;
781
+ }
782
+ async function fetchAddresseesDeletionLog(options) {
783
+ const { select, filter, top, skip } = options;
784
+ const body = await sendMasterDataRequest({
785
+ ...options,
786
+ path: ADDRESSEES_DELETION_LOG_PATH,
787
+ method: "GET",
788
+ query: {
789
+ select,
790
+ filter,
791
+ top,
792
+ skip,
793
+ },
794
+ });
795
+ if (body === undefined) {
796
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected addressees deletion log payload.`);
797
+ }
798
+ return body;
799
+ }
800
+ const ACCOUNTING_BASE_PATH = "datevconnect/accounting/v1";
801
+ async function sendAccountingRequest(options) {
802
+ const { host, token, clientInstanceId, path, method, query, body, fetchImpl = fetch } = options;
803
+ const url = buildApiUrl(host, path);
804
+ if (query) {
805
+ for (const [key, value] of Object.entries(query)) {
806
+ if (value === undefined || value === null) {
807
+ continue;
808
+ }
809
+ url.searchParams.set(key, String(value));
810
+ }
811
+ }
812
+ const response = await fetchImpl(url, {
813
+ method,
814
+ headers: buildHeaders({
815
+ accept: JSON_CONTENT_TYPE,
816
+ authorization: `Bearer ${token}`,
817
+ "content-type": JSON_CONTENT_TYPE,
818
+ "x-client-instance-id": clientInstanceId,
819
+ }),
820
+ body: body === undefined ? undefined : JSON.stringify(body),
821
+ });
822
+ return ensureSuccess(response);
823
+ }
824
+ async function fetchAccountingClients(options) {
825
+ const { select, filter, top, skip, expand } = options;
826
+ const body = await sendAccountingRequest({
827
+ ...options,
828
+ path: `${ACCOUNTING_BASE_PATH}/clients`,
829
+ method: "GET",
830
+ query: {
831
+ select,
832
+ filter,
833
+ top,
834
+ skip,
835
+ expand,
836
+ },
837
+ });
838
+ if (body === undefined) {
839
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting clients payload.`);
840
+ }
841
+ return body;
842
+ }
843
+ async function fetchAccountingClient(options) {
844
+ const { clientId, select, expand } = options;
845
+ const body = await sendAccountingRequest({
846
+ ...options,
847
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}`,
848
+ method: "GET",
849
+ query: {
850
+ select: select,
851
+ expand: expand,
852
+ },
853
+ });
854
+ if (body === undefined) {
855
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting client payload.`);
856
+ }
857
+ return body;
858
+ }
859
+ async function fetchFiscalYears(options) {
860
+ const { clientId, select, filter, top, skip } = options;
861
+ const body = await sendAccountingRequest({
862
+ ...options,
863
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years`,
864
+ method: "GET",
865
+ query: {
866
+ select: select,
867
+ filter: filter,
868
+ top: top,
869
+ skip: skip,
870
+ },
871
+ });
872
+ if (body === undefined) {
873
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected fiscal years payload.`);
874
+ }
875
+ return body;
876
+ }
877
+ async function fetchFiscalYear(options) {
878
+ const { clientId, fiscalYearId, select } = options;
879
+ const body = await sendAccountingRequest({
880
+ ...options,
881
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}`,
882
+ method: "GET",
883
+ query: {
884
+ select: select,
885
+ },
886
+ });
887
+ if (body === undefined) {
888
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected fiscal year payload.`);
889
+ }
890
+ return body;
891
+ }
892
+ async function fetchAccountsReceivable(options) {
893
+ const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
894
+ const body = await sendAccountingRequest({
895
+ ...options,
896
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-receivable`,
897
+ method: "GET",
898
+ query: {
899
+ select: select,
900
+ filter: filter,
901
+ top: top,
902
+ skip: skip,
903
+ expand: expand,
904
+ },
905
+ });
906
+ if (body === undefined) {
907
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounts receivable payload.`);
908
+ }
909
+ return body;
910
+ }
911
+ async function fetchAccountsReceivableCondensed(options) {
912
+ const { clientId, fiscalYearId, select, filter, top, skip } = options;
913
+ const body = await sendAccountingRequest({
914
+ ...options,
915
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-receivable/condensed`,
916
+ method: "GET",
917
+ query: {
918
+ select: select,
919
+ filter: filter,
920
+ top: top,
921
+ skip: skip,
922
+ },
923
+ });
924
+ if (body === undefined) {
925
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected condensed accounts receivable payload.`);
926
+ }
927
+ return body;
928
+ }
929
+ async function fetchAccountReceivable(options) {
930
+ const { clientId, fiscalYearId, accountsReceivableId, select, expand } = options;
931
+ const body = await sendAccountingRequest({
932
+ ...options,
933
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-receivable/${encodeURIComponent(accountsReceivableId)}`,
934
+ method: "GET",
935
+ query: {
936
+ select: select,
937
+ expand: expand,
938
+ },
939
+ });
940
+ if (body === undefined) {
941
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account receivable payload.`);
942
+ }
943
+ return body;
944
+ }
945
+ async function fetchAccountsPayable(options) {
946
+ const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
947
+ const body = await sendAccountingRequest({
948
+ ...options,
949
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-payable`,
950
+ method: "GET",
951
+ query: {
952
+ select: select,
953
+ filter: filter,
954
+ top: top,
955
+ skip: skip,
956
+ expand: expand,
957
+ },
958
+ });
959
+ if (body === undefined) {
960
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounts payable payload.`);
961
+ }
962
+ return body;
963
+ }
964
+ async function fetchAccountsPayableCondensed(options) {
965
+ const { clientId, fiscalYearId, select, filter, top, skip } = options;
966
+ const body = await sendAccountingRequest({
967
+ ...options,
968
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-payable/condense`,
969
+ method: "GET",
970
+ query: {
971
+ select: select,
972
+ filter: filter,
973
+ top: top,
974
+ skip: skip,
975
+ },
976
+ });
977
+ if (body === undefined) {
978
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected condensed accounts payable payload.`);
979
+ }
980
+ return body;
981
+ }
982
+ async function fetchAccountPayable(options) {
983
+ const { clientId, fiscalYearId, accountsPayableId, select, expand } = options;
984
+ const body = await sendAccountingRequest({
985
+ ...options,
986
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-payable/${encodeURIComponent(accountsPayableId)}`,
987
+ method: "GET",
988
+ query: {
989
+ select: select,
990
+ expand: expand,
991
+ },
992
+ });
993
+ if (body === undefined) {
994
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account payable payload.`);
995
+ }
996
+ return body;
997
+ }
998
+ async function fetchAccountPostings(options) {
999
+ const { clientId, fiscalYearId, select, filter, top, skip } = options;
1000
+ const body = await sendAccountingRequest({
1001
+ ...options,
1002
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/account-postings`,
1003
+ method: "GET",
1004
+ query: {
1005
+ select: select,
1006
+ filter: filter,
1007
+ top: top,
1008
+ skip: skip,
1009
+ },
1010
+ });
1011
+ if (body === undefined) {
1012
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account postings payload.`);
1013
+ }
1014
+ return body;
1015
+ }
1016
+ async function fetchAccountPosting(options) {
1017
+ const { clientId, fiscalYearId, accountPostingId, select } = options;
1018
+ const body = await sendAccountingRequest({
1019
+ ...options,
1020
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/account-postings/${encodeURIComponent(accountPostingId)}`,
1021
+ method: "GET",
1022
+ query: {
1023
+ select: select,
1024
+ },
1025
+ });
1026
+ if (body === undefined) {
1027
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account posting payload.`);
1028
+ }
1029
+ return body;
1030
+ }
1031
+ async function fetchAccountingSequences(options) {
1032
+ const { clientId, fiscalYearId, select, top, skip } = options;
1033
+ const body = await sendAccountingRequest({
1034
+ ...options,
1035
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed`,
1036
+ method: "GET",
1037
+ query: {
1038
+ select: select,
1039
+ top: top,
1040
+ skip: skip,
1041
+ },
1042
+ });
1043
+ if (body === undefined) {
1044
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sequences payload.`);
1045
+ }
1046
+ return body;
1047
+ }
1048
+ async function fetchAccountingSequence(options) {
1049
+ const { clientId, fiscalYearId, accountingSequenceId, select } = options;
1050
+ const body = await sendAccountingRequest({
1051
+ ...options,
1052
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed/${encodeURIComponent(accountingSequenceId)}`,
1053
+ method: "GET",
1054
+ query: {
1055
+ select: select,
1056
+ },
1057
+ });
1058
+ if (body === undefined) {
1059
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sequence payload.`);
1060
+ }
1061
+ return body;
1062
+ }
1063
+ async function createAccountingSequence(options) {
1064
+ const { clientId, fiscalYearId, accountingSequence } = options;
1065
+ return sendAccountingRequest({
1066
+ ...options,
1067
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences`,
1068
+ method: "POST",
1069
+ body: accountingSequence,
1070
+ });
1071
+ }
1072
+ async function fetchAccountingRecords(options) {
1073
+ const { clientId, fiscalYearId, accountingSequenceId, select, filter, top, skip } = options;
1074
+ const body = await sendAccountingRequest({
1075
+ ...options,
1076
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed/${encodeURIComponent(accountingSequenceId)}/accounting-records`,
1077
+ method: "GET",
1078
+ query: {
1079
+ select: select,
1080
+ filter: filter,
1081
+ top: top,
1082
+ skip: skip,
1083
+ },
1084
+ });
1085
+ if (body === undefined) {
1086
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting records payload.`);
1087
+ }
1088
+ return body;
1089
+ }
1090
+ async function fetchAccountingRecord(options) {
1091
+ const { clientId, fiscalYearId, accountingSequenceId, accountingRecordId, select } = options;
1092
+ const body = await sendAccountingRequest({
1093
+ ...options,
1094
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed/${encodeURIComponent(accountingSequenceId)}/accounting-records/${encodeURIComponent(accountingRecordId)}`,
1095
+ method: "GET",
1096
+ query: {
1097
+ select: select,
1098
+ },
1099
+ });
1100
+ if (body === undefined) {
1101
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting record payload.`);
1102
+ }
1103
+ return body;
1104
+ }
1105
+ async function fetchPostingProposalRulesIncoming(options) {
1106
+ const { clientId, fiscalYearId, select, top, skip } = options;
1107
+ const body = await sendAccountingRequest({
1108
+ ...options,
1109
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-incoming-invoices`,
1110
+ method: "GET",
1111
+ query: {
1112
+ select: select,
1113
+ top: top,
1114
+ skip: skip,
1115
+ },
1116
+ });
1117
+ if (body === undefined) {
1118
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rules incoming payload.`);
1119
+ }
1120
+ return body;
1121
+ }
1122
+ async function fetchPostingProposalRulesOutgoing(options) {
1123
+ const { clientId, fiscalYearId, select, top, skip } = options;
1124
+ const body = await sendAccountingRequest({
1125
+ ...options,
1126
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-outgoing-invoices`,
1127
+ method: "GET",
1128
+ query: {
1129
+ select: select,
1130
+ top: top,
1131
+ skip: skip,
1132
+ },
1133
+ });
1134
+ if (body === undefined) {
1135
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rules outgoing payload.`);
1136
+ }
1137
+ return body;
1138
+ }
1139
+ async function fetchPostingProposalRulesCashRegister(options) {
1140
+ const { clientId, fiscalYearId, select, top, skip } = options;
1141
+ const body = await sendAccountingRequest({
1142
+ ...options,
1143
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-cash-register`,
1144
+ method: "GET",
1145
+ query: {
1146
+ select: select,
1147
+ top: top,
1148
+ skip: skip,
1149
+ },
1150
+ });
1151
+ if (body === undefined) {
1152
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rules cash register payload.`);
1153
+ }
1154
+ return body;
1155
+ }
1156
+ async function fetchPostingProposalRuleIncoming(options) {
1157
+ const { clientId, fiscalYearId, ruleId, select } = options;
1158
+ const body = await sendAccountingRequest({
1159
+ ...options,
1160
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-incoming-invoices/${encodeURIComponent(ruleId)}`,
1161
+ method: "GET",
1162
+ query: {
1163
+ select: select,
1164
+ },
1165
+ });
1166
+ if (body === undefined) {
1167
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rule incoming payload.`);
1168
+ }
1169
+ return body;
1170
+ }
1171
+ async function fetchPostingProposalRuleOutgoing(options) {
1172
+ const { clientId, fiscalYearId, ruleId, select } = options;
1173
+ const body = await sendAccountingRequest({
1174
+ ...options,
1175
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-outgoing-invoices/${encodeURIComponent(ruleId)}`,
1176
+ method: "GET",
1177
+ query: {
1178
+ select: select,
1179
+ },
1180
+ });
1181
+ if (body === undefined) {
1182
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rule outgoing payload.`);
1183
+ }
1184
+ return body;
1185
+ }
1186
+ async function fetchPostingProposalRuleCashRegister(options) {
1187
+ const { clientId, fiscalYearId, ruleId, select } = options;
1188
+ const body = await sendAccountingRequest({
1189
+ ...options,
1190
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-cash-register/${encodeURIComponent(ruleId)}`,
1191
+ method: "GET",
1192
+ query: {
1193
+ select: select,
1194
+ },
1195
+ });
1196
+ if (body === undefined) {
1197
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rule cash register payload.`);
1198
+ }
1199
+ return body;
1200
+ }
1201
+ async function batchPostingProposalsIncoming(options) {
1202
+ const { clientId, fiscalYearId, postingProposals } = options;
1203
+ return sendAccountingRequest({
1204
+ ...options,
1205
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposals-incoming-invoices/batch`,
1206
+ method: "POST",
1207
+ body: postingProposals,
1208
+ });
1209
+ }
1210
+ async function batchPostingProposalsOutgoing(options) {
1211
+ const { clientId, fiscalYearId, postingProposals } = options;
1212
+ return sendAccountingRequest({
1213
+ ...options,
1214
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposals-outgoing-invoices/batch`,
1215
+ method: "POST",
1216
+ body: postingProposals,
1217
+ });
1218
+ }
1219
+ async function batchPostingProposalsCashRegister(options) {
1220
+ const { clientId, fiscalYearId, postingProposals } = options;
1221
+ return sendAccountingRequest({
1222
+ ...options,
1223
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposals-cash-register/batch`,
1224
+ method: "POST",
1225
+ body: postingProposals,
1226
+ });
1227
+ }
1228
+ async function fetchAccountingSumsAndBalances(options) {
1229
+ const { clientId, fiscalYearId, select, filter, top, skip } = options;
1230
+ const body = await sendAccountingRequest({
1231
+ ...options,
1232
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sums-and-balances`,
1233
+ method: "GET",
1234
+ query: {
1235
+ select: select,
1236
+ filter: filter,
1237
+ top: top,
1238
+ skip: skip,
1239
+ },
1240
+ });
1241
+ if (body === undefined) {
1242
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sums and balances payload.`);
1243
+ }
1244
+ return body;
1245
+ }
1246
+ async function fetchAccountingSumsAndBalance(options) {
1247
+ const { clientId, fiscalYearId, accountingSumsAndBalancesId } = options;
1248
+ const body = await sendAccountingRequest({
1249
+ ...options,
1250
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sums-and-balances/${encodeURIComponent(accountingSumsAndBalancesId)}`,
1251
+ method: "GET",
1252
+ });
1253
+ if (body === undefined) {
1254
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sums and balance payload.`);
1255
+ }
1256
+ return body;
1257
+ }
1258
+ async function fetchDebitors(options) {
1259
+ const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
1260
+ const body = await sendAccountingRequest({
1261
+ ...options,
1262
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors`,
1263
+ method: "GET",
1264
+ query: {
1265
+ select: select,
1266
+ filter: filter,
1267
+ top: top,
1268
+ skip: skip,
1269
+ expand: expand,
1270
+ },
1271
+ });
1272
+ if (body === undefined) {
1273
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected debitors payload.`);
1274
+ }
1275
+ return body;
1276
+ }
1277
+ async function fetchDebitor(options) {
1278
+ const { clientId, fiscalYearId, debitorId, select, expand } = options;
1279
+ const body = await sendAccountingRequest({
1280
+ ...options,
1281
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors/${encodeURIComponent(debitorId)}`,
1282
+ method: "GET",
1283
+ query: {
1284
+ select: select,
1285
+ expand: expand,
1286
+ },
1287
+ });
1288
+ if (body === undefined) {
1289
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected debitor payload.`);
1290
+ }
1291
+ return body;
1292
+ }
1293
+ async function createDebitor(options) {
1294
+ const { clientId, fiscalYearId, debitor } = options;
1295
+ return sendAccountingRequest({
1296
+ ...options,
1297
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors`,
1298
+ method: "POST",
1299
+ body: debitor,
1300
+ });
1301
+ }
1302
+ async function updateDebitor(options) {
1303
+ const { clientId, fiscalYearId, debitorId, debitor } = options;
1304
+ return sendAccountingRequest({
1305
+ ...options,
1306
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors/${encodeURIComponent(debitorId)}`,
1307
+ method: "PUT",
1308
+ body: debitor,
1309
+ });
1310
+ }
1311
+ async function fetchNextAvailableDebitor(options) {
1312
+ const { clientId, fiscalYearId, startAt } = options;
1313
+ const body = await sendAccountingRequest({
1314
+ ...options,
1315
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors/next-available`,
1316
+ method: "GET",
1317
+ query: {
1318
+ "start-at": startAt,
1319
+ },
1320
+ });
1321
+ if (body === undefined) {
1322
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected next available debitor payload.`);
1323
+ }
1324
+ return body;
1325
+ }
1326
+ async function fetchCreditors(options) {
1327
+ const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
1328
+ const body = await sendAccountingRequest({
1329
+ ...options,
1330
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors`,
1331
+ method: "GET",
1332
+ query: {
1333
+ select: select,
1334
+ filter: filter,
1335
+ top: top,
1336
+ skip: skip,
1337
+ expand: expand,
1338
+ },
1339
+ });
1340
+ if (body === undefined) {
1341
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected creditors payload.`);
1342
+ }
1343
+ return body;
1344
+ }
1345
+ async function fetchCreditor(options) {
1346
+ const { clientId, fiscalYearId, creditorId, select, expand } = options;
1347
+ const body = await sendAccountingRequest({
1348
+ ...options,
1349
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors/${encodeURIComponent(creditorId)}`,
1350
+ method: "GET",
1351
+ query: {
1352
+ select: select,
1353
+ expand: expand,
1354
+ },
1355
+ });
1356
+ if (body === undefined) {
1357
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected creditor payload.`);
1358
+ }
1359
+ return body;
1360
+ }
1361
+ async function createCreditor(options) {
1362
+ const { clientId, fiscalYearId, creditor } = options;
1363
+ return sendAccountingRequest({
1364
+ ...options,
1365
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors`,
1366
+ method: "POST",
1367
+ body: creditor,
1368
+ });
1369
+ }
1370
+ async function updateCreditor(options) {
1371
+ const { clientId, fiscalYearId, creditorId, creditor } = options;
1372
+ return sendAccountingRequest({
1373
+ ...options,
1374
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors/${encodeURIComponent(creditorId)}`,
1375
+ method: "PUT",
1376
+ body: creditor,
1377
+ });
1378
+ }
1379
+ async function fetchNextAvailableCreditor(options) {
1380
+ const { clientId, fiscalYearId, startAt } = options;
1381
+ const body = await sendAccountingRequest({
1382
+ ...options,
1383
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors/next-available`,
1384
+ method: "GET",
1385
+ query: {
1386
+ "start-at": startAt,
1387
+ },
1388
+ });
1389
+ if (body === undefined) {
1390
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected next available creditor payload.`);
1391
+ }
1392
+ return body;
1393
+ }
1394
+ async function fetchGeneralLedgerAccounts(options) {
1395
+ const { clientId, fiscalYearId, select, filter, top, skip } = options;
1396
+ const body = await sendAccountingRequest({
1397
+ ...options,
1398
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/general-ledger-accounts`,
1399
+ method: "GET",
1400
+ query: {
1401
+ select: select,
1402
+ filter: filter,
1403
+ top: top,
1404
+ skip: skip,
1405
+ },
1406
+ });
1407
+ if (body === undefined) {
1408
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected general ledger accounts payload.`);
1409
+ }
1410
+ return body;
1411
+ }
1412
+ async function fetchGeneralLedgerAccount(options) {
1413
+ const { clientId, fiscalYearId, generalLedgerAccountId, select } = options;
1414
+ const body = await sendAccountingRequest({
1415
+ ...options,
1416
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/general-ledger-accounts/${encodeURIComponent(generalLedgerAccountId)}`,
1417
+ method: "GET",
1418
+ query: {
1419
+ select: select,
1420
+ },
1421
+ });
1422
+ if (body === undefined) {
1423
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected general ledger account payload.`);
1424
+ }
1425
+ return body;
1426
+ }
1427
+ async function fetchUtilizedGeneralLedgerAccounts(options) {
1428
+ const { clientId, fiscalYearId, select, top, skip } = options;
1429
+ const body = await sendAccountingRequest({
1430
+ ...options,
1431
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/general-ledger-accounts/utilized`,
1432
+ method: "GET",
1433
+ query: {
1434
+ select: select,
1435
+ top: top,
1436
+ skip: skip,
1437
+ },
1438
+ });
1439
+ if (body === undefined) {
1440
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected utilized general ledger accounts payload.`);
1441
+ }
1442
+ return body;
1443
+ }
1444
+ // Terms of Payment functions
1445
+ async function fetchTermsOfPayment(options) {
1446
+ const { clientId, fiscalYearId, select, filter, skip, top } = options;
1447
+ const body = await sendAccountingRequest({
1448
+ ...options,
1449
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment`,
1450
+ method: "GET",
1451
+ query: {
1452
+ select: select,
1453
+ filter: filter,
1454
+ skip: skip,
1455
+ top: top,
1456
+ },
1457
+ });
1458
+ if (body === undefined) {
1459
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected terms of payment payload.`);
1460
+ }
1461
+ return body;
1462
+ }
1463
+ async function fetchTermOfPayment(options) {
1464
+ const { clientId, fiscalYearId, termOfPaymentId, select } = options;
1465
+ const body = await sendAccountingRequest({
1466
+ ...options,
1467
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment/${encodeURIComponent(termOfPaymentId)}`,
1468
+ method: "GET",
1469
+ query: {
1470
+ select: select,
1471
+ },
1472
+ });
1473
+ if (body === undefined) {
1474
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected term of payment payload.`);
1475
+ }
1476
+ return body;
1477
+ }
1478
+ async function createTermOfPayment(options) {
1479
+ const { clientId, fiscalYearId, termOfPaymentData } = options;
1480
+ return sendAccountingRequest({
1481
+ ...options,
1482
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment`,
1483
+ method: "POST",
1484
+ body: termOfPaymentData,
1485
+ });
1486
+ }
1487
+ async function updateTermOfPayment(options) {
1488
+ const { clientId, fiscalYearId, termOfPaymentId, termOfPaymentData } = options;
1489
+ return sendAccountingRequest({
1490
+ ...options,
1491
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment/${encodeURIComponent(termOfPaymentId)}`,
1492
+ method: "PUT",
1493
+ body: termOfPaymentData,
1494
+ });
1495
+ }
1496
+ // Stocktaking Data functions
1497
+ async function fetchStocktakingData(options) {
1498
+ const { clientId, fiscalYearId, filter, select, skip, top } = options;
1499
+ const body = await sendAccountingRequest({
1500
+ ...options,
1501
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/assets/stocktakings`,
1502
+ method: "GET",
1503
+ query: {
1504
+ filter: filter,
1505
+ select: select,
1506
+ skip: skip,
1507
+ top: top,
1508
+ },
1509
+ });
1510
+ if (body === undefined) {
1511
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected stocktaking data payload.`);
1512
+ }
1513
+ return body;
1514
+ }
1515
+ async function fetchStocktakingDataByAsset(options) {
1516
+ const { clientId, fiscalYearId, assetId, select, skip, top } = options;
1517
+ const body = await sendAccountingRequest({
1518
+ ...options,
1519
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/assets/${encodeURIComponent(assetId)}/stocktaking/`,
1520
+ method: "GET",
1521
+ query: {
1522
+ select: select,
1523
+ skip: skip,
1524
+ top: top,
1525
+ },
1526
+ });
1527
+ if (body === undefined) {
1528
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected stocktaking data by asset payload.`);
1529
+ }
1530
+ return body;
1531
+ }
1532
+ async function updateStocktakingData(options) {
1533
+ const { clientId, fiscalYearId, assetId, stocktakingData } = options;
1534
+ return sendAccountingRequest({
1535
+ ...options,
1536
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/assets/${encodeURIComponent(assetId)}/stocktaking/`,
1537
+ method: "PUT",
1538
+ body: stocktakingData,
1539
+ });
1540
+ }
1541
+ // Cost Systems functions
1542
+ async function fetchCostSystems(options) {
1543
+ const { clientId, fiscalYearId, select, skip, top } = options;
1544
+ const body = await sendAccountingRequest({
1545
+ ...options,
1546
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems`,
1547
+ method: "GET",
1548
+ query: {
1549
+ select: select,
1550
+ skip: skip,
1551
+ top: top,
1552
+ },
1553
+ });
1554
+ if (body === undefined) {
1555
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost systems payload.`);
1556
+ }
1557
+ return body;
1558
+ }
1559
+ async function fetchCostSystem(options) {
1560
+ const { clientId, fiscalYearId, costSystemId, select } = options;
1561
+ const body = await sendAccountingRequest({
1562
+ ...options,
1563
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}`,
1564
+ method: "GET",
1565
+ query: {
1566
+ select: select,
1567
+ },
1568
+ });
1569
+ if (body === undefined) {
1570
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost system payload.`);
1571
+ }
1572
+ return body;
1573
+ }
1574
+ // Cost Centers functions
1575
+ async function fetchCostCenters(options) {
1576
+ const { clientId, fiscalYearId, costSystemId, select, top, skip } = options;
1577
+ const body = await sendAccountingRequest({
1578
+ ...options,
1579
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-centers`,
1580
+ method: "GET",
1581
+ query: {
1582
+ select: select,
1583
+ top: top,
1584
+ skip: skip,
1585
+ },
1586
+ });
1587
+ if (body === undefined) {
1588
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost centers payload.`);
1589
+ }
1590
+ return body;
1591
+ }
1592
+ async function fetchCostCenter(options) {
1593
+ const { clientId, fiscalYearId, costSystemId, costCenterId, select } = options;
1594
+ const body = await sendAccountingRequest({
1595
+ ...options,
1596
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-centers/${encodeURIComponent(costCenterId)}`,
1597
+ method: "GET",
1598
+ query: {
1599
+ select: select,
1600
+ },
1601
+ });
1602
+ if (body === undefined) {
1603
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost center payload.`);
1604
+ }
1605
+ return body;
1606
+ }
1607
+ // Cost Center Properties functions
1608
+ async function fetchCostCenterProperties(options) {
1609
+ const { clientId, fiscalYearId, costSystemId, select, skip, top } = options;
1610
+ const body = await sendAccountingRequest({
1611
+ ...options,
1612
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-center-properties`,
1613
+ method: "GET",
1614
+ query: {
1615
+ select: select,
1616
+ skip: skip,
1617
+ top: top,
1618
+ },
1619
+ });
1620
+ if (body === undefined) {
1621
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost center properties payload.`);
1622
+ }
1623
+ return body;
1624
+ }
1625
+ async function fetchCostCenterProperty(options) {
1626
+ const { clientId, fiscalYearId, costSystemId, costCenterPropertyId, select } = options;
1627
+ const body = await sendAccountingRequest({
1628
+ ...options,
1629
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-center-properties/${encodeURIComponent(costCenterPropertyId)}`,
1630
+ method: "GET",
1631
+ query: {
1632
+ select: select,
1633
+ },
1634
+ });
1635
+ if (body === undefined) {
1636
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost center property payload.`);
1637
+ }
1638
+ return body;
1639
+ }
1640
+ // Internal Cost Services functions
1641
+ async function createInternalCostService(options) {
1642
+ const { clientId, fiscalYearId, costSystemId, internalCostServiceData } = options;
1643
+ return sendAccountingRequest({
1644
+ ...options,
1645
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/internal-cost-services`,
1646
+ method: "POST",
1647
+ body: internalCostServiceData,
1648
+ });
1649
+ }
1650
+ // Cost Sequences functions
1651
+ async function fetchCostSequences(options) {
1652
+ const { clientId, fiscalYearId, costSystemId, select, skip, top } = options;
1653
+ const body = await sendAccountingRequest({
1654
+ ...options,
1655
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences`,
1656
+ method: "GET",
1657
+ query: {
1658
+ select: select,
1659
+ skip: skip,
1660
+ top: top,
1661
+ },
1662
+ });
1663
+ if (body === undefined) {
1664
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost sequences payload.`);
1665
+ }
1666
+ return body;
1667
+ }
1668
+ async function fetchCostSequence(options) {
1669
+ const { clientId, fiscalYearId, costSystemId, costSequenceId, select } = options;
1670
+ const body = await sendAccountingRequest({
1671
+ ...options,
1672
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences/${encodeURIComponent(costSequenceId)}`,
1673
+ method: "GET",
1674
+ query: {
1675
+ select: select,
1676
+ },
1677
+ });
1678
+ if (body === undefined) {
1679
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost sequence payload.`);
1680
+ }
1681
+ return body;
1682
+ }
1683
+ async function createCostSequence(options) {
1684
+ const { clientId, fiscalYearId, costSystemId, costSequenceId, costSequenceData } = options;
1685
+ return sendAccountingRequest({
1686
+ ...options,
1687
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences/${encodeURIComponent(costSequenceId)}`,
1688
+ method: "POST",
1689
+ body: costSequenceData,
1690
+ });
1691
+ }
1692
+ async function fetchCostAccountingRecords(options) {
1693
+ const { clientId, fiscalYearId, costSystemId, costSequenceId, select, skip, top } = options;
1694
+ const body = await sendAccountingRequest({
1695
+ ...options,
1696
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences/${encodeURIComponent(costSequenceId)}/cost-accounting-records`,
1697
+ method: "GET",
1698
+ query: {
1699
+ select: select,
1700
+ skip: skip,
1701
+ top: top,
1702
+ },
1703
+ });
1704
+ if (body === undefined) {
1705
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost accounting records payload.`);
1706
+ }
1707
+ return body;
1708
+ }
1709
+ // Accounting Statistics functions
1710
+ async function fetchAccountingStatistics(options) {
1711
+ const { clientId, fiscalYearId, select, filter, skip, top } = options;
1712
+ const body = await sendAccountingRequest({
1713
+ ...options,
1714
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-statistics`,
1715
+ method: "GET",
1716
+ query: {
1717
+ select: select,
1718
+ filter: filter,
1719
+ skip: skip,
1720
+ top: top,
1721
+ },
1722
+ });
1723
+ if (body === undefined) {
1724
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting statistics payload.`);
1725
+ }
1726
+ return body;
1727
+ }
1728
+ // Accounting Transaction Keys functions
1729
+ async function fetchAccountingTransactionKeys(options) {
1730
+ const { clientId, fiscalYearId, select, skip, top } = options;
1731
+ const body = await sendAccountingRequest({
1732
+ ...options,
1733
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-transaction-keys`,
1734
+ method: "GET",
1735
+ query: {
1736
+ select: select,
1737
+ skip: skip,
1738
+ top: top,
1739
+ },
1740
+ });
1741
+ if (body === undefined) {
1742
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting transaction keys payload.`);
1743
+ }
1744
+ return body;
1745
+ }
1746
+ async function fetchAccountingTransactionKey(options) {
1747
+ const { clientId, fiscalYearId, accountingTransactionKeyId, select, filter, skip, top } = options;
1748
+ const body = await sendAccountingRequest({
1749
+ ...options,
1750
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-transaction-keys/${encodeURIComponent(accountingTransactionKeyId)}`,
1751
+ method: "GET",
1752
+ query: {
1753
+ select: select,
1754
+ filter: filter,
1755
+ skip: skip,
1756
+ top: top,
1757
+ },
1758
+ });
1759
+ if (body === undefined) {
1760
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting transaction key payload.`);
1761
+ }
1762
+ return body;
1763
+ }
1764
+ // Various Addresses functions
1765
+ async function fetchVariousAddresses(options) {
1766
+ const { clientId, fiscalYearId, select, skip, top, expand } = options;
1767
+ const body = await sendAccountingRequest({
1768
+ ...options,
1769
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/various-addresses`,
1770
+ method: "GET",
1771
+ query: {
1772
+ select: select,
1773
+ skip: skip,
1774
+ top: top,
1775
+ expand: expand,
1776
+ },
1777
+ });
1778
+ if (body === undefined) {
1779
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected various addresses payload.`);
1780
+ }
1781
+ return body;
1782
+ }
1783
+ async function fetchVariousAddress(options) {
1784
+ const { clientId, fiscalYearId, variousAddressId, select, skip, top, expand } = options;
1785
+ const body = await sendAccountingRequest({
1786
+ ...options,
1787
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/various-addresses/${encodeURIComponent(variousAddressId)}`,
1788
+ method: "GET",
1789
+ query: {
1790
+ select: select,
1791
+ skip: skip,
1792
+ top: top,
1793
+ expand: expand,
1794
+ },
1795
+ });
1796
+ if (body === undefined) {
1797
+ throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected various address payload.`);
1798
+ }
1799
+ return body;
1800
+ }
1801
+ async function createVariousAddress(options) {
1802
+ const { clientId, fiscalYearId, variousAddressData } = options;
1803
+ return sendAccountingRequest({
1804
+ ...options,
1805
+ path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/various-addresses`,
1806
+ method: "POST",
1807
+ body: variousAddressData,
1808
+ });
1809
+ }