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
|
-
const require_create_once = require("./create-once-
|
|
1
|
+
const require_create_once = require("./create-once-DgMtKKcG.cjs");
|
|
2
2
|
const require_errors = require("./errors-DxeuTslP.cjs");
|
|
3
3
|
const require_binary = require("./binary-B89HM03_.cjs");
|
|
4
|
-
const
|
|
4
|
+
const require_serialize = require("./serialize-BXOww1Uq.cjs");
|
|
5
|
+
const require_parse = require("./parse-BJj-aqKy.cjs");
|
|
5
6
|
const require_session = require("./session-CKOuE6Jc.cjs");
|
|
6
7
|
const require_dates = require("./dates-CPgBodkP.cjs");
|
|
7
8
|
const require_vat = require("./vat-g35srbNG.cjs");
|
|
8
|
-
const require_money = require("./money-
|
|
9
|
+
const require_money = require("./money-BxytJW6f.cjs");
|
|
10
|
+
const require_issue = require("./issue-AGRohSm7.cjs");
|
|
11
|
+
const require_get = require("./get-Csm2n0rZ.cjs");
|
|
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:";
|
|
@@ -71,9 +74,9 @@ function resolveCredentials(options) {
|
|
|
71
74
|
const agentKey = options.agentKey?.trim() || (options.username ? void 0 : readEnv("SZAMLAZZ_AGENT_KEY"));
|
|
72
75
|
if (agentKey) {
|
|
73
76
|
if (agentKey !== agentKey.toLowerCase()) throw configurationError("Az Agent kulcs nagybetűt tartalmaz. A Számlázz.hu csak kisbetűs kulcsot fogad el, másold ki újra a kulcsot.");
|
|
74
|
-
return [
|
|
77
|
+
return [require_serialize.el("szamlaagentkulcs", agentKey)];
|
|
75
78
|
}
|
|
76
|
-
if (options.username && options.password) return [
|
|
79
|
+
if (options.username && options.password) return [require_serialize.el("felhasznalo", options.username), require_serialize.el("jelszo", options.password)];
|
|
77
80
|
throw configurationError("Hiányzik az Agent kulcs. Add meg az agentKey opciót, vagy állítsd be a SZAMLAZZ_AGENT_KEY környezeti változót.");
|
|
78
81
|
}
|
|
79
82
|
function toBlob(attachment) {
|
|
@@ -201,7 +204,7 @@ function createAgentContext(options = {}) {
|
|
|
201
204
|
const merged = require_session.mergeSetCookies(cookie, response.headers);
|
|
202
205
|
if (merged) await ignoreStoreFailure(async () => cookieStore.set(await resolveSessionKey(), merged, require_session.SESSION_TTL_SECONDS));
|
|
203
206
|
}
|
|
204
|
-
return
|
|
207
|
+
return require_parse.createAgentResponse(request.action, response.status, response.headers, body);
|
|
205
208
|
}
|
|
206
209
|
async function resetSession() {
|
|
207
210
|
if (cookieStore) await ignoreStoreFailure(async () => cookieStore.delete(await resolveSessionKey()));
|
|
@@ -274,8 +277,8 @@ function createAgentContext(options = {}) {
|
|
|
274
277
|
//#endregion
|
|
275
278
|
//#region src/invoices/create-response.ts
|
|
276
279
|
function readRawResponse(response) {
|
|
277
|
-
|
|
278
|
-
const headers =
|
|
280
|
+
require_parse.throwIfAnyError(response);
|
|
281
|
+
const headers = require_parse.readDocumentHeaders(response.headers);
|
|
279
282
|
const fromHeaders = {
|
|
280
283
|
number: headers.number,
|
|
281
284
|
netTotal: headers.netTotal,
|
|
@@ -288,26 +291,26 @@ function readRawResponse(response) {
|
|
|
288
291
|
...fromHeaders,
|
|
289
292
|
pdf: response.body
|
|
290
293
|
};
|
|
291
|
-
if (
|
|
292
|
-
const root =
|
|
293
|
-
|
|
294
|
-
const pdfBase64 =
|
|
294
|
+
if (require_parse.looksLikeXml(response)) {
|
|
295
|
+
const root = require_parse.parseResponseXml(response);
|
|
296
|
+
require_parse.throwIfXmlFailure(root, response);
|
|
297
|
+
const pdfBase64 = require_serialize.childText(root, "pdf");
|
|
295
298
|
return {
|
|
296
|
-
number:
|
|
297
|
-
netTotal:
|
|
298
|
-
grossTotal:
|
|
299
|
-
outstanding:
|
|
300
|
-
buyerAccountUrl:
|
|
299
|
+
number: require_serialize.childText(root, "szamlaszam") ?? headers.number,
|
|
300
|
+
netTotal: require_serialize.childNumber(root, "szamlanetto") ?? headers.netTotal,
|
|
301
|
+
grossTotal: require_serialize.childNumber(root, "szamlabrutto") ?? headers.grossTotal,
|
|
302
|
+
outstanding: require_serialize.childNumber(root, "kintlevoseg"),
|
|
303
|
+
buyerAccountUrl: require_serialize.childText(root, "vevoifiokurl") ?? headers.buyerAccountUrl,
|
|
301
304
|
pdf: pdfBase64 === void 0 ? void 0 : require_binary.base64ToBytes(pdfBase64)
|
|
302
305
|
};
|
|
303
306
|
}
|
|
304
|
-
const done =
|
|
307
|
+
const done = require_parse.parseDoneText(response.text());
|
|
305
308
|
if (done) return {
|
|
306
309
|
...fromHeaders,
|
|
307
310
|
number: done.number ?? headers.number
|
|
308
311
|
};
|
|
309
312
|
if (headers.number !== void 0) return fromHeaders;
|
|
310
|
-
throw
|
|
313
|
+
throw require_parse.unexpectedResponse(response, "Számlaszámot vagy PDF-et vártunk.");
|
|
311
314
|
}
|
|
312
315
|
function totalsFor(raw, items) {
|
|
313
316
|
if (raw.netTotal !== void 0 && raw.grossTotal !== void 0) return {
|
|
@@ -322,7 +325,7 @@ function totalsFor(raw, items) {
|
|
|
322
325
|
}
|
|
323
326
|
function parseCreateInvoiceResponse(response, items = []) {
|
|
324
327
|
const raw = readRawResponse(response);
|
|
325
|
-
if (raw.number === void 0) throw
|
|
328
|
+
if (raw.number === void 0) throw require_parse.unexpectedResponse(response, "A sikeres válaszból hiányzik a számlaszám.");
|
|
326
329
|
return {
|
|
327
330
|
number: raw.number,
|
|
328
331
|
...totalsFor(raw, items),
|
|
@@ -334,7 +337,7 @@ function parseCreateInvoiceResponse(response, items = []) {
|
|
|
334
337
|
}
|
|
335
338
|
function parseInvoicePreviewResponse(response, items = []) {
|
|
336
339
|
const raw = readRawResponse(response);
|
|
337
|
-
if (raw.pdf === void 0) throw
|
|
340
|
+
if (raw.pdf === void 0) throw require_parse.unexpectedResponse(response, "Az előnézeti válaszból hiányzik a PDF.");
|
|
338
341
|
return {
|
|
339
342
|
pdf: raw.pdf,
|
|
340
343
|
...totalsFor(raw, items),
|
|
@@ -347,60 +350,60 @@ const INVOICE_XML_NAMESPACE = "http://www.szamlazz.hu/xmlszamla";
|
|
|
347
350
|
const INVOICE_XML_SCHEMA_LOCATION = "https://www.szamlazz.hu/szamla/docs/xsds/agent/xmlszamla.xsd";
|
|
348
351
|
const RESPONSE_VERSION_XML = 2;
|
|
349
352
|
function textEl(name, value) {
|
|
350
|
-
return
|
|
353
|
+
return require_serialize.optionalEl(name, require_create_once.presentText(value));
|
|
351
354
|
}
|
|
352
355
|
function settingsNode(credentials, invoice, preview) {
|
|
353
|
-
return
|
|
356
|
+
return require_serialize.el("beallitasok", [
|
|
354
357
|
...credentials,
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
+
require_serialize.el("eszamla", invoice.eInvoice),
|
|
359
|
+
require_serialize.el("szamlaLetoltes", preview || invoice.downloadPdf),
|
|
360
|
+
require_serialize.el("valaszVerzio", RESPONSE_VERSION_XML),
|
|
358
361
|
textEl("aggregator", invoice.aggregator),
|
|
359
|
-
|
|
360
|
-
|
|
362
|
+
require_serialize.optionalEl("guardian", invoice.guardian),
|
|
363
|
+
require_serialize.optionalEl("cikkazoninvoice", invoice.articleIdentifierInvoice),
|
|
361
364
|
textEl("szamlaKulsoAzon", invoice.input.externalId)
|
|
362
365
|
]);
|
|
363
366
|
}
|
|
364
367
|
function documentTypeNodes(invoice) {
|
|
365
368
|
const { input, type } = invoice;
|
|
366
369
|
return [
|
|
367
|
-
type === "advance" &&
|
|
368
|
-
type === "final" &&
|
|
370
|
+
type === "advance" && require_serialize.el("elolegszamla", true),
|
|
371
|
+
type === "final" && require_serialize.el("vegszamla", true),
|
|
369
372
|
input.type === "final" && textEl("elolegSzamlaszam", input.advanceInvoiceNumber),
|
|
370
|
-
type === "corrective" &&
|
|
373
|
+
type === "corrective" && require_serialize.el("helyesbitoszamla", true),
|
|
371
374
|
input.type === "corrective" && textEl("helyesbitettSzamlaszam", input.correctedInvoiceNumber),
|
|
372
|
-
type === "proforma" &&
|
|
373
|
-
type === "deliveryNote" &&
|
|
375
|
+
type === "proforma" && require_serialize.el("dijbekero", true),
|
|
376
|
+
type === "deliveryNote" && require_serialize.el("szallitolevel", true)
|
|
374
377
|
];
|
|
375
378
|
}
|
|
376
379
|
function headerNode(invoice, preview) {
|
|
377
380
|
const { input } = invoice;
|
|
378
|
-
return
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
381
|
+
return require_serialize.el("fejlec", [
|
|
382
|
+
require_serialize.el("keltDatum", invoice.issueDate),
|
|
383
|
+
require_serialize.el("teljesitesDatum", invoice.fulfillmentDate),
|
|
384
|
+
require_serialize.el("fizetesiHataridoDatum", invoice.dueDate),
|
|
385
|
+
require_serialize.el("fizmod", invoice.paymentMethod),
|
|
386
|
+
require_serialize.el("penznem", invoice.currency),
|
|
387
|
+
require_serialize.el("szamlaNyelve", invoice.language),
|
|
385
388
|
textEl("megjegyzes", input.comment),
|
|
386
389
|
textEl("arfolyamBank", invoice.exchangeBank),
|
|
387
|
-
|
|
390
|
+
require_serialize.optionalEl("arfolyam", invoice.exchangeRate),
|
|
388
391
|
textEl("rendelesSzam", input.orderNumber),
|
|
389
392
|
textEl("dijbekeroSzamlaszam", input.proformaNumber),
|
|
390
393
|
...documentTypeNodes(invoice),
|
|
391
394
|
textEl("logoExtra", invoice.logoExtra),
|
|
392
395
|
textEl("szamlaszamElotag", invoice.prefix),
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
preview &&
|
|
399
|
-
|
|
396
|
+
require_serialize.optionalEl("fizetendoKorrekcio", input.paymentCorrection),
|
|
397
|
+
require_serialize.optionalEl("fizetve", input.paid),
|
|
398
|
+
require_serialize.optionalEl("arresAfa", input.marginVat),
|
|
399
|
+
require_serialize.optionalEl("eusAfa", invoice.euVat),
|
|
400
|
+
require_serialize.optionalEl("szamlaSablon", invoice.template),
|
|
401
|
+
preview && require_serialize.el("elonezetpdf", true),
|
|
402
|
+
require_serialize.optionalEl("simpleItems", invoice.simpleItems)
|
|
400
403
|
]);
|
|
401
404
|
}
|
|
402
405
|
function sellerNode(seller) {
|
|
403
|
-
return
|
|
406
|
+
return require_serialize.el("elado", [
|
|
404
407
|
textEl("bank", seller.bank),
|
|
405
408
|
textEl("bankszamlaszam", seller.bankAccount),
|
|
406
409
|
textEl("emailReplyto", seller.emailReplyTo),
|
|
@@ -411,26 +414,26 @@ function sellerNode(seller) {
|
|
|
411
414
|
}
|
|
412
415
|
function buyerLedgerNode(ledger) {
|
|
413
416
|
if (!ledger) return void 0;
|
|
414
|
-
return
|
|
415
|
-
|
|
417
|
+
return require_serialize.optionalEl("vevoFokonyv", [
|
|
418
|
+
require_serialize.optionalEl("konyvelesDatum", require_create_once.optionalAgentDate(ledger.bookingDate, "buyer.ledger.bookingDate")),
|
|
416
419
|
textEl("vevoAzonosito", ledger.buyerId),
|
|
417
420
|
textEl("vevoFokonyviSzam", ledger.ledgerAccount),
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
+
require_serialize.optionalEl("folyamatosTelj", ledger.continuousFulfillment),
|
|
422
|
+
require_serialize.optionalEl("elszDatumTol", require_create_once.optionalAgentDate(ledger.settlementPeriodStart, "buyer.ledger.settlementPeriodStart")),
|
|
423
|
+
require_serialize.optionalEl("elszDatumIg", require_create_once.optionalAgentDate(ledger.settlementPeriodEnd, "buyer.ledger.settlementPeriodEnd"))
|
|
421
424
|
]);
|
|
422
425
|
}
|
|
423
426
|
function buyerNode(buyer, sendEmail) {
|
|
424
427
|
const taxpayerType = buyer.taxpayerType;
|
|
425
|
-
return
|
|
426
|
-
|
|
428
|
+
return require_serialize.el("vevo", [
|
|
429
|
+
require_serialize.el("nev", buyer.name),
|
|
427
430
|
textEl("orszag", buyer.country),
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
+
require_serialize.el("irsz", buyer.zip),
|
|
432
|
+
require_serialize.el("telepules", buyer.city),
|
|
433
|
+
require_serialize.el("cim", buyer.address),
|
|
431
434
|
textEl("email", buyer.email),
|
|
432
|
-
|
|
433
|
-
|
|
435
|
+
require_serialize.el("sendEmail", sendEmail),
|
|
436
|
+
require_serialize.optionalEl("adoalany", taxpayerType === void 0 ? void 0 : require_create_once.TAXPAYER_TYPE_CODES[taxpayerType]),
|
|
434
437
|
textEl("adoszam", buyer.taxNumber),
|
|
435
438
|
textEl("csoportazonosito", buyer.groupTaxNumber),
|
|
436
439
|
textEl("adoszamEU", buyer.euTaxNumber),
|
|
@@ -449,68 +452,68 @@ function buyerNode(buyer, sendEmail) {
|
|
|
449
452
|
function waybillNode(waybill) {
|
|
450
453
|
if (!waybill) return void 0;
|
|
451
454
|
const { transOFlex: tof, pickPackPoint: ppp, sprinter, mpl } = waybill;
|
|
452
|
-
return
|
|
455
|
+
return require_serialize.el("fuvarlevel", [
|
|
453
456
|
textEl("futarSzolgalat", waybill.courier),
|
|
454
457
|
textEl("vonalkod", waybill.barcode),
|
|
455
458
|
textEl("megjegyzes", waybill.comment),
|
|
456
|
-
tof &&
|
|
459
|
+
tof && require_serialize.el("tof", [
|
|
457
460
|
textEl("azonosito", tof.id),
|
|
458
461
|
textEl("shipmentID", tof.shipmentId),
|
|
459
|
-
|
|
462
|
+
require_serialize.optionalEl("csomagszam", tof.packageCount),
|
|
460
463
|
textEl("countryCode", tof.countryCode),
|
|
461
464
|
textEl("zip", tof.zip),
|
|
462
465
|
textEl("service", tof.service)
|
|
463
466
|
]),
|
|
464
|
-
ppp &&
|
|
465
|
-
sprinter &&
|
|
467
|
+
ppp && require_serialize.el("ppp", [textEl("vonalkodPrefix", ppp.barcodePrefix), textEl("vonalkodPostfix", ppp.barcodePostfix)]),
|
|
468
|
+
sprinter && require_serialize.el("sprinter", [
|
|
466
469
|
textEl("azonosito", sprinter.id),
|
|
467
470
|
textEl("feladokod", sprinter.senderCode),
|
|
468
471
|
textEl("iranykod", sprinter.directionCode),
|
|
469
|
-
|
|
472
|
+
require_serialize.optionalEl("csomagszam", sprinter.packageCount),
|
|
470
473
|
textEl("vonalkodPostfix", sprinter.barcodePostfix),
|
|
471
474
|
textEl("szallitasiIdo", sprinter.deliveryTime)
|
|
472
475
|
]),
|
|
473
|
-
mpl &&
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
476
|
+
mpl && require_serialize.el("mpl", [
|
|
477
|
+
require_serialize.el("vevokod", mpl.customerCode),
|
|
478
|
+
require_serialize.el("vonalkod", mpl.barcode),
|
|
479
|
+
require_serialize.el("tomeg", String(mpl.weight)),
|
|
477
480
|
textEl("kulonszolgaltatasok", mpl.services),
|
|
478
|
-
|
|
481
|
+
require_serialize.optionalEl("erteknyilvanitas", mpl.declaredValue)
|
|
479
482
|
])
|
|
480
483
|
]);
|
|
481
484
|
}
|
|
482
485
|
function itemLedgerNode(ledger, label) {
|
|
483
486
|
if (!ledger) return void 0;
|
|
484
|
-
return
|
|
487
|
+
return require_serialize.optionalEl("tetelFokonyv", [
|
|
485
488
|
textEl("gazdasagiEsem", ledger.economicEvent),
|
|
486
489
|
textEl("gazdasagiEsemAfa", ledger.vatEconomicEvent),
|
|
487
490
|
textEl("arbevetelFokonyviSzam", ledger.revenueLedgerAccount),
|
|
488
491
|
textEl("afaFokonyviSzam", ledger.vatLedgerAccount),
|
|
489
|
-
|
|
490
|
-
|
|
492
|
+
require_serialize.optionalEl("elszDatumTol", require_create_once.optionalAgentDate(ledger.settlementPeriodStart, `${label} settlementPeriodStart`)),
|
|
493
|
+
require_serialize.optionalEl("elszDatumIg", require_create_once.optionalAgentDate(ledger.settlementPeriodEnd, `${label} settlementPeriodEnd`))
|
|
491
494
|
]);
|
|
492
495
|
}
|
|
493
496
|
function itemNode(item, index) {
|
|
494
497
|
const { input, amounts } = item;
|
|
495
|
-
return
|
|
496
|
-
|
|
498
|
+
return require_serialize.el("tetel", [
|
|
499
|
+
require_serialize.el("megnevezes", input.name),
|
|
497
500
|
textEl("azonosito", input.identifier),
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
501
|
+
require_serialize.el("mennyiseg", amounts.quantity),
|
|
502
|
+
require_serialize.el("mennyisegiEgyseg", item.unit),
|
|
503
|
+
require_serialize.el("nettoEgysegar", amounts.netUnitPrice),
|
|
504
|
+
require_serialize.el("afakulcs", require_vat.formatVatRate(amounts.vat)),
|
|
505
|
+
require_serialize.optionalEl("arresAfaAlap", input.marginVatBase),
|
|
506
|
+
require_serialize.el("nettoErtek", amounts.netAmount),
|
|
507
|
+
require_serialize.el("afaErtek", amounts.vatAmount),
|
|
508
|
+
require_serialize.el("bruttoErtek", amounts.grossAmount),
|
|
506
509
|
textEl("megjegyzes", input.comment),
|
|
507
510
|
itemLedgerNode(input.ledger, `${index + 1}. tétel ledger`),
|
|
508
|
-
|
|
511
|
+
require_serialize.optionalEl("torloKod", input.dataDeletionCode)
|
|
509
512
|
]);
|
|
510
513
|
}
|
|
511
514
|
function renderInvoiceXml(credentials, invoice, options = {}) {
|
|
512
515
|
const preview = options.preview === true;
|
|
513
|
-
return
|
|
516
|
+
return require_serialize.buildXmlDocument({
|
|
514
517
|
root: "xmlszamla",
|
|
515
518
|
namespace: INVOICE_XML_NAMESPACE,
|
|
516
519
|
schemaLocation: INVOICE_XML_SCHEMA_LOCATION,
|
|
@@ -520,10 +523,13 @@ function renderInvoiceXml(credentials, invoice, options = {}) {
|
|
|
520
523
|
sellerNode(invoice.seller),
|
|
521
524
|
buyerNode(invoice.input.buyer, invoice.sendEmail),
|
|
522
525
|
waybillNode(invoice.input.waybill),
|
|
523
|
-
|
|
526
|
+
require_serialize.el("tetelek", invoice.items.map(itemNode))
|
|
524
527
|
]
|
|
525
528
|
});
|
|
526
529
|
}
|
|
530
|
+
function buildCreateInvoiceXml(credentials, defaults, input, now = /* @__PURE__ */ new Date()) {
|
|
531
|
+
return renderInvoiceXml(credentials, require_create_once.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 require_errors.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 require_dates.toAgentDate(input);
|
|
570
|
-
} catch (error) {
|
|
571
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
572
|
-
throw new require_errors.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 = require_issue.readHeader(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 = require_issue.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 = require_issue.childText(root, "pdf");
|
|
623
|
-
if (encoded === void 0) return void 0;
|
|
624
|
-
try {
|
|
625
|
-
return require_binary.base64ToBytes(encoded);
|
|
626
|
-
} catch (error) {
|
|
627
|
-
throw new require_errors.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: require_issue.childText(root, "szamlaszam") ?? headers.number,
|
|
639
|
-
netTotal: require_issue.childNumber(root, "szamlanetto") ?? headers.netTotal,
|
|
640
|
-
grossTotal: require_issue.childNumber(root, "szamlabrutto") ?? headers.grossTotal,
|
|
641
|
-
outstanding: require_issue.childNumber(root, "kintlevoseg") ?? headers.outstanding,
|
|
642
|
-
buyerAccountUrl: require_issue.childText(root, "vevoifiokurl") ?? headers.buyerAccountUrl,
|
|
643
|
-
pdf: decodeResponsePdf(root, response)
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
const INVOICE_RESULT_ROOT = "xmlszamlavalasz";
|
|
647
|
-
function parseInvoiceResult(response) {
|
|
648
|
-
require_issue.throwIfHeaderError(response);
|
|
649
|
-
if (response.isPdf) return {
|
|
650
|
-
...headerSummary(response),
|
|
651
|
-
pdf: response.body
|
|
652
|
-
};
|
|
653
|
-
require_issue.throwIfTextError(response);
|
|
654
|
-
require_issue.throwIfHttpError(response);
|
|
655
|
-
if (require_issue.looksLikeXml(response)) {
|
|
656
|
-
const root = require_issue.parseResponseXml(response);
|
|
657
|
-
require_issue.throwIfXmlFailure(root, response);
|
|
658
|
-
if (root.name !== INVOICE_RESULT_ROOT || require_issue.childText(root, "sikeres")?.toLowerCase() !== "true") throw require_issue.unexpectedResponse(response, `${INVOICE_RESULT_ROOT} XML választ vártunk.`);
|
|
659
|
-
return readInvoiceResultXml(root, response);
|
|
660
|
-
}
|
|
661
|
-
const headers = headerSummary(response);
|
|
662
|
-
const done = require_issue.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 require_issue.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 require_issue.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
|
-
require_issue.optionalEl("szamlaszam", referenceValue(resolved, "invoiceNumber")),
|
|
690
|
-
require_issue.optionalEl("rendelesSzam", referenceValue(resolved, "orderNumber")),
|
|
691
|
-
require_issue.optionalEl("pdf", query.includePdf),
|
|
692
|
-
require_issue.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 require_issue.unexpectedResponse(this.response, `Hiányzik a(z) <${path}> elem a számla XML-ből.`);
|
|
703
|
-
}
|
|
704
|
-
element(parent, name, path) {
|
|
705
|
-
const child = require_issue.findChild(parent, name);
|
|
706
|
-
if (!child) throw this.missing(path);
|
|
707
|
-
return child;
|
|
708
|
-
}
|
|
709
|
-
text(parent, name, path) {
|
|
710
|
-
const value = require_issue.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 = require_issue.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: require_issue.childText(element, "nev"),
|
|
724
|
-
country: require_issue.childText(element, "orszag"),
|
|
725
|
-
zip: require_issue.childText(element, "irsz"),
|
|
726
|
-
city: require_issue.childText(element, "telepules"),
|
|
727
|
-
address: require_issue.childText(element, "cim")
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
function readSeller(root, reader) {
|
|
731
|
-
const seller = reader.element(root, "szallito", "szallito");
|
|
732
|
-
const bank = require_issue.findChild(seller, "bank");
|
|
733
|
-
return {
|
|
734
|
-
id: require_issue.childNumber(seller, "id"),
|
|
735
|
-
name: reader.text(seller, "nev", "szallito"),
|
|
736
|
-
address: readAddress(require_issue.findChild(seller, "cim")),
|
|
737
|
-
postalAddress: readAddress(require_issue.findChild(seller, "postacim")),
|
|
738
|
-
taxNumber: require_issue.childText(seller, "adoszam"),
|
|
739
|
-
groupTaxNumber: require_issue.childText(seller, "csoportazonosito"),
|
|
740
|
-
euTaxNumber: require_issue.childText(seller, "adoszameu"),
|
|
741
|
-
bank: bank && {
|
|
742
|
-
name: require_issue.childText(bank, "nev"),
|
|
743
|
-
accountNumber: require_issue.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 = require_issue.childNumber(header, "eszamla");
|
|
753
|
-
return {
|
|
754
|
-
id: require_issue.childNumber(header, "id"),
|
|
755
|
-
number: reader.text(header, "szamlaszam", "alap"),
|
|
756
|
-
economicEventId: require_issue.childNumber(header, "gazdEsemAzon"),
|
|
757
|
-
sourceSystem: require_issue.childNumber(header, "forras"),
|
|
758
|
-
registrationNumber: require_issue.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: require_issue.childText(header, "hivszamlaszam"),
|
|
764
|
-
referencedProformaNumber: require_issue.childText(header, "hivdijbekszam"),
|
|
765
|
-
issueDate: reader.text(header, "kelt", "alap"),
|
|
766
|
-
fulfillmentDate: require_issue.childText(header, "telj"),
|
|
767
|
-
dueDate: require_issue.childText(header, "fizh"),
|
|
768
|
-
paymentMethod: require_issue.childText(header, "fizmod"),
|
|
769
|
-
unifiedPaymentMethod: require_issue.childText(header, "fizmodunified"),
|
|
770
|
-
cash: require_issue.childBoolean(header, "keszpenz"),
|
|
771
|
-
orderNumber: require_issue.childText(header, "rendelesszam"),
|
|
772
|
-
language: require_issue.childText(header, "nyelv"),
|
|
773
|
-
currency: require_issue.childText(header, "devizanem"),
|
|
774
|
-
exchangeBank: require_issue.childText(header, "devizabank"),
|
|
775
|
-
exchangeRate: require_issue.childNumber(header, "devizaarf"),
|
|
776
|
-
comment: require_issue.childText(header, "megjegyzes"),
|
|
777
|
-
vatType: require_issue.childText(header, "afatipus"),
|
|
778
|
-
cashAccounting: require_issue.childBoolean(header, "penzforg"),
|
|
779
|
-
kata: require_issue.childBoolean(header, "kata"),
|
|
780
|
-
kataLedger: require_issue.childBoolean(header, "katafokonyv"),
|
|
781
|
-
email: require_issue.childText(header, "email"),
|
|
782
|
-
test: require_issue.childBoolean(header, "teszt"),
|
|
783
|
-
reversed: require_issue.childBoolean(header, "sztornozott")
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
function readBuyerLedger(element) {
|
|
787
|
-
if (!element) return void 0;
|
|
788
|
-
return {
|
|
789
|
-
ledgerAccount: require_issue.childText(element, "vevo"),
|
|
790
|
-
buyerId: require_issue.childText(element, "vevoazon"),
|
|
791
|
-
bookingDate: require_issue.childText(element, "datum"),
|
|
792
|
-
continuousFulfillment: require_issue.childBoolean(element, "folyamatostelj"),
|
|
793
|
-
settlementPeriodStart: require_issue.childText(element, "elszDatTol") ?? require_issue.childText(element, "elszdattol"),
|
|
794
|
-
settlementPeriodEnd: require_issue.childText(element, "elszDatIg") ?? require_issue.childText(element, "elszdatig")
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
function readBuyer(root, reader) {
|
|
798
|
-
const buyer = reader.element(root, "vevo", "vevo");
|
|
799
|
-
return {
|
|
800
|
-
id: require_issue.childNumber(buyer, "id"),
|
|
801
|
-
name: reader.text(buyer, "nev", "vevo"),
|
|
802
|
-
identifier: require_issue.childText(buyer, "azonosito"),
|
|
803
|
-
address: readAddress(require_issue.findChild(buyer, "cim")),
|
|
804
|
-
postalAddress: readAddress(require_issue.findChild(buyer, "postacim")),
|
|
805
|
-
email: require_issue.childText(buyer, "email"),
|
|
806
|
-
taxNumber: require_issue.childText(buyer, "adoszam"),
|
|
807
|
-
groupTaxNumber: require_issue.childText(buyer, "csoportazonosito"),
|
|
808
|
-
euTaxNumber: require_issue.childText(buyer, "adoszameu"),
|
|
809
|
-
location: require_issue.childNumber(buyer, "lokacio"),
|
|
810
|
-
privatePerson: require_issue.childBoolean(buyer, "privatePersonIndicator"),
|
|
811
|
-
ledger: readBuyerLedger(require_issue.findChild(buyer, "fokonyv"))
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
function readItemLedger(element) {
|
|
815
|
-
if (!element) return void 0;
|
|
816
|
-
return {
|
|
817
|
-
revenueLedgerAccount: require_issue.childText(element, "arbevetel"),
|
|
818
|
-
vatLedgerAccount: require_issue.childText(element, "afa"),
|
|
819
|
-
economicEvent: require_issue.childText(element, "gazdasagiesemeny"),
|
|
820
|
-
vatEconomicEvent: require_issue.childText(element, "gazdasagiesemenyafa"),
|
|
821
|
-
settlementPeriodStart: require_issue.childText(element, "elszdattol"),
|
|
822
|
-
settlementPeriodEnd: require_issue.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: require_issue.childText(item, "azonosito"),
|
|
830
|
-
quantity: reader.number(item, "mennyiseg", path),
|
|
831
|
-
unit: require_issue.childText(item, "mennyisegiegyseg"),
|
|
832
|
-
netUnitPrice: reader.number(item, "nettoegysegar", path),
|
|
833
|
-
vat: reader.number(item, "afakulcs", path),
|
|
834
|
-
vatCode: require_issue.childText(item, "afatipus"),
|
|
835
|
-
netAmount: reader.number(item, "netto", path),
|
|
836
|
-
marginVatBase: require_issue.childNumber(item, "arresafaalap"),
|
|
837
|
-
vatAmount: reader.number(item, "afa", path),
|
|
838
|
-
grossAmount: reader.number(item, "brutto", path),
|
|
839
|
-
comment: require_issue.childText(item, "megjegyzes"),
|
|
840
|
-
position: require_issue.childNumber(item, "sztetordering"),
|
|
841
|
-
ledger: readItemLedger(require_issue.findChild(item, "fokonyv"))
|
|
842
|
-
};
|
|
843
|
-
}
|
|
844
|
-
function readLabels(element) {
|
|
845
|
-
return require_issue.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: require_issue.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: require_issue.childText(item, "elszdattol"),
|
|
860
|
-
settlementPeriodEnd: require_issue.childText(item, "elszdatig"),
|
|
861
|
-
vatDeduction: require_issue.childNumber(item, "afalevon"),
|
|
862
|
-
labels: readLabels(require_issue.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: require_issue.findChildren(totals, "afakulcsossz").map((entry) => ({
|
|
874
|
-
vat: reader.number(entry, "afakulcs", "osszegek/afakulcsossz"),
|
|
875
|
-
vatCode: require_issue.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: require_issue.childText(payment, "megjegyzes"),
|
|
889
|
-
bankAccountNumber: require_issue.childText(payment, "bankszamlaszam"),
|
|
890
|
-
bankTransactionId: require_issue.childNumber(payment, "banktranzid"),
|
|
891
|
-
exchangeRate: require_issue.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: require_issue.findChildren(require_issue.findChild(root, "tetelek"), "tetel").map((item) => readItem(item, reader)),
|
|
901
|
-
financialItems: require_issue.findChildren(require_issue.findChild(root, "qutetek"), "qutet").map((item) => readFinancialItem(item, reader)),
|
|
902
|
-
labels: readLabels(require_issue.findChild(root, "cimkek")),
|
|
903
|
-
totals: readTotals(root, reader),
|
|
904
|
-
payments: require_issue.findChildren(require_issue.findChild(root, "kifizetesek"), "kifizetes").map((payment) => readPayment(payment, reader)),
|
|
905
|
-
pdf: decodeResponsePdf(root, response)
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
function parseGetInvoiceResponse(response) {
|
|
909
|
-
require_issue.throwIfHeaderError(response);
|
|
910
|
-
require_issue.throwIfTextError(response);
|
|
911
|
-
require_issue.throwIfHttpError(response);
|
|
912
|
-
const root = require_issue.parseResponseXml(response);
|
|
913
|
-
require_issue.throwIfXmlFailure(root, response);
|
|
914
|
-
if (root.name !== "szamla") throw require_issue.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,
|
|
@@ -930,8 +562,8 @@ function normalizeRegisterInput(input) {
|
|
|
930
562
|
date: input.date,
|
|
931
563
|
description: input.description
|
|
932
564
|
}];
|
|
933
|
-
if (!Array.isArray(payments) || payments.length === 0) throw validationError("Adj meg legalább egy befizetést (payments). A korábbi befizetések törléséhez a clearPayments függvényt használd.");
|
|
934
|
-
if (payments.length > 5) throw validationError(`Egy kérésben legfeljebb 5 befizetés rögzíthető, kapott: ${payments.length}.`);
|
|
565
|
+
if (!Array.isArray(payments) || payments.length === 0) throw require_get.validationError("Adj meg legalább egy befizetést (payments). A korábbi befizetések törléséhez a clearPayments függvényt használd.");
|
|
566
|
+
if (payments.length > 5) throw require_get.validationError(`Egy kérésben legfeljebb 5 befizetés rögzíthető, kapott: ${payments.length}.`);
|
|
935
567
|
return {
|
|
936
568
|
invoiceNumber: input.invoiceNumber,
|
|
937
569
|
taxNumber: input.taxNumber,
|
|
@@ -950,31 +582,31 @@ function normalizeClearInput(input) {
|
|
|
950
582
|
}
|
|
951
583
|
function paymentNode(payment, index) {
|
|
952
584
|
const position = index + 1;
|
|
953
|
-
if (typeof payment.amount !== "number" || !Number.isFinite(payment.amount)) throw validationError(`A(z) ${position}. befizetés összege (amount) nem véges szám.`);
|
|
954
|
-
return
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
585
|
+
if (typeof payment.amount !== "number" || !Number.isFinite(payment.amount)) throw require_get.validationError(`A(z) ${position}. befizetés összege (amount) nem véges szám.`);
|
|
586
|
+
return require_serialize.el("kifizetes", [
|
|
587
|
+
require_serialize.el("datum", payment.date === void 0 ? require_dates.todayInBudapest() : require_get.agentDate(payment.date, "date")),
|
|
588
|
+
require_serialize.el("jogcim", require_get.requireText(payment.method, `Add meg a(z) ${position}. befizetés módját (method).`)),
|
|
589
|
+
require_serialize.el("osszeg", payment.amount),
|
|
590
|
+
require_serialize.optionalEl("leiras", require_get.optionalText(payment.description))
|
|
959
591
|
]);
|
|
960
592
|
}
|
|
961
593
|
function buildPaymentXml(credentials, request) {
|
|
962
|
-
const invoiceNumber = requireText(request.invoiceNumber, "Add meg a számla számát (invoiceNumber), amelyhez a befizetés tartozik.");
|
|
963
|
-
return
|
|
594
|
+
const invoiceNumber = require_get.requireText(request.invoiceNumber, "Add meg a számla számát (invoiceNumber), amelyhez a befizetés tartozik.");
|
|
595
|
+
return require_serialize.buildXmlDocument({
|
|
964
596
|
root: "xmlszamlakifiz",
|
|
965
597
|
namespace: "http://www.szamlazz.hu/xmlszamlakifiz",
|
|
966
|
-
schemaLocation: `${AGENT_XSD_BASE_URL}agentkifiz/xmlszamlakifiz.xsd`,
|
|
967
|
-
children: [
|
|
598
|
+
schemaLocation: `${require_get.AGENT_XSD_BASE_URL}agentkifiz/xmlszamlakifiz.xsd`,
|
|
599
|
+
children: [require_serialize.el("beallitasok", [
|
|
968
600
|
...credentials,
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
601
|
+
require_serialize.el("szamlaszam", invoiceNumber),
|
|
602
|
+
require_serialize.optionalEl("adoszam", require_get.optionalText(request.taxNumber)),
|
|
603
|
+
require_serialize.el("additiv", request.additive),
|
|
604
|
+
require_serialize.el("valaszVerzio", 2)
|
|
973
605
|
]), ...request.payments.map(paymentNode)]
|
|
974
606
|
});
|
|
975
607
|
}
|
|
976
608
|
function parseRegisterPaymentResponse(response, invoiceNumber) {
|
|
977
|
-
const result = parseInvoiceResult(response);
|
|
609
|
+
const result = require_get.parseInvoiceResult(response);
|
|
978
610
|
return {
|
|
979
611
|
invoiceNumber: result.number ?? invoiceNumber.trim(),
|
|
980
612
|
netTotal: result.netTotal,
|
|
@@ -1001,23 +633,23 @@ async function clearPayments(ctx, input, options = {}) {
|
|
|
1001
633
|
//#endregion
|
|
1002
634
|
//#region src/invoices/pdf.ts
|
|
1003
635
|
function buildInvoicePdfXml(credentials, reference) {
|
|
1004
|
-
const resolved = resolveInvoiceReference(reference);
|
|
1005
|
-
return
|
|
636
|
+
const resolved = require_get.resolveInvoiceReference(reference);
|
|
637
|
+
return require_serialize.buildXmlDocument({
|
|
1006
638
|
root: "xmlszamlapdf",
|
|
1007
639
|
namespace: "http://www.szamlazz.hu/xmlszamlapdf",
|
|
1008
|
-
schemaLocation: `${AGENT_XSD_BASE_URL}agentpdf/xmlszamlapdf.xsd`,
|
|
640
|
+
schemaLocation: `${require_get.AGENT_XSD_BASE_URL}agentpdf/xmlszamlapdf.xsd`,
|
|
1009
641
|
children: [
|
|
1010
642
|
...credentials,
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
643
|
+
require_serialize.optionalEl("szamlaszam", require_get.referenceValue(resolved, "invoiceNumber")),
|
|
644
|
+
require_serialize.optionalEl("rendelesSzam", require_get.referenceValue(resolved, "orderNumber")),
|
|
645
|
+
require_serialize.el("valaszVerzio", 2),
|
|
646
|
+
require_serialize.optionalEl("szamlaKulsoAzon", require_get.referenceValue(resolved, "externalId"))
|
|
1015
647
|
]
|
|
1016
648
|
});
|
|
1017
649
|
}
|
|
1018
650
|
function parseInvoicePdfResponse(response) {
|
|
1019
|
-
const { pdf, ...rest } = parseInvoiceResult(response);
|
|
1020
|
-
if (pdf === void 0 || pdf.length === 0) throw
|
|
651
|
+
const { pdf, ...rest } = require_get.parseInvoiceResult(response);
|
|
652
|
+
if (pdf === void 0 || pdf.length === 0) throw require_parse.unexpectedResponse(response, "A válasz nem tartalmaz PDF-et.");
|
|
1021
653
|
return {
|
|
1022
654
|
...rest,
|
|
1023
655
|
pdf
|
|
@@ -1035,20 +667,20 @@ async function getInvoicePdf(ctx, reference, options = {}) {
|
|
|
1035
667
|
const RESPONSE_ROOTS = /* @__PURE__ */ new Set(["xmlszamladbkdelvalasz", "xmlszamlavalasz"]);
|
|
1036
668
|
const REFERENCE_HINT = "Add meg a díjbekérő számát szövegként, vagy pontosan egyet ezek közül: { proformaNumber }, { orderNumber }.";
|
|
1037
669
|
function resolveProformaReference(reference) {
|
|
1038
|
-
if (typeof reference === "string") return { proformaNumber: requireText(reference, `Üres díjbekérőszám. ${REFERENCE_HINT}`) };
|
|
1039
|
-
if (typeof reference !== "object" || reference === null) throw validationError(`Érvénytelen díjbekérő-hivatkozás. ${REFERENCE_HINT}`);
|
|
670
|
+
if (typeof reference === "string") return { proformaNumber: require_get.requireText(reference, `Üres díjbekérőszám. ${REFERENCE_HINT}`) };
|
|
671
|
+
if (typeof reference !== "object" || reference === null) throw require_get.validationError(`Érvénytelen díjbekérő-hivatkozás. ${REFERENCE_HINT}`);
|
|
1040
672
|
const record = reference;
|
|
1041
673
|
const hasNumber = record.proformaNumber !== void 0;
|
|
1042
|
-
if (hasNumber === (record.orderNumber !== void 0)) throw validationError(`Érvénytelen díjbekérő-hivatkozás. ${REFERENCE_HINT}`);
|
|
1043
|
-
return hasNumber ? { proformaNumber: requireText(record.proformaNumber, `Üres proformaNumber. ${REFERENCE_HINT}`) } : { orderNumber: requireText(record.orderNumber, `Üres orderNumber. ${REFERENCE_HINT}`) };
|
|
674
|
+
if (hasNumber === (record.orderNumber !== void 0)) throw require_get.validationError(`Érvénytelen díjbekérő-hivatkozás. ${REFERENCE_HINT}`);
|
|
675
|
+
return hasNumber ? { proformaNumber: require_get.requireText(record.proformaNumber, `Üres proformaNumber. ${REFERENCE_HINT}`) } : { orderNumber: require_get.requireText(record.orderNumber, `Üres orderNumber. ${REFERENCE_HINT}`) };
|
|
1044
676
|
}
|
|
1045
677
|
function buildDeleteProformaXml(credentials, reference) {
|
|
1046
678
|
const resolved = resolveProformaReference(reference);
|
|
1047
|
-
return
|
|
679
|
+
return require_serialize.buildXmlDocument({
|
|
1048
680
|
root: "xmlszamladbkdel",
|
|
1049
681
|
namespace: "http://www.szamlazz.hu/xmlszamladbkdel",
|
|
1050
682
|
schemaLocation: "http://www.szamlazz.hu/docs/xsds/szamladbkdel/xmlszamladbkdel.xsd",
|
|
1051
|
-
children: [
|
|
683
|
+
children: [require_serialize.el("beallitasok", [...credentials]), require_serialize.el("fejlec", [require_serialize.optionalEl("szamlaszam", resolved.proformaNumber), require_serialize.optionalEl("rendelesszam", resolved.orderNumber)])]
|
|
1052
684
|
});
|
|
1053
685
|
}
|
|
1054
686
|
function withProformaCategory(error) {
|
|
@@ -1065,12 +697,12 @@ function withProformaCategory(error) {
|
|
|
1065
697
|
}
|
|
1066
698
|
function parseDeleteProformaResponse(response) {
|
|
1067
699
|
try {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
const root =
|
|
1072
|
-
|
|
1073
|
-
if (!RESPONSE_ROOTS.has(root.name) ||
|
|
700
|
+
require_parse.throwIfHeaderError(response);
|
|
701
|
+
require_parse.throwIfTextError(response);
|
|
702
|
+
require_parse.throwIfHttpError(response);
|
|
703
|
+
const root = require_parse.parseResponseXml(response);
|
|
704
|
+
require_parse.throwIfXmlFailure(root, response);
|
|
705
|
+
if (!RESPONSE_ROOTS.has(root.name) || require_serialize.childText(root, "sikeres")?.toLowerCase() !== "true") throw require_parse.unexpectedResponse(response, "xmlszamladbkdelvalasz XML választ vártunk.");
|
|
1074
706
|
} catch (error) {
|
|
1075
707
|
throw withProformaCategory(error);
|
|
1076
708
|
}
|
|
@@ -1089,49 +721,49 @@ function normalizeInput$2(input) {
|
|
|
1089
721
|
}
|
|
1090
722
|
function validateTemplate(template) {
|
|
1091
723
|
if (template === void 0 || templates.has(template)) return template;
|
|
1092
|
-
throw validationError(`Ismeretlen számlasablon: ${String(template)}. Lehetséges értékek: ${require_create_once.INVOICE_TEMPLATES.join(", ")}.`);
|
|
724
|
+
throw require_get.validationError(`Ismeretlen számlasablon: ${String(template)}. Lehetséges értékek: ${require_create_once.INVOICE_TEMPLATES.join(", ")}.`);
|
|
1093
725
|
}
|
|
1094
726
|
function buildReverseInvoiceXml(credentials, input) {
|
|
1095
727
|
const options = normalizeInput$2(input);
|
|
1096
|
-
const invoiceNumber = requireText(options.invoiceNumber, "Add meg a sztornózandó számla számát (invoiceNumber).");
|
|
728
|
+
const invoiceNumber = require_get.requireText(options.invoiceNumber, "Add meg a sztornózandó számla számát (invoiceNumber).");
|
|
1097
729
|
const email = options.email;
|
|
1098
730
|
const buyer = options.buyer;
|
|
1099
|
-
return
|
|
731
|
+
return require_serialize.buildXmlDocument({
|
|
1100
732
|
root: "xmlszamlast",
|
|
1101
733
|
namespace: "http://www.szamlazz.hu/xmlszamlast",
|
|
1102
|
-
schemaLocation: `${AGENT_XSD_BASE_URL}agentst/xmlszamlast.xsd`,
|
|
734
|
+
schemaLocation: `${require_get.AGENT_XSD_BASE_URL}agentst/xmlszamlast.xsd`,
|
|
1103
735
|
children: [
|
|
1104
|
-
|
|
736
|
+
require_serialize.el("beallitasok", [
|
|
1105
737
|
...credentials,
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
738
|
+
require_serialize.el("eszamla", options.eInvoice ?? false),
|
|
739
|
+
require_serialize.el("szamlaLetoltes", options.downloadPdf ?? true),
|
|
740
|
+
require_serialize.el("valaszVerzio", 2),
|
|
741
|
+
require_serialize.optionalEl("szamlaKulsoAzon", require_get.optionalText(options.externalId))
|
|
1110
742
|
]),
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
743
|
+
require_serialize.el("fejlec", [
|
|
744
|
+
require_serialize.el("szamlaszam", invoiceNumber),
|
|
745
|
+
require_serialize.optionalEl("keltDatum", require_get.optionalAgentDate(options.issueDate, "issueDate")),
|
|
746
|
+
require_serialize.optionalEl("teljesitesDatum", require_get.optionalAgentDate(options.fulfillmentDate, "fulfillmentDate")),
|
|
747
|
+
require_serialize.optionalEl("megjegyzes", require_get.optionalText(options.comment)),
|
|
748
|
+
require_serialize.el("tipus", "SS"),
|
|
749
|
+
require_serialize.optionalEl("szamlaSablon", validateTemplate(options.template))
|
|
1118
750
|
]),
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
751
|
+
require_serialize.optionalEl("elado", [
|
|
752
|
+
require_serialize.optionalEl("emailReplyto", require_get.optionalText(email?.replyTo)),
|
|
753
|
+
require_serialize.optionalEl("emailTargy", require_get.optionalText(email?.subject)),
|
|
754
|
+
require_serialize.optionalEl("emailSzoveg", require_get.optionalText(email?.text))
|
|
1123
755
|
]),
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
756
|
+
require_serialize.optionalEl("vevo", [
|
|
757
|
+
require_serialize.optionalEl("email", require_get.optionalText(buyer?.email)),
|
|
758
|
+
require_serialize.optionalEl("adoszam", require_get.optionalText(buyer?.taxNumber)),
|
|
759
|
+
require_serialize.optionalEl("adoszamEU", require_get.optionalText(buyer?.euTaxNumber))
|
|
1128
760
|
])
|
|
1129
761
|
]
|
|
1130
762
|
});
|
|
1131
763
|
}
|
|
1132
764
|
function parseReverseInvoiceResponse(response, originalInvoiceNumber) {
|
|
1133
|
-
const result = parseInvoiceResult(response);
|
|
1134
|
-
if (result.number === void 0) throw
|
|
765
|
+
const result = require_get.parseInvoiceResult(response);
|
|
766
|
+
if (result.number === void 0) throw require_parse.unexpectedResponse(response, "A válaszban nincs sztornó számlaszám.");
|
|
1135
767
|
if (originalInvoiceNumber !== void 0 && result.number === originalInvoiceNumber.trim()) throw new require_errors.SzamlazzError(`A(z) ${result.number} bizonylat nem lett sztornózva: a Számlázz.hu az eredeti bizonylatot adta vissza.`, {
|
|
1136
768
|
category: "validation",
|
|
1137
769
|
action: response.action,
|
|
@@ -1171,15 +803,15 @@ function resolveIdentifier(input) {
|
|
|
1171
803
|
function buildGetReceiptXml(credentials, input) {
|
|
1172
804
|
const normalized = normalizeInput$1(input);
|
|
1173
805
|
const { receiptNumber, orderNumber } = resolveIdentifier(normalized);
|
|
1174
|
-
return
|
|
806
|
+
return require_serialize.buildXmlDocument({
|
|
1175
807
|
root: "xmlnyugtaget",
|
|
1176
808
|
namespace: GET_RECEIPT_NAMESPACE,
|
|
1177
809
|
schemaLocation: `${require_issue.RECEIPT_XSD_BASE_URL}nyugtaget/xmlnyugtaget.xsd`,
|
|
1178
|
-
children: [
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
810
|
+
children: [require_serialize.el("beallitasok", [...credentials, require_serialize.el("pdfLetoltes", normalized.downloadPdf ?? true)]), require_serialize.el("fejlec", [
|
|
811
|
+
require_serialize.optionalEl("nyugtaszam", receiptNumber),
|
|
812
|
+
require_serialize.optionalEl("rendelesSzam", orderNumber),
|
|
813
|
+
require_serialize.optionalEl("hivasAzonosito", require_issue.optionalText(normalized.callId)),
|
|
814
|
+
require_serialize.optionalEl("pdfSablon", require_issue.validateTemplate(normalized.template))
|
|
1183
815
|
])]
|
|
1184
816
|
});
|
|
1185
817
|
}
|
|
@@ -1190,7 +822,7 @@ function getReceipt(ctx, input, options = {}) {
|
|
|
1190
822
|
xml,
|
|
1191
823
|
signal: options.signal,
|
|
1192
824
|
safeToRetry: true
|
|
1193
|
-
},
|
|
825
|
+
}, require_parse.parseReceiptResponse);
|
|
1194
826
|
}
|
|
1195
827
|
//#endregion
|
|
1196
828
|
//#region src/receipts/reverse.ts
|
|
@@ -1200,14 +832,14 @@ function normalizeInput(input) {
|
|
|
1200
832
|
}
|
|
1201
833
|
function buildReverseReceiptXml(credentials, input) {
|
|
1202
834
|
const normalized = normalizeInput(input);
|
|
1203
|
-
return
|
|
835
|
+
return require_serialize.buildXmlDocument({
|
|
1204
836
|
root: "xmlnyugtast",
|
|
1205
837
|
namespace: REVERSE_RECEIPT_NAMESPACE,
|
|
1206
838
|
schemaLocation: `${require_issue.RECEIPT_XSD_BASE_URL}nyugtast/xmlnyugtast.xsd`,
|
|
1207
|
-
children: [
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
839
|
+
children: [require_serialize.el("beallitasok", [...credentials, require_serialize.el("pdfLetoltes", normalized.downloadPdf ?? true)]), require_serialize.el("fejlec", [
|
|
840
|
+
require_serialize.el("nyugtaszam", require_issue.requireReceiptNumber(normalized.receiptNumber)),
|
|
841
|
+
require_serialize.optionalEl("pdfSablon", require_issue.validateTemplate(normalized.template)),
|
|
842
|
+
require_serialize.optionalEl("hivasAzonosito", require_issue.optionalText(normalized.callId))
|
|
1211
843
|
])]
|
|
1212
844
|
});
|
|
1213
845
|
}
|
|
@@ -1219,7 +851,7 @@ function reverseReceipt(ctx, input, options = {}) {
|
|
|
1219
851
|
xml,
|
|
1220
852
|
signal: options.signal,
|
|
1221
853
|
safeToRetry: require_issue.optionalText(normalized.callId) !== void 0
|
|
1222
|
-
},
|
|
854
|
+
}, require_parse.parseReceiptResponse);
|
|
1223
855
|
}
|
|
1224
856
|
//#endregion
|
|
1225
857
|
//#region src/receipts/send.ts
|
|
@@ -1242,35 +874,35 @@ function buildSendReceiptXml(credentials, input) {
|
|
|
1242
874
|
const emails = normalizeEmails(input.emails);
|
|
1243
875
|
const replyTo = require_issue.optionalText(input.replyTo);
|
|
1244
876
|
if (replyTo !== void 0) assertEmail(replyTo, "replyTo");
|
|
1245
|
-
return
|
|
877
|
+
return require_serialize.buildXmlDocument({
|
|
1246
878
|
root: "xmlnyugtasend",
|
|
1247
879
|
namespace: SEND_RECEIPT_NAMESPACE,
|
|
1248
880
|
schemaLocation: `${require_issue.RECEIPT_XSD_BASE_URL}nyugtasend/xmlnyugtasend.xsd`,
|
|
1249
881
|
children: [
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
882
|
+
require_serialize.el("beallitasok", credentials),
|
|
883
|
+
require_serialize.el("fejlec", [require_serialize.el("nyugtaszam", receiptNumber)]),
|
|
884
|
+
require_serialize.el("emailKuldes", [
|
|
885
|
+
require_serialize.el("email", emails.join(",")),
|
|
886
|
+
require_serialize.optionalEl("emailReplyto", replyTo),
|
|
887
|
+
require_serialize.el("emailTargy", require_issue.optionalText(input.subject) ?? `Nyugta ${receiptNumber}`),
|
|
888
|
+
require_serialize.optionalEl("emailSzoveg", input.text?.trim() ? input.text : void 0)
|
|
1257
889
|
])
|
|
1258
890
|
]
|
|
1259
891
|
});
|
|
1260
892
|
}
|
|
1261
893
|
function parseSendReceiptResponse(response) {
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
if (!
|
|
1265
|
-
|
|
1266
|
-
if (
|
|
1267
|
-
throw
|
|
894
|
+
require_parse.throwIfHeaderError(response);
|
|
895
|
+
require_parse.throwIfTextError(response);
|
|
896
|
+
if (!require_parse.looksLikeXml(response)) {
|
|
897
|
+
require_parse.throwIfHttpError(response);
|
|
898
|
+
if (require_parse.parseDoneText(response.text())) return;
|
|
899
|
+
throw require_parse.unexpectedResponse(response, "XML választ vártunk a nyugta kiküldésére.");
|
|
1268
900
|
}
|
|
1269
|
-
const root =
|
|
1270
|
-
|
|
1271
|
-
if (
|
|
1272
|
-
|
|
1273
|
-
throw
|
|
901
|
+
const root = require_parse.parseResponseXml(response);
|
|
902
|
+
require_parse.throwIfXmlFailure(root, response);
|
|
903
|
+
if (require_serialize.childBoolean(root, "sikeres") !== true) {
|
|
904
|
+
require_parse.throwIfHttpError(response);
|
|
905
|
+
throw require_parse.unexpectedResponse(response, "A válasz nem jelez sikeres kiküldést.");
|
|
1274
906
|
}
|
|
1275
907
|
}
|
|
1276
908
|
function sendReceipt(ctx, input, options = {}) {
|
|
@@ -1323,24 +955,24 @@ function formatAddress(address) {
|
|
|
1323
955
|
}
|
|
1324
956
|
function readDetailedAddress(element) {
|
|
1325
957
|
return {
|
|
1326
|
-
countryCode:
|
|
1327
|
-
region:
|
|
1328
|
-
postalCode:
|
|
1329
|
-
city:
|
|
1330
|
-
streetName:
|
|
1331
|
-
publicPlaceCategory:
|
|
1332
|
-
number:
|
|
1333
|
-
building:
|
|
1334
|
-
staircase:
|
|
1335
|
-
floor:
|
|
1336
|
-
door:
|
|
1337
|
-
lotNumber:
|
|
958
|
+
countryCode: require_serialize.childText(element, "countryCode"),
|
|
959
|
+
region: require_serialize.childText(element, "region"),
|
|
960
|
+
postalCode: require_serialize.childText(element, "postalCode"),
|
|
961
|
+
city: require_serialize.childText(element, "city"),
|
|
962
|
+
streetName: require_serialize.childText(element, "streetName"),
|
|
963
|
+
publicPlaceCategory: require_serialize.childText(element, "publicPlaceCategory"),
|
|
964
|
+
number: require_serialize.childText(element, "number"),
|
|
965
|
+
building: require_serialize.childText(element, "building"),
|
|
966
|
+
staircase: require_serialize.childText(element, "staircase"),
|
|
967
|
+
floor: require_serialize.childText(element, "floor"),
|
|
968
|
+
door: require_serialize.childText(element, "door"),
|
|
969
|
+
lotNumber: require_serialize.childText(element, "lotNumber")
|
|
1338
970
|
};
|
|
1339
971
|
}
|
|
1340
972
|
function parseTaxpayerAddress(item) {
|
|
1341
|
-
const raw = readDetailedAddress(
|
|
973
|
+
const raw = readDetailedAddress(require_serialize.findChild(item, "taxpayerAddress"));
|
|
1342
974
|
const address = {
|
|
1343
|
-
type:
|
|
975
|
+
type: require_serialize.childText(item, "taxpayerAddressType")?.toUpperCase() ?? "",
|
|
1344
976
|
countryCode: raw.countryCode?.toUpperCase() ?? "",
|
|
1345
977
|
region: toReadableName(raw.region),
|
|
1346
978
|
postalCode: raw.postalCode ?? "",
|
|
@@ -1373,19 +1005,19 @@ function toTaxpayerId(taxNumber) {
|
|
|
1373
1005
|
return digits.slice(0, 8);
|
|
1374
1006
|
}
|
|
1375
1007
|
function buildQueryTaxpayerXml(credentials, taxNumber) {
|
|
1376
|
-
return
|
|
1008
|
+
return require_serialize.buildXmlDocument({
|
|
1377
1009
|
root: "xmltaxpayer",
|
|
1378
1010
|
namespace: TAXPAYER_NAMESPACE,
|
|
1379
1011
|
schemaLocation: TAXPAYER_SCHEMA_LOCATION,
|
|
1380
|
-
children: [
|
|
1012
|
+
children: [require_serialize.el("beallitasok", credentials), require_serialize.el("torzsszam", toTaxpayerId(taxNumber))]
|
|
1381
1013
|
});
|
|
1382
1014
|
}
|
|
1383
1015
|
function throwIfNavError(root, response) {
|
|
1384
|
-
const result =
|
|
1385
|
-
if (
|
|
1386
|
-
const errorCode =
|
|
1016
|
+
const result = require_serialize.findChild(root, "result");
|
|
1017
|
+
if (require_serialize.childText(result, "funcCode")?.toUpperCase() !== "ERROR") return;
|
|
1018
|
+
const errorCode = require_serialize.childText(result, "errorCode");
|
|
1387
1019
|
const code = require_errors.parseErrorCode(errorCode);
|
|
1388
|
-
const message =
|
|
1020
|
+
const message = require_serialize.childText(result, "message");
|
|
1389
1021
|
const textCode = code === void 0 ? errorCode : void 0;
|
|
1390
1022
|
throw require_errors.createAgentError({
|
|
1391
1023
|
code,
|
|
@@ -1396,11 +1028,11 @@ function throwIfNavError(root, response) {
|
|
|
1396
1028
|
});
|
|
1397
1029
|
}
|
|
1398
1030
|
function readTaxNumber(data) {
|
|
1399
|
-
const detail =
|
|
1400
|
-
const taxpayerId =
|
|
1031
|
+
const detail = require_serialize.findChild(data, "taxNumberDetail");
|
|
1032
|
+
const taxpayerId = require_serialize.childText(detail, "taxpayerId");
|
|
1401
1033
|
if (taxpayerId === void 0) return void 0;
|
|
1402
|
-
const vatCode =
|
|
1403
|
-
const countyCode =
|
|
1034
|
+
const vatCode = require_serialize.childText(detail, "vatCode");
|
|
1035
|
+
const countyCode = require_serialize.childText(detail, "countyCode");
|
|
1404
1036
|
return {
|
|
1405
1037
|
taxpayerId,
|
|
1406
1038
|
vatCode,
|
|
@@ -1409,22 +1041,22 @@ function readTaxNumber(data) {
|
|
|
1409
1041
|
};
|
|
1410
1042
|
}
|
|
1411
1043
|
function readAddresses(data) {
|
|
1412
|
-
return
|
|
1044
|
+
return require_serialize.findChildren(require_serialize.findChild(data, "taxpayerAddressList"), "taxpayerAddressItem").map(parseTaxpayerAddress);
|
|
1413
1045
|
}
|
|
1414
1046
|
function readRequestId(root) {
|
|
1415
|
-
const requestId =
|
|
1047
|
+
const requestId = require_serialize.childText(require_serialize.findChild(root, "header"), "requestId");
|
|
1416
1048
|
return requestId === "-" ? void 0 : requestId;
|
|
1417
1049
|
}
|
|
1418
1050
|
function parseQueryTaxpayerResponse(response) {
|
|
1419
|
-
|
|
1420
|
-
const root =
|
|
1421
|
-
|
|
1422
|
-
if (root.name !== "QueryTaxpayerResponse") throw
|
|
1051
|
+
require_parse.throwIfAnyError(response);
|
|
1052
|
+
const root = require_parse.parseResponseXml(response);
|
|
1053
|
+
require_parse.throwIfXmlFailure(root, response);
|
|
1054
|
+
if (root.name !== "QueryTaxpayerResponse") throw require_parse.unexpectedResponse(response, "QueryTaxpayerResponse XML választ vártunk.");
|
|
1423
1055
|
throwIfNavError(root, response);
|
|
1424
1056
|
const requestId = readRequestId(root);
|
|
1425
|
-
const infoDate =
|
|
1426
|
-
const data =
|
|
1427
|
-
const validity =
|
|
1057
|
+
const infoDate = require_serialize.childText(root, "infoDate");
|
|
1058
|
+
const data = require_serialize.findChild(root, "taxpayerData");
|
|
1059
|
+
const validity = require_serialize.childBoolean(root, "taxpayerValidity");
|
|
1428
1060
|
if (validity === false || data === void 0) return {
|
|
1429
1061
|
valid: validity === true,
|
|
1430
1062
|
addresses: [],
|
|
@@ -1434,13 +1066,13 @@ function parseQueryTaxpayerResponse(response) {
|
|
|
1434
1066
|
const addresses = readAddresses(data);
|
|
1435
1067
|
return {
|
|
1436
1068
|
valid: true,
|
|
1437
|
-
name:
|
|
1438
|
-
shortName:
|
|
1069
|
+
name: require_serialize.childText(data, "taxpayerName"),
|
|
1070
|
+
shortName: require_serialize.childText(data, "taxpayerShortName"),
|
|
1439
1071
|
taxNumber: readTaxNumber(data),
|
|
1440
1072
|
address: addresses.find((address) => address.type === "HQ") ?? addresses[0],
|
|
1441
1073
|
addresses,
|
|
1442
|
-
incorporation:
|
|
1443
|
-
vatGroupMembership:
|
|
1074
|
+
incorporation: require_serialize.childText(data, "incorporation"),
|
|
1075
|
+
vatGroupMembership: require_serialize.childText(data, "vatGroupMembership"),
|
|
1444
1076
|
infoDate,
|
|
1445
1077
|
requestId
|
|
1446
1078
|
};
|
|
@@ -1524,8 +1156,8 @@ function createInvoicesApi(ctx, defaults, onDocument) {
|
|
|
1524
1156
|
return document;
|
|
1525
1157
|
},
|
|
1526
1158
|
getPdf: (reference, options) => getInvoicePdf(ctx, reference, options),
|
|
1527
|
-
get: (reference, query, options) => getInvoice(ctx, reference, query, options),
|
|
1528
|
-
find: (reference, query, options) => nullIfNotFound(getInvoice(ctx, reference, query, options)),
|
|
1159
|
+
get: (reference, query, options) => require_get.getInvoice(ctx, reference, query, options),
|
|
1160
|
+
find: (reference, query, options) => nullIfNotFound(require_get.getInvoice(ctx, reference, query, options)),
|
|
1529
1161
|
deleteProforma: (reference, options) => deleteProforma(ctx, reference, options)
|
|
1530
1162
|
};
|
|
1531
1163
|
return api;
|
|
@@ -1611,6 +1243,12 @@ Object.defineProperty(exports, "attemptLedgerKey", {
|
|
|
1611
1243
|
return attemptLedgerKey;
|
|
1612
1244
|
}
|
|
1613
1245
|
});
|
|
1246
|
+
Object.defineProperty(exports, "buildCreateInvoiceXml", {
|
|
1247
|
+
enumerable: true,
|
|
1248
|
+
get: function() {
|
|
1249
|
+
return buildCreateInvoiceXml;
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1614
1252
|
Object.defineProperty(exports, "createAgentContext", {
|
|
1615
1253
|
enumerable: true,
|
|
1616
1254
|
get: function() {
|