kassza 1.0.1 → 1.0.2
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/README.md +3 -2
- package/agents/api.md +4 -4
- package/agents/pitfalls.md +3 -0
- package/dist/batch/index.d.cts +2 -2
- package/dist/batch/index.d.ts +2 -2
- package/dist/cli.cjs +2 -2
- package/dist/cli.js +2 -2
- package/dist/{client-JZ1M1sZX.js → client-8ElbVwSO.js} +2 -2
- package/dist/{client-B00WZ3FK.d.cts → client-CXjvVevB.d.cts} +11 -3
- package/dist/{client-I_29IPMh.cjs → client-CYS1_Xaz.cjs} +2 -2
- package/dist/{client-BJfeFjCM.d.ts → client-CvojBxd9.d.ts} +11 -3
- package/dist/{create-once-zeF7GVVP.cjs → create-once-BKUhF1Ov.cjs} +1 -1
- package/dist/{create-once-B6cAXyET.js → create-once-DcEjO8QH.js} +1 -1
- package/dist/delegation/index.cjs +1 -1
- package/dist/delegation/index.d.cts +1 -1
- package/dist/delegation/index.d.ts +1 -1
- package/dist/delegation/index.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{issue-Dy9zvRK1.js → issue-CUiDvJhQ.js} +92 -3
- package/dist/{issue-DReARZnF.cjs → issue-bLLBTt9j.cjs} +92 -3
- package/dist/journal/index.cjs +22 -2
- package/dist/journal/index.d.cts +1 -1
- package/dist/journal/index.d.ts +1 -1
- package/dist/journal/index.js +22 -2
- package/dist/{journal-JwiYpBui.d.ts → journal-9pfg0if1.d.ts} +1 -0
- package/dist/{journal-D_ypAW50.d.cts → journal-Cp_OMWlI.d.cts} +1 -0
- package/dist/mcp/index.cjs +1 -1
- package/dist/mcp/index.d.cts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/payments/barion.d.cts +2 -2
- package/dist/payments/barion.d.ts +2 -2
- package/dist/payments/index.cjs +1 -1
- package/dist/payments/index.d.cts +4 -4
- package/dist/payments/index.d.ts +4 -4
- package/dist/payments/index.js +1 -1
- package/dist/payments/paypal.d.cts +2 -2
- package/dist/payments/paypal.d.ts +2 -2
- package/dist/payments/revolut.d.cts +2 -2
- package/dist/payments/revolut.d.ts +2 -2
- package/dist/payments/simplepay.d.cts +2 -2
- package/dist/payments/simplepay.d.ts +2 -2
- package/dist/payments/stripe.cjs +30 -1
- package/dist/payments/stripe.d.cts +2 -2
- package/dist/payments/stripe.d.ts +2 -2
- package/dist/payments/stripe.js +30 -1
- package/dist/{server-aSw0DUua.js → server-CZTJ3562.js} +38 -10
- package/dist/{server-BbR19Oj6.cjs → server-CrmxXPV-.cjs} +38 -10
- package/dist/testing/index.cjs +2 -2
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/{types-DeuUqIvU.d.cts → types-DGJiVNxr.d.cts} +1 -1
- package/dist/{types-oiDulesz.d.ts → types-DPnHIwQ_.d.ts} +1 -1
- package/dist/{webhook-C9IBUdeT.d.ts → webhook-BY7437wx.d.ts} +1 -1
- package/dist/{webhook-DF2p_m2Q.d.cts → webhook-CwDbGvSn.d.cts} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -750,8 +750,9 @@ export const POST = stripeWebhook({
|
|
|
750
750
|
```
|
|
751
751
|
|
|
752
752
|
- Az újraküldött webhook nem állít ki második bizonylatot; a `dedupe: store` opcióval a már feldolgozott eseményt a Számla Agent hívása nélkül nyugtázza.
|
|
753
|
-
- Teljes visszatérítéskor a kassza sztornózza a bizonylatot.
|
|
753
|
+
- Teljes visszatérítéskor a kassza egyszer sztornózza a bizonylatot; több példány között ehhez a `lock` opció kell. A fizetés bizonylata előtt érkező visszatérítésre `in_progress` hibát ad, így a szolgáltató a fizetés után újraküldi.
|
|
754
754
|
- Részleges visszatérítéskor számlánál visszatérítésenként egy helyesbítő számlát állít ki, a visszatérített összeget tételenként pontosan szétosztva; több áfakulcsnál és nyugtánál javaslatot ad.
|
|
755
|
+
- A meghiúsult Stripe visszatérítés `refund-failed` eredményt ad, írás nélkül, kézi rendezésre.
|
|
755
756
|
- Ugyanígy működik a `simplePayWebhook`, a `barionWebhook`, a `revolutWebhook` és a `payPalWebhook`.
|
|
756
757
|
|
|
757
758
|
📖 **Dokumentáció:** [Fizetésből bizonylat](https://kasszajs.hu/docs/fizetesek)
|
|
@@ -1260,7 +1261,7 @@ A `doctor` ellenőrzi a Node.js-t, az Agent kulcsot, a gép óráját és a munk
|
|
|
1260
1261
|
}
|
|
1261
1262
|
```
|
|
1262
1263
|
|
|
1263
|
-
Claude, Cursor és más MCP kliensek számára. Alapból csak olvas. Az `--allow-write` kapcsolóval kiállíthat és sztornózhat is, de minden íráshoz kell a megfelelő előnézeti eszköz megerősítő kódja.
|
|
1264
|
+
Claude, Cursor és más MCP kliensek számára. Alapból csak olvas. Az `--allow-write` kapcsolóval kiállíthat és sztornózhat is, de minden íráshoz kell a megfelelő előnézeti eszköz megerősítő kódja, 15 percig és csak az előnézet budapesti napján.
|
|
1264
1265
|
|
|
1265
1266
|
📖 **Dokumentáció:** [MCP szerver](https://kasszajs.hu/docs/kiegeszitok/mcp-szerver)
|
|
1266
1267
|
|
package/agents/api.md
CHANGED
|
@@ -295,7 +295,7 @@ const journal = createJournal(kvJournal(store), { now? })
|
|
|
295
295
|
createKassza({ hooks: { onDocument: (event) => journal.record(event), onDocumentError: 'throw' } })
|
|
296
296
|
```
|
|
297
297
|
|
|
298
|
-
- `kvJournal(store, { prefix?, retentionDays? (400), reservationTtlDays? (30) })` needs a store with `increment`; `memoryJournal()` for tests; or implement `JournalStorage` for SQL.
|
|
298
|
+
- `kvJournal(store, { prefix?, retentionDays? (400), reservationTtlDays? (30) })` needs a store with `increment`; it writes the day index with `setIfAbsent` (or `set` plus a read-back) and throws `store_unavailable` when that fails, so a `resilient` store cannot hide an entry; `reconcile()` re-indexes a stored entry that is missing from the index (`JournalStorage.indexEntry`, optional); `memoryJournal()` for tests; or implement `JournalStorage` for SQL.
|
|
299
299
|
- `record(event)` stores created and reversed documents (payments are ignored); idempotent by document number.
|
|
300
300
|
- `trackReceipt(orderNumber, run)` / `trackInvoice(orderNumber, run)` reserve before `run` and complete after it. Definite `SzamlazzError`s release the reservation; uncertain errors and crashes leave it pending. A failed journal write after success throws `JournalWriteError` with `result`.
|
|
301
301
|
- `pending(range?)` lists reservations (last 30 days by default); `settle(kassza, { range?, releaseNotFound? })` looks them up by order number and records what it finds.
|
|
@@ -316,7 +316,7 @@ Webhook handlers are `(request: Request) => Promise<Response>`, usable directly
|
|
|
316
316
|
|
|
317
317
|
- Common options: `onPayment(payment)`, `onError?(error)`, `method?` (the payment method written on the document), `maxBodyBytes?`, `fetch?`; `sandbox?` where the provider has one.
|
|
318
318
|
- Responses: `400` for a bad signature or payload (never reaches `onPayment`), `200` on success (`204` for Revolut, a signed JSON for SimplePay), `500` when `onPayment` throws, so the provider redelivers.
|
|
319
|
-
- `PaymentEvent` is `{ provider, kind: 'paid' | 'refunded' | 'partially-refunded' | 'failed' | 'other', id, eventId?, eventType?, orderRef?, amount?: { value, currency }, refundedAmount?, refunds?: { id, amount, refundedBefore?, createdAt? }[], paidAt?, method, customer?, items?, raw }`. Amounts are in major units (12700 HUF, not minor units). `refunds` lists the individual refunds the provider reported (Barion and SimplePay: all; Revolut and PayPal: the current one; Stripe: the delta of `charge.refunded` keyed by the event ID).
|
|
319
|
+
- `PaymentEvent` is `{ provider, kind: 'paid' | 'refunded' | 'partially-refunded' | 'refund-failed' | 'failed' | 'other', id, eventId?, eventType?, orderRef?, amount?: { value, currency }, refundedAmount?, refunds?: { id, amount, refundedBefore?, createdAt? }[], paidAt?, method, customer?, items?, raw }`. Amounts are in major units (12700 HUF, not minor units). `refunds` lists the individual refunds the provider reported (Barion and SimplePay: all; Revolut and PayPal: the current one; Stripe: the delta of `charge.refunded` keyed by the event ID).
|
|
320
320
|
- `dedupe?: KeyValueStore` and `dedupeTtlSeconds?` (7 days): an event that was already processed successfully is acknowledged without calling `onPayment` again. It is marked only after `onPayment` succeeds.
|
|
321
321
|
|
|
322
322
|
```ts
|
|
@@ -338,12 +338,12 @@ const result = await kassza.issueForPayment(payment, {
|
|
|
338
338
|
})
|
|
339
339
|
```
|
|
340
340
|
|
|
341
|
-
- `paid`: chooses receipt or invoice with `chooseDocument` (override with `document`) and issues it with `createOnce`. `refunded`: reverses that document exactly once. `failed` and `other`: skipped.
|
|
341
|
+
- `paid`: chooses receipt or invoice with `chooseDocument` (override with `document`) and issues it with `createOnce`. `refunded`: reverses that document exactly once; concurrent calls in one process run one after the other, and `lock` (a store with `setIfAbsent`) keeps two processes from reversing at once (`in_progress` while another holds it). A refund that arrives before the payment's document throws `in_progress`, so the provider redelivers it after the paid event. `refund-failed` (Stripe `charge.refund.updated` / `refund.updated` / `refund.failed` with status `failed` or `canceled`): writes nothing and returns `{ kind: 'refund-failed', document, documentNumber, reason, orderNumber }` for a human; skipped without a document. `failed` and `other`: skipped.
|
|
342
342
|
- `partially-refunded`: for an invoice, one corrective invoice per refund (external ID `{orderNumber}/R-{refund}`), with the refund allocated exactly over the original items (`allocateRefund`, house-monotone, never more than an item's original amount across refunds). If the invoice has several VAT rates and no `refundItems` is given, it returns `{ kind: 'refund-proposal', ... }` instead (or allocate proportionally with `partialRefund: 'proportional'`). For a receipt it always returns a `refund-proposal`. Without `payment.refunds` it is skipped with a reason.
|
|
343
343
|
- The order number defaults to `{PROVIDER}-{payment id}`, for example `STRIPE-pi_123`, so the payment and its refund share it.
|
|
344
344
|
- Items come from `items`, then the provider's line items, then one item with the paid amount (`fallbackItemName`). VAT comes from `vatFor`, the provider's per-item rate, then `vat`. Without any, it throws `validation`: kassza never guesses VAT.
|
|
345
345
|
- The document total must equal the paid amount, unless `allowAmountMismatch: true`.
|
|
346
|
-
- It returns `{ kind: 'receipt', number, created, receipt, decision, orderNumber }`, `{ kind: 'invoice', number, created, invoice, decision, orderNumber }`, `{ kind: 'reversal', document, reversedNumber, number?, created, orderNumber }`, `{ kind: 'correction', correctedNumber, created, corrections: { refundId, externalId, number, created, grossTotal, invoice }[], orderNumber }`, `{ kind: 'refund-proposal', document, documentNumber, refunds: { refundId, grossTotal, items }[], reason, orderNumber }` or `{ kind: 'skipped', reason, orderNumber }`.
|
|
346
|
+
- It returns `{ kind: 'receipt', number, created, receipt, decision, orderNumber }`, `{ kind: 'invoice', number, created, invoice, decision, orderNumber }`, `{ kind: 'reversal', document, reversedNumber, number?, created, orderNumber }`, `{ kind: 'correction', correctedNumber, created, corrections: { refundId, externalId, number, created, grossTotal, invoice }[], orderNumber }`, `{ kind: 'refund-proposal', document, documentNumber, refunds: { refundId, grossTotal, items }[], reason, orderNumber }`, `{ kind: 'refund-failed', document, documentNumber, reason, orderNumber }` or `{ kind: 'skipped', reason, orderNumber }`.
|
|
347
347
|
- `issueForPayment(api, payment, options)` from `kassza/payments` does the same with any object that has `invoices` and `receipts` (`createOnce`, `find`, `reverse`), for example a delegated client.
|
|
348
348
|
|
|
349
349
|
### `kassza/batch`
|
package/agents/pitfalls.md
CHANGED
|
@@ -48,6 +48,9 @@ Read this before writing any code that issues invoices or receipts. These rules
|
|
|
48
48
|
| `maintenanceCooldownMs` | After error `1`, kassza sends nothing for the cooldown and throws `maintenance` at once | Switch to a fallback, for example a paper receipt pad |
|
|
49
49
|
| `in_progress` error | Another process holds the `createOnce` lock for this order | Do not issue by hand; call `createOnce` again later (5xx in a webhook) |
|
|
50
50
|
| `store_unavailable` error | The lock store (or a `fail-closed` attempt ledger) is down; nothing was sent | Restore the store, or choose `lockFailure: 'proceed'` / `attemptLedgerMode: 'fail-open'` deliberately |
|
|
51
|
+
| Refund before the payment's document | `issueForPayment` throws `in_progress` on purpose: acknowledging the refund would let the paid redelivery issue a document for returned money | Let the webhook answer 500; acknowledge it only for payments that will never get a document |
|
|
52
|
+
| Stripe refund fails after `charge.refunded` | `charge.refund.updated` gives `refund-failed`; the reversal or corrective invoice stays | Correct the books by hand |
|
|
53
|
+
| Concurrent full refunds on several instances | Only one process at a time may reverse; in one process kassza serializes | Pass `lock` (a store with `setIfAbsent`) to `issueForPayment` |
|
|
51
54
|
| Partial refund on a mixed-VAT invoice | `issueForPayment` returns `refund-proposal`, issues nothing | Pass `refundItems` (what was returned) or `partialRefund: 'proportional'` |
|
|
52
55
|
| `registerPayment` twice | Two payments on the invoice (`additive` defaults to `true`) | Use `registerPaymentOnce({ key })` with a stable bank or payment ID |
|
|
53
56
|
| `szamlaLetoltesPld` (PDF copies) | Obsolete in the XSD; Számlázz.hu ignores it, so kassza does not offer it | Nothing to do |
|
package/dist/batch/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as DateInput } from "../dates-nlGEokCf.cjs";
|
|
2
2
|
import { M as CreateInvoiceInput } from "../context-zGthvNo2.cjs";
|
|
3
3
|
import { t as CreateReceiptInput } from "../types-_HKTOCuQ.cjs";
|
|
4
|
-
import { a as ReceiptsApi, t as InvoicesApi } from "../client-
|
|
5
|
-
import { n as Journal } from "../journal-
|
|
4
|
+
import { a as ReceiptsApi, t as InvoicesApi } from "../client-CXjvVevB.cjs";
|
|
5
|
+
import { n as Journal } from "../journal-Cp_OMWlI.cjs";
|
|
6
6
|
type BillingInterval = "week" | "month" | "quarter" | "year";
|
|
7
7
|
interface BillingPeriodOptions {
|
|
8
8
|
readonly interval: BillingInterval;
|
package/dist/batch/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as DateInput } from "../dates-nlGEokCf.js";
|
|
2
2
|
import { M as CreateInvoiceInput } from "../context-BROX7Krw.js";
|
|
3
3
|
import { t as CreateReceiptInput } from "../types-Z6rQoqHn.js";
|
|
4
|
-
import { a as ReceiptsApi, t as InvoicesApi } from "../client-
|
|
5
|
-
import { n as Journal } from "../journal-
|
|
4
|
+
import { a as ReceiptsApi, t as InvoicesApi } from "../client-CvojBxd9.js";
|
|
5
|
+
import { n as Journal } from "../journal-9pfg0if1.js";
|
|
6
6
|
type BillingInterval = "week" | "month" | "quarter" | "year";
|
|
7
7
|
interface BillingPeriodOptions {
|
|
8
8
|
readonly interval: BillingInterval;
|
package/dist/cli.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const require_errors = require("./errors-Bn6pe6yw.cjs");
|
|
3
|
-
const require_client = require("./client-
|
|
3
|
+
const require_client = require("./client-CYS1_Xaz.cjs");
|
|
4
4
|
const require_serialize = require("./serialize-DEU7r6Bk.cjs");
|
|
5
5
|
const require_create = require("./create-DH5jiZPA.cjs");
|
|
6
6
|
const require_nav = require("./nav-VShZkjg8.cjs");
|
|
7
|
-
const require_server = require("./server-
|
|
7
|
+
const require_server = require("./server-CrmxXPV-.cjs");
|
|
8
8
|
let node_fs_promises = require("node:fs/promises");
|
|
9
9
|
let node_readline = require("node:readline");
|
|
10
10
|
// src/cli/args.ts
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { o as isSzamlazzError, r as SzamlazzError } from "./errors-CGGsW0Y5.js";
|
|
3
|
-
import { s as buildCreateInvoiceXml, t as createKassza } from "./client-
|
|
3
|
+
import { s as buildCreateInvoiceXml, t as createKassza } from "./client-8ElbVwSO.js";
|
|
4
4
|
import { r as el } from "./serialize-CjymGkJj.js";
|
|
5
5
|
import { t as buildCreateReceiptXml } from "./create-BwRslos0.js";
|
|
6
6
|
import { i as navDailyReports, n as describeNavReport } from "./nav-NvNgaONz.js";
|
|
7
|
-
import { n as KASSZA_VERSION, t as createKasszaMcpServer } from "./server-
|
|
7
|
+
import { n as KASSZA_VERSION, t as createKasszaMcpServer } from "./server-CZTJ3562.js";
|
|
8
8
|
import { readFile } from "node:fs/promises";
|
|
9
9
|
import { createInterface } from "node:readline";
|
|
10
10
|
// src/cli/args.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as registerPayment, c as resolveInvoice, d as TAXPAYER_TYPE_CODES, f as KASSZA_AGGREGATOR, g as AGENT_ACTIONS, i as clearPayments, m as emitDocumentEvent, o as optionalAgentDate, r as registerPaymentOnce, s as presentText, t as createReceiptOnce, u as INVOICE_TEMPLATES } from "./create-once-
|
|
1
|
+
import { a as registerPayment, c as resolveInvoice, d as TAXPAYER_TYPE_CODES, f as KASSZA_AGGREGATOR, g as AGENT_ACTIONS, i as clearPayments, m as emitDocumentEvent, o as optionalAgentDate, r as registerPaymentOnce, s as presentText, t as createReceiptOnce, u as INVOICE_TEMPLATES } from "./create-once-DcEjO8QH.js";
|
|
2
2
|
import { i as createAgentError, o as isSzamlazzError, r as SzamlazzError, s as parseErrorCode } from "./errors-CGGsW0Y5.js";
|
|
3
3
|
import { t as base64ToBytes } from "./binary-DuKBSfH-.js";
|
|
4
4
|
import { a as optionalEl, c as childNumber, d as findChildren, l as childText, n as buildXmlDocument, r as el, s as childBoolean, u as findChild } from "./serialize-CjymGkJj.js";
|
|
5
5
|
import { a as looksLikeXml, c as readDocumentHeaders, d as throwIfHeaderError, f as throwIfHttpError, h as unexpectedResponse, m as throwIfXmlFailure, n as parseReceiptResponse, o as parseDoneText, p as throwIfTextError, r as createAgentResponse, s as parseResponseXml, u as throwIfAnyError } from "./parse-1RiSh4vY.js";
|
|
6
6
|
import { i as sessionKeyFor, n as memoryCookieStore, r as mergeSetCookies, t as SESSION_TTL_SECONDS } from "./session-DZeE1ryt.js";
|
|
7
7
|
import { t as emitWarning } from "./warnings-DJ0QvZOp.js";
|
|
8
|
-
import { l as createInvoiceOnce, m as guardOnce, n as issueForPayment, o as convertReceiptToInvoice } from "./issue-
|
|
8
|
+
import { l as createInvoiceOnce, m as guardOnce, n as issueForPayment, o as convertReceiptToInvoice } from "./issue-CUiDvJhQ.js";
|
|
9
9
|
import { r as formatVatRate } from "./vat-B4J5Q0tu.js";
|
|
10
10
|
import { a as summarizeItems } from "./money-f280VT77.js";
|
|
11
11
|
import { a as optionalText, c as requireText, i as optionalAgentDate$1, l as resolveInvoiceReference, o as parseInvoiceResult, s as referenceValue, t as AGENT_XSD_BASE_URL, u as validationError } from "./reference-Cxz0m2zF.js";
|
|
@@ -5,7 +5,7 @@ import { S as VatRate, a as RefundAllocation, s as RefundableItem } from "./inde
|
|
|
5
5
|
import { h as SendReceiptInput, i as ReceiptDefaults, m as ReverseReceiptInput, n as GetReceiptInput, p as ReceiptVatRate, r as Receipt, s as ReceiptOnlyVatCode, t as CreateReceiptInput } from "./types-_HKTOCuQ.cjs";
|
|
6
6
|
import { n as InvoiceDetails, o as InvoiceDetailsPayment, t as GetInvoiceOptions } from "./get-BL4Fr8-P.cjs";
|
|
7
7
|
import { n as InvoiceOnceResult, t as ReceiptOnceResult } from "./create-once-BA0KAHIB.cjs";
|
|
8
|
-
import { i as PaymentEvent, l as PaymentRefund, r as PaymentCustomer, s as PaymentLineItem } from "./types-
|
|
8
|
+
import { i as PaymentEvent, l as PaymentRefund, r as PaymentCustomer, s as PaymentLineItem } from "./types-DGJiVNxr.cjs";
|
|
9
9
|
declare const ONCE_LOCK_KEY_PREFIX = "szamlazz:once:";
|
|
10
10
|
declare const DEFAULT_LOCK_TTL_SECONDS = 600;
|
|
11
11
|
declare const DEFAULT_LOCK_WAIT_MS = 1e4;
|
|
@@ -147,6 +147,7 @@ interface IssueForPaymentOptions {
|
|
|
147
147
|
readonly refundItems?: RefundItemsResolver | undefined;
|
|
148
148
|
readonly receipt?: Partial<Omit<CreateReceiptInput, "items" | "orderNumber" | "callId" | "currency" | "exchangeRate" | "exchangeBank">> | undefined;
|
|
149
149
|
readonly invoice?: Partial<Omit<StandardInvoiceInput, "items" | "buyer" | "type" | "orderNumber" | "paid" | "currency" | "exchangeRate" | "exchangeBank" | "externalId">> | undefined;
|
|
150
|
+
readonly lock?: KeyValueStore | undefined;
|
|
150
151
|
readonly recoveryDelayMs?: number | undefined;
|
|
151
152
|
readonly signal?: AbortSignal | undefined;
|
|
152
153
|
}
|
|
@@ -174,12 +175,19 @@ interface IssuedReversal {
|
|
|
174
175
|
readonly number?: string | undefined;
|
|
175
176
|
readonly created: boolean;
|
|
176
177
|
}
|
|
178
|
+
interface IssuedRefundFailure {
|
|
179
|
+
readonly kind: "refund-failed";
|
|
180
|
+
readonly orderNumber: string;
|
|
181
|
+
readonly document: "receipt" | "invoice";
|
|
182
|
+
readonly documentNumber: string;
|
|
183
|
+
readonly reason: string;
|
|
184
|
+
}
|
|
177
185
|
interface SkippedPayment {
|
|
178
186
|
readonly kind: "skipped";
|
|
179
187
|
readonly orderNumber: string;
|
|
180
188
|
readonly reason: string;
|
|
181
189
|
}
|
|
182
|
-
type IssuedDocument = IssuedReceipt | IssuedInvoice | IssuedReversal | IssuedCorrection | IssuedRefundProposal | SkippedPayment;
|
|
190
|
+
type IssuedDocument = IssuedReceipt | IssuedInvoice | IssuedReversal | IssuedCorrection | IssuedRefundProposal | IssuedRefundFailure | SkippedPayment;
|
|
183
191
|
interface PaymentDocumentsApi {
|
|
184
192
|
readonly invoices: Pick<InvoicesApi, "createOnce" | "find" | "reverse">;
|
|
185
193
|
readonly receipts: Pick<ReceiptsApi, "createOnce" | "find" | "reverse">;
|
|
@@ -310,4 +318,4 @@ interface Kassza {
|
|
|
310
318
|
issueForPayment(payment: PaymentEvent, options?: IssueForPaymentOptions): Promise<IssuedDocument>;
|
|
311
319
|
}
|
|
312
320
|
declare function createKassza(options?: KasszaOptions): Kassza;
|
|
313
|
-
export {
|
|
321
|
+
export { LockFailureMode as $, IssuedCorrection as A, DocumentChoice as B, IssuedReversal as C, buyerFromCustomer as D, SkippedPayment as E, RefundItemsResolver as F, InvoicePdf as G, RECEIPT_MAX_GROSS_HUF as H, RefundProposalLine as I, paymentMarker as J, RegisterPaymentOnceInput as K, correctionExternalId as L, IssuedRefundProposal as M, PartialRefundMode as N, issueForPayment as O, RefundItemsContext as P, DEFAULT_LOCK_WAIT_MS as Q, ChooseDocumentBuyer as R, IssuedRefundFailure as S, PaymentDocumentsApi as T, chooseDocument as U, DocumentDecision as V, ProformaReference as W, CreateOnceOptions as X, InvoiceReference as Y, DEFAULT_LOCK_TTL_SECONDS as Z, conversionExternalId as _, ReceiptsApi as a, IssuedInvoice as b, DEFAULT_TAXPAYER_INVALID_TTL_SECONDS as c, TaxpayerCacheOptions as d, ONCE_LOCK_KEY_PREFIX as et, TaxpayerInfo as f, ConvertedReceipt as g, ConvertReceiptInput as h, KasszaOptions as i, IssuedRefundCorrection as j, paymentOrderNumber as k, DEFAULT_TAXPAYER_TTL_SECONDS as l, TaxpayerAddress as m, Kassza as n, TaxpayerApi as o, TaxpayerTaxNumber as p, RegisteredPaymentOnce as q, KasszaDefaults as r, createKassza as s, InvoicesApi as t, OnceLockOptions as tt, TAXPAYER_CACHE_KEY_PREFIX as u, IssueForPaymentOptions as v, PaymentDocumentItem as w, IssuedReceipt as x, IssuedDocument as y, ChooseDocumentInput as z };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const require_create_once = require("./create-once-
|
|
1
|
+
const require_create_once = require("./create-once-BKUhF1Ov.cjs");
|
|
2
2
|
const require_errors = require("./errors-Bn6pe6yw.cjs");
|
|
3
3
|
const require_binary = require("./binary-CdpKlNNI.cjs");
|
|
4
4
|
const require_serialize = require("./serialize-DEU7r6Bk.cjs");
|
|
5
5
|
const require_parse = require("./parse-CmM5va-p.cjs");
|
|
6
6
|
const require_session = require("./session-BYotpR_s.cjs");
|
|
7
7
|
const require_warnings = require("./warnings-ciSzK6Jc.cjs");
|
|
8
|
-
const require_issue = require("./issue-
|
|
8
|
+
const require_issue = require("./issue-bLLBTt9j.cjs");
|
|
9
9
|
const require_vat = require("./vat-BkoiiKm4.cjs");
|
|
10
10
|
const require_money = require("./money-NtVytaxG.cjs");
|
|
11
11
|
const require_reference = require("./reference-DoY12fc1.cjs");
|
|
@@ -5,7 +5,7 @@ import { S as VatRate, a as RefundAllocation, s as RefundableItem } from "./inde
|
|
|
5
5
|
import { h as SendReceiptInput, i as ReceiptDefaults, m as ReverseReceiptInput, n as GetReceiptInput, p as ReceiptVatRate, r as Receipt, s as ReceiptOnlyVatCode, t as CreateReceiptInput } from "./types-Z6rQoqHn.js";
|
|
6
6
|
import { n as InvoiceDetails, o as InvoiceDetailsPayment, t as GetInvoiceOptions } from "./get-BL4Fr8-P.js";
|
|
7
7
|
import { n as InvoiceOnceResult, t as ReceiptOnceResult } from "./create-once-CoybK69A.js";
|
|
8
|
-
import { i as PaymentEvent, l as PaymentRefund, r as PaymentCustomer, s as PaymentLineItem } from "./types-
|
|
8
|
+
import { i as PaymentEvent, l as PaymentRefund, r as PaymentCustomer, s as PaymentLineItem } from "./types-DPnHIwQ_.js";
|
|
9
9
|
declare const ONCE_LOCK_KEY_PREFIX = "szamlazz:once:";
|
|
10
10
|
declare const DEFAULT_LOCK_TTL_SECONDS = 600;
|
|
11
11
|
declare const DEFAULT_LOCK_WAIT_MS = 1e4;
|
|
@@ -147,6 +147,7 @@ interface IssueForPaymentOptions {
|
|
|
147
147
|
readonly refundItems?: RefundItemsResolver | undefined;
|
|
148
148
|
readonly receipt?: Partial<Omit<CreateReceiptInput, "items" | "orderNumber" | "callId" | "currency" | "exchangeRate" | "exchangeBank">> | undefined;
|
|
149
149
|
readonly invoice?: Partial<Omit<StandardInvoiceInput, "items" | "buyer" | "type" | "orderNumber" | "paid" | "currency" | "exchangeRate" | "exchangeBank" | "externalId">> | undefined;
|
|
150
|
+
readonly lock?: KeyValueStore | undefined;
|
|
150
151
|
readonly recoveryDelayMs?: number | undefined;
|
|
151
152
|
readonly signal?: AbortSignal | undefined;
|
|
152
153
|
}
|
|
@@ -174,12 +175,19 @@ interface IssuedReversal {
|
|
|
174
175
|
readonly number?: string | undefined;
|
|
175
176
|
readonly created: boolean;
|
|
176
177
|
}
|
|
178
|
+
interface IssuedRefundFailure {
|
|
179
|
+
readonly kind: "refund-failed";
|
|
180
|
+
readonly orderNumber: string;
|
|
181
|
+
readonly document: "receipt" | "invoice";
|
|
182
|
+
readonly documentNumber: string;
|
|
183
|
+
readonly reason: string;
|
|
184
|
+
}
|
|
177
185
|
interface SkippedPayment {
|
|
178
186
|
readonly kind: "skipped";
|
|
179
187
|
readonly orderNumber: string;
|
|
180
188
|
readonly reason: string;
|
|
181
189
|
}
|
|
182
|
-
type IssuedDocument = IssuedReceipt | IssuedInvoice | IssuedReversal | IssuedCorrection | IssuedRefundProposal | SkippedPayment;
|
|
190
|
+
type IssuedDocument = IssuedReceipt | IssuedInvoice | IssuedReversal | IssuedCorrection | IssuedRefundProposal | IssuedRefundFailure | SkippedPayment;
|
|
183
191
|
interface PaymentDocumentsApi {
|
|
184
192
|
readonly invoices: Pick<InvoicesApi, "createOnce" | "find" | "reverse">;
|
|
185
193
|
readonly receipts: Pick<ReceiptsApi, "createOnce" | "find" | "reverse">;
|
|
@@ -310,4 +318,4 @@ interface Kassza {
|
|
|
310
318
|
issueForPayment(payment: PaymentEvent, options?: IssueForPaymentOptions): Promise<IssuedDocument>;
|
|
311
319
|
}
|
|
312
320
|
declare function createKassza(options?: KasszaOptions): Kassza;
|
|
313
|
-
export {
|
|
321
|
+
export { LockFailureMode as $, IssuedCorrection as A, DocumentChoice as B, IssuedReversal as C, buyerFromCustomer as D, SkippedPayment as E, RefundItemsResolver as F, InvoicePdf as G, RECEIPT_MAX_GROSS_HUF as H, RefundProposalLine as I, paymentMarker as J, RegisterPaymentOnceInput as K, correctionExternalId as L, IssuedRefundProposal as M, PartialRefundMode as N, issueForPayment as O, RefundItemsContext as P, DEFAULT_LOCK_WAIT_MS as Q, ChooseDocumentBuyer as R, IssuedRefundFailure as S, PaymentDocumentsApi as T, chooseDocument as U, DocumentDecision as V, ProformaReference as W, CreateOnceOptions as X, InvoiceReference as Y, DEFAULT_LOCK_TTL_SECONDS as Z, conversionExternalId as _, ReceiptsApi as a, IssuedInvoice as b, DEFAULT_TAXPAYER_INVALID_TTL_SECONDS as c, TaxpayerCacheOptions as d, ONCE_LOCK_KEY_PREFIX as et, TaxpayerInfo as f, ConvertedReceipt as g, ConvertReceiptInput as h, KasszaOptions as i, IssuedRefundCorrection as j, paymentOrderNumber as k, DEFAULT_TAXPAYER_TTL_SECONDS as l, TaxpayerAddress as m, Kassza as n, TaxpayerApi as o, TaxpayerTaxNumber as p, RegisteredPaymentOnce as q, KasszaDefaults as r, createKassza as s, InvoicesApi as t, OnceLockOptions as tt, TAXPAYER_CACHE_KEY_PREFIX as u, IssueForPaymentOptions as v, PaymentDocumentItem as w, IssuedReceipt as x, IssuedDocument as y, ChooseDocumentInput as z };
|
|
@@ -3,7 +3,7 @@ const require_binary = require("./binary-CdpKlNNI.cjs");
|
|
|
3
3
|
const require_serialize = require("./serialize-DEU7r6Bk.cjs");
|
|
4
4
|
const require_warnings = require("./warnings-ciSzK6Jc.cjs");
|
|
5
5
|
const require_once = require("./once-BmXfrNbQ.cjs");
|
|
6
|
-
const require_issue = require("./issue-
|
|
6
|
+
const require_issue = require("./issue-bLLBTt9j.cjs");
|
|
7
7
|
const require_dates = require("./dates-oOp3ypPP.cjs");
|
|
8
8
|
const require_vat = require("./vat-BkoiiKm4.cjs");
|
|
9
9
|
const require_money = require("./money-NtVytaxG.cjs");
|
|
@@ -3,7 +3,7 @@ import { i as encodeUtf8 } from "./binary-DuKBSfH-.js";
|
|
|
3
3
|
import { a as optionalEl, n as buildXmlDocument, r as el } from "./serialize-CjymGkJj.js";
|
|
4
4
|
import { t as emitWarning } from "./warnings-DJ0QvZOp.js";
|
|
5
5
|
import { a as unknownOutcomeError, i as resolveRecoveryDelay, n as isUncertainOutcome, r as recoverAfterFailure } from "./once-CMhDPrs7.js";
|
|
6
|
-
import { m as guardOnce } from "./issue-
|
|
6
|
+
import { m as guardOnce } from "./issue-CUiDvJhQ.js";
|
|
7
7
|
import { a as todayInBudapest, n as toAgentDate, t as addBudapestDays } from "./dates-DWsZOdaO.js";
|
|
8
8
|
import { i as isHuf } from "./vat-B4J5Q0tu.js";
|
|
9
9
|
import { n as calculateInvoiceItem } from "./money-f280VT77.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_errors = require("../errors-Bn6pe6yw.cjs");
|
|
3
|
-
const require_client = require("../client-
|
|
3
|
+
const require_client = require("../client-CYS1_Xaz.cjs");
|
|
4
4
|
const require_serialize = require("../serialize-DEU7r6Bk.cjs");
|
|
5
5
|
const require_parse = require("../parse-CmM5va-p.cjs");
|
|
6
6
|
const require_dates = require("../dates-oOp3ypPP.cjs");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as DateInput } from "../dates-nlGEokCf.cjs";
|
|
2
2
|
import { D as XmlNode, O as AgentResponse, dt as suggestedPrefix, l as SzamlazzOptions, r as AgentContext, s as RequestOptions, st as SzamlazzError } from "../context-zGthvNo2.cjs";
|
|
3
|
-
import { i as KasszaOptions, n as Kassza, r as KasszaDefaults } from "../client-
|
|
3
|
+
import { i as KasszaOptions, n as Kassza, r as KasszaDefaults } from "../client-CXjvVevB.cjs";
|
|
4
4
|
export declare const CONNECT_PRINCIPAL_NAMESPACE = "http://www.szamlazz.hu/xmlcegmb";
|
|
5
5
|
export declare const CONNECT_PRINCIPAL_SCHEMA_LOCATION = "http://www.szamlazz.hu/docs/xsds/agentmb/xmlcegmb.xsd";
|
|
6
6
|
export declare const DELEGATE_PREFIX_PATTERN: RegExp;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as DateInput } from "../dates-nlGEokCf.js";
|
|
2
2
|
import { D as XmlNode, O as AgentResponse, dt as suggestedPrefix, l as SzamlazzOptions, r as AgentContext, s as RequestOptions, st as SzamlazzError } from "../context-BROX7Krw.js";
|
|
3
|
-
import { i as KasszaOptions, n as Kassza, r as KasszaDefaults } from "../client-
|
|
3
|
+
import { i as KasszaOptions, n as Kassza, r as KasszaDefaults } from "../client-CvojBxd9.js";
|
|
4
4
|
export declare const CONNECT_PRINCIPAL_NAMESPACE = "http://www.szamlazz.hu/xmlcegmb";
|
|
5
5
|
export declare const CONNECT_PRINCIPAL_SCHEMA_LOCATION = "http://www.szamlazz.hu/docs/xsds/agentmb/xmlcegmb.xsd";
|
|
6
6
|
export declare const DELEGATE_PREFIX_PATTERN: RegExp;
|
package/dist/delegation/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as suggestedPrefix, o as isSzamlazzError, r as SzamlazzError } from "../errors-CGGsW0Y5.js";
|
|
2
|
-
import { a as queryTaxpayer, c as createAgentContext, o as getInvoicePdf, t as createKassza } from "../client-
|
|
2
|
+
import { a as queryTaxpayer, c as createAgentContext, o as getInvoicePdf, t as createKassza } from "../client-8ElbVwSO.js";
|
|
3
3
|
import { a as optionalEl, n as buildXmlDocument, r as el } from "../serialize-CjymGkJj.js";
|
|
4
4
|
import { h as unexpectedResponse, i as decodeHeaderValue, l as readHeader, u as throwIfAnyError } from "../parse-1RiSh4vY.js";
|
|
5
5
|
import { n as toAgentDate } from "../dates-DWsZOdaO.js";
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_create_once = require("./create-once-
|
|
2
|
+
const require_create_once = require("./create-once-BKUhF1Ov.cjs");
|
|
3
3
|
const require_errors = require("./errors-Bn6pe6yw.cjs");
|
|
4
|
-
const require_client = require("./client-
|
|
4
|
+
const require_client = require("./client-CYS1_Xaz.cjs");
|
|
5
5
|
const require_binary = require("./binary-CdpKlNNI.cjs");
|
|
6
6
|
const require_session = require("./session-BYotpR_s.cjs");
|
|
7
|
-
const require_issue = require("./issue-
|
|
7
|
+
const require_issue = require("./issue-bLLBTt9j.cjs");
|
|
8
8
|
const require_dates = require("./dates-oOp3ypPP.cjs");
|
|
9
9
|
exports.AGENT_ACTIONS = require_create_once.AGENT_ACTIONS;
|
|
10
10
|
exports.AGENT_ERROR_CODES = require_errors.AGENT_ERROR_CODES;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,9 +5,9 @@ import { a as storeCapabilities, i as memoryStore, n as KeyValueStore, r as Stor
|
|
|
5
5
|
import { S as VatRate, d as ItemAmounts, f as ItemPriceInput } from "./index-CinpAhQM.cjs";
|
|
6
6
|
import { a as ReceiptItem, c as ReceiptPayment, d as ReceiptTotals, f as ReceiptType, h as SendReceiptInput, i as ReceiptDefaults, l as ReceiptPaymentInput, m as ReverseReceiptInput, n as GetReceiptInput, o as ReceiptItemInput, p as ReceiptVatRate, r as Receipt, s as ReceiptOnlyVatCode, t as CreateReceiptInput, u as ReceiptPdfTemplate } from "./types-_HKTOCuQ.cjs";
|
|
7
7
|
import { r as memoryCookieStore, t as CookieStore } from "./session-BBbSXlx3.cjs";
|
|
8
|
-
import { $ as
|
|
8
|
+
import { $ as LockFailureMode, A as IssuedCorrection, B as DocumentChoice, C as IssuedReversal, D as buyerFromCustomer, E as SkippedPayment, F as RefundItemsResolver, G as InvoicePdf, H as RECEIPT_MAX_GROSS_HUF, I as RefundProposalLine, J as paymentMarker, K as RegisterPaymentOnceInput, L as correctionExternalId, M as IssuedRefundProposal, N as PartialRefundMode, O as issueForPayment, P as RefundItemsContext, Q as DEFAULT_LOCK_WAIT_MS, R as ChooseDocumentBuyer, S as IssuedRefundFailure, T as PaymentDocumentsApi, U as chooseDocument, V as DocumentDecision, W as ProformaReference, X as CreateOnceOptions, Y as InvoiceReference, Z as DEFAULT_LOCK_TTL_SECONDS, _ as conversionExternalId, a as ReceiptsApi, b as IssuedInvoice, c as DEFAULT_TAXPAYER_INVALID_TTL_SECONDS, d as TaxpayerCacheOptions, et as ONCE_LOCK_KEY_PREFIX, f as TaxpayerInfo, g as ConvertedReceipt, h as ConvertReceiptInput, i as KasszaOptions, j as IssuedRefundCorrection, k as paymentOrderNumber, l as DEFAULT_TAXPAYER_TTL_SECONDS, m as TaxpayerAddress, n as Kassza, o as TaxpayerApi, p as TaxpayerTaxNumber, q as RegisteredPaymentOnce, r as KasszaDefaults, s as createKassza, t as InvoicesApi, tt as OnceLockOptions, u as TAXPAYER_CACHE_KEY_PREFIX, v as IssueForPaymentOptions, w as PaymentDocumentItem, x as IssuedReceipt, y as IssuedDocument, z as ChooseDocumentInput } from "./client-CXjvVevB.cjs";
|
|
9
9
|
import { a as InvoiceDetailsItem, c as InvoiceDetailsTotals, i as InvoiceDetailsHeader, l as InvoiceDocumentType, n as InvoiceDetails, o as InvoiceDetailsPayment, r as InvoiceDetailsBuyer, s as InvoiceDetailsSeller, t as GetInvoiceOptions } from "./get-BL4Fr8-P.cjs";
|
|
10
10
|
import { n as InvoiceOnceResult, r as invoiceOnceExternalId, t as ReceiptOnceResult } from "./create-once-BA0KAHIB.cjs";
|
|
11
|
-
import { a as PaymentEventKind, c as PaymentProvider, i as PaymentEvent, l as PaymentRefund, n as PaymentAmount, r as PaymentCustomer, s as PaymentLineItem, t as PaymentAddress } from "./types-
|
|
11
|
+
import { a as PaymentEventKind, c as PaymentProvider, i as PaymentEvent, l as PaymentRefund, n as PaymentAmount, r as PaymentCustomer, s as PaymentLineItem, t as PaymentAddress } from "./types-DGJiVNxr.cjs";
|
|
12
12
|
export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
13
|
-
export { AGENT_ACTIONS, AGENT_ERROR_CODES, ATTEMPT_LEDGER_KEY_PREFIX, ATTEMPT_LEDGER_TTL_SECONDS, type AgentAction, type AgentAttachment, type AgentCompleteEvent, type AgentErrorCodeInfo, type AgentErrorEvent, type AgentRequestEvent, type AgentResponseEvent, type AttemptLedgerMode, type Awaitable, type BuyerLedger, type ChooseDocumentBuyer, type ChooseDocumentInput, type ClearPaymentsInput, type ConvertReceiptInput, type ConvertedReceipt, type CookieStore, type CorrectiveInvoiceInput, type CourierService, type CreateInvoiceInput, type CreateOnceOptions, type CreateReceiptInput, type CreatedInvoice, type CreatedInvoiceItem, type Currency, DEFAULT_LOCK_TTL_SECONDS, DEFAULT_LOCK_WAIT_MS, DEFAULT_TAXPAYER_INVALID_TTL_SECONDS, DEFAULT_TAXPAYER_TTL_SECONDS, type DateInput, type DocumentChoice, type DocumentDecision, type DocumentErrorHandler, type DocumentErrorMode, type DocumentEvent, type DocumentHook, DocumentHookError, type FinalInvoiceInput, type GetInvoiceOptions, type GetReceiptInput, type InvoiceBuyer, type InvoiceCreatedEvent, type InvoiceDefaults, type InvoiceDetails, type InvoiceDetailsBuyer, type InvoiceDetailsHeader, type InvoiceDetailsItem, type InvoiceDetailsPayment, type InvoiceDetailsSeller, type InvoiceDetailsTotals, type InvoiceDocumentType, type InvoiceItemInput, type InvoiceLanguage, type InvoiceOnceResult, type InvoicePaymentEvent, type InvoicePdf, type InvoicePostalAddress, type InvoicePreview, type InvoiceReference, type InvoiceReversedEvent, type InvoiceSeller, type InvoiceTemplate, type InvoiceType, type InvoicesApi, type IssueForPaymentOptions, type IssuedCorrection, type IssuedDocument, type IssuedInvoice, type IssuedReceipt, type IssuedRefundCorrection, type IssuedRefundProposal, type IssuedReversal, type ItemAmounts, type ItemLedger, type ItemPriceInput, KASSZA_ERROR_DOCS_URL, type Kassza, type KasszaDefaults, type KasszaOptions, type KasszaWarning, type KasszaWarningKind, type KeyValueStore, type LockFailureMode, MAX_INVOICE_ATTACHMENTS, type MplWaybill, ONCE_LOCK_KEY_PREFIX, type OnceLockOptions, type PartialRefundMode, type PaymentAddress, type PaymentAmount, type PaymentCustomer, type PaymentDocumentItem, type PaymentDocumentsApi, type PaymentEntry, type PaymentEvent, type PaymentEventKind, type PaymentLineItem, type PaymentProvider, type PaymentRefund, type PickPackPointWaybill, type ProformaReference, RECEIPT_MAX_GROSS_HUF, type Receipt, type ReceiptCreatedEvent, type ReceiptDefaults, type ReceiptItem, type ReceiptItemInput, type ReceiptOnceResult, type ReceiptOnlyVatCode, type ReceiptPayment, type ReceiptPaymentInput, type ReceiptPdfTemplate, type ReceiptReversedEvent, type ReceiptTotals, type ReceiptType, type ReceiptVatRate, type ReceiptsApi, type RefundItemsContext, type RefundItemsResolver, type RefundProposalLine, type RegisterPaymentInput, type RegisterPaymentOnceInput, type RegisteredPayment, type RegisteredPaymentOnce, type RequestOptions, type ReverseInvoiceInput, type ReverseReceiptInput, type ReversedInvoice, SZAMLAZZ_AGENT_URL, type SendReceiptInput, type SkippedPayment, type SprinterWaybill, type StandardInvoiceInput, type StoreCapabilities, SzamlazzError, type SzamlazzErrorCategory, type SzamlazzHooks, type SzamlazzOptions, TAXPAYER_CACHE_KEY_PREFIX, type TaxpayerAddress, type TaxpayerApi, type TaxpayerCacheOptions, type TaxpayerInfo, type TaxpayerTaxNumber, type TaxpayerType, type TransOFlexWaybill, type VatRate, type WarningHook, type Waybill, addBudapestDays, attemptLedgerKey, buyerFromCustomer, chooseDocument, conversionExternalId, correctionExternalId, createKassza, errorCodeDocsUrl, invoiceOnceExternalId, isDocumentHookError, isSzamlazzError, issueForPayment, memoryCookieStore, memoryStore, paymentMarker, paymentOrderNumber, storeCapabilities, suggestedPrefix, toBudapestDate, toBudapestTimestamp, todayInBudapest };
|
|
13
|
+
export { AGENT_ACTIONS, AGENT_ERROR_CODES, ATTEMPT_LEDGER_KEY_PREFIX, ATTEMPT_LEDGER_TTL_SECONDS, type AgentAction, type AgentAttachment, type AgentCompleteEvent, type AgentErrorCodeInfo, type AgentErrorEvent, type AgentRequestEvent, type AgentResponseEvent, type AttemptLedgerMode, type Awaitable, type BuyerLedger, type ChooseDocumentBuyer, type ChooseDocumentInput, type ClearPaymentsInput, type ConvertReceiptInput, type ConvertedReceipt, type CookieStore, type CorrectiveInvoiceInput, type CourierService, type CreateInvoiceInput, type CreateOnceOptions, type CreateReceiptInput, type CreatedInvoice, type CreatedInvoiceItem, type Currency, DEFAULT_LOCK_TTL_SECONDS, DEFAULT_LOCK_WAIT_MS, DEFAULT_TAXPAYER_INVALID_TTL_SECONDS, DEFAULT_TAXPAYER_TTL_SECONDS, type DateInput, type DocumentChoice, type DocumentDecision, type DocumentErrorHandler, type DocumentErrorMode, type DocumentEvent, type DocumentHook, DocumentHookError, type FinalInvoiceInput, type GetInvoiceOptions, type GetReceiptInput, type InvoiceBuyer, type InvoiceCreatedEvent, type InvoiceDefaults, type InvoiceDetails, type InvoiceDetailsBuyer, type InvoiceDetailsHeader, type InvoiceDetailsItem, type InvoiceDetailsPayment, type InvoiceDetailsSeller, type InvoiceDetailsTotals, type InvoiceDocumentType, type InvoiceItemInput, type InvoiceLanguage, type InvoiceOnceResult, type InvoicePaymentEvent, type InvoicePdf, type InvoicePostalAddress, type InvoicePreview, type InvoiceReference, type InvoiceReversedEvent, type InvoiceSeller, type InvoiceTemplate, type InvoiceType, type InvoicesApi, type IssueForPaymentOptions, type IssuedCorrection, type IssuedDocument, type IssuedInvoice, type IssuedReceipt, type IssuedRefundCorrection, type IssuedRefundFailure, type IssuedRefundProposal, type IssuedReversal, type ItemAmounts, type ItemLedger, type ItemPriceInput, KASSZA_ERROR_DOCS_URL, type Kassza, type KasszaDefaults, type KasszaOptions, type KasszaWarning, type KasszaWarningKind, type KeyValueStore, type LockFailureMode, MAX_INVOICE_ATTACHMENTS, type MplWaybill, ONCE_LOCK_KEY_PREFIX, type OnceLockOptions, type PartialRefundMode, type PaymentAddress, type PaymentAmount, type PaymentCustomer, type PaymentDocumentItem, type PaymentDocumentsApi, type PaymentEntry, type PaymentEvent, type PaymentEventKind, type PaymentLineItem, type PaymentProvider, type PaymentRefund, type PickPackPointWaybill, type ProformaReference, RECEIPT_MAX_GROSS_HUF, type Receipt, type ReceiptCreatedEvent, type ReceiptDefaults, type ReceiptItem, type ReceiptItemInput, type ReceiptOnceResult, type ReceiptOnlyVatCode, type ReceiptPayment, type ReceiptPaymentInput, type ReceiptPdfTemplate, type ReceiptReversedEvent, type ReceiptTotals, type ReceiptType, type ReceiptVatRate, type ReceiptsApi, type RefundItemsContext, type RefundItemsResolver, type RefundProposalLine, type RegisterPaymentInput, type RegisterPaymentOnceInput, type RegisteredPayment, type RegisteredPaymentOnce, type RequestOptions, type ReverseInvoiceInput, type ReverseReceiptInput, type ReversedInvoice, SZAMLAZZ_AGENT_URL, type SendReceiptInput, type SkippedPayment, type SprinterWaybill, type StandardInvoiceInput, type StoreCapabilities, SzamlazzError, type SzamlazzErrorCategory, type SzamlazzHooks, type SzamlazzOptions, TAXPAYER_CACHE_KEY_PREFIX, type TaxpayerAddress, type TaxpayerApi, type TaxpayerCacheOptions, type TaxpayerInfo, type TaxpayerTaxNumber, type TaxpayerType, type TransOFlexWaybill, type VatRate, type WarningHook, type Waybill, addBudapestDays, attemptLedgerKey, buyerFromCustomer, chooseDocument, conversionExternalId, correctionExternalId, createKassza, errorCodeDocsUrl, invoiceOnceExternalId, isDocumentHookError, isSzamlazzError, issueForPayment, memoryCookieStore, memoryStore, paymentMarker, paymentOrderNumber, storeCapabilities, suggestedPrefix, toBudapestDate, toBudapestTimestamp, todayInBudapest };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { a as storeCapabilities, i as memoryStore, n as KeyValueStore, r as Stor
|
|
|
5
5
|
import { S as VatRate, d as ItemAmounts, f as ItemPriceInput } from "./index-CinpAhQM.js";
|
|
6
6
|
import { a as ReceiptItem, c as ReceiptPayment, d as ReceiptTotals, f as ReceiptType, h as SendReceiptInput, i as ReceiptDefaults, l as ReceiptPaymentInput, m as ReverseReceiptInput, n as GetReceiptInput, o as ReceiptItemInput, p as ReceiptVatRate, r as Receipt, s as ReceiptOnlyVatCode, t as CreateReceiptInput, u as ReceiptPdfTemplate } from "./types-Z6rQoqHn.js";
|
|
7
7
|
import { r as memoryCookieStore, t as CookieStore } from "./session-mKtpAeUB.js";
|
|
8
|
-
import { $ as
|
|
8
|
+
import { $ as LockFailureMode, A as IssuedCorrection, B as DocumentChoice, C as IssuedReversal, D as buyerFromCustomer, E as SkippedPayment, F as RefundItemsResolver, G as InvoicePdf, H as RECEIPT_MAX_GROSS_HUF, I as RefundProposalLine, J as paymentMarker, K as RegisterPaymentOnceInput, L as correctionExternalId, M as IssuedRefundProposal, N as PartialRefundMode, O as issueForPayment, P as RefundItemsContext, Q as DEFAULT_LOCK_WAIT_MS, R as ChooseDocumentBuyer, S as IssuedRefundFailure, T as PaymentDocumentsApi, U as chooseDocument, V as DocumentDecision, W as ProformaReference, X as CreateOnceOptions, Y as InvoiceReference, Z as DEFAULT_LOCK_TTL_SECONDS, _ as conversionExternalId, a as ReceiptsApi, b as IssuedInvoice, c as DEFAULT_TAXPAYER_INVALID_TTL_SECONDS, d as TaxpayerCacheOptions, et as ONCE_LOCK_KEY_PREFIX, f as TaxpayerInfo, g as ConvertedReceipt, h as ConvertReceiptInput, i as KasszaOptions, j as IssuedRefundCorrection, k as paymentOrderNumber, l as DEFAULT_TAXPAYER_TTL_SECONDS, m as TaxpayerAddress, n as Kassza, o as TaxpayerApi, p as TaxpayerTaxNumber, q as RegisteredPaymentOnce, r as KasszaDefaults, s as createKassza, t as InvoicesApi, tt as OnceLockOptions, u as TAXPAYER_CACHE_KEY_PREFIX, v as IssueForPaymentOptions, w as PaymentDocumentItem, x as IssuedReceipt, y as IssuedDocument, z as ChooseDocumentInput } from "./client-CvojBxd9.js";
|
|
9
9
|
import { a as InvoiceDetailsItem, c as InvoiceDetailsTotals, i as InvoiceDetailsHeader, l as InvoiceDocumentType, n as InvoiceDetails, o as InvoiceDetailsPayment, r as InvoiceDetailsBuyer, s as InvoiceDetailsSeller, t as GetInvoiceOptions } from "./get-BL4Fr8-P.js";
|
|
10
10
|
import { n as InvoiceOnceResult, r as invoiceOnceExternalId, t as ReceiptOnceResult } from "./create-once-CoybK69A.js";
|
|
11
|
-
import { a as PaymentEventKind, c as PaymentProvider, i as PaymentEvent, l as PaymentRefund, n as PaymentAmount, r as PaymentCustomer, s as PaymentLineItem, t as PaymentAddress } from "./types-
|
|
11
|
+
import { a as PaymentEventKind, c as PaymentProvider, i as PaymentEvent, l as PaymentRefund, n as PaymentAmount, r as PaymentCustomer, s as PaymentLineItem, t as PaymentAddress } from "./types-DPnHIwQ_.js";
|
|
12
12
|
export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
13
|
-
export { AGENT_ACTIONS, AGENT_ERROR_CODES, ATTEMPT_LEDGER_KEY_PREFIX, ATTEMPT_LEDGER_TTL_SECONDS, type AgentAction, type AgentAttachment, type AgentCompleteEvent, type AgentErrorCodeInfo, type AgentErrorEvent, type AgentRequestEvent, type AgentResponseEvent, type AttemptLedgerMode, type Awaitable, type BuyerLedger, type ChooseDocumentBuyer, type ChooseDocumentInput, type ClearPaymentsInput, type ConvertReceiptInput, type ConvertedReceipt, type CookieStore, type CorrectiveInvoiceInput, type CourierService, type CreateInvoiceInput, type CreateOnceOptions, type CreateReceiptInput, type CreatedInvoice, type CreatedInvoiceItem, type Currency, DEFAULT_LOCK_TTL_SECONDS, DEFAULT_LOCK_WAIT_MS, DEFAULT_TAXPAYER_INVALID_TTL_SECONDS, DEFAULT_TAXPAYER_TTL_SECONDS, type DateInput, type DocumentChoice, type DocumentDecision, type DocumentErrorHandler, type DocumentErrorMode, type DocumentEvent, type DocumentHook, DocumentHookError, type FinalInvoiceInput, type GetInvoiceOptions, type GetReceiptInput, type InvoiceBuyer, type InvoiceCreatedEvent, type InvoiceDefaults, type InvoiceDetails, type InvoiceDetailsBuyer, type InvoiceDetailsHeader, type InvoiceDetailsItem, type InvoiceDetailsPayment, type InvoiceDetailsSeller, type InvoiceDetailsTotals, type InvoiceDocumentType, type InvoiceItemInput, type InvoiceLanguage, type InvoiceOnceResult, type InvoicePaymentEvent, type InvoicePdf, type InvoicePostalAddress, type InvoicePreview, type InvoiceReference, type InvoiceReversedEvent, type InvoiceSeller, type InvoiceTemplate, type InvoiceType, type InvoicesApi, type IssueForPaymentOptions, type IssuedCorrection, type IssuedDocument, type IssuedInvoice, type IssuedReceipt, type IssuedRefundCorrection, type IssuedRefundProposal, type IssuedReversal, type ItemAmounts, type ItemLedger, type ItemPriceInput, KASSZA_ERROR_DOCS_URL, type Kassza, type KasszaDefaults, type KasszaOptions, type KasszaWarning, type KasszaWarningKind, type KeyValueStore, type LockFailureMode, MAX_INVOICE_ATTACHMENTS, type MplWaybill, ONCE_LOCK_KEY_PREFIX, type OnceLockOptions, type PartialRefundMode, type PaymentAddress, type PaymentAmount, type PaymentCustomer, type PaymentDocumentItem, type PaymentDocumentsApi, type PaymentEntry, type PaymentEvent, type PaymentEventKind, type PaymentLineItem, type PaymentProvider, type PaymentRefund, type PickPackPointWaybill, type ProformaReference, RECEIPT_MAX_GROSS_HUF, type Receipt, type ReceiptCreatedEvent, type ReceiptDefaults, type ReceiptItem, type ReceiptItemInput, type ReceiptOnceResult, type ReceiptOnlyVatCode, type ReceiptPayment, type ReceiptPaymentInput, type ReceiptPdfTemplate, type ReceiptReversedEvent, type ReceiptTotals, type ReceiptType, type ReceiptVatRate, type ReceiptsApi, type RefundItemsContext, type RefundItemsResolver, type RefundProposalLine, type RegisterPaymentInput, type RegisterPaymentOnceInput, type RegisteredPayment, type RegisteredPaymentOnce, type RequestOptions, type ReverseInvoiceInput, type ReverseReceiptInput, type ReversedInvoice, SZAMLAZZ_AGENT_URL, type SendReceiptInput, type SkippedPayment, type SprinterWaybill, type StandardInvoiceInput, type StoreCapabilities, SzamlazzError, type SzamlazzErrorCategory, type SzamlazzHooks, type SzamlazzOptions, TAXPAYER_CACHE_KEY_PREFIX, type TaxpayerAddress, type TaxpayerApi, type TaxpayerCacheOptions, type TaxpayerInfo, type TaxpayerTaxNumber, type TaxpayerType, type TransOFlexWaybill, type VatRate, type WarningHook, type Waybill, addBudapestDays, attemptLedgerKey, buyerFromCustomer, chooseDocument, conversionExternalId, correctionExternalId, createKassza, errorCodeDocsUrl, invoiceOnceExternalId, isDocumentHookError, isSzamlazzError, issueForPayment, memoryCookieStore, memoryStore, paymentMarker, paymentOrderNumber, storeCapabilities, suggestedPrefix, toBudapestDate, toBudapestTimestamp, todayInBudapest };
|
|
13
|
+
export { AGENT_ACTIONS, AGENT_ERROR_CODES, ATTEMPT_LEDGER_KEY_PREFIX, ATTEMPT_LEDGER_TTL_SECONDS, type AgentAction, type AgentAttachment, type AgentCompleteEvent, type AgentErrorCodeInfo, type AgentErrorEvent, type AgentRequestEvent, type AgentResponseEvent, type AttemptLedgerMode, type Awaitable, type BuyerLedger, type ChooseDocumentBuyer, type ChooseDocumentInput, type ClearPaymentsInput, type ConvertReceiptInput, type ConvertedReceipt, type CookieStore, type CorrectiveInvoiceInput, type CourierService, type CreateInvoiceInput, type CreateOnceOptions, type CreateReceiptInput, type CreatedInvoice, type CreatedInvoiceItem, type Currency, DEFAULT_LOCK_TTL_SECONDS, DEFAULT_LOCK_WAIT_MS, DEFAULT_TAXPAYER_INVALID_TTL_SECONDS, DEFAULT_TAXPAYER_TTL_SECONDS, type DateInput, type DocumentChoice, type DocumentDecision, type DocumentErrorHandler, type DocumentErrorMode, type DocumentEvent, type DocumentHook, DocumentHookError, type FinalInvoiceInput, type GetInvoiceOptions, type GetReceiptInput, type InvoiceBuyer, type InvoiceCreatedEvent, type InvoiceDefaults, type InvoiceDetails, type InvoiceDetailsBuyer, type InvoiceDetailsHeader, type InvoiceDetailsItem, type InvoiceDetailsPayment, type InvoiceDetailsSeller, type InvoiceDetailsTotals, type InvoiceDocumentType, type InvoiceItemInput, type InvoiceLanguage, type InvoiceOnceResult, type InvoicePaymentEvent, type InvoicePdf, type InvoicePostalAddress, type InvoicePreview, type InvoiceReference, type InvoiceReversedEvent, type InvoiceSeller, type InvoiceTemplate, type InvoiceType, type InvoicesApi, type IssueForPaymentOptions, type IssuedCorrection, type IssuedDocument, type IssuedInvoice, type IssuedReceipt, type IssuedRefundCorrection, type IssuedRefundFailure, type IssuedRefundProposal, type IssuedReversal, type ItemAmounts, type ItemLedger, type ItemPriceInput, KASSZA_ERROR_DOCS_URL, type Kassza, type KasszaDefaults, type KasszaOptions, type KasszaWarning, type KasszaWarningKind, type KeyValueStore, type LockFailureMode, MAX_INVOICE_ATTACHMENTS, type MplWaybill, ONCE_LOCK_KEY_PREFIX, type OnceLockOptions, type PartialRefundMode, type PaymentAddress, type PaymentAmount, type PaymentCustomer, type PaymentDocumentItem, type PaymentDocumentsApi, type PaymentEntry, type PaymentEvent, type PaymentEventKind, type PaymentLineItem, type PaymentProvider, type PaymentRefund, type PickPackPointWaybill, type ProformaReference, RECEIPT_MAX_GROSS_HUF, type Receipt, type ReceiptCreatedEvent, type ReceiptDefaults, type ReceiptItem, type ReceiptItemInput, type ReceiptOnceResult, type ReceiptOnlyVatCode, type ReceiptPayment, type ReceiptPaymentInput, type ReceiptPdfTemplate, type ReceiptReversedEvent, type ReceiptTotals, type ReceiptType, type ReceiptVatRate, type ReceiptsApi, type RefundItemsContext, type RefundItemsResolver, type RefundProposalLine, type RegisterPaymentInput, type RegisterPaymentOnceInput, type RegisteredPayment, type RegisteredPaymentOnce, type RequestOptions, type ReverseInvoiceInput, type ReverseReceiptInput, type ReversedInvoice, SZAMLAZZ_AGENT_URL, type SendReceiptInput, type SkippedPayment, type SprinterWaybill, type StandardInvoiceInput, type StoreCapabilities, SzamlazzError, type SzamlazzErrorCategory, type SzamlazzHooks, type SzamlazzOptions, TAXPAYER_CACHE_KEY_PREFIX, type TaxpayerAddress, type TaxpayerApi, type TaxpayerCacheOptions, type TaxpayerInfo, type TaxpayerTaxNumber, type TaxpayerType, type TransOFlexWaybill, type VatRate, type WarningHook, type Waybill, addBudapestDays, attemptLedgerKey, buyerFromCustomer, chooseDocument, conversionExternalId, correctionExternalId, createKassza, errorCodeDocsUrl, invoiceOnceExternalId, isDocumentHookError, isSzamlazzError, issueForPayment, memoryCookieStore, memoryStore, paymentMarker, paymentOrderNumber, storeCapabilities, suggestedPrefix, toBudapestDate, toBudapestTimestamp, todayInBudapest };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { _ as MAX_INVOICE_ATTACHMENTS, g as AGENT_ACTIONS, h as isDocumentHookError, n as paymentMarker, p as DocumentHookError, v as SZAMLAZZ_AGENT_URL } from "./create-once-
|
|
1
|
+
import { _ as MAX_INVOICE_ATTACHMENTS, g as AGENT_ACTIONS, h as isDocumentHookError, n as paymentMarker, p as DocumentHookError, v as SZAMLAZZ_AGENT_URL } from "./create-once-DcEjO8QH.js";
|
|
2
2
|
import { a as errorCodeDocsUrl, c as suggestedPrefix, n as KASSZA_ERROR_DOCS_URL, o as isSzamlazzError, r as SzamlazzError, t as AGENT_ERROR_CODES } from "./errors-CGGsW0Y5.js";
|
|
3
|
-
import { d as attemptLedgerKey, i as TAXPAYER_CACHE_KEY_PREFIX, l as ATTEMPT_LEDGER_KEY_PREFIX, n as DEFAULT_TAXPAYER_INVALID_TTL_SECONDS, r as DEFAULT_TAXPAYER_TTL_SECONDS, t as createKassza, u as ATTEMPT_LEDGER_TTL_SECONDS } from "./client-
|
|
3
|
+
import { d as attemptLedgerKey, i as TAXPAYER_CACHE_KEY_PREFIX, l as ATTEMPT_LEDGER_KEY_PREFIX, n as DEFAULT_TAXPAYER_INVALID_TTL_SECONDS, r as DEFAULT_TAXPAYER_TTL_SECONDS, t as createKassza, u as ATTEMPT_LEDGER_TTL_SECONDS } from "./client-8ElbVwSO.js";
|
|
4
4
|
import { n as bytesToBase64 } from "./binary-DuKBSfH-.js";
|
|
5
5
|
import { a as memoryStore, n as memoryCookieStore, o as storeCapabilities } from "./session-DZeE1ryt.js";
|
|
6
|
-
import { a as conversionExternalId, c as chooseDocument, d as DEFAULT_LOCK_TTL_SECONDS, f as DEFAULT_LOCK_WAIT_MS, i as correctionExternalId, n as issueForPayment, p as ONCE_LOCK_KEY_PREFIX, r as paymentOrderNumber, s as RECEIPT_MAX_GROSS_HUF, t as buyerFromCustomer, u as invoiceOnceExternalId } from "./issue-
|
|
6
|
+
import { a as conversionExternalId, c as chooseDocument, d as DEFAULT_LOCK_TTL_SECONDS, f as DEFAULT_LOCK_WAIT_MS, i as correctionExternalId, n as issueForPayment, p as ONCE_LOCK_KEY_PREFIX, r as paymentOrderNumber, s as RECEIPT_MAX_GROSS_HUF, t as buyerFromCustomer, u as invoiceOnceExternalId } from "./issue-CUiDvJhQ.js";
|
|
7
7
|
import { a as todayInBudapest, i as toBudapestTimestamp, r as toBudapestDate, t as addBudapestDays } from "./dates-DWsZOdaO.js";
|
|
8
8
|
export { AGENT_ACTIONS, AGENT_ERROR_CODES, ATTEMPT_LEDGER_KEY_PREFIX, ATTEMPT_LEDGER_TTL_SECONDS, DEFAULT_LOCK_TTL_SECONDS, DEFAULT_LOCK_WAIT_MS, DEFAULT_TAXPAYER_INVALID_TTL_SECONDS, DEFAULT_TAXPAYER_TTL_SECONDS, DocumentHookError, KASSZA_ERROR_DOCS_URL, MAX_INVOICE_ATTACHMENTS, ONCE_LOCK_KEY_PREFIX, RECEIPT_MAX_GROSS_HUF, SZAMLAZZ_AGENT_URL, SzamlazzError, TAXPAYER_CACHE_KEY_PREFIX, addBudapestDays, attemptLedgerKey, buyerFromCustomer, bytesToBase64, chooseDocument, conversionExternalId, correctionExternalId, createKassza, errorCodeDocsUrl, invoiceOnceExternalId, isDocumentHookError, isSzamlazzError, issueForPayment, memoryCookieStore, memoryStore, paymentMarker, paymentOrderNumber, storeCapabilities, suggestedPrefix, toBudapestDate, toBudapestTimestamp, todayInBudapest };
|
|
@@ -376,6 +376,12 @@ function skipped$1(orderNumber, reason) {
|
|
|
376
376
|
reason
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
|
+
function refundBeforeDocumentError(payment, orderNumber) {
|
|
380
|
+
return new SzamlazzError(`A(z) ${payment.provider} visszatérítéshez (${payment.id}) még nincs kiállított bizonylat (rendelésszám: ${orderNumber}): a fizetés eseménye valószínűleg még nem futott le, például egy korábbi hiba után újraküldésre vár.`, {
|
|
381
|
+
category: "in_progress",
|
|
382
|
+
hint: "A webhook 500-at ad, így a szolgáltató később újraküldi a visszatérítést; addigra a fizetés bizonylata elkészül, és a visszatérítés sztornózza vagy helyesbíti. Ha ehhez a fizetéshez soha nem készül bizonylat (például a kassza bevezetése előtti fizetés), kezeld kézzel, és az onPayment-ben nyugtázd ezt az in_progress hibát."
|
|
383
|
+
});
|
|
384
|
+
}
|
|
379
385
|
async function refundKey(id) {
|
|
380
386
|
if (id.length <= MAX_PLAIN_REFUND_KEY && /^[A-Za-z0-9_.:-]+$/.test(id)) return id;
|
|
381
387
|
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(id));
|
|
@@ -572,7 +578,7 @@ async function issueForPartialRefund(api, payment, orderNumber, options) {
|
|
|
572
578
|
orderNumber,
|
|
573
579
|
downloadPdf: false
|
|
574
580
|
}, { signal: options.signal });
|
|
575
|
-
if (!receipt)
|
|
581
|
+
if (!receipt) throw refundBeforeDocumentError(payment, orderNumber);
|
|
576
582
|
const original = receipt.type === "reversal" ? receipt.reversedReceiptNumber ?? receipt.number : receipt.number;
|
|
577
583
|
if (receipt.type === "reversal" || receipt.isReversed) {
|
|
578
584
|
const converted = await find(conversionExternalId(original));
|
|
@@ -589,6 +595,8 @@ const DEFAULT_CURRENCY = "HUF";
|
|
|
589
595
|
const DEFAULT_EXCHANGE_BANK = "MNB";
|
|
590
596
|
const INVOICE_REVERSAL_SUFFIX = "/SS";
|
|
591
597
|
const RECEIPT_REVERSAL_SUFFIX = "/SN";
|
|
598
|
+
const REFUND_LOCK_KEY_PREFIX = "szamlazz:refund:";
|
|
599
|
+
const refundsInFlight = /* @__PURE__ */ new WeakMap();
|
|
592
600
|
function validation(message, hint) {
|
|
593
601
|
return new SzamlazzError(message, {
|
|
594
602
|
category: "validation",
|
|
@@ -839,7 +847,7 @@ async function reverseReceiptForRefund(api, payment, orderNumber, options) {
|
|
|
839
847
|
downloadPdf: false
|
|
840
848
|
}, { signal: options.signal });
|
|
841
849
|
const receipt = await lookup();
|
|
842
|
-
if (!receipt)
|
|
850
|
+
if (!receipt) throw refundBeforeDocumentError(payment, orderNumber);
|
|
843
851
|
if (isReversedReceipt(receipt)) {
|
|
844
852
|
const originalNumber = receipt.type === "reversal" ? receipt.reversedReceiptNumber ?? receipt.number : receipt.number;
|
|
845
853
|
const converted = await reverseConvertedInvoice(api, orderNumber, originalNumber, options);
|
|
@@ -875,6 +883,86 @@ async function reverseForRefund(api, payment, orderNumber, options) {
|
|
|
875
883
|
if (invoice && invoice.header.type !== "reversal") return reverseInvoiceOnce(api, orderNumber, invoice.header.number, options);
|
|
876
884
|
return reverseReceiptForRefund(api, payment, orderNumber, options);
|
|
877
885
|
}
|
|
886
|
+
function refundIdsOf(payment) {
|
|
887
|
+
const ids = (payment.refunds ?? []).map((refund) => refund.id);
|
|
888
|
+
return ids.length > 0 ? ids.join(", ") : payment.id;
|
|
889
|
+
}
|
|
890
|
+
async function reportRefundFailure(api, payment, orderNumber, options) {
|
|
891
|
+
const which = refundIdsOf(payment);
|
|
892
|
+
const invoice = await api.invoices.find({ externalId: orderNumber }, { includePdf: false }, { signal: options.signal });
|
|
893
|
+
const receipt = invoice ? void 0 : await api.receipts.find({
|
|
894
|
+
orderNumber,
|
|
895
|
+
downloadPdf: false
|
|
896
|
+
}, { signal: options.signal });
|
|
897
|
+
const found = invoice ? {
|
|
898
|
+
document: "invoice",
|
|
899
|
+
number: invoice.header.number
|
|
900
|
+
} : receipt && {
|
|
901
|
+
document: "receipt",
|
|
902
|
+
number: receipt.type === "reversal" ? receipt.reversedReceiptNumber ?? receipt.number : receipt.number
|
|
903
|
+
};
|
|
904
|
+
if (!found) return skipped(orderNumber, `A(z) ${payment.provider} visszatérítés (${which}) meghiúsult, de ehhez a fizetéshez nincs kiállított bizonylat, így nincs mit rendezni.`);
|
|
905
|
+
return {
|
|
906
|
+
kind: "refund-failed",
|
|
907
|
+
orderNumber,
|
|
908
|
+
document: found.document,
|
|
909
|
+
documentNumber: found.number,
|
|
910
|
+
reason: `A(z) ${payment.provider} visszatérítés (${which}) meghiúsult vagy visszavonták, a pénz nem ment vissza a vevőnek. A kassza a visszatérítésre kiállított sztornót vagy helyesbítő számlát nem fordítja vissza magától: ellenőrizd a(z) ${found.number} bizonylatot és a hozzá tartozó javító bizonylatokat, és ha kell, kézzel állíts ki új bizonylatot a vevőnél maradt összegről.`
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
async function oneAtATime(scope, key, signal, run) {
|
|
914
|
+
let running = refundsInFlight.get(scope);
|
|
915
|
+
if (!running) {
|
|
916
|
+
running = /* @__PURE__ */ new Map();
|
|
917
|
+
refundsInFlight.set(scope, running);
|
|
918
|
+
}
|
|
919
|
+
for (;;) {
|
|
920
|
+
const pending = running.get(key);
|
|
921
|
+
if (!pending) break;
|
|
922
|
+
await pending.catch(() => void 0);
|
|
923
|
+
signal?.throwIfAborted();
|
|
924
|
+
}
|
|
925
|
+
const current = run();
|
|
926
|
+
running.set(key, current);
|
|
927
|
+
try {
|
|
928
|
+
return await current;
|
|
929
|
+
} finally {
|
|
930
|
+
if (running.get(key) === current) running.delete(key);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
async function releaseRefundLock(lock, key, token) {
|
|
934
|
+
if (lock.deleteIfEquals) {
|
|
935
|
+
await lock.deleteIfEquals(key, token);
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
if (await lock.get(key) === token) await lock.delete(key);
|
|
939
|
+
}
|
|
940
|
+
async function withRefundLock(lock, orderNumber, run) {
|
|
941
|
+
if (!lock) return run();
|
|
942
|
+
const setIfAbsent = lock.setIfAbsent?.bind(lock);
|
|
943
|
+
if (!setIfAbsent) throw new SzamlazzError("A visszatérítés zárához (lock) olyan tároló kell, amely támogatja a setIfAbsent műveletet (például a kassza/stores Redis adapterei vagy a Durable Object tároló). A Cloudflare KV erre nem alkalmas.", { category: "configuration" });
|
|
944
|
+
const key = `${REFUND_LOCK_KEY_PREFIX}${orderNumber}`;
|
|
945
|
+
const token = crypto.randomUUID();
|
|
946
|
+
let acquired;
|
|
947
|
+
try {
|
|
948
|
+
acquired = await setIfAbsent(key, token, 600);
|
|
949
|
+
} catch (error) {
|
|
950
|
+
throw new SzamlazzError(`A visszatérítés zárának tárolója nem érhető el, ezért a kassza nem sztornózott (${orderNumber}).`, {
|
|
951
|
+
category: "store_unavailable",
|
|
952
|
+
cause: error,
|
|
953
|
+
hint: "Állítsd helyre a tárolót, a webhook 500-at ad, és a szolgáltató újraküldi a visszatérítést."
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
if (!acquired) throw new SzamlazzError(`Egy másik folyamat éppen sztornózza a(z) ${orderNumber} rendelés bizonylatát.`, {
|
|
957
|
+
category: "in_progress",
|
|
958
|
+
hint: "Ne sztornózd kézzel. A webhook 500-at ad, a szolgáltató újraküldi a visszatérítést, és akkor a kassza a már elkészült sztornót adja vissza."
|
|
959
|
+
});
|
|
960
|
+
try {
|
|
961
|
+
return await run();
|
|
962
|
+
} finally {
|
|
963
|
+
await releaseRefundLock(lock, key, token).catch(() => void 0);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
878
966
|
function assertPaidAmount(payment) {
|
|
879
967
|
const value = payment.amount?.value;
|
|
880
968
|
if (value !== void 0 && (!Number.isFinite(value) || value < 0)) throw validation(`A(z) ${payment.provider} fizetés összege érvénytelen: ${value}`);
|
|
@@ -882,8 +970,9 @@ function assertPaidAmount(payment) {
|
|
|
882
970
|
async function issueForPayment(api, payment, options = {}) {
|
|
883
971
|
resolveRecoveryDelay(options.recoveryDelayMs);
|
|
884
972
|
const orderNumber = options.orderNumber?.trim() || paymentOrderNumber(payment);
|
|
885
|
-
if (payment.kind === "refunded") return reverseForRefund(api, payment, orderNumber, options);
|
|
973
|
+
if (payment.kind === "refunded") return oneAtATime(api.invoices, orderNumber, options.signal, () => withRefundLock(options.lock, orderNumber, () => reverseForRefund(api, payment, orderNumber, options)));
|
|
886
974
|
if (payment.kind === "partially-refunded") return issueForPartialRefund(api, payment, orderNumber, options);
|
|
975
|
+
if (payment.kind === "refund-failed") return reportRefundFailure(api, payment, orderNumber, options);
|
|
887
976
|
if (payment.kind !== "paid") return skipped(orderNumber, `A fizetés állapota (${payment.kind}) nem sikeres fizetés, ezért nem készül bizonylat.`);
|
|
888
977
|
assertPaidAmount(payment);
|
|
889
978
|
if (payment.amount?.value === 0) return skipped(orderNumber, "A fizetett összeg 0, ezért nem készül bizonylat.");
|