@genz-its/sevdesk-sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -146,6 +146,133 @@ declare class CheckAccountsResource extends BaseResource {
146
146
  }): Promise<string>;
147
147
  }
148
148
  //#endregion
149
+ //#region src/resources/communication-ways.d.ts
150
+ /** The medium of a communication way. */
151
+ type CommunicationWayType = 'EMAIL' | 'PHONE' | 'WEB' | 'MOBILE';
152
+ interface ListCommunicationWaysOptions extends ListOptions {
153
+ /** Only returns the communication ways of this contact. */
154
+ contactId?: number;
155
+ type?: CommunicationWayType;
156
+ /** `'1'` returns only the main communication ways. */
157
+ main?: '0' | '1';
158
+ }
159
+ interface CreateCommunicationWayOptions {
160
+ /** The contact this communication way belongs to. */
161
+ contactId: number;
162
+ type: CommunicationWayType;
163
+ /** The phone number, e-mail address or website. */
164
+ value: string;
165
+ /**
166
+ * The key of the communication way, e.g. `1` for private and `2` for work.
167
+ * For all keys, send a `GET` to `/CommunicationWayKey`.
168
+ */
169
+ keyId: number;
170
+ /** Defines if this is the main communication way of the contact. */
171
+ main?: boolean;
172
+ }
173
+ interface UpdateCommunicationWayOptions extends Partial<CreateCommunicationWayOptions> {
174
+ communicationWayId: number;
175
+ }
176
+ interface CommunicationWay {
177
+ id: string;
178
+ objectName: string;
179
+ create: string;
180
+ update: string;
181
+ sevClient: ModelRefResponse;
182
+ contact: ModelRefResponse;
183
+ type: string;
184
+ value: string;
185
+ key: ModelRefResponse;
186
+ main: string;
187
+ }
188
+ /** The key of a communication way, similar to the category of an address. */
189
+ interface CommunicationWayKey {
190
+ id: string;
191
+ objectName: string;
192
+ create: string;
193
+ update: string;
194
+ name: string;
195
+ translationCode: string;
196
+ }
197
+ declare class CommunicationWaysResource extends BaseResource {
198
+ /** Retrieves communication ways via `GET /CommunicationWay`. */
199
+ list(options?: ListCommunicationWaysOptions): Promise<CommunicationWay[]>;
200
+ /** Retrieves a single communication way via `GET /CommunicationWay/{communicationWayId}`. */
201
+ get(options: {
202
+ communicationWayId: number;
203
+ }): Promise<CommunicationWay>;
204
+ /** Creates a communication way via `POST /CommunicationWay`. */
205
+ create(options: CreateCommunicationWayOptions): Promise<CommunicationWay>;
206
+ /** Updates a communication way via `PUT /CommunicationWay/{communicationWayId}`. */
207
+ update(options: UpdateCommunicationWayOptions): Promise<CommunicationWay>;
208
+ /** Deletes a communication way via `DELETE /CommunicationWay/{communicationWayId}`. */
209
+ delete(options: {
210
+ communicationWayId: number;
211
+ }): Promise<void>;
212
+ /** Retrieves all communication way keys via `GET /CommunicationWayKey`. */
213
+ listKeys(options?: ListOptions): Promise<CommunicationWayKey[]>;
214
+ }
215
+ //#endregion
216
+ //#region src/resources/contact-addresses.d.ts
217
+ interface CreateContactAddressOptions {
218
+ /** The contact this address belongs to. */
219
+ contactId: number;
220
+ /** The country of the address. For all countries, send a `GET` to `/StaticCountry`. */
221
+ countryId: number;
222
+ /**
223
+ * The category of the address. For all categories, send a `GET` to
224
+ * `/Category?objectType=ContactAddress`.
225
+ */
226
+ categoryId: number;
227
+ street?: string;
228
+ zip?: string;
229
+ city?: string;
230
+ /** Name in the address. */
231
+ name?: string;
232
+ /** Second name in the address. */
233
+ name2?: string;
234
+ /** Third name in the address. */
235
+ name3?: string;
236
+ /** Fourth name in the address. */
237
+ name4?: string;
238
+ }
239
+ interface UpdateContactAddressOptions extends Partial<CreateContactAddressOptions> {
240
+ contactAddressId: number;
241
+ }
242
+ interface ContactAddress {
243
+ id: string;
244
+ objectName: string;
245
+ create: string;
246
+ update: string;
247
+ sevClient: ModelRefResponse;
248
+ contact: ModelRefResponse;
249
+ street: string | null;
250
+ zip: string | null;
251
+ city: string | null;
252
+ country: ModelRefResponse;
253
+ category: ModelRefResponse | null;
254
+ name: string | null;
255
+ name2: string | null;
256
+ name3: string | null;
257
+ name4: string | null;
258
+ }
259
+ declare class ContactAddressesResource extends BaseResource {
260
+ /** Retrieves contact addresses via `GET /ContactAddress`. */
261
+ list(options?: ListOptions): Promise<ContactAddress[]>;
262
+ /** Retrieves a single contact address via `GET /ContactAddress/{contactAddressId}`. */
263
+ get(options: {
264
+ contactAddressId: number;
265
+ }): Promise<ContactAddress>;
266
+ /** Creates a contact address via `POST /ContactAddress`. */
267
+ create(options: CreateContactAddressOptions): Promise<ContactAddress>;
268
+ /** Updates a contact address via `PUT /ContactAddress/{contactAddressId}`. */
269
+ update(options: UpdateContactAddressOptions): Promise<ContactAddress>;
270
+ /** Deletes a contact address via `DELETE /ContactAddress/{contactAddressId}`. */
271
+ delete(options: {
272
+ contactAddressId: number;
273
+ }): Promise<void>;
274
+ }
275
+ //#endregion
149
276
  //#region src/resources/contacts.d.ts
150
277
  /** `100` for a lead, `500` for a pending and `1000` for an active contact. */
151
278
  type ContactStatus = 100 | 500 | 1000;
@@ -1817,6 +1944,18 @@ interface ListVouchersOptions extends ListOptions {
1817
1944
  startDate?: DateInput;
1818
1945
  endDate?: DateInput;
1819
1946
  contactId?: number;
1947
+ /**
1948
+ * Filters vouchers by a linked object, for example a document the voucher
1949
+ * originated from. Payment bookings are not exposed as linked objects, so
1950
+ * this cannot look up the voucher booked against a bank transaction.
1951
+ */
1952
+ linkedObjectId?: number;
1953
+ linkedObjectName?: string;
1954
+ embed?: string[];
1955
+ }
1956
+ interface ListVoucherPositionsOptions extends ListOptions {
1957
+ /** Only returns the positions of this voucher. */
1958
+ voucherId?: number;
1820
1959
  embed?: string[];
1821
1960
  }
1822
1961
  interface UpdateVoucherOptions {
@@ -1954,16 +2093,16 @@ declare class VouchersResource extends BaseResource {
1954
2093
  enshrine(options: {
1955
2094
  voucherId: number;
1956
2095
  }): Promise<void>;
1957
- /** Retrieves the positions of a voucher via `GET /VoucherPos`. */
1958
- listPositions(options: {
1959
- voucherId: number;
1960
- } & ListOptions): Promise<VoucherPosition[]>;
2096
+ /** Retrieves voucher positions via `GET /VoucherPos`. */
2097
+ listPositions(options?: ListVoucherPositionsOptions): Promise<VoucherPosition[]>;
1961
2098
  }
1962
2099
  //#endregion
1963
2100
  //#region src/client.d.ts
1964
2101
  declare class SevDesk {
1965
2102
  readonly basics: BasicsResource;
1966
2103
  readonly checkAccounts: CheckAccountsResource;
2104
+ readonly communicationWays: CommunicationWaysResource;
2105
+ readonly contactAddresses: ContactAddressesResource;
1967
2106
  readonly contacts: ContactsResource;
1968
2107
  readonly creditNotes: CreditNotesResource;
1969
2108
  readonly exports: ExportsResource;
@@ -1990,5 +2129,5 @@ declare class SevDeskError extends Error {
1990
2129
  });
1991
2130
  }
1992
2131
  //#endregion
1993
- 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 };
2132
+ export { AllowedTaxRule, BasicsResource, BookCreditNoteOptions, BookCreditNoteResult, BookInvoiceOptions, BookInvoiceResult, BookVoucherOptions, BookVoucherResult, BookkeepingSystemVersion, CheckAccount, CheckAccountTransaction, CheckAccountsResource, CommunicationWay, CommunicationWayKey, CommunicationWayType, CommunicationWaysResource, Contact, ContactAddress, ContactAddressesResource, ContactStatus, ContactTabsItemCount, ContactsResource, CreateClearingAccountOptions, CreateCommunicationWayOptions, CreateContactAddressOptions, 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, ListCommunicationWaysOptions, ListContactsOptions, ListCreditNotePositionsOptions, ListCreditNotesOptions, ListInvoicesOptions, type ListOptions, ListOrderPositionsOptions, ListOrdersOptions, ListPartsOptions, ListTagsOptions, ListTransactionsOptions, ListVoucherPositionsOptions, 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, UpdateCommunicationWayOptions, UpdateContactAddressOptions, UpdateContactOptions, UpdateCreditNoteOptions, UpdateOrderOptions, UpdateOrderPositionOptions, UpdatePartOptions, UpdateTransactionOptions, UpdateVoucherOptions, UploadVoucherFileResult, Voucher, VoucherBookingType, VoucherInput, VoucherPosition, VoucherPositionInput, VoucherStatus, VouchersResource, toExportContactFilter, toExportDocumentFilter, toExportInvoiceFilter, toExportSevQueryParams, toExportVoucherFilter };
1994
2133
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -266,6 +266,165 @@ var CheckAccountsResource = class extends BaseResource {
266
266
  }
267
267
  };
268
268
  //#endregion
269
+ //#region src/resources/communication-ways.ts
270
+ var CommunicationWaysResource = class extends BaseResource {
271
+ /** Retrieves communication ways via `GET /CommunicationWay`. */
272
+ list(options = {}) {
273
+ const { contactId, type, main, limit, offset } = options;
274
+ return this.http.request({
275
+ method: "GET",
276
+ path: "/CommunicationWay",
277
+ query: {
278
+ "contact[id]": contactId,
279
+ "contact[objectName]": contactId === void 0 ? void 0 : "Contact",
280
+ type,
281
+ main,
282
+ limit,
283
+ offset
284
+ }
285
+ });
286
+ }
287
+ /** Retrieves a single communication way via `GET /CommunicationWay/{communicationWayId}`. */
288
+ async get(options) {
289
+ const communicationWay = (await this.http.request({
290
+ method: "GET",
291
+ path: `/CommunicationWay/${options.communicationWayId}`
292
+ }))[0];
293
+ if (!communicationWay) throw new SevDeskError({
294
+ status: 404,
295
+ statusText: "Not Found",
296
+ body: null
297
+ });
298
+ return communicationWay;
299
+ }
300
+ /** Creates a communication way via `POST /CommunicationWay`. */
301
+ create(options) {
302
+ return this.http.request({
303
+ method: "POST",
304
+ path: "/CommunicationWay",
305
+ body: toCommunicationWayBody(options)
306
+ });
307
+ }
308
+ /** Updates a communication way via `PUT /CommunicationWay/{communicationWayId}`. */
309
+ update(options) {
310
+ const { communicationWayId, ...fields } = options;
311
+ return this.http.request({
312
+ method: "PUT",
313
+ path: `/CommunicationWay/${communicationWayId}`,
314
+ body: toCommunicationWayBody(fields)
315
+ });
316
+ }
317
+ /** Deletes a communication way via `DELETE /CommunicationWay/{communicationWayId}`. */
318
+ async delete(options) {
319
+ await this.http.request({
320
+ method: "DELETE",
321
+ path: `/CommunicationWay/${options.communicationWayId}`
322
+ });
323
+ }
324
+ /** Retrieves all communication way keys via `GET /CommunicationWayKey`. */
325
+ listKeys(options = {}) {
326
+ return this.http.request({
327
+ method: "GET",
328
+ path: "/CommunicationWayKey",
329
+ query: {
330
+ limit: options.limit,
331
+ offset: options.offset
332
+ }
333
+ });
334
+ }
335
+ };
336
+ function toCommunicationWayBody(fields) {
337
+ return {
338
+ objectName: "CommunicationWay",
339
+ mapAll: true,
340
+ contact: toRef$8(fields.contactId, "Contact"),
341
+ type: fields.type,
342
+ value: fields.value,
343
+ key: toRef$8(fields.keyId, "CommunicationWayKey"),
344
+ main: fields.main
345
+ };
346
+ }
347
+ function toRef$8(id, objectName) {
348
+ return id === void 0 ? void 0 : {
349
+ id,
350
+ objectName
351
+ };
352
+ }
353
+ //#endregion
354
+ //#region src/resources/contact-addresses.ts
355
+ var ContactAddressesResource = class extends BaseResource {
356
+ /** Retrieves contact addresses via `GET /ContactAddress`. */
357
+ list(options = {}) {
358
+ return this.http.request({
359
+ method: "GET",
360
+ path: "/ContactAddress",
361
+ query: {
362
+ limit: options.limit,
363
+ offset: options.offset
364
+ }
365
+ });
366
+ }
367
+ /** Retrieves a single contact address via `GET /ContactAddress/{contactAddressId}`. */
368
+ async get(options) {
369
+ const address = (await this.http.request({
370
+ method: "GET",
371
+ path: `/ContactAddress/${options.contactAddressId}`
372
+ }))[0];
373
+ if (!address) throw new SevDeskError({
374
+ status: 404,
375
+ statusText: "Not Found",
376
+ body: null
377
+ });
378
+ return address;
379
+ }
380
+ /** Creates a contact address via `POST /ContactAddress`. */
381
+ create(options) {
382
+ return this.http.request({
383
+ method: "POST",
384
+ path: "/ContactAddress",
385
+ body: toContactAddressBody(options)
386
+ });
387
+ }
388
+ /** Updates a contact address via `PUT /ContactAddress/{contactAddressId}`. */
389
+ update(options) {
390
+ const { contactAddressId, ...fields } = options;
391
+ return this.http.request({
392
+ method: "PUT",
393
+ path: `/ContactAddress/${contactAddressId}`,
394
+ body: toContactAddressBody(fields)
395
+ });
396
+ }
397
+ /** Deletes a contact address via `DELETE /ContactAddress/{contactAddressId}`. */
398
+ async delete(options) {
399
+ await this.http.request({
400
+ method: "DELETE",
401
+ path: `/ContactAddress/${options.contactAddressId}`
402
+ });
403
+ }
404
+ };
405
+ function toContactAddressBody(fields) {
406
+ return {
407
+ objectName: "ContactAddress",
408
+ mapAll: true,
409
+ contact: toRef$7(fields.contactId, "Contact"),
410
+ country: toRef$7(fields.countryId, "StaticCountry"),
411
+ category: toRef$7(fields.categoryId, "Category"),
412
+ street: fields.street,
413
+ zip: fields.zip,
414
+ city: fields.city,
415
+ name: fields.name,
416
+ name2: fields.name2,
417
+ name3: fields.name3,
418
+ name4: fields.name4
419
+ };
420
+ }
421
+ function toRef$7(id, objectName) {
422
+ return id === void 0 ? void 0 : {
423
+ id,
424
+ objectName
425
+ };
426
+ }
427
+ //#endregion
269
428
  //#region src/resources/contacts.ts
270
429
  var ContactsResource = class extends BaseResource {
271
430
  /** Retrieves contacts via `GET /Contact`. */
@@ -1788,7 +1947,7 @@ function toOptionalIsoDateTime(value) {
1788
1947
  var VouchersResource = class extends BaseResource {
1789
1948
  /** Retrieves vouchers via `GET /Voucher`. */
1790
1949
  list(options = {}) {
1791
- const { status, creditDebit, descriptionLike, startDate, endDate, contactId, limit, offset, embed } = options;
1950
+ const { status, creditDebit, descriptionLike, startDate, endDate, contactId, linkedObjectId, linkedObjectName, limit, offset, embed } = options;
1792
1951
  return this.http.request({
1793
1952
  method: "GET",
1794
1953
  path: "/Voucher",
@@ -1800,6 +1959,8 @@ var VouchersResource = class extends BaseResource {
1800
1959
  endDate: toOptionalVoucherDate(endDate),
1801
1960
  "contact[id]": contactId,
1802
1961
  "contact[objectName]": contactId === void 0 ? void 0 : "Contact",
1962
+ "object[id]": linkedObjectId,
1963
+ "object[objectName]": linkedObjectId === void 0 ? void 0 : linkedObjectName,
1803
1964
  limit,
1804
1965
  offset,
1805
1966
  embed
@@ -1918,17 +2079,18 @@ var VouchersResource = class extends BaseResource {
1918
2079
  path: `/Voucher/${options.voucherId}/enshrine`
1919
2080
  });
1920
2081
  }
1921
- /** Retrieves the positions of a voucher via `GET /VoucherPos`. */
1922
- listPositions(options) {
1923
- const { voucherId, limit, offset } = options;
2082
+ /** Retrieves voucher positions via `GET /VoucherPos`. */
2083
+ listPositions(options = {}) {
2084
+ const { voucherId, limit, offset, embed } = options;
1924
2085
  return this.http.request({
1925
2086
  method: "GET",
1926
2087
  path: "/VoucherPos",
1927
2088
  query: {
1928
2089
  "voucher[id]": voucherId,
1929
- "voucher[objectName]": "Voucher",
2090
+ "voucher[objectName]": voucherId === void 0 ? void 0 : "Voucher",
1930
2091
  limit,
1931
- offset
2092
+ offset,
2093
+ embed
1932
2094
  }
1933
2095
  });
1934
2096
  }
@@ -1987,6 +2149,8 @@ function toOptionalVoucherDate(value) {
1987
2149
  var SevDesk = class {
1988
2150
  basics;
1989
2151
  checkAccounts;
2152
+ communicationWays;
2153
+ contactAddresses;
1990
2154
  contacts;
1991
2155
  creditNotes;
1992
2156
  exports;
@@ -2002,6 +2166,8 @@ var SevDesk = class {
2002
2166
  const http = new HttpClient(options);
2003
2167
  this.basics = new BasicsResource(http);
2004
2168
  this.checkAccounts = new CheckAccountsResource(http);
2169
+ this.communicationWays = new CommunicationWaysResource(http);
2170
+ this.contactAddresses = new ContactAddressesResource(http);
2005
2171
  this.contacts = new ContactsResource(http);
2006
2172
  this.creditNotes = new CreditNotesResource(http);
2007
2173
  this.exports = new ExportsResource(http);
@@ -2016,6 +2182,6 @@ var SevDesk = class {
2016
2182
  }
2017
2183
  };
2018
2184
  //#endregion
2019
- export { BasicsResource, CheckAccountsResource, ContactsResource, CreditNotesResource, DEFAULT_BASE_URL, ExportsResource, InvoicesResource, OrdersResource, PartsResource, ReceiptGuidanceResource, ReportsResource, SevDesk, SevDeskError, TagsResource, TransactionsResource, VouchersResource, toExportContactFilter, toExportDocumentFilter, toExportInvoiceFilter, toExportSevQueryParams, toExportVoucherFilter };
2185
+ export { BasicsResource, CheckAccountsResource, CommunicationWaysResource, ContactAddressesResource, ContactsResource, CreditNotesResource, DEFAULT_BASE_URL, ExportsResource, InvoicesResource, OrdersResource, PartsResource, ReceiptGuidanceResource, ReportsResource, SevDesk, SevDeskError, TagsResource, TransactionsResource, VouchersResource, toExportContactFilter, toExportDocumentFilter, toExportInvoiceFilter, toExportSevQueryParams, toExportVoucherFilter };
2020
2186
 
2021
2187
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["toRef","toOptionalDate","toRef","toOptionalIsoDateTime","toRef","toRef","toRef","toRef"],"sources":["../src/errors.ts","../src/http-client.ts","../src/resources/base.ts","../src/resources/basics.ts","../src/dates.ts","../src/resources/check-accounts.ts","../src/resources/contacts.ts","../src/resources/credit-notes.ts","../src/resources/exports.ts","../src/resources/invoices.ts","../src/resources/orders.ts","../src/resources/parts.ts","../src/resources/receipt-guidance.ts","../src/resources/reports.ts","../src/resources/tags.ts","../src/resources/transactions.ts","../src/resources/vouchers.ts","../src/client.ts"],"sourcesContent":["export class SevDeskError extends Error {\n public readonly status: number;\n public readonly statusText: string;\n public readonly body: unknown;\n\n constructor(options: { status: number; statusText: string; body: unknown }) {\n super(extractMessage(options));\n this.name = 'SevDeskError';\n this.status = options.status;\n this.statusText = options.statusText;\n this.body = options.body;\n }\n}\n\nfunction extractMessage(options: {\n status: number;\n statusText: string;\n body: unknown;\n}): string {\n const fallback = `sevdesk API error: ${options.status} ${options.statusText}`;\n const body = options.body;\n if (typeof body === 'string' && body.length > 0) {\n return body;\n }\n if (typeof body === 'object' && body !== null) {\n const error = (body as { error?: unknown }).error;\n if (typeof error === 'object' && error !== null) {\n const message = (error as { message?: unknown }).message;\n if (typeof message === 'string' && message.length > 0) {\n return message;\n }\n }\n const message = (body as { message?: unknown }).message;\n if (typeof message === 'string' && message.length > 0) {\n return message;\n }\n }\n return fallback;\n}\n","import { SevDeskError } from './errors';\n\nexport const DEFAULT_BASE_URL = 'https://my.sevdesk.de/api/v1';\n\nconst DEFAULT_TIMEOUT = 30_000;\nconst DEFAULT_USER_AGENT = '@genz-its/sevdesk-sdk';\nconst RETRY_MAX_ATTEMPTS = 3;\nconst RETRY_BASE_DELAY = 500;\nconst RETRY_MAX_DELAY = 10_000;\nconst RETRY_AFTER_MAX_DELAY = 60_000;\nconst RETRYABLE_METHODS = new Set(['GET', 'PUT', 'DELETE']);\nconst RETRYABLE_STATUS_CODES = new Set([429, 500, 502, 503, 504]);\n\nexport interface SevDeskOptions {\n /** The sevdesk API token, sent as raw `Authorization` header value. */\n token: string;\n baseUrl?: string;\n /** Request timeout in milliseconds. Defaults to 30 seconds. */\n timeout?: number;\n userAgent?: string;\n fetch?: typeof globalThis.fetch;\n}\n\nexport type QueryValue = string | number | boolean | string[] | undefined;\n\nexport type Query = Record<string, QueryValue>;\n\nexport interface HttpRequestOptions {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n path: string;\n query?: Query;\n body?: unknown;\n formData?: FormData;\n}\n\nexport class HttpClient {\n private readonly token: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly userAgent: string;\n private readonly fetch: typeof globalThis.fetch;\n\n constructor(options: SevDeskOptions) {\n this.token = options.token.trim();\n this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n this.userAgent = options.userAgent ?? DEFAULT_USER_AGENT;\n this.fetch = options.fetch ?? globalThis.fetch;\n }\n\n /**\n * Performs a request and returns the payload of the `objects` response\n * envelope. Responses without an envelope are returned as-is.\n */\n public async request<T>(options: HttpRequestOptions): Promise<T> {\n const response = await this.fetchWithRetry(options);\n const text = await response.text();\n if (text.length === 0) {\n return undefined as T;\n }\n return unwrap(JSON.parse(text)) as T;\n }\n\n private async fetchWithRetry(options: HttpRequestOptions): Promise<Response> {\n const url = this.buildUrl(options);\n const retryable = RETRYABLE_METHODS.has(options.method);\n for (let attempt = 0; ; attempt++) {\n const canRetry = retryable && attempt < RETRY_MAX_ATTEMPTS;\n let response: Response;\n try {\n response = await this.fetch(url, this.buildRequestInit(options));\n } catch (error) {\n if (canRetry) {\n await delay(backoffDelay(attempt));\n continue;\n }\n throw error;\n }\n if (response.ok) {\n return response;\n }\n if (canRetry && RETRYABLE_STATUS_CODES.has(response.status)) {\n await delay(\n retryAfterDelay(response.headers.get('Retry-After')) ??\n backoffDelay(attempt),\n );\n continue;\n }\n throw new SevDeskError({\n status: response.status,\n statusText: response.statusText,\n body: await parseErrorBody(response),\n });\n }\n }\n\n private buildUrl(options: HttpRequestOptions): string {\n const url = new URL(this.baseUrl + options.path);\n for (const [key, value] of Object.entries(options.query ?? {})) {\n if (value === undefined) {\n continue;\n }\n url.searchParams.append(\n key,\n Array.isArray(value) ? value.join(',') : String(value),\n );\n }\n return url.toString();\n }\n\n private buildRequestInit(options: HttpRequestOptions): RequestInit {\n const headers: Record<string, string> = {\n Authorization: this.token,\n Accept: 'application/json',\n 'User-Agent': this.userAgent,\n };\n let body: RequestInit['body'];\n if (options.formData) {\n body = options.formData;\n } else if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n body = JSON.stringify(options.body);\n }\n return {\n method: options.method,\n headers,\n body,\n signal: AbortSignal.timeout(this.timeout),\n };\n }\n}\n\nfunction unwrap(payload: unknown): unknown {\n if (typeof payload === 'object' && payload !== null && 'objects' in payload) {\n return (payload as { objects: unknown }).objects;\n }\n return payload;\n}\n\nasync function parseErrorBody(response: Response): Promise<unknown> {\n const text = await response.text();\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n}\n\nfunction backoffDelay(attempt: number): number {\n const ceiling = Math.min(RETRY_MAX_DELAY, RETRY_BASE_DELAY * 2 ** attempt);\n return ceiling / 2 + Math.random() * (ceiling / 2);\n}\n\nfunction retryAfterDelay(header: string | null): number | undefined {\n if (!header) {\n return undefined;\n }\n const seconds = Number(header);\n const milliseconds = Number.isFinite(seconds)\n ? seconds * 1000\n : new Date(header).getTime() - Date.now();\n if (!Number.isFinite(milliseconds) || milliseconds < 0) {\n return undefined;\n }\n return Math.min(milliseconds, RETRY_AFTER_MAX_DELAY);\n}\n\nfunction delay(milliseconds: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, milliseconds));\n}\n","import type { HttpClient } from '../http-client';\n\nexport abstract class BaseResource {\n protected readonly http: HttpClient;\n\n constructor(http: HttpClient) {\n this.http = http;\n }\n}\n","import { BaseResource } from './base';\n\nexport type BookkeepingSystemVersion = '1.0' | '2.0';\n\nexport class BasicsResource extends BaseResource {\n /** Retrieves the bookkeeping system version via `GET /Tools/bookkeepingSystemVersion`. */\n public async getBookkeepingSystemVersion(): Promise<BookkeepingSystemVersion> {\n const result = await this.http.request<{\n version: BookkeepingSystemVersion;\n }>({\n method: 'GET',\n path: '/Tools/bookkeepingSystemVersion',\n });\n return result.version;\n }\n}\n","import type { DateInput } from './types';\n\n/**\n * Serializes a date for voucher endpoints, which accept a Unix timestamp\n * or a `dd.mm.yyyy` string.\n */\nexport function toVoucherDate(value: DateInput): string | number {\n if (value instanceof Date) {\n return Math.floor(value.getTime() / 1000);\n }\n return value;\n}\n\n/** Serializes a date as ISO 8601, as expected by transaction endpoints. */\nexport function toIsoDateTime(value: DateInput): string {\n if (value instanceof Date) {\n return value.toISOString();\n }\n if (typeof value === 'number') {\n return new Date(value * 1000).toISOString();\n }\n return value;\n}\n\n/** Serializes a date as `YYYY-MM-DD`. */\nexport function toPlainDate(value: DateInput): string {\n if (value instanceof Date) {\n return value.toISOString().slice(0, 10);\n }\n if (typeof value === 'number') {\n return new Date(value * 1000).toISOString().slice(0, 10);\n }\n return value;\n}\n","import { toPlainDate } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type { DateInput, ListOptions, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/** A payment account, e.g. a bank account or a clearing account. */\nexport interface CheckAccount {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n name: string;\n iban: string | null;\n type: 'online' | 'offline' | 'register';\n importType: 'CSV' | 'MT940' | null;\n currency: string;\n defaultAccount: string;\n baseAccount: string;\n priority: string;\n status: string;\n balance: string | null;\n bankServer: string | null;\n autoMapTransactions: string | null;\n autoSyncTransactions: string;\n lastSync: string;\n accountingNumber: string;\n bic: string | null;\n}\n\nexport interface CreateFileImportAccountOptions {\n name: string;\n importType: 'CSV' | 'MT940';\n accountingNumber?: number;\n iban?: string;\n}\n\nexport interface CreateClearingAccountOptions {\n name: string;\n accountingNumber?: number;\n}\n\nexport interface UpdateCheckAccountOptions {\n checkAccountId: number;\n name?: string;\n defaultAccount?: number;\n autoMapTransactions?: number;\n accountingNumber?: number;\n iban?: string;\n bic?: string;\n}\n\nexport class CheckAccountsResource extends BaseResource {\n /** Retrieves all check accounts via `GET /CheckAccount`. */\n public async list(options: ListOptions = {}): Promise<CheckAccount[]> {\n return this.http.request<CheckAccount[]>({\n method: 'GET',\n path: '/CheckAccount',\n query: { limit: options.limit, offset: options.offset },\n });\n }\n\n /** Retrieves a single check account via `GET /CheckAccount/{checkAccountId}`. */\n public async get(options: { checkAccountId: number }): Promise<CheckAccount> {\n const checkAccounts = await this.http.request<CheckAccount[]>({\n method: 'GET',\n path: `/CheckAccount/${options.checkAccountId}`,\n });\n const checkAccount = checkAccounts[0];\n if (!checkAccount) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return checkAccount;\n }\n\n /** Creates a file import account via `POST /CheckAccount/Factory/fileImportAccount`. */\n public async createFileImportAccount(\n options: CreateFileImportAccountOptions,\n ): Promise<CheckAccount> {\n return this.http.request<CheckAccount>({\n method: 'POST',\n path: '/CheckAccount/Factory/fileImportAccount',\n body: options,\n });\n }\n\n /** Creates a clearing account via `POST /CheckAccount/Factory/clearingAccount`. */\n public async createClearingAccount(\n options: CreateClearingAccountOptions,\n ): Promise<CheckAccount> {\n return this.http.request<CheckAccount>({\n method: 'POST',\n path: '/CheckAccount/Factory/clearingAccount',\n body: options,\n });\n }\n\n /** Updates a check account via `PUT /CheckAccount/{checkAccountId}`. */\n public async update(\n options: UpdateCheckAccountOptions,\n ): Promise<CheckAccount> {\n const { checkAccountId, ...body } = options;\n return this.http.request<CheckAccount>({\n method: 'PUT',\n path: `/CheckAccount/${checkAccountId}`,\n body,\n });\n }\n\n /** Deletes a check account via `DELETE /CheckAccount/{checkAccountId}`. */\n public async delete(options: { checkAccountId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/CheckAccount/${options.checkAccountId}`,\n });\n }\n\n /**\n * Retrieves the balance at a date via `GET /CheckAccount/{checkAccountId}/getBalanceAtDate`.\n *\n * The balance is the sum of all transactions sevdesk knows up to and\n * including the given date. It does not have to match the actual bank\n * account balance, e.g. if old transactions were never imported.\n */\n public async getBalanceAtDate(options: {\n checkAccountId: number;\n date: DateInput;\n }): Promise<string> {\n return this.http.request<string>({\n method: 'GET',\n path: `/CheckAccount/${options.checkAccountId}/getBalanceAtDate`,\n query: { date: toPlainDate(options.date) },\n });\n }\n}\n","import { SevDeskError } from '../errors';\nimport type { ListOptions, ModelRef, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/** `100` for a lead, `500` for a pending and `1000` for an active contact. */\nexport type ContactStatus = 100 | 500 | 1000;\n\nexport interface ListContactsOptions extends ListOptions {\n /**\n * `'0'` returns only organizations, `'1'` organizations and persons.\n * Defaults to `'0'`.\n */\n depth?: '0' | '1';\n customerNumber?: string;\n /** Matches the `name`, `surename` or `familyname` of a contact. */\n name?: string;\n categoryId?: number;\n /** Only returns contacts belonging to this organization. */\n parentId?: number;\n embed?: string[];\n}\n\nexport interface CreateContactOptions {\n /**\n * The category of the contact. The sevdesk default categories are `2` for a\n * supplier, `3` for a customer, `4` for a partner and `28` for a prospect\n * customer.\n */\n categoryId: number;\n /**\n * The organization name. A contact holding a name is regarded as an\n * organization, one holding a `surename` or `familyname` as a person.\n */\n name?: string;\n /** The **first** name of a person. Not to be used for organizations. */\n surename?: string;\n /** The last name of a person. Not to be used for organizations. */\n familyname?: string;\n /** The middle name or name suffix of a person. */\n name2?: string;\n /** A non-academic title, e.g. the position the person holds. */\n titel?: string;\n academicTitle?: string;\n gender?: string;\n /** The organization this person belongs to. */\n parentId?: number;\n customerNumber?: string;\n status?: ContactStatus;\n description?: string;\n vatNumber?: string;\n taxNumber?: string;\n /** Defines if the contact is freed from paying vat. */\n exemptVat?: boolean;\n /** Bank account number (IBAN) of the contact. */\n bankAccount?: string;\n bankNumber?: string;\n /** The payment goal in days which is set for every invoice of the contact. */\n defaultTimeToPay?: number;\n /** Buyer reference of the contact, required for e-invoices. */\n buyerReference?: string;\n governmentAgency?: boolean;\n}\n\nexport interface UpdateContactOptions extends Partial<CreateContactOptions> {\n contactId: number;\n}\n\nexport interface FindContactsByCustomFieldValueOptions {\n /** The value to be checked. */\n value: string;\n /** The name of the contact custom field setting. */\n customFieldName: string;\n /** Restricts the lookup to a single contact custom field setting. */\n customFieldSettingId?: number;\n}\n\nexport interface Contact {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n name: string | null;\n status: string | null;\n customerNumber: string | null;\n parent: ModelRefResponse | null;\n surename: string | null;\n familyname: string | null;\n titel: string | null;\n category: ModelRefResponse;\n description: string | null;\n academicTitle: string | null;\n gender: string | null;\n name2: string | null;\n birthday: string | null;\n vatNumber: string | null;\n bankAccount: string | null;\n bankNumber: string | null;\n defaultCashbackTime: string | null;\n defaultCashbackPercent: string | null;\n defaultTimeToPay: string | null;\n taxNumber: string | null;\n taxOffice: string | null;\n exemptVat: string | null;\n defaultDiscountAmount: string | null;\n defaultDiscountPercentage: string | null;\n buyerReference: string | null;\n governmentAgency: string | null;\n}\n\n/** Number of documents of a contact, grouped by document type. */\nexport interface ContactTabsItemCount {\n orders: number;\n invoices: number;\n creditNotes: number;\n documents: number;\n persons: number;\n vouchers: number;\n letters: number;\n parts: string;\n invoicePos: number;\n}\n\nexport class ContactsResource extends BaseResource {\n /** Retrieves contacts via `GET /Contact`. */\n public list(options: ListContactsOptions = {}): Promise<Contact[]> {\n const {\n depth,\n customerNumber,\n name,\n categoryId,\n parentId,\n limit,\n offset,\n embed,\n } = options;\n return this.http.request<Contact[]>({\n method: 'GET',\n path: '/Contact',\n query: {\n depth,\n customerNumber,\n name,\n 'category[id]': categoryId,\n 'category[objectName]':\n categoryId === undefined ? undefined : 'Category',\n 'parent[id]': parentId,\n 'parent[objectName]': parentId === undefined ? undefined : 'Contact',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single contact via `GET /Contact/{contactId}`. */\n public async get(options: { contactId: number }): Promise<Contact> {\n const contacts = await this.http.request<Contact[]>({\n method: 'GET',\n path: `/Contact/${options.contactId}`,\n });\n const contact = contacts[0];\n if (!contact) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return contact;\n }\n\n /** Creates a contact via `POST /Contact`. */\n public create(options: CreateContactOptions): Promise<Contact> {\n return this.http.request<Contact>({\n method: 'POST',\n path: '/Contact',\n body: toContactBody(options),\n });\n }\n\n /** Updates a contact via `PUT /Contact/{contactId}`. */\n public update(options: UpdateContactOptions): Promise<Contact> {\n const { contactId, ...fields } = options;\n return this.http.request<Contact>({\n method: 'PUT',\n path: `/Contact/${contactId}`,\n body: toContactBody(fields),\n });\n }\n\n /** Deletes a contact via `DELETE /Contact/{contactId}`. */\n public async delete(options: { contactId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/Contact/${options.contactId}`,\n });\n }\n\n /** Retrieves the next free customer number via `GET /Contact/Factory/getNextCustomerNumber`. */\n public getNextCustomerNumber(): Promise<string> {\n return this.http.request<string>({\n method: 'GET',\n path: '/Contact/Factory/getNextCustomerNumber',\n });\n }\n\n /** Retrieves contacts by a custom field value via `GET /Contact/Factory/findContactsByCustomFieldValue`. */\n public findByCustomFieldValue(\n options: FindContactsByCustomFieldValueOptions,\n ): Promise<Contact[]> {\n const { value, customFieldName, customFieldSettingId } = options;\n return this.http.request<Contact[]>({\n method: 'GET',\n path: '/Contact/Factory/findContactsByCustomFieldValue',\n query: {\n value,\n customFieldName,\n 'customFieldSetting[id]': customFieldSettingId,\n 'customFieldSetting[objectName]':\n customFieldSettingId === undefined\n ? undefined\n : 'ContactCustomFieldSetting',\n },\n });\n }\n\n /** Checks if a customer number is still free via `GET /Contact/Mapper/checkCustomerNumberAvailability`. */\n public checkCustomerNumberAvailability(options: {\n customerNumber: string;\n }): Promise<boolean> {\n return this.http.request<boolean>({\n method: 'GET',\n path: '/Contact/Mapper/checkCustomerNumberAvailability',\n query: { customerNumber: options.customerNumber },\n });\n }\n\n /** Retrieves the document counts of a contact via `GET /Contact/{contactId}/getTabsItemCount`. */\n public getTabsItemCount(options: {\n contactId: number;\n }): Promise<ContactTabsItemCount> {\n return this.http.request<ContactTabsItemCount>({\n method: 'GET',\n path: `/Contact/${options.contactId}/getTabsItemCount`,\n });\n }\n}\n\nfunction toContactBody(\n fields: Partial<CreateContactOptions>,\n): Record<string, unknown> {\n return {\n objectName: 'Contact',\n mapAll: true,\n category: toRef(fields.categoryId, 'Category'),\n parent: toRef(fields.parentId, 'Contact'),\n name: fields.name,\n surename: fields.surename,\n familyname: fields.familyname,\n name2: fields.name2,\n titel: fields.titel,\n academicTitle: fields.academicTitle,\n gender: fields.gender,\n customerNumber: fields.customerNumber,\n status: fields.status,\n description: fields.description,\n vatNumber: fields.vatNumber,\n taxNumber: fields.taxNumber,\n exemptVat: fields.exemptVat,\n bankAccount: fields.bankAccount,\n bankNumber: fields.bankNumber,\n defaultTimeToPay: fields.defaultTimeToPay,\n buyerReference: fields.buyerReference,\n governmentAgency: fields.governmentAgency,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n","import { toIsoDateTime, toVoucherDate } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type {\n DateInput,\n ListOptions,\n ModelRef,\n ModelRefResponse,\n} from '../types';\nimport { BaseResource } from './base';\n\n/**\n * Status of a credit note.\n *\n * - `100` draft\n * - `200` open / delivered\n * - `750` partially paid\n * - `1000` paid\n */\nexport type CreditNoteStatus = 100 | 200 | 750 | 1000;\n\n/**\n * Reason why the credit note was created. `ACCOUNTING_TYPE` is not supported\n * by bookkeeping system 2.0 and therefore not available.\n */\nexport type CreditNoteBookingCategory =\n 'PROVISION' | 'ROYALTY_ASSIGNED' | 'ROYALTY_UNASSIGNED' | 'UNDERACHIEVEMENT';\n\n/**\n * Way in which a credit note was sent to the end-customer: `VPR` printed,\n * `VP` postal, `VM` mailed, `VPDF` downloaded pdf.\n */\nexport type CreditNoteSendType = 'VPR' | 'VP' | 'VM' | 'VPDF';\n\nexport type CreditNoteBookingType =\n 'FULL_PAYMENT' | 'N' | 'CB' | 'O' | 'OF' | 'MTC';\n\nexport interface CreditNoteInput {\n creditNoteNumber: string;\n creditNoteDate: DateInput;\n contactId: number;\n status: CreditNoteStatus;\n /** Usually consists of a prefix and the credit note number. */\n header: string;\n bookingCategory: CreditNoteBookingCategory;\n /** The sevdesk user acting as the contact person. */\n contactPersonId: number;\n /** Defines the vat regulation, for example `1` for \"Umsatzsteuerpflichtige Umsätze\". */\n taxRuleId: number;\n /** Not used anymore, the tax rate of the positions is used instead. */\n taxRate: number;\n /** Text describing the vat regulation, for example `Umsatzsteuer 19%`. */\n taxText: string;\n /** Currency code according to ISO-4217. */\n currency: string;\n deliveryDate: DateInput;\n /** Can be omitted as the complete address is defined in `address`. */\n addressCountryId?: number;\n headText?: string;\n footText?: string;\n /** Complete address of the recipient. Line breaks are kept in the pdf. */\n address?: string;\n smallSettlement?: boolean;\n /** `true` if the position prices are net, `false` if they are gross. */\n showNet?: boolean;\n customerInternalNote?: string;\n sendDate?: DateInput;\n sendType?: CreditNoteSendType;\n}\n\nexport interface CreditNotePositionInput {\n unityId: number;\n quantity: number;\n taxRate: number;\n name?: string;\n /** Price of one unit. Is either net or gross, depending on `showNet`. */\n price?: number;\n text?: string;\n partId?: number;\n /** Starts at zero and is incremented for every further position. */\n positionNumber?: number;\n discount?: number;\n optional?: boolean;\n}\n\nexport interface SaveCreditNoteOptions {\n creditNote: CreditNoteInput;\n positions: CreditNotePositionInput[];\n}\n\nexport interface ListCreditNotesOptions extends ListOptions {\n status?: CreditNoteStatus;\n creditNoteNumber?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n contactId?: number;\n embed?: string[];\n}\n\nexport interface UpdateCreditNoteOptions {\n creditNoteId: number;\n creditNoteNumber?: string;\n creditNoteDate?: DateInput;\n status?: CreditNoteStatus;\n header?: string;\n headText?: string;\n footText?: string;\n address?: string;\n customerInternalNote?: string;\n deliveryDate?: DateInput;\n}\n\nexport interface SendCreditNoteViaEmailOptions {\n creditNoteId: number;\n toEmail: string;\n subject: string;\n /** Can contain html. */\n text: string;\n /** Send a copy of the email to yourself. */\n copy?: boolean;\n /** Ids of existing documents in your sevdesk account, separated by `,`. */\n additionalAttachments?: string;\n /** Mail addresses to be put as cc, separated by `,`. */\n ccEmail?: string;\n /** Mail addresses to be put as bcc, separated by `,`. */\n bccEmail?: string;\n}\n\nexport interface SendCreditNoteByOptions {\n creditNoteId: number;\n sendType: CreditNoteSendType;\n /**\n * Creates a draft for internal use. Neither the status of the credit note\n * nor the bookings for reports are changed.\n */\n sendDraft: boolean;\n}\n\nexport interface BookCreditNoteOptions {\n creditNoteId: number;\n /** Can also be a partial amount. */\n amount: number;\n date: DateInput;\n type: CreditNoteBookingType;\n checkAccountId: number;\n /**\n * Required for online check accounts. Must be omitted for offline check\n * accounts and cash registers, where the transaction is created automatically.\n */\n checkAccountTransactionId?: number;\n createFeed?: boolean;\n}\n\nexport interface ListCreditNotePositionsOptions extends ListOptions {\n creditNoteId?: number;\n embed?: string[];\n}\n\nexport interface CreditNote {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n createUser: ModelRefResponse;\n creditNoteNumber: string | null;\n contact: ModelRefResponse | null;\n creditNoteDate: string;\n status: string;\n header: string | null;\n headText: string | null;\n footText: string | null;\n addressCountry: ModelRefResponse | null;\n deliveryDate: string;\n smallSettlement: boolean | null;\n contactPerson: ModelRefResponse | null;\n taxRate: string | null;\n taxRule: ModelRefResponse;\n taxText: string | null;\n sendDate: string | null;\n address: string | null;\n currency: string | null;\n sumNet: string;\n sumTax: string;\n sumGross: string;\n sumDiscounts: string;\n sumNetForeignCurrency: string;\n sumTaxForeignCurrency: string;\n sumGrossForeignCurrency: string;\n sumDiscountsForeignCurrency: string;\n customerInternalNote: string | null;\n showNet: boolean;\n sendType: string | null;\n}\n\nexport interface CreditNotePosition {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n creditNote: ModelRefResponse;\n part: ModelRefResponse | null;\n quantity: string;\n price: string | null;\n priceNet: string | null;\n priceTax: string | null;\n priceGross: string | null;\n name: string | null;\n unity: ModelRefResponse;\n positionNumber: string | null;\n text: string | null;\n discount: string | null;\n optional: boolean | null;\n taxRate: string;\n sumDiscount: string | null;\n}\n\nexport interface CreditNoteDiscount {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: string;\n /** `1` for a discount, `0` for a surcharge. */\n discount: string;\n text: string;\n /** `1` if `value` is a percentage, `0` if it is an absolute amount. */\n percentage: string;\n value: string;\n /** `0` if the discount is net, `1` if it is gross. */\n isNet: string;\n}\n\nexport interface CreditNoteMail {\n id: string;\n objectName: string;\n additionalInformation: string | null;\n create: string;\n update: string;\n object: CreditNote;\n from: string;\n to: string;\n subject: string;\n text: string;\n sevClient: ModelRefResponse;\n}\n\nexport interface CreditNotePdf {\n filename: string;\n mimeType: string;\n base64encoded: boolean;\n /** The pdf document, base64 encoded. */\n content: string;\n}\n\nexport interface SaveCreditNoteResult {\n creditNote: CreditNote;\n positions: CreditNotePosition[];\n}\n\nexport interface CreateCreditNoteFromInvoiceResult extends SaveCreditNoteResult {\n discounts: CreditNoteDiscount[];\n}\n\nexport interface BookCreditNoteResult {\n id: string;\n objectName: string;\n additionalInformation: string | null;\n create: string;\n creditNote: ModelRefResponse;\n fromStatus: string;\n toStatus: string;\n /** Spelled with two `m` by the sevdesk API. */\n ammountPayed: string;\n bookingDate: string;\n sevClient: ModelRefResponse;\n}\n\nexport class CreditNotesResource extends BaseResource {\n /** Retrieves credit notes via `GET /CreditNote`. */\n public list(options: ListCreditNotesOptions = {}): Promise<CreditNote[]> {\n const {\n status,\n creditNoteNumber,\n startDate,\n endDate,\n contactId,\n limit,\n offset,\n embed,\n } = options;\n return this.http.request<CreditNote[]>({\n method: 'GET',\n path: '/CreditNote',\n query: {\n status,\n creditNoteNumber,\n startDate: toOptionalDate(startDate),\n endDate: toOptionalDate(endDate),\n 'contact[id]': contactId,\n 'contact[objectName]': contactId === undefined ? undefined : 'Contact',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single credit note via `GET /CreditNote/{creditNoteId}`. */\n public async get(options: {\n creditNoteId: number;\n embed?: string[];\n }): Promise<CreditNote> {\n const creditNotes = await this.http.request<CreditNote[]>({\n method: 'GET',\n path: `/CreditNote/${options.creditNoteId}`,\n query: { embed: options.embed },\n });\n const creditNote = creditNotes[0];\n if (!creditNote) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return creditNote;\n }\n\n /** Creates or updates a credit note with its positions via `POST /CreditNote/Factory/saveCreditNote`. */\n public async save(\n options: SaveCreditNoteOptions,\n ): Promise<SaveCreditNoteResult> {\n const { creditNote, positions } = options;\n const result = await this.http.request<{\n creditNote: CreditNote;\n creditNotePos: CreditNotePosition[];\n }>({\n method: 'POST',\n path: '/CreditNote/Factory/saveCreditNote',\n body: {\n creditNote: toCreditNoteBody(creditNote),\n creditNotePosSave: positions.map(toCreditNotePositionBody),\n creditNotePosDelete: null,\n discountSave: null,\n discountDelete: null,\n },\n });\n return {\n creditNote: result.creditNote,\n positions: result.creditNotePos,\n };\n }\n\n /** Creates a credit note from an invoice via `POST /CreditNote/Factory/createFromInvoice`. */\n public async createFromInvoice(options: {\n invoiceId: number;\n }): Promise<CreateCreditNoteFromInvoiceResult> {\n const result = await this.http.request<{\n creditNote: CreditNote;\n creditNotePos: CreditNotePosition[];\n discount: CreditNoteDiscount[];\n }>({\n method: 'POST',\n path: '/CreditNote/Factory/createFromInvoice',\n body: { invoice: { id: options.invoiceId, objectName: 'Invoice' } },\n });\n return {\n creditNote: result.creditNote,\n positions: result.creditNotePos,\n discounts: result.discount,\n };\n }\n\n /** Updates a credit note via `PUT /CreditNote/{creditNoteId}`. */\n public update(options: UpdateCreditNoteOptions): Promise<CreditNote> {\n const { creditNoteId, creditNoteDate, deliveryDate, ...rest } = options;\n return this.http.request<CreditNote>({\n method: 'PUT',\n path: `/CreditNote/${creditNoteId}`,\n body: {\n ...rest,\n creditNoteDate: toOptionalDate(creditNoteDate),\n deliveryDate: toOptionalDate(deliveryDate),\n },\n });\n }\n\n /** Deletes a credit note via `DELETE /CreditNote/{creditNoteId}`. */\n public async delete(options: { creditNoteId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/CreditNote/${options.creditNoteId}`,\n });\n }\n\n /** Sends a credit note via email using `POST /CreditNote/{creditNoteId}/sendViaEmail`. */\n public sendViaEmail(\n options: SendCreditNoteViaEmailOptions,\n ): Promise<CreditNoteMail[]> {\n const { creditNoteId, ...body } = options;\n return this.http.request<CreditNoteMail[]>({\n method: 'POST',\n path: `/CreditNote/${creditNoteId}/sendViaEmail`,\n body,\n });\n }\n\n /** Retrieves the pdf of a credit note via `GET /CreditNote/{creditNoteId}/getPdf`. */\n public getPdf(options: {\n creditNoteId: number;\n /** Prevents the credit note from being marked as sent. */\n preventSendBy?: boolean;\n }): Promise<CreditNotePdf> {\n return this.http.request<CreditNotePdf>({\n method: 'GET',\n path: `/CreditNote/${options.creditNoteId}/getPdf`,\n query: { preventSendBy: options.preventSendBy },\n });\n }\n\n /** Marks a credit note as sent via `PUT /CreditNote/{creditNoteId}/sendBy`. */\n public sendBy(options: SendCreditNoteByOptions): Promise<CreditNote> {\n const { creditNoteId, sendType, sendDraft } = options;\n return this.http.request<CreditNote>({\n method: 'PUT',\n path: `/CreditNote/${creditNoteId}/sendBy`,\n body: { sendType, sendDraft },\n });\n }\n\n /** Books an amount on a credit note via `PUT /CreditNote/{creditNoteId}/bookAmount`. */\n public book(options: BookCreditNoteOptions): Promise<BookCreditNoteResult> {\n const {\n creditNoteId,\n amount,\n date,\n type,\n checkAccountId,\n checkAccountTransactionId,\n createFeed,\n } = options;\n return this.http.request<BookCreditNoteResult>({\n method: 'PUT',\n path: `/CreditNote/${creditNoteId}/bookAmount`,\n body: {\n amount,\n date: toIsoDateTime(date),\n type,\n checkAccount: { id: checkAccountId, objectName: 'CheckAccount' },\n checkAccountTransaction: toRef(\n checkAccountTransactionId,\n 'CheckAccountTransaction',\n ),\n createFeed,\n },\n });\n }\n\n /** Enshrines a credit note via `PUT /CreditNote/{creditNoteId}/enshrine`. This cannot be undone. */\n public async enshrine(options: { creditNoteId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'PUT',\n path: `/CreditNote/${options.creditNoteId}/enshrine`,\n });\n }\n\n /** Resets the credit note status to open via `PUT /CreditNote/{creditNoteId}/resetToOpen`. */\n public resetToOpen(options: { creditNoteId: number }): Promise<CreditNote> {\n return this.http.request<CreditNote>({\n method: 'PUT',\n path: `/CreditNote/${options.creditNoteId}/resetToOpen`,\n });\n }\n\n /** Resets the credit note status to draft via `PUT /CreditNote/{creditNoteId}/resetToDraft`. */\n public resetToDraft(options: { creditNoteId: number }): Promise<CreditNote> {\n return this.http.request<CreditNote>({\n method: 'PUT',\n path: `/CreditNote/${options.creditNoteId}/resetToDraft`,\n });\n }\n\n /** Retrieves credit note positions via `GET /CreditNotePos`. */\n public listPositions(\n options: ListCreditNotePositionsOptions = {},\n ): Promise<CreditNotePosition[]> {\n const { creditNoteId, limit, offset, embed } = options;\n return this.http.request<CreditNotePosition[]>({\n method: 'GET',\n path: '/CreditNotePos',\n query: {\n 'creditNote[id]': creditNoteId,\n 'creditNote[objectName]':\n creditNoteId === undefined ? undefined : 'CreditNote',\n limit,\n offset,\n embed,\n },\n });\n }\n}\n\nfunction toCreditNoteBody(\n creditNote: CreditNoteInput,\n): Record<string, unknown> {\n return {\n objectName: 'CreditNote',\n mapAll: true,\n creditNoteNumber: creditNote.creditNoteNumber,\n creditNoteDate: toVoucherDate(creditNote.creditNoteDate),\n contact: { id: creditNote.contactId, objectName: 'Contact' },\n status: creditNote.status,\n header: creditNote.header,\n bookingCategory: creditNote.bookingCategory,\n contactPerson: { id: creditNote.contactPersonId, objectName: 'SevUser' },\n taxRule: { id: creditNote.taxRuleId, objectName: 'TaxRule' },\n taxRate: creditNote.taxRate,\n taxText: creditNote.taxText,\n currency: creditNote.currency,\n deliveryDate: toVoucherDate(creditNote.deliveryDate),\n addressCountry: toRef(creditNote.addressCountryId, 'StaticCountry'),\n headText: creditNote.headText,\n footText: creditNote.footText,\n address: creditNote.address,\n smallSettlement: creditNote.smallSettlement,\n showNet: creditNote.showNet,\n customerInternalNote: creditNote.customerInternalNote,\n sendDate: toOptionalDate(creditNote.sendDate),\n sendType: creditNote.sendType,\n };\n}\n\nfunction toCreditNotePositionBody(\n position: CreditNotePositionInput,\n): Record<string, unknown> {\n return {\n objectName: 'CreditNotePos',\n mapAll: true,\n unity: { id: position.unityId, objectName: 'Unity' },\n quantity: position.quantity,\n taxRate: position.taxRate,\n name: position.name,\n price: position.price,\n text: position.text,\n part: toRef(position.partId, 'Part'),\n positionNumber: position.positionNumber,\n discount: position.discount,\n optional: position.optional,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n\nfunction toOptionalDate(\n value: DateInput | undefined,\n): string | number | undefined {\n return value === undefined ? undefined : toVoucherDate(value);\n}\n","import { toIsoDateTime, toVoucherDate } from '../dates';\nimport type { Query } from '../http-client';\nimport type { DateInput } from '../types';\nimport { BaseResource } from './base';\n\n/** A file generated by an export, returned inside the response envelope. */\nexport interface ExportFile {\n filename: string;\n mimetype: string;\n base64Encoded: boolean;\n /** The file content, base64 encoded when `base64Encoded` is `true`. */\n content: string;\n}\n\n/** Progress of an export job. The job is finished once `current` reaches `total`. */\nexport interface ExportProgress {\n current: number;\n total: number;\n}\n\nexport interface ExportJobDownloadInfo {\n filename: string;\n /** Download url of the export file. */\n link: string;\n /** Expiry date of the download url. */\n linkExpireDate: string;\n}\n\nexport interface ExportConfigOptions {\n sevClientId: number;\n accountantNumber: number;\n accountantClientNumber: number;\n /** Begin of the accounting year, sent as Unix timestamp. */\n accountingYearBegin: DateInput;\n}\n\nexport interface ExportDatevCsvJobOptions {\n /** Sent as Unix timestamp. */\n startDate: DateInput;\n /** Sent as Unix timestamp. */\n endDate: DateInput;\n /**\n * The models to include, given as a string of letters: `E` (earnings),\n * `X` (expenditure), `T` (transactions), `C` (cash register) and\n * `D` (assets), for example `EXTCD`.\n */\n scope: string;\n /** Includes only documents paid between `startDate` and `endDate`. Defaults to `false`. */\n exportByPaydate?: boolean;\n /** Defaults to `true`. */\n includeEnshrined?: boolean;\n /** Enshrines all exported models. Defaults to `false`. */\n enshrineDocuments?: boolean;\n /** Defaults to `false`. */\n includeDocumentImages?: boolean;\n}\n\nexport interface ExportDatevXmlJobOptions {\n /** Sent as Unix timestamp. */\n startDate: DateInput;\n /** Sent as Unix timestamp. */\n endDate: DateInput;\n /**\n * The document types to include, given as a string of letters:\n * `E` (receipts, outgoing invoices and credit notes) and\n * `X` (expenditure documents), for example `EX`.\n */\n scope: string;\n /** Includes only documents paid between `startDate` and `endDate`. Defaults to `false`. */\n exportByPaydate?: boolean;\n /** Defaults to `true`. */\n includeEnshrined?: boolean;\n /** Defaults to `true`. */\n includeExportedDocuments?: boolean;\n /** Includes an XML file with the data of each document. Defaults to `true`. */\n includeDocumentXml?: boolean;\n}\n\nexport type ExportInvoiceType = 'RE' | 'SR' | 'TR' | 'AR' | 'ER' | 'WKR' | 'MA';\n\n/** Filters shared by all document exports. */\nexport interface ExportDocumentFilter {\n startDate?: DateInput;\n endDate?: DateInput;\n contactId?: number;\n startAmount?: number;\n endAmount?: number;\n}\n\nexport interface ExportInvoiceFilter extends ExportDocumentFilter {\n /**\n * `RE` (invoice), `SR` (cancellation invoice), `TR` (partial invoice),\n * `AR` (down payment invoice), `ER` (final invoice),\n * `WKR` (recurring invoice) and `MA` (dunning).\n */\n invoiceType?: ExportInvoiceType[];\n}\n\nexport interface ExportVoucherFilter extends ExportDocumentFilter {\n startPayDate?: DateInput;\n endPayDate?: DateInput;\n}\n\nexport interface ExportTransactionFilter {\n paymtPurpose?: string;\n /** The name of the payee or payer. */\n name?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n startAmount?: number;\n endAmount?: number;\n checkAccountId?: number;\n}\n\nexport interface ExportContactFilter {\n zip?: number;\n city?: string;\n countryId?: number;\n /** Exports only organisations. */\n depth?: boolean;\n /** Exports only people. */\n onlyPeople?: boolean;\n}\n\nexport interface ExportInvoicesOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportInvoiceFilter;\n}\n\nexport interface ExportCreditNotesOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportDocumentFilter;\n}\n\nexport interface ExportVouchersOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportVoucherFilter;\n}\n\nexport interface ExportTransactionsOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportTransactionFilter;\n}\n\nexport interface ExportContactsOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportContactFilter;\n}\n\n/** A value of a `sevQuery` parameter before it is flattened into bracket keys. */\nexport type ExportSevQueryValue =\n string | number | boolean | ExportSevQueryValue[] | ExportSevQueryObject;\n\nexport interface ExportSevQueryObject {\n [key: string]: ExportSevQueryValue | undefined;\n}\n\nexport interface ExportSevQueryOptions {\n modelName: string;\n limit?: number;\n filter?: ExportSevQueryObject;\n}\n\nexport class ExportsResource extends BaseResource {\n /**\n * Updates the export config via `PUT /SevClient/{sevClientId}/updateExportConfig`.\n *\n * The accounting year has to be set once before any DATEV export can be run.\n */\n public async updateExportConfig(options: ExportConfigOptions): Promise<void> {\n const {\n sevClientId,\n accountantNumber,\n accountantClientNumber,\n accountingYearBegin,\n } = options;\n await this.http.request<void>({\n method: 'PUT',\n path: `/SevClient/${sevClientId}/updateExportConfig`,\n body: {\n accountantNumber,\n accountantClientNumber,\n accountingYearBegin: toVoucherDate(accountingYearBegin),\n },\n });\n }\n\n /** Starts a DATEV CSV zip export via `GET /Export/createDatevCsvZipExportJob` and returns the job id. */\n public createDatevCsvZipExportJob(\n options: ExportDatevCsvJobOptions,\n ): Promise<string> {\n const { startDate, endDate, ...rest } = options;\n return this.http.request<string>({\n method: 'GET',\n path: '/Export/createDatevCsvZipExportJob',\n query: {\n startDate: toVoucherDate(startDate),\n endDate: toVoucherDate(endDate),\n ...rest,\n },\n });\n }\n\n /** Starts a DATEV XML zip export via `GET /Export/createDatevXmlZipExportJob` and returns the job id. */\n public createDatevXmlZipExportJob(\n options: ExportDatevXmlJobOptions,\n ): Promise<string> {\n const { startDate, endDate, ...rest } = options;\n return this.http.request<string>({\n method: 'GET',\n path: '/Export/createDatevXmlZipExportJob',\n query: {\n startDate: toVoucherDate(startDate),\n endDate: toVoucherDate(endDate),\n ...rest,\n },\n });\n }\n\n /** Generates the hash of an export job via `GET /Progress/generateDownloadHash`. */\n public generateDownloadHash(options: {\n jobId: string;\n }): Promise<ExportProgress[]> {\n return this.http.request<ExportProgress[]>({\n method: 'GET',\n path: '/Progress/generateDownloadHash',\n query: { jobId: options.jobId },\n });\n }\n\n /** Retrieves the progress of an export via `GET /Progress/getProgress`. */\n public getProgress(options: { hash: string }): Promise<ExportProgress[]> {\n return this.http.request<ExportProgress[]>({\n method: 'GET',\n path: '/Progress/getProgress',\n query: { hash: options.hash },\n });\n }\n\n /** Retrieves the download url of a finished export job via `GET /ExportJob/jobDownloadInfo`. */\n public getJobDownloadInfo(options: {\n jobId: string;\n }): Promise<ExportJobDownloadInfo[]> {\n return this.http.request<ExportJobDownloadInfo[]>({\n method: 'GET',\n path: '/ExportJob/jobDownloadInfo',\n query: { jobId: options.jobId },\n });\n }\n\n /** Exports invoices as CSV via `GET /Export/invoiceCsv`. */\n public exportInvoicesCsv(\n options: ExportInvoicesOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/invoiceCsv', options, {\n modelName: 'Invoice',\n limit: options.limit,\n filter: toExportInvoiceFilter(options.filter),\n });\n }\n\n /** Exports invoices as zip via `GET /Export/invoiceZip`. */\n public exportInvoicesZip(\n options: ExportInvoicesOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/invoiceZip', options, {\n modelName: 'Invoice',\n limit: options.limit,\n filter: toExportInvoiceFilter(options.filter),\n });\n }\n\n /** Exports credit notes as CSV via `GET /Export/creditNoteCsv`. */\n public exportCreditNotesCsv(\n options: ExportCreditNotesOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/creditNoteCsv', options, {\n modelName: 'CreditNote',\n limit: options.limit,\n filter: toExportDocumentFilter(options.filter),\n });\n }\n\n /** Exports vouchers as CSV via `GET /Export/voucherListCsv`. */\n public exportVouchersCsv(\n options: ExportVouchersOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/voucherListCsv', options, {\n modelName: 'Voucher',\n limit: options.limit,\n filter: toExportVoucherFilter(options.filter),\n });\n }\n\n /** Exports vouchers as zip via `GET /Export/voucherZip`. */\n public exportVouchersZip(\n options: ExportVouchersOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/voucherZip', options, {\n modelName: 'Voucher',\n limit: options.limit,\n filter: toExportVoucherFilter(options.filter),\n });\n }\n\n /** Exports transactions as CSV via `GET /Export/transactionsCsv`. */\n public exportTransactionsCsv(\n options: ExportTransactionsOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/transactionsCsv', options, {\n modelName: 'CheckAccountTransaction',\n limit: options.limit,\n filter: toExportTransactionFilter(options.filter),\n });\n }\n\n /** Exports contacts as CSV via `GET /Export/contactListCsv`. */\n public exportContactsCsv(\n options: ExportContactsOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/contactListCsv', options, {\n modelName: 'Contact',\n limit: options.limit,\n filter: toExportContactFilter(options.filter),\n });\n }\n\n private requestExport(\n path: string,\n options: { download?: boolean },\n sevQuery: ExportSevQueryOptions,\n ): Promise<ExportFile> {\n return this.http.request<ExportFile>({\n method: 'GET',\n path,\n query: {\n download: options.download,\n ...toExportSevQueryParams(sevQuery),\n },\n });\n }\n}\n\n/**\n * Flattens a `sevQuery` object into the deep bracket query parameters expected\n * by the export and report endpoints, e.g. `sevQuery[filter][startDate]`.\n */\nexport function toExportSevQueryParams(sevQuery: ExportSevQueryOptions): Query {\n const query: Query = {};\n flattenSevQueryValue(\n 'sevQuery',\n { objectName: 'SevQuery', ...sevQuery },\n query,\n );\n return query;\n}\n\n/** Maps a document export filter to its `sevQuery` representation. */\nexport function toExportDocumentFilter(\n filter: ExportDocumentFilter = {},\n): ExportSevQueryObject {\n return {\n startDate: toOptionalIsoDateTime(filter.startDate),\n endDate: toOptionalIsoDateTime(filter.endDate),\n contact: toRef(filter.contactId, 'Contact'),\n startAmount: filter.startAmount,\n endAmount: filter.endAmount,\n };\n}\n\n/** Maps an invoice export filter to its `sevQuery` representation. */\nexport function toExportInvoiceFilter(\n filter: ExportInvoiceFilter = {},\n): ExportSevQueryObject {\n return {\n ...toExportDocumentFilter(filter),\n invoiceType: filter.invoiceType,\n };\n}\n\n/** Maps a voucher export filter to its `sevQuery` representation. */\nexport function toExportVoucherFilter(\n filter: ExportVoucherFilter = {},\n): ExportSevQueryObject {\n return {\n ...toExportDocumentFilter(filter),\n startPayDate: toOptionalIsoDateTime(filter.startPayDate),\n endPayDate: toOptionalIsoDateTime(filter.endPayDate),\n };\n}\n\n/** Maps a contact export filter to its `sevQuery` representation. */\nexport function toExportContactFilter(\n filter: ExportContactFilter = {},\n): ExportSevQueryObject {\n return {\n zip: filter.zip,\n city: filter.city,\n country: toRef(filter.countryId, 'StaticCountry'),\n depth: filter.depth,\n onlyPeople: filter.onlyPeople,\n };\n}\n\nfunction toExportTransactionFilter(\n filter: ExportTransactionFilter = {},\n): ExportSevQueryObject {\n return {\n paymtPurpose: filter.paymtPurpose,\n name: filter.name,\n startDate: toOptionalIsoDateTime(filter.startDate),\n endDate: toOptionalIsoDateTime(filter.endDate),\n startAmount: filter.startAmount,\n endAmount: filter.endAmount,\n checkAccount: toRef(filter.checkAccountId, 'CheckAccount'),\n };\n}\n\nfunction flattenSevQueryValue(\n key: string,\n value: ExportSevQueryValue,\n query: Query,\n): void {\n if (Array.isArray(value)) {\n value.forEach((item, index) =>\n flattenSevQueryValue(`${key}[${index}]`, item, query),\n );\n return;\n }\n if (typeof value === 'object') {\n for (const [nestedKey, nestedValue] of Object.entries(value)) {\n if (nestedValue !== undefined) {\n flattenSevQueryValue(`${key}[${nestedKey}]`, nestedValue, query);\n }\n }\n return;\n }\n query[key] = value;\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ExportSevQueryObject | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n\nfunction toOptionalIsoDateTime(\n value: DateInput | undefined,\n): string | undefined {\n return value === undefined ? undefined : toIsoDateTime(value);\n}\n","import { toIsoDateTime, toVoucherDate } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type {\n DateInput,\n ListOptions,\n ModelRef,\n ModelRefResponse,\n} from '../types';\nimport { BaseResource } from './base';\n\n/**\n * Status of an invoice.\n *\n * - `50` deactivated recurring invoice, only relevant for recurring invoices\n * - `100` draft, not sent to the end-customer yet and still changeable\n * - `200` open if the pay date is not exceeded, due if it is\n * - `750` partially paid, only set for invoices partially paid after\n * release 4.181 (June 13, 2024). Older ones stay at `200`, use\n * `isPartiallyPaid` for them.\n * - `1000` paid\n */\nexport type InvoiceStatus = 50 | 100 | 200 | 750 | 1000;\n\n/**\n * Type of an invoice.\n *\n * - `RE` normal invoice\n * - `WKR` recurring invoice\n * - `SR` cancellation invoice\n * - `MA` invoice reminder\n * - `TR` partial invoice\n * - `AR` advance invoice\n * - `ER` final invoice\n */\nexport type InvoiceType = 'RE' | 'WKR' | 'SR' | 'MA' | 'TR' | 'AR' | 'ER';\n\n/** `VPR` printed, `VPDF` downloaded, `VM` mailed, `VP` postal. */\nexport type InvoiceSendType = 'VPR' | 'VPDF' | 'VM' | 'VP';\n\nexport type InvoiceBookingType =\n 'FULL_PAYMENT' | 'N' | 'CB' | 'O' | 'OF' | 'MTC';\n\nexport interface InvoiceInput {\n /**\n * `100` for a draft invoice. Invoices can only be created as drafts, the\n * status is advanced by the dedicated endpoints.\n */\n status: 100;\n invoiceDate: DateInput;\n contactId: number;\n /** The sevdesk user acting as contact person for this invoice. */\n contactPersonId: number;\n invoiceType: InvoiceType;\n /** Currency code according to ISO-4217, for example `EUR`. */\n currency: string;\n /** Defines the vat regulation, for example `1` for \"Umsatzsteuerpflichtige Umsätze\". */\n taxRuleId: number;\n /** Text describing the chosen vat regulation, for example `Umsatzsteuer 19%`. */\n taxText: string;\n invoiceNumber?: string;\n /** Usually consists of a prefix and the invoice number. */\n header?: string;\n headText?: string;\n footText?: string;\n /** The complete recipient address, line breaks are kept on the pdf. */\n address?: string;\n /** Can be omitted when the complete address is given in `address`. */\n addressCountryId?: number;\n /** Percentage the end-customer gets when paying early. Defaults to `0`. */\n discount?: number;\n /** Days the end-customer has to pay the invoice. */\n timeToPay?: number;\n deliveryDate?: DateInput;\n deliveryDateUntil?: DateInput;\n payDate?: DateInput;\n paymentMethodId?: number;\n /** `true` if the sevdesk account falls under the small entrepreneur scheme. */\n smallSettlement?: boolean;\n /** `true` if the position prices are net values, `false` if they are gross. */\n showNet?: boolean;\n /** Shown as \"Referenz/Bestellnummer\" in sevdesk. */\n customerInternalNote?: string;\n propertyIsEInvoice?: boolean;\n}\n\nexport interface InvoicePositionInput {\n quantity: number;\n taxRate: number;\n /** The unit in which the position is measured. */\n unityId: number;\n name?: string;\n /** Net or gross price of one unit, depending on the invoice `showNet`. */\n price?: number;\n /** Part from the sevdesk inventory used in the position. */\n partId?: number;\n text?: string;\n /** Starts at zero and orders the positions of an invoice. */\n positionNumber?: number;\n discount?: number;\n}\n\nexport interface SaveInvoiceOptions {\n invoice: InvoiceInput;\n positions: InvoicePositionInput[];\n /** Takes the first address of the contact as the invoice address. */\n takeDefaultAddress?: boolean;\n}\n\nexport interface ListInvoicesOptions extends ListOptions {\n status?: InvoiceStatus;\n invoiceNumber?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n contactId?: number;\n embed?: string[];\n}\n\nexport interface CreateInvoiceFromOrderOptions {\n orderId: number;\n /** Defines how `amount` is interpreted. */\n type?: 'percentage' | 'net' | 'gross';\n amount?: number;\n /** `RE` final invoice, `TR` partial invoice, `AR` advance invoice. */\n partialType?: 'RE' | 'TR' | 'AR';\n}\n\nexport interface SendInvoiceViaEmailOptions {\n invoiceId: number;\n toEmail: string;\n subject: string;\n /** Can contain html. */\n text: string;\n /** Sends a copy of the email to yourself. */\n copy?: boolean;\n /** Ids of existing sevdesk documents, separated by `,`. */\n additionalAttachments?: string;\n /** Mail addresses separated by `,`. */\n ccEmail?: string;\n /** Mail addresses separated by `,`. */\n bccEmail?: string;\n /** Attaches the xml of the e-invoice instead of the pdf. */\n sendXml?: boolean;\n}\n\nexport interface SendInvoiceByOptions {\n invoiceId: number;\n sendType: InvoiceSendType;\n /** Creates a draft for internal use without changing the status. */\n sendDraft?: boolean;\n}\n\nexport interface BookInvoiceOptions {\n invoiceId: number;\n /** Can also be a partial amount. */\n amount: number;\n date: DateInput;\n type: InvoiceBookingType;\n checkAccountId: number;\n /**\n * Required for online check accounts. Must be omitted for offline check\n * accounts and cash registers, where the transaction is created automatically.\n */\n checkAccountTransactionId?: number;\n createFeed?: boolean;\n}\n\nexport interface Invoice {\n id: string;\n objectName: string;\n invoiceNumber: string | null;\n contact: ModelRefResponse | null;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n invoiceDate: string;\n header: string | null;\n headText: string | null;\n footText: string | null;\n timeToPay: string | null;\n discountTime: string | null;\n discount: string;\n address: string | null;\n addressCountry: ModelRefResponse | null;\n payDate: string | null;\n createUser: ModelRefResponse;\n deliveryDate: string | null;\n deliveryDateUntil: string | null;\n status: string;\n smallSettlement: boolean;\n contactPerson: ModelRefResponse;\n taxRate: string;\n taxRule: ModelRefResponse;\n taxText: string;\n dunningLevel: string | null;\n paymentMethod: ModelRefResponse | null;\n costCentre: ModelRefResponse | null;\n sendDate: string | null;\n origin: ModelRefResponse | null;\n invoiceType: string;\n accountIntervall: string | null;\n accountNextInvoice: string | null;\n reminderTotal: string | null;\n reminderDebit: string | null;\n reminderDeadline: string | null;\n reminderCharge: string | null;\n currency: string;\n sumNet: string;\n sumTax: string;\n sumGross: string;\n sumDiscounts: string;\n sumNetForeignCurrency: string;\n sumTaxForeignCurrency: string;\n sumGrossForeignCurrency: string;\n sumDiscountsForeignCurrency: string;\n sumNetAccounting: string;\n sumTaxAccounting: string;\n sumGrossAccounting: string;\n paidAmount: number | null;\n customerInternalNote: string | null;\n showNet: boolean;\n enshrined: string | null;\n sendType: string | null;\n}\n\nexport interface InvoicePosition {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n invoice: ModelRefResponse;\n part: ModelRefResponse | null;\n quantity: string;\n price: string | null;\n name: string | null;\n unity: ModelRefResponse;\n positionNumber: string;\n text: string | null;\n discount: string | null;\n taxRate: string;\n sumDiscount: string | null;\n sumNetAccounting: string;\n sumTaxAccounting: string;\n sumGrossAccounting: string;\n priceNet: string;\n priceGross: string;\n priceTax: string;\n}\n\nexport interface SaveInvoiceResult {\n invoice: Invoice;\n positions: InvoicePosition[];\n}\n\nexport interface RenderInvoiceResult {\n thumbs: unknown[];\n pages: number;\n /** Internal id of the rendered document. */\n docId: string;\n parameters: InvoiceRenderParameter[];\n}\n\nexport interface InvoiceRenderParameter {\n key: string;\n name: string;\n values: { name: string; translationCade: string; value: string }[];\n visible: boolean;\n value: string;\n}\n\nexport interface InvoicePdf {\n filename: string;\n mimeType: string;\n base64encoded: boolean;\n /** The base64 encoded pdf document. */\n content: string;\n}\n\nexport interface InvoiceEmail {\n id: string;\n objectName: string;\n create: string;\n update: string;\n /** The invoice the email was sent for. */\n object: Invoice;\n from: string;\n to: string;\n subject: string;\n text: string | null;\n sevClient: ModelRefResponse;\n}\n\nexport interface BookInvoiceResult {\n id: string;\n objectName: string;\n additionalInformation: string | null;\n create: string;\n invoice: ModelRefResponse;\n fromStatus: string;\n toStatus: string;\n /** Spelled `ammountPayed` by the sevdesk API. */\n ammountPayed: string;\n bookingDate: string;\n sevClient: ModelRefResponse;\n}\n\nexport class InvoicesResource extends BaseResource {\n /** Retrieves invoices via `GET /Invoice`. */\n public list(options: ListInvoicesOptions = {}): Promise<Invoice[]> {\n const {\n status,\n invoiceNumber,\n startDate,\n endDate,\n contactId,\n limit,\n offset,\n embed,\n } = options;\n return this.http.request<Invoice[]>({\n method: 'GET',\n path: '/Invoice',\n query: {\n status,\n invoiceNumber,\n startDate: toOptionalInvoiceDate(startDate),\n endDate: toOptionalInvoiceDate(endDate),\n 'contact[id]': contactId,\n 'contact[objectName]': contactId === undefined ? undefined : 'Contact',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single invoice via `GET /Invoice/{invoiceId}`. */\n public async get(options: {\n invoiceId: number;\n embed?: string[];\n }): Promise<Invoice> {\n const invoices = await this.http.request<Invoice[]>({\n method: 'GET',\n path: `/Invoice/${options.invoiceId}`,\n query: { embed: options.embed },\n });\n const invoice = invoices[0];\n if (!invoice) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return invoice;\n }\n\n /**\n * Creates or updates an invoice with its positions via\n * `POST /Invoice/Factory/saveInvoice`.\n *\n * Invoices can only be created as drafts. Use `sendViaEmail`, `sendBy` and\n * `book` to advance the status afterwards.\n */\n public async save(options: SaveInvoiceOptions): Promise<SaveInvoiceResult> {\n const { invoice, positions, takeDefaultAddress } = options;\n const result = await this.http.request<{\n invoice: Invoice;\n invoicePos: InvoicePosition[];\n }>({\n method: 'POST',\n path: '/Invoice/Factory/saveInvoice',\n body: {\n invoice: toInvoiceBody(invoice),\n invoicePosSave: positions.map(toInvoicePositionBody),\n invoicePosDelete: null,\n discountSave: null,\n discountDelete: null,\n ...(takeDefaultAddress === undefined ? {} : { takeDefaultAddress }),\n },\n });\n return { invoice: result.invoice, positions: result.invoicePos };\n }\n\n /** Creates an invoice from an order via `POST /Invoice/Factory/createInvoiceFromOrder`. */\n public createFromOrder(\n options: CreateInvoiceFromOrderOptions,\n ): Promise<Invoice> {\n const { orderId, type, amount, partialType } = options;\n return this.http.request<Invoice>({\n method: 'POST',\n path: '/Invoice/Factory/createInvoiceFromOrder',\n body: {\n order: { id: orderId, objectName: 'Order' },\n type,\n amount,\n partialType,\n },\n });\n }\n\n /** Creates a reminder for an invoice via `POST /Invoice/Factory/createInvoiceReminder`. */\n public createReminder(options: { invoiceId: number }): Promise<Invoice> {\n return this.http.request<Invoice>({\n method: 'POST',\n path: '/Invoice/Factory/createInvoiceReminder',\n body: {\n invoice: { id: options.invoiceId, objectName: 'Invoice' },\n },\n });\n }\n\n /** Retrieves the positions of an invoice via `GET /Invoice/{invoiceId}/getPositions`. */\n public getPositions(\n options: { invoiceId: number; embed?: string[] } & ListOptions,\n ): Promise<InvoicePosition[]> {\n const { invoiceId, limit, offset, embed } = options;\n return this.http.request<InvoicePosition[]>({\n method: 'GET',\n path: `/Invoice/${invoiceId}/getPositions`,\n query: { limit, offset, embed },\n });\n }\n\n /**\n * Checks if an invoice is partially paid via\n * `GET /Invoice/{invoiceId}/getIsPartiallyPaid`.\n *\n * Fully paid invoices are regarded as not partially paid.\n */\n public isPartiallyPaid(options: { invoiceId: number }): Promise<boolean> {\n return this.http.request<boolean>({\n method: 'GET',\n path: `/Invoice/${options.invoiceId}/getIsPartiallyPaid`,\n });\n }\n\n /**\n * Cancels an invoice via `POST /Invoice/{invoiceId}/cancelInvoice` and\n * returns the created cancellation invoice.\n */\n public cancel(options: { invoiceId: number }): Promise<Invoice> {\n return this.http.request<Invoice>({\n method: 'POST',\n path: `/Invoice/${options.invoiceId}/cancelInvoice`,\n });\n }\n\n /** Renders the pdf document of an invoice via `POST /Invoice/{invoiceId}/render`. */\n public render(options: {\n invoiceId: number;\n forceReload?: boolean;\n }): Promise<RenderInvoiceResult> {\n return this.http.request<RenderInvoiceResult>({\n method: 'POST',\n path: `/Invoice/${options.invoiceId}/render`,\n body: { forceReload: options.forceReload },\n });\n }\n\n /**\n * Sends an invoice to the end-customer via\n * `POST /Invoice/{invoiceId}/sendViaEmail`. This marks the invoice as sent.\n */\n public sendViaEmail(\n options: SendInvoiceViaEmailOptions,\n ): Promise<InvoiceEmail> {\n const { invoiceId, ...body } = options;\n return this.http.request<InvoiceEmail>({\n method: 'POST',\n path: `/Invoice/${invoiceId}/sendViaEmail`,\n body,\n });\n }\n\n /** Retrieves the pdf document of an invoice via `GET /Invoice/{invoiceId}/getPdf`. */\n public getPdf(options: {\n invoiceId: number;\n /** Prevents marking the invoice as sent. */\n preventSendBy?: boolean;\n }): Promise<InvoicePdf> {\n return this.http.request<InvoicePdf>({\n method: 'GET',\n path: `/Invoice/${options.invoiceId}/getPdf`,\n query: { preventSendBy: options.preventSendBy },\n });\n }\n\n /** Retrieves the xml of an e-invoice via `GET /Invoice/{invoiceId}/getXml`. */\n public getXml(options: { invoiceId: number }): Promise<string> {\n return this.http.request<string>({\n method: 'GET',\n path: `/Invoice/${options.invoiceId}/getXml`,\n });\n }\n\n /** Marks an invoice as sent via `PUT /Invoice/{invoiceId}/sendBy`. */\n public sendBy(options: SendInvoiceByOptions): Promise<Invoice> {\n const { invoiceId, sendType, sendDraft } = options;\n return this.http.request<Invoice>({\n method: 'PUT',\n path: `/Invoice/${invoiceId}/sendBy`,\n body: { sendType, sendDraft },\n });\n }\n\n /** Books an amount on an invoice via `PUT /Invoice/{invoiceId}/bookAmount`. */\n public book(options: BookInvoiceOptions): Promise<BookInvoiceResult> {\n const {\n invoiceId,\n amount,\n date,\n type,\n checkAccountId,\n checkAccountTransactionId,\n createFeed,\n } = options;\n return this.http.request<BookInvoiceResult>({\n method: 'PUT',\n path: `/Invoice/${invoiceId}/bookAmount`,\n body: {\n amount,\n date: toIsoDateTime(date),\n type,\n checkAccount: { id: checkAccountId, objectName: 'CheckAccount' },\n checkAccountTransaction: toRef(\n checkAccountTransactionId,\n 'CheckAccountTransaction',\n ),\n createFeed,\n },\n });\n }\n\n /**\n * Enshrines an invoice via `PUT /Invoice/{invoiceId}/enshrine`.\n *\n * Requires a status of at least `200` and cannot be undone.\n */\n public async enshrine(options: { invoiceId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'PUT',\n path: `/Invoice/${options.invoiceId}/enshrine`,\n });\n }\n\n /**\n * Resets the invoice status to open via `PUT /Invoice/{invoiceId}/resetToOpen`.\n *\n * Linked transactions are unlinked. Not possible for enshrined invoices.\n */\n public resetToOpen(options: { invoiceId: number }): Promise<Invoice> {\n return this.http.request<Invoice>({\n method: 'PUT',\n path: `/Invoice/${options.invoiceId}/resetToOpen`,\n });\n }\n\n /**\n * Resets the invoice status to draft via `PUT /Invoice/{invoiceId}/resetToDraft`.\n *\n * Only possible for invoices with the status `200`.\n */\n public resetToDraft(options: { invoiceId: number }): Promise<Invoice> {\n return this.http.request<Invoice>({\n method: 'PUT',\n path: `/Invoice/${options.invoiceId}/resetToDraft`,\n });\n }\n}\n\nfunction toInvoiceBody(invoice: InvoiceInput): Record<string, unknown> {\n return {\n objectName: 'Invoice',\n mapAll: true,\n invoiceNumber: invoice.invoiceNumber,\n contact: { id: invoice.contactId, objectName: 'Contact' },\n contactPerson: { id: invoice.contactPersonId, objectName: 'SevUser' },\n invoiceDate: toVoucherDate(invoice.invoiceDate),\n header: invoice.header,\n headText: invoice.headText,\n footText: invoice.footText,\n timeToPay: invoice.timeToPay,\n discount: invoice.discount ?? 0,\n address: invoice.address,\n addressCountry: toRef(invoice.addressCountryId, 'StaticCountry'),\n payDate: toOptionalInvoiceDate(invoice.payDate),\n deliveryDate: toOptionalInvoiceDate(invoice.deliveryDate),\n deliveryDateUntil: toOptionalInvoiceDate(invoice.deliveryDateUntil),\n status: invoice.status,\n smallSettlement: invoice.smallSettlement,\n taxRate: 0,\n taxRule: { id: invoice.taxRuleId, objectName: 'TaxRule' },\n taxText: invoice.taxText,\n paymentMethod: toRef(invoice.paymentMethodId, 'PaymentMethod'),\n invoiceType: invoice.invoiceType,\n currency: invoice.currency,\n showNet: invoice.showNet,\n customerInternalNote: invoice.customerInternalNote,\n propertyIsEInvoice: invoice.propertyIsEInvoice,\n };\n}\n\nfunction toInvoicePositionBody(\n position: InvoicePositionInput,\n): Record<string, unknown> {\n return {\n objectName: 'InvoicePos',\n mapAll: true,\n invoice: null,\n part: toRef(position.partId, 'Part'),\n quantity: position.quantity,\n price: position.price,\n name: position.name,\n unity: { id: position.unityId, objectName: 'Unity' },\n positionNumber: position.positionNumber,\n text: position.text,\n discount: position.discount,\n taxRate: position.taxRate,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n\nfunction toOptionalInvoiceDate(\n value: DateInput | undefined,\n): string | number | undefined {\n return value === undefined ? undefined : toVoucherDate(value);\n}\n","import { toVoucherDate } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type {\n DateInput,\n ListOptions,\n ModelRef,\n ModelRefResponse,\n} from '../types';\nimport { BaseResource } from './base';\n\n/**\n * Status of an order.\n *\n * - `100` draft\n * - `200` delivered\n * - `300` rejected / cancelled\n * - `500` accepted\n * - `750` partially calculated\n * - `1000` calculated\n */\nexport type OrderStatus = 100 | 200 | 300 | 500 | 750 | 1000;\n\n/**\n * Type of an order: `AN` estimate / proposal, `AB` order confirmation,\n * `LI` delivery note.\n */\nexport type OrderType = 'AN' | 'AB' | 'LI';\n\n/**\n * Way in which an order was sent to the end-customer: `VPR` printed,\n * `VP` postal, `VM` mailed, `VPDF` downloaded pdf.\n */\nexport type OrderSendType = 'VPR' | 'VP' | 'VM' | 'VPDF';\n\nexport interface OrderInput {\n orderNumber: string;\n orderDate: DateInput;\n contactId: number;\n status: OrderStatus;\n orderType: OrderType;\n /** Usually consists of a prefix and the order number. */\n header: string;\n /** Version of the order, used for multiple drafts. Starts at `0`. */\n version: number;\n addressCountryId: number;\n /** The sevdesk user acting as the contact person. */\n contactPersonId: number;\n /** Defines the vat regulation, for example `1` for \"Umsatzsteuerpflichtige Umsätze\". */\n taxRuleId: number;\n /** Not used anymore, the tax rate of the positions is used instead. */\n taxRate: number;\n /** Text describing the vat regulation, for example `Umsatzsteuer 19%`. */\n taxText: string;\n /** Currency code according to ISO-4217. */\n currency: string;\n headText?: string;\n footText?: string;\n deliveryTerms?: string;\n paymentTerms?: string;\n smallSettlement?: boolean;\n /** `true` if the position prices are net, `false` if they are gross. */\n showNet?: boolean;\n /** Complete address of the recipient. Line breaks are kept in the pdf. */\n address?: string;\n customerInternalNote?: string;\n sendDate?: DateInput;\n sendType?: OrderSendType;\n}\n\nexport interface OrderPositionInput {\n unityId: number;\n quantity: number;\n taxRate: number;\n name?: string;\n /** Price of one unit. Is either net or gross, depending on `showNet`. */\n price?: number;\n text?: string;\n partId?: number;\n /** Starts at zero and is incremented for every further position. */\n positionNumber?: number;\n discount?: number;\n optional?: boolean;\n}\n\nexport interface SaveOrderOptions {\n order: OrderInput;\n positions: OrderPositionInput[];\n}\n\nexport interface ListOrdersOptions extends ListOptions {\n status?: OrderStatus;\n orderNumber?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n contactId?: number;\n embed?: string[];\n}\n\nexport interface UpdateOrderOptions {\n orderId: number;\n orderNumber?: string;\n orderDate?: DateInput;\n status?: OrderStatus;\n header?: string;\n headText?: string;\n footText?: string;\n deliveryTerms?: string;\n paymentTerms?: string;\n address?: string;\n customerInternalNote?: string;\n version?: number;\n}\n\nexport interface GetOrderRelatedObjectsOptions {\n orderId: number;\n /** Include the order itself in the result. */\n includeItself?: boolean;\n sortByType?: boolean;\n embed?: string[];\n}\n\nexport interface SendOrderViaEmailOptions {\n orderId: number;\n toEmail: string;\n subject: string;\n /** Can contain html. */\n text: string;\n /** Send a copy of the email to yourself. */\n copy?: boolean;\n /** Ids of existing documents in your sevdesk account, separated by `,`. */\n additionalAttachments?: string;\n /** Mail addresses to be put as cc, separated by `,`. */\n ccEmail?: string;\n /** Mail addresses to be put as bcc, separated by `,`. */\n bccEmail?: string;\n}\n\nexport interface SendOrderByOptions {\n orderId: number;\n sendType: OrderSendType;\n /**\n * Creates a draft for internal use. The status of the order is not changed.\n */\n sendDraft: boolean;\n}\n\nexport interface ListOrderPositionsOptions extends ListOptions {\n orderId?: number;\n embed?: string[];\n}\n\nexport interface UpdateOrderPositionOptions {\n orderPosId: number;\n quantity?: number;\n price?: number;\n priceTax?: number;\n priceGross?: number;\n name?: string;\n text?: string;\n positionNumber?: number;\n discount?: number;\n optional?: boolean;\n taxRate?: number;\n unityId?: number;\n partId?: number;\n}\n\nexport interface Order {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n createUser: ModelRefResponse;\n orderNumber: string;\n contact: ModelRefResponse;\n orderDate: string;\n status: string;\n header: string;\n headText: string | null;\n footText: string | null;\n addressCountry: ModelRefResponse | null;\n deliveryTerms: string | null;\n paymentTerms: string | null;\n origin: ModelRefResponse | null;\n version: string;\n smallSettlement: boolean;\n contactPerson: ModelRefResponse;\n taxRate: string;\n taxRule: ModelRefResponse;\n taxText: string;\n orderType: string;\n sendDate: string | null;\n address: string | null;\n currency: string;\n sumNet: string;\n sumTax: string;\n sumGross: string;\n sumDiscounts: string;\n sumNetForeignCurrency: string;\n sumTaxForeignCurrency: string;\n sumGrossForeignCurrency: string;\n sumDiscountsForeignCurrency: string;\n customerInternalNote: string | null;\n showNet: boolean;\n sendType: string | null;\n}\n\nexport interface OrderPosition {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n order: ModelRefResponse;\n part: ModelRefResponse | null;\n quantity: string;\n price: string | null;\n priceNet: string | null;\n priceTax: string | null;\n priceGross: string | null;\n name: string | null;\n unity: ModelRefResponse;\n positionNumber: string | null;\n text: string | null;\n discount: string | null;\n optional: boolean | null;\n taxRate: string;\n sumDiscount: string | null;\n}\n\nexport interface OrderDiscount {\n id: string;\n objectName: string;\n create: string;\n update: string;\n /** The order the discount belongs to. */\n object: ModelRefResponse;\n sevClient: string;\n text: string;\n /** `1` if `value` is a percentage, `0` if it is an absolute amount. */\n percentage: string;\n value: string;\n /** `0` if the discount is gross, `1` if it is net. */\n isNet: string;\n}\n\n/**\n * An object related to an order, for example an invoice or another order.\n * Only `id` and `objectName` are guaranteed, all further fields depend on the\n * type of the related object.\n */\nexport interface OrderRelatedObject {\n id: string;\n objectName: string;\n [key: string]: unknown;\n}\n\nexport interface OrderMail {\n id: string;\n objectName: string;\n create: string;\n update: string;\n object: Order;\n from: string;\n to: string;\n subject: string;\n text: string | null;\n sevClient: ModelRefResponse;\n cc: string | null;\n bcc: string | null;\n arrived: string | null;\n}\n\nexport interface OrderPdf {\n filename: string;\n mimeType: string;\n base64encoded: boolean;\n /** The pdf document, base64 encoded. */\n content: string;\n}\n\nexport interface SaveOrderResult {\n order: Order;\n positions: OrderPosition[];\n}\n\nexport class OrdersResource extends BaseResource {\n /** Retrieves orders via `GET /Order`. */\n public list(options: ListOrdersOptions = {}): Promise<Order[]> {\n const {\n status,\n orderNumber,\n startDate,\n endDate,\n contactId,\n limit,\n offset,\n embed,\n } = options;\n return this.http.request<Order[]>({\n method: 'GET',\n path: '/Order',\n query: {\n status,\n orderNumber,\n startDate: toOptionalDate(startDate),\n endDate: toOptionalDate(endDate),\n 'contact[id]': contactId,\n 'contact[objectName]': contactId === undefined ? undefined : 'Contact',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single order via `GET /Order/{orderId}`. */\n public async get(options: {\n orderId: number;\n embed?: string[];\n }): Promise<Order> {\n const orders = await this.http.request<Order[]>({\n method: 'GET',\n path: `/Order/${options.orderId}`,\n query: { embed: options.embed },\n });\n const order = orders[0];\n if (!order) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return order;\n }\n\n /** Creates or updates an order with its positions via `POST /Order/Factory/saveOrder`. */\n public async save(options: SaveOrderOptions): Promise<SaveOrderResult> {\n const { order, positions } = options;\n const result = await this.http.request<{\n order: Order;\n orderPos: OrderPosition[];\n }>({\n method: 'POST',\n path: '/Order/Factory/saveOrder',\n body: {\n order: toOrderBody(order),\n orderPosSave: positions.map(toOrderPositionBody),\n orderPosDelete: null,\n },\n });\n return { order: result.order, positions: result.orderPos };\n }\n\n /** Updates an order via `PUT /Order/{orderId}`. */\n public update(options: UpdateOrderOptions): Promise<Order> {\n const { orderId, orderDate, ...rest } = options;\n return this.http.request<Order>({\n method: 'PUT',\n path: `/Order/${orderId}`,\n body: { ...rest, orderDate: toOptionalDate(orderDate) },\n });\n }\n\n /** Deletes an order via `DELETE /Order/{orderId}`. */\n public async delete(options: { orderId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/Order/${options.orderId}`,\n });\n }\n\n /** Retrieves the positions of an order via `GET /Order/{orderId}/getPositions`. */\n public getPositions(\n options: { orderId: number; embed?: string[] } & ListOptions,\n ): Promise<OrderPosition[]> {\n const { orderId, limit, offset, embed } = options;\n return this.http.request<OrderPosition[]>({\n method: 'GET',\n path: `/Order/${orderId}/getPositions`,\n query: { limit, offset, embed },\n });\n }\n\n /** Retrieves the discounts of an order via `GET /Order/{orderId}/getDiscounts`. */\n public getDiscounts(\n options: { orderId: number; embed?: string[] } & ListOptions,\n ): Promise<OrderDiscount[]> {\n const { orderId, limit, offset, embed } = options;\n return this.http.request<OrderDiscount[]>({\n method: 'GET',\n path: `/Order/${orderId}/getDiscounts`,\n query: { limit, offset, embed },\n });\n }\n\n /** Retrieves the objects related to an order via `GET /Order/{orderId}/getRelatedObjects`. */\n public getRelatedObjects(\n options: GetOrderRelatedObjectsOptions,\n ): Promise<OrderRelatedObject[]> {\n const { orderId, includeItself, sortByType, embed } = options;\n return this.http.request<OrderRelatedObject[]>({\n method: 'GET',\n path: `/Order/${orderId}/getRelatedObjects`,\n query: { includeItself, sortByType, embed },\n });\n }\n\n /** Sends an order via email using `POST /Order/{orderId}/sendViaEmail`. */\n public sendViaEmail(options: SendOrderViaEmailOptions): Promise<OrderMail[]> {\n const { orderId, ...body } = options;\n return this.http.request<OrderMail[]>({\n method: 'POST',\n path: `/Order/${orderId}/sendViaEmail`,\n body,\n });\n }\n\n /** Creates a packing list from an order via `POST /Order/Factory/createPackingListFromOrder`. */\n public createPackingList(options: { orderId: number }): Promise<Order> {\n return this.http.request<Order>({\n method: 'POST',\n path: '/Order/Factory/createPackingListFromOrder',\n query: {\n 'order[id]': options.orderId,\n 'order[objectName]': 'Order',\n },\n body: { id: options.orderId, objectName: 'Order' },\n });\n }\n\n /** Creates a contract note from an order via `POST /Order/Factory/createContractNoteFromOrder`. */\n public createContractNote(options: { orderId: number }): Promise<Order> {\n return this.http.request<Order>({\n method: 'POST',\n path: '/Order/Factory/createContractNoteFromOrder',\n query: {\n 'order[id]': options.orderId,\n 'order[objectName]': 'Order',\n },\n body: { id: options.orderId, objectName: 'Order' },\n });\n }\n\n /** Retrieves the pdf of an order via `GET /Order/{orderId}/getPdf`. */\n public getPdf(options: {\n orderId: number;\n /** Prevents the order from being marked as sent. */\n preventSendBy?: boolean;\n }): Promise<OrderPdf> {\n return this.http.request<OrderPdf>({\n method: 'GET',\n path: `/Order/${options.orderId}/getPdf`,\n query: { preventSendBy: options.preventSendBy },\n });\n }\n\n /** Marks an order as sent via `PUT /Order/{orderId}/sendBy`. */\n public sendBy(options: SendOrderByOptions): Promise<Order> {\n const { orderId, sendType, sendDraft } = options;\n return this.http.request<Order>({\n method: 'PUT',\n path: `/Order/${orderId}/sendBy`,\n body: { sendType, sendDraft },\n });\n }\n\n /** Retrieves order positions via `GET /OrderPos`. */\n public listPositions(\n options: ListOrderPositionsOptions = {},\n ): Promise<OrderPosition[]> {\n const { orderId, limit, offset, embed } = options;\n return this.http.request<OrderPosition[]>({\n method: 'GET',\n path: '/OrderPos',\n query: {\n 'order[id]': orderId,\n 'order[objectName]': orderId === undefined ? undefined : 'Order',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single order position via `GET /OrderPos/{orderPosId}`. */\n public async getPosition(options: {\n orderPosId: number;\n }): Promise<OrderPosition> {\n const positions = await this.http.request<OrderPosition[]>({\n method: 'GET',\n path: `/OrderPos/${options.orderPosId}`,\n });\n const position = positions[0];\n if (!position) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return position;\n }\n\n /** Updates an order position via `PUT /OrderPos/{orderPosId}`. */\n public updatePosition(\n options: UpdateOrderPositionOptions,\n ): Promise<OrderPosition> {\n const { orderPosId, unityId, partId, ...rest } = options;\n return this.http.request<OrderPosition>({\n method: 'PUT',\n path: `/OrderPos/${orderPosId}`,\n body: {\n ...rest,\n unity: toRef(unityId, 'Unity'),\n part: toRef(partId, 'Part'),\n },\n });\n }\n\n /** Deletes an order position via `DELETE /OrderPos/{orderPosId}`. */\n public async deletePosition(options: { orderPosId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/OrderPos/${options.orderPosId}`,\n });\n }\n}\n\nfunction toOrderBody(order: OrderInput): Record<string, unknown> {\n return {\n objectName: 'Order',\n mapAll: true,\n orderNumber: order.orderNumber,\n orderDate: toVoucherDate(order.orderDate),\n contact: { id: order.contactId, objectName: 'Contact' },\n status: order.status,\n orderType: order.orderType,\n header: order.header,\n version: order.version,\n addressCountry: { id: order.addressCountryId, objectName: 'StaticCountry' },\n contactPerson: { id: order.contactPersonId, objectName: 'SevUser' },\n taxRule: { id: order.taxRuleId, objectName: 'TaxRule' },\n taxRate: order.taxRate,\n taxText: order.taxText,\n currency: order.currency,\n headText: order.headText,\n footText: order.footText,\n deliveryTerms: order.deliveryTerms,\n paymentTerms: order.paymentTerms,\n smallSettlement: order.smallSettlement,\n showNet: order.showNet,\n address: order.address,\n customerInternalNote: order.customerInternalNote,\n sendDate: toOptionalDate(order.sendDate),\n sendType: order.sendType,\n };\n}\n\nfunction toOrderPositionBody(\n position: OrderPositionInput,\n): Record<string, unknown> {\n return {\n objectName: 'OrderPos',\n mapAll: true,\n unity: { id: position.unityId, objectName: 'Unity' },\n quantity: position.quantity,\n taxRate: position.taxRate,\n name: position.name,\n price: position.price,\n text: position.text,\n part: toRef(position.partId, 'Part'),\n positionNumber: position.positionNumber,\n discount: position.discount,\n optional: position.optional,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n\nfunction toOptionalDate(\n value: DateInput | undefined,\n): string | number | undefined {\n return value === undefined ? undefined : toVoucherDate(value);\n}\n","import { SevDeskError } from '../errors';\nimport type { ListOptions, ModelRef, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/** `50` for an inactive and `100` for an active part. */\nexport type PartStatus = 50 | 100;\n\nexport interface ListPartsOptions extends ListOptions {\n partNumber?: string;\n name?: string;\n embed?: string[];\n}\n\nexport interface CreatePartOptions {\n name: string;\n partNumber: string;\n /** The unit in which the part is measured. `1` is the \"piece\" unit. */\n unityId: number;\n /** In sevdesk-Update 2.0 only `0`, `7` and `19` are allowed. */\n taxRate: number;\n stock: number;\n /** A text describing the part. */\n text?: string;\n /** Send a `GET /Category?objectType=Part` for all available categories. */\n categoryId?: number;\n stockEnabled?: boolean;\n /**\n * Net price for which the part is sold. sevdesk will change this parameter\n * so that the gross price is calculated automatically, until then\n * `priceGross` must be used.\n */\n price?: number;\n priceNet?: number;\n priceGross?: number;\n pricePurchase?: number;\n status?: PartStatus;\n /** An internal comment which does not appear on invoices and orders. */\n internalComment?: string;\n}\n\nexport interface UpdatePartOptions extends Partial<CreatePartOptions> {\n partId: number;\n}\n\nexport interface Part {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n name: string;\n partNumber: string;\n text: string | null;\n category: ModelRefResponse | null;\n stock: string;\n stockEnabled: string;\n unity: ModelRefResponse;\n price: string | null;\n priceNet: string | null;\n priceGross: string | null;\n pricePurchase: string | null;\n taxRate: string;\n status: string | null;\n internalComment: string | null;\n}\n\nexport class PartsResource extends BaseResource {\n /** Retrieves parts via `GET /Part`. */\n public list(options: ListPartsOptions = {}): Promise<Part[]> {\n const { partNumber, name, limit, offset, embed } = options;\n return this.http.request<Part[]>({\n method: 'GET',\n path: '/Part',\n query: { partNumber, name, limit, offset, embed },\n });\n }\n\n /** Retrieves a single part via `GET /Part/{partId}`. */\n public async get(options: { partId: number }): Promise<Part> {\n const parts = await this.http.request<Part[]>({\n method: 'GET',\n path: `/Part/${options.partId}`,\n });\n const part = parts[0];\n if (!part) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return part;\n }\n\n /** Creates a part via `POST /Part`. */\n public create(options: CreatePartOptions): Promise<Part> {\n return this.http.request<Part>({\n method: 'POST',\n path: '/Part',\n body: toPartBody(options),\n });\n }\n\n /** Updates a part via `PUT /Part/{partId}`. */\n public update(options: UpdatePartOptions): Promise<Part> {\n const { partId, ...fields } = options;\n return this.http.request<Part>({\n method: 'PUT',\n path: `/Part/${partId}`,\n body: toPartBody(fields),\n });\n }\n\n /** Retrieves the current stock amount of a part via `GET /Part/{partId}/getStock`. */\n public getStock(options: { partId: number }): Promise<number> {\n return this.http.request<number>({\n method: 'GET',\n path: `/Part/${options.partId}/getStock`,\n });\n }\n}\n\nfunction toPartBody(\n fields: Partial<CreatePartOptions>,\n): Record<string, unknown> {\n return {\n objectName: 'Part',\n mapAll: true,\n name: fields.name,\n partNumber: fields.partNumber,\n unity: toRef(fields.unityId, 'Unity'),\n taxRate: fields.taxRate,\n stock: fields.stock,\n text: fields.text,\n category: toRef(fields.categoryId, 'Category'),\n stockEnabled: fields.stockEnabled,\n price: fields.price,\n priceNet: fields.priceNet,\n priceGross: fields.priceGross,\n pricePurchase: fields.pricePurchase,\n status: fields.status,\n internalComment: fields.internalComment,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n","import { BaseResource } from './base';\n\nexport interface AllowedTaxRule {\n id: number;\n name: string;\n description: string;\n /** Tax rates combinable with this tax rule, for example `ZERO` or `NINETEEN`. */\n taxRates: string[];\n}\n\nexport interface ReceiptGuide {\n accountDatevId: number;\n accountNumber: string;\n accountName: string;\n description: string;\n allowedTaxRules: AllowedTaxRule[];\n /** Viable receipt types for this account, for example `EXPENSE`. */\n allowedReceiptTypes: string[];\n}\n\nexport class ReceiptGuidanceResource extends BaseResource {\n /** Retrieves guidance for all accounts via `GET /ReceiptGuidance/forAllAccounts`. */\n public forAllAccounts(): Promise<ReceiptGuide[]> {\n return this.http.request<ReceiptGuide[]>({\n method: 'GET',\n path: '/ReceiptGuidance/forAllAccounts',\n });\n }\n\n /** Retrieves guidance for a datev account number via `GET /ReceiptGuidance/forAccountNumber`. */\n public forAccountNumber(options: {\n accountNumber: string;\n }): Promise<ReceiptGuide[]> {\n return this.http.request<ReceiptGuide[]>({\n method: 'GET',\n path: '/ReceiptGuidance/forAccountNumber',\n query: { accountNumber: options.accountNumber },\n });\n }\n\n /** Retrieves guidance for a tax rule via `GET /ReceiptGuidance/forTaxRule`. */\n public forTaxRule(options: { taxRule: string }): Promise<ReceiptGuide[]> {\n return this.http.request<ReceiptGuide[]>({\n method: 'GET',\n path: '/ReceiptGuidance/forTaxRule',\n query: { taxRule: options.taxRule },\n });\n }\n\n /** Retrieves guidance for revenue accounts via `GET /ReceiptGuidance/forRevenue`. */\n public forRevenue(): Promise<ReceiptGuide[]> {\n return this.http.request<ReceiptGuide[]>({\n method: 'GET',\n path: '/ReceiptGuidance/forRevenue',\n });\n }\n\n /** Retrieves guidance for expense accounts via `GET /ReceiptGuidance/forExpense`. */\n public forExpense(): Promise<ReceiptGuide[]> {\n return this.http.request<ReceiptGuide[]>({\n method: 'GET',\n path: '/ReceiptGuidance/forExpense',\n });\n }\n}\n","import { BaseResource } from './base';\nimport type {\n ExportContactFilter,\n ExportDocumentFilter,\n ExportFile,\n ExportInvoiceFilter,\n ExportSevQueryOptions,\n ExportVoucherFilter,\n} from './exports';\nimport {\n toExportContactFilter,\n toExportDocumentFilter,\n toExportInvoiceFilter,\n toExportSevQueryParams,\n toExportVoucherFilter,\n} from './exports';\n\n/** `AN` (quotation), `AB` (order confirmation) and `LI` (delivery note). */\nexport type ReportOrderType = 'AN' | 'AB' | 'LI';\n\nexport interface ReportOrderFilter extends ExportDocumentFilter {\n orderType?: ReportOrderType;\n}\n\nexport interface ReportInvoiceListOptions {\n download?: boolean;\n /** Defaults to `all`. */\n view?: string;\n limit?: number;\n filter?: ExportInvoiceFilter;\n}\n\nexport interface ReportOrderListOptions {\n download?: boolean;\n /** Defaults to `all`. */\n view?: string;\n limit?: number;\n filter?: ReportOrderFilter;\n}\n\nexport interface ReportContactListOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportContactFilter;\n}\n\nexport interface ReportVoucherListOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportVoucherFilter;\n}\n\nexport class ReportsResource extends BaseResource {\n /** Creates an invoice list report as PDF via `GET /Report/invoicelist`. */\n public invoiceList(\n options: ReportInvoiceListOptions = {},\n ): Promise<ExportFile> {\n return this.requestReport(\n '/Report/invoicelist',\n { download: options.download, view: options.view ?? 'all' },\n {\n modelName: 'Invoice',\n limit: options.limit,\n filter: toExportInvoiceFilter(options.filter),\n },\n );\n }\n\n /** Creates an order list report as PDF via `GET /Report/orderlist`. */\n public orderList(options: ReportOrderListOptions = {}): Promise<ExportFile> {\n return this.requestReport(\n '/Report/orderlist',\n { download: options.download, view: options.view ?? 'all' },\n {\n modelName: 'Order',\n limit: options.limit,\n filter: {\n ...toExportDocumentFilter(options.filter),\n orderType: options.filter?.orderType,\n },\n },\n );\n }\n\n /** Creates a contact list report as PDF via `GET /Report/contactlist`. */\n public contactList(\n options: ReportContactListOptions = {},\n ): Promise<ExportFile> {\n return this.requestReport('/Report/contactlist', options, {\n modelName: 'Contact',\n limit: options.limit,\n filter: toExportContactFilter(options.filter),\n });\n }\n\n /** Creates a voucher list report as PDF via `GET /Report/voucherlist`. */\n public voucherList(\n options: ReportVoucherListOptions = {},\n ): Promise<ExportFile> {\n return this.requestReport('/Report/voucherlist', options, {\n modelName: 'Voucher',\n limit: options.limit,\n filter: toExportVoucherFilter(options.filter),\n });\n }\n\n private requestReport(\n path: string,\n options: { download?: boolean; view?: string },\n sevQuery: ExportSevQueryOptions,\n ): Promise<ExportFile> {\n return this.http.request<ExportFile>({\n method: 'GET',\n path,\n query: {\n download: options.download,\n view: options.view,\n ...toExportSevQueryParams(sevQuery),\n },\n });\n }\n}\n","import { SevDeskError } from '../errors';\nimport type { ListOptions, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/** The document types a tag can be attached to. */\nexport type TagObjectType = 'Invoice' | 'Voucher' | 'Order' | 'CreditNote';\n\nexport interface ListTagsOptions extends ListOptions {\n name?: string;\n}\n\nexport interface CreateTagOptions {\n name: string;\n /** The document the tag is attached to. */\n objectId: number;\n objectName: TagObjectType;\n}\n\nexport interface Tag {\n id: string;\n objectName: string;\n create: string;\n name: string;\n sevClient: ModelRefResponse;\n}\n\n/** The link between a tag and the document it is attached to. */\nexport interface TagRelation {\n id: string;\n objectName: string;\n create: string;\n tag: ModelRefResponse;\n object: ModelRefResponse;\n sevClient: ModelRefResponse;\n}\n\nexport class TagsResource extends BaseResource {\n /** Retrieves tags via `GET /Tag`. */\n public list(options: ListTagsOptions = {}): Promise<Tag[]> {\n const { name, limit, offset } = options;\n return this.http.request<Tag[]>({\n method: 'GET',\n path: '/Tag',\n query: { name, limit, offset },\n });\n }\n\n /** Retrieves a single tag via `GET /Tag/{tagId}`. */\n public async get(options: { tagId: number }): Promise<Tag> {\n const tags = await this.http.request<Tag[]>({\n method: 'GET',\n path: `/Tag/${options.tagId}`,\n });\n const tag = tags[0];\n if (!tag) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return tag;\n }\n\n /**\n * Creates a tag and attaches it to a document via `POST /Tag/Factory/create`.\n * Returns the created tag relation.\n */\n public create(options: CreateTagOptions): Promise<TagRelation> {\n const { name, objectId, objectName } = options;\n return this.http.request<TagRelation>({\n method: 'POST',\n path: '/Tag/Factory/create',\n body: { name, object: { id: objectId, objectName } },\n });\n }\n\n /** Renames a tag via `PUT /Tag/{tagId}`. */\n public update(options: { tagId: number; name: string }): Promise<Tag> {\n return this.http.request<Tag>({\n method: 'PUT',\n path: `/Tag/${options.tagId}`,\n body: { name: options.name },\n });\n }\n\n /** Deletes a tag via `DELETE /Tag/{tagId}`. */\n public async delete(options: { tagId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/Tag/${options.tagId}`,\n });\n }\n\n /** Retrieves tag relations via `GET /TagRelation`. */\n public listRelations(options: ListOptions = {}): Promise<TagRelation[]> {\n return this.http.request<TagRelation[]>({\n method: 'GET',\n path: '/TagRelation',\n query: { limit: options.limit, offset: options.offset },\n });\n }\n}\n","import { toIsoDateTime } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type { DateInput, ListOptions, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/**\n * Status of a transaction.\n *\n * - `100` created\n * - `200` linked\n * - `300` private\n * - `350` auto-booked without user confirmation\n * - `400` booked\n */\nexport type TransactionStatus = 100 | 200 | 300 | 350 | 400;\n\n/** A transaction on a check account. */\nexport interface CheckAccountTransaction {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n valueDate: string;\n entryDate: string | null;\n paymtPurpose: string | null;\n amount: string;\n payeePayerName: string | null;\n payeePayerAcctNo: string | null;\n payeePayerBankCode: string | null;\n checkAccount: ModelRefResponse;\n status: string;\n enshrined: string | null;\n sourceTransaction: ModelRefResponse | null;\n targetTransaction: ModelRefResponse | null;\n gvCode: string | null;\n entryText: string | null;\n primaNotaNo: string | null;\n}\n\nexport interface ListTransactionsOptions extends ListOptions {\n checkAccountId?: number;\n isBooked?: boolean;\n paymtPurpose?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n payeePayerName?: string;\n onlyCredit?: boolean;\n onlyDebit?: boolean;\n}\n\nexport interface CreateTransactionOptions {\n checkAccountId: number;\n valueDate: DateInput;\n entryDate?: DateInput;\n amount: number;\n payeePayerName: string;\n paymtPurpose?: string;\n payeePayerAcctNo?: string;\n payeePayerBankCode?: string;\n /** Defaults to `100`, the only status that makes sense on creation. */\n status?: TransactionStatus;\n}\n\nexport interface UpdateTransactionOptions {\n transactionId: number;\n valueDate?: DateInput;\n entryDate?: DateInput;\n paymtPurpose?: string;\n amount?: number;\n payeePayerName?: string;\n status?: TransactionStatus;\n}\n\nexport class TransactionsResource extends BaseResource {\n /** Retrieves transactions via `GET /CheckAccountTransaction`. */\n public async list(\n options: ListTransactionsOptions = {},\n ): Promise<CheckAccountTransaction[]> {\n return this.http.request<CheckAccountTransaction[]>({\n method: 'GET',\n path: '/CheckAccountTransaction',\n query: {\n 'checkAccount[id]': options.checkAccountId,\n 'checkAccount[objectName]':\n options.checkAccountId === undefined ? undefined : 'CheckAccount',\n isBooked: options.isBooked,\n paymtPurpose: options.paymtPurpose,\n startDate: toOptionalIsoDateTime(options.startDate),\n endDate: toOptionalIsoDateTime(options.endDate),\n payeePayerName: options.payeePayerName,\n onlyCredit: options.onlyCredit,\n onlyDebit: options.onlyDebit,\n limit: options.limit,\n offset: options.offset,\n },\n });\n }\n\n /** Retrieves a single transaction via `GET /CheckAccountTransaction/{transactionId}`. */\n public async get(options: {\n transactionId: number;\n }): Promise<CheckAccountTransaction> {\n const transactions = await this.http.request<CheckAccountTransaction[]>({\n method: 'GET',\n path: `/CheckAccountTransaction/${options.transactionId}`,\n });\n const transaction = transactions[0];\n if (!transaction) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return transaction;\n }\n\n /**\n * Creates a transaction via `POST /CheckAccountTransaction`.\n *\n * Should only be used on check accounts of type online, preferably on\n * accounts that import their transactions from CSV files.\n */\n public async create(\n options: CreateTransactionOptions,\n ): Promise<CheckAccountTransaction> {\n return this.http.request<CheckAccountTransaction>({\n method: 'POST',\n path: '/CheckAccountTransaction',\n body: {\n objectName: 'CheckAccountTransaction',\n mapAll: true,\n valueDate: toIsoDateTime(options.valueDate),\n entryDate: toOptionalIsoDateTime(options.entryDate),\n amount: options.amount,\n payeePayerName: options.payeePayerName,\n paymtPurpose: options.paymtPurpose,\n payeePayerAcctNo: options.payeePayerAcctNo,\n payeePayerBankCode: options.payeePayerBankCode,\n checkAccount: {\n id: options.checkAccountId,\n objectName: 'CheckAccount',\n },\n status: options.status ?? 100,\n },\n });\n }\n\n /** Updates a transaction via `PUT /CheckAccountTransaction/{transactionId}`. */\n public async update(\n options: UpdateTransactionOptions,\n ): Promise<CheckAccountTransaction> {\n const { transactionId, valueDate, entryDate, ...rest } = options;\n return this.http.request<CheckAccountTransaction>({\n method: 'PUT',\n path: `/CheckAccountTransaction/${transactionId}`,\n body: {\n ...rest,\n valueDate: toOptionalIsoDateTime(valueDate),\n entryDate: toOptionalIsoDateTime(entryDate),\n },\n });\n }\n\n /** Deletes a transaction via `DELETE /CheckAccountTransaction/{transactionId}`. */\n public async delete(options: { transactionId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/CheckAccountTransaction/${options.transactionId}`,\n });\n }\n\n /**\n * Enshrines a transaction via `PUT /CheckAccountTransaction/{transactionId}/enshrine`.\n *\n * Requires a status of at least `200` and cannot be undone. Linked invoices,\n * credit notes and vouchers can no longer be changed afterwards.\n */\n public async enshrine(options: { transactionId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'PUT',\n path: `/CheckAccountTransaction/${options.transactionId}/enshrine`,\n });\n }\n}\n\nfunction toOptionalIsoDateTime(\n value: DateInput | undefined,\n): string | undefined {\n return value === undefined ? undefined : toIsoDateTime(value);\n}\n","import { toIsoDateTime, toVoucherDate } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type {\n DateInput,\n ListOptions,\n ModelRef,\n ModelRefResponse,\n} from '../types';\nimport { BaseResource } from './base';\n\nexport type VoucherStatus = 50 | 100 | 150 | 750 | 1000;\n\nexport type VoucherBookingType =\n 'FULL_PAYMENT' | 'N' | 'CB' | 'O' | 'OF' | 'MTC';\n\nexport interface VoucherInput {\n /** `50` for a draft voucher, `100` for an open one. */\n status: 50 | 100;\n /** `C` for a credit voucher, `D` for a debit voucher. */\n creditDebit: 'C' | 'D';\n /** Defines the vat regulation, for example `1` for \"Umsatzsteuerpflichtige Umsätze\". */\n taxRuleId: number;\n /** Defaults to `VOU`. */\n voucherType?: 'VOU' | 'RV';\n voucherDate?: DateInput;\n payDate?: DateInput;\n deliveryDate?: DateInput;\n deliveryDateUntil?: DateInput;\n supplierId?: number;\n /** Shown as the supplier of the voucher when no `supplierId` is given. */\n supplierName?: string;\n /** The voucher number. */\n description?: string;\n currency?: string;\n propertyExchangeRate?: number;\n costCentreId?: number;\n}\n\nexport interface VoucherPositionInput {\n accountDatevId: number;\n taxRate: number;\n /** `true` if `sumNet` is authoritative, `false` if `sumGross` is. */\n net: boolean;\n sumNet?: number;\n sumGross?: number;\n isAsset?: boolean;\n comment?: string;\n}\n\nexport interface SaveVoucherOptions {\n voucher: VoucherInput;\n positions: VoucherPositionInput[];\n /** Internal filename returned by `uploadFile`. */\n filename?: string;\n}\n\nexport interface ListVouchersOptions extends ListOptions {\n status?: VoucherStatus;\n creditDebit?: 'C' | 'D';\n descriptionLike?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n contactId?: number;\n embed?: string[];\n}\n\nexport interface UpdateVoucherOptions {\n voucherId: number;\n voucherDate?: DateInput;\n /** The voucher number. */\n description?: string;\n payDate?: DateInput;\n supplierName?: string;\n}\n\nexport interface BookVoucherOptions {\n voucherId: number;\n /** Can also be a partial amount. */\n amount: number;\n date: DateInput;\n type: VoucherBookingType;\n checkAccountId: number;\n /**\n * Required for online check accounts. Must be omitted for offline check\n * accounts and cash registers, where the transaction is created automatically.\n */\n checkAccountTransactionId?: number;\n createFeed?: boolean;\n}\n\nexport interface Voucher {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n voucherDate: string | null;\n supplier: ModelRefResponse | null;\n supplierName: string | null;\n description: string | null;\n payDate: string | null;\n status: string | null;\n sumNet: string;\n sumTax: string;\n sumGross: string;\n sumNetAccounting: string;\n sumTaxAccounting: string;\n sumGrossAccounting: string;\n sumDiscounts: string;\n paidAmount: number | null;\n taxRule: ModelRefResponse;\n creditDebit: string | null;\n voucherType: string | null;\n currency: string | null;\n propertyExchangeRate: string | null;\n enshrined: string | null;\n paymentDeadline: string | null;\n deliveryDate: string;\n deliveryDateUntil: string | null;\n document: ModelRefResponse | null;\n costCentre: ModelRefResponse | null;\n}\n\nexport interface VoucherPosition {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n voucher: ModelRefResponse;\n accountDatev: ModelRefResponse;\n taxRate: string;\n net: boolean;\n isAsset: boolean;\n sumNet: string;\n sumTax: string;\n sumGross: string;\n sumNetAccounting: string;\n sumTaxAccounting: string;\n sumGrossAccounting: string;\n comment: string | null;\n}\n\nexport interface SaveVoucherResult {\n voucher: Voucher;\n positions: VoucherPosition[];\n filename?: string;\n}\n\nexport interface BookVoucherResult {\n id: string;\n objectName: string;\n create: string;\n voucher: ModelRefResponse;\n fromStatus: string;\n toStatus: string;\n amountPayed: string;\n bookingDate: string;\n sevClient: ModelRefResponse;\n}\n\nexport interface UploadVoucherFileResult {\n pages: number;\n mimeType: string;\n originMimeType: string;\n /** The sevdesk internal filename to pass to `save`. */\n filename: string;\n contentHash: string;\n}\n\nexport class VouchersResource extends BaseResource {\n /** Retrieves vouchers via `GET /Voucher`. */\n public list(options: ListVouchersOptions = {}): Promise<Voucher[]> {\n const {\n status,\n creditDebit,\n descriptionLike,\n startDate,\n endDate,\n contactId,\n limit,\n offset,\n embed,\n } = options;\n return this.http.request<Voucher[]>({\n method: 'GET',\n path: '/Voucher',\n query: {\n status,\n creditDebit,\n descriptionLike,\n startDate: toOptionalVoucherDate(startDate),\n endDate: toOptionalVoucherDate(endDate),\n 'contact[id]': contactId,\n 'contact[objectName]': contactId === undefined ? undefined : 'Contact',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single voucher via `GET /Voucher/{voucherId}`. */\n public async get(options: {\n voucherId: number;\n embed?: string[];\n }): Promise<Voucher> {\n const vouchers = await this.http.request<Voucher[]>({\n method: 'GET',\n path: `/Voucher/${options.voucherId}`,\n query: { embed: options.embed },\n });\n const voucher = vouchers[0];\n if (!voucher) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return voucher;\n }\n\n /** Uploads a voucher document via `POST /Voucher/Factory/uploadTempFile`. */\n public uploadFile(options: {\n file: Blob | Uint8Array;\n filename?: string;\n }): Promise<UploadVoucherFileResult> {\n const { file, filename = 'upload' } = options;\n const formData = new FormData();\n const blob =\n file instanceof Blob ? file : new Blob([file as Uint8Array<ArrayBuffer>]);\n formData.append('file', blob, filename);\n return this.http.request<UploadVoucherFileResult>({\n method: 'POST',\n path: '/Voucher/Factory/uploadTempFile',\n formData,\n });\n }\n\n /** Creates or updates a voucher with its positions via `POST /Voucher/Factory/saveVoucher`. */\n public async save(options: SaveVoucherOptions): Promise<SaveVoucherResult> {\n const { voucher, positions, filename } = options;\n const result = await this.http.request<{\n voucher: Voucher;\n voucherPos: VoucherPosition[];\n filename?: string;\n }>({\n method: 'POST',\n path: '/Voucher/Factory/saveVoucher',\n body: {\n voucher: toVoucherBody(voucher),\n voucherPosSave: positions.map(toVoucherPositionBody),\n voucherPosDelete: null,\n ...(filename === undefined ? {} : { filename }),\n },\n });\n return {\n voucher: result.voucher,\n positions: result.voucherPos,\n filename: result.filename,\n };\n }\n\n /** Uploads a document and creates a voucher with it attached. */\n public async createFromFile(options: {\n file: Blob | Uint8Array;\n filename?: string;\n voucher: VoucherInput;\n positions: VoucherPositionInput[];\n }): Promise<SaveVoucherResult> {\n const { file, filename, voucher, positions } = options;\n const upload = await this.uploadFile({ file, filename });\n return this.save({ voucher, positions, filename: upload.filename });\n }\n\n /** Updates simple fields of a draft voucher via `PUT /Voucher/{voucherId}`. */\n public update(options: UpdateVoucherOptions): Promise<Voucher> {\n const { voucherId, voucherDate, description, payDate, supplierName } =\n options;\n return this.http.request<Voucher>({\n method: 'PUT',\n path: `/Voucher/${voucherId}`,\n body: {\n voucherDate: toOptionalVoucherDate(voucherDate),\n description,\n payDate: toOptionalVoucherDate(payDate),\n supplierName,\n },\n });\n }\n\n /** Books an amount on a voucher via `PUT /Voucher/{voucherId}/bookAmount`. */\n public book(options: BookVoucherOptions): Promise<BookVoucherResult> {\n const {\n voucherId,\n amount,\n date,\n type,\n checkAccountId,\n checkAccountTransactionId,\n createFeed,\n } = options;\n return this.http.request<BookVoucherResult>({\n method: 'PUT',\n path: `/Voucher/${voucherId}/bookAmount`,\n body: {\n amount,\n date: toIsoDateTime(date),\n type,\n checkAccount: { id: checkAccountId, objectName: 'CheckAccount' },\n checkAccountTransaction: toRef(\n checkAccountTransactionId,\n 'CheckAccountTransaction',\n ),\n createFeed,\n },\n });\n }\n\n /** Resets the voucher status to open via `PUT /Voucher/{voucherId}/resetToOpen`. */\n public resetToOpen(options: { voucherId: number }): Promise<Voucher> {\n return this.http.request<Voucher>({\n method: 'PUT',\n path: `/Voucher/${options.voucherId}/resetToOpen`,\n });\n }\n\n /** Resets the voucher status to draft via `PUT /Voucher/{voucherId}/resetToDraft`. */\n public resetToDraft(options: { voucherId: number }): Promise<Voucher> {\n return this.http.request<Voucher>({\n method: 'PUT',\n path: `/Voucher/${options.voucherId}/resetToDraft`,\n });\n }\n\n /** Enshrines a voucher via `PUT /Voucher/{voucherId}/enshrine`. This cannot be undone. */\n public async enshrine(options: { voucherId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'PUT',\n path: `/Voucher/${options.voucherId}/enshrine`,\n });\n }\n\n /** Retrieves the positions of a voucher via `GET /VoucherPos`. */\n public listPositions(\n options: { voucherId: number } & ListOptions,\n ): Promise<VoucherPosition[]> {\n const { voucherId, limit, offset } = options;\n return this.http.request<VoucherPosition[]>({\n method: 'GET',\n path: '/VoucherPos',\n query: {\n 'voucher[id]': voucherId,\n 'voucher[objectName]': 'Voucher',\n limit,\n offset,\n },\n });\n }\n}\n\nfunction toVoucherBody(voucher: VoucherInput): Record<string, unknown> {\n return {\n objectName: 'Voucher',\n mapAll: true,\n status: voucher.status,\n creditDebit: voucher.creditDebit,\n taxRule: { id: voucher.taxRuleId, objectName: 'TaxRule' },\n voucherType: voucher.voucherType ?? 'VOU',\n voucherDate: toOptionalVoucherDate(voucher.voucherDate),\n payDate: toOptionalVoucherDate(voucher.payDate),\n deliveryDate: toOptionalVoucherDate(voucher.deliveryDate),\n deliveryDateUntil: toOptionalVoucherDate(voucher.deliveryDateUntil),\n supplier: toRef(voucher.supplierId, 'Contact'),\n supplierName: voucher.supplierName,\n description: voucher.description,\n currency: voucher.currency,\n propertyExchangeRate: voucher.propertyExchangeRate,\n costCentre: toRef(voucher.costCentreId, 'CostCentre'),\n };\n}\n\nfunction toVoucherPositionBody(\n position: VoucherPositionInput,\n): Record<string, unknown> {\n return {\n objectName: 'VoucherPos',\n mapAll: true,\n voucher: null,\n accountDatev: {\n id: position.accountDatevId,\n objectName: 'AccountDatev',\n },\n taxRate: position.taxRate,\n net: position.net,\n sumNet: position.sumNet,\n sumGross: position.sumGross,\n isAsset: position.isAsset,\n comment: position.comment,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n\nfunction toOptionalVoucherDate(\n value: DateInput | undefined,\n): string | number | undefined {\n return value === undefined ? undefined : toVoucherDate(value);\n}\n","import type { SevDeskOptions } from './http-client';\nimport { HttpClient } from './http-client';\nimport { BasicsResource } from './resources/basics';\nimport { CheckAccountsResource } from './resources/check-accounts';\nimport { ContactsResource } from './resources/contacts';\nimport { CreditNotesResource } from './resources/credit-notes';\nimport { ExportsResource } from './resources/exports';\nimport { InvoicesResource } from './resources/invoices';\nimport { OrdersResource } from './resources/orders';\nimport { PartsResource } from './resources/parts';\nimport { ReceiptGuidanceResource } from './resources/receipt-guidance';\nimport { ReportsResource } from './resources/reports';\nimport { TagsResource } from './resources/tags';\nimport { TransactionsResource } from './resources/transactions';\nimport { VouchersResource } from './resources/vouchers';\n\nexport class SevDesk {\n public readonly basics: BasicsResource;\n public readonly checkAccounts: CheckAccountsResource;\n public readonly contacts: ContactsResource;\n public readonly creditNotes: CreditNotesResource;\n public readonly exports: ExportsResource;\n public readonly invoices: InvoicesResource;\n public readonly orders: OrdersResource;\n public readonly parts: PartsResource;\n public readonly receiptGuidance: ReceiptGuidanceResource;\n public readonly reports: ReportsResource;\n public readonly tags: TagsResource;\n public readonly transactions: TransactionsResource;\n public readonly vouchers: VouchersResource;\n\n constructor(options: SevDeskOptions) {\n const http = new HttpClient(options);\n this.basics = new BasicsResource(http);\n this.checkAccounts = new CheckAccountsResource(http);\n this.contacts = new ContactsResource(http);\n this.creditNotes = new CreditNotesResource(http);\n this.exports = new ExportsResource(http);\n this.invoices = new InvoicesResource(http);\n this.orders = new OrdersResource(http);\n this.parts = new PartsResource(http);\n this.receiptGuidance = new ReceiptGuidanceResource(http);\n this.reports = new ReportsResource(http);\n this.tags = new TagsResource(http);\n this.transactions = new TransactionsResource(http);\n this.vouchers = new VouchersResource(http);\n }\n}\n"],"mappings":";AAAA,IAAa,eAAb,cAAkC,MAAM;CACtC;CACA;CACA;CAEA,YAAY,SAAgE;EAC1E,MAAM,eAAe,OAAO,CAAC;EAC7B,KAAK,OAAO;EACZ,KAAK,SAAS,QAAQ;EACtB,KAAK,aAAa,QAAQ;EAC1B,KAAK,OAAO,QAAQ;CACtB;AACF;AAEA,SAAS,eAAe,SAIb;CACT,MAAM,WAAW,sBAAsB,QAAQ,OAAO,GAAG,QAAQ;CACjE,MAAM,OAAO,QAAQ;CACrB,IAAI,OAAO,SAAS,YAAY,KAAK,SAAS,GAC5C,OAAO;CAET,IAAI,OAAO,SAAS,YAAY,SAAS,MAAM;EAC7C,MAAM,QAAS,KAA6B;EAC5C,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;GAC/C,MAAM,UAAW,MAAgC;GACjD,IAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,GAClD,OAAO;EAEX;EACA,MAAM,UAAW,KAA+B;EAChD,IAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,GAClD,OAAO;CAEX;CACA,OAAO;AACT;;;ACpCA,MAAa,mBAAmB;AAEhC,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,mBAAmB;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C9B,YAAY,MAAM,QAAQ,cAAc,YAAY;CACtD;AACF;AAEA,SAAS,sBACP,UACyB;CACzB,OAAO;EACL,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,cAAc;GACZ,IAAI,SAAS;GACb,YAAY;EACd;EACA,SAAS,SAAS;EAClB,KAAK,SAAS;EACd,QAAQ,SAAS;EACjB,UAAU,SAAS;EACnB,SAAS,SAAS;EAClB,SAAS,SAAS;CACpB;AACF;AAEA,SAAS,MACP,IACA,YACsB;CACtB,OAAO,OAAO,KAAA,IAAY,KAAA,IAAY;EAAE;EAAI;CAAW;AACzD;AAEA,SAAS,sBACP,OAC6B;CAC7B,OAAO,UAAU,KAAA,IAAY,KAAA,IAAY,cAAc,KAAK;AAC9D;;;AC9YA,IAAa,UAAb,MAAqB;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAAyB;EACnC,MAAM,OAAO,IAAI,WAAW,OAAO;EACnC,KAAK,SAAS,IAAI,eAAe,IAAI;EACrC,KAAK,gBAAgB,IAAI,sBAAsB,IAAI;EACnD,KAAK,WAAW,IAAI,iBAAiB,IAAI;EACzC,KAAK,cAAc,IAAI,oBAAoB,IAAI;EAC/C,KAAK,UAAU,IAAI,gBAAgB,IAAI;EACvC,KAAK,WAAW,IAAI,iBAAiB,IAAI;EACzC,KAAK,SAAS,IAAI,eAAe,IAAI;EACrC,KAAK,QAAQ,IAAI,cAAc,IAAI;EACnC,KAAK,kBAAkB,IAAI,wBAAwB,IAAI;EACvD,KAAK,UAAU,IAAI,gBAAgB,IAAI;EACvC,KAAK,OAAO,IAAI,aAAa,IAAI;EACjC,KAAK,eAAe,IAAI,qBAAqB,IAAI;EACjD,KAAK,WAAW,IAAI,iBAAiB,IAAI;CAC3C;AACF"}
1
+ {"version":3,"file":"index.js","names":["toRef","toRef","toRef","toOptionalDate","toRef","toOptionalIsoDateTime","toRef","toRef","toRef","toRef"],"sources":["../src/errors.ts","../src/http-client.ts","../src/resources/base.ts","../src/resources/basics.ts","../src/dates.ts","../src/resources/check-accounts.ts","../src/resources/communication-ways.ts","../src/resources/contact-addresses.ts","../src/resources/contacts.ts","../src/resources/credit-notes.ts","../src/resources/exports.ts","../src/resources/invoices.ts","../src/resources/orders.ts","../src/resources/parts.ts","../src/resources/receipt-guidance.ts","../src/resources/reports.ts","../src/resources/tags.ts","../src/resources/transactions.ts","../src/resources/vouchers.ts","../src/client.ts"],"sourcesContent":["export class SevDeskError extends Error {\n public readonly status: number;\n public readonly statusText: string;\n public readonly body: unknown;\n\n constructor(options: { status: number; statusText: string; body: unknown }) {\n super(extractMessage(options));\n this.name = 'SevDeskError';\n this.status = options.status;\n this.statusText = options.statusText;\n this.body = options.body;\n }\n}\n\nfunction extractMessage(options: {\n status: number;\n statusText: string;\n body: unknown;\n}): string {\n const fallback = `sevdesk API error: ${options.status} ${options.statusText}`;\n const body = options.body;\n if (typeof body === 'string' && body.length > 0) {\n return body;\n }\n if (typeof body === 'object' && body !== null) {\n const error = (body as { error?: unknown }).error;\n if (typeof error === 'object' && error !== null) {\n const message = (error as { message?: unknown }).message;\n if (typeof message === 'string' && message.length > 0) {\n return message;\n }\n }\n const message = (body as { message?: unknown }).message;\n if (typeof message === 'string' && message.length > 0) {\n return message;\n }\n }\n return fallback;\n}\n","import { SevDeskError } from './errors';\n\nexport const DEFAULT_BASE_URL = 'https://my.sevdesk.de/api/v1';\n\nconst DEFAULT_TIMEOUT = 30_000;\nconst DEFAULT_USER_AGENT = '@genz-its/sevdesk-sdk';\nconst RETRY_MAX_ATTEMPTS = 3;\nconst RETRY_BASE_DELAY = 500;\nconst RETRY_MAX_DELAY = 10_000;\nconst RETRY_AFTER_MAX_DELAY = 60_000;\nconst RETRYABLE_METHODS = new Set(['GET', 'PUT', 'DELETE']);\nconst RETRYABLE_STATUS_CODES = new Set([429, 500, 502, 503, 504]);\n\nexport interface SevDeskOptions {\n /** The sevdesk API token, sent as raw `Authorization` header value. */\n token: string;\n baseUrl?: string;\n /** Request timeout in milliseconds. Defaults to 30 seconds. */\n timeout?: number;\n userAgent?: string;\n fetch?: typeof globalThis.fetch;\n}\n\nexport type QueryValue = string | number | boolean | string[] | undefined;\n\nexport type Query = Record<string, QueryValue>;\n\nexport interface HttpRequestOptions {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n path: string;\n query?: Query;\n body?: unknown;\n formData?: FormData;\n}\n\nexport class HttpClient {\n private readonly token: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly userAgent: string;\n private readonly fetch: typeof globalThis.fetch;\n\n constructor(options: SevDeskOptions) {\n this.token = options.token.trim();\n this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n this.userAgent = options.userAgent ?? DEFAULT_USER_AGENT;\n this.fetch = options.fetch ?? globalThis.fetch;\n }\n\n /**\n * Performs a request and returns the payload of the `objects` response\n * envelope. Responses without an envelope are returned as-is.\n */\n public async request<T>(options: HttpRequestOptions): Promise<T> {\n const response = await this.fetchWithRetry(options);\n const text = await response.text();\n if (text.length === 0) {\n return undefined as T;\n }\n return unwrap(JSON.parse(text)) as T;\n }\n\n private async fetchWithRetry(options: HttpRequestOptions): Promise<Response> {\n const url = this.buildUrl(options);\n const retryable = RETRYABLE_METHODS.has(options.method);\n for (let attempt = 0; ; attempt++) {\n const canRetry = retryable && attempt < RETRY_MAX_ATTEMPTS;\n let response: Response;\n try {\n response = await this.fetch(url, this.buildRequestInit(options));\n } catch (error) {\n if (canRetry) {\n await delay(backoffDelay(attempt));\n continue;\n }\n throw error;\n }\n if (response.ok) {\n return response;\n }\n if (canRetry && RETRYABLE_STATUS_CODES.has(response.status)) {\n await delay(\n retryAfterDelay(response.headers.get('Retry-After')) ??\n backoffDelay(attempt),\n );\n continue;\n }\n throw new SevDeskError({\n status: response.status,\n statusText: response.statusText,\n body: await parseErrorBody(response),\n });\n }\n }\n\n private buildUrl(options: HttpRequestOptions): string {\n const url = new URL(this.baseUrl + options.path);\n for (const [key, value] of Object.entries(options.query ?? {})) {\n if (value === undefined) {\n continue;\n }\n url.searchParams.append(\n key,\n Array.isArray(value) ? value.join(',') : String(value),\n );\n }\n return url.toString();\n }\n\n private buildRequestInit(options: HttpRequestOptions): RequestInit {\n const headers: Record<string, string> = {\n Authorization: this.token,\n Accept: 'application/json',\n 'User-Agent': this.userAgent,\n };\n let body: RequestInit['body'];\n if (options.formData) {\n body = options.formData;\n } else if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n body = JSON.stringify(options.body);\n }\n return {\n method: options.method,\n headers,\n body,\n signal: AbortSignal.timeout(this.timeout),\n };\n }\n}\n\nfunction unwrap(payload: unknown): unknown {\n if (typeof payload === 'object' && payload !== null && 'objects' in payload) {\n return (payload as { objects: unknown }).objects;\n }\n return payload;\n}\n\nasync function parseErrorBody(response: Response): Promise<unknown> {\n const text = await response.text();\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n}\n\nfunction backoffDelay(attempt: number): number {\n const ceiling = Math.min(RETRY_MAX_DELAY, RETRY_BASE_DELAY * 2 ** attempt);\n return ceiling / 2 + Math.random() * (ceiling / 2);\n}\n\nfunction retryAfterDelay(header: string | null): number | undefined {\n if (!header) {\n return undefined;\n }\n const seconds = Number(header);\n const milliseconds = Number.isFinite(seconds)\n ? seconds * 1000\n : new Date(header).getTime() - Date.now();\n if (!Number.isFinite(milliseconds) || milliseconds < 0) {\n return undefined;\n }\n return Math.min(milliseconds, RETRY_AFTER_MAX_DELAY);\n}\n\nfunction delay(milliseconds: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, milliseconds));\n}\n","import type { HttpClient } from '../http-client';\n\nexport abstract class BaseResource {\n protected readonly http: HttpClient;\n\n constructor(http: HttpClient) {\n this.http = http;\n }\n}\n","import { BaseResource } from './base';\n\nexport type BookkeepingSystemVersion = '1.0' | '2.0';\n\nexport class BasicsResource extends BaseResource {\n /** Retrieves the bookkeeping system version via `GET /Tools/bookkeepingSystemVersion`. */\n public async getBookkeepingSystemVersion(): Promise<BookkeepingSystemVersion> {\n const result = await this.http.request<{\n version: BookkeepingSystemVersion;\n }>({\n method: 'GET',\n path: '/Tools/bookkeepingSystemVersion',\n });\n return result.version;\n }\n}\n","import type { DateInput } from './types';\n\n/**\n * Serializes a date for voucher endpoints, which accept a Unix timestamp\n * or a `dd.mm.yyyy` string.\n */\nexport function toVoucherDate(value: DateInput): string | number {\n if (value instanceof Date) {\n return Math.floor(value.getTime() / 1000);\n }\n return value;\n}\n\n/** Serializes a date as ISO 8601, as expected by transaction endpoints. */\nexport function toIsoDateTime(value: DateInput): string {\n if (value instanceof Date) {\n return value.toISOString();\n }\n if (typeof value === 'number') {\n return new Date(value * 1000).toISOString();\n }\n return value;\n}\n\n/** Serializes a date as `YYYY-MM-DD`. */\nexport function toPlainDate(value: DateInput): string {\n if (value instanceof Date) {\n return value.toISOString().slice(0, 10);\n }\n if (typeof value === 'number') {\n return new Date(value * 1000).toISOString().slice(0, 10);\n }\n return value;\n}\n","import { toPlainDate } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type { DateInput, ListOptions, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/** A payment account, e.g. a bank account or a clearing account. */\nexport interface CheckAccount {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n name: string;\n iban: string | null;\n type: 'online' | 'offline' | 'register';\n importType: 'CSV' | 'MT940' | null;\n currency: string;\n defaultAccount: string;\n baseAccount: string;\n priority: string;\n status: string;\n balance: string | null;\n bankServer: string | null;\n autoMapTransactions: string | null;\n autoSyncTransactions: string;\n lastSync: string;\n accountingNumber: string;\n bic: string | null;\n}\n\nexport interface CreateFileImportAccountOptions {\n name: string;\n importType: 'CSV' | 'MT940';\n accountingNumber?: number;\n iban?: string;\n}\n\nexport interface CreateClearingAccountOptions {\n name: string;\n accountingNumber?: number;\n}\n\nexport interface UpdateCheckAccountOptions {\n checkAccountId: number;\n name?: string;\n defaultAccount?: number;\n autoMapTransactions?: number;\n accountingNumber?: number;\n iban?: string;\n bic?: string;\n}\n\nexport class CheckAccountsResource extends BaseResource {\n /** Retrieves all check accounts via `GET /CheckAccount`. */\n public async list(options: ListOptions = {}): Promise<CheckAccount[]> {\n return this.http.request<CheckAccount[]>({\n method: 'GET',\n path: '/CheckAccount',\n query: { limit: options.limit, offset: options.offset },\n });\n }\n\n /** Retrieves a single check account via `GET /CheckAccount/{checkAccountId}`. */\n public async get(options: { checkAccountId: number }): Promise<CheckAccount> {\n const checkAccounts = await this.http.request<CheckAccount[]>({\n method: 'GET',\n path: `/CheckAccount/${options.checkAccountId}`,\n });\n const checkAccount = checkAccounts[0];\n if (!checkAccount) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return checkAccount;\n }\n\n /** Creates a file import account via `POST /CheckAccount/Factory/fileImportAccount`. */\n public async createFileImportAccount(\n options: CreateFileImportAccountOptions,\n ): Promise<CheckAccount> {\n return this.http.request<CheckAccount>({\n method: 'POST',\n path: '/CheckAccount/Factory/fileImportAccount',\n body: options,\n });\n }\n\n /** Creates a clearing account via `POST /CheckAccount/Factory/clearingAccount`. */\n public async createClearingAccount(\n options: CreateClearingAccountOptions,\n ): Promise<CheckAccount> {\n return this.http.request<CheckAccount>({\n method: 'POST',\n path: '/CheckAccount/Factory/clearingAccount',\n body: options,\n });\n }\n\n /** Updates a check account via `PUT /CheckAccount/{checkAccountId}`. */\n public async update(\n options: UpdateCheckAccountOptions,\n ): Promise<CheckAccount> {\n const { checkAccountId, ...body } = options;\n return this.http.request<CheckAccount>({\n method: 'PUT',\n path: `/CheckAccount/${checkAccountId}`,\n body,\n });\n }\n\n /** Deletes a check account via `DELETE /CheckAccount/{checkAccountId}`. */\n public async delete(options: { checkAccountId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/CheckAccount/${options.checkAccountId}`,\n });\n }\n\n /**\n * Retrieves the balance at a date via `GET /CheckAccount/{checkAccountId}/getBalanceAtDate`.\n *\n * The balance is the sum of all transactions sevdesk knows up to and\n * including the given date. It does not have to match the actual bank\n * account balance, e.g. if old transactions were never imported.\n */\n public async getBalanceAtDate(options: {\n checkAccountId: number;\n date: DateInput;\n }): Promise<string> {\n return this.http.request<string>({\n method: 'GET',\n path: `/CheckAccount/${options.checkAccountId}/getBalanceAtDate`,\n query: { date: toPlainDate(options.date) },\n });\n }\n}\n","import { SevDeskError } from '../errors';\nimport type { ListOptions, ModelRef, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/** The medium of a communication way. */\nexport type CommunicationWayType = 'EMAIL' | 'PHONE' | 'WEB' | 'MOBILE';\n\nexport interface ListCommunicationWaysOptions extends ListOptions {\n /** Only returns the communication ways of this contact. */\n contactId?: number;\n type?: CommunicationWayType;\n /** `'1'` returns only the main communication ways. */\n main?: '0' | '1';\n}\n\nexport interface CreateCommunicationWayOptions {\n /** The contact this communication way belongs to. */\n contactId: number;\n type: CommunicationWayType;\n /** The phone number, e-mail address or website. */\n value: string;\n /**\n * The key of the communication way, e.g. `1` for private and `2` for work.\n * For all keys, send a `GET` to `/CommunicationWayKey`.\n */\n keyId: number;\n /** Defines if this is the main communication way of the contact. */\n main?: boolean;\n}\n\nexport interface UpdateCommunicationWayOptions extends Partial<CreateCommunicationWayOptions> {\n communicationWayId: number;\n}\n\nexport interface CommunicationWay {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n contact: ModelRefResponse;\n type: string;\n value: string;\n key: ModelRefResponse;\n main: string;\n}\n\n/** The key of a communication way, similar to the category of an address. */\nexport interface CommunicationWayKey {\n id: string;\n objectName: string;\n create: string;\n update: string;\n name: string;\n translationCode: string;\n}\n\nexport class CommunicationWaysResource extends BaseResource {\n /** Retrieves communication ways via `GET /CommunicationWay`. */\n public list(\n options: ListCommunicationWaysOptions = {},\n ): Promise<CommunicationWay[]> {\n const { contactId, type, main, limit, offset } = options;\n return this.http.request<CommunicationWay[]>({\n method: 'GET',\n path: '/CommunicationWay',\n query: {\n 'contact[id]': contactId,\n 'contact[objectName]': contactId === undefined ? undefined : 'Contact',\n type,\n main,\n limit,\n offset,\n },\n });\n }\n\n /** Retrieves a single communication way via `GET /CommunicationWay/{communicationWayId}`. */\n public async get(options: {\n communicationWayId: number;\n }): Promise<CommunicationWay> {\n const communicationWays = await this.http.request<CommunicationWay[]>({\n method: 'GET',\n path: `/CommunicationWay/${options.communicationWayId}`,\n });\n const communicationWay = communicationWays[0];\n if (!communicationWay) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return communicationWay;\n }\n\n /** Creates a communication way via `POST /CommunicationWay`. */\n public create(\n options: CreateCommunicationWayOptions,\n ): Promise<CommunicationWay> {\n return this.http.request<CommunicationWay>({\n method: 'POST',\n path: '/CommunicationWay',\n body: toCommunicationWayBody(options),\n });\n }\n\n /** Updates a communication way via `PUT /CommunicationWay/{communicationWayId}`. */\n public update(\n options: UpdateCommunicationWayOptions,\n ): Promise<CommunicationWay> {\n const { communicationWayId, ...fields } = options;\n return this.http.request<CommunicationWay>({\n method: 'PUT',\n path: `/CommunicationWay/${communicationWayId}`,\n body: toCommunicationWayBody(fields),\n });\n }\n\n /** Deletes a communication way via `DELETE /CommunicationWay/{communicationWayId}`. */\n public async delete(options: { communicationWayId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/CommunicationWay/${options.communicationWayId}`,\n });\n }\n\n /** Retrieves all communication way keys via `GET /CommunicationWayKey`. */\n public listKeys(options: ListOptions = {}): Promise<CommunicationWayKey[]> {\n return this.http.request<CommunicationWayKey[]>({\n method: 'GET',\n path: '/CommunicationWayKey',\n query: { limit: options.limit, offset: options.offset },\n });\n }\n}\n\nfunction toCommunicationWayBody(\n fields: Partial<CreateCommunicationWayOptions>,\n): Record<string, unknown> {\n return {\n objectName: 'CommunicationWay',\n mapAll: true,\n contact: toRef(fields.contactId, 'Contact'),\n type: fields.type,\n value: fields.value,\n key: toRef(fields.keyId, 'CommunicationWayKey'),\n main: fields.main,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n","import { SevDeskError } from '../errors';\nimport type { ListOptions, ModelRef, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\nexport interface CreateContactAddressOptions {\n /** The contact this address belongs to. */\n contactId: number;\n /** The country of the address. For all countries, send a `GET` to `/StaticCountry`. */\n countryId: number;\n /**\n * The category of the address. For all categories, send a `GET` to\n * `/Category?objectType=ContactAddress`.\n */\n categoryId: number;\n street?: string;\n zip?: string;\n city?: string;\n /** Name in the address. */\n name?: string;\n /** Second name in the address. */\n name2?: string;\n /** Third name in the address. */\n name3?: string;\n /** Fourth name in the address. */\n name4?: string;\n}\n\nexport interface UpdateContactAddressOptions extends Partial<CreateContactAddressOptions> {\n contactAddressId: number;\n}\n\nexport interface ContactAddress {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n contact: ModelRefResponse;\n street: string | null;\n zip: string | null;\n city: string | null;\n country: ModelRefResponse;\n category: ModelRefResponse | null;\n name: string | null;\n name2: string | null;\n name3: string | null;\n name4: string | null;\n}\n\nexport class ContactAddressesResource extends BaseResource {\n /** Retrieves contact addresses via `GET /ContactAddress`. */\n public list(options: ListOptions = {}): Promise<ContactAddress[]> {\n return this.http.request<ContactAddress[]>({\n method: 'GET',\n path: '/ContactAddress',\n query: { limit: options.limit, offset: options.offset },\n });\n }\n\n /** Retrieves a single contact address via `GET /ContactAddress/{contactAddressId}`. */\n public async get(options: {\n contactAddressId: number;\n }): Promise<ContactAddress> {\n const addresses = await this.http.request<ContactAddress[]>({\n method: 'GET',\n path: `/ContactAddress/${options.contactAddressId}`,\n });\n const address = addresses[0];\n if (!address) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return address;\n }\n\n /** Creates a contact address via `POST /ContactAddress`. */\n public create(options: CreateContactAddressOptions): Promise<ContactAddress> {\n return this.http.request<ContactAddress>({\n method: 'POST',\n path: '/ContactAddress',\n body: toContactAddressBody(options),\n });\n }\n\n /** Updates a contact address via `PUT /ContactAddress/{contactAddressId}`. */\n public update(options: UpdateContactAddressOptions): Promise<ContactAddress> {\n const { contactAddressId, ...fields } = options;\n return this.http.request<ContactAddress>({\n method: 'PUT',\n path: `/ContactAddress/${contactAddressId}`,\n body: toContactAddressBody(fields),\n });\n }\n\n /** Deletes a contact address via `DELETE /ContactAddress/{contactAddressId}`. */\n public async delete(options: { contactAddressId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/ContactAddress/${options.contactAddressId}`,\n });\n }\n}\n\nfunction toContactAddressBody(\n fields: Partial<CreateContactAddressOptions>,\n): Record<string, unknown> {\n return {\n objectName: 'ContactAddress',\n mapAll: true,\n contact: toRef(fields.contactId, 'Contact'),\n country: toRef(fields.countryId, 'StaticCountry'),\n category: toRef(fields.categoryId, 'Category'),\n street: fields.street,\n zip: fields.zip,\n city: fields.city,\n name: fields.name,\n name2: fields.name2,\n name3: fields.name3,\n name4: fields.name4,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n","import { SevDeskError } from '../errors';\nimport type { ListOptions, ModelRef, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/** `100` for a lead, `500` for a pending and `1000` for an active contact. */\nexport type ContactStatus = 100 | 500 | 1000;\n\nexport interface ListContactsOptions extends ListOptions {\n /**\n * `'0'` returns only organizations, `'1'` organizations and persons.\n * Defaults to `'0'`.\n */\n depth?: '0' | '1';\n customerNumber?: string;\n /** Matches the `name`, `surename` or `familyname` of a contact. */\n name?: string;\n categoryId?: number;\n /** Only returns contacts belonging to this organization. */\n parentId?: number;\n embed?: string[];\n}\n\nexport interface CreateContactOptions {\n /**\n * The category of the contact. The sevdesk default categories are `2` for a\n * supplier, `3` for a customer, `4` for a partner and `28` for a prospect\n * customer.\n */\n categoryId: number;\n /**\n * The organization name. A contact holding a name is regarded as an\n * organization, one holding a `surename` or `familyname` as a person.\n */\n name?: string;\n /** The **first** name of a person. Not to be used for organizations. */\n surename?: string;\n /** The last name of a person. Not to be used for organizations. */\n familyname?: string;\n /** The middle name or name suffix of a person. */\n name2?: string;\n /** A non-academic title, e.g. the position the person holds. */\n titel?: string;\n academicTitle?: string;\n gender?: string;\n /** The organization this person belongs to. */\n parentId?: number;\n customerNumber?: string;\n status?: ContactStatus;\n description?: string;\n vatNumber?: string;\n taxNumber?: string;\n /** Defines if the contact is freed from paying vat. */\n exemptVat?: boolean;\n /** Bank account number (IBAN) of the contact. */\n bankAccount?: string;\n bankNumber?: string;\n /** The payment goal in days which is set for every invoice of the contact. */\n defaultTimeToPay?: number;\n /** Buyer reference of the contact, required for e-invoices. */\n buyerReference?: string;\n governmentAgency?: boolean;\n}\n\nexport interface UpdateContactOptions extends Partial<CreateContactOptions> {\n contactId: number;\n}\n\nexport interface FindContactsByCustomFieldValueOptions {\n /** The value to be checked. */\n value: string;\n /** The name of the contact custom field setting. */\n customFieldName: string;\n /** Restricts the lookup to a single contact custom field setting. */\n customFieldSettingId?: number;\n}\n\nexport interface Contact {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n name: string | null;\n status: string | null;\n customerNumber: string | null;\n parent: ModelRefResponse | null;\n surename: string | null;\n familyname: string | null;\n titel: string | null;\n category: ModelRefResponse;\n description: string | null;\n academicTitle: string | null;\n gender: string | null;\n name2: string | null;\n birthday: string | null;\n vatNumber: string | null;\n bankAccount: string | null;\n bankNumber: string | null;\n defaultCashbackTime: string | null;\n defaultCashbackPercent: string | null;\n defaultTimeToPay: string | null;\n taxNumber: string | null;\n taxOffice: string | null;\n exemptVat: string | null;\n defaultDiscountAmount: string | null;\n defaultDiscountPercentage: string | null;\n buyerReference: string | null;\n governmentAgency: string | null;\n}\n\n/** Number of documents of a contact, grouped by document type. */\nexport interface ContactTabsItemCount {\n orders: number;\n invoices: number;\n creditNotes: number;\n documents: number;\n persons: number;\n vouchers: number;\n letters: number;\n parts: string;\n invoicePos: number;\n}\n\nexport class ContactsResource extends BaseResource {\n /** Retrieves contacts via `GET /Contact`. */\n public list(options: ListContactsOptions = {}): Promise<Contact[]> {\n const {\n depth,\n customerNumber,\n name,\n categoryId,\n parentId,\n limit,\n offset,\n embed,\n } = options;\n return this.http.request<Contact[]>({\n method: 'GET',\n path: '/Contact',\n query: {\n depth,\n customerNumber,\n name,\n 'category[id]': categoryId,\n 'category[objectName]':\n categoryId === undefined ? undefined : 'Category',\n 'parent[id]': parentId,\n 'parent[objectName]': parentId === undefined ? undefined : 'Contact',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single contact via `GET /Contact/{contactId}`. */\n public async get(options: { contactId: number }): Promise<Contact> {\n const contacts = await this.http.request<Contact[]>({\n method: 'GET',\n path: `/Contact/${options.contactId}`,\n });\n const contact = contacts[0];\n if (!contact) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return contact;\n }\n\n /** Creates a contact via `POST /Contact`. */\n public create(options: CreateContactOptions): Promise<Contact> {\n return this.http.request<Contact>({\n method: 'POST',\n path: '/Contact',\n body: toContactBody(options),\n });\n }\n\n /** Updates a contact via `PUT /Contact/{contactId}`. */\n public update(options: UpdateContactOptions): Promise<Contact> {\n const { contactId, ...fields } = options;\n return this.http.request<Contact>({\n method: 'PUT',\n path: `/Contact/${contactId}`,\n body: toContactBody(fields),\n });\n }\n\n /** Deletes a contact via `DELETE /Contact/{contactId}`. */\n public async delete(options: { contactId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/Contact/${options.contactId}`,\n });\n }\n\n /** Retrieves the next free customer number via `GET /Contact/Factory/getNextCustomerNumber`. */\n public getNextCustomerNumber(): Promise<string> {\n return this.http.request<string>({\n method: 'GET',\n path: '/Contact/Factory/getNextCustomerNumber',\n });\n }\n\n /** Retrieves contacts by a custom field value via `GET /Contact/Factory/findContactsByCustomFieldValue`. */\n public findByCustomFieldValue(\n options: FindContactsByCustomFieldValueOptions,\n ): Promise<Contact[]> {\n const { value, customFieldName, customFieldSettingId } = options;\n return this.http.request<Contact[]>({\n method: 'GET',\n path: '/Contact/Factory/findContactsByCustomFieldValue',\n query: {\n value,\n customFieldName,\n 'customFieldSetting[id]': customFieldSettingId,\n 'customFieldSetting[objectName]':\n customFieldSettingId === undefined\n ? undefined\n : 'ContactCustomFieldSetting',\n },\n });\n }\n\n /** Checks if a customer number is still free via `GET /Contact/Mapper/checkCustomerNumberAvailability`. */\n public checkCustomerNumberAvailability(options: {\n customerNumber: string;\n }): Promise<boolean> {\n return this.http.request<boolean>({\n method: 'GET',\n path: '/Contact/Mapper/checkCustomerNumberAvailability',\n query: { customerNumber: options.customerNumber },\n });\n }\n\n /** Retrieves the document counts of a contact via `GET /Contact/{contactId}/getTabsItemCount`. */\n public getTabsItemCount(options: {\n contactId: number;\n }): Promise<ContactTabsItemCount> {\n return this.http.request<ContactTabsItemCount>({\n method: 'GET',\n path: `/Contact/${options.contactId}/getTabsItemCount`,\n });\n }\n}\n\nfunction toContactBody(\n fields: Partial<CreateContactOptions>,\n): Record<string, unknown> {\n return {\n objectName: 'Contact',\n mapAll: true,\n category: toRef(fields.categoryId, 'Category'),\n parent: toRef(fields.parentId, 'Contact'),\n name: fields.name,\n surename: fields.surename,\n familyname: fields.familyname,\n name2: fields.name2,\n titel: fields.titel,\n academicTitle: fields.academicTitle,\n gender: fields.gender,\n customerNumber: fields.customerNumber,\n status: fields.status,\n description: fields.description,\n vatNumber: fields.vatNumber,\n taxNumber: fields.taxNumber,\n exemptVat: fields.exemptVat,\n bankAccount: fields.bankAccount,\n bankNumber: fields.bankNumber,\n defaultTimeToPay: fields.defaultTimeToPay,\n buyerReference: fields.buyerReference,\n governmentAgency: fields.governmentAgency,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n","import { toIsoDateTime, toVoucherDate } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type {\n DateInput,\n ListOptions,\n ModelRef,\n ModelRefResponse,\n} from '../types';\nimport { BaseResource } from './base';\n\n/**\n * Status of a credit note.\n *\n * - `100` draft\n * - `200` open / delivered\n * - `750` partially paid\n * - `1000` paid\n */\nexport type CreditNoteStatus = 100 | 200 | 750 | 1000;\n\n/**\n * Reason why the credit note was created. `ACCOUNTING_TYPE` is not supported\n * by bookkeeping system 2.0 and therefore not available.\n */\nexport type CreditNoteBookingCategory =\n 'PROVISION' | 'ROYALTY_ASSIGNED' | 'ROYALTY_UNASSIGNED' | 'UNDERACHIEVEMENT';\n\n/**\n * Way in which a credit note was sent to the end-customer: `VPR` printed,\n * `VP` postal, `VM` mailed, `VPDF` downloaded pdf.\n */\nexport type CreditNoteSendType = 'VPR' | 'VP' | 'VM' | 'VPDF';\n\nexport type CreditNoteBookingType =\n 'FULL_PAYMENT' | 'N' | 'CB' | 'O' | 'OF' | 'MTC';\n\nexport interface CreditNoteInput {\n creditNoteNumber: string;\n creditNoteDate: DateInput;\n contactId: number;\n status: CreditNoteStatus;\n /** Usually consists of a prefix and the credit note number. */\n header: string;\n bookingCategory: CreditNoteBookingCategory;\n /** The sevdesk user acting as the contact person. */\n contactPersonId: number;\n /** Defines the vat regulation, for example `1` for \"Umsatzsteuerpflichtige Umsätze\". */\n taxRuleId: number;\n /** Not used anymore, the tax rate of the positions is used instead. */\n taxRate: number;\n /** Text describing the vat regulation, for example `Umsatzsteuer 19%`. */\n taxText: string;\n /** Currency code according to ISO-4217. */\n currency: string;\n deliveryDate: DateInput;\n /** Can be omitted as the complete address is defined in `address`. */\n addressCountryId?: number;\n headText?: string;\n footText?: string;\n /** Complete address of the recipient. Line breaks are kept in the pdf. */\n address?: string;\n smallSettlement?: boolean;\n /** `true` if the position prices are net, `false` if they are gross. */\n showNet?: boolean;\n customerInternalNote?: string;\n sendDate?: DateInput;\n sendType?: CreditNoteSendType;\n}\n\nexport interface CreditNotePositionInput {\n unityId: number;\n quantity: number;\n taxRate: number;\n name?: string;\n /** Price of one unit. Is either net or gross, depending on `showNet`. */\n price?: number;\n text?: string;\n partId?: number;\n /** Starts at zero and is incremented for every further position. */\n positionNumber?: number;\n discount?: number;\n optional?: boolean;\n}\n\nexport interface SaveCreditNoteOptions {\n creditNote: CreditNoteInput;\n positions: CreditNotePositionInput[];\n}\n\nexport interface ListCreditNotesOptions extends ListOptions {\n status?: CreditNoteStatus;\n creditNoteNumber?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n contactId?: number;\n embed?: string[];\n}\n\nexport interface UpdateCreditNoteOptions {\n creditNoteId: number;\n creditNoteNumber?: string;\n creditNoteDate?: DateInput;\n status?: CreditNoteStatus;\n header?: string;\n headText?: string;\n footText?: string;\n address?: string;\n customerInternalNote?: string;\n deliveryDate?: DateInput;\n}\n\nexport interface SendCreditNoteViaEmailOptions {\n creditNoteId: number;\n toEmail: string;\n subject: string;\n /** Can contain html. */\n text: string;\n /** Send a copy of the email to yourself. */\n copy?: boolean;\n /** Ids of existing documents in your sevdesk account, separated by `,`. */\n additionalAttachments?: string;\n /** Mail addresses to be put as cc, separated by `,`. */\n ccEmail?: string;\n /** Mail addresses to be put as bcc, separated by `,`. */\n bccEmail?: string;\n}\n\nexport interface SendCreditNoteByOptions {\n creditNoteId: number;\n sendType: CreditNoteSendType;\n /**\n * Creates a draft for internal use. Neither the status of the credit note\n * nor the bookings for reports are changed.\n */\n sendDraft: boolean;\n}\n\nexport interface BookCreditNoteOptions {\n creditNoteId: number;\n /** Can also be a partial amount. */\n amount: number;\n date: DateInput;\n type: CreditNoteBookingType;\n checkAccountId: number;\n /**\n * Required for online check accounts. Must be omitted for offline check\n * accounts and cash registers, where the transaction is created automatically.\n */\n checkAccountTransactionId?: number;\n createFeed?: boolean;\n}\n\nexport interface ListCreditNotePositionsOptions extends ListOptions {\n creditNoteId?: number;\n embed?: string[];\n}\n\nexport interface CreditNote {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n createUser: ModelRefResponse;\n creditNoteNumber: string | null;\n contact: ModelRefResponse | null;\n creditNoteDate: string;\n status: string;\n header: string | null;\n headText: string | null;\n footText: string | null;\n addressCountry: ModelRefResponse | null;\n deliveryDate: string;\n smallSettlement: boolean | null;\n contactPerson: ModelRefResponse | null;\n taxRate: string | null;\n taxRule: ModelRefResponse;\n taxText: string | null;\n sendDate: string | null;\n address: string | null;\n currency: string | null;\n sumNet: string;\n sumTax: string;\n sumGross: string;\n sumDiscounts: string;\n sumNetForeignCurrency: string;\n sumTaxForeignCurrency: string;\n sumGrossForeignCurrency: string;\n sumDiscountsForeignCurrency: string;\n customerInternalNote: string | null;\n showNet: boolean;\n sendType: string | null;\n}\n\nexport interface CreditNotePosition {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n creditNote: ModelRefResponse;\n part: ModelRefResponse | null;\n quantity: string;\n price: string | null;\n priceNet: string | null;\n priceTax: string | null;\n priceGross: string | null;\n name: string | null;\n unity: ModelRefResponse;\n positionNumber: string | null;\n text: string | null;\n discount: string | null;\n optional: boolean | null;\n taxRate: string;\n sumDiscount: string | null;\n}\n\nexport interface CreditNoteDiscount {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: string;\n /** `1` for a discount, `0` for a surcharge. */\n discount: string;\n text: string;\n /** `1` if `value` is a percentage, `0` if it is an absolute amount. */\n percentage: string;\n value: string;\n /** `0` if the discount is net, `1` if it is gross. */\n isNet: string;\n}\n\nexport interface CreditNoteMail {\n id: string;\n objectName: string;\n additionalInformation: string | null;\n create: string;\n update: string;\n object: CreditNote;\n from: string;\n to: string;\n subject: string;\n text: string;\n sevClient: ModelRefResponse;\n}\n\nexport interface CreditNotePdf {\n filename: string;\n mimeType: string;\n base64encoded: boolean;\n /** The pdf document, base64 encoded. */\n content: string;\n}\n\nexport interface SaveCreditNoteResult {\n creditNote: CreditNote;\n positions: CreditNotePosition[];\n}\n\nexport interface CreateCreditNoteFromInvoiceResult extends SaveCreditNoteResult {\n discounts: CreditNoteDiscount[];\n}\n\nexport interface BookCreditNoteResult {\n id: string;\n objectName: string;\n additionalInformation: string | null;\n create: string;\n creditNote: ModelRefResponse;\n fromStatus: string;\n toStatus: string;\n /** Spelled with two `m` by the sevdesk API. */\n ammountPayed: string;\n bookingDate: string;\n sevClient: ModelRefResponse;\n}\n\nexport class CreditNotesResource extends BaseResource {\n /** Retrieves credit notes via `GET /CreditNote`. */\n public list(options: ListCreditNotesOptions = {}): Promise<CreditNote[]> {\n const {\n status,\n creditNoteNumber,\n startDate,\n endDate,\n contactId,\n limit,\n offset,\n embed,\n } = options;\n return this.http.request<CreditNote[]>({\n method: 'GET',\n path: '/CreditNote',\n query: {\n status,\n creditNoteNumber,\n startDate: toOptionalDate(startDate),\n endDate: toOptionalDate(endDate),\n 'contact[id]': contactId,\n 'contact[objectName]': contactId === undefined ? undefined : 'Contact',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single credit note via `GET /CreditNote/{creditNoteId}`. */\n public async get(options: {\n creditNoteId: number;\n embed?: string[];\n }): Promise<CreditNote> {\n const creditNotes = await this.http.request<CreditNote[]>({\n method: 'GET',\n path: `/CreditNote/${options.creditNoteId}`,\n query: { embed: options.embed },\n });\n const creditNote = creditNotes[0];\n if (!creditNote) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return creditNote;\n }\n\n /** Creates or updates a credit note with its positions via `POST /CreditNote/Factory/saveCreditNote`. */\n public async save(\n options: SaveCreditNoteOptions,\n ): Promise<SaveCreditNoteResult> {\n const { creditNote, positions } = options;\n const result = await this.http.request<{\n creditNote: CreditNote;\n creditNotePos: CreditNotePosition[];\n }>({\n method: 'POST',\n path: '/CreditNote/Factory/saveCreditNote',\n body: {\n creditNote: toCreditNoteBody(creditNote),\n creditNotePosSave: positions.map(toCreditNotePositionBody),\n creditNotePosDelete: null,\n discountSave: null,\n discountDelete: null,\n },\n });\n return {\n creditNote: result.creditNote,\n positions: result.creditNotePos,\n };\n }\n\n /** Creates a credit note from an invoice via `POST /CreditNote/Factory/createFromInvoice`. */\n public async createFromInvoice(options: {\n invoiceId: number;\n }): Promise<CreateCreditNoteFromInvoiceResult> {\n const result = await this.http.request<{\n creditNote: CreditNote;\n creditNotePos: CreditNotePosition[];\n discount: CreditNoteDiscount[];\n }>({\n method: 'POST',\n path: '/CreditNote/Factory/createFromInvoice',\n body: { invoice: { id: options.invoiceId, objectName: 'Invoice' } },\n });\n return {\n creditNote: result.creditNote,\n positions: result.creditNotePos,\n discounts: result.discount,\n };\n }\n\n /** Updates a credit note via `PUT /CreditNote/{creditNoteId}`. */\n public update(options: UpdateCreditNoteOptions): Promise<CreditNote> {\n const { creditNoteId, creditNoteDate, deliveryDate, ...rest } = options;\n return this.http.request<CreditNote>({\n method: 'PUT',\n path: `/CreditNote/${creditNoteId}`,\n body: {\n ...rest,\n creditNoteDate: toOptionalDate(creditNoteDate),\n deliveryDate: toOptionalDate(deliveryDate),\n },\n });\n }\n\n /** Deletes a credit note via `DELETE /CreditNote/{creditNoteId}`. */\n public async delete(options: { creditNoteId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/CreditNote/${options.creditNoteId}`,\n });\n }\n\n /** Sends a credit note via email using `POST /CreditNote/{creditNoteId}/sendViaEmail`. */\n public sendViaEmail(\n options: SendCreditNoteViaEmailOptions,\n ): Promise<CreditNoteMail[]> {\n const { creditNoteId, ...body } = options;\n return this.http.request<CreditNoteMail[]>({\n method: 'POST',\n path: `/CreditNote/${creditNoteId}/sendViaEmail`,\n body,\n });\n }\n\n /** Retrieves the pdf of a credit note via `GET /CreditNote/{creditNoteId}/getPdf`. */\n public getPdf(options: {\n creditNoteId: number;\n /** Prevents the credit note from being marked as sent. */\n preventSendBy?: boolean;\n }): Promise<CreditNotePdf> {\n return this.http.request<CreditNotePdf>({\n method: 'GET',\n path: `/CreditNote/${options.creditNoteId}/getPdf`,\n query: { preventSendBy: options.preventSendBy },\n });\n }\n\n /** Marks a credit note as sent via `PUT /CreditNote/{creditNoteId}/sendBy`. */\n public sendBy(options: SendCreditNoteByOptions): Promise<CreditNote> {\n const { creditNoteId, sendType, sendDraft } = options;\n return this.http.request<CreditNote>({\n method: 'PUT',\n path: `/CreditNote/${creditNoteId}/sendBy`,\n body: { sendType, sendDraft },\n });\n }\n\n /** Books an amount on a credit note via `PUT /CreditNote/{creditNoteId}/bookAmount`. */\n public book(options: BookCreditNoteOptions): Promise<BookCreditNoteResult> {\n const {\n creditNoteId,\n amount,\n date,\n type,\n checkAccountId,\n checkAccountTransactionId,\n createFeed,\n } = options;\n return this.http.request<BookCreditNoteResult>({\n method: 'PUT',\n path: `/CreditNote/${creditNoteId}/bookAmount`,\n body: {\n amount,\n date: toIsoDateTime(date),\n type,\n checkAccount: { id: checkAccountId, objectName: 'CheckAccount' },\n checkAccountTransaction: toRef(\n checkAccountTransactionId,\n 'CheckAccountTransaction',\n ),\n createFeed,\n },\n });\n }\n\n /** Enshrines a credit note via `PUT /CreditNote/{creditNoteId}/enshrine`. This cannot be undone. */\n public async enshrine(options: { creditNoteId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'PUT',\n path: `/CreditNote/${options.creditNoteId}/enshrine`,\n });\n }\n\n /** Resets the credit note status to open via `PUT /CreditNote/{creditNoteId}/resetToOpen`. */\n public resetToOpen(options: { creditNoteId: number }): Promise<CreditNote> {\n return this.http.request<CreditNote>({\n method: 'PUT',\n path: `/CreditNote/${options.creditNoteId}/resetToOpen`,\n });\n }\n\n /** Resets the credit note status to draft via `PUT /CreditNote/{creditNoteId}/resetToDraft`. */\n public resetToDraft(options: { creditNoteId: number }): Promise<CreditNote> {\n return this.http.request<CreditNote>({\n method: 'PUT',\n path: `/CreditNote/${options.creditNoteId}/resetToDraft`,\n });\n }\n\n /** Retrieves credit note positions via `GET /CreditNotePos`. */\n public listPositions(\n options: ListCreditNotePositionsOptions = {},\n ): Promise<CreditNotePosition[]> {\n const { creditNoteId, limit, offset, embed } = options;\n return this.http.request<CreditNotePosition[]>({\n method: 'GET',\n path: '/CreditNotePos',\n query: {\n 'creditNote[id]': creditNoteId,\n 'creditNote[objectName]':\n creditNoteId === undefined ? undefined : 'CreditNote',\n limit,\n offset,\n embed,\n },\n });\n }\n}\n\nfunction toCreditNoteBody(\n creditNote: CreditNoteInput,\n): Record<string, unknown> {\n return {\n objectName: 'CreditNote',\n mapAll: true,\n creditNoteNumber: creditNote.creditNoteNumber,\n creditNoteDate: toVoucherDate(creditNote.creditNoteDate),\n contact: { id: creditNote.contactId, objectName: 'Contact' },\n status: creditNote.status,\n header: creditNote.header,\n bookingCategory: creditNote.bookingCategory,\n contactPerson: { id: creditNote.contactPersonId, objectName: 'SevUser' },\n taxRule: { id: creditNote.taxRuleId, objectName: 'TaxRule' },\n taxRate: creditNote.taxRate,\n taxText: creditNote.taxText,\n currency: creditNote.currency,\n deliveryDate: toVoucherDate(creditNote.deliveryDate),\n addressCountry: toRef(creditNote.addressCountryId, 'StaticCountry'),\n headText: creditNote.headText,\n footText: creditNote.footText,\n address: creditNote.address,\n smallSettlement: creditNote.smallSettlement,\n showNet: creditNote.showNet,\n customerInternalNote: creditNote.customerInternalNote,\n sendDate: toOptionalDate(creditNote.sendDate),\n sendType: creditNote.sendType,\n };\n}\n\nfunction toCreditNotePositionBody(\n position: CreditNotePositionInput,\n): Record<string, unknown> {\n return {\n objectName: 'CreditNotePos',\n mapAll: true,\n unity: { id: position.unityId, objectName: 'Unity' },\n quantity: position.quantity,\n taxRate: position.taxRate,\n name: position.name,\n price: position.price,\n text: position.text,\n part: toRef(position.partId, 'Part'),\n positionNumber: position.positionNumber,\n discount: position.discount,\n optional: position.optional,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n\nfunction toOptionalDate(\n value: DateInput | undefined,\n): string | number | undefined {\n return value === undefined ? undefined : toVoucherDate(value);\n}\n","import { toIsoDateTime, toVoucherDate } from '../dates';\nimport type { Query } from '../http-client';\nimport type { DateInput } from '../types';\nimport { BaseResource } from './base';\n\n/** A file generated by an export, returned inside the response envelope. */\nexport interface ExportFile {\n filename: string;\n mimetype: string;\n base64Encoded: boolean;\n /** The file content, base64 encoded when `base64Encoded` is `true`. */\n content: string;\n}\n\n/** Progress of an export job. The job is finished once `current` reaches `total`. */\nexport interface ExportProgress {\n current: number;\n total: number;\n}\n\nexport interface ExportJobDownloadInfo {\n filename: string;\n /** Download url of the export file. */\n link: string;\n /** Expiry date of the download url. */\n linkExpireDate: string;\n}\n\nexport interface ExportConfigOptions {\n sevClientId: number;\n accountantNumber: number;\n accountantClientNumber: number;\n /** Begin of the accounting year, sent as Unix timestamp. */\n accountingYearBegin: DateInput;\n}\n\nexport interface ExportDatevCsvJobOptions {\n /** Sent as Unix timestamp. */\n startDate: DateInput;\n /** Sent as Unix timestamp. */\n endDate: DateInput;\n /**\n * The models to include, given as a string of letters: `E` (earnings),\n * `X` (expenditure), `T` (transactions), `C` (cash register) and\n * `D` (assets), for example `EXTCD`.\n */\n scope: string;\n /** Includes only documents paid between `startDate` and `endDate`. Defaults to `false`. */\n exportByPaydate?: boolean;\n /** Defaults to `true`. */\n includeEnshrined?: boolean;\n /** Enshrines all exported models. Defaults to `false`. */\n enshrineDocuments?: boolean;\n /** Defaults to `false`. */\n includeDocumentImages?: boolean;\n}\n\nexport interface ExportDatevXmlJobOptions {\n /** Sent as Unix timestamp. */\n startDate: DateInput;\n /** Sent as Unix timestamp. */\n endDate: DateInput;\n /**\n * The document types to include, given as a string of letters:\n * `E` (receipts, outgoing invoices and credit notes) and\n * `X` (expenditure documents), for example `EX`.\n */\n scope: string;\n /** Includes only documents paid between `startDate` and `endDate`. Defaults to `false`. */\n exportByPaydate?: boolean;\n /** Defaults to `true`. */\n includeEnshrined?: boolean;\n /** Defaults to `true`. */\n includeExportedDocuments?: boolean;\n /** Includes an XML file with the data of each document. Defaults to `true`. */\n includeDocumentXml?: boolean;\n}\n\nexport type ExportInvoiceType = 'RE' | 'SR' | 'TR' | 'AR' | 'ER' | 'WKR' | 'MA';\n\n/** Filters shared by all document exports. */\nexport interface ExportDocumentFilter {\n startDate?: DateInput;\n endDate?: DateInput;\n contactId?: number;\n startAmount?: number;\n endAmount?: number;\n}\n\nexport interface ExportInvoiceFilter extends ExportDocumentFilter {\n /**\n * `RE` (invoice), `SR` (cancellation invoice), `TR` (partial invoice),\n * `AR` (down payment invoice), `ER` (final invoice),\n * `WKR` (recurring invoice) and `MA` (dunning).\n */\n invoiceType?: ExportInvoiceType[];\n}\n\nexport interface ExportVoucherFilter extends ExportDocumentFilter {\n startPayDate?: DateInput;\n endPayDate?: DateInput;\n}\n\nexport interface ExportTransactionFilter {\n paymtPurpose?: string;\n /** The name of the payee or payer. */\n name?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n startAmount?: number;\n endAmount?: number;\n checkAccountId?: number;\n}\n\nexport interface ExportContactFilter {\n zip?: number;\n city?: string;\n countryId?: number;\n /** Exports only organisations. */\n depth?: boolean;\n /** Exports only people. */\n onlyPeople?: boolean;\n}\n\nexport interface ExportInvoicesOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportInvoiceFilter;\n}\n\nexport interface ExportCreditNotesOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportDocumentFilter;\n}\n\nexport interface ExportVouchersOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportVoucherFilter;\n}\n\nexport interface ExportTransactionsOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportTransactionFilter;\n}\n\nexport interface ExportContactsOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportContactFilter;\n}\n\n/** A value of a `sevQuery` parameter before it is flattened into bracket keys. */\nexport type ExportSevQueryValue =\n string | number | boolean | ExportSevQueryValue[] | ExportSevQueryObject;\n\nexport interface ExportSevQueryObject {\n [key: string]: ExportSevQueryValue | undefined;\n}\n\nexport interface ExportSevQueryOptions {\n modelName: string;\n limit?: number;\n filter?: ExportSevQueryObject;\n}\n\nexport class ExportsResource extends BaseResource {\n /**\n * Updates the export config via `PUT /SevClient/{sevClientId}/updateExportConfig`.\n *\n * The accounting year has to be set once before any DATEV export can be run.\n */\n public async updateExportConfig(options: ExportConfigOptions): Promise<void> {\n const {\n sevClientId,\n accountantNumber,\n accountantClientNumber,\n accountingYearBegin,\n } = options;\n await this.http.request<void>({\n method: 'PUT',\n path: `/SevClient/${sevClientId}/updateExportConfig`,\n body: {\n accountantNumber,\n accountantClientNumber,\n accountingYearBegin: toVoucherDate(accountingYearBegin),\n },\n });\n }\n\n /** Starts a DATEV CSV zip export via `GET /Export/createDatevCsvZipExportJob` and returns the job id. */\n public createDatevCsvZipExportJob(\n options: ExportDatevCsvJobOptions,\n ): Promise<string> {\n const { startDate, endDate, ...rest } = options;\n return this.http.request<string>({\n method: 'GET',\n path: '/Export/createDatevCsvZipExportJob',\n query: {\n startDate: toVoucherDate(startDate),\n endDate: toVoucherDate(endDate),\n ...rest,\n },\n });\n }\n\n /** Starts a DATEV XML zip export via `GET /Export/createDatevXmlZipExportJob` and returns the job id. */\n public createDatevXmlZipExportJob(\n options: ExportDatevXmlJobOptions,\n ): Promise<string> {\n const { startDate, endDate, ...rest } = options;\n return this.http.request<string>({\n method: 'GET',\n path: '/Export/createDatevXmlZipExportJob',\n query: {\n startDate: toVoucherDate(startDate),\n endDate: toVoucherDate(endDate),\n ...rest,\n },\n });\n }\n\n /** Generates the hash of an export job via `GET /Progress/generateDownloadHash`. */\n public generateDownloadHash(options: {\n jobId: string;\n }): Promise<ExportProgress[]> {\n return this.http.request<ExportProgress[]>({\n method: 'GET',\n path: '/Progress/generateDownloadHash',\n query: { jobId: options.jobId },\n });\n }\n\n /** Retrieves the progress of an export via `GET /Progress/getProgress`. */\n public getProgress(options: { hash: string }): Promise<ExportProgress[]> {\n return this.http.request<ExportProgress[]>({\n method: 'GET',\n path: '/Progress/getProgress',\n query: { hash: options.hash },\n });\n }\n\n /** Retrieves the download url of a finished export job via `GET /ExportJob/jobDownloadInfo`. */\n public getJobDownloadInfo(options: {\n jobId: string;\n }): Promise<ExportJobDownloadInfo[]> {\n return this.http.request<ExportJobDownloadInfo[]>({\n method: 'GET',\n path: '/ExportJob/jobDownloadInfo',\n query: { jobId: options.jobId },\n });\n }\n\n /** Exports invoices as CSV via `GET /Export/invoiceCsv`. */\n public exportInvoicesCsv(\n options: ExportInvoicesOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/invoiceCsv', options, {\n modelName: 'Invoice',\n limit: options.limit,\n filter: toExportInvoiceFilter(options.filter),\n });\n }\n\n /** Exports invoices as zip via `GET /Export/invoiceZip`. */\n public exportInvoicesZip(\n options: ExportInvoicesOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/invoiceZip', options, {\n modelName: 'Invoice',\n limit: options.limit,\n filter: toExportInvoiceFilter(options.filter),\n });\n }\n\n /** Exports credit notes as CSV via `GET /Export/creditNoteCsv`. */\n public exportCreditNotesCsv(\n options: ExportCreditNotesOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/creditNoteCsv', options, {\n modelName: 'CreditNote',\n limit: options.limit,\n filter: toExportDocumentFilter(options.filter),\n });\n }\n\n /** Exports vouchers as CSV via `GET /Export/voucherListCsv`. */\n public exportVouchersCsv(\n options: ExportVouchersOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/voucherListCsv', options, {\n modelName: 'Voucher',\n limit: options.limit,\n filter: toExportVoucherFilter(options.filter),\n });\n }\n\n /** Exports vouchers as zip via `GET /Export/voucherZip`. */\n public exportVouchersZip(\n options: ExportVouchersOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/voucherZip', options, {\n modelName: 'Voucher',\n limit: options.limit,\n filter: toExportVoucherFilter(options.filter),\n });\n }\n\n /** Exports transactions as CSV via `GET /Export/transactionsCsv`. */\n public exportTransactionsCsv(\n options: ExportTransactionsOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/transactionsCsv', options, {\n modelName: 'CheckAccountTransaction',\n limit: options.limit,\n filter: toExportTransactionFilter(options.filter),\n });\n }\n\n /** Exports contacts as CSV via `GET /Export/contactListCsv`. */\n public exportContactsCsv(\n options: ExportContactsOptions = {},\n ): Promise<ExportFile> {\n return this.requestExport('/Export/contactListCsv', options, {\n modelName: 'Contact',\n limit: options.limit,\n filter: toExportContactFilter(options.filter),\n });\n }\n\n private requestExport(\n path: string,\n options: { download?: boolean },\n sevQuery: ExportSevQueryOptions,\n ): Promise<ExportFile> {\n return this.http.request<ExportFile>({\n method: 'GET',\n path,\n query: {\n download: options.download,\n ...toExportSevQueryParams(sevQuery),\n },\n });\n }\n}\n\n/**\n * Flattens a `sevQuery` object into the deep bracket query parameters expected\n * by the export and report endpoints, e.g. `sevQuery[filter][startDate]`.\n */\nexport function toExportSevQueryParams(sevQuery: ExportSevQueryOptions): Query {\n const query: Query = {};\n flattenSevQueryValue(\n 'sevQuery',\n { objectName: 'SevQuery', ...sevQuery },\n query,\n );\n return query;\n}\n\n/** Maps a document export filter to its `sevQuery` representation. */\nexport function toExportDocumentFilter(\n filter: ExportDocumentFilter = {},\n): ExportSevQueryObject {\n return {\n startDate: toOptionalIsoDateTime(filter.startDate),\n endDate: toOptionalIsoDateTime(filter.endDate),\n contact: toRef(filter.contactId, 'Contact'),\n startAmount: filter.startAmount,\n endAmount: filter.endAmount,\n };\n}\n\n/** Maps an invoice export filter to its `sevQuery` representation. */\nexport function toExportInvoiceFilter(\n filter: ExportInvoiceFilter = {},\n): ExportSevQueryObject {\n return {\n ...toExportDocumentFilter(filter),\n invoiceType: filter.invoiceType,\n };\n}\n\n/** Maps a voucher export filter to its `sevQuery` representation. */\nexport function toExportVoucherFilter(\n filter: ExportVoucherFilter = {},\n): ExportSevQueryObject {\n return {\n ...toExportDocumentFilter(filter),\n startPayDate: toOptionalIsoDateTime(filter.startPayDate),\n endPayDate: toOptionalIsoDateTime(filter.endPayDate),\n };\n}\n\n/** Maps a contact export filter to its `sevQuery` representation. */\nexport function toExportContactFilter(\n filter: ExportContactFilter = {},\n): ExportSevQueryObject {\n return {\n zip: filter.zip,\n city: filter.city,\n country: toRef(filter.countryId, 'StaticCountry'),\n depth: filter.depth,\n onlyPeople: filter.onlyPeople,\n };\n}\n\nfunction toExportTransactionFilter(\n filter: ExportTransactionFilter = {},\n): ExportSevQueryObject {\n return {\n paymtPurpose: filter.paymtPurpose,\n name: filter.name,\n startDate: toOptionalIsoDateTime(filter.startDate),\n endDate: toOptionalIsoDateTime(filter.endDate),\n startAmount: filter.startAmount,\n endAmount: filter.endAmount,\n checkAccount: toRef(filter.checkAccountId, 'CheckAccount'),\n };\n}\n\nfunction flattenSevQueryValue(\n key: string,\n value: ExportSevQueryValue,\n query: Query,\n): void {\n if (Array.isArray(value)) {\n value.forEach((item, index) =>\n flattenSevQueryValue(`${key}[${index}]`, item, query),\n );\n return;\n }\n if (typeof value === 'object') {\n for (const [nestedKey, nestedValue] of Object.entries(value)) {\n if (nestedValue !== undefined) {\n flattenSevQueryValue(`${key}[${nestedKey}]`, nestedValue, query);\n }\n }\n return;\n }\n query[key] = value;\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ExportSevQueryObject | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n\nfunction toOptionalIsoDateTime(\n value: DateInput | undefined,\n): string | undefined {\n return value === undefined ? undefined : toIsoDateTime(value);\n}\n","import { toIsoDateTime, toVoucherDate } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type {\n DateInput,\n ListOptions,\n ModelRef,\n ModelRefResponse,\n} from '../types';\nimport { BaseResource } from './base';\n\n/**\n * Status of an invoice.\n *\n * - `50` deactivated recurring invoice, only relevant for recurring invoices\n * - `100` draft, not sent to the end-customer yet and still changeable\n * - `200` open if the pay date is not exceeded, due if it is\n * - `750` partially paid, only set for invoices partially paid after\n * release 4.181 (June 13, 2024). Older ones stay at `200`, use\n * `isPartiallyPaid` for them.\n * - `1000` paid\n */\nexport type InvoiceStatus = 50 | 100 | 200 | 750 | 1000;\n\n/**\n * Type of an invoice.\n *\n * - `RE` normal invoice\n * - `WKR` recurring invoice\n * - `SR` cancellation invoice\n * - `MA` invoice reminder\n * - `TR` partial invoice\n * - `AR` advance invoice\n * - `ER` final invoice\n */\nexport type InvoiceType = 'RE' | 'WKR' | 'SR' | 'MA' | 'TR' | 'AR' | 'ER';\n\n/** `VPR` printed, `VPDF` downloaded, `VM` mailed, `VP` postal. */\nexport type InvoiceSendType = 'VPR' | 'VPDF' | 'VM' | 'VP';\n\nexport type InvoiceBookingType =\n 'FULL_PAYMENT' | 'N' | 'CB' | 'O' | 'OF' | 'MTC';\n\nexport interface InvoiceInput {\n /**\n * `100` for a draft invoice. Invoices can only be created as drafts, the\n * status is advanced by the dedicated endpoints.\n */\n status: 100;\n invoiceDate: DateInput;\n contactId: number;\n /** The sevdesk user acting as contact person for this invoice. */\n contactPersonId: number;\n invoiceType: InvoiceType;\n /** Currency code according to ISO-4217, for example `EUR`. */\n currency: string;\n /** Defines the vat regulation, for example `1` for \"Umsatzsteuerpflichtige Umsätze\". */\n taxRuleId: number;\n /** Text describing the chosen vat regulation, for example `Umsatzsteuer 19%`. */\n taxText: string;\n invoiceNumber?: string;\n /** Usually consists of a prefix and the invoice number. */\n header?: string;\n headText?: string;\n footText?: string;\n /** The complete recipient address, line breaks are kept on the pdf. */\n address?: string;\n /** Can be omitted when the complete address is given in `address`. */\n addressCountryId?: number;\n /** Percentage the end-customer gets when paying early. Defaults to `0`. */\n discount?: number;\n /** Days the end-customer has to pay the invoice. */\n timeToPay?: number;\n deliveryDate?: DateInput;\n deliveryDateUntil?: DateInput;\n payDate?: DateInput;\n paymentMethodId?: number;\n /** `true` if the sevdesk account falls under the small entrepreneur scheme. */\n smallSettlement?: boolean;\n /** `true` if the position prices are net values, `false` if they are gross. */\n showNet?: boolean;\n /** Shown as \"Referenz/Bestellnummer\" in sevdesk. */\n customerInternalNote?: string;\n propertyIsEInvoice?: boolean;\n}\n\nexport interface InvoicePositionInput {\n quantity: number;\n taxRate: number;\n /** The unit in which the position is measured. */\n unityId: number;\n name?: string;\n /** Net or gross price of one unit, depending on the invoice `showNet`. */\n price?: number;\n /** Part from the sevdesk inventory used in the position. */\n partId?: number;\n text?: string;\n /** Starts at zero and orders the positions of an invoice. */\n positionNumber?: number;\n discount?: number;\n}\n\nexport interface SaveInvoiceOptions {\n invoice: InvoiceInput;\n positions: InvoicePositionInput[];\n /** Takes the first address of the contact as the invoice address. */\n takeDefaultAddress?: boolean;\n}\n\nexport interface ListInvoicesOptions extends ListOptions {\n status?: InvoiceStatus;\n invoiceNumber?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n contactId?: number;\n embed?: string[];\n}\n\nexport interface CreateInvoiceFromOrderOptions {\n orderId: number;\n /** Defines how `amount` is interpreted. */\n type?: 'percentage' | 'net' | 'gross';\n amount?: number;\n /** `RE` final invoice, `TR` partial invoice, `AR` advance invoice. */\n partialType?: 'RE' | 'TR' | 'AR';\n}\n\nexport interface SendInvoiceViaEmailOptions {\n invoiceId: number;\n toEmail: string;\n subject: string;\n /** Can contain html. */\n text: string;\n /** Sends a copy of the email to yourself. */\n copy?: boolean;\n /** Ids of existing sevdesk documents, separated by `,`. */\n additionalAttachments?: string;\n /** Mail addresses separated by `,`. */\n ccEmail?: string;\n /** Mail addresses separated by `,`. */\n bccEmail?: string;\n /** Attaches the xml of the e-invoice instead of the pdf. */\n sendXml?: boolean;\n}\n\nexport interface SendInvoiceByOptions {\n invoiceId: number;\n sendType: InvoiceSendType;\n /** Creates a draft for internal use without changing the status. */\n sendDraft?: boolean;\n}\n\nexport interface BookInvoiceOptions {\n invoiceId: number;\n /** Can also be a partial amount. */\n amount: number;\n date: DateInput;\n type: InvoiceBookingType;\n checkAccountId: number;\n /**\n * Required for online check accounts. Must be omitted for offline check\n * accounts and cash registers, where the transaction is created automatically.\n */\n checkAccountTransactionId?: number;\n createFeed?: boolean;\n}\n\nexport interface Invoice {\n id: string;\n objectName: string;\n invoiceNumber: string | null;\n contact: ModelRefResponse | null;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n invoiceDate: string;\n header: string | null;\n headText: string | null;\n footText: string | null;\n timeToPay: string | null;\n discountTime: string | null;\n discount: string;\n address: string | null;\n addressCountry: ModelRefResponse | null;\n payDate: string | null;\n createUser: ModelRefResponse;\n deliveryDate: string | null;\n deliveryDateUntil: string | null;\n status: string;\n smallSettlement: boolean;\n contactPerson: ModelRefResponse;\n taxRate: string;\n taxRule: ModelRefResponse;\n taxText: string;\n dunningLevel: string | null;\n paymentMethod: ModelRefResponse | null;\n costCentre: ModelRefResponse | null;\n sendDate: string | null;\n origin: ModelRefResponse | null;\n invoiceType: string;\n accountIntervall: string | null;\n accountNextInvoice: string | null;\n reminderTotal: string | null;\n reminderDebit: string | null;\n reminderDeadline: string | null;\n reminderCharge: string | null;\n currency: string;\n sumNet: string;\n sumTax: string;\n sumGross: string;\n sumDiscounts: string;\n sumNetForeignCurrency: string;\n sumTaxForeignCurrency: string;\n sumGrossForeignCurrency: string;\n sumDiscountsForeignCurrency: string;\n sumNetAccounting: string;\n sumTaxAccounting: string;\n sumGrossAccounting: string;\n paidAmount: number | null;\n customerInternalNote: string | null;\n showNet: boolean;\n enshrined: string | null;\n sendType: string | null;\n}\n\nexport interface InvoicePosition {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n invoice: ModelRefResponse;\n part: ModelRefResponse | null;\n quantity: string;\n price: string | null;\n name: string | null;\n unity: ModelRefResponse;\n positionNumber: string;\n text: string | null;\n discount: string | null;\n taxRate: string;\n sumDiscount: string | null;\n sumNetAccounting: string;\n sumTaxAccounting: string;\n sumGrossAccounting: string;\n priceNet: string;\n priceGross: string;\n priceTax: string;\n}\n\nexport interface SaveInvoiceResult {\n invoice: Invoice;\n positions: InvoicePosition[];\n}\n\nexport interface RenderInvoiceResult {\n thumbs: unknown[];\n pages: number;\n /** Internal id of the rendered document. */\n docId: string;\n parameters: InvoiceRenderParameter[];\n}\n\nexport interface InvoiceRenderParameter {\n key: string;\n name: string;\n values: { name: string; translationCade: string; value: string }[];\n visible: boolean;\n value: string;\n}\n\nexport interface InvoicePdf {\n filename: string;\n mimeType: string;\n base64encoded: boolean;\n /** The base64 encoded pdf document. */\n content: string;\n}\n\nexport interface InvoiceEmail {\n id: string;\n objectName: string;\n create: string;\n update: string;\n /** The invoice the email was sent for. */\n object: Invoice;\n from: string;\n to: string;\n subject: string;\n text: string | null;\n sevClient: ModelRefResponse;\n}\n\nexport interface BookInvoiceResult {\n id: string;\n objectName: string;\n additionalInformation: string | null;\n create: string;\n invoice: ModelRefResponse;\n fromStatus: string;\n toStatus: string;\n /** Spelled `ammountPayed` by the sevdesk API. */\n ammountPayed: string;\n bookingDate: string;\n sevClient: ModelRefResponse;\n}\n\nexport class InvoicesResource extends BaseResource {\n /** Retrieves invoices via `GET /Invoice`. */\n public list(options: ListInvoicesOptions = {}): Promise<Invoice[]> {\n const {\n status,\n invoiceNumber,\n startDate,\n endDate,\n contactId,\n limit,\n offset,\n embed,\n } = options;\n return this.http.request<Invoice[]>({\n method: 'GET',\n path: '/Invoice',\n query: {\n status,\n invoiceNumber,\n startDate: toOptionalInvoiceDate(startDate),\n endDate: toOptionalInvoiceDate(endDate),\n 'contact[id]': contactId,\n 'contact[objectName]': contactId === undefined ? undefined : 'Contact',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single invoice via `GET /Invoice/{invoiceId}`. */\n public async get(options: {\n invoiceId: number;\n embed?: string[];\n }): Promise<Invoice> {\n const invoices = await this.http.request<Invoice[]>({\n method: 'GET',\n path: `/Invoice/${options.invoiceId}`,\n query: { embed: options.embed },\n });\n const invoice = invoices[0];\n if (!invoice) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return invoice;\n }\n\n /**\n * Creates or updates an invoice with its positions via\n * `POST /Invoice/Factory/saveInvoice`.\n *\n * Invoices can only be created as drafts. Use `sendViaEmail`, `sendBy` and\n * `book` to advance the status afterwards.\n */\n public async save(options: SaveInvoiceOptions): Promise<SaveInvoiceResult> {\n const { invoice, positions, takeDefaultAddress } = options;\n const result = await this.http.request<{\n invoice: Invoice;\n invoicePos: InvoicePosition[];\n }>({\n method: 'POST',\n path: '/Invoice/Factory/saveInvoice',\n body: {\n invoice: toInvoiceBody(invoice),\n invoicePosSave: positions.map(toInvoicePositionBody),\n invoicePosDelete: null,\n discountSave: null,\n discountDelete: null,\n ...(takeDefaultAddress === undefined ? {} : { takeDefaultAddress }),\n },\n });\n return { invoice: result.invoice, positions: result.invoicePos };\n }\n\n /** Creates an invoice from an order via `POST /Invoice/Factory/createInvoiceFromOrder`. */\n public createFromOrder(\n options: CreateInvoiceFromOrderOptions,\n ): Promise<Invoice> {\n const { orderId, type, amount, partialType } = options;\n return this.http.request<Invoice>({\n method: 'POST',\n path: '/Invoice/Factory/createInvoiceFromOrder',\n body: {\n order: { id: orderId, objectName: 'Order' },\n type,\n amount,\n partialType,\n },\n });\n }\n\n /** Creates a reminder for an invoice via `POST /Invoice/Factory/createInvoiceReminder`. */\n public createReminder(options: { invoiceId: number }): Promise<Invoice> {\n return this.http.request<Invoice>({\n method: 'POST',\n path: '/Invoice/Factory/createInvoiceReminder',\n body: {\n invoice: { id: options.invoiceId, objectName: 'Invoice' },\n },\n });\n }\n\n /** Retrieves the positions of an invoice via `GET /Invoice/{invoiceId}/getPositions`. */\n public getPositions(\n options: { invoiceId: number; embed?: string[] } & ListOptions,\n ): Promise<InvoicePosition[]> {\n const { invoiceId, limit, offset, embed } = options;\n return this.http.request<InvoicePosition[]>({\n method: 'GET',\n path: `/Invoice/${invoiceId}/getPositions`,\n query: { limit, offset, embed },\n });\n }\n\n /**\n * Checks if an invoice is partially paid via\n * `GET /Invoice/{invoiceId}/getIsPartiallyPaid`.\n *\n * Fully paid invoices are regarded as not partially paid.\n */\n public isPartiallyPaid(options: { invoiceId: number }): Promise<boolean> {\n return this.http.request<boolean>({\n method: 'GET',\n path: `/Invoice/${options.invoiceId}/getIsPartiallyPaid`,\n });\n }\n\n /**\n * Cancels an invoice via `POST /Invoice/{invoiceId}/cancelInvoice` and\n * returns the created cancellation invoice.\n */\n public cancel(options: { invoiceId: number }): Promise<Invoice> {\n return this.http.request<Invoice>({\n method: 'POST',\n path: `/Invoice/${options.invoiceId}/cancelInvoice`,\n });\n }\n\n /** Renders the pdf document of an invoice via `POST /Invoice/{invoiceId}/render`. */\n public render(options: {\n invoiceId: number;\n forceReload?: boolean;\n }): Promise<RenderInvoiceResult> {\n return this.http.request<RenderInvoiceResult>({\n method: 'POST',\n path: `/Invoice/${options.invoiceId}/render`,\n body: { forceReload: options.forceReload },\n });\n }\n\n /**\n * Sends an invoice to the end-customer via\n * `POST /Invoice/{invoiceId}/sendViaEmail`. This marks the invoice as sent.\n */\n public sendViaEmail(\n options: SendInvoiceViaEmailOptions,\n ): Promise<InvoiceEmail> {\n const { invoiceId, ...body } = options;\n return this.http.request<InvoiceEmail>({\n method: 'POST',\n path: `/Invoice/${invoiceId}/sendViaEmail`,\n body,\n });\n }\n\n /** Retrieves the pdf document of an invoice via `GET /Invoice/{invoiceId}/getPdf`. */\n public getPdf(options: {\n invoiceId: number;\n /** Prevents marking the invoice as sent. */\n preventSendBy?: boolean;\n }): Promise<InvoicePdf> {\n return this.http.request<InvoicePdf>({\n method: 'GET',\n path: `/Invoice/${options.invoiceId}/getPdf`,\n query: { preventSendBy: options.preventSendBy },\n });\n }\n\n /** Retrieves the xml of an e-invoice via `GET /Invoice/{invoiceId}/getXml`. */\n public getXml(options: { invoiceId: number }): Promise<string> {\n return this.http.request<string>({\n method: 'GET',\n path: `/Invoice/${options.invoiceId}/getXml`,\n });\n }\n\n /** Marks an invoice as sent via `PUT /Invoice/{invoiceId}/sendBy`. */\n public sendBy(options: SendInvoiceByOptions): Promise<Invoice> {\n const { invoiceId, sendType, sendDraft } = options;\n return this.http.request<Invoice>({\n method: 'PUT',\n path: `/Invoice/${invoiceId}/sendBy`,\n body: { sendType, sendDraft },\n });\n }\n\n /** Books an amount on an invoice via `PUT /Invoice/{invoiceId}/bookAmount`. */\n public book(options: BookInvoiceOptions): Promise<BookInvoiceResult> {\n const {\n invoiceId,\n amount,\n date,\n type,\n checkAccountId,\n checkAccountTransactionId,\n createFeed,\n } = options;\n return this.http.request<BookInvoiceResult>({\n method: 'PUT',\n path: `/Invoice/${invoiceId}/bookAmount`,\n body: {\n amount,\n date: toIsoDateTime(date),\n type,\n checkAccount: { id: checkAccountId, objectName: 'CheckAccount' },\n checkAccountTransaction: toRef(\n checkAccountTransactionId,\n 'CheckAccountTransaction',\n ),\n createFeed,\n },\n });\n }\n\n /**\n * Enshrines an invoice via `PUT /Invoice/{invoiceId}/enshrine`.\n *\n * Requires a status of at least `200` and cannot be undone.\n */\n public async enshrine(options: { invoiceId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'PUT',\n path: `/Invoice/${options.invoiceId}/enshrine`,\n });\n }\n\n /**\n * Resets the invoice status to open via `PUT /Invoice/{invoiceId}/resetToOpen`.\n *\n * Linked transactions are unlinked. Not possible for enshrined invoices.\n */\n public resetToOpen(options: { invoiceId: number }): Promise<Invoice> {\n return this.http.request<Invoice>({\n method: 'PUT',\n path: `/Invoice/${options.invoiceId}/resetToOpen`,\n });\n }\n\n /**\n * Resets the invoice status to draft via `PUT /Invoice/{invoiceId}/resetToDraft`.\n *\n * Only possible for invoices with the status `200`.\n */\n public resetToDraft(options: { invoiceId: number }): Promise<Invoice> {\n return this.http.request<Invoice>({\n method: 'PUT',\n path: `/Invoice/${options.invoiceId}/resetToDraft`,\n });\n }\n}\n\nfunction toInvoiceBody(invoice: InvoiceInput): Record<string, unknown> {\n return {\n objectName: 'Invoice',\n mapAll: true,\n invoiceNumber: invoice.invoiceNumber,\n contact: { id: invoice.contactId, objectName: 'Contact' },\n contactPerson: { id: invoice.contactPersonId, objectName: 'SevUser' },\n invoiceDate: toVoucherDate(invoice.invoiceDate),\n header: invoice.header,\n headText: invoice.headText,\n footText: invoice.footText,\n timeToPay: invoice.timeToPay,\n discount: invoice.discount ?? 0,\n address: invoice.address,\n addressCountry: toRef(invoice.addressCountryId, 'StaticCountry'),\n payDate: toOptionalInvoiceDate(invoice.payDate),\n deliveryDate: toOptionalInvoiceDate(invoice.deliveryDate),\n deliveryDateUntil: toOptionalInvoiceDate(invoice.deliveryDateUntil),\n status: invoice.status,\n smallSettlement: invoice.smallSettlement,\n taxRate: 0,\n taxRule: { id: invoice.taxRuleId, objectName: 'TaxRule' },\n taxText: invoice.taxText,\n paymentMethod: toRef(invoice.paymentMethodId, 'PaymentMethod'),\n invoiceType: invoice.invoiceType,\n currency: invoice.currency,\n showNet: invoice.showNet,\n customerInternalNote: invoice.customerInternalNote,\n propertyIsEInvoice: invoice.propertyIsEInvoice,\n };\n}\n\nfunction toInvoicePositionBody(\n position: InvoicePositionInput,\n): Record<string, unknown> {\n return {\n objectName: 'InvoicePos',\n mapAll: true,\n invoice: null,\n part: toRef(position.partId, 'Part'),\n quantity: position.quantity,\n price: position.price,\n name: position.name,\n unity: { id: position.unityId, objectName: 'Unity' },\n positionNumber: position.positionNumber,\n text: position.text,\n discount: position.discount,\n taxRate: position.taxRate,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n\nfunction toOptionalInvoiceDate(\n value: DateInput | undefined,\n): string | number | undefined {\n return value === undefined ? undefined : toVoucherDate(value);\n}\n","import { toVoucherDate } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type {\n DateInput,\n ListOptions,\n ModelRef,\n ModelRefResponse,\n} from '../types';\nimport { BaseResource } from './base';\n\n/**\n * Status of an order.\n *\n * - `100` draft\n * - `200` delivered\n * - `300` rejected / cancelled\n * - `500` accepted\n * - `750` partially calculated\n * - `1000` calculated\n */\nexport type OrderStatus = 100 | 200 | 300 | 500 | 750 | 1000;\n\n/**\n * Type of an order: `AN` estimate / proposal, `AB` order confirmation,\n * `LI` delivery note.\n */\nexport type OrderType = 'AN' | 'AB' | 'LI';\n\n/**\n * Way in which an order was sent to the end-customer: `VPR` printed,\n * `VP` postal, `VM` mailed, `VPDF` downloaded pdf.\n */\nexport type OrderSendType = 'VPR' | 'VP' | 'VM' | 'VPDF';\n\nexport interface OrderInput {\n orderNumber: string;\n orderDate: DateInput;\n contactId: number;\n status: OrderStatus;\n orderType: OrderType;\n /** Usually consists of a prefix and the order number. */\n header: string;\n /** Version of the order, used for multiple drafts. Starts at `0`. */\n version: number;\n addressCountryId: number;\n /** The sevdesk user acting as the contact person. */\n contactPersonId: number;\n /** Defines the vat regulation, for example `1` for \"Umsatzsteuerpflichtige Umsätze\". */\n taxRuleId: number;\n /** Not used anymore, the tax rate of the positions is used instead. */\n taxRate: number;\n /** Text describing the vat regulation, for example `Umsatzsteuer 19%`. */\n taxText: string;\n /** Currency code according to ISO-4217. */\n currency: string;\n headText?: string;\n footText?: string;\n deliveryTerms?: string;\n paymentTerms?: string;\n smallSettlement?: boolean;\n /** `true` if the position prices are net, `false` if they are gross. */\n showNet?: boolean;\n /** Complete address of the recipient. Line breaks are kept in the pdf. */\n address?: string;\n customerInternalNote?: string;\n sendDate?: DateInput;\n sendType?: OrderSendType;\n}\n\nexport interface OrderPositionInput {\n unityId: number;\n quantity: number;\n taxRate: number;\n name?: string;\n /** Price of one unit. Is either net or gross, depending on `showNet`. */\n price?: number;\n text?: string;\n partId?: number;\n /** Starts at zero and is incremented for every further position. */\n positionNumber?: number;\n discount?: number;\n optional?: boolean;\n}\n\nexport interface SaveOrderOptions {\n order: OrderInput;\n positions: OrderPositionInput[];\n}\n\nexport interface ListOrdersOptions extends ListOptions {\n status?: OrderStatus;\n orderNumber?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n contactId?: number;\n embed?: string[];\n}\n\nexport interface UpdateOrderOptions {\n orderId: number;\n orderNumber?: string;\n orderDate?: DateInput;\n status?: OrderStatus;\n header?: string;\n headText?: string;\n footText?: string;\n deliveryTerms?: string;\n paymentTerms?: string;\n address?: string;\n customerInternalNote?: string;\n version?: number;\n}\n\nexport interface GetOrderRelatedObjectsOptions {\n orderId: number;\n /** Include the order itself in the result. */\n includeItself?: boolean;\n sortByType?: boolean;\n embed?: string[];\n}\n\nexport interface SendOrderViaEmailOptions {\n orderId: number;\n toEmail: string;\n subject: string;\n /** Can contain html. */\n text: string;\n /** Send a copy of the email to yourself. */\n copy?: boolean;\n /** Ids of existing documents in your sevdesk account, separated by `,`. */\n additionalAttachments?: string;\n /** Mail addresses to be put as cc, separated by `,`. */\n ccEmail?: string;\n /** Mail addresses to be put as bcc, separated by `,`. */\n bccEmail?: string;\n}\n\nexport interface SendOrderByOptions {\n orderId: number;\n sendType: OrderSendType;\n /**\n * Creates a draft for internal use. The status of the order is not changed.\n */\n sendDraft: boolean;\n}\n\nexport interface ListOrderPositionsOptions extends ListOptions {\n orderId?: number;\n embed?: string[];\n}\n\nexport interface UpdateOrderPositionOptions {\n orderPosId: number;\n quantity?: number;\n price?: number;\n priceTax?: number;\n priceGross?: number;\n name?: string;\n text?: string;\n positionNumber?: number;\n discount?: number;\n optional?: boolean;\n taxRate?: number;\n unityId?: number;\n partId?: number;\n}\n\nexport interface Order {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n createUser: ModelRefResponse;\n orderNumber: string;\n contact: ModelRefResponse;\n orderDate: string;\n status: string;\n header: string;\n headText: string | null;\n footText: string | null;\n addressCountry: ModelRefResponse | null;\n deliveryTerms: string | null;\n paymentTerms: string | null;\n origin: ModelRefResponse | null;\n version: string;\n smallSettlement: boolean;\n contactPerson: ModelRefResponse;\n taxRate: string;\n taxRule: ModelRefResponse;\n taxText: string;\n orderType: string;\n sendDate: string | null;\n address: string | null;\n currency: string;\n sumNet: string;\n sumTax: string;\n sumGross: string;\n sumDiscounts: string;\n sumNetForeignCurrency: string;\n sumTaxForeignCurrency: string;\n sumGrossForeignCurrency: string;\n sumDiscountsForeignCurrency: string;\n customerInternalNote: string | null;\n showNet: boolean;\n sendType: string | null;\n}\n\nexport interface OrderPosition {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n order: ModelRefResponse;\n part: ModelRefResponse | null;\n quantity: string;\n price: string | null;\n priceNet: string | null;\n priceTax: string | null;\n priceGross: string | null;\n name: string | null;\n unity: ModelRefResponse;\n positionNumber: string | null;\n text: string | null;\n discount: string | null;\n optional: boolean | null;\n taxRate: string;\n sumDiscount: string | null;\n}\n\nexport interface OrderDiscount {\n id: string;\n objectName: string;\n create: string;\n update: string;\n /** The order the discount belongs to. */\n object: ModelRefResponse;\n sevClient: string;\n text: string;\n /** `1` if `value` is a percentage, `0` if it is an absolute amount. */\n percentage: string;\n value: string;\n /** `0` if the discount is gross, `1` if it is net. */\n isNet: string;\n}\n\n/**\n * An object related to an order, for example an invoice or another order.\n * Only `id` and `objectName` are guaranteed, all further fields depend on the\n * type of the related object.\n */\nexport interface OrderRelatedObject {\n id: string;\n objectName: string;\n [key: string]: unknown;\n}\n\nexport interface OrderMail {\n id: string;\n objectName: string;\n create: string;\n update: string;\n object: Order;\n from: string;\n to: string;\n subject: string;\n text: string | null;\n sevClient: ModelRefResponse;\n cc: string | null;\n bcc: string | null;\n arrived: string | null;\n}\n\nexport interface OrderPdf {\n filename: string;\n mimeType: string;\n base64encoded: boolean;\n /** The pdf document, base64 encoded. */\n content: string;\n}\n\nexport interface SaveOrderResult {\n order: Order;\n positions: OrderPosition[];\n}\n\nexport class OrdersResource extends BaseResource {\n /** Retrieves orders via `GET /Order`. */\n public list(options: ListOrdersOptions = {}): Promise<Order[]> {\n const {\n status,\n orderNumber,\n startDate,\n endDate,\n contactId,\n limit,\n offset,\n embed,\n } = options;\n return this.http.request<Order[]>({\n method: 'GET',\n path: '/Order',\n query: {\n status,\n orderNumber,\n startDate: toOptionalDate(startDate),\n endDate: toOptionalDate(endDate),\n 'contact[id]': contactId,\n 'contact[objectName]': contactId === undefined ? undefined : 'Contact',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single order via `GET /Order/{orderId}`. */\n public async get(options: {\n orderId: number;\n embed?: string[];\n }): Promise<Order> {\n const orders = await this.http.request<Order[]>({\n method: 'GET',\n path: `/Order/${options.orderId}`,\n query: { embed: options.embed },\n });\n const order = orders[0];\n if (!order) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return order;\n }\n\n /** Creates or updates an order with its positions via `POST /Order/Factory/saveOrder`. */\n public async save(options: SaveOrderOptions): Promise<SaveOrderResult> {\n const { order, positions } = options;\n const result = await this.http.request<{\n order: Order;\n orderPos: OrderPosition[];\n }>({\n method: 'POST',\n path: '/Order/Factory/saveOrder',\n body: {\n order: toOrderBody(order),\n orderPosSave: positions.map(toOrderPositionBody),\n orderPosDelete: null,\n },\n });\n return { order: result.order, positions: result.orderPos };\n }\n\n /** Updates an order via `PUT /Order/{orderId}`. */\n public update(options: UpdateOrderOptions): Promise<Order> {\n const { orderId, orderDate, ...rest } = options;\n return this.http.request<Order>({\n method: 'PUT',\n path: `/Order/${orderId}`,\n body: { ...rest, orderDate: toOptionalDate(orderDate) },\n });\n }\n\n /** Deletes an order via `DELETE /Order/{orderId}`. */\n public async delete(options: { orderId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/Order/${options.orderId}`,\n });\n }\n\n /** Retrieves the positions of an order via `GET /Order/{orderId}/getPositions`. */\n public getPositions(\n options: { orderId: number; embed?: string[] } & ListOptions,\n ): Promise<OrderPosition[]> {\n const { orderId, limit, offset, embed } = options;\n return this.http.request<OrderPosition[]>({\n method: 'GET',\n path: `/Order/${orderId}/getPositions`,\n query: { limit, offset, embed },\n });\n }\n\n /** Retrieves the discounts of an order via `GET /Order/{orderId}/getDiscounts`. */\n public getDiscounts(\n options: { orderId: number; embed?: string[] } & ListOptions,\n ): Promise<OrderDiscount[]> {\n const { orderId, limit, offset, embed } = options;\n return this.http.request<OrderDiscount[]>({\n method: 'GET',\n path: `/Order/${orderId}/getDiscounts`,\n query: { limit, offset, embed },\n });\n }\n\n /** Retrieves the objects related to an order via `GET /Order/{orderId}/getRelatedObjects`. */\n public getRelatedObjects(\n options: GetOrderRelatedObjectsOptions,\n ): Promise<OrderRelatedObject[]> {\n const { orderId, includeItself, sortByType, embed } = options;\n return this.http.request<OrderRelatedObject[]>({\n method: 'GET',\n path: `/Order/${orderId}/getRelatedObjects`,\n query: { includeItself, sortByType, embed },\n });\n }\n\n /** Sends an order via email using `POST /Order/{orderId}/sendViaEmail`. */\n public sendViaEmail(options: SendOrderViaEmailOptions): Promise<OrderMail[]> {\n const { orderId, ...body } = options;\n return this.http.request<OrderMail[]>({\n method: 'POST',\n path: `/Order/${orderId}/sendViaEmail`,\n body,\n });\n }\n\n /** Creates a packing list from an order via `POST /Order/Factory/createPackingListFromOrder`. */\n public createPackingList(options: { orderId: number }): Promise<Order> {\n return this.http.request<Order>({\n method: 'POST',\n path: '/Order/Factory/createPackingListFromOrder',\n query: {\n 'order[id]': options.orderId,\n 'order[objectName]': 'Order',\n },\n body: { id: options.orderId, objectName: 'Order' },\n });\n }\n\n /** Creates a contract note from an order via `POST /Order/Factory/createContractNoteFromOrder`. */\n public createContractNote(options: { orderId: number }): Promise<Order> {\n return this.http.request<Order>({\n method: 'POST',\n path: '/Order/Factory/createContractNoteFromOrder',\n query: {\n 'order[id]': options.orderId,\n 'order[objectName]': 'Order',\n },\n body: { id: options.orderId, objectName: 'Order' },\n });\n }\n\n /** Retrieves the pdf of an order via `GET /Order/{orderId}/getPdf`. */\n public getPdf(options: {\n orderId: number;\n /** Prevents the order from being marked as sent. */\n preventSendBy?: boolean;\n }): Promise<OrderPdf> {\n return this.http.request<OrderPdf>({\n method: 'GET',\n path: `/Order/${options.orderId}/getPdf`,\n query: { preventSendBy: options.preventSendBy },\n });\n }\n\n /** Marks an order as sent via `PUT /Order/{orderId}/sendBy`. */\n public sendBy(options: SendOrderByOptions): Promise<Order> {\n const { orderId, sendType, sendDraft } = options;\n return this.http.request<Order>({\n method: 'PUT',\n path: `/Order/${orderId}/sendBy`,\n body: { sendType, sendDraft },\n });\n }\n\n /** Retrieves order positions via `GET /OrderPos`. */\n public listPositions(\n options: ListOrderPositionsOptions = {},\n ): Promise<OrderPosition[]> {\n const { orderId, limit, offset, embed } = options;\n return this.http.request<OrderPosition[]>({\n method: 'GET',\n path: '/OrderPos',\n query: {\n 'order[id]': orderId,\n 'order[objectName]': orderId === undefined ? undefined : 'Order',\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single order position via `GET /OrderPos/{orderPosId}`. */\n public async getPosition(options: {\n orderPosId: number;\n }): Promise<OrderPosition> {\n const positions = await this.http.request<OrderPosition[]>({\n method: 'GET',\n path: `/OrderPos/${options.orderPosId}`,\n });\n const position = positions[0];\n if (!position) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return position;\n }\n\n /** Updates an order position via `PUT /OrderPos/{orderPosId}`. */\n public updatePosition(\n options: UpdateOrderPositionOptions,\n ): Promise<OrderPosition> {\n const { orderPosId, unityId, partId, ...rest } = options;\n return this.http.request<OrderPosition>({\n method: 'PUT',\n path: `/OrderPos/${orderPosId}`,\n body: {\n ...rest,\n unity: toRef(unityId, 'Unity'),\n part: toRef(partId, 'Part'),\n },\n });\n }\n\n /** Deletes an order position via `DELETE /OrderPos/{orderPosId}`. */\n public async deletePosition(options: { orderPosId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/OrderPos/${options.orderPosId}`,\n });\n }\n}\n\nfunction toOrderBody(order: OrderInput): Record<string, unknown> {\n return {\n objectName: 'Order',\n mapAll: true,\n orderNumber: order.orderNumber,\n orderDate: toVoucherDate(order.orderDate),\n contact: { id: order.contactId, objectName: 'Contact' },\n status: order.status,\n orderType: order.orderType,\n header: order.header,\n version: order.version,\n addressCountry: { id: order.addressCountryId, objectName: 'StaticCountry' },\n contactPerson: { id: order.contactPersonId, objectName: 'SevUser' },\n taxRule: { id: order.taxRuleId, objectName: 'TaxRule' },\n taxRate: order.taxRate,\n taxText: order.taxText,\n currency: order.currency,\n headText: order.headText,\n footText: order.footText,\n deliveryTerms: order.deliveryTerms,\n paymentTerms: order.paymentTerms,\n smallSettlement: order.smallSettlement,\n showNet: order.showNet,\n address: order.address,\n customerInternalNote: order.customerInternalNote,\n sendDate: toOptionalDate(order.sendDate),\n sendType: order.sendType,\n };\n}\n\nfunction toOrderPositionBody(\n position: OrderPositionInput,\n): Record<string, unknown> {\n return {\n objectName: 'OrderPos',\n mapAll: true,\n unity: { id: position.unityId, objectName: 'Unity' },\n quantity: position.quantity,\n taxRate: position.taxRate,\n name: position.name,\n price: position.price,\n text: position.text,\n part: toRef(position.partId, 'Part'),\n positionNumber: position.positionNumber,\n discount: position.discount,\n optional: position.optional,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n\nfunction toOptionalDate(\n value: DateInput | undefined,\n): string | number | undefined {\n return value === undefined ? undefined : toVoucherDate(value);\n}\n","import { SevDeskError } from '../errors';\nimport type { ListOptions, ModelRef, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/** `50` for an inactive and `100` for an active part. */\nexport type PartStatus = 50 | 100;\n\nexport interface ListPartsOptions extends ListOptions {\n partNumber?: string;\n name?: string;\n embed?: string[];\n}\n\nexport interface CreatePartOptions {\n name: string;\n partNumber: string;\n /** The unit in which the part is measured. `1` is the \"piece\" unit. */\n unityId: number;\n /** In sevdesk-Update 2.0 only `0`, `7` and `19` are allowed. */\n taxRate: number;\n stock: number;\n /** A text describing the part. */\n text?: string;\n /** Send a `GET /Category?objectType=Part` for all available categories. */\n categoryId?: number;\n stockEnabled?: boolean;\n /**\n * Net price for which the part is sold. sevdesk will change this parameter\n * so that the gross price is calculated automatically, until then\n * `priceGross` must be used.\n */\n price?: number;\n priceNet?: number;\n priceGross?: number;\n pricePurchase?: number;\n status?: PartStatus;\n /** An internal comment which does not appear on invoices and orders. */\n internalComment?: string;\n}\n\nexport interface UpdatePartOptions extends Partial<CreatePartOptions> {\n partId: number;\n}\n\nexport interface Part {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n name: string;\n partNumber: string;\n text: string | null;\n category: ModelRefResponse | null;\n stock: string;\n stockEnabled: string;\n unity: ModelRefResponse;\n price: string | null;\n priceNet: string | null;\n priceGross: string | null;\n pricePurchase: string | null;\n taxRate: string;\n status: string | null;\n internalComment: string | null;\n}\n\nexport class PartsResource extends BaseResource {\n /** Retrieves parts via `GET /Part`. */\n public list(options: ListPartsOptions = {}): Promise<Part[]> {\n const { partNumber, name, limit, offset, embed } = options;\n return this.http.request<Part[]>({\n method: 'GET',\n path: '/Part',\n query: { partNumber, name, limit, offset, embed },\n });\n }\n\n /** Retrieves a single part via `GET /Part/{partId}`. */\n public async get(options: { partId: number }): Promise<Part> {\n const parts = await this.http.request<Part[]>({\n method: 'GET',\n path: `/Part/${options.partId}`,\n });\n const part = parts[0];\n if (!part) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return part;\n }\n\n /** Creates a part via `POST /Part`. */\n public create(options: CreatePartOptions): Promise<Part> {\n return this.http.request<Part>({\n method: 'POST',\n path: '/Part',\n body: toPartBody(options),\n });\n }\n\n /** Updates a part via `PUT /Part/{partId}`. */\n public update(options: UpdatePartOptions): Promise<Part> {\n const { partId, ...fields } = options;\n return this.http.request<Part>({\n method: 'PUT',\n path: `/Part/${partId}`,\n body: toPartBody(fields),\n });\n }\n\n /** Retrieves the current stock amount of a part via `GET /Part/{partId}/getStock`. */\n public getStock(options: { partId: number }): Promise<number> {\n return this.http.request<number>({\n method: 'GET',\n path: `/Part/${options.partId}/getStock`,\n });\n }\n}\n\nfunction toPartBody(\n fields: Partial<CreatePartOptions>,\n): Record<string, unknown> {\n return {\n objectName: 'Part',\n mapAll: true,\n name: fields.name,\n partNumber: fields.partNumber,\n unity: toRef(fields.unityId, 'Unity'),\n taxRate: fields.taxRate,\n stock: fields.stock,\n text: fields.text,\n category: toRef(fields.categoryId, 'Category'),\n stockEnabled: fields.stockEnabled,\n price: fields.price,\n priceNet: fields.priceNet,\n priceGross: fields.priceGross,\n pricePurchase: fields.pricePurchase,\n status: fields.status,\n internalComment: fields.internalComment,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n","import { BaseResource } from './base';\n\nexport interface AllowedTaxRule {\n id: number;\n name: string;\n description: string;\n /** Tax rates combinable with this tax rule, for example `ZERO` or `NINETEEN`. */\n taxRates: string[];\n}\n\nexport interface ReceiptGuide {\n accountDatevId: number;\n accountNumber: string;\n accountName: string;\n description: string;\n allowedTaxRules: AllowedTaxRule[];\n /** Viable receipt types for this account, for example `EXPENSE`. */\n allowedReceiptTypes: string[];\n}\n\nexport class ReceiptGuidanceResource extends BaseResource {\n /** Retrieves guidance for all accounts via `GET /ReceiptGuidance/forAllAccounts`. */\n public forAllAccounts(): Promise<ReceiptGuide[]> {\n return this.http.request<ReceiptGuide[]>({\n method: 'GET',\n path: '/ReceiptGuidance/forAllAccounts',\n });\n }\n\n /** Retrieves guidance for a datev account number via `GET /ReceiptGuidance/forAccountNumber`. */\n public forAccountNumber(options: {\n accountNumber: string;\n }): Promise<ReceiptGuide[]> {\n return this.http.request<ReceiptGuide[]>({\n method: 'GET',\n path: '/ReceiptGuidance/forAccountNumber',\n query: { accountNumber: options.accountNumber },\n });\n }\n\n /** Retrieves guidance for a tax rule via `GET /ReceiptGuidance/forTaxRule`. */\n public forTaxRule(options: { taxRule: string }): Promise<ReceiptGuide[]> {\n return this.http.request<ReceiptGuide[]>({\n method: 'GET',\n path: '/ReceiptGuidance/forTaxRule',\n query: { taxRule: options.taxRule },\n });\n }\n\n /** Retrieves guidance for revenue accounts via `GET /ReceiptGuidance/forRevenue`. */\n public forRevenue(): Promise<ReceiptGuide[]> {\n return this.http.request<ReceiptGuide[]>({\n method: 'GET',\n path: '/ReceiptGuidance/forRevenue',\n });\n }\n\n /** Retrieves guidance for expense accounts via `GET /ReceiptGuidance/forExpense`. */\n public forExpense(): Promise<ReceiptGuide[]> {\n return this.http.request<ReceiptGuide[]>({\n method: 'GET',\n path: '/ReceiptGuidance/forExpense',\n });\n }\n}\n","import { BaseResource } from './base';\nimport type {\n ExportContactFilter,\n ExportDocumentFilter,\n ExportFile,\n ExportInvoiceFilter,\n ExportSevQueryOptions,\n ExportVoucherFilter,\n} from './exports';\nimport {\n toExportContactFilter,\n toExportDocumentFilter,\n toExportInvoiceFilter,\n toExportSevQueryParams,\n toExportVoucherFilter,\n} from './exports';\n\n/** `AN` (quotation), `AB` (order confirmation) and `LI` (delivery note). */\nexport type ReportOrderType = 'AN' | 'AB' | 'LI';\n\nexport interface ReportOrderFilter extends ExportDocumentFilter {\n orderType?: ReportOrderType;\n}\n\nexport interface ReportInvoiceListOptions {\n download?: boolean;\n /** Defaults to `all`. */\n view?: string;\n limit?: number;\n filter?: ExportInvoiceFilter;\n}\n\nexport interface ReportOrderListOptions {\n download?: boolean;\n /** Defaults to `all`. */\n view?: string;\n limit?: number;\n filter?: ReportOrderFilter;\n}\n\nexport interface ReportContactListOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportContactFilter;\n}\n\nexport interface ReportVoucherListOptions {\n download?: boolean;\n limit?: number;\n filter?: ExportVoucherFilter;\n}\n\nexport class ReportsResource extends BaseResource {\n /** Creates an invoice list report as PDF via `GET /Report/invoicelist`. */\n public invoiceList(\n options: ReportInvoiceListOptions = {},\n ): Promise<ExportFile> {\n return this.requestReport(\n '/Report/invoicelist',\n { download: options.download, view: options.view ?? 'all' },\n {\n modelName: 'Invoice',\n limit: options.limit,\n filter: toExportInvoiceFilter(options.filter),\n },\n );\n }\n\n /** Creates an order list report as PDF via `GET /Report/orderlist`. */\n public orderList(options: ReportOrderListOptions = {}): Promise<ExportFile> {\n return this.requestReport(\n '/Report/orderlist',\n { download: options.download, view: options.view ?? 'all' },\n {\n modelName: 'Order',\n limit: options.limit,\n filter: {\n ...toExportDocumentFilter(options.filter),\n orderType: options.filter?.orderType,\n },\n },\n );\n }\n\n /** Creates a contact list report as PDF via `GET /Report/contactlist`. */\n public contactList(\n options: ReportContactListOptions = {},\n ): Promise<ExportFile> {\n return this.requestReport('/Report/contactlist', options, {\n modelName: 'Contact',\n limit: options.limit,\n filter: toExportContactFilter(options.filter),\n });\n }\n\n /** Creates a voucher list report as PDF via `GET /Report/voucherlist`. */\n public voucherList(\n options: ReportVoucherListOptions = {},\n ): Promise<ExportFile> {\n return this.requestReport('/Report/voucherlist', options, {\n modelName: 'Voucher',\n limit: options.limit,\n filter: toExportVoucherFilter(options.filter),\n });\n }\n\n private requestReport(\n path: string,\n options: { download?: boolean; view?: string },\n sevQuery: ExportSevQueryOptions,\n ): Promise<ExportFile> {\n return this.http.request<ExportFile>({\n method: 'GET',\n path,\n query: {\n download: options.download,\n view: options.view,\n ...toExportSevQueryParams(sevQuery),\n },\n });\n }\n}\n","import { SevDeskError } from '../errors';\nimport type { ListOptions, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/** The document types a tag can be attached to. */\nexport type TagObjectType = 'Invoice' | 'Voucher' | 'Order' | 'CreditNote';\n\nexport interface ListTagsOptions extends ListOptions {\n name?: string;\n}\n\nexport interface CreateTagOptions {\n name: string;\n /** The document the tag is attached to. */\n objectId: number;\n objectName: TagObjectType;\n}\n\nexport interface Tag {\n id: string;\n objectName: string;\n create: string;\n name: string;\n sevClient: ModelRefResponse;\n}\n\n/** The link between a tag and the document it is attached to. */\nexport interface TagRelation {\n id: string;\n objectName: string;\n create: string;\n tag: ModelRefResponse;\n object: ModelRefResponse;\n sevClient: ModelRefResponse;\n}\n\nexport class TagsResource extends BaseResource {\n /** Retrieves tags via `GET /Tag`. */\n public list(options: ListTagsOptions = {}): Promise<Tag[]> {\n const { name, limit, offset } = options;\n return this.http.request<Tag[]>({\n method: 'GET',\n path: '/Tag',\n query: { name, limit, offset },\n });\n }\n\n /** Retrieves a single tag via `GET /Tag/{tagId}`. */\n public async get(options: { tagId: number }): Promise<Tag> {\n const tags = await this.http.request<Tag[]>({\n method: 'GET',\n path: `/Tag/${options.tagId}`,\n });\n const tag = tags[0];\n if (!tag) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return tag;\n }\n\n /**\n * Creates a tag and attaches it to a document via `POST /Tag/Factory/create`.\n * Returns the created tag relation.\n */\n public create(options: CreateTagOptions): Promise<TagRelation> {\n const { name, objectId, objectName } = options;\n return this.http.request<TagRelation>({\n method: 'POST',\n path: '/Tag/Factory/create',\n body: { name, object: { id: objectId, objectName } },\n });\n }\n\n /** Renames a tag via `PUT /Tag/{tagId}`. */\n public update(options: { tagId: number; name: string }): Promise<Tag> {\n return this.http.request<Tag>({\n method: 'PUT',\n path: `/Tag/${options.tagId}`,\n body: { name: options.name },\n });\n }\n\n /** Deletes a tag via `DELETE /Tag/{tagId}`. */\n public async delete(options: { tagId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/Tag/${options.tagId}`,\n });\n }\n\n /** Retrieves tag relations via `GET /TagRelation`. */\n public listRelations(options: ListOptions = {}): Promise<TagRelation[]> {\n return this.http.request<TagRelation[]>({\n method: 'GET',\n path: '/TagRelation',\n query: { limit: options.limit, offset: options.offset },\n });\n }\n}\n","import { toIsoDateTime } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type { DateInput, ListOptions, ModelRefResponse } from '../types';\nimport { BaseResource } from './base';\n\n/**\n * Status of a transaction.\n *\n * - `100` created\n * - `200` linked\n * - `300` private\n * - `350` auto-booked without user confirmation\n * - `400` booked\n */\nexport type TransactionStatus = 100 | 200 | 300 | 350 | 400;\n\n/** A transaction on a check account. */\nexport interface CheckAccountTransaction {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n valueDate: string;\n entryDate: string | null;\n paymtPurpose: string | null;\n amount: string;\n payeePayerName: string | null;\n payeePayerAcctNo: string | null;\n payeePayerBankCode: string | null;\n checkAccount: ModelRefResponse;\n status: string;\n enshrined: string | null;\n sourceTransaction: ModelRefResponse | null;\n targetTransaction: ModelRefResponse | null;\n gvCode: string | null;\n entryText: string | null;\n primaNotaNo: string | null;\n}\n\nexport interface ListTransactionsOptions extends ListOptions {\n checkAccountId?: number;\n isBooked?: boolean;\n paymtPurpose?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n payeePayerName?: string;\n onlyCredit?: boolean;\n onlyDebit?: boolean;\n}\n\nexport interface CreateTransactionOptions {\n checkAccountId: number;\n valueDate: DateInput;\n entryDate?: DateInput;\n amount: number;\n payeePayerName: string;\n paymtPurpose?: string;\n payeePayerAcctNo?: string;\n payeePayerBankCode?: string;\n /** Defaults to `100`, the only status that makes sense on creation. */\n status?: TransactionStatus;\n}\n\nexport interface UpdateTransactionOptions {\n transactionId: number;\n valueDate?: DateInput;\n entryDate?: DateInput;\n paymtPurpose?: string;\n amount?: number;\n payeePayerName?: string;\n status?: TransactionStatus;\n}\n\nexport class TransactionsResource extends BaseResource {\n /** Retrieves transactions via `GET /CheckAccountTransaction`. */\n public async list(\n options: ListTransactionsOptions = {},\n ): Promise<CheckAccountTransaction[]> {\n return this.http.request<CheckAccountTransaction[]>({\n method: 'GET',\n path: '/CheckAccountTransaction',\n query: {\n 'checkAccount[id]': options.checkAccountId,\n 'checkAccount[objectName]':\n options.checkAccountId === undefined ? undefined : 'CheckAccount',\n isBooked: options.isBooked,\n paymtPurpose: options.paymtPurpose,\n startDate: toOptionalIsoDateTime(options.startDate),\n endDate: toOptionalIsoDateTime(options.endDate),\n payeePayerName: options.payeePayerName,\n onlyCredit: options.onlyCredit,\n onlyDebit: options.onlyDebit,\n limit: options.limit,\n offset: options.offset,\n },\n });\n }\n\n /** Retrieves a single transaction via `GET /CheckAccountTransaction/{transactionId}`. */\n public async get(options: {\n transactionId: number;\n }): Promise<CheckAccountTransaction> {\n const transactions = await this.http.request<CheckAccountTransaction[]>({\n method: 'GET',\n path: `/CheckAccountTransaction/${options.transactionId}`,\n });\n const transaction = transactions[0];\n if (!transaction) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return transaction;\n }\n\n /**\n * Creates a transaction via `POST /CheckAccountTransaction`.\n *\n * Should only be used on check accounts of type online, preferably on\n * accounts that import their transactions from CSV files.\n */\n public async create(\n options: CreateTransactionOptions,\n ): Promise<CheckAccountTransaction> {\n return this.http.request<CheckAccountTransaction>({\n method: 'POST',\n path: '/CheckAccountTransaction',\n body: {\n objectName: 'CheckAccountTransaction',\n mapAll: true,\n valueDate: toIsoDateTime(options.valueDate),\n entryDate: toOptionalIsoDateTime(options.entryDate),\n amount: options.amount,\n payeePayerName: options.payeePayerName,\n paymtPurpose: options.paymtPurpose,\n payeePayerAcctNo: options.payeePayerAcctNo,\n payeePayerBankCode: options.payeePayerBankCode,\n checkAccount: {\n id: options.checkAccountId,\n objectName: 'CheckAccount',\n },\n status: options.status ?? 100,\n },\n });\n }\n\n /** Updates a transaction via `PUT /CheckAccountTransaction/{transactionId}`. */\n public async update(\n options: UpdateTransactionOptions,\n ): Promise<CheckAccountTransaction> {\n const { transactionId, valueDate, entryDate, ...rest } = options;\n return this.http.request<CheckAccountTransaction>({\n method: 'PUT',\n path: `/CheckAccountTransaction/${transactionId}`,\n body: {\n ...rest,\n valueDate: toOptionalIsoDateTime(valueDate),\n entryDate: toOptionalIsoDateTime(entryDate),\n },\n });\n }\n\n /** Deletes a transaction via `DELETE /CheckAccountTransaction/{transactionId}`. */\n public async delete(options: { transactionId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/CheckAccountTransaction/${options.transactionId}`,\n });\n }\n\n /**\n * Enshrines a transaction via `PUT /CheckAccountTransaction/{transactionId}/enshrine`.\n *\n * Requires a status of at least `200` and cannot be undone. Linked invoices,\n * credit notes and vouchers can no longer be changed afterwards.\n */\n public async enshrine(options: { transactionId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'PUT',\n path: `/CheckAccountTransaction/${options.transactionId}/enshrine`,\n });\n }\n}\n\nfunction toOptionalIsoDateTime(\n value: DateInput | undefined,\n): string | undefined {\n return value === undefined ? undefined : toIsoDateTime(value);\n}\n","import { toIsoDateTime, toVoucherDate } from '../dates';\nimport { SevDeskError } from '../errors';\nimport type {\n DateInput,\n ListOptions,\n ModelRef,\n ModelRefResponse,\n} from '../types';\nimport { BaseResource } from './base';\n\nexport type VoucherStatus = 50 | 100 | 150 | 750 | 1000;\n\nexport type VoucherBookingType =\n 'FULL_PAYMENT' | 'N' | 'CB' | 'O' | 'OF' | 'MTC';\n\nexport interface VoucherInput {\n /** `50` for a draft voucher, `100` for an open one. */\n status: 50 | 100;\n /** `C` for a credit voucher, `D` for a debit voucher. */\n creditDebit: 'C' | 'D';\n /** Defines the vat regulation, for example `1` for \"Umsatzsteuerpflichtige Umsätze\". */\n taxRuleId: number;\n /** Defaults to `VOU`. */\n voucherType?: 'VOU' | 'RV';\n voucherDate?: DateInput;\n payDate?: DateInput;\n deliveryDate?: DateInput;\n deliveryDateUntil?: DateInput;\n supplierId?: number;\n /** Shown as the supplier of the voucher when no `supplierId` is given. */\n supplierName?: string;\n /** The voucher number. */\n description?: string;\n currency?: string;\n propertyExchangeRate?: number;\n costCentreId?: number;\n}\n\nexport interface VoucherPositionInput {\n accountDatevId: number;\n taxRate: number;\n /** `true` if `sumNet` is authoritative, `false` if `sumGross` is. */\n net: boolean;\n sumNet?: number;\n sumGross?: number;\n isAsset?: boolean;\n comment?: string;\n}\n\nexport interface SaveVoucherOptions {\n voucher: VoucherInput;\n positions: VoucherPositionInput[];\n /** Internal filename returned by `uploadFile`. */\n filename?: string;\n}\n\nexport interface ListVouchersOptions extends ListOptions {\n status?: VoucherStatus;\n creditDebit?: 'C' | 'D';\n descriptionLike?: string;\n startDate?: DateInput;\n endDate?: DateInput;\n contactId?: number;\n /**\n * Filters vouchers by a linked object, for example a document the voucher\n * originated from. Payment bookings are not exposed as linked objects, so\n * this cannot look up the voucher booked against a bank transaction.\n */\n linkedObjectId?: number;\n linkedObjectName?: string;\n embed?: string[];\n}\n\nexport interface ListVoucherPositionsOptions extends ListOptions {\n /** Only returns the positions of this voucher. */\n voucherId?: number;\n embed?: string[];\n}\n\nexport interface UpdateVoucherOptions {\n voucherId: number;\n voucherDate?: DateInput;\n /** The voucher number. */\n description?: string;\n payDate?: DateInput;\n supplierName?: string;\n}\n\nexport interface BookVoucherOptions {\n voucherId: number;\n /** Can also be a partial amount. */\n amount: number;\n date: DateInput;\n type: VoucherBookingType;\n checkAccountId: number;\n /**\n * Required for online check accounts. Must be omitted for offline check\n * accounts and cash registers, where the transaction is created automatically.\n */\n checkAccountTransactionId?: number;\n createFeed?: boolean;\n}\n\nexport interface Voucher {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n voucherDate: string | null;\n supplier: ModelRefResponse | null;\n supplierName: string | null;\n description: string | null;\n payDate: string | null;\n status: string | null;\n sumNet: string;\n sumTax: string;\n sumGross: string;\n sumNetAccounting: string;\n sumTaxAccounting: string;\n sumGrossAccounting: string;\n sumDiscounts: string;\n paidAmount: number | null;\n taxRule: ModelRefResponse;\n creditDebit: string | null;\n voucherType: string | null;\n currency: string | null;\n propertyExchangeRate: string | null;\n enshrined: string | null;\n paymentDeadline: string | null;\n deliveryDate: string;\n deliveryDateUntil: string | null;\n document: ModelRefResponse | null;\n costCentre: ModelRefResponse | null;\n}\n\nexport interface VoucherPosition {\n id: string;\n objectName: string;\n create: string;\n update: string;\n sevClient: ModelRefResponse;\n voucher: ModelRefResponse;\n accountDatev: ModelRefResponse;\n taxRate: string;\n net: boolean;\n isAsset: boolean;\n sumNet: string;\n sumTax: string;\n sumGross: string;\n sumNetAccounting: string;\n sumTaxAccounting: string;\n sumGrossAccounting: string;\n comment: string | null;\n}\n\nexport interface SaveVoucherResult {\n voucher: Voucher;\n positions: VoucherPosition[];\n filename?: string;\n}\n\nexport interface BookVoucherResult {\n id: string;\n objectName: string;\n create: string;\n voucher: ModelRefResponse;\n fromStatus: string;\n toStatus: string;\n amountPayed: string;\n bookingDate: string;\n sevClient: ModelRefResponse;\n}\n\nexport interface UploadVoucherFileResult {\n pages: number;\n mimeType: string;\n originMimeType: string;\n /** The sevdesk internal filename to pass to `save`. */\n filename: string;\n contentHash: string;\n}\n\nexport class VouchersResource extends BaseResource {\n /** Retrieves vouchers via `GET /Voucher`. */\n public list(options: ListVouchersOptions = {}): Promise<Voucher[]> {\n const {\n status,\n creditDebit,\n descriptionLike,\n startDate,\n endDate,\n contactId,\n linkedObjectId,\n linkedObjectName,\n limit,\n offset,\n embed,\n } = options;\n return this.http.request<Voucher[]>({\n method: 'GET',\n path: '/Voucher',\n query: {\n status,\n creditDebit,\n descriptionLike,\n startDate: toOptionalVoucherDate(startDate),\n endDate: toOptionalVoucherDate(endDate),\n 'contact[id]': contactId,\n 'contact[objectName]': contactId === undefined ? undefined : 'Contact',\n 'object[id]': linkedObjectId,\n 'object[objectName]':\n linkedObjectId === undefined ? undefined : linkedObjectName,\n limit,\n offset,\n embed,\n },\n });\n }\n\n /** Retrieves a single voucher via `GET /Voucher/{voucherId}`. */\n public async get(options: {\n voucherId: number;\n embed?: string[];\n }): Promise<Voucher> {\n const vouchers = await this.http.request<Voucher[]>({\n method: 'GET',\n path: `/Voucher/${options.voucherId}`,\n query: { embed: options.embed },\n });\n const voucher = vouchers[0];\n if (!voucher) {\n throw new SevDeskError({\n status: 404,\n statusText: 'Not Found',\n body: null,\n });\n }\n return voucher;\n }\n\n /** Uploads a voucher document via `POST /Voucher/Factory/uploadTempFile`. */\n public uploadFile(options: {\n file: Blob | Uint8Array;\n filename?: string;\n }): Promise<UploadVoucherFileResult> {\n const { file, filename = 'upload' } = options;\n const formData = new FormData();\n const blob =\n file instanceof Blob ? file : new Blob([file as Uint8Array<ArrayBuffer>]);\n formData.append('file', blob, filename);\n return this.http.request<UploadVoucherFileResult>({\n method: 'POST',\n path: '/Voucher/Factory/uploadTempFile',\n formData,\n });\n }\n\n /** Creates or updates a voucher with its positions via `POST /Voucher/Factory/saveVoucher`. */\n public async save(options: SaveVoucherOptions): Promise<SaveVoucherResult> {\n const { voucher, positions, filename } = options;\n const result = await this.http.request<{\n voucher: Voucher;\n voucherPos: VoucherPosition[];\n filename?: string;\n }>({\n method: 'POST',\n path: '/Voucher/Factory/saveVoucher',\n body: {\n voucher: toVoucherBody(voucher),\n voucherPosSave: positions.map(toVoucherPositionBody),\n voucherPosDelete: null,\n ...(filename === undefined ? {} : { filename }),\n },\n });\n return {\n voucher: result.voucher,\n positions: result.voucherPos,\n filename: result.filename,\n };\n }\n\n /** Uploads a document and creates a voucher with it attached. */\n public async createFromFile(options: {\n file: Blob | Uint8Array;\n filename?: string;\n voucher: VoucherInput;\n positions: VoucherPositionInput[];\n }): Promise<SaveVoucherResult> {\n const { file, filename, voucher, positions } = options;\n const upload = await this.uploadFile({ file, filename });\n return this.save({ voucher, positions, filename: upload.filename });\n }\n\n /** Updates simple fields of a draft voucher via `PUT /Voucher/{voucherId}`. */\n public update(options: UpdateVoucherOptions): Promise<Voucher> {\n const { voucherId, voucherDate, description, payDate, supplierName } =\n options;\n return this.http.request<Voucher>({\n method: 'PUT',\n path: `/Voucher/${voucherId}`,\n body: {\n voucherDate: toOptionalVoucherDate(voucherDate),\n description,\n payDate: toOptionalVoucherDate(payDate),\n supplierName,\n },\n });\n }\n\n /** Books an amount on a voucher via `PUT /Voucher/{voucherId}/bookAmount`. */\n public book(options: BookVoucherOptions): Promise<BookVoucherResult> {\n const {\n voucherId,\n amount,\n date,\n type,\n checkAccountId,\n checkAccountTransactionId,\n createFeed,\n } = options;\n return this.http.request<BookVoucherResult>({\n method: 'PUT',\n path: `/Voucher/${voucherId}/bookAmount`,\n body: {\n amount,\n date: toIsoDateTime(date),\n type,\n checkAccount: { id: checkAccountId, objectName: 'CheckAccount' },\n checkAccountTransaction: toRef(\n checkAccountTransactionId,\n 'CheckAccountTransaction',\n ),\n createFeed,\n },\n });\n }\n\n /** Resets the voucher status to open via `PUT /Voucher/{voucherId}/resetToOpen`. */\n public resetToOpen(options: { voucherId: number }): Promise<Voucher> {\n return this.http.request<Voucher>({\n method: 'PUT',\n path: `/Voucher/${options.voucherId}/resetToOpen`,\n });\n }\n\n /** Resets the voucher status to draft via `PUT /Voucher/{voucherId}/resetToDraft`. */\n public resetToDraft(options: { voucherId: number }): Promise<Voucher> {\n return this.http.request<Voucher>({\n method: 'PUT',\n path: `/Voucher/${options.voucherId}/resetToDraft`,\n });\n }\n\n /** Enshrines a voucher via `PUT /Voucher/{voucherId}/enshrine`. This cannot be undone. */\n public async enshrine(options: { voucherId: number }): Promise<void> {\n await this.http.request<void>({\n method: 'PUT',\n path: `/Voucher/${options.voucherId}/enshrine`,\n });\n }\n\n /** Retrieves voucher positions via `GET /VoucherPos`. */\n public listPositions(\n options: ListVoucherPositionsOptions = {},\n ): Promise<VoucherPosition[]> {\n const { voucherId, limit, offset, embed } = options;\n return this.http.request<VoucherPosition[]>({\n method: 'GET',\n path: '/VoucherPos',\n query: {\n 'voucher[id]': voucherId,\n 'voucher[objectName]': voucherId === undefined ? undefined : 'Voucher',\n limit,\n offset,\n embed,\n },\n });\n }\n}\n\nfunction toVoucherBody(voucher: VoucherInput): Record<string, unknown> {\n return {\n objectName: 'Voucher',\n mapAll: true,\n status: voucher.status,\n creditDebit: voucher.creditDebit,\n taxRule: { id: voucher.taxRuleId, objectName: 'TaxRule' },\n voucherType: voucher.voucherType ?? 'VOU',\n voucherDate: toOptionalVoucherDate(voucher.voucherDate),\n payDate: toOptionalVoucherDate(voucher.payDate),\n deliveryDate: toOptionalVoucherDate(voucher.deliveryDate),\n deliveryDateUntil: toOptionalVoucherDate(voucher.deliveryDateUntil),\n supplier: toRef(voucher.supplierId, 'Contact'),\n supplierName: voucher.supplierName,\n description: voucher.description,\n currency: voucher.currency,\n propertyExchangeRate: voucher.propertyExchangeRate,\n costCentre: toRef(voucher.costCentreId, 'CostCentre'),\n };\n}\n\nfunction toVoucherPositionBody(\n position: VoucherPositionInput,\n): Record<string, unknown> {\n return {\n objectName: 'VoucherPos',\n mapAll: true,\n voucher: null,\n accountDatev: {\n id: position.accountDatevId,\n objectName: 'AccountDatev',\n },\n taxRate: position.taxRate,\n net: position.net,\n sumNet: position.sumNet,\n sumGross: position.sumGross,\n isAsset: position.isAsset,\n comment: position.comment,\n };\n}\n\nfunction toRef(\n id: number | undefined,\n objectName: string,\n): ModelRef | undefined {\n return id === undefined ? undefined : { id, objectName };\n}\n\nfunction toOptionalVoucherDate(\n value: DateInput | undefined,\n): string | number | undefined {\n return value === undefined ? undefined : toVoucherDate(value);\n}\n","import type { SevDeskOptions } from './http-client';\nimport { HttpClient } from './http-client';\nimport { BasicsResource } from './resources/basics';\nimport { CheckAccountsResource } from './resources/check-accounts';\nimport { CommunicationWaysResource } from './resources/communication-ways';\nimport { ContactAddressesResource } from './resources/contact-addresses';\nimport { ContactsResource } from './resources/contacts';\nimport { CreditNotesResource } from './resources/credit-notes';\nimport { ExportsResource } from './resources/exports';\nimport { InvoicesResource } from './resources/invoices';\nimport { OrdersResource } from './resources/orders';\nimport { PartsResource } from './resources/parts';\nimport { ReceiptGuidanceResource } from './resources/receipt-guidance';\nimport { ReportsResource } from './resources/reports';\nimport { TagsResource } from './resources/tags';\nimport { TransactionsResource } from './resources/transactions';\nimport { VouchersResource } from './resources/vouchers';\n\nexport class SevDesk {\n public readonly basics: BasicsResource;\n public readonly checkAccounts: CheckAccountsResource;\n public readonly communicationWays: CommunicationWaysResource;\n public readonly contactAddresses: ContactAddressesResource;\n public readonly contacts: ContactsResource;\n public readonly creditNotes: CreditNotesResource;\n public readonly exports: ExportsResource;\n public readonly invoices: InvoicesResource;\n public readonly orders: OrdersResource;\n public readonly parts: PartsResource;\n public readonly receiptGuidance: ReceiptGuidanceResource;\n public readonly reports: ReportsResource;\n public readonly tags: TagsResource;\n public readonly transactions: TransactionsResource;\n public readonly vouchers: VouchersResource;\n\n constructor(options: SevDeskOptions) {\n const http = new HttpClient(options);\n this.basics = new BasicsResource(http);\n this.checkAccounts = new CheckAccountsResource(http);\n this.communicationWays = new CommunicationWaysResource(http);\n this.contactAddresses = new ContactAddressesResource(http);\n this.contacts = new ContactsResource(http);\n this.creditNotes = new CreditNotesResource(http);\n this.exports = new ExportsResource(http);\n this.invoices = new InvoicesResource(http);\n this.orders = new OrdersResource(http);\n this.parts = new PartsResource(http);\n this.receiptGuidance = new ReceiptGuidanceResource(http);\n this.reports = new ReportsResource(http);\n this.tags = new TagsResource(http);\n this.transactions = new TransactionsResource(http);\n this.vouchers = new VouchersResource(http);\n }\n}\n"],"mappings":";AAAA,IAAa,eAAb,cAAkC,MAAM;CACtC;CACA;CACA;CAEA,YAAY,SAAgE;EAC1E,MAAM,eAAe,OAAO,CAAC;EAC7B,KAAK,OAAO;EACZ,KAAK,SAAS,QAAQ;EACtB,KAAK,aAAa,QAAQ;EAC1B,KAAK,OAAO,QAAQ;CACtB;AACF;AAEA,SAAS,eAAe,SAIb;CACT,MAAM,WAAW,sBAAsB,QAAQ,OAAO,GAAG,QAAQ;CACjE,MAAM,OAAO,QAAQ;CACrB,IAAI,OAAO,SAAS,YAAY,KAAK,SAAS,GAC5C,OAAO;CAET,IAAI,OAAO,SAAS,YAAY,SAAS,MAAM;EAC7C,MAAM,QAAS,KAA6B;EAC5C,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;GAC/C,MAAM,UAAW,MAAgC;GACjD,IAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,GAClD,OAAO;EAEX;EACA,MAAM,UAAW,KAA+B;EAChD,IAAI,OAAO,YAAY,YAAY,QAAQ,SAA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WAAW,IAAI,iBAAiB,IAAI;EACzC,KAAK,cAAc,IAAI,oBAAoB,IAAI;EAC/C,KAAK,UAAU,IAAI,gBAAgB,IAAI;EACvC,KAAK,WAAW,IAAI,iBAAiB,IAAI;EACzC,KAAK,SAAS,IAAI,eAAe,IAAI;EACrC,KAAK,QAAQ,IAAI,cAAc,IAAI;EACnC,KAAK,kBAAkB,IAAI,wBAAwB,IAAI;EACvD,KAAK,UAAU,IAAI,gBAAgB,IAAI;EACvC,KAAK,OAAO,IAAI,aAAa,IAAI;EACjC,KAAK,eAAe,IAAI,qBAAqB,IAAI;EACjD,KAAK,WAAW,IAAI,iBAAiB,IAAI;CAC3C;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genz-its/sevdesk-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Unofficial Node.js SDK for the sevdesk API.",
5
5
  "type": "module",
6
6
  "sideEffects": false,