kassza 0.12.0 → 0.13.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.
- package/README.md +283 -18
- package/agents/README.md +20 -5
- package/agents/api.md +165 -2
- package/agents/pitfalls.md +16 -3
- package/agents/recipes.md +215 -45
- package/agents/skills/kassza/SKILL.md +11 -8
- package/dist/cli.cjs +552 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +552 -0
- package/dist/client-6MkeuFqD.d.ts +268 -0
- package/dist/client-B5FryKxJ.d.cts +268 -0
- package/dist/{client-CsmGIFRS.cjs → client-C-PdfL_P.cjs} +235 -597
- package/dist/{client-CL3fuH6A.js → client-CfaS1-Jx.js} +35 -403
- package/dist/context-BxQlIlug.d.ts +425 -0
- package/dist/context-DXNbTPwz.d.cts +425 -0
- package/dist/{create-once-CqdYmQD8.js → create-once-Cz621l8r.js} +3 -3
- package/dist/{create-once-D0pwuenl.cjs → create-once-DgMtKKcG.cjs} +8 -2
- package/dist/{crypto-B8lERvR1.cjs → crypto-Dpn4FHQ6.cjs} +9 -0
- package/dist/{crypto-DK_osBVy.js → crypto-usDg8L2K.js} +4 -1
- package/dist/data-link/index.cjs +232 -0
- package/dist/data-link/index.d.cts +79 -0
- package/dist/data-link/index.d.ts +79 -0
- package/dist/data-link/index.js +224 -0
- package/dist/delegation/index.cjs +34 -33
- package/dist/delegation/index.d.cts +2 -1
- package/dist/delegation/index.d.ts +2 -1
- package/dist/delegation/index.js +3 -2
- package/dist/get-Byc9T5WO.d.cts +151 -0
- package/dist/get-Byc9T5WO.d.ts +151 -0
- package/dist/get-Csm2n0rZ.cjs +445 -0
- package/dist/get-DT3JEgQ6.js +380 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -3
- package/dist/{issue-BsyYdrIG.cjs → issue-AGRohSm7.cjs} +48 -665
- package/dist/{issue-C6Fcjvln.js → issue-DtSLpVdJ.js} +5 -502
- package/dist/mcp/index.cjs +10 -0
- package/dist/mcp/index.d.cts +71 -0
- package/dist/mcp/index.d.ts +71 -0
- package/dist/mcp/index.js +2 -0
- package/dist/money/index.cjs +1 -1
- package/dist/money/index.js +1 -1
- package/dist/{money-DrhGkWHW.cjs → money-BxytJW6f.cjs} +25 -9
- package/dist/{money-DAA7OwiO.js → money-t7uy1n91.js} +25 -9
- package/dist/nav/index.cjs +1046 -0
- package/dist/nav/index.d.cts +247 -0
- package/dist/nav/index.d.ts +247 -0
- package/dist/nav/index.js +1012 -0
- package/dist/nav-BEwcX7-N.cjs +203 -0
- package/dist/nav-CK1WgYo7.js +156 -0
- package/dist/parse-BJj-aqKy.cjs +380 -0
- package/dist/parse-C608ehqM.js +291 -0
- package/dist/payments/barion.cjs +1 -1
- package/dist/payments/barion.d.cts +2 -2
- package/dist/payments/barion.d.ts +2 -2
- package/dist/payments/barion.js +1 -1
- package/dist/payments/index.cjs +2 -2
- package/dist/payments/index.d.cts +3 -3
- package/dist/payments/index.d.ts +3 -3
- package/dist/payments/index.js +2 -2
- package/dist/payments/paypal.cjs +1 -1
- package/dist/payments/paypal.d.cts +2 -2
- package/dist/payments/paypal.d.ts +2 -2
- package/dist/payments/paypal.js +1 -1
- package/dist/payments/revolut.cjs +2 -2
- package/dist/payments/revolut.d.cts +2 -2
- package/dist/payments/revolut.d.ts +2 -2
- package/dist/payments/revolut.js +2 -2
- package/dist/payments/simplepay.cjs +2 -2
- package/dist/payments/simplepay.d.cts +2 -2
- package/dist/payments/simplepay.d.ts +2 -2
- package/dist/payments/simplepay.js +2 -2
- package/dist/payments/stripe.cjs +2 -2
- package/dist/payments/stripe.d.cts +2 -2
- package/dist/payments/stripe.d.ts +2 -2
- package/dist/payments/stripe.js +2 -2
- package/dist/reports/index.cjs +11 -164
- package/dist/reports/index.js +1 -154
- package/dist/request-body-CH6ZGOrq.cjs +34 -0
- package/dist/request-body-uZHMRlQr.js +29 -0
- package/dist/serialize-BXOww1Uq.cjs +286 -0
- package/dist/serialize-DSE_o9RK.js +215 -0
- package/dist/server-C6PoNkdD.cjs +1557 -0
- package/dist/server-Cd8HB661.js +1504 -0
- package/dist/testing/index.cjs +1476 -3
- package/dist/testing/index.d.cts +194 -2
- package/dist/testing/index.d.ts +194 -2
- package/dist/testing/index.js +1477 -6
- package/dist/{types-COf1LAD-.d.cts → types-BVeR7KyU.d.cts} +1 -1
- package/dist/{types-COf1LAD-.d.ts → types-BVeR7KyU.d.ts} +1 -1
- package/dist/{webhook-C76bV-4R.cjs → webhook-81giRMdQ.cjs} +3 -25
- package/dist/{webhook-q2OzNwd7.d.ts → webhook-CpCMHhn2.d.ts} +1 -1
- package/dist/{webhook-CfaDgcL0.d.cts → webhook-CpMJuP6c.d.cts} +1 -1
- package/dist/{webhook-D4lvtex1.js → webhook-CrEGohbg.js} +3 -25
- package/llms.txt +4 -4
- package/package.json +43 -1
- package/dist/client-CickRRFr.d.ts +0 -838
- package/dist/client-DvWZoX_E.d.cts +0 -838
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as emitDocumentEvent, i as resolveInvoice, l as AGENT_ACTIONS, n as optionalAgentDate, o as INVOICE_TEMPLATES, r as presentText, s as TAXPAYER_TYPE_CODES, t as createReceiptOnce } from "./create-once-Cz621l8r.js";
|
|
2
2
|
import { a as parseErrorCode, i as isSzamlazzError, n as SzamlazzError, r as createAgentError } from "./errors-DLrb0g64.js";
|
|
3
3
|
import { t as base64ToBytes } from "./binary-D0M9U2MD.js";
|
|
4
|
-
import {
|
|
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-DSE_o9RK.js";
|
|
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-C608ehqM.js";
|
|
5
6
|
import { i as sessionKeyFor, n as memoryCookieStore, r as mergeSetCookies, t as SESSION_TTL_SECONDS } from "./session-rMKaJcmq.js";
|
|
6
|
-
import { a as todayInBudapest
|
|
7
|
+
import { a as todayInBudapest } from "./dates-CXyj7Azy.js";
|
|
7
8
|
import { r as formatVatRate } from "./vat-v_dcWCto.js";
|
|
8
|
-
import { i as summarizeItems } from "./money-
|
|
9
|
+
import { i as summarizeItems } from "./money-t7uy1n91.js";
|
|
10
|
+
import { _ as createInvoiceOnce, c as optionalText, d as validateTemplate$1, l as receiptValidationError, n as issueForPayment, o as createReceipt, p as convertReceiptToInvoice, s as RECEIPT_XSD_BASE_URL, u as requireReceiptNumber } from "./issue-DtSLpVdJ.js";
|
|
11
|
+
import { a as optionalAgentDate$1, c as referenceValue, d as validationError, i as agentDate, l as requireText, o as optionalText$1, r as AGENT_XSD_BASE_URL, s as parseInvoiceResult, t as getInvoice, u as resolveInvoiceReference } from "./get-DT3JEgQ6.js";
|
|
9
12
|
//#region src/core/attempt-ledger.ts
|
|
10
13
|
const ATTEMPT_LEDGER_TTL_SECONDS = 86400;
|
|
11
14
|
const ATTEMPT_LEDGER_KEY_PREFIX = "szamlazz:attempts:";
|
|
@@ -412,12 +415,12 @@ function sellerNode(seller) {
|
|
|
412
415
|
function buyerLedgerNode(ledger) {
|
|
413
416
|
if (!ledger) return void 0;
|
|
414
417
|
return optionalEl("vevoFokonyv", [
|
|
415
|
-
optionalEl("konyvelesDatum", optionalAgentDate
|
|
418
|
+
optionalEl("konyvelesDatum", optionalAgentDate(ledger.bookingDate, "buyer.ledger.bookingDate")),
|
|
416
419
|
textEl("vevoAzonosito", ledger.buyerId),
|
|
417
420
|
textEl("vevoFokonyviSzam", ledger.ledgerAccount),
|
|
418
421
|
optionalEl("folyamatosTelj", ledger.continuousFulfillment),
|
|
419
|
-
optionalEl("elszDatumTol", optionalAgentDate
|
|
420
|
-
optionalEl("elszDatumIg", optionalAgentDate
|
|
422
|
+
optionalEl("elszDatumTol", optionalAgentDate(ledger.settlementPeriodStart, "buyer.ledger.settlementPeriodStart")),
|
|
423
|
+
optionalEl("elszDatumIg", optionalAgentDate(ledger.settlementPeriodEnd, "buyer.ledger.settlementPeriodEnd"))
|
|
421
424
|
]);
|
|
422
425
|
}
|
|
423
426
|
function buyerNode(buyer, sendEmail) {
|
|
@@ -486,8 +489,8 @@ function itemLedgerNode(ledger, label) {
|
|
|
486
489
|
textEl("gazdasagiEsemAfa", ledger.vatEconomicEvent),
|
|
487
490
|
textEl("arbevetelFokonyviSzam", ledger.revenueLedgerAccount),
|
|
488
491
|
textEl("afaFokonyviSzam", ledger.vatLedgerAccount),
|
|
489
|
-
optionalEl("elszDatumTol", optionalAgentDate
|
|
490
|
-
optionalEl("elszDatumIg", optionalAgentDate
|
|
492
|
+
optionalEl("elszDatumTol", optionalAgentDate(ledger.settlementPeriodStart, `${label} settlementPeriodStart`)),
|
|
493
|
+
optionalEl("elszDatumIg", optionalAgentDate(ledger.settlementPeriodEnd, `${label} settlementPeriodEnd`))
|
|
491
494
|
]);
|
|
492
495
|
}
|
|
493
496
|
function itemNode(item, index) {
|
|
@@ -524,6 +527,9 @@ function renderInvoiceXml(credentials, invoice, options = {}) {
|
|
|
524
527
|
]
|
|
525
528
|
});
|
|
526
529
|
}
|
|
530
|
+
function buildCreateInvoiceXml(credentials, defaults, input, now = /* @__PURE__ */ new Date()) {
|
|
531
|
+
return renderInvoiceXml(credentials, resolveInvoice(defaults, input, now));
|
|
532
|
+
}
|
|
527
533
|
//#endregion
|
|
528
534
|
//#region src/invoices/create.ts
|
|
529
535
|
function buildRequest(ctx, invoice, preview, options) {
|
|
@@ -549,380 +555,6 @@ async function previewInvoice(ctx, defaults, input, options = {}) {
|
|
|
549
555
|
const items = itemsOf(invoice);
|
|
550
556
|
return ctx.execute(buildRequest(ctx, invoice, true, options), (response) => parseInvoicePreviewResponse(response, items));
|
|
551
557
|
}
|
|
552
|
-
//#endregion
|
|
553
|
-
//#region src/invoices/reference.ts
|
|
554
|
-
const AGENT_XSD_BASE_URL = "https://www.szamlazz.hu/szamla/docs/xsds/";
|
|
555
|
-
function validationError(message) {
|
|
556
|
-
return new SzamlazzError(message, { category: "validation" });
|
|
557
|
-
}
|
|
558
|
-
function requireText(value, message) {
|
|
559
|
-
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
560
|
-
if (trimmed === "") throw validationError(message);
|
|
561
|
-
return trimmed;
|
|
562
|
-
}
|
|
563
|
-
function optionalText(value) {
|
|
564
|
-
const trimmed = value?.trim();
|
|
565
|
-
return trimmed ? trimmed : void 0;
|
|
566
|
-
}
|
|
567
|
-
function agentDate(input, field) {
|
|
568
|
-
try {
|
|
569
|
-
return toAgentDate(input);
|
|
570
|
-
} catch (error) {
|
|
571
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
572
|
-
throw new SzamlazzError(`Érvénytelen dátum (${field}): ${detail}`, {
|
|
573
|
-
category: "validation",
|
|
574
|
-
cause: error
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
function optionalAgentDate(input, field) {
|
|
579
|
-
return input === void 0 ? void 0 : agentDate(input, field);
|
|
580
|
-
}
|
|
581
|
-
const REFERENCE_KEYS = [
|
|
582
|
-
"invoiceNumber",
|
|
583
|
-
"orderNumber",
|
|
584
|
-
"externalId"
|
|
585
|
-
];
|
|
586
|
-
const REFERENCE_HINT$1 = "Add meg a számlaszámot szövegként, vagy pontosan egyet ezek közül: { invoiceNumber }, { orderNumber }, { externalId }.";
|
|
587
|
-
function resolveInvoiceReference(reference) {
|
|
588
|
-
if (typeof reference === "string") return {
|
|
589
|
-
kind: "invoiceNumber",
|
|
590
|
-
value: requireText(reference, `Üres számlaszám. ${REFERENCE_HINT$1}`)
|
|
591
|
-
};
|
|
592
|
-
if (typeof reference !== "object" || reference === null) throw validationError(`Érvénytelen bizonylat-hivatkozás. ${REFERENCE_HINT$1}`);
|
|
593
|
-
const record = reference;
|
|
594
|
-
const present = REFERENCE_KEYS.filter((key) => record[key] !== void 0);
|
|
595
|
-
const [kind] = present;
|
|
596
|
-
if (kind === void 0 || present.length > 1) throw validationError(`Érvénytelen bizonylat-hivatkozás. ${REFERENCE_HINT$1}`);
|
|
597
|
-
return {
|
|
598
|
-
kind,
|
|
599
|
-
value: requireText(record[kind], `Üres ${kind} érték. ${REFERENCE_HINT$1}`)
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
function referenceValue(reference, kind) {
|
|
603
|
-
return reference.kind === kind ? reference.value : void 0;
|
|
604
|
-
}
|
|
605
|
-
function readNumericHeader(headers, name) {
|
|
606
|
-
const value = readHeader$1(headers, name);
|
|
607
|
-
if (value === void 0) return void 0;
|
|
608
|
-
const parsed = Number(value.replace(",", "."));
|
|
609
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
610
|
-
}
|
|
611
|
-
function headerSummary(response) {
|
|
612
|
-
const headers = readDocumentHeaders(response.headers);
|
|
613
|
-
return {
|
|
614
|
-
number: headers.number,
|
|
615
|
-
netTotal: headers.netTotal,
|
|
616
|
-
grossTotal: headers.grossTotal,
|
|
617
|
-
outstanding: readNumericHeader(response.headers, "szlahu_kintlevoseg"),
|
|
618
|
-
buyerAccountUrl: headers.buyerAccountUrl
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
function decodeResponsePdf(root, response) {
|
|
622
|
-
const encoded = childText(root, "pdf");
|
|
623
|
-
if (encoded === void 0) return void 0;
|
|
624
|
-
try {
|
|
625
|
-
return base64ToBytes(encoded);
|
|
626
|
-
} catch (error) {
|
|
627
|
-
throw new SzamlazzError("A válaszban kapott PDF nem érvényes base64.", {
|
|
628
|
-
category: "unexpected_response",
|
|
629
|
-
action: response.action,
|
|
630
|
-
httpStatus: response.status,
|
|
631
|
-
cause: error
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
function readInvoiceResultXml(root, response) {
|
|
636
|
-
const headers = headerSummary(response);
|
|
637
|
-
return {
|
|
638
|
-
number: childText(root, "szamlaszam") ?? headers.number,
|
|
639
|
-
netTotal: childNumber(root, "szamlanetto") ?? headers.netTotal,
|
|
640
|
-
grossTotal: childNumber(root, "szamlabrutto") ?? headers.grossTotal,
|
|
641
|
-
outstanding: childNumber(root, "kintlevoseg") ?? headers.outstanding,
|
|
642
|
-
buyerAccountUrl: childText(root, "vevoifiokurl") ?? headers.buyerAccountUrl,
|
|
643
|
-
pdf: decodeResponsePdf(root, response)
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
const INVOICE_RESULT_ROOT = "xmlszamlavalasz";
|
|
647
|
-
function parseInvoiceResult(response) {
|
|
648
|
-
throwIfHeaderError(response);
|
|
649
|
-
if (response.isPdf) return {
|
|
650
|
-
...headerSummary(response),
|
|
651
|
-
pdf: response.body
|
|
652
|
-
};
|
|
653
|
-
throwIfTextError(response);
|
|
654
|
-
throwIfHttpError(response);
|
|
655
|
-
if (looksLikeXml(response)) {
|
|
656
|
-
const root = parseResponseXml(response);
|
|
657
|
-
throwIfXmlFailure(root, response);
|
|
658
|
-
if (root.name !== INVOICE_RESULT_ROOT || childText(root, "sikeres")?.toLowerCase() !== "true") throw unexpectedResponse(response, `${INVOICE_RESULT_ROOT} XML választ vártunk.`);
|
|
659
|
-
return readInvoiceResultXml(root, response);
|
|
660
|
-
}
|
|
661
|
-
const headers = headerSummary(response);
|
|
662
|
-
const done = parseDoneText(response.text());
|
|
663
|
-
if (done) return {
|
|
664
|
-
...headers,
|
|
665
|
-
number: done.number ?? headers.number
|
|
666
|
-
};
|
|
667
|
-
if (headers.number !== void 0) return headers;
|
|
668
|
-
throw unexpectedResponse(response);
|
|
669
|
-
}
|
|
670
|
-
//#endregion
|
|
671
|
-
//#region src/invoices/get.ts
|
|
672
|
-
const INVOICE_DOCUMENT_TYPE_CODES = {
|
|
673
|
-
invoice: "SZ",
|
|
674
|
-
proforma: "D",
|
|
675
|
-
advance: "ES",
|
|
676
|
-
final: "VS",
|
|
677
|
-
corrective: "HS",
|
|
678
|
-
reversal: "SS",
|
|
679
|
-
deliveryNote: "SL"
|
|
680
|
-
};
|
|
681
|
-
function buildGetInvoiceXml(credentials, reference, query = {}) {
|
|
682
|
-
const resolved = resolveInvoiceReference(reference);
|
|
683
|
-
return buildXmlDocument({
|
|
684
|
-
root: "xmlszamlaxml",
|
|
685
|
-
namespace: "http://www.szamlazz.hu/xmlszamlaxml",
|
|
686
|
-
schemaLocation: `${AGENT_XSD_BASE_URL}agentxml/xmlszamlaxml.xsd`,
|
|
687
|
-
children: [
|
|
688
|
-
...credentials,
|
|
689
|
-
optionalEl("szamlaszam", referenceValue(resolved, "invoiceNumber")),
|
|
690
|
-
optionalEl("rendelesSzam", referenceValue(resolved, "orderNumber")),
|
|
691
|
-
optionalEl("pdf", query.includePdf),
|
|
692
|
-
optionalEl("szamlaKulsoAzon", referenceValue(resolved, "externalId"))
|
|
693
|
-
]
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
var InvoiceReader = class {
|
|
697
|
-
response;
|
|
698
|
-
constructor(response) {
|
|
699
|
-
this.response = response;
|
|
700
|
-
}
|
|
701
|
-
missing(path) {
|
|
702
|
-
return unexpectedResponse(this.response, `Hiányzik a(z) <${path}> elem a számla XML-ből.`);
|
|
703
|
-
}
|
|
704
|
-
element(parent, name, path) {
|
|
705
|
-
const child = findChild(parent, name);
|
|
706
|
-
if (!child) throw this.missing(path);
|
|
707
|
-
return child;
|
|
708
|
-
}
|
|
709
|
-
text(parent, name, path) {
|
|
710
|
-
const value = childText(parent, name);
|
|
711
|
-
if (value === void 0) throw this.missing(`${path}/${name}`);
|
|
712
|
-
return value;
|
|
713
|
-
}
|
|
714
|
-
number(parent, name, path) {
|
|
715
|
-
const value = childNumber(parent, name);
|
|
716
|
-
if (value === void 0) throw this.missing(`${path}/${name}`);
|
|
717
|
-
return value;
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
function readAddress(element) {
|
|
721
|
-
if (!element) return void 0;
|
|
722
|
-
return {
|
|
723
|
-
name: childText(element, "nev"),
|
|
724
|
-
country: childText(element, "orszag"),
|
|
725
|
-
zip: childText(element, "irsz"),
|
|
726
|
-
city: childText(element, "telepules"),
|
|
727
|
-
address: childText(element, "cim")
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
function readSeller(root, reader) {
|
|
731
|
-
const seller = reader.element(root, "szallito", "szallito");
|
|
732
|
-
const bank = findChild(seller, "bank");
|
|
733
|
-
return {
|
|
734
|
-
id: childNumber(seller, "id"),
|
|
735
|
-
name: reader.text(seller, "nev", "szallito"),
|
|
736
|
-
address: readAddress(findChild(seller, "cim")),
|
|
737
|
-
postalAddress: readAddress(findChild(seller, "postacim")),
|
|
738
|
-
taxNumber: childText(seller, "adoszam"),
|
|
739
|
-
groupTaxNumber: childText(seller, "csoportazonosito"),
|
|
740
|
-
euTaxNumber: childText(seller, "adoszameu"),
|
|
741
|
-
bank: bank && {
|
|
742
|
-
name: childText(bank, "nev"),
|
|
743
|
-
accountNumber: childText(bank, "bankszamla")
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
const DOCUMENT_TYPES_BY_CODE = new Map(Object.entries(INVOICE_DOCUMENT_TYPE_CODES).map(([type, code]) => [code, type]));
|
|
748
|
-
const E_INVOICE_CODES = /* @__PURE__ */ new Set([2, 3]);
|
|
749
|
-
function readHeader(root, reader) {
|
|
750
|
-
const header = reader.element(root, "alap", "alap");
|
|
751
|
-
const typeCode = reader.text(header, "tipus", "alap");
|
|
752
|
-
const appearanceCode = childNumber(header, "eszamla");
|
|
753
|
-
return {
|
|
754
|
-
id: childNumber(header, "id"),
|
|
755
|
-
number: reader.text(header, "szamlaszam", "alap"),
|
|
756
|
-
economicEventId: childNumber(header, "gazdEsemAzon"),
|
|
757
|
-
sourceSystem: childNumber(header, "forras"),
|
|
758
|
-
registrationNumber: childText(header, "iktatoszam"),
|
|
759
|
-
type: DOCUMENT_TYPES_BY_CODE.get(typeCode) ?? "unknown",
|
|
760
|
-
typeCode,
|
|
761
|
-
eInvoice: appearanceCode !== void 0 && E_INVOICE_CODES.has(appearanceCode),
|
|
762
|
-
appearanceCode,
|
|
763
|
-
referencedInvoiceNumber: childText(header, "hivszamlaszam"),
|
|
764
|
-
referencedProformaNumber: childText(header, "hivdijbekszam"),
|
|
765
|
-
issueDate: reader.text(header, "kelt", "alap"),
|
|
766
|
-
fulfillmentDate: childText(header, "telj"),
|
|
767
|
-
dueDate: childText(header, "fizh"),
|
|
768
|
-
paymentMethod: childText(header, "fizmod"),
|
|
769
|
-
unifiedPaymentMethod: childText(header, "fizmodunified"),
|
|
770
|
-
cash: childBoolean(header, "keszpenz"),
|
|
771
|
-
orderNumber: childText(header, "rendelesszam"),
|
|
772
|
-
language: childText(header, "nyelv"),
|
|
773
|
-
currency: childText(header, "devizanem"),
|
|
774
|
-
exchangeBank: childText(header, "devizabank"),
|
|
775
|
-
exchangeRate: childNumber(header, "devizaarf"),
|
|
776
|
-
comment: childText(header, "megjegyzes"),
|
|
777
|
-
vatType: childText(header, "afatipus"),
|
|
778
|
-
cashAccounting: childBoolean(header, "penzforg"),
|
|
779
|
-
kata: childBoolean(header, "kata"),
|
|
780
|
-
kataLedger: childBoolean(header, "katafokonyv"),
|
|
781
|
-
email: childText(header, "email"),
|
|
782
|
-
test: childBoolean(header, "teszt"),
|
|
783
|
-
reversed: childBoolean(header, "sztornozott")
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
function readBuyerLedger(element) {
|
|
787
|
-
if (!element) return void 0;
|
|
788
|
-
return {
|
|
789
|
-
ledgerAccount: childText(element, "vevo"),
|
|
790
|
-
buyerId: childText(element, "vevoazon"),
|
|
791
|
-
bookingDate: childText(element, "datum"),
|
|
792
|
-
continuousFulfillment: childBoolean(element, "folyamatostelj"),
|
|
793
|
-
settlementPeriodStart: childText(element, "elszDatTol") ?? childText(element, "elszdattol"),
|
|
794
|
-
settlementPeriodEnd: childText(element, "elszDatIg") ?? childText(element, "elszdatig")
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
function readBuyer(root, reader) {
|
|
798
|
-
const buyer = reader.element(root, "vevo", "vevo");
|
|
799
|
-
return {
|
|
800
|
-
id: childNumber(buyer, "id"),
|
|
801
|
-
name: reader.text(buyer, "nev", "vevo"),
|
|
802
|
-
identifier: childText(buyer, "azonosito"),
|
|
803
|
-
address: readAddress(findChild(buyer, "cim")),
|
|
804
|
-
postalAddress: readAddress(findChild(buyer, "postacim")),
|
|
805
|
-
email: childText(buyer, "email"),
|
|
806
|
-
taxNumber: childText(buyer, "adoszam"),
|
|
807
|
-
groupTaxNumber: childText(buyer, "csoportazonosito"),
|
|
808
|
-
euTaxNumber: childText(buyer, "adoszameu"),
|
|
809
|
-
location: childNumber(buyer, "lokacio"),
|
|
810
|
-
privatePerson: childBoolean(buyer, "privatePersonIndicator"),
|
|
811
|
-
ledger: readBuyerLedger(findChild(buyer, "fokonyv"))
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
function readItemLedger(element) {
|
|
815
|
-
if (!element) return void 0;
|
|
816
|
-
return {
|
|
817
|
-
revenueLedgerAccount: childText(element, "arbevetel"),
|
|
818
|
-
vatLedgerAccount: childText(element, "afa"),
|
|
819
|
-
economicEvent: childText(element, "gazdasagiesemeny"),
|
|
820
|
-
vatEconomicEvent: childText(element, "gazdasagiesemenyafa"),
|
|
821
|
-
settlementPeriodStart: childText(element, "elszdattol"),
|
|
822
|
-
settlementPeriodEnd: childText(element, "elszdatig")
|
|
823
|
-
};
|
|
824
|
-
}
|
|
825
|
-
function readItem(item, reader) {
|
|
826
|
-
const path = "tetelek/tetel";
|
|
827
|
-
return {
|
|
828
|
-
name: reader.text(item, "nev", path),
|
|
829
|
-
identifier: childText(item, "azonosito"),
|
|
830
|
-
quantity: reader.number(item, "mennyiseg", path),
|
|
831
|
-
unit: childText(item, "mennyisegiegyseg"),
|
|
832
|
-
netUnitPrice: reader.number(item, "nettoegysegar", path),
|
|
833
|
-
vat: reader.number(item, "afakulcs", path),
|
|
834
|
-
vatCode: childText(item, "afatipus"),
|
|
835
|
-
netAmount: reader.number(item, "netto", path),
|
|
836
|
-
marginVatBase: childNumber(item, "arresafaalap"),
|
|
837
|
-
vatAmount: reader.number(item, "afa", path),
|
|
838
|
-
grossAmount: reader.number(item, "brutto", path),
|
|
839
|
-
comment: childText(item, "megjegyzes"),
|
|
840
|
-
position: childNumber(item, "sztetordering"),
|
|
841
|
-
ledger: readItemLedger(findChild(item, "fokonyv"))
|
|
842
|
-
};
|
|
843
|
-
}
|
|
844
|
-
function readLabels(element) {
|
|
845
|
-
return findChildren(element, "cimke").flatMap((label) => {
|
|
846
|
-
const value = label.text.trim();
|
|
847
|
-
return value === "" ? [] : [value];
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
|
-
function readFinancialItem(item, reader) {
|
|
851
|
-
const path = "qutetek/qutet";
|
|
852
|
-
return {
|
|
853
|
-
name: reader.text(item, "nev", path),
|
|
854
|
-
vat: reader.number(item, "afakulcs", path),
|
|
855
|
-
vatCode: childText(item, "afatipus"),
|
|
856
|
-
netAmount: reader.number(item, "netto", path),
|
|
857
|
-
vatAmount: reader.number(item, "afa", path),
|
|
858
|
-
grossAmount: reader.number(item, "brutto", path),
|
|
859
|
-
settlementPeriodStart: childText(item, "elszdattol"),
|
|
860
|
-
settlementPeriodEnd: childText(item, "elszdatig"),
|
|
861
|
-
vatDeduction: childNumber(item, "afalevon"),
|
|
862
|
-
labels: readLabels(findChild(item, "cimkek"))
|
|
863
|
-
};
|
|
864
|
-
}
|
|
865
|
-
function readTotals(root, reader) {
|
|
866
|
-
const totals = reader.element(root, "osszegek", "osszegek");
|
|
867
|
-
const total = reader.element(totals, "totalossz", "osszegek/totalossz");
|
|
868
|
-
const path = "osszegek/totalossz";
|
|
869
|
-
return {
|
|
870
|
-
netAmount: reader.number(total, "netto", path),
|
|
871
|
-
vatAmount: reader.number(total, "afa", path),
|
|
872
|
-
grossAmount: reader.number(total, "brutto", path),
|
|
873
|
-
byVat: findChildren(totals, "afakulcsossz").map((entry) => ({
|
|
874
|
-
vat: reader.number(entry, "afakulcs", "osszegek/afakulcsossz"),
|
|
875
|
-
vatCode: childText(entry, "afatipus"),
|
|
876
|
-
netAmount: reader.number(entry, "netto", "osszegek/afakulcsossz"),
|
|
877
|
-
vatAmount: reader.number(entry, "afa", "osszegek/afakulcsossz"),
|
|
878
|
-
grossAmount: reader.number(entry, "brutto", "osszegek/afakulcsossz")
|
|
879
|
-
}))
|
|
880
|
-
};
|
|
881
|
-
}
|
|
882
|
-
function readPayment(payment, reader) {
|
|
883
|
-
const path = "kifizetesek/kifizetes";
|
|
884
|
-
return {
|
|
885
|
-
date: reader.text(payment, "datum", path),
|
|
886
|
-
method: reader.text(payment, "jogcim", path),
|
|
887
|
-
amount: reader.number(payment, "osszeg", path),
|
|
888
|
-
comment: childText(payment, "megjegyzes"),
|
|
889
|
-
bankAccountNumber: childText(payment, "bankszamlaszam"),
|
|
890
|
-
bankTransactionId: childNumber(payment, "banktranzid"),
|
|
891
|
-
exchangeRate: childNumber(payment, "devizaarf")
|
|
892
|
-
};
|
|
893
|
-
}
|
|
894
|
-
function parseInvoiceDetailsXml(root, response) {
|
|
895
|
-
const reader = new InvoiceReader(response);
|
|
896
|
-
return {
|
|
897
|
-
seller: readSeller(root, reader),
|
|
898
|
-
header: readHeader(root, reader),
|
|
899
|
-
buyer: readBuyer(root, reader),
|
|
900
|
-
items: findChildren(findChild(root, "tetelek"), "tetel").map((item) => readItem(item, reader)),
|
|
901
|
-
financialItems: findChildren(findChild(root, "qutetek"), "qutet").map((item) => readFinancialItem(item, reader)),
|
|
902
|
-
labels: readLabels(findChild(root, "cimkek")),
|
|
903
|
-
totals: readTotals(root, reader),
|
|
904
|
-
payments: findChildren(findChild(root, "kifizetesek"), "kifizetes").map((payment) => readPayment(payment, reader)),
|
|
905
|
-
pdf: decodeResponsePdf(root, response)
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
function parseGetInvoiceResponse(response) {
|
|
909
|
-
throwIfHeaderError(response);
|
|
910
|
-
throwIfTextError(response);
|
|
911
|
-
throwIfHttpError(response);
|
|
912
|
-
const root = parseResponseXml(response);
|
|
913
|
-
throwIfXmlFailure(root, response);
|
|
914
|
-
if (root.name !== "szamla") throw unexpectedResponse(response, "A számla XML (<szamla>) helyett más válasz érkezett.");
|
|
915
|
-
return parseInvoiceDetailsXml(root, response);
|
|
916
|
-
}
|
|
917
|
-
async function getInvoice(ctx, reference, query = {}, options = {}) {
|
|
918
|
-
const xml = buildGetInvoiceXml(ctx.credentials, reference, query);
|
|
919
|
-
return ctx.execute({
|
|
920
|
-
action: "getInvoiceXml",
|
|
921
|
-
xml,
|
|
922
|
-
signal: options.signal,
|
|
923
|
-
safeToRetry: true
|
|
924
|
-
}, parseGetInvoiceResponse);
|
|
925
|
-
}
|
|
926
558
|
function normalizeRegisterInput(input) {
|
|
927
559
|
const payments = "payments" in input ? input.payments : [{
|
|
928
560
|
amount: input.amount,
|
|
@@ -955,7 +587,7 @@ function paymentNode(payment, index) {
|
|
|
955
587
|
el("datum", payment.date === void 0 ? todayInBudapest() : agentDate(payment.date, "date")),
|
|
956
588
|
el("jogcim", requireText(payment.method, `Add meg a(z) ${position}. befizetés módját (method).`)),
|
|
957
589
|
el("osszeg", payment.amount),
|
|
958
|
-
optionalEl("leiras", optionalText(payment.description))
|
|
590
|
+
optionalEl("leiras", optionalText$1(payment.description))
|
|
959
591
|
]);
|
|
960
592
|
}
|
|
961
593
|
function buildPaymentXml(credentials, request) {
|
|
@@ -967,7 +599,7 @@ function buildPaymentXml(credentials, request) {
|
|
|
967
599
|
children: [el("beallitasok", [
|
|
968
600
|
...credentials,
|
|
969
601
|
el("szamlaszam", invoiceNumber),
|
|
970
|
-
optionalEl("adoszam", optionalText(request.taxNumber)),
|
|
602
|
+
optionalEl("adoszam", optionalText$1(request.taxNumber)),
|
|
971
603
|
el("additiv", request.additive),
|
|
972
604
|
el("valaszVerzio", 2)
|
|
973
605
|
]), ...request.payments.map(paymentNode)]
|
|
@@ -1106,25 +738,25 @@ function buildReverseInvoiceXml(credentials, input) {
|
|
|
1106
738
|
el("eszamla", options.eInvoice ?? false),
|
|
1107
739
|
el("szamlaLetoltes", options.downloadPdf ?? true),
|
|
1108
740
|
el("valaszVerzio", 2),
|
|
1109
|
-
optionalEl("szamlaKulsoAzon", optionalText(options.externalId))
|
|
741
|
+
optionalEl("szamlaKulsoAzon", optionalText$1(options.externalId))
|
|
1110
742
|
]),
|
|
1111
743
|
el("fejlec", [
|
|
1112
744
|
el("szamlaszam", invoiceNumber),
|
|
1113
|
-
optionalEl("keltDatum", optionalAgentDate(options.issueDate, "issueDate")),
|
|
1114
|
-
optionalEl("teljesitesDatum", optionalAgentDate(options.fulfillmentDate, "fulfillmentDate")),
|
|
1115
|
-
optionalEl("megjegyzes", optionalText(options.comment)),
|
|
745
|
+
optionalEl("keltDatum", optionalAgentDate$1(options.issueDate, "issueDate")),
|
|
746
|
+
optionalEl("teljesitesDatum", optionalAgentDate$1(options.fulfillmentDate, "fulfillmentDate")),
|
|
747
|
+
optionalEl("megjegyzes", optionalText$1(options.comment)),
|
|
1116
748
|
el("tipus", "SS"),
|
|
1117
749
|
optionalEl("szamlaSablon", validateTemplate(options.template))
|
|
1118
750
|
]),
|
|
1119
751
|
optionalEl("elado", [
|
|
1120
|
-
optionalEl("emailReplyto", optionalText(email?.replyTo)),
|
|
1121
|
-
optionalEl("emailTargy", optionalText(email?.subject)),
|
|
1122
|
-
optionalEl("emailSzoveg", optionalText(email?.text))
|
|
752
|
+
optionalEl("emailReplyto", optionalText$1(email?.replyTo)),
|
|
753
|
+
optionalEl("emailTargy", optionalText$1(email?.subject)),
|
|
754
|
+
optionalEl("emailSzoveg", optionalText$1(email?.text))
|
|
1123
755
|
]),
|
|
1124
756
|
optionalEl("vevo", [
|
|
1125
|
-
optionalEl("email", optionalText(buyer?.email)),
|
|
1126
|
-
optionalEl("adoszam", optionalText(buyer?.taxNumber)),
|
|
1127
|
-
optionalEl("adoszamEU", optionalText(buyer?.euTaxNumber))
|
|
757
|
+
optionalEl("email", optionalText$1(buyer?.email)),
|
|
758
|
+
optionalEl("adoszam", optionalText$1(buyer?.taxNumber)),
|
|
759
|
+
optionalEl("adoszamEU", optionalText$1(buyer?.euTaxNumber))
|
|
1128
760
|
])
|
|
1129
761
|
]
|
|
1130
762
|
});
|
|
@@ -1159,8 +791,8 @@ function normalizeInput$1(input) {
|
|
|
1159
791
|
return typeof input === "string" ? { receiptNumber: input } : input;
|
|
1160
792
|
}
|
|
1161
793
|
function resolveIdentifier(input) {
|
|
1162
|
-
const receiptNumber = optionalText
|
|
1163
|
-
const orderNumber = optionalText
|
|
794
|
+
const receiptNumber = optionalText(input.receiptNumber);
|
|
795
|
+
const orderNumber = optionalText(input.orderNumber);
|
|
1164
796
|
if (receiptNumber === void 0 && orderNumber === void 0) throw receiptValidationError("A nyugta lekérdezéséhez add meg a nyugtaszámot (receiptNumber) vagy a rendelésszámot (orderNumber).");
|
|
1165
797
|
if (receiptNumber !== void 0 && orderNumber !== void 0) throw receiptValidationError("A nyugta lekérdezéséhez a nyugtaszám (receiptNumber) és a rendelésszám (orderNumber) közül csak az egyiket add meg.");
|
|
1166
798
|
return {
|
|
@@ -1178,7 +810,7 @@ function buildGetReceiptXml(credentials, input) {
|
|
|
1178
810
|
children: [el("beallitasok", [...credentials, el("pdfLetoltes", normalized.downloadPdf ?? true)]), el("fejlec", [
|
|
1179
811
|
optionalEl("nyugtaszam", receiptNumber),
|
|
1180
812
|
optionalEl("rendelesSzam", orderNumber),
|
|
1181
|
-
optionalEl("hivasAzonosito", optionalText
|
|
813
|
+
optionalEl("hivasAzonosito", optionalText(normalized.callId)),
|
|
1182
814
|
optionalEl("pdfSablon", validateTemplate$1(normalized.template))
|
|
1183
815
|
])]
|
|
1184
816
|
});
|
|
@@ -1207,7 +839,7 @@ function buildReverseReceiptXml(credentials, input) {
|
|
|
1207
839
|
children: [el("beallitasok", [...credentials, el("pdfLetoltes", normalized.downloadPdf ?? true)]), el("fejlec", [
|
|
1208
840
|
el("nyugtaszam", requireReceiptNumber(normalized.receiptNumber)),
|
|
1209
841
|
optionalEl("pdfSablon", validateTemplate$1(normalized.template)),
|
|
1210
|
-
optionalEl("hivasAzonosito", optionalText
|
|
842
|
+
optionalEl("hivasAzonosito", optionalText(normalized.callId))
|
|
1211
843
|
])]
|
|
1212
844
|
});
|
|
1213
845
|
}
|
|
@@ -1218,7 +850,7 @@ function reverseReceipt(ctx, input, options = {}) {
|
|
|
1218
850
|
action: "reverseReceipt",
|
|
1219
851
|
xml,
|
|
1220
852
|
signal: options.signal,
|
|
1221
|
-
safeToRetry: optionalText
|
|
853
|
+
safeToRetry: optionalText(normalized.callId) !== void 0
|
|
1222
854
|
}, parseReceiptResponse);
|
|
1223
855
|
}
|
|
1224
856
|
//#endregion
|
|
@@ -1240,7 +872,7 @@ function normalizeEmails(emails) {
|
|
|
1240
872
|
function buildSendReceiptXml(credentials, input) {
|
|
1241
873
|
const receiptNumber = requireReceiptNumber(input.receiptNumber);
|
|
1242
874
|
const emails = normalizeEmails(input.emails);
|
|
1243
|
-
const replyTo = optionalText
|
|
875
|
+
const replyTo = optionalText(input.replyTo);
|
|
1244
876
|
if (replyTo !== void 0) assertEmail(replyTo, "replyTo");
|
|
1245
877
|
return buildXmlDocument({
|
|
1246
878
|
root: "xmlnyugtasend",
|
|
@@ -1252,7 +884,7 @@ function buildSendReceiptXml(credentials, input) {
|
|
|
1252
884
|
el("emailKuldes", [
|
|
1253
885
|
el("email", emails.join(",")),
|
|
1254
886
|
optionalEl("emailReplyto", replyTo),
|
|
1255
|
-
el("emailTargy", optionalText
|
|
887
|
+
el("emailTargy", optionalText(input.subject) ?? `Nyugta ${receiptNumber}`),
|
|
1256
888
|
optionalEl("emailSzoveg", input.text?.trim() ? input.text : void 0)
|
|
1257
889
|
])
|
|
1258
890
|
]
|
|
@@ -1593,4 +1225,4 @@ function createKassza(options = {}) {
|
|
|
1593
1225
|
};
|
|
1594
1226
|
}
|
|
1595
1227
|
//#endregion
|
|
1596
|
-
export {
|
|
1228
|
+
export { createAgentContext as a, attemptLedgerKey as c, buildCreateInvoiceXml as i, queryTaxpayer as n, ATTEMPT_LEDGER_KEY_PREFIX as o, getInvoicePdf as r, ATTEMPT_LEDGER_TTL_SECONDS as s, createKassza as t };
|