@genz-its/sevdesk-sdk 0.0.0

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.
@@ -0,0 +1,1990 @@
1
+ //#region src/http-client.d.ts
2
+ declare const DEFAULT_BASE_URL = "https://my.sevdesk.de/api/v1";
3
+ interface SevDeskOptions {
4
+ /** The sevdesk API token, sent as raw `Authorization` header value. */
5
+ token: string;
6
+ baseUrl?: string;
7
+ /** Request timeout in milliseconds. Defaults to 30 seconds. */
8
+ timeout?: number;
9
+ userAgent?: string;
10
+ fetch?: typeof globalThis.fetch;
11
+ }
12
+ type QueryValue = string | number | boolean | string[] | undefined;
13
+ type Query = Record<string, QueryValue>;
14
+ interface HttpRequestOptions {
15
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
16
+ path: string;
17
+ query?: Query;
18
+ body?: unknown;
19
+ formData?: FormData;
20
+ }
21
+ declare class HttpClient {
22
+ private readonly token;
23
+ private readonly baseUrl;
24
+ private readonly timeout;
25
+ private readonly userAgent;
26
+ private readonly fetch;
27
+ constructor(options: SevDeskOptions);
28
+ /**
29
+ * Performs a request and returns the payload of the `objects` response
30
+ * envelope. Responses without an envelope are returned as-is.
31
+ */
32
+ request<T>(options: HttpRequestOptions): Promise<T>;
33
+ private fetchWithRetry;
34
+ private buildUrl;
35
+ private buildRequestInit;
36
+ }
37
+ //#endregion
38
+ //#region src/resources/base.d.ts
39
+ declare abstract class BaseResource {
40
+ protected readonly http: HttpClient;
41
+ constructor(http: HttpClient);
42
+ }
43
+ //#endregion
44
+ //#region src/resources/basics.d.ts
45
+ type BookkeepingSystemVersion = '1.0' | '2.0';
46
+ declare class BasicsResource extends BaseResource {
47
+ /** Retrieves the bookkeeping system version via `GET /Tools/bookkeepingSystemVersion`. */
48
+ getBookkeepingSystemVersion(): Promise<BookkeepingSystemVersion>;
49
+ }
50
+ //#endregion
51
+ //#region src/types.d.ts
52
+ /**
53
+ * Accepted date representations for request options. Numbers are interpreted
54
+ * as Unix timestamps in seconds, strings are passed through unchanged.
55
+ */
56
+ type DateInput = Date | string | number;
57
+ interface ListOptions {
58
+ limit?: number;
59
+ offset?: number;
60
+ }
61
+ /** Reference to a related object in request bodies. */
62
+ interface ModelRef {
63
+ id: number;
64
+ objectName: string;
65
+ }
66
+ /**
67
+ * Reference to a related object in responses. The sevdesk API returns all
68
+ * scalar values in responses as strings, including ids.
69
+ */
70
+ interface ModelRefResponse {
71
+ id: string;
72
+ objectName: string;
73
+ }
74
+ //#endregion
75
+ //#region src/resources/check-accounts.d.ts
76
+ /** A payment account, e.g. a bank account or a clearing account. */
77
+ interface CheckAccount {
78
+ id: string;
79
+ objectName: string;
80
+ create: string;
81
+ update: string;
82
+ sevClient: ModelRefResponse;
83
+ name: string;
84
+ iban: string | null;
85
+ type: 'online' | 'offline' | 'register';
86
+ importType: 'CSV' | 'MT940' | null;
87
+ currency: string;
88
+ defaultAccount: string;
89
+ baseAccount: string;
90
+ priority: string;
91
+ status: string;
92
+ balance: string | null;
93
+ bankServer: string | null;
94
+ autoMapTransactions: string | null;
95
+ autoSyncTransactions: string;
96
+ lastSync: string;
97
+ accountingNumber: string;
98
+ bic: string | null;
99
+ }
100
+ interface CreateFileImportAccountOptions {
101
+ name: string;
102
+ importType: 'CSV' | 'MT940';
103
+ accountingNumber?: number;
104
+ iban?: string;
105
+ }
106
+ interface CreateClearingAccountOptions {
107
+ name: string;
108
+ accountingNumber?: number;
109
+ }
110
+ interface UpdateCheckAccountOptions {
111
+ checkAccountId: number;
112
+ name?: string;
113
+ defaultAccount?: number;
114
+ autoMapTransactions?: number;
115
+ accountingNumber?: number;
116
+ iban?: string;
117
+ bic?: string;
118
+ }
119
+ declare class CheckAccountsResource extends BaseResource {
120
+ /** Retrieves all check accounts via `GET /CheckAccount`. */
121
+ list(options?: ListOptions): Promise<CheckAccount[]>;
122
+ /** Retrieves a single check account via `GET /CheckAccount/{checkAccountId}`. */
123
+ get(options: {
124
+ checkAccountId: number;
125
+ }): Promise<CheckAccount>;
126
+ /** Creates a file import account via `POST /CheckAccount/Factory/fileImportAccount`. */
127
+ createFileImportAccount(options: CreateFileImportAccountOptions): Promise<CheckAccount>;
128
+ /** Creates a clearing account via `POST /CheckAccount/Factory/clearingAccount`. */
129
+ createClearingAccount(options: CreateClearingAccountOptions): Promise<CheckAccount>;
130
+ /** Updates a check account via `PUT /CheckAccount/{checkAccountId}`. */
131
+ update(options: UpdateCheckAccountOptions): Promise<CheckAccount>;
132
+ /** Deletes a check account via `DELETE /CheckAccount/{checkAccountId}`. */
133
+ delete(options: {
134
+ checkAccountId: number;
135
+ }): Promise<void>;
136
+ /**
137
+ * Retrieves the balance at a date via `GET /CheckAccount/{checkAccountId}/getBalanceAtDate`.
138
+ *
139
+ * The balance is the sum of all transactions sevdesk knows up to and
140
+ * including the given date. It does not have to match the actual bank
141
+ * account balance, e.g. if old transactions were never imported.
142
+ */
143
+ getBalanceAtDate(options: {
144
+ checkAccountId: number;
145
+ date: DateInput;
146
+ }): Promise<string>;
147
+ }
148
+ //#endregion
149
+ //#region src/resources/contacts.d.ts
150
+ /** `100` for a lead, `500` for a pending and `1000` for an active contact. */
151
+ type ContactStatus = 100 | 500 | 1000;
152
+ interface ListContactsOptions extends ListOptions {
153
+ /**
154
+ * `'0'` returns only organizations, `'1'` organizations and persons.
155
+ * Defaults to `'0'`.
156
+ */
157
+ depth?: '0' | '1';
158
+ customerNumber?: string;
159
+ /** Matches the `name`, `surename` or `familyname` of a contact. */
160
+ name?: string;
161
+ categoryId?: number;
162
+ /** Only returns contacts belonging to this organization. */
163
+ parentId?: number;
164
+ embed?: string[];
165
+ }
166
+ interface CreateContactOptions {
167
+ /**
168
+ * The category of the contact. The sevdesk default categories are `2` for a
169
+ * supplier, `3` for a customer, `4` for a partner and `28` for a prospect
170
+ * customer.
171
+ */
172
+ categoryId: number;
173
+ /**
174
+ * The organization name. A contact holding a name is regarded as an
175
+ * organization, one holding a `surename` or `familyname` as a person.
176
+ */
177
+ name?: string;
178
+ /** The **first** name of a person. Not to be used for organizations. */
179
+ surename?: string;
180
+ /** The last name of a person. Not to be used for organizations. */
181
+ familyname?: string;
182
+ /** The middle name or name suffix of a person. */
183
+ name2?: string;
184
+ /** A non-academic title, e.g. the position the person holds. */
185
+ titel?: string;
186
+ academicTitle?: string;
187
+ gender?: string;
188
+ /** The organization this person belongs to. */
189
+ parentId?: number;
190
+ customerNumber?: string;
191
+ status?: ContactStatus;
192
+ description?: string;
193
+ vatNumber?: string;
194
+ taxNumber?: string;
195
+ /** Defines if the contact is freed from paying vat. */
196
+ exemptVat?: boolean;
197
+ /** Bank account number (IBAN) of the contact. */
198
+ bankAccount?: string;
199
+ bankNumber?: string;
200
+ /** The payment goal in days which is set for every invoice of the contact. */
201
+ defaultTimeToPay?: number;
202
+ /** Buyer reference of the contact, required for e-invoices. */
203
+ buyerReference?: string;
204
+ governmentAgency?: boolean;
205
+ }
206
+ interface UpdateContactOptions extends Partial<CreateContactOptions> {
207
+ contactId: number;
208
+ }
209
+ interface FindContactsByCustomFieldValueOptions {
210
+ /** The value to be checked. */
211
+ value: string;
212
+ /** The name of the contact custom field setting. */
213
+ customFieldName: string;
214
+ /** Restricts the lookup to a single contact custom field setting. */
215
+ customFieldSettingId?: number;
216
+ }
217
+ interface Contact {
218
+ id: string;
219
+ objectName: string;
220
+ create: string;
221
+ update: string;
222
+ sevClient: ModelRefResponse;
223
+ name: string | null;
224
+ status: string | null;
225
+ customerNumber: string | null;
226
+ parent: ModelRefResponse | null;
227
+ surename: string | null;
228
+ familyname: string | null;
229
+ titel: string | null;
230
+ category: ModelRefResponse;
231
+ description: string | null;
232
+ academicTitle: string | null;
233
+ gender: string | null;
234
+ name2: string | null;
235
+ birthday: string | null;
236
+ vatNumber: string | null;
237
+ bankAccount: string | null;
238
+ bankNumber: string | null;
239
+ defaultCashbackTime: string | null;
240
+ defaultCashbackPercent: string | null;
241
+ defaultTimeToPay: string | null;
242
+ taxNumber: string | null;
243
+ taxOffice: string | null;
244
+ exemptVat: string | null;
245
+ defaultDiscountAmount: string | null;
246
+ defaultDiscountPercentage: string | null;
247
+ buyerReference: string | null;
248
+ governmentAgency: string | null;
249
+ }
250
+ /** Number of documents of a contact, grouped by document type. */
251
+ interface ContactTabsItemCount {
252
+ orders: number;
253
+ invoices: number;
254
+ creditNotes: number;
255
+ documents: number;
256
+ persons: number;
257
+ vouchers: number;
258
+ letters: number;
259
+ parts: string;
260
+ invoicePos: number;
261
+ }
262
+ declare class ContactsResource extends BaseResource {
263
+ /** Retrieves contacts via `GET /Contact`. */
264
+ list(options?: ListContactsOptions): Promise<Contact[]>;
265
+ /** Retrieves a single contact via `GET /Contact/{contactId}`. */
266
+ get(options: {
267
+ contactId: number;
268
+ }): Promise<Contact>;
269
+ /** Creates a contact via `POST /Contact`. */
270
+ create(options: CreateContactOptions): Promise<Contact>;
271
+ /** Updates a contact via `PUT /Contact/{contactId}`. */
272
+ update(options: UpdateContactOptions): Promise<Contact>;
273
+ /** Deletes a contact via `DELETE /Contact/{contactId}`. */
274
+ delete(options: {
275
+ contactId: number;
276
+ }): Promise<void>;
277
+ /** Retrieves the next free customer number via `GET /Contact/Factory/getNextCustomerNumber`. */
278
+ getNextCustomerNumber(): Promise<string>;
279
+ /** Retrieves contacts by a custom field value via `GET /Contact/Factory/findContactsByCustomFieldValue`. */
280
+ findByCustomFieldValue(options: FindContactsByCustomFieldValueOptions): Promise<Contact[]>;
281
+ /** Checks if a customer number is still free via `GET /Contact/Mapper/checkCustomerNumberAvailability`. */
282
+ checkCustomerNumberAvailability(options: {
283
+ customerNumber: string;
284
+ }): Promise<boolean>;
285
+ /** Retrieves the document counts of a contact via `GET /Contact/{contactId}/getTabsItemCount`. */
286
+ getTabsItemCount(options: {
287
+ contactId: number;
288
+ }): Promise<ContactTabsItemCount>;
289
+ }
290
+ //#endregion
291
+ //#region src/resources/credit-notes.d.ts
292
+ /**
293
+ * Status of a credit note.
294
+ *
295
+ * - `100` draft
296
+ * - `200` open / delivered
297
+ * - `750` partially paid
298
+ * - `1000` paid
299
+ */
300
+ type CreditNoteStatus = 100 | 200 | 750 | 1000;
301
+ /**
302
+ * Reason why the credit note was created. `ACCOUNTING_TYPE` is not supported
303
+ * by bookkeeping system 2.0 and therefore not available.
304
+ */
305
+ type CreditNoteBookingCategory = 'PROVISION' | 'ROYALTY_ASSIGNED' | 'ROYALTY_UNASSIGNED' | 'UNDERACHIEVEMENT';
306
+ /**
307
+ * Way in which a credit note was sent to the end-customer: `VPR` printed,
308
+ * `VP` postal, `VM` mailed, `VPDF` downloaded pdf.
309
+ */
310
+ type CreditNoteSendType = 'VPR' | 'VP' | 'VM' | 'VPDF';
311
+ type CreditNoteBookingType = 'FULL_PAYMENT' | 'N' | 'CB' | 'O' | 'OF' | 'MTC';
312
+ interface CreditNoteInput {
313
+ creditNoteNumber: string;
314
+ creditNoteDate: DateInput;
315
+ contactId: number;
316
+ status: CreditNoteStatus;
317
+ /** Usually consists of a prefix and the credit note number. */
318
+ header: string;
319
+ bookingCategory: CreditNoteBookingCategory;
320
+ /** The sevdesk user acting as the contact person. */
321
+ contactPersonId: number;
322
+ /** Defines the vat regulation, for example `1` for "Umsatzsteuerpflichtige Umsätze". */
323
+ taxRuleId: number;
324
+ /** Not used anymore, the tax rate of the positions is used instead. */
325
+ taxRate: number;
326
+ /** Text describing the vat regulation, for example `Umsatzsteuer 19%`. */
327
+ taxText: string;
328
+ /** Currency code according to ISO-4217. */
329
+ currency: string;
330
+ deliveryDate: DateInput;
331
+ /** Can be omitted as the complete address is defined in `address`. */
332
+ addressCountryId?: number;
333
+ headText?: string;
334
+ footText?: string;
335
+ /** Complete address of the recipient. Line breaks are kept in the pdf. */
336
+ address?: string;
337
+ smallSettlement?: boolean;
338
+ /** `true` if the position prices are net, `false` if they are gross. */
339
+ showNet?: boolean;
340
+ customerInternalNote?: string;
341
+ sendDate?: DateInput;
342
+ sendType?: CreditNoteSendType;
343
+ }
344
+ interface CreditNotePositionInput {
345
+ unityId: number;
346
+ quantity: number;
347
+ taxRate: number;
348
+ name?: string;
349
+ /** Price of one unit. Is either net or gross, depending on `showNet`. */
350
+ price?: number;
351
+ text?: string;
352
+ partId?: number;
353
+ /** Starts at zero and is incremented for every further position. */
354
+ positionNumber?: number;
355
+ discount?: number;
356
+ optional?: boolean;
357
+ }
358
+ interface SaveCreditNoteOptions {
359
+ creditNote: CreditNoteInput;
360
+ positions: CreditNotePositionInput[];
361
+ }
362
+ interface ListCreditNotesOptions extends ListOptions {
363
+ status?: CreditNoteStatus;
364
+ creditNoteNumber?: string;
365
+ startDate?: DateInput;
366
+ endDate?: DateInput;
367
+ contactId?: number;
368
+ embed?: string[];
369
+ }
370
+ interface UpdateCreditNoteOptions {
371
+ creditNoteId: number;
372
+ creditNoteNumber?: string;
373
+ creditNoteDate?: DateInput;
374
+ status?: CreditNoteStatus;
375
+ header?: string;
376
+ headText?: string;
377
+ footText?: string;
378
+ address?: string;
379
+ customerInternalNote?: string;
380
+ deliveryDate?: DateInput;
381
+ }
382
+ interface SendCreditNoteViaEmailOptions {
383
+ creditNoteId: number;
384
+ toEmail: string;
385
+ subject: string;
386
+ /** Can contain html. */
387
+ text: string;
388
+ /** Send a copy of the email to yourself. */
389
+ copy?: boolean;
390
+ /** Ids of existing documents in your sevdesk account, separated by `,`. */
391
+ additionalAttachments?: string;
392
+ /** Mail addresses to be put as cc, separated by `,`. */
393
+ ccEmail?: string;
394
+ /** Mail addresses to be put as bcc, separated by `,`. */
395
+ bccEmail?: string;
396
+ }
397
+ interface SendCreditNoteByOptions {
398
+ creditNoteId: number;
399
+ sendType: CreditNoteSendType;
400
+ /**
401
+ * Creates a draft for internal use. Neither the status of the credit note
402
+ * nor the bookings for reports are changed.
403
+ */
404
+ sendDraft: boolean;
405
+ }
406
+ interface BookCreditNoteOptions {
407
+ creditNoteId: number;
408
+ /** Can also be a partial amount. */
409
+ amount: number;
410
+ date: DateInput;
411
+ type: CreditNoteBookingType;
412
+ checkAccountId: number;
413
+ /**
414
+ * Required for online check accounts. Must be omitted for offline check
415
+ * accounts and cash registers, where the transaction is created automatically.
416
+ */
417
+ checkAccountTransactionId?: number;
418
+ createFeed?: boolean;
419
+ }
420
+ interface ListCreditNotePositionsOptions extends ListOptions {
421
+ creditNoteId?: number;
422
+ embed?: string[];
423
+ }
424
+ interface CreditNote {
425
+ id: string;
426
+ objectName: string;
427
+ create: string;
428
+ update: string;
429
+ sevClient: ModelRefResponse;
430
+ createUser: ModelRefResponse;
431
+ creditNoteNumber: string | null;
432
+ contact: ModelRefResponse | null;
433
+ creditNoteDate: string;
434
+ status: string;
435
+ header: string | null;
436
+ headText: string | null;
437
+ footText: string | null;
438
+ addressCountry: ModelRefResponse | null;
439
+ deliveryDate: string;
440
+ smallSettlement: boolean | null;
441
+ contactPerson: ModelRefResponse | null;
442
+ taxRate: string | null;
443
+ taxRule: ModelRefResponse;
444
+ taxText: string | null;
445
+ sendDate: string | null;
446
+ address: string | null;
447
+ currency: string | null;
448
+ sumNet: string;
449
+ sumTax: string;
450
+ sumGross: string;
451
+ sumDiscounts: string;
452
+ sumNetForeignCurrency: string;
453
+ sumTaxForeignCurrency: string;
454
+ sumGrossForeignCurrency: string;
455
+ sumDiscountsForeignCurrency: string;
456
+ customerInternalNote: string | null;
457
+ showNet: boolean;
458
+ sendType: string | null;
459
+ }
460
+ interface CreditNotePosition {
461
+ id: string;
462
+ objectName: string;
463
+ create: string;
464
+ update: string;
465
+ sevClient: ModelRefResponse;
466
+ creditNote: ModelRefResponse;
467
+ part: ModelRefResponse | null;
468
+ quantity: string;
469
+ price: string | null;
470
+ priceNet: string | null;
471
+ priceTax: string | null;
472
+ priceGross: string | null;
473
+ name: string | null;
474
+ unity: ModelRefResponse;
475
+ positionNumber: string | null;
476
+ text: string | null;
477
+ discount: string | null;
478
+ optional: boolean | null;
479
+ taxRate: string;
480
+ sumDiscount: string | null;
481
+ }
482
+ interface CreditNoteDiscount {
483
+ id: string;
484
+ objectName: string;
485
+ create: string;
486
+ update: string;
487
+ sevClient: string;
488
+ /** `1` for a discount, `0` for a surcharge. */
489
+ discount: string;
490
+ text: string;
491
+ /** `1` if `value` is a percentage, `0` if it is an absolute amount. */
492
+ percentage: string;
493
+ value: string;
494
+ /** `0` if the discount is net, `1` if it is gross. */
495
+ isNet: string;
496
+ }
497
+ interface CreditNoteMail {
498
+ id: string;
499
+ objectName: string;
500
+ additionalInformation: string | null;
501
+ create: string;
502
+ update: string;
503
+ object: CreditNote;
504
+ from: string;
505
+ to: string;
506
+ subject: string;
507
+ text: string;
508
+ sevClient: ModelRefResponse;
509
+ }
510
+ interface CreditNotePdf {
511
+ filename: string;
512
+ mimeType: string;
513
+ base64encoded: boolean;
514
+ /** The pdf document, base64 encoded. */
515
+ content: string;
516
+ }
517
+ interface SaveCreditNoteResult {
518
+ creditNote: CreditNote;
519
+ positions: CreditNotePosition[];
520
+ }
521
+ interface CreateCreditNoteFromInvoiceResult extends SaveCreditNoteResult {
522
+ discounts: CreditNoteDiscount[];
523
+ }
524
+ interface BookCreditNoteResult {
525
+ id: string;
526
+ objectName: string;
527
+ additionalInformation: string | null;
528
+ create: string;
529
+ creditNote: ModelRefResponse;
530
+ fromStatus: string;
531
+ toStatus: string;
532
+ /** Spelled with two `m` by the sevdesk API. */
533
+ ammountPayed: string;
534
+ bookingDate: string;
535
+ sevClient: ModelRefResponse;
536
+ }
537
+ declare class CreditNotesResource extends BaseResource {
538
+ /** Retrieves credit notes via `GET /CreditNote`. */
539
+ list(options?: ListCreditNotesOptions): Promise<CreditNote[]>;
540
+ /** Retrieves a single credit note via `GET /CreditNote/{creditNoteId}`. */
541
+ get(options: {
542
+ creditNoteId: number;
543
+ }): Promise<CreditNote>;
544
+ /** Creates or updates a credit note with its positions via `POST /CreditNote/Factory/saveCreditNote`. */
545
+ save(options: SaveCreditNoteOptions): Promise<SaveCreditNoteResult>;
546
+ /** Creates a credit note from an invoice via `POST /CreditNote/Factory/createFromInvoice`. */
547
+ createFromInvoice(options: {
548
+ invoiceId: number;
549
+ }): Promise<CreateCreditNoteFromInvoiceResult>;
550
+ /** Updates a credit note via `PUT /CreditNote/{creditNoteId}`. */
551
+ update(options: UpdateCreditNoteOptions): Promise<CreditNote>;
552
+ /** Deletes a credit note via `DELETE /CreditNote/{creditNoteId}`. */
553
+ delete(options: {
554
+ creditNoteId: number;
555
+ }): Promise<void>;
556
+ /** Sends a credit note via email using `POST /CreditNote/{creditNoteId}/sendViaEmail`. */
557
+ sendViaEmail(options: SendCreditNoteViaEmailOptions): Promise<CreditNoteMail[]>;
558
+ /** Retrieves the pdf of a credit note via `GET /CreditNote/{creditNoteId}/getPdf`. */
559
+ getPdf(options: {
560
+ creditNoteId: number;
561
+ /** Prevents the credit note from being marked as sent. */
562
+ preventSendBy?: boolean;
563
+ }): Promise<CreditNotePdf>;
564
+ /** Marks a credit note as sent via `PUT /CreditNote/{creditNoteId}/sendBy`. */
565
+ sendBy(options: SendCreditNoteByOptions): Promise<CreditNote>;
566
+ /** Books an amount on a credit note via `PUT /CreditNote/{creditNoteId}/bookAmount`. */
567
+ book(options: BookCreditNoteOptions): Promise<BookCreditNoteResult>;
568
+ /** Enshrines a credit note via `PUT /CreditNote/{creditNoteId}/enshrine`. This cannot be undone. */
569
+ enshrine(options: {
570
+ creditNoteId: number;
571
+ }): Promise<void>;
572
+ /** Resets the credit note status to open via `PUT /CreditNote/{creditNoteId}/resetToOpen`. */
573
+ resetToOpen(options: {
574
+ creditNoteId: number;
575
+ }): Promise<CreditNote>;
576
+ /** Resets the credit note status to draft via `PUT /CreditNote/{creditNoteId}/resetToDraft`. */
577
+ resetToDraft(options: {
578
+ creditNoteId: number;
579
+ }): Promise<CreditNote>;
580
+ /** Retrieves credit note positions via `GET /CreditNotePos`. */
581
+ listPositions(options?: ListCreditNotePositionsOptions): Promise<CreditNotePosition[]>;
582
+ }
583
+ //#endregion
584
+ //#region src/resources/exports.d.ts
585
+ /** A file generated by an export, returned inside the response envelope. */
586
+ interface ExportFile {
587
+ filename: string;
588
+ mimetype: string;
589
+ base64Encoded: boolean;
590
+ /** The file content, base64 encoded when `base64Encoded` is `true`. */
591
+ content: string;
592
+ }
593
+ /** Progress of an export job. The job is finished once `current` reaches `total`. */
594
+ interface ExportProgress {
595
+ current: number;
596
+ total: number;
597
+ }
598
+ interface ExportJobDownloadInfo {
599
+ filename: string;
600
+ /** Download url of the export file. */
601
+ link: string;
602
+ /** Expiry date of the download url. */
603
+ linkExpireDate: string;
604
+ }
605
+ interface ExportConfigOptions {
606
+ sevClientId: number;
607
+ accountantNumber: number;
608
+ accountantClientNumber: number;
609
+ /** Begin of the accounting year, sent as Unix timestamp. */
610
+ accountingYearBegin: DateInput;
611
+ }
612
+ interface ExportDatevCsvJobOptions {
613
+ /** Sent as Unix timestamp. */
614
+ startDate: DateInput;
615
+ /** Sent as Unix timestamp. */
616
+ endDate: DateInput;
617
+ /**
618
+ * The models to include, given as a string of letters: `E` (earnings),
619
+ * `X` (expenditure), `T` (transactions), `C` (cash register) and
620
+ * `D` (assets), for example `EXTCD`.
621
+ */
622
+ scope: string;
623
+ /** Includes only documents paid between `startDate` and `endDate`. Defaults to `false`. */
624
+ exportByPaydate?: boolean;
625
+ /** Defaults to `true`. */
626
+ includeEnshrined?: boolean;
627
+ /** Enshrines all exported models. Defaults to `false`. */
628
+ enshrineDocuments?: boolean;
629
+ /** Defaults to `false`. */
630
+ includeDocumentImages?: boolean;
631
+ }
632
+ interface ExportDatevXmlJobOptions {
633
+ /** Sent as Unix timestamp. */
634
+ startDate: DateInput;
635
+ /** Sent as Unix timestamp. */
636
+ endDate: DateInput;
637
+ /**
638
+ * The document types to include, given as a string of letters:
639
+ * `E` (receipts, outgoing invoices and credit notes) and
640
+ * `X` (expenditure documents), for example `EX`.
641
+ */
642
+ scope: string;
643
+ /** Includes only documents paid between `startDate` and `endDate`. Defaults to `false`. */
644
+ exportByPaydate?: boolean;
645
+ /** Defaults to `true`. */
646
+ includeEnshrined?: boolean;
647
+ /** Defaults to `true`. */
648
+ includeExportedDocuments?: boolean;
649
+ /** Includes an XML file with the data of each document. Defaults to `true`. */
650
+ includeDocumentXml?: boolean;
651
+ }
652
+ type ExportInvoiceType = 'RE' | 'SR' | 'TR' | 'AR' | 'ER' | 'WKR' | 'MA';
653
+ /** Filters shared by all document exports. */
654
+ interface ExportDocumentFilter {
655
+ startDate?: DateInput;
656
+ endDate?: DateInput;
657
+ contactId?: number;
658
+ startAmount?: number;
659
+ endAmount?: number;
660
+ }
661
+ interface ExportInvoiceFilter extends ExportDocumentFilter {
662
+ /**
663
+ * `RE` (invoice), `SR` (cancellation invoice), `TR` (partial invoice),
664
+ * `AR` (down payment invoice), `ER` (final invoice),
665
+ * `WKR` (recurring invoice) and `MA` (dunning).
666
+ */
667
+ invoiceType?: ExportInvoiceType[];
668
+ }
669
+ interface ExportVoucherFilter extends ExportDocumentFilter {
670
+ startPayDate?: DateInput;
671
+ endPayDate?: DateInput;
672
+ }
673
+ interface ExportTransactionFilter {
674
+ paymtPurpose?: string;
675
+ /** The name of the payee or payer. */
676
+ name?: string;
677
+ startDate?: DateInput;
678
+ endDate?: DateInput;
679
+ startAmount?: number;
680
+ endAmount?: number;
681
+ checkAccountId?: number;
682
+ }
683
+ interface ExportContactFilter {
684
+ zip?: number;
685
+ city?: string;
686
+ countryId?: number;
687
+ /** Exports only organisations. */
688
+ depth?: boolean;
689
+ /** Exports only people. */
690
+ onlyPeople?: boolean;
691
+ }
692
+ interface ExportInvoicesOptions {
693
+ download?: boolean;
694
+ limit?: number;
695
+ filter?: ExportInvoiceFilter;
696
+ }
697
+ interface ExportCreditNotesOptions {
698
+ download?: boolean;
699
+ limit?: number;
700
+ filter?: ExportDocumentFilter;
701
+ }
702
+ interface ExportVouchersOptions {
703
+ download?: boolean;
704
+ limit?: number;
705
+ filter?: ExportVoucherFilter;
706
+ }
707
+ interface ExportTransactionsOptions {
708
+ download?: boolean;
709
+ limit?: number;
710
+ filter?: ExportTransactionFilter;
711
+ }
712
+ interface ExportContactsOptions {
713
+ download?: boolean;
714
+ limit?: number;
715
+ filter?: ExportContactFilter;
716
+ }
717
+ /** A value of a `sevQuery` parameter before it is flattened into bracket keys. */
718
+ type ExportSevQueryValue = string | number | boolean | ExportSevQueryValue[] | ExportSevQueryObject;
719
+ interface ExportSevQueryObject {
720
+ [key: string]: ExportSevQueryValue | undefined;
721
+ }
722
+ interface ExportSevQueryOptions {
723
+ modelName: string;
724
+ limit?: number;
725
+ filter?: ExportSevQueryObject;
726
+ }
727
+ declare class ExportsResource extends BaseResource {
728
+ /**
729
+ * Updates the export config via `PUT /SevClient/{sevClientId}/updateExportConfig`.
730
+ *
731
+ * The accounting year has to be set once before any DATEV export can be run.
732
+ */
733
+ updateExportConfig(options: ExportConfigOptions): Promise<void>;
734
+ /** Starts a DATEV CSV zip export via `GET /Export/createDatevCsvZipExportJob` and returns the job id. */
735
+ createDatevCsvZipExportJob(options: ExportDatevCsvJobOptions): Promise<string>;
736
+ /** Starts a DATEV XML zip export via `GET /Export/createDatevXmlZipExportJob` and returns the job id. */
737
+ createDatevXmlZipExportJob(options: ExportDatevXmlJobOptions): Promise<string>;
738
+ /** Generates the hash of an export job via `GET /Progress/generateDownloadHash`. */
739
+ generateDownloadHash(options: {
740
+ jobId: string;
741
+ }): Promise<ExportProgress[]>;
742
+ /** Retrieves the progress of an export via `GET /Progress/getProgress`. */
743
+ getProgress(options: {
744
+ hash: string;
745
+ }): Promise<ExportProgress[]>;
746
+ /** Retrieves the download url of a finished export job via `GET /ExportJob/jobDownloadInfo`. */
747
+ getJobDownloadInfo(options: {
748
+ jobId: string;
749
+ }): Promise<ExportJobDownloadInfo[]>;
750
+ /** Exports invoices as CSV via `GET /Export/invoiceCsv`. */
751
+ exportInvoicesCsv(options?: ExportInvoicesOptions): Promise<ExportFile>;
752
+ /** Exports invoices as zip via `GET /Export/invoiceZip`. */
753
+ exportInvoicesZip(options?: ExportInvoicesOptions): Promise<ExportFile>;
754
+ /** Exports credit notes as CSV via `GET /Export/creditNoteCsv`. */
755
+ exportCreditNotesCsv(options?: ExportCreditNotesOptions): Promise<ExportFile>;
756
+ /** Exports vouchers as CSV via `GET /Export/voucherListCsv`. */
757
+ exportVouchersCsv(options?: ExportVouchersOptions): Promise<ExportFile>;
758
+ /** Exports vouchers as zip via `GET /Export/voucherZip`. */
759
+ exportVouchersZip(options?: ExportVouchersOptions): Promise<ExportFile>;
760
+ /** Exports transactions as CSV via `GET /Export/transactionsCsv`. */
761
+ exportTransactionsCsv(options?: ExportTransactionsOptions): Promise<ExportFile>;
762
+ /** Exports contacts as CSV via `GET /Export/contactListCsv`. */
763
+ exportContactsCsv(options?: ExportContactsOptions): Promise<ExportFile>;
764
+ private requestExport;
765
+ }
766
+ /**
767
+ * Flattens a `sevQuery` object into the deep bracket query parameters expected
768
+ * by the export and report endpoints, e.g. `sevQuery[filter][startDate]`.
769
+ */
770
+ declare function toExportSevQueryParams(sevQuery: ExportSevQueryOptions): Query;
771
+ /** Maps a document export filter to its `sevQuery` representation. */
772
+ declare function toExportDocumentFilter(filter?: ExportDocumentFilter): ExportSevQueryObject;
773
+ /** Maps an invoice export filter to its `sevQuery` representation. */
774
+ declare function toExportInvoiceFilter(filter?: ExportInvoiceFilter): ExportSevQueryObject;
775
+ /** Maps a voucher export filter to its `sevQuery` representation. */
776
+ declare function toExportVoucherFilter(filter?: ExportVoucherFilter): ExportSevQueryObject;
777
+ /** Maps a contact export filter to its `sevQuery` representation. */
778
+ declare function toExportContactFilter(filter?: ExportContactFilter): ExportSevQueryObject;
779
+ //#endregion
780
+ //#region src/resources/invoices.d.ts
781
+ /**
782
+ * Status of an invoice.
783
+ *
784
+ * - `50` deactivated recurring invoice, only relevant for recurring invoices
785
+ * - `100` draft, not sent to the end-customer yet and still changeable
786
+ * - `200` open if the pay date is not exceeded, due if it is
787
+ * - `750` partially paid, only set for invoices partially paid after
788
+ * release 4.181 (June 13, 2024). Older ones stay at `200`, use
789
+ * `isPartiallyPaid` for them.
790
+ * - `1000` paid
791
+ */
792
+ type InvoiceStatus = 50 | 100 | 200 | 750 | 1000;
793
+ /**
794
+ * Type of an invoice.
795
+ *
796
+ * - `RE` normal invoice
797
+ * - `WKR` recurring invoice
798
+ * - `SR` cancellation invoice
799
+ * - `MA` invoice reminder
800
+ * - `TR` partial invoice
801
+ * - `AR` advance invoice
802
+ * - `ER` final invoice
803
+ */
804
+ type InvoiceType = 'RE' | 'WKR' | 'SR' | 'MA' | 'TR' | 'AR' | 'ER';
805
+ /** `VPR` printed, `VPDF` downloaded, `VM` mailed, `VP` postal. */
806
+ type InvoiceSendType = 'VPR' | 'VPDF' | 'VM' | 'VP';
807
+ type InvoiceBookingType = 'FULL_PAYMENT' | 'N' | 'CB' | 'O' | 'OF' | 'MTC';
808
+ interface InvoiceInput {
809
+ /**
810
+ * `100` for a draft invoice. Invoices can only be created as drafts, the
811
+ * status is advanced by the dedicated endpoints.
812
+ */
813
+ status: 100;
814
+ invoiceDate: DateInput;
815
+ contactId: number;
816
+ /** The sevdesk user acting as contact person for this invoice. */
817
+ contactPersonId: number;
818
+ invoiceType: InvoiceType;
819
+ /** Currency code according to ISO-4217, for example `EUR`. */
820
+ currency: string;
821
+ /** Defines the vat regulation, for example `1` for "Umsatzsteuerpflichtige Umsätze". */
822
+ taxRuleId: number;
823
+ /** Text describing the chosen vat regulation, for example `Umsatzsteuer 19%`. */
824
+ taxText: string;
825
+ invoiceNumber?: string;
826
+ /** Usually consists of a prefix and the invoice number. */
827
+ header?: string;
828
+ headText?: string;
829
+ footText?: string;
830
+ /** The complete recipient address, line breaks are kept on the pdf. */
831
+ address?: string;
832
+ /** Can be omitted when the complete address is given in `address`. */
833
+ addressCountryId?: number;
834
+ /** Percentage the end-customer gets when paying early. Defaults to `0`. */
835
+ discount?: number;
836
+ /** Days the end-customer has to pay the invoice. */
837
+ timeToPay?: number;
838
+ deliveryDate?: DateInput;
839
+ deliveryDateUntil?: DateInput;
840
+ payDate?: DateInput;
841
+ paymentMethodId?: number;
842
+ /** `true` if the sevdesk account falls under the small entrepreneur scheme. */
843
+ smallSettlement?: boolean;
844
+ /** `true` if the position prices are net values, `false` if they are gross. */
845
+ showNet?: boolean;
846
+ /** Shown as "Referenz/Bestellnummer" in sevdesk. */
847
+ customerInternalNote?: string;
848
+ propertyIsEInvoice?: boolean;
849
+ }
850
+ interface InvoicePositionInput {
851
+ quantity: number;
852
+ taxRate: number;
853
+ /** The unit in which the position is measured. */
854
+ unityId: number;
855
+ name?: string;
856
+ /** Net or gross price of one unit, depending on the invoice `showNet`. */
857
+ price?: number;
858
+ /** Part from the sevdesk inventory used in the position. */
859
+ partId?: number;
860
+ text?: string;
861
+ /** Starts at zero and orders the positions of an invoice. */
862
+ positionNumber?: number;
863
+ discount?: number;
864
+ }
865
+ interface SaveInvoiceOptions {
866
+ invoice: InvoiceInput;
867
+ positions: InvoicePositionInput[];
868
+ /** Takes the first address of the contact as the invoice address. */
869
+ takeDefaultAddress?: boolean;
870
+ }
871
+ interface ListInvoicesOptions extends ListOptions {
872
+ status?: InvoiceStatus;
873
+ invoiceNumber?: string;
874
+ startDate?: DateInput;
875
+ endDate?: DateInput;
876
+ contactId?: number;
877
+ embed?: string[];
878
+ }
879
+ interface CreateInvoiceFromOrderOptions {
880
+ orderId: number;
881
+ /** Defines how `amount` is interpreted. */
882
+ type?: 'percentage' | 'net' | 'gross';
883
+ amount?: number;
884
+ /** `RE` final invoice, `TR` partial invoice, `AR` advance invoice. */
885
+ partialType?: 'RE' | 'TR' | 'AR';
886
+ }
887
+ interface SendInvoiceViaEmailOptions {
888
+ invoiceId: number;
889
+ toEmail: string;
890
+ subject: string;
891
+ /** Can contain html. */
892
+ text: string;
893
+ /** Sends a copy of the email to yourself. */
894
+ copy?: boolean;
895
+ /** Ids of existing sevdesk documents, separated by `,`. */
896
+ additionalAttachments?: string;
897
+ /** Mail addresses separated by `,`. */
898
+ ccEmail?: string;
899
+ /** Mail addresses separated by `,`. */
900
+ bccEmail?: string;
901
+ /** Attaches the xml of the e-invoice instead of the pdf. */
902
+ sendXml?: boolean;
903
+ }
904
+ interface SendInvoiceByOptions {
905
+ invoiceId: number;
906
+ sendType: InvoiceSendType;
907
+ /** Creates a draft for internal use without changing the status. */
908
+ sendDraft?: boolean;
909
+ }
910
+ interface BookInvoiceOptions {
911
+ invoiceId: number;
912
+ /** Can also be a partial amount. */
913
+ amount: number;
914
+ date: DateInput;
915
+ type: InvoiceBookingType;
916
+ checkAccountId: number;
917
+ /**
918
+ * Required for online check accounts. Must be omitted for offline check
919
+ * accounts and cash registers, where the transaction is created automatically.
920
+ */
921
+ checkAccountTransactionId?: number;
922
+ createFeed?: boolean;
923
+ }
924
+ interface Invoice {
925
+ id: string;
926
+ objectName: string;
927
+ invoiceNumber: string | null;
928
+ contact: ModelRefResponse | null;
929
+ create: string;
930
+ update: string;
931
+ sevClient: ModelRefResponse;
932
+ invoiceDate: string;
933
+ header: string | null;
934
+ headText: string | null;
935
+ footText: string | null;
936
+ timeToPay: string | null;
937
+ discountTime: string | null;
938
+ discount: string;
939
+ address: string | null;
940
+ addressCountry: ModelRefResponse | null;
941
+ payDate: string | null;
942
+ createUser: ModelRefResponse;
943
+ deliveryDate: string | null;
944
+ deliveryDateUntil: string | null;
945
+ status: string;
946
+ smallSettlement: boolean;
947
+ contactPerson: ModelRefResponse;
948
+ taxRate: string;
949
+ taxRule: ModelRefResponse;
950
+ taxText: string;
951
+ dunningLevel: string | null;
952
+ paymentMethod: ModelRefResponse | null;
953
+ costCentre: ModelRefResponse | null;
954
+ sendDate: string | null;
955
+ origin: ModelRefResponse | null;
956
+ invoiceType: string;
957
+ accountIntervall: string | null;
958
+ accountNextInvoice: string | null;
959
+ reminderTotal: string | null;
960
+ reminderDebit: string | null;
961
+ reminderDeadline: string | null;
962
+ reminderCharge: string | null;
963
+ currency: string;
964
+ sumNet: string;
965
+ sumTax: string;
966
+ sumGross: string;
967
+ sumDiscounts: string;
968
+ sumNetForeignCurrency: string;
969
+ sumTaxForeignCurrency: string;
970
+ sumGrossForeignCurrency: string;
971
+ sumDiscountsForeignCurrency: string;
972
+ sumNetAccounting: string;
973
+ sumTaxAccounting: string;
974
+ sumGrossAccounting: string;
975
+ paidAmount: number | null;
976
+ customerInternalNote: string | null;
977
+ showNet: boolean;
978
+ enshrined: string | null;
979
+ sendType: string | null;
980
+ }
981
+ interface InvoicePosition {
982
+ id: string;
983
+ objectName: string;
984
+ create: string;
985
+ update: string;
986
+ sevClient: ModelRefResponse;
987
+ invoice: ModelRefResponse;
988
+ part: ModelRefResponse | null;
989
+ quantity: string;
990
+ price: string | null;
991
+ name: string | null;
992
+ unity: ModelRefResponse;
993
+ positionNumber: string;
994
+ text: string | null;
995
+ discount: string | null;
996
+ taxRate: string;
997
+ sumDiscount: string | null;
998
+ sumNetAccounting: string;
999
+ sumTaxAccounting: string;
1000
+ sumGrossAccounting: string;
1001
+ priceNet: string;
1002
+ priceGross: string;
1003
+ priceTax: string;
1004
+ }
1005
+ interface SaveInvoiceResult {
1006
+ invoice: Invoice;
1007
+ positions: InvoicePosition[];
1008
+ }
1009
+ interface RenderInvoiceResult {
1010
+ thumbs: unknown[];
1011
+ pages: number;
1012
+ /** Internal id of the rendered document. */
1013
+ docId: string;
1014
+ parameters: InvoiceRenderParameter[];
1015
+ }
1016
+ interface InvoiceRenderParameter {
1017
+ key: string;
1018
+ name: string;
1019
+ values: {
1020
+ name: string;
1021
+ translationCade: string;
1022
+ value: string;
1023
+ }[];
1024
+ visible: boolean;
1025
+ value: string;
1026
+ }
1027
+ interface InvoicePdf {
1028
+ filename: string;
1029
+ mimeType: string;
1030
+ base64encoded: boolean;
1031
+ /** The base64 encoded pdf document. */
1032
+ content: string;
1033
+ }
1034
+ interface InvoiceEmail {
1035
+ id: string;
1036
+ objectName: string;
1037
+ create: string;
1038
+ update: string;
1039
+ /** The invoice the email was sent for. */
1040
+ object: Invoice;
1041
+ from: string;
1042
+ to: string;
1043
+ subject: string;
1044
+ text: string | null;
1045
+ sevClient: ModelRefResponse;
1046
+ }
1047
+ interface BookInvoiceResult {
1048
+ id: string;
1049
+ objectName: string;
1050
+ additionalInformation: string | null;
1051
+ create: string;
1052
+ invoice: ModelRefResponse;
1053
+ fromStatus: string;
1054
+ toStatus: string;
1055
+ /** Spelled `ammountPayed` by the sevdesk API. */
1056
+ ammountPayed: string;
1057
+ bookingDate: string;
1058
+ sevClient: ModelRefResponse;
1059
+ }
1060
+ declare class InvoicesResource extends BaseResource {
1061
+ /** Retrieves invoices via `GET /Invoice`. */
1062
+ list(options?: ListInvoicesOptions): Promise<Invoice[]>;
1063
+ /** Retrieves a single invoice via `GET /Invoice/{invoiceId}`. */
1064
+ get(options: {
1065
+ invoiceId: number;
1066
+ }): Promise<Invoice>;
1067
+ /**
1068
+ * Creates or updates an invoice with its positions via
1069
+ * `POST /Invoice/Factory/saveInvoice`.
1070
+ *
1071
+ * Invoices can only be created as drafts. Use `sendViaEmail`, `sendBy` and
1072
+ * `book` to advance the status afterwards.
1073
+ */
1074
+ save(options: SaveInvoiceOptions): Promise<SaveInvoiceResult>;
1075
+ /** Creates an invoice from an order via `POST /Invoice/Factory/createInvoiceFromOrder`. */
1076
+ createFromOrder(options: CreateInvoiceFromOrderOptions): Promise<Invoice>;
1077
+ /** Creates a reminder for an invoice via `POST /Invoice/Factory/createInvoiceReminder`. */
1078
+ createReminder(options: {
1079
+ invoiceId: number;
1080
+ }): Promise<Invoice>;
1081
+ /** Retrieves the positions of an invoice via `GET /Invoice/{invoiceId}/getPositions`. */
1082
+ getPositions(options: {
1083
+ invoiceId: number;
1084
+ embed?: string[];
1085
+ } & ListOptions): Promise<InvoicePosition[]>;
1086
+ /**
1087
+ * Checks if an invoice is partially paid via
1088
+ * `GET /Invoice/{invoiceId}/getIsPartiallyPaid`.
1089
+ *
1090
+ * Fully paid invoices are regarded as not partially paid.
1091
+ */
1092
+ isPartiallyPaid(options: {
1093
+ invoiceId: number;
1094
+ }): Promise<boolean>;
1095
+ /**
1096
+ * Cancels an invoice via `POST /Invoice/{invoiceId}/cancelInvoice` and
1097
+ * returns the created cancellation invoice.
1098
+ */
1099
+ cancel(options: {
1100
+ invoiceId: number;
1101
+ }): Promise<Invoice>;
1102
+ /** Renders the pdf document of an invoice via `POST /Invoice/{invoiceId}/render`. */
1103
+ render(options: {
1104
+ invoiceId: number;
1105
+ forceReload?: boolean;
1106
+ }): Promise<RenderInvoiceResult>;
1107
+ /**
1108
+ * Sends an invoice to the end-customer via
1109
+ * `POST /Invoice/{invoiceId}/sendViaEmail`. This marks the invoice as sent.
1110
+ */
1111
+ sendViaEmail(options: SendInvoiceViaEmailOptions): Promise<InvoiceEmail>;
1112
+ /** Retrieves the pdf document of an invoice via `GET /Invoice/{invoiceId}/getPdf`. */
1113
+ getPdf(options: {
1114
+ invoiceId: number;
1115
+ /** Prevents marking the invoice as sent. */
1116
+ preventSendBy?: boolean;
1117
+ }): Promise<InvoicePdf>;
1118
+ /** Retrieves the xml of an e-invoice via `GET /Invoice/{invoiceId}/getXml`. */
1119
+ getXml(options: {
1120
+ invoiceId: number;
1121
+ }): Promise<string>;
1122
+ /** Marks an invoice as sent via `PUT /Invoice/{invoiceId}/sendBy`. */
1123
+ sendBy(options: SendInvoiceByOptions): Promise<Invoice>;
1124
+ /** Books an amount on an invoice via `PUT /Invoice/{invoiceId}/bookAmount`. */
1125
+ book(options: BookInvoiceOptions): Promise<BookInvoiceResult>;
1126
+ /**
1127
+ * Enshrines an invoice via `PUT /Invoice/{invoiceId}/enshrine`.
1128
+ *
1129
+ * Requires a status of at least `200` and cannot be undone.
1130
+ */
1131
+ enshrine(options: {
1132
+ invoiceId: number;
1133
+ }): Promise<void>;
1134
+ /**
1135
+ * Resets the invoice status to open via `PUT /Invoice/{invoiceId}/resetToOpen`.
1136
+ *
1137
+ * Linked transactions are unlinked. Not possible for enshrined invoices.
1138
+ */
1139
+ resetToOpen(options: {
1140
+ invoiceId: number;
1141
+ }): Promise<Invoice>;
1142
+ /**
1143
+ * Resets the invoice status to draft via `PUT /Invoice/{invoiceId}/resetToDraft`.
1144
+ *
1145
+ * Only possible for invoices with the status `200`.
1146
+ */
1147
+ resetToDraft(options: {
1148
+ invoiceId: number;
1149
+ }): Promise<Invoice>;
1150
+ }
1151
+ //#endregion
1152
+ //#region src/resources/orders.d.ts
1153
+ /**
1154
+ * Status of an order.
1155
+ *
1156
+ * - `100` draft
1157
+ * - `200` delivered
1158
+ * - `300` rejected / cancelled
1159
+ * - `500` accepted
1160
+ * - `750` partially calculated
1161
+ * - `1000` calculated
1162
+ */
1163
+ type OrderStatus = 100 | 200 | 300 | 500 | 750 | 1000;
1164
+ /**
1165
+ * Type of an order: `AN` estimate / proposal, `AB` order confirmation,
1166
+ * `LI` delivery note.
1167
+ */
1168
+ type OrderType = 'AN' | 'AB' | 'LI';
1169
+ /**
1170
+ * Way in which an order was sent to the end-customer: `VPR` printed,
1171
+ * `VP` postal, `VM` mailed, `VPDF` downloaded pdf.
1172
+ */
1173
+ type OrderSendType = 'VPR' | 'VP' | 'VM' | 'VPDF';
1174
+ interface OrderInput {
1175
+ orderNumber: string;
1176
+ orderDate: DateInput;
1177
+ contactId: number;
1178
+ status: OrderStatus;
1179
+ orderType: OrderType;
1180
+ /** Usually consists of a prefix and the order number. */
1181
+ header: string;
1182
+ /** Version of the order, used for multiple drafts. Starts at `0`. */
1183
+ version: number;
1184
+ addressCountryId: number;
1185
+ /** The sevdesk user acting as the contact person. */
1186
+ contactPersonId: number;
1187
+ /** Defines the vat regulation, for example `1` for "Umsatzsteuerpflichtige Umsätze". */
1188
+ taxRuleId: number;
1189
+ /** Not used anymore, the tax rate of the positions is used instead. */
1190
+ taxRate: number;
1191
+ /** Text describing the vat regulation, for example `Umsatzsteuer 19%`. */
1192
+ taxText: string;
1193
+ /** Currency code according to ISO-4217. */
1194
+ currency: string;
1195
+ headText?: string;
1196
+ footText?: string;
1197
+ deliveryTerms?: string;
1198
+ paymentTerms?: string;
1199
+ smallSettlement?: boolean;
1200
+ /** `true` if the position prices are net, `false` if they are gross. */
1201
+ showNet?: boolean;
1202
+ /** Complete address of the recipient. Line breaks are kept in the pdf. */
1203
+ address?: string;
1204
+ customerInternalNote?: string;
1205
+ sendDate?: DateInput;
1206
+ sendType?: OrderSendType;
1207
+ }
1208
+ interface OrderPositionInput {
1209
+ unityId: number;
1210
+ quantity: number;
1211
+ taxRate: number;
1212
+ name?: string;
1213
+ /** Price of one unit. Is either net or gross, depending on `showNet`. */
1214
+ price?: number;
1215
+ text?: string;
1216
+ partId?: number;
1217
+ /** Starts at zero and is incremented for every further position. */
1218
+ positionNumber?: number;
1219
+ discount?: number;
1220
+ optional?: boolean;
1221
+ }
1222
+ interface SaveOrderOptions {
1223
+ order: OrderInput;
1224
+ positions: OrderPositionInput[];
1225
+ }
1226
+ interface ListOrdersOptions extends ListOptions {
1227
+ status?: OrderStatus;
1228
+ orderNumber?: string;
1229
+ startDate?: DateInput;
1230
+ endDate?: DateInput;
1231
+ contactId?: number;
1232
+ embed?: string[];
1233
+ }
1234
+ interface UpdateOrderOptions {
1235
+ orderId: number;
1236
+ orderNumber?: string;
1237
+ orderDate?: DateInput;
1238
+ status?: OrderStatus;
1239
+ header?: string;
1240
+ headText?: string;
1241
+ footText?: string;
1242
+ deliveryTerms?: string;
1243
+ paymentTerms?: string;
1244
+ address?: string;
1245
+ customerInternalNote?: string;
1246
+ version?: number;
1247
+ }
1248
+ interface GetOrderRelatedObjectsOptions {
1249
+ orderId: number;
1250
+ /** Include the order itself in the result. */
1251
+ includeItself?: boolean;
1252
+ sortByType?: boolean;
1253
+ embed?: string[];
1254
+ }
1255
+ interface SendOrderViaEmailOptions {
1256
+ orderId: number;
1257
+ toEmail: string;
1258
+ subject: string;
1259
+ /** Can contain html. */
1260
+ text: string;
1261
+ /** Send a copy of the email to yourself. */
1262
+ copy?: boolean;
1263
+ /** Ids of existing documents in your sevdesk account, separated by `,`. */
1264
+ additionalAttachments?: string;
1265
+ /** Mail addresses to be put as cc, separated by `,`. */
1266
+ ccEmail?: string;
1267
+ /** Mail addresses to be put as bcc, separated by `,`. */
1268
+ bccEmail?: string;
1269
+ }
1270
+ interface SendOrderByOptions {
1271
+ orderId: number;
1272
+ sendType: OrderSendType;
1273
+ /**
1274
+ * Creates a draft for internal use. The status of the order is not changed.
1275
+ */
1276
+ sendDraft: boolean;
1277
+ }
1278
+ interface ListOrderPositionsOptions extends ListOptions {
1279
+ orderId?: number;
1280
+ embed?: string[];
1281
+ }
1282
+ interface UpdateOrderPositionOptions {
1283
+ orderPosId: number;
1284
+ quantity?: number;
1285
+ price?: number;
1286
+ priceTax?: number;
1287
+ priceGross?: number;
1288
+ name?: string;
1289
+ text?: string;
1290
+ positionNumber?: number;
1291
+ discount?: number;
1292
+ optional?: boolean;
1293
+ taxRate?: number;
1294
+ unityId?: number;
1295
+ partId?: number;
1296
+ }
1297
+ interface Order {
1298
+ id: string;
1299
+ objectName: string;
1300
+ create: string;
1301
+ update: string;
1302
+ sevClient: ModelRefResponse;
1303
+ createUser: ModelRefResponse;
1304
+ orderNumber: string;
1305
+ contact: ModelRefResponse;
1306
+ orderDate: string;
1307
+ status: string;
1308
+ header: string;
1309
+ headText: string | null;
1310
+ footText: string | null;
1311
+ addressCountry: ModelRefResponse | null;
1312
+ deliveryTerms: string | null;
1313
+ paymentTerms: string | null;
1314
+ origin: ModelRefResponse | null;
1315
+ version: string;
1316
+ smallSettlement: boolean;
1317
+ contactPerson: ModelRefResponse;
1318
+ taxRate: string;
1319
+ taxRule: ModelRefResponse;
1320
+ taxText: string;
1321
+ orderType: string;
1322
+ sendDate: string | null;
1323
+ address: string | null;
1324
+ currency: string;
1325
+ sumNet: string;
1326
+ sumTax: string;
1327
+ sumGross: string;
1328
+ sumDiscounts: string;
1329
+ sumNetForeignCurrency: string;
1330
+ sumTaxForeignCurrency: string;
1331
+ sumGrossForeignCurrency: string;
1332
+ sumDiscountsForeignCurrency: string;
1333
+ customerInternalNote: string | null;
1334
+ showNet: boolean;
1335
+ sendType: string | null;
1336
+ }
1337
+ interface OrderPosition {
1338
+ id: string;
1339
+ objectName: string;
1340
+ create: string;
1341
+ update: string;
1342
+ sevClient: ModelRefResponse;
1343
+ order: ModelRefResponse;
1344
+ part: ModelRefResponse | null;
1345
+ quantity: string;
1346
+ price: string | null;
1347
+ priceNet: string | null;
1348
+ priceTax: string | null;
1349
+ priceGross: string | null;
1350
+ name: string | null;
1351
+ unity: ModelRefResponse;
1352
+ positionNumber: string | null;
1353
+ text: string | null;
1354
+ discount: string | null;
1355
+ optional: boolean | null;
1356
+ taxRate: string;
1357
+ sumDiscount: string | null;
1358
+ }
1359
+ interface OrderDiscount {
1360
+ id: string;
1361
+ objectName: string;
1362
+ create: string;
1363
+ update: string;
1364
+ /** The order the discount belongs to. */
1365
+ object: ModelRefResponse;
1366
+ sevClient: string;
1367
+ text: string;
1368
+ /** `1` if `value` is a percentage, `0` if it is an absolute amount. */
1369
+ percentage: string;
1370
+ value: string;
1371
+ /** `0` if the discount is gross, `1` if it is net. */
1372
+ isNet: string;
1373
+ }
1374
+ /**
1375
+ * An object related to an order, for example an invoice or another order.
1376
+ * Only `id` and `objectName` are guaranteed, all further fields depend on the
1377
+ * type of the related object.
1378
+ */
1379
+ interface OrderRelatedObject {
1380
+ id: string;
1381
+ objectName: string;
1382
+ [key: string]: unknown;
1383
+ }
1384
+ interface OrderMail {
1385
+ id: string;
1386
+ objectName: string;
1387
+ create: string;
1388
+ update: string;
1389
+ object: Order;
1390
+ from: string;
1391
+ to: string;
1392
+ subject: string;
1393
+ text: string | null;
1394
+ sevClient: ModelRefResponse;
1395
+ cc: string | null;
1396
+ bcc: string | null;
1397
+ arrived: string | null;
1398
+ }
1399
+ interface OrderPdf {
1400
+ filename: string;
1401
+ mimeType: string;
1402
+ base64encoded: boolean;
1403
+ /** The pdf document, base64 encoded. */
1404
+ content: string;
1405
+ }
1406
+ interface SaveOrderResult {
1407
+ order: Order;
1408
+ positions: OrderPosition[];
1409
+ }
1410
+ declare class OrdersResource extends BaseResource {
1411
+ /** Retrieves orders via `GET /Order`. */
1412
+ list(options?: ListOrdersOptions): Promise<Order[]>;
1413
+ /** Retrieves a single order via `GET /Order/{orderId}`. */
1414
+ get(options: {
1415
+ orderId: number;
1416
+ }): Promise<Order>;
1417
+ /** Creates or updates an order with its positions via `POST /Order/Factory/saveOrder`. */
1418
+ save(options: SaveOrderOptions): Promise<SaveOrderResult>;
1419
+ /** Updates an order via `PUT /Order/{orderId}`. */
1420
+ update(options: UpdateOrderOptions): Promise<Order>;
1421
+ /** Deletes an order via `DELETE /Order/{orderId}`. */
1422
+ delete(options: {
1423
+ orderId: number;
1424
+ }): Promise<void>;
1425
+ /** Retrieves the positions of an order via `GET /Order/{orderId}/getPositions`. */
1426
+ getPositions(options: {
1427
+ orderId: number;
1428
+ embed?: string[];
1429
+ } & ListOptions): Promise<OrderPosition[]>;
1430
+ /** Retrieves the discounts of an order via `GET /Order/{orderId}/getDiscounts`. */
1431
+ getDiscounts(options: {
1432
+ orderId: number;
1433
+ embed?: string[];
1434
+ } & ListOptions): Promise<OrderDiscount[]>;
1435
+ /** Retrieves the objects related to an order via `GET /Order/{orderId}/getRelatedObjects`. */
1436
+ getRelatedObjects(options: GetOrderRelatedObjectsOptions): Promise<OrderRelatedObject[]>;
1437
+ /** Sends an order via email using `POST /Order/{orderId}/sendViaEmail`. */
1438
+ sendViaEmail(options: SendOrderViaEmailOptions): Promise<OrderMail[]>;
1439
+ /** Creates a packing list from an order via `POST /Order/Factory/createPackingListFromOrder`. */
1440
+ createPackingList(options: {
1441
+ orderId: number;
1442
+ }): Promise<Order>;
1443
+ /** Creates a contract note from an order via `POST /Order/Factory/createContractNoteFromOrder`. */
1444
+ createContractNote(options: {
1445
+ orderId: number;
1446
+ }): Promise<Order>;
1447
+ /** Retrieves the pdf of an order via `GET /Order/{orderId}/getPdf`. */
1448
+ getPdf(options: {
1449
+ orderId: number;
1450
+ /** Prevents the order from being marked as sent. */
1451
+ preventSendBy?: boolean;
1452
+ }): Promise<OrderPdf>;
1453
+ /** Marks an order as sent via `PUT /Order/{orderId}/sendBy`. */
1454
+ sendBy(options: SendOrderByOptions): Promise<Order>;
1455
+ /** Retrieves order positions via `GET /OrderPos`. */
1456
+ listPositions(options?: ListOrderPositionsOptions): Promise<OrderPosition[]>;
1457
+ /** Retrieves a single order position via `GET /OrderPos/{orderPosId}`. */
1458
+ getPosition(options: {
1459
+ orderPosId: number;
1460
+ }): Promise<OrderPosition>;
1461
+ /** Updates an order position via `PUT /OrderPos/{orderPosId}`. */
1462
+ updatePosition(options: UpdateOrderPositionOptions): Promise<OrderPosition>;
1463
+ /** Deletes an order position via `DELETE /OrderPos/{orderPosId}`. */
1464
+ deletePosition(options: {
1465
+ orderPosId: number;
1466
+ }): Promise<void>;
1467
+ }
1468
+ //#endregion
1469
+ //#region src/resources/parts.d.ts
1470
+ /** `50` for an inactive and `100` for an active part. */
1471
+ type PartStatus = 50 | 100;
1472
+ interface ListPartsOptions extends ListOptions {
1473
+ partNumber?: string;
1474
+ name?: string;
1475
+ embed?: string[];
1476
+ }
1477
+ interface CreatePartOptions {
1478
+ name: string;
1479
+ partNumber: string;
1480
+ /** The unit in which the part is measured. `1` is the "piece" unit. */
1481
+ unityId: number;
1482
+ /** In sevdesk-Update 2.0 only `0`, `7` and `19` are allowed. */
1483
+ taxRate: number;
1484
+ stock: number;
1485
+ /** A text describing the part. */
1486
+ text?: string;
1487
+ /** Send a `GET /Category?objectType=Part` for all available categories. */
1488
+ categoryId?: number;
1489
+ stockEnabled?: boolean;
1490
+ /**
1491
+ * Net price for which the part is sold. sevdesk will change this parameter
1492
+ * so that the gross price is calculated automatically, until then
1493
+ * `priceGross` must be used.
1494
+ */
1495
+ price?: number;
1496
+ priceNet?: number;
1497
+ priceGross?: number;
1498
+ pricePurchase?: number;
1499
+ status?: PartStatus;
1500
+ /** An internal comment which does not appear on invoices and orders. */
1501
+ internalComment?: string;
1502
+ }
1503
+ interface UpdatePartOptions extends Partial<CreatePartOptions> {
1504
+ partId: number;
1505
+ }
1506
+ interface Part {
1507
+ id: string;
1508
+ objectName: string;
1509
+ create: string;
1510
+ update: string;
1511
+ sevClient: ModelRefResponse;
1512
+ name: string;
1513
+ partNumber: string;
1514
+ text: string | null;
1515
+ category: ModelRefResponse | null;
1516
+ stock: string;
1517
+ stockEnabled: string;
1518
+ unity: ModelRefResponse;
1519
+ price: string | null;
1520
+ priceNet: string | null;
1521
+ priceGross: string | null;
1522
+ pricePurchase: string | null;
1523
+ taxRate: string;
1524
+ status: string | null;
1525
+ internalComment: string | null;
1526
+ }
1527
+ declare class PartsResource extends BaseResource {
1528
+ /** Retrieves parts via `GET /Part`. */
1529
+ list(options?: ListPartsOptions): Promise<Part[]>;
1530
+ /** Retrieves a single part via `GET /Part/{partId}`. */
1531
+ get(options: {
1532
+ partId: number;
1533
+ }): Promise<Part>;
1534
+ /** Creates a part via `POST /Part`. */
1535
+ create(options: CreatePartOptions): Promise<Part>;
1536
+ /** Updates a part via `PUT /Part/{partId}`. */
1537
+ update(options: UpdatePartOptions): Promise<Part>;
1538
+ /** Retrieves the current stock amount of a part via `GET /Part/{partId}/getStock`. */
1539
+ getStock(options: {
1540
+ partId: number;
1541
+ }): Promise<number>;
1542
+ }
1543
+ //#endregion
1544
+ //#region src/resources/receipt-guidance.d.ts
1545
+ interface AllowedTaxRule {
1546
+ id: number;
1547
+ name: string;
1548
+ description: string;
1549
+ /** Tax rates combinable with this tax rule, for example `ZERO` or `NINETEEN`. */
1550
+ taxRates: string[];
1551
+ }
1552
+ interface ReceiptGuide {
1553
+ accountDatevId: number;
1554
+ accountNumber: string;
1555
+ accountName: string;
1556
+ description: string;
1557
+ allowedTaxRules: AllowedTaxRule[];
1558
+ /** Viable receipt types for this account, for example `EXPENSE`. */
1559
+ allowedReceiptTypes: string[];
1560
+ }
1561
+ declare class ReceiptGuidanceResource extends BaseResource {
1562
+ /** Retrieves guidance for all accounts via `GET /ReceiptGuidance/forAllAccounts`. */
1563
+ forAllAccounts(): Promise<ReceiptGuide[]>;
1564
+ /** Retrieves guidance for a datev account number via `GET /ReceiptGuidance/forAccountNumber`. */
1565
+ forAccountNumber(options: {
1566
+ accountNumber: string;
1567
+ }): Promise<ReceiptGuide[]>;
1568
+ /** Retrieves guidance for a tax rule via `GET /ReceiptGuidance/forTaxRule`. */
1569
+ forTaxRule(options: {
1570
+ taxRule: string;
1571
+ }): Promise<ReceiptGuide[]>;
1572
+ /** Retrieves guidance for revenue accounts via `GET /ReceiptGuidance/forRevenue`. */
1573
+ forRevenue(): Promise<ReceiptGuide[]>;
1574
+ /** Retrieves guidance for expense accounts via `GET /ReceiptGuidance/forExpense`. */
1575
+ forExpense(): Promise<ReceiptGuide[]>;
1576
+ }
1577
+ //#endregion
1578
+ //#region src/resources/reports.d.ts
1579
+ /** `AN` (quotation), `AB` (order confirmation) and `LI` (delivery note). */
1580
+ type ReportOrderType = 'AN' | 'AB' | 'LI';
1581
+ interface ReportOrderFilter extends ExportDocumentFilter {
1582
+ orderType?: ReportOrderType;
1583
+ }
1584
+ interface ReportInvoiceListOptions {
1585
+ download?: boolean;
1586
+ /** Defaults to `all`. */
1587
+ view?: string;
1588
+ limit?: number;
1589
+ filter?: ExportInvoiceFilter;
1590
+ }
1591
+ interface ReportOrderListOptions {
1592
+ download?: boolean;
1593
+ /** Defaults to `all`. */
1594
+ view?: string;
1595
+ limit?: number;
1596
+ filter?: ReportOrderFilter;
1597
+ }
1598
+ interface ReportContactListOptions {
1599
+ download?: boolean;
1600
+ limit?: number;
1601
+ filter?: ExportContactFilter;
1602
+ }
1603
+ interface ReportVoucherListOptions {
1604
+ download?: boolean;
1605
+ limit?: number;
1606
+ filter?: ExportVoucherFilter;
1607
+ }
1608
+ declare class ReportsResource extends BaseResource {
1609
+ /** Creates an invoice list report as PDF via `GET /Report/invoicelist`. */
1610
+ invoiceList(options?: ReportInvoiceListOptions): Promise<ExportFile>;
1611
+ /** Creates an order list report as PDF via `GET /Report/orderlist`. */
1612
+ orderList(options?: ReportOrderListOptions): Promise<ExportFile>;
1613
+ /** Creates a contact list report as PDF via `GET /Report/contactlist`. */
1614
+ contactList(options?: ReportContactListOptions): Promise<ExportFile>;
1615
+ /** Creates a voucher list report as PDF via `GET /Report/voucherlist`. */
1616
+ voucherList(options?: ReportVoucherListOptions): Promise<ExportFile>;
1617
+ private requestReport;
1618
+ }
1619
+ //#endregion
1620
+ //#region src/resources/tags.d.ts
1621
+ /** The document types a tag can be attached to. */
1622
+ type TagObjectType = 'Invoice' | 'Voucher' | 'Order' | 'CreditNote';
1623
+ interface ListTagsOptions extends ListOptions {
1624
+ name?: string;
1625
+ }
1626
+ interface CreateTagOptions {
1627
+ name: string;
1628
+ /** The document the tag is attached to. */
1629
+ objectId: number;
1630
+ objectName: TagObjectType;
1631
+ }
1632
+ interface Tag {
1633
+ id: string;
1634
+ objectName: string;
1635
+ create: string;
1636
+ name: string;
1637
+ sevClient: ModelRefResponse;
1638
+ }
1639
+ /** The link between a tag and the document it is attached to. */
1640
+ interface TagRelation {
1641
+ id: string;
1642
+ objectName: string;
1643
+ create: string;
1644
+ tag: ModelRefResponse;
1645
+ object: ModelRefResponse;
1646
+ sevClient: ModelRefResponse;
1647
+ }
1648
+ declare class TagsResource extends BaseResource {
1649
+ /** Retrieves tags via `GET /Tag`. */
1650
+ list(options?: ListTagsOptions): Promise<Tag[]>;
1651
+ /** Retrieves a single tag via `GET /Tag/{tagId}`. */
1652
+ get(options: {
1653
+ tagId: number;
1654
+ }): Promise<Tag>;
1655
+ /**
1656
+ * Creates a tag and attaches it to a document via `POST /Tag/Factory/create`.
1657
+ * Returns the created tag relation.
1658
+ */
1659
+ create(options: CreateTagOptions): Promise<TagRelation>;
1660
+ /** Renames a tag via `PUT /Tag/{tagId}`. */
1661
+ update(options: {
1662
+ tagId: number;
1663
+ name: string;
1664
+ }): Promise<Tag>;
1665
+ /** Deletes a tag via `DELETE /Tag/{tagId}`. */
1666
+ delete(options: {
1667
+ tagId: number;
1668
+ }): Promise<void>;
1669
+ /** Retrieves tag relations via `GET /TagRelation`. */
1670
+ listRelations(options?: ListOptions): Promise<TagRelation[]>;
1671
+ }
1672
+ //#endregion
1673
+ //#region src/resources/transactions.d.ts
1674
+ /**
1675
+ * Status of a transaction.
1676
+ *
1677
+ * - `100` created
1678
+ * - `200` linked
1679
+ * - `300` private
1680
+ * - `350` auto-booked without user confirmation
1681
+ * - `400` booked
1682
+ */
1683
+ type TransactionStatus = 100 | 200 | 300 | 350 | 400;
1684
+ /** A transaction on a check account. */
1685
+ interface CheckAccountTransaction {
1686
+ id: string;
1687
+ objectName: string;
1688
+ create: string;
1689
+ update: string;
1690
+ sevClient: ModelRefResponse;
1691
+ valueDate: string;
1692
+ entryDate: string | null;
1693
+ paymtPurpose: string | null;
1694
+ amount: string;
1695
+ payeePayerName: string | null;
1696
+ payeePayerAcctNo: string | null;
1697
+ payeePayerBankCode: string | null;
1698
+ checkAccount: ModelRefResponse;
1699
+ status: string;
1700
+ enshrined: string | null;
1701
+ sourceTransaction: ModelRefResponse | null;
1702
+ targetTransaction: ModelRefResponse | null;
1703
+ gvCode: string | null;
1704
+ entryText: string | null;
1705
+ primaNotaNo: string | null;
1706
+ }
1707
+ interface ListTransactionsOptions extends ListOptions {
1708
+ checkAccountId?: number;
1709
+ isBooked?: boolean;
1710
+ paymtPurpose?: string;
1711
+ startDate?: DateInput;
1712
+ endDate?: DateInput;
1713
+ payeePayerName?: string;
1714
+ onlyCredit?: boolean;
1715
+ onlyDebit?: boolean;
1716
+ }
1717
+ interface CreateTransactionOptions {
1718
+ checkAccountId: number;
1719
+ valueDate: DateInput;
1720
+ entryDate?: DateInput;
1721
+ amount: number;
1722
+ payeePayerName: string;
1723
+ paymtPurpose?: string;
1724
+ payeePayerAcctNo?: string;
1725
+ payeePayerBankCode?: string;
1726
+ /** Defaults to `100`, the only status that makes sense on creation. */
1727
+ status?: TransactionStatus;
1728
+ }
1729
+ interface UpdateTransactionOptions {
1730
+ transactionId: number;
1731
+ valueDate?: DateInput;
1732
+ entryDate?: DateInput;
1733
+ paymtPurpose?: string;
1734
+ amount?: number;
1735
+ payeePayerName?: string;
1736
+ status?: TransactionStatus;
1737
+ }
1738
+ declare class TransactionsResource extends BaseResource {
1739
+ /** Retrieves transactions via `GET /CheckAccountTransaction`. */
1740
+ list(options?: ListTransactionsOptions): Promise<CheckAccountTransaction[]>;
1741
+ /** Retrieves a single transaction via `GET /CheckAccountTransaction/{transactionId}`. */
1742
+ get(options: {
1743
+ transactionId: number;
1744
+ }): Promise<CheckAccountTransaction>;
1745
+ /**
1746
+ * Creates a transaction via `POST /CheckAccountTransaction`.
1747
+ *
1748
+ * Should only be used on check accounts of type online, preferably on
1749
+ * accounts that import their transactions from CSV files.
1750
+ */
1751
+ create(options: CreateTransactionOptions): Promise<CheckAccountTransaction>;
1752
+ /** Updates a transaction via `PUT /CheckAccountTransaction/{transactionId}`. */
1753
+ update(options: UpdateTransactionOptions): Promise<CheckAccountTransaction>;
1754
+ /** Deletes a transaction via `DELETE /CheckAccountTransaction/{transactionId}`. */
1755
+ delete(options: {
1756
+ transactionId: number;
1757
+ }): Promise<void>;
1758
+ /**
1759
+ * Enshrines a transaction via `PUT /CheckAccountTransaction/{transactionId}/enshrine`.
1760
+ *
1761
+ * Requires a status of at least `200` and cannot be undone. Linked invoices,
1762
+ * credit notes and vouchers can no longer be changed afterwards.
1763
+ */
1764
+ enshrine(options: {
1765
+ transactionId: number;
1766
+ }): Promise<void>;
1767
+ }
1768
+ //#endregion
1769
+ //#region src/resources/vouchers.d.ts
1770
+ type VoucherStatus = 50 | 100 | 150 | 750 | 1000;
1771
+ type VoucherBookingType = 'FULL_PAYMENT' | 'N' | 'CB' | 'O' | 'OF' | 'MTC';
1772
+ interface VoucherInput {
1773
+ /** `50` for a draft voucher, `100` for an open one. */
1774
+ status: 50 | 100;
1775
+ /** `C` for a credit voucher, `D` for a debit voucher. */
1776
+ creditDebit: 'C' | 'D';
1777
+ /** Defines the vat regulation, for example `1` for "Umsatzsteuerpflichtige Umsätze". */
1778
+ taxRuleId: number;
1779
+ /** Defaults to `VOU`. */
1780
+ voucherType?: 'VOU' | 'RV';
1781
+ voucherDate?: DateInput;
1782
+ payDate?: DateInput;
1783
+ deliveryDate?: DateInput;
1784
+ deliveryDateUntil?: DateInput;
1785
+ supplierId?: number;
1786
+ /** Shown as the supplier of the voucher when no `supplierId` is given. */
1787
+ supplierName?: string;
1788
+ /** The voucher number. */
1789
+ description?: string;
1790
+ currency?: string;
1791
+ propertyExchangeRate?: number;
1792
+ costCentreId?: number;
1793
+ }
1794
+ interface VoucherPositionInput {
1795
+ accountDatevId: number;
1796
+ taxRate: number;
1797
+ /** `true` if `sumNet` is authoritative, `false` if `sumGross` is. */
1798
+ net: boolean;
1799
+ sumNet?: number;
1800
+ sumGross?: number;
1801
+ isAsset?: boolean;
1802
+ comment?: string;
1803
+ }
1804
+ interface SaveVoucherOptions {
1805
+ voucher: VoucherInput;
1806
+ positions: VoucherPositionInput[];
1807
+ /** Internal filename returned by `uploadFile`. */
1808
+ filename?: string;
1809
+ }
1810
+ interface ListVouchersOptions extends ListOptions {
1811
+ status?: VoucherStatus;
1812
+ creditDebit?: 'C' | 'D';
1813
+ descriptionLike?: string;
1814
+ startDate?: DateInput;
1815
+ endDate?: DateInput;
1816
+ contactId?: number;
1817
+ embed?: string[];
1818
+ }
1819
+ interface UpdateVoucherOptions {
1820
+ voucherId: number;
1821
+ voucherDate?: DateInput;
1822
+ /** The voucher number. */
1823
+ description?: string;
1824
+ payDate?: DateInput;
1825
+ supplierName?: string;
1826
+ }
1827
+ interface BookVoucherOptions {
1828
+ voucherId: number;
1829
+ /** Can also be a partial amount. */
1830
+ amount: number;
1831
+ date: DateInput;
1832
+ type: VoucherBookingType;
1833
+ checkAccountId: number;
1834
+ /**
1835
+ * Required for online check accounts. Must be omitted for offline check
1836
+ * accounts and cash registers, where the transaction is created automatically.
1837
+ */
1838
+ checkAccountTransactionId?: number;
1839
+ createFeed?: boolean;
1840
+ }
1841
+ interface Voucher {
1842
+ id: string;
1843
+ objectName: string;
1844
+ create: string;
1845
+ update: string;
1846
+ sevClient: ModelRefResponse;
1847
+ voucherDate: string | null;
1848
+ supplier: ModelRefResponse | null;
1849
+ supplierName: string | null;
1850
+ description: string | null;
1851
+ payDate: string | null;
1852
+ status: string | null;
1853
+ sumNet: string;
1854
+ sumTax: string;
1855
+ sumGross: string;
1856
+ sumNetAccounting: string;
1857
+ sumTaxAccounting: string;
1858
+ sumGrossAccounting: string;
1859
+ sumDiscounts: string;
1860
+ paidAmount: number | null;
1861
+ taxRule: ModelRefResponse;
1862
+ creditDebit: string | null;
1863
+ voucherType: string | null;
1864
+ currency: string | null;
1865
+ propertyExchangeRate: string | null;
1866
+ enshrined: string | null;
1867
+ paymentDeadline: string | null;
1868
+ deliveryDate: string;
1869
+ deliveryDateUntil: string | null;
1870
+ document: ModelRefResponse | null;
1871
+ costCentre: ModelRefResponse | null;
1872
+ }
1873
+ interface VoucherPosition {
1874
+ id: string;
1875
+ objectName: string;
1876
+ create: string;
1877
+ update: string;
1878
+ sevClient: ModelRefResponse;
1879
+ voucher: ModelRefResponse;
1880
+ accountDatev: ModelRefResponse;
1881
+ taxRate: string;
1882
+ net: boolean;
1883
+ isAsset: boolean;
1884
+ sumNet: string;
1885
+ sumTax: string;
1886
+ sumGross: string;
1887
+ sumNetAccounting: string;
1888
+ sumTaxAccounting: string;
1889
+ sumGrossAccounting: string;
1890
+ comment: string | null;
1891
+ }
1892
+ interface SaveVoucherResult {
1893
+ voucher: Voucher;
1894
+ positions: VoucherPosition[];
1895
+ filename?: string;
1896
+ }
1897
+ interface BookVoucherResult {
1898
+ id: string;
1899
+ objectName: string;
1900
+ create: string;
1901
+ voucher: ModelRefResponse;
1902
+ fromStatus: string;
1903
+ toStatus: string;
1904
+ amountPayed: string;
1905
+ bookingDate: string;
1906
+ sevClient: ModelRefResponse;
1907
+ }
1908
+ interface UploadVoucherFileResult {
1909
+ pages: number;
1910
+ mimeType: string;
1911
+ originMimeType: string;
1912
+ /** The sevdesk internal filename to pass to `save`. */
1913
+ filename: string;
1914
+ contentHash: string;
1915
+ }
1916
+ declare class VouchersResource extends BaseResource {
1917
+ /** Retrieves vouchers via `GET /Voucher`. */
1918
+ list(options?: ListVouchersOptions): Promise<Voucher[]>;
1919
+ /** Retrieves a single voucher via `GET /Voucher/{voucherId}`. */
1920
+ get(options: {
1921
+ voucherId: number;
1922
+ }): Promise<Voucher>;
1923
+ /** Uploads a voucher document via `POST /Voucher/Factory/uploadTempFile`. */
1924
+ uploadFile(options: {
1925
+ file: Blob | Uint8Array;
1926
+ filename?: string;
1927
+ }): Promise<UploadVoucherFileResult>;
1928
+ /** Creates or updates a voucher with its positions via `POST /Voucher/Factory/saveVoucher`. */
1929
+ save(options: SaveVoucherOptions): Promise<SaveVoucherResult>;
1930
+ /** Uploads a document and creates a voucher with it attached. */
1931
+ createFromFile(options: {
1932
+ file: Blob | Uint8Array;
1933
+ filename?: string;
1934
+ voucher: VoucherInput;
1935
+ positions: VoucherPositionInput[];
1936
+ }): Promise<SaveVoucherResult>;
1937
+ /** Updates simple fields of a draft voucher via `PUT /Voucher/{voucherId}`. */
1938
+ update(options: UpdateVoucherOptions): Promise<Voucher>;
1939
+ /** Books an amount on a voucher via `PUT /Voucher/{voucherId}/bookAmount`. */
1940
+ book(options: BookVoucherOptions): Promise<BookVoucherResult>;
1941
+ /** Resets the voucher status to open via `PUT /Voucher/{voucherId}/resetToOpen`. */
1942
+ resetToOpen(options: {
1943
+ voucherId: number;
1944
+ }): Promise<Voucher>;
1945
+ /** Resets the voucher status to draft via `PUT /Voucher/{voucherId}/resetToDraft`. */
1946
+ resetToDraft(options: {
1947
+ voucherId: number;
1948
+ }): Promise<Voucher>;
1949
+ /** Enshrines a voucher via `PUT /Voucher/{voucherId}/enshrine`. This cannot be undone. */
1950
+ enshrine(options: {
1951
+ voucherId: number;
1952
+ }): Promise<void>;
1953
+ /** Retrieves the positions of a voucher via `GET /VoucherPos`. */
1954
+ listPositions(options: {
1955
+ voucherId: number;
1956
+ } & ListOptions): Promise<VoucherPosition[]>;
1957
+ }
1958
+ //#endregion
1959
+ //#region src/client.d.ts
1960
+ declare class SevDesk {
1961
+ readonly basics: BasicsResource;
1962
+ readonly checkAccounts: CheckAccountsResource;
1963
+ readonly contacts: ContactsResource;
1964
+ readonly creditNotes: CreditNotesResource;
1965
+ readonly exports: ExportsResource;
1966
+ readonly invoices: InvoicesResource;
1967
+ readonly orders: OrdersResource;
1968
+ readonly parts: PartsResource;
1969
+ readonly receiptGuidance: ReceiptGuidanceResource;
1970
+ readonly reports: ReportsResource;
1971
+ readonly tags: TagsResource;
1972
+ readonly transactions: TransactionsResource;
1973
+ readonly vouchers: VouchersResource;
1974
+ constructor(options: SevDeskOptions);
1975
+ }
1976
+ //#endregion
1977
+ //#region src/errors.d.ts
1978
+ declare class SevDeskError extends Error {
1979
+ readonly status: number;
1980
+ readonly statusText: string;
1981
+ readonly body: unknown;
1982
+ constructor(options: {
1983
+ status: number;
1984
+ statusText: string;
1985
+ body: unknown;
1986
+ });
1987
+ }
1988
+ //#endregion
1989
+ export { AllowedTaxRule, BasicsResource, BookCreditNoteOptions, BookCreditNoteResult, BookInvoiceOptions, BookInvoiceResult, BookVoucherOptions, BookVoucherResult, BookkeepingSystemVersion, CheckAccount, CheckAccountTransaction, CheckAccountsResource, Contact, ContactStatus, ContactTabsItemCount, ContactsResource, CreateClearingAccountOptions, CreateContactOptions, CreateCreditNoteFromInvoiceResult, CreateFileImportAccountOptions, CreateInvoiceFromOrderOptions, CreatePartOptions, CreateTagOptions, CreateTransactionOptions, CreditNote, CreditNoteBookingCategory, CreditNoteBookingType, CreditNoteDiscount, CreditNoteInput, CreditNoteMail, CreditNotePdf, CreditNotePosition, CreditNotePositionInput, CreditNoteSendType, CreditNoteStatus, CreditNotesResource, DEFAULT_BASE_URL, type DateInput, ExportConfigOptions, ExportContactFilter, ExportContactsOptions, ExportCreditNotesOptions, ExportDatevCsvJobOptions, ExportDatevXmlJobOptions, ExportDocumentFilter, ExportFile, ExportInvoiceFilter, ExportInvoiceType, ExportInvoicesOptions, ExportJobDownloadInfo, ExportProgress, ExportSevQueryObject, ExportSevQueryOptions, ExportSevQueryValue, ExportTransactionFilter, ExportTransactionsOptions, ExportVoucherFilter, ExportVouchersOptions, ExportsResource, FindContactsByCustomFieldValueOptions, GetOrderRelatedObjectsOptions, type HttpRequestOptions, Invoice, InvoiceBookingType, InvoiceEmail, InvoiceInput, InvoicePdf, InvoicePosition, InvoicePositionInput, InvoiceRenderParameter, InvoiceSendType, InvoiceStatus, InvoiceType, InvoicesResource, ListContactsOptions, ListCreditNotePositionsOptions, ListCreditNotesOptions, ListInvoicesOptions, type ListOptions, ListOrderPositionsOptions, ListOrdersOptions, ListPartsOptions, ListTagsOptions, ListTransactionsOptions, ListVouchersOptions, type ModelRef, type ModelRefResponse, Order, OrderDiscount, OrderInput, OrderMail, OrderPdf, OrderPosition, OrderPositionInput, OrderRelatedObject, OrderSendType, OrderStatus, OrderType, OrdersResource, Part, PartStatus, PartsResource, type Query, type QueryValue, ReceiptGuidanceResource, ReceiptGuide, RenderInvoiceResult, ReportContactListOptions, ReportInvoiceListOptions, ReportOrderFilter, ReportOrderListOptions, ReportOrderType, ReportVoucherListOptions, ReportsResource, SaveCreditNoteOptions, SaveCreditNoteResult, SaveInvoiceOptions, SaveInvoiceResult, SaveOrderOptions, SaveOrderResult, SaveVoucherOptions, SaveVoucherResult, SendCreditNoteByOptions, SendCreditNoteViaEmailOptions, SendInvoiceByOptions, SendInvoiceViaEmailOptions, SendOrderByOptions, SendOrderViaEmailOptions, SevDesk, SevDeskError, type SevDeskOptions, Tag, TagObjectType, TagRelation, TagsResource, TransactionStatus, TransactionsResource, UpdateCheckAccountOptions, UpdateContactOptions, UpdateCreditNoteOptions, UpdateOrderOptions, UpdateOrderPositionOptions, UpdatePartOptions, UpdateTransactionOptions, UpdateVoucherOptions, UploadVoucherFileResult, Voucher, VoucherBookingType, VoucherInput, VoucherPosition, VoucherPositionInput, VoucherStatus, VouchersResource, toExportContactFilter, toExportDocumentFilter, toExportInvoiceFilter, toExportSevQueryParams, toExportVoucherFilter };
1990
+ //# sourceMappingURL=index.d.ts.map