kassza 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +103 -103
  2. package/dist/client-CL3fuH6A.js +1596 -0
  3. package/dist/{client-zv4enyq7.d.ts → client-CickRRFr.d.ts} +307 -217
  4. package/dist/client-CsmGIFRS.cjs +1637 -0
  5. package/dist/{client-B9kbKKBf.d.cts → client-DvWZoX_E.d.cts} +307 -217
  6. package/dist/create-once-CqdYmQD8.js +330 -0
  7. package/dist/create-once-D0pwuenl.cjs +389 -0
  8. package/dist/crypto-B8lERvR1.cjs +56 -0
  9. package/dist/crypto-DK_osBVy.js +33 -0
  10. package/dist/{dates-DtHzwNU6.d.cts → dates-9zvESP0i.d.cts} +2 -1
  11. package/dist/{dates-DtHzwNU6.d.ts → dates-9zvESP0i.d.ts} +2 -1
  12. package/dist/{dates-PPxH0n5H.cjs → dates-CPgBodkP.cjs} +44 -1
  13. package/dist/{dates-D2XebOIg.js → dates-CXyj7Azy.js} +39 -2
  14. package/dist/delegation/index.cjs +395 -0
  15. package/dist/delegation/index.d.cts +99 -0
  16. package/dist/delegation/index.d.ts +99 -0
  17. package/dist/delegation/index.js +377 -0
  18. package/dist/{errors-DapdV5DK.js → errors-DLrb0g64.js} +122 -5
  19. package/dist/{errors-B0QJhUW1.cjs → errors-DxeuTslP.cjs} +127 -4
  20. package/dist/index.cjs +21 -1410
  21. package/dist/index.d.cts +18 -3
  22. package/dist/index.d.ts +18 -3
  23. package/dist/index.js +8 -1409
  24. package/dist/ipn/index.cjs +1 -1
  25. package/dist/ipn/index.js +1 -1
  26. package/dist/{create-DZsl3Z4m.cjs → issue-BsyYdrIG.cjs} +664 -311
  27. package/dist/{create-5YkUcJSe.js → issue-C6Fcjvln.js} +589 -272
  28. package/dist/json-4y4E2xxS.cjs +61 -0
  29. package/dist/json-B70TwoX1.d.cts +4 -0
  30. package/dist/json-B70TwoX1.d.ts +4 -0
  31. package/dist/json-DjnqnaJK.js +32 -0
  32. package/dist/money/index.cjs +12 -10
  33. package/dist/money/index.js +3 -1
  34. package/dist/{money-C9j7nBNP.js → money-DAA7OwiO.js} +4 -101
  35. package/dist/{money-DkiGukAw.cjs → money-DrhGkWHW.cjs} +19 -170
  36. package/dist/payments/barion.cjs +208 -0
  37. package/dist/payments/barion.d.cts +28 -0
  38. package/dist/payments/barion.d.ts +28 -0
  39. package/dist/payments/barion.js +199 -0
  40. package/dist/payments/index.cjs +16 -0
  41. package/dist/payments/index.d.cts +31 -0
  42. package/dist/payments/index.d.ts +31 -0
  43. package/dist/payments/index.js +3 -0
  44. package/dist/payments/paypal.cjs +351 -0
  45. package/dist/payments/paypal.d.cts +59 -0
  46. package/dist/payments/paypal.d.ts +59 -0
  47. package/dist/payments/paypal.js +337 -0
  48. package/dist/payments/revolut.cjs +261 -0
  49. package/dist/payments/revolut.d.cts +48 -0
  50. package/dist/payments/revolut.d.ts +48 -0
  51. package/dist/payments/revolut.js +249 -0
  52. package/dist/payments/simplepay.cjs +313 -0
  53. package/dist/payments/simplepay.d.cts +86 -0
  54. package/dist/payments/simplepay.d.ts +86 -0
  55. package/dist/payments/simplepay.js +299 -0
  56. package/dist/payments/stripe.cjs +315 -0
  57. package/dist/payments/stripe.d.cts +49 -0
  58. package/dist/payments/stripe.d.ts +49 -0
  59. package/dist/payments/stripe.js +303 -0
  60. package/dist/reports/index.cjs +256 -0
  61. package/dist/reports/index.d.cts +70 -0
  62. package/dist/reports/index.d.ts +70 -0
  63. package/dist/reports/index.js +247 -0
  64. package/dist/rounding-BLyHjjI5.js +20 -0
  65. package/dist/rounding-TxoWy2ww.cjs +37 -0
  66. package/dist/storage/fs.cjs +1 -1
  67. package/dist/storage/fs.js +1 -1
  68. package/dist/storage/index.cjs +2 -2
  69. package/dist/storage/index.d.cts +1 -1
  70. package/dist/storage/index.d.ts +1 -1
  71. package/dist/storage/index.js +2 -2
  72. package/dist/tax-number-BYFkBp4A.cjs +141 -0
  73. package/dist/tax-number-BdqKsxNR.js +76 -0
  74. package/dist/testing/index.cjs +183 -84
  75. package/dist/testing/index.d.cts +10 -2
  76. package/dist/testing/index.d.ts +10 -2
  77. package/dist/testing/index.js +181 -82
  78. package/dist/types-COf1LAD-.d.cts +56 -0
  79. package/dist/types-COf1LAD-.d.ts +56 -0
  80. package/dist/types-DH8QoNZK.d.cts +135 -0
  81. package/dist/types-k--zHf4l.d.ts +135 -0
  82. package/dist/validators/index.cjs +14 -88
  83. package/dist/validators/index.js +1 -75
  84. package/dist/vat-g35srbNG.cjs +116 -0
  85. package/dist/vat-v_dcWCto.js +81 -0
  86. package/dist/webhook-C76bV-4R.cjs +245 -0
  87. package/dist/webhook-CfaDgcL0.d.cts +6 -0
  88. package/dist/webhook-D4lvtex1.js +174 -0
  89. package/dist/webhook-q2OzNwd7.d.ts +6 -0
  90. package/package.json +106 -2
@@ -1,6 +1,8 @@
1
1
  import { t as CookieStore } from "./session-Dm_45x8K.js";
2
- import { t as DateInput } from "./dates-DtHzwNU6.js";
2
+ import { t as DateInput } from "./dates-9zvESP0i.js";
3
3
  import { _ as VatRate, o as ItemAmounts, s as ItemPriceInput } from "./index-CYAGCdKJ.js";
4
+ import { h as SendReceiptInput, i as ReceiptDefaults, m as ReverseReceiptInput, n as GetReceiptInput, r as Receipt, s as ReceiptOnlyVatCode, t as CreateReceiptInput } from "./types-k--zHf4l.js";
5
+ import { i as PaymentEvent, r as PaymentCustomer, s as PaymentLineItem } from "./types-COf1LAD-.js";
4
6
  //#region src/core/actions.d.ts
5
7
  declare const SZAMLAZZ_AGENT_URL = "https://www.szamlazz.hu/szamla/";
6
8
  declare const AGENT_ACTIONS: {
@@ -15,12 +17,13 @@ declare const AGENT_ACTIONS: {
15
17
  readonly getReceipt: "action-szamla_agent_nyugta_get";
16
18
  readonly sendReceipt: "action-szamla_agent_nyugta_send";
17
19
  readonly queryTaxpayer: "action-szamla_agent_taxpayer";
20
+ readonly connectPrincipal: "action-agent_ceg_mb";
18
21
  };
19
22
  type AgentAction = keyof typeof AGENT_ACTIONS;
20
23
  declare const MAX_INVOICE_ATTACHMENTS = 5;
21
24
  //#endregion
22
25
  //#region src/core/errors.d.ts
23
- type SzamlazzErrorCategory = "auth" | "account" | "validation" | "duplicate" | "partial_success" | "not_found" | "maintenance" | "network" | "timeout" | "configuration" | "unexpected_response" | "unknown";
26
+ type SzamlazzErrorCategory = "auth" | "account" | "validation" | "duplicate" | "partial_success" | "not_found" | "maintenance" | "rate_limit" | "attempt_limit" | "network" | "timeout" | "configuration" | "unexpected_response" | "unknown";
24
27
  interface AgentErrorCodeInfo {
25
28
  readonly message: string;
26
29
  readonly category: SzamlazzErrorCategory;
@@ -34,6 +37,7 @@ interface SzamlazzErrorOptions {
34
37
  readonly action?: AgentAction | undefined;
35
38
  readonly httpStatus?: number | undefined;
36
39
  readonly rawResponse?: string | undefined;
40
+ readonly details?: Readonly<Record<string, string>> | undefined;
37
41
  readonly cause?: unknown;
38
42
  }
39
43
  declare class SzamlazzError extends Error {
@@ -45,50 +49,13 @@ declare class SzamlazzError extends Error {
45
49
  readonly action: AgentAction | undefined;
46
50
  readonly httpStatus: number | undefined;
47
51
  readonly rawResponse: string | undefined;
52
+ readonly details: Readonly<Record<string, string>> | undefined;
48
53
  constructor(message: string, options: SzamlazzErrorOptions);
49
54
  get isDuplicate(): boolean;
50
55
  get isNotFound(): boolean;
51
56
  }
52
57
  declare function isSzamlazzError(error: unknown): error is SzamlazzError;
53
- //#endregion
54
- //#region src/core/context.d.ts
55
- interface AgentAttachment {
56
- readonly filename: string;
57
- readonly content: Uint8Array | ArrayBuffer | Blob | string;
58
- readonly contentType?: string;
59
- }
60
- interface AgentRequestEvent {
61
- readonly action: AgentAction;
62
- readonly attempt: number;
63
- }
64
- interface AgentResponseEvent extends AgentRequestEvent {
65
- readonly status: number;
66
- readonly durationMs: number;
67
- }
68
- interface AgentErrorEvent extends AgentRequestEvent {
69
- readonly error: SzamlazzError;
70
- readonly willRetry: boolean;
71
- }
72
- interface SzamlazzHooks {
73
- readonly onRequest?: (event: AgentRequestEvent) => void;
74
- readonly onResponse?: (event: AgentResponseEvent) => void;
75
- readonly onError?: (event: AgentErrorEvent) => void;
76
- }
77
- interface SzamlazzOptions {
78
- readonly agentKey?: string;
79
- readonly username?: string;
80
- readonly password?: string;
81
- readonly endpoint?: string;
82
- readonly fetch?: typeof globalThis.fetch;
83
- readonly timeoutMs?: number;
84
- readonly maxAttempts?: number;
85
- readonly retryDelayMs?: number;
86
- readonly cookieStore?: CookieStore | false;
87
- readonly hooks?: SzamlazzHooks;
88
- }
89
- interface RequestOptions {
90
- readonly signal?: AbortSignal | undefined;
91
- }
58
+ declare function suggestedPrefix(error: unknown): string | undefined;
92
59
  //#endregion
93
60
  //#region src/invoices/create-types.d.ts
94
61
  type InvoiceType = "invoice" | "proforma" | "advance" | "final" | "corrective" | "deliveryNote";
@@ -278,6 +245,191 @@ interface InvoicePreview {
278
245
  readonly items: readonly CreatedInvoiceItem[];
279
246
  }
280
247
  //#endregion
248
+ //#region src/core/response.d.ts
249
+ interface AgentResponse {
250
+ readonly action: AgentAction;
251
+ readonly status: number;
252
+ readonly headers: Headers;
253
+ readonly body: Uint8Array;
254
+ readonly isPdf: boolean;
255
+ text(): string;
256
+ }
257
+ //#endregion
258
+ //#region src/core/xml/serialize.d.ts
259
+ type XmlScalar = string | number | boolean;
260
+ type XmlContent = XmlScalar | null | undefined | readonly XmlChild[];
261
+ type XmlChild = XmlNode | false | null | undefined;
262
+ type XmlAttributes = Readonly<Record<string, string>>;
263
+ interface XmlNode {
264
+ readonly name: string;
265
+ readonly content: XmlContent;
266
+ readonly attributes?: XmlAttributes | undefined;
267
+ }
268
+ //#endregion
269
+ //#region src/invoices/payment.d.ts
270
+ interface PaymentEntry {
271
+ readonly date?: DateInput | undefined;
272
+ readonly method: string;
273
+ readonly amount: number;
274
+ readonly description?: string | undefined;
275
+ }
276
+ interface PaymentTarget {
277
+ readonly invoiceNumber: string;
278
+ readonly taxNumber?: string | undefined;
279
+ }
280
+ interface RegisterPaymentsInput extends PaymentTarget {
281
+ readonly additive?: boolean | undefined;
282
+ readonly payments: readonly PaymentEntry[];
283
+ }
284
+ interface RegisterSinglePaymentInput extends PaymentTarget {
285
+ readonly additive?: boolean | undefined;
286
+ readonly amount: number;
287
+ readonly method?: string | undefined;
288
+ readonly date?: DateInput | undefined;
289
+ readonly description?: string | undefined;
290
+ }
291
+ type RegisterPaymentInput = RegisterPaymentsInput | RegisterSinglePaymentInput;
292
+ type ClearPaymentsInput = string | PaymentTarget;
293
+ interface RegisteredPayment {
294
+ readonly invoiceNumber: string;
295
+ readonly netTotal?: number | undefined;
296
+ readonly grossTotal?: number | undefined;
297
+ readonly outstanding?: number | undefined;
298
+ readonly buyerAccountUrl?: string | undefined;
299
+ }
300
+ //#endregion
301
+ //#region src/invoices/reverse.d.ts
302
+ interface ReverseInvoiceEmail {
303
+ readonly replyTo?: string | undefined;
304
+ readonly subject?: string | undefined;
305
+ readonly text?: string | undefined;
306
+ }
307
+ interface ReverseInvoiceBuyer {
308
+ readonly email?: string | undefined;
309
+ readonly taxNumber?: string | undefined;
310
+ readonly euTaxNumber?: string | undefined;
311
+ }
312
+ interface ReverseInvoiceOptions {
313
+ readonly invoiceNumber: string;
314
+ readonly issueDate?: DateInput | undefined;
315
+ readonly fulfillmentDate?: DateInput | undefined;
316
+ readonly comment?: string | undefined;
317
+ readonly template?: InvoiceTemplate | undefined;
318
+ readonly eInvoice?: boolean | undefined;
319
+ readonly downloadPdf?: boolean | undefined;
320
+ readonly externalId?: string | undefined;
321
+ readonly email?: ReverseInvoiceEmail | undefined;
322
+ readonly buyer?: ReverseInvoiceBuyer | undefined;
323
+ }
324
+ type ReverseInvoiceInput = string | ReverseInvoiceOptions;
325
+ interface ReversedInvoice {
326
+ readonly number: string;
327
+ readonly netTotal?: number | undefined;
328
+ readonly grossTotal?: number | undefined;
329
+ readonly outstanding?: number | undefined;
330
+ readonly buyerAccountUrl?: string | undefined;
331
+ readonly pdf?: Uint8Array | undefined;
332
+ }
333
+ //#endregion
334
+ //#region src/core/document-events.d.ts
335
+ interface InvoiceCreatedEvent {
336
+ readonly kind: "invoice";
337
+ readonly action: "created";
338
+ readonly number: string;
339
+ readonly document: CreatedInvoice;
340
+ readonly input: CreateInvoiceInput;
341
+ }
342
+ interface InvoiceReversedEvent {
343
+ readonly kind: "invoice";
344
+ readonly action: "reversed";
345
+ readonly number: string;
346
+ readonly reversedNumber: string;
347
+ readonly document: ReversedInvoice;
348
+ }
349
+ interface InvoicePaymentEvent {
350
+ readonly kind: "invoice";
351
+ readonly action: "payment";
352
+ readonly number: string;
353
+ readonly document: RegisteredPayment;
354
+ }
355
+ interface ReceiptCreatedEvent {
356
+ readonly kind: "receipt";
357
+ readonly action: "created";
358
+ readonly number: string;
359
+ readonly document: Receipt;
360
+ }
361
+ interface ReceiptReversedEvent {
362
+ readonly kind: "receipt";
363
+ readonly action: "reversed";
364
+ readonly number: string;
365
+ readonly reversedNumber: string;
366
+ readonly document: Receipt;
367
+ }
368
+ type DocumentEvent = InvoiceCreatedEvent | InvoiceReversedEvent | InvoicePaymentEvent | ReceiptCreatedEvent | ReceiptReversedEvent;
369
+ type DocumentHook = (event: DocumentEvent) => void | Promise<void>;
370
+ //#endregion
371
+ //#region src/core/context.d.ts
372
+ interface AgentAttachment {
373
+ readonly filename: string;
374
+ readonly content: Uint8Array | ArrayBuffer | Blob | string;
375
+ readonly contentType?: string;
376
+ }
377
+ interface AgentRequestEvent {
378
+ readonly action: AgentAction;
379
+ readonly attempt: number;
380
+ }
381
+ interface AgentResponseEvent extends AgentRequestEvent {
382
+ readonly status: number;
383
+ readonly durationMs: number;
384
+ }
385
+ interface AgentErrorEvent extends AgentRequestEvent {
386
+ readonly error: SzamlazzError;
387
+ readonly willRetry: boolean;
388
+ }
389
+ interface SzamlazzHooks {
390
+ readonly onRequest?: (event: AgentRequestEvent) => void;
391
+ readonly onResponse?: (event: AgentResponseEvent) => void;
392
+ readonly onError?: (event: AgentErrorEvent) => void;
393
+ readonly onDocument?: DocumentHook;
394
+ }
395
+ interface SzamlazzOptions {
396
+ readonly agentKey?: string;
397
+ readonly username?: string;
398
+ readonly password?: string;
399
+ readonly endpoint?: string;
400
+ readonly fetch?: typeof globalThis.fetch;
401
+ readonly timeoutMs?: number;
402
+ readonly maxAttempts?: number;
403
+ readonly retryDelayMs?: number;
404
+ readonly cookieStore?: CookieStore | false;
405
+ readonly attemptLedger?: CookieStore | undefined;
406
+ readonly maintenanceCooldownMs?: number | undefined;
407
+ readonly hooks?: SzamlazzHooks;
408
+ }
409
+ interface RequestOptions {
410
+ readonly signal?: AbortSignal | undefined;
411
+ }
412
+ interface AgentRequest {
413
+ readonly action: AgentAction;
414
+ readonly xml: string;
415
+ readonly attachments?: readonly AgentAttachment[];
416
+ readonly signal?: AbortSignal | undefined;
417
+ readonly safeToRetry?: boolean;
418
+ }
419
+ interface AgentContext {
420
+ readonly credentials: readonly XmlNode[];
421
+ execute<T>(request: AgentRequest, parse: (response: AgentResponse) => T | Promise<T>): Promise<T>;
422
+ resetSession(): Promise<void>;
423
+ resetAttempts(key: string): Promise<void>;
424
+ }
425
+ //#endregion
426
+ //#region src/core/once.d.ts
427
+ interface CreateOnceOptions extends RequestOptions {
428
+ readonly lookupFirst?: boolean | undefined;
429
+ readonly matchOrderNumber?: boolean | undefined;
430
+ readonly recoveryDelayMs?: number | undefined;
431
+ }
432
+ //#endregion
281
433
  //#region src/invoices/reference.d.ts
282
434
  type InvoiceReference = string | {
283
435
  readonly invoiceNumber: string;
@@ -437,37 +589,15 @@ interface InvoiceDetails {
437
589
  readonly pdf?: Uint8Array | undefined;
438
590
  }
439
591
  //#endregion
440
- //#region src/invoices/payment.d.ts
441
- interface PaymentEntry {
442
- readonly date?: DateInput | undefined;
443
- readonly method: string;
444
- readonly amount: number;
445
- readonly description?: string | undefined;
446
- }
447
- interface PaymentTarget {
448
- readonly invoiceNumber: string;
449
- readonly taxNumber?: string | undefined;
450
- }
451
- interface RegisterPaymentsInput extends PaymentTarget {
452
- readonly additive?: boolean | undefined;
453
- readonly payments: readonly PaymentEntry[];
454
- }
455
- interface RegisterSinglePaymentInput extends PaymentTarget {
456
- readonly additive?: boolean | undefined;
457
- readonly amount: number;
458
- readonly method?: string | undefined;
459
- readonly date?: DateInput | undefined;
460
- readonly description?: string | undefined;
461
- }
462
- type RegisterPaymentInput = RegisterPaymentsInput | RegisterSinglePaymentInput;
463
- type ClearPaymentsInput = string | PaymentTarget;
464
- interface RegisteredPayment {
465
- readonly invoiceNumber: string;
466
- readonly netTotal?: number | undefined;
467
- readonly grossTotal?: number | undefined;
468
- readonly outstanding?: number | undefined;
469
- readonly buyerAccountUrl?: string | undefined;
592
+ //#region src/invoices/create-once.d.ts
593
+ interface InvoiceOnceResult {
594
+ readonly number: string;
595
+ readonly created: boolean;
596
+ readonly externalId: string;
597
+ readonly invoice?: CreatedInvoice | undefined;
598
+ readonly details?: InvoiceDetails | undefined;
470
599
  }
600
+ declare function invoiceOnceExternalId(type: InvoiceType, orderNumber: string): string;
471
601
  //#endregion
472
602
  //#region src/invoices/pdf.d.ts
473
603
  interface InvoicePdf {
@@ -486,170 +616,125 @@ type ProformaReference = string | {
486
616
  readonly orderNumber: string;
487
617
  };
488
618
  //#endregion
489
- //#region src/invoices/reverse.d.ts
490
- interface ReverseInvoiceEmail {
491
- readonly replyTo?: string | undefined;
492
- readonly subject?: string | undefined;
493
- readonly text?: string | undefined;
494
- }
495
- interface ReverseInvoiceBuyer {
496
- readonly email?: string | undefined;
619
+ //#region src/documents/choose.d.ts
620
+ declare const RECEIPT_MAX_GROSS_HUF = 9e5;
621
+ interface ChooseDocumentBuyer {
497
622
  readonly taxNumber?: string | undefined;
498
623
  readonly euTaxNumber?: string | undefined;
624
+ readonly isBusiness?: boolean | undefined;
499
625
  }
500
- interface ReverseInvoiceOptions {
501
- readonly invoiceNumber: string;
502
- readonly issueDate?: DateInput | undefined;
503
- readonly fulfillmentDate?: DateInput | undefined;
504
- readonly comment?: string | undefined;
505
- readonly template?: InvoiceTemplate | undefined;
506
- readonly eInvoice?: boolean | undefined;
507
- readonly downloadPdf?: boolean | undefined;
508
- readonly externalId?: string | undefined;
509
- readonly email?: ReverseInvoiceEmail | undefined;
510
- readonly buyer?: ReverseInvoiceBuyer | undefined;
511
- }
512
- type ReverseInvoiceInput = string | ReverseInvoiceOptions;
513
- interface ReversedInvoice {
514
- readonly number: string;
515
- readonly netTotal?: number | undefined;
516
- readonly grossTotal?: number | undefined;
517
- readonly outstanding?: number | undefined;
518
- readonly buyerAccountUrl?: string | undefined;
519
- readonly pdf?: Uint8Array | undefined;
520
- }
626
+ interface ChooseDocumentInput {
627
+ readonly grossTotal: number;
628
+ readonly currency?: string | undefined;
629
+ readonly exchangeRate?: number | undefined;
630
+ readonly buyer?: ChooseDocumentBuyer | undefined;
631
+ readonly paidByFulfillment?: boolean | undefined;
632
+ readonly invoiceRequested?: boolean | undefined;
633
+ readonly cashRegisterRequired?: boolean | undefined;
634
+ }
635
+ type DocumentChoice = "receipt" | "invoice" | "cash-register";
636
+ interface DocumentDecision {
637
+ readonly type: DocumentChoice;
638
+ readonly reasons: readonly string[];
639
+ readonly grossTotalHuf: number;
640
+ }
641
+ declare function chooseDocument(input: ChooseDocumentInput): DocumentDecision;
521
642
  //#endregion
522
- //#region src/receipts/types.d.ts
523
- declare const RECEIPT_ONLY_VAT_CODES: readonly ["ÁKK", "MAA", "EU", "EUK"];
524
- type ReceiptOnlyVatCode = (typeof RECEIPT_ONLY_VAT_CODES)[number];
525
- type ReceiptVatRate = VatRate | ReceiptOnlyVatCode;
526
- declare const RECEIPT_PDF_TEMPLATES: readonly ["A", "N", "J", "L"];
527
- type ReceiptPdfTemplate = (typeof RECEIPT_PDF_TEMPLATES)[number];
528
- interface ReceiptLedgerInput {
529
- readonly revenue?: string | undefined;
530
- readonly vat?: string | undefined;
531
- }
532
- type ReceiptItemInput = Omit<ItemPriceInput, "vat"> & {
533
- readonly vat: ReceiptVatRate;
643
+ //#region src/payments/issue.d.ts
644
+ interface PaymentDocumentItem {
534
645
  readonly name: string;
535
- readonly identifier?: string | undefined;
646
+ readonly quantity?: number;
536
647
  readonly unit?: string | undefined;
648
+ readonly identifier?: string | undefined;
537
649
  readonly comment?: string | undefined;
538
- readonly ledger?: ReceiptLedgerInput | undefined;
539
- readonly dataDeletionCode?: number | undefined;
540
- };
541
- interface ReceiptPaymentInput {
542
- readonly method: string;
543
- readonly amount: number;
544
- readonly description?: string | undefined;
545
- }
546
- interface ReceiptDefaults {
547
- readonly prefix?: string | undefined;
548
- readonly paymentMethod?: string | undefined;
549
- readonly currency?: string | undefined;
550
- readonly exchangeRate?: number | undefined;
551
- readonly exchangeBank?: string | undefined;
552
- readonly downloadPdf?: boolean | undefined;
553
- readonly template?: ReceiptPdfTemplate | undefined;
554
- readonly unit?: string | undefined;
555
- readonly customerLedgerId?: string | undefined;
556
- }
557
- interface CreateReceiptInput {
558
- readonly prefix?: string | undefined;
559
- readonly paymentMethod?: string | undefined;
650
+ readonly grossUnitPrice?: number;
651
+ readonly netUnitPrice?: number;
652
+ readonly vat: VatRate;
653
+ }
654
+ interface IssueForPaymentOptions {
655
+ readonly vat?: VatRate | undefined;
656
+ readonly vatFor?: ((item: PaymentLineItem) => VatRate) | undefined;
657
+ readonly items?: readonly PaymentDocumentItem[] | undefined;
658
+ readonly fallbackItemName?: string | undefined;
659
+ readonly document?: "auto" | "receipt" | "invoice" | undefined;
660
+ readonly buyer?: InvoiceBuyer | undefined;
661
+ readonly buyerIsBusiness?: boolean | undefined;
662
+ readonly invoiceRequested?: boolean | undefined;
663
+ readonly cashRegisterRequired?: boolean | undefined;
664
+ readonly orderNumber?: string | undefined;
560
665
  readonly currency?: string | undefined;
561
666
  readonly exchangeRate?: number | undefined;
562
667
  readonly exchangeBank?: string | undefined;
563
- readonly callId?: string | undefined;
564
- readonly comment?: string | undefined;
565
- readonly template?: ReceiptPdfTemplate | undefined;
566
- readonly customerLedgerId?: string | undefined;
567
- readonly orderNumber?: string | undefined;
568
- readonly downloadPdf?: boolean | undefined;
569
- readonly items: readonly ReceiptItemInput[];
570
- readonly payments?: readonly ReceiptPaymentInput[] | undefined;
571
- }
572
- interface ReverseReceiptInput {
573
- readonly receiptNumber: string;
574
- readonly callId?: string | undefined;
575
- readonly template?: ReceiptPdfTemplate | undefined;
576
- readonly downloadPdf?: boolean | undefined;
668
+ readonly allowAmountMismatch?: boolean | undefined;
669
+ readonly receipt?: Partial<Omit<CreateReceiptInput, "items" | "orderNumber" | "callId" | "currency" | "exchangeRate" | "exchangeBank">> | undefined;
670
+ readonly invoice?: Partial<Omit<StandardInvoiceInput, "items" | "buyer" | "type" | "orderNumber" | "paid" | "currency" | "exchangeRate" | "exchangeBank" | "externalId">> | undefined;
671
+ readonly recoveryDelayMs?: number | undefined;
672
+ readonly signal?: AbortSignal | undefined;
577
673
  }
578
- interface GetReceiptOptions {
579
- readonly callId?: string | undefined;
580
- readonly template?: ReceiptPdfTemplate | undefined;
581
- readonly downloadPdf?: boolean | undefined;
674
+ interface IssuedReceipt {
675
+ readonly kind: "receipt";
676
+ readonly orderNumber: string;
677
+ readonly number: string;
678
+ readonly created: boolean;
679
+ readonly receipt: Receipt;
680
+ readonly decision: DocumentDecision;
582
681
  }
583
- type GetReceiptInput = GetReceiptOptions & ({
584
- readonly receiptNumber: string;
585
- readonly orderNumber?: undefined;
586
- } | {
682
+ interface IssuedInvoice {
683
+ readonly kind: "invoice";
587
684
  readonly orderNumber: string;
588
- readonly receiptNumber?: undefined;
589
- });
590
- interface SendReceiptInput {
591
- readonly receiptNumber: string;
592
- readonly emails: string | readonly string[];
593
- readonly replyTo?: string | undefined;
594
- readonly subject?: string | undefined;
595
- readonly text?: string | undefined;
685
+ readonly number: string;
686
+ readonly created: boolean;
687
+ readonly invoice: InvoiceOnceResult;
688
+ readonly decision: DocumentDecision;
596
689
  }
597
- type ReceiptType = "receipt" | "reversal";
598
- interface ReceiptLedger {
599
- readonly revenue?: string | undefined;
600
- readonly vat?: string | undefined;
690
+ interface IssuedReversal {
691
+ readonly kind: "reversal";
692
+ readonly orderNumber: string;
693
+ readonly document: "receipt" | "invoice";
694
+ readonly reversedNumber: string;
695
+ readonly number?: string | undefined;
696
+ readonly created: boolean;
601
697
  }
602
- interface ReceiptItem {
603
- readonly name: string;
604
- readonly identifier?: string | undefined;
605
- readonly quantity: number;
606
- readonly unit: string;
607
- readonly netUnitPrice: number;
608
- readonly vat: ReceiptVatRate;
609
- readonly vatPercentage: number;
610
- readonly netAmount: number;
611
- readonly vatAmount: number;
612
- readonly grossAmount: number;
613
- readonly ledger?: ReceiptLedger | undefined;
698
+ interface SkippedPayment {
699
+ readonly kind: "skipped";
700
+ readonly orderNumber: string;
701
+ readonly reason: string;
614
702
  }
615
- interface ReceiptPayment {
616
- readonly method: string;
617
- readonly amount: number;
618
- readonly description?: string | undefined;
703
+ type IssuedDocument = IssuedReceipt | IssuedInvoice | IssuedReversal | SkippedPayment;
704
+ interface PaymentDocumentsApi {
705
+ readonly invoices: Pick<InvoicesApi, "createOnce" | "find" | "reverse">;
706
+ readonly receipts: Pick<ReceiptsApi, "createOnce" | "find" | "reverse">;
619
707
  }
620
- interface ReceiptVatTotal {
621
- readonly vat: ReceiptVatRate;
622
- readonly vatPercentage: number;
623
- readonly netAmount: number;
624
- readonly vatAmount: number;
625
- readonly grossAmount: number;
708
+ declare function paymentOrderNumber(payment: PaymentEvent): string;
709
+ declare function buyerFromCustomer(customer: PaymentCustomer | undefined): InvoiceBuyer | undefined;
710
+ declare function issueForPayment(api: PaymentDocumentsApi, payment: PaymentEvent, options?: IssueForPaymentOptions): Promise<IssuedDocument>;
711
+ //#endregion
712
+ //#region src/receipts/convert.d.ts
713
+ interface ConvertReceiptInput {
714
+ readonly receiptNumber: string;
715
+ readonly buyer: InvoiceBuyer;
716
+ readonly orderNumber?: string | undefined;
717
+ readonly prefix?: string | undefined;
718
+ readonly comment?: string | undefined;
719
+ readonly language?: InvoiceLanguage | undefined;
720
+ readonly template?: InvoiceTemplate | undefined;
721
+ readonly seller?: InvoiceSeller | undefined;
722
+ readonly eInvoice?: boolean | undefined;
723
+ readonly downloadPdf?: boolean | undefined;
724
+ readonly vatMapping?: Readonly<Partial<Record<ReceiptOnlyVatCode, VatRate>>> | undefined;
725
+ readonly allowAlreadyReversed?: boolean | undefined;
626
726
  }
627
- interface ReceiptTotals {
628
- readonly netAmount: number;
629
- readonly vatAmount: number;
630
- readonly grossAmount: number;
631
- readonly byVat: readonly ReceiptVatTotal[];
727
+ interface ConvertedReceipt {
728
+ readonly receipt: Receipt;
729
+ readonly reversal?: Receipt | undefined;
730
+ readonly invoice: InvoiceOnceResult;
632
731
  }
633
- interface Receipt {
634
- readonly id: number;
635
- readonly number: string;
636
- readonly callId?: string | undefined;
637
- readonly type: ReceiptType;
638
- readonly isReversed: boolean;
639
- readonly reversedReceiptNumber?: string | undefined;
640
- readonly issueDate: string;
641
- readonly paymentMethod: string;
642
- readonly currency: string;
643
- readonly exchangeBank?: string | undefined;
644
- readonly exchangeRate?: number | undefined;
645
- readonly comment?: string | undefined;
646
- readonly customerLedgerId?: string | undefined;
647
- readonly isTest: boolean;
648
- readonly orderNumber?: string | undefined;
649
- readonly items: readonly ReceiptItem[];
650
- readonly payments: readonly ReceiptPayment[];
651
- readonly totals: ReceiptTotals;
652
- readonly pdf?: Uint8Array | undefined;
732
+ declare function conversionExternalId(receiptNumber: string): string;
733
+ //#endregion
734
+ //#region src/receipts/create-once.d.ts
735
+ interface ReceiptOnceResult {
736
+ readonly receipt: Receipt;
737
+ readonly created: boolean;
653
738
  }
654
739
  //#endregion
655
740
  //#region src/taxpayer/address.d.ts
@@ -717,6 +802,7 @@ interface KasszaOptions extends SzamlazzOptions {
717
802
  }
718
803
  interface InvoicesApi {
719
804
  create(input: CreateInvoiceInput, options?: RequestOptions): Promise<CreatedInvoice>;
805
+ createOnce(input: CreateInvoiceInput, options?: CreateOnceOptions): Promise<InvoiceOnceResult>;
720
806
  preview(input: CreateInvoiceInput, options?: RequestOptions): Promise<InvoicePreview>;
721
807
  reverse(input: ReverseInvoiceInput, options?: RequestOptions): Promise<ReversedInvoice>;
722
808
  registerPayment(input: RegisterPaymentInput, options?: RequestOptions): Promise<RegisteredPayment>;
@@ -728,10 +814,12 @@ interface InvoicesApi {
728
814
  }
729
815
  interface ReceiptsApi {
730
816
  create(input: CreateReceiptInput, options?: RequestOptions): Promise<Receipt>;
817
+ createOnce(input: CreateReceiptInput, options?: CreateOnceOptions): Promise<ReceiptOnceResult>;
731
818
  reverse(input: ReverseReceiptInput | string, options?: RequestOptions): Promise<Receipt>;
732
819
  get(input: GetReceiptInput | string, options?: RequestOptions): Promise<Receipt>;
733
820
  find(input: GetReceiptInput | string, options?: RequestOptions): Promise<Receipt | null>;
734
821
  send(input: SendReceiptInput, options?: RequestOptions): Promise<void>;
822
+ convertToInvoice(input: ConvertReceiptInput, options?: CreateOnceOptions): Promise<ConvertedReceipt>;
735
823
  }
736
824
  interface TaxpayerApi {
737
825
  query(taxNumber: string, options?: RequestOptions): Promise<TaxpayerInfo>;
@@ -742,7 +830,9 @@ interface Kassza {
742
830
  readonly taxpayer: TaxpayerApi;
743
831
  verifyCredentials(options?: RequestOptions): Promise<boolean>;
744
832
  resetSession(): Promise<void>;
833
+ resetAttempts(target: SzamlazzError | string): Promise<void>;
834
+ issueForPayment(payment: PaymentEvent, options?: IssueForPaymentOptions): Promise<IssuedDocument>;
745
835
  }
746
836
  declare function createKassza(options?: KasszaOptions): Kassza;
747
837
  //#endregion
748
- export { InvoiceItemInput as $, PaymentEntry as A, InvoiceDetailsTotals as B, ReverseReceiptInput as C, SzamlazzError as Ct, ProformaReference as D, AgentAction as Dt, ReversedInvoice as E, AGENT_ACTIONS as Et, InvoiceDetailsBuyer as F, CourierService as G, InvoiceReference as H, InvoiceDetailsHeader as I, CreatedInvoiceItem as J, CreateInvoiceInput as K, InvoiceDetailsItem as L, RegisteredPayment as M, GetInvoiceOptions as N, InvoicePdf as O, MAX_INVOICE_ATTACHMENTS as Ot, InvoiceDetails as P, InvoiceDefaults as Q, InvoiceDetailsPayment as R, ReceiptVatRate as S, AgentErrorCodeInfo as St, ReverseInvoiceInput as T, isSzamlazzError as Tt, BuyerLedger as U, InvoiceDocumentType as V, CorrectiveInvoiceInput as W, FinalInvoiceInput as X, Currency as Y, InvoiceBuyer as Z, ReceiptPayment as _, AgentResponseEvent as _t, ReceiptsApi as a, InvoiceType as at, ReceiptTotals as b, SzamlazzOptions as bt, TaxpayerInfo as c, PickPackPointWaybill as ct, CreateReceiptInput as d, TaxpayerType as dt, InvoiceLanguage as et, GetReceiptInput as f, TransOFlexWaybill as ft, ReceiptItemInput as g, AgentRequestEvent as gt, ReceiptItem as h, AgentErrorEvent as ht, KasszaOptions as i, InvoiceTemplate as it, RegisterPaymentInput as j, ClearPaymentsInput as k, SZAMLAZZ_AGENT_URL as kt, TaxpayerTaxNumber as l, SprinterWaybill as lt, ReceiptDefaults as m, AgentAttachment as mt, Kassza as n, InvoicePreview as nt, TaxpayerApi as o, ItemLedger as ot, Receipt as p, Waybill as pt, CreatedInvoice as q, KasszaDefaults as r, InvoiceSeller as rt, createKassza as s, MplWaybill as st, InvoicesApi as t, InvoicePostalAddress as tt, TaxpayerAddress as u, StandardInvoiceInput as ut, ReceiptPaymentInput as v, RequestOptions as vt, SendReceiptInput as w, SzamlazzErrorCategory as wt, ReceiptType as x, AGENT_ERROR_CODES as xt, ReceiptPdfTemplate as y, SzamlazzHooks as yt, InvoiceDetailsSeller as z };
838
+ export { SzamlazzHooks as $, RECEIPT_MAX_GROSS_HUF as A, InvoiceSeller as At, InvoiceDetailsItem as B, Waybill as Bt, buyerFromCustomer as C, FinalInvoiceInput as Ct, ChooseDocumentInput as D, InvoiceLanguage as Dt, ChooseDocumentBuyer as E, InvoiceItemInput as Et, invoiceOnceExternalId as F, PickPackPointWaybill as Ft, InvoiceReference as G, isSzamlazzError as Gt, InvoiceDetailsSeller as H, AgentErrorCodeInfo as Ht, GetInvoiceOptions as I, SprinterWaybill as It, AgentContext as J, AgentAction as Jt, CreateOnceOptions as K, suggestedPrefix as Kt, InvoiceDetails as L, StandardInvoiceInput as Lt, ProformaReference as M, InvoiceType as Mt, InvoicePdf as N, ItemLedger as Nt, DocumentChoice as O, InvoicePostalAddress as Ot, InvoiceOnceResult as P, MplWaybill as Pt, RequestOptions as Q, InvoiceDetailsBuyer as R, TaxpayerType as Rt, SkippedPayment as S, Currency as St, paymentOrderNumber as T, InvoiceDefaults as Tt, InvoiceDetailsTotals as U, SzamlazzError as Ut, InvoiceDetailsPayment as V, AGENT_ERROR_CODES as Vt, InvoiceDocumentType as W, SzamlazzErrorCategory as Wt, AgentRequestEvent as X, SZAMLAZZ_AGENT_URL as Xt, AgentErrorEvent as Y, MAX_INVOICE_ATTACHMENTS as Yt, AgentResponseEvent as Z, IssuedInvoice as _, CorrectiveInvoiceInput as _t, ReceiptsApi as a, InvoiceReversedEvent as at, PaymentDocumentItem as b, CreatedInvoice as bt, TaxpayerInfo as c, ReverseInvoiceInput as ct, ReceiptOnceResult as d, PaymentEntry as dt, SzamlazzOptions as et, ConvertReceiptInput as f, RegisterPaymentInput as ft, IssuedDocument as g, BuyerLedger as gt, IssueForPaymentOptions as h, AgentResponse as ht, KasszaOptions as i, InvoicePaymentEvent as it, chooseDocument as j, InvoiceTemplate as jt, DocumentDecision as k, InvoicePreview as kt, TaxpayerTaxNumber as l, ReversedInvoice as lt, conversionExternalId as m, XmlNode as mt, Kassza as n, DocumentHook as nt, TaxpayerApi as o, ReceiptCreatedEvent as ot, ConvertedReceipt as p, RegisteredPayment as pt, AgentAttachment as q, AGENT_ACTIONS as qt, KasszaDefaults as r, InvoiceCreatedEvent as rt, createKassza as s, ReceiptReversedEvent as st, InvoicesApi as t, DocumentEvent as tt, TaxpayerAddress as u, ClearPaymentsInput as ut, IssuedReceipt as v, CourierService as vt, issueForPayment as w, InvoiceBuyer as wt, PaymentDocumentsApi as x, CreatedInvoiceItem as xt, IssuedReversal as y, CreateInvoiceInput as yt, InvoiceDetailsHeader as z, TransOFlexWaybill as zt };