kassza 0.1.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/LICENSE +21 -0
- package/README.md +150 -0
- package/agents/README.md +59 -0
- package/agents/api.md +206 -0
- package/agents/pitfalls.md +52 -0
- package/agents/recipes.md +217 -0
- package/agents/skills/kassza/SKILL.md +29 -0
- package/assets/logo-wordmark.svg +25 -0
- package/assets/logo.svg +19 -0
- package/dist/binary-B89HM03_.cjs +63 -0
- package/dist/binary-D0M9U2MD.js +34 -0
- package/dist/client-B9kbKKBf.d.cts +748 -0
- package/dist/client-zv4enyq7.d.ts +748 -0
- package/dist/cookie-stores/index.cjs +153 -0
- package/dist/cookie-stores/index.d.cts +63 -0
- package/dist/cookie-stores/index.d.ts +63 -0
- package/dist/cookie-stores/index.js +144 -0
- package/dist/create-BZd6CUO7.cjs +1160 -0
- package/dist/create-DDZaNlOz.js +939 -0
- package/dist/dates-D2XebOIg.js +34 -0
- package/dist/dates-DtHzwNU6.d.cts +7 -0
- package/dist/dates-DtHzwNU6.d.ts +7 -0
- package/dist/dates-PPxH0n5H.cjs +57 -0
- package/dist/errors-B0QJhUW1.cjs +302 -0
- package/dist/errors-DapdV5DK.js +273 -0
- package/dist/index-CYAGCdKJ.d.cts +56 -0
- package/dist/index-CYAGCdKJ.d.ts +56 -0
- package/dist/index.cjs +1406 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1394 -0
- package/dist/ipn/index.cjs +108 -0
- package/dist/ipn/index.d.cts +32 -0
- package/dist/ipn/index.d.ts +32 -0
- package/dist/ipn/index.js +101 -0
- package/dist/money/index.cjs +15 -0
- package/dist/money/index.d.cts +2 -0
- package/dist/money/index.d.ts +2 -0
- package/dist/money/index.js +2 -0
- package/dist/money-C9j7nBNP.js +258 -0
- package/dist/money-DkiGukAw.cjs +335 -0
- package/dist/session-CRGOuz-R.cjs +100 -0
- package/dist/session-Dm_45x8K.d.cts +11 -0
- package/dist/session-Dm_45x8K.d.ts +11 -0
- package/dist/session-OJMLGufT.js +77 -0
- package/dist/shared-CrxlxI8n.cjs +207 -0
- package/dist/shared-D6DLa4b7.js +100 -0
- package/dist/storage/fs.cjs +88 -0
- package/dist/storage/fs.d.cts +13 -0
- package/dist/storage/fs.d.ts +13 -0
- package/dist/storage/fs.js +87 -0
- package/dist/storage/index.cjs +643 -0
- package/dist/storage/index.d.cts +288 -0
- package/dist/storage/index.d.ts +288 -0
- package/dist/storage/index.js +619 -0
- package/dist/testing/index.cjs +409 -0
- package/dist/testing/index.d.cts +35 -0
- package/dist/testing/index.d.ts +35 -0
- package/dist/testing/index.js +407 -0
- package/dist/types-DVRgwcqg.d.cts +26 -0
- package/dist/types-DVRgwcqg.d.ts +26 -0
- package/dist/validators/index.cjs +296 -0
- package/dist/validators/index.d.cts +51 -0
- package/dist/validators/index.d.ts +51 -0
- package/dist/validators/index.js +278 -0
- package/llms.txt +16 -0
- package/package.json +151 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1406 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_create = require("./create-BZd6CUO7.cjs");
|
|
3
|
+
const require_errors = require("./errors-B0QJhUW1.cjs");
|
|
4
|
+
const require_binary = require("./binary-B89HM03_.cjs");
|
|
5
|
+
const require_session = require("./session-CRGOuz-R.cjs");
|
|
6
|
+
const require_dates = require("./dates-PPxH0n5H.cjs");
|
|
7
|
+
const require_money = require("./money-DkiGukAw.cjs");
|
|
8
|
+
const DEFAULT_SAFE_ATTEMPTS = 3;
|
|
9
|
+
const DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
10
|
+
function readEnv(name) {
|
|
11
|
+
const value = (globalThis.process?.env)?.[name]?.trim();
|
|
12
|
+
return value ? value : void 0;
|
|
13
|
+
}
|
|
14
|
+
function configurationError(message) {
|
|
15
|
+
return new require_errors.SzamlazzError(message, { category: "configuration" });
|
|
16
|
+
}
|
|
17
|
+
function resolveCredentials(options) {
|
|
18
|
+
const agentKey = options.agentKey?.trim() || (options.username ? void 0 : readEnv("SZAMLAZZ_AGENT_KEY"));
|
|
19
|
+
if (agentKey) {
|
|
20
|
+
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.");
|
|
21
|
+
return [require_create.el("szamlaagentkulcs", agentKey)];
|
|
22
|
+
}
|
|
23
|
+
if (options.username && options.password) return [require_create.el("felhasznalo", options.username), require_create.el("jelszo", options.password)];
|
|
24
|
+
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.");
|
|
25
|
+
}
|
|
26
|
+
function toBlob(attachment) {
|
|
27
|
+
const type = attachment.contentType ?? "application/octet-stream";
|
|
28
|
+
if (attachment.content instanceof Blob) return attachment.content;
|
|
29
|
+
return new Blob([attachment.content], { type });
|
|
30
|
+
}
|
|
31
|
+
function buildFormData(request) {
|
|
32
|
+
const form = new FormData();
|
|
33
|
+
form.append(require_create.AGENT_ACTIONS[request.action], new Blob([request.xml], { type: "text/xml; charset=UTF-8" }), "request.xml");
|
|
34
|
+
request.attachments?.forEach((attachment, index) => {
|
|
35
|
+
form.append(`attachfile${index + 1}`, toBlob(attachment), attachment.filename);
|
|
36
|
+
});
|
|
37
|
+
return form;
|
|
38
|
+
}
|
|
39
|
+
function isAbortError(error) {
|
|
40
|
+
return error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
41
|
+
}
|
|
42
|
+
function sleep(ms, signal) {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
if (signal?.aborted) {
|
|
45
|
+
reject(signal.reason);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const timer = setTimeout(() => {
|
|
49
|
+
signal?.removeEventListener("abort", onAbort);
|
|
50
|
+
resolve();
|
|
51
|
+
}, ms);
|
|
52
|
+
const onAbort = () => {
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
reject(signal?.reason);
|
|
55
|
+
};
|
|
56
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async function ignoreStoreFailure(operation) {
|
|
60
|
+
try {
|
|
61
|
+
return await operation();
|
|
62
|
+
} catch {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function clampAttempts(value) {
|
|
67
|
+
if (value === void 0) return DEFAULT_SAFE_ATTEMPTS;
|
|
68
|
+
if (!Number.isInteger(value) || value < 1) throw configurationError(`A maxAttempts értéke legalább 1 egész szám legyen, kapott: ${value}`);
|
|
69
|
+
return Math.min(value, 5);
|
|
70
|
+
}
|
|
71
|
+
function createAgentContext(options = {}) {
|
|
72
|
+
const credentials = resolveCredentials(options);
|
|
73
|
+
const endpoint = options.endpoint ?? "https://www.szamlazz.hu/szamla/";
|
|
74
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
75
|
+
if (typeof fetchImpl !== "function") throw configurationError("Nem található fetch implementáció. Add meg a fetch opciót.");
|
|
76
|
+
const timeoutMs = options.timeoutMs ?? 6e4;
|
|
77
|
+
const safeAttempts = clampAttempts(options.maxAttempts);
|
|
78
|
+
const retryDelayMs = options.retryDelayMs ?? DEFAULT_RETRY_DELAY_MS;
|
|
79
|
+
const cookieStore = options.cookieStore === false ? void 0 : options.cookieStore ?? require_session.memoryCookieStore();
|
|
80
|
+
const sessionKey = require_session.sessionKeyFor(credentials.map((node) => String(node.content)).join("|"));
|
|
81
|
+
const hooks = options.hooks ?? {};
|
|
82
|
+
async function send(request) {
|
|
83
|
+
const cookie = cookieStore ? await ignoreStoreFailure(() => cookieStore.get(sessionKey)) : void 0;
|
|
84
|
+
request.signal?.throwIfAborted();
|
|
85
|
+
const headers = new Headers({ Accept: "application/xml, application/pdf, text/plain, */*" });
|
|
86
|
+
if (cookie) headers.set("Cookie", cookie);
|
|
87
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
88
|
+
const signal = request.signal ? AbortSignal.any([request.signal, timeoutSignal]) : timeoutSignal;
|
|
89
|
+
let response;
|
|
90
|
+
try {
|
|
91
|
+
response = await fetchImpl(endpoint, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers,
|
|
94
|
+
body: buildFormData(request),
|
|
95
|
+
signal
|
|
96
|
+
});
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (request.signal?.aborted) throw request.signal.reason;
|
|
99
|
+
if (timeoutSignal.aborted || isAbortError(error)) throw new require_errors.SzamlazzError(`A Számlázz.hu nem válaszolt ${timeoutMs} ms alatt.`, {
|
|
100
|
+
category: "timeout",
|
|
101
|
+
action: request.action,
|
|
102
|
+
cause: error
|
|
103
|
+
});
|
|
104
|
+
throw new require_errors.SzamlazzError("Hálózati hiba a Számlázz.hu elérésekor.", {
|
|
105
|
+
category: "network",
|
|
106
|
+
action: request.action,
|
|
107
|
+
cause: error
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const body = new Uint8Array(await response.arrayBuffer());
|
|
111
|
+
if (cookieStore) {
|
|
112
|
+
const merged = require_session.mergeSetCookies(cookie, response.headers);
|
|
113
|
+
if (merged) await ignoreStoreFailure(() => cookieStore.set(sessionKey, merged, require_session.SESSION_TTL_SECONDS));
|
|
114
|
+
}
|
|
115
|
+
return require_create.createAgentResponse(request.action, response.status, response.headers, body);
|
|
116
|
+
}
|
|
117
|
+
async function resetSession() {
|
|
118
|
+
if (cookieStore) await ignoreStoreFailure(() => cookieStore.delete(sessionKey));
|
|
119
|
+
}
|
|
120
|
+
async function execute(request, parse) {
|
|
121
|
+
const maxAttempts = request.safeToRetry ? safeAttempts : 1;
|
|
122
|
+
for (let attempt = 1;; attempt++) {
|
|
123
|
+
const startedAt = Date.now();
|
|
124
|
+
hooks.onRequest?.({
|
|
125
|
+
action: request.action,
|
|
126
|
+
attempt
|
|
127
|
+
});
|
|
128
|
+
try {
|
|
129
|
+
const response = await send(request);
|
|
130
|
+
hooks.onResponse?.({
|
|
131
|
+
action: request.action,
|
|
132
|
+
attempt,
|
|
133
|
+
status: response.status,
|
|
134
|
+
durationMs: Date.now() - startedAt
|
|
135
|
+
});
|
|
136
|
+
return await parse(response);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (!(error instanceof require_errors.SzamlazzError)) throw error;
|
|
139
|
+
const willRetry = error.retryable && attempt < maxAttempts;
|
|
140
|
+
hooks.onError?.({
|
|
141
|
+
action: request.action,
|
|
142
|
+
attempt,
|
|
143
|
+
error,
|
|
144
|
+
willRetry
|
|
145
|
+
});
|
|
146
|
+
if (error.category === "auth") await resetSession();
|
|
147
|
+
if (!willRetry) throw error;
|
|
148
|
+
await sleep(retryDelayMs * 2 ** (attempt - 1), request.signal);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
credentials,
|
|
154
|
+
execute,
|
|
155
|
+
resetSession
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/invoices/create-response.ts
|
|
160
|
+
function readRawResponse(response) {
|
|
161
|
+
require_create.throwIfAnyError(response);
|
|
162
|
+
const headers = require_create.readDocumentHeaders(response.headers);
|
|
163
|
+
const fromHeaders = {
|
|
164
|
+
number: headers.number,
|
|
165
|
+
netTotal: headers.netTotal,
|
|
166
|
+
grossTotal: headers.grossTotal,
|
|
167
|
+
outstanding: void 0,
|
|
168
|
+
buyerAccountUrl: headers.buyerAccountUrl,
|
|
169
|
+
pdf: void 0
|
|
170
|
+
};
|
|
171
|
+
if (response.isPdf) return {
|
|
172
|
+
...fromHeaders,
|
|
173
|
+
pdf: response.body
|
|
174
|
+
};
|
|
175
|
+
if (require_create.looksLikeXml(response)) {
|
|
176
|
+
const root = require_create.parseResponseXml(response);
|
|
177
|
+
require_create.throwIfXmlFailure(root, response);
|
|
178
|
+
const pdfBase64 = require_create.childText(root, "pdf");
|
|
179
|
+
return {
|
|
180
|
+
number: require_create.childText(root, "szamlaszam") ?? headers.number,
|
|
181
|
+
netTotal: require_create.childNumber(root, "szamlanetto") ?? headers.netTotal,
|
|
182
|
+
grossTotal: require_create.childNumber(root, "szamlabrutto") ?? headers.grossTotal,
|
|
183
|
+
outstanding: require_create.childNumber(root, "kintlevoseg"),
|
|
184
|
+
buyerAccountUrl: require_create.childText(root, "vevoifiokurl") ?? headers.buyerAccountUrl,
|
|
185
|
+
pdf: pdfBase64 === void 0 ? void 0 : require_binary.base64ToBytes(pdfBase64)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const done = require_create.parseDoneText(response.text());
|
|
189
|
+
if (done) return {
|
|
190
|
+
...fromHeaders,
|
|
191
|
+
number: done.number ?? headers.number
|
|
192
|
+
};
|
|
193
|
+
if (headers.number !== void 0) return fromHeaders;
|
|
194
|
+
throw require_create.unexpectedResponse(response, "Számlaszámot vagy PDF-et vártunk.");
|
|
195
|
+
}
|
|
196
|
+
function totalsFor(raw, items) {
|
|
197
|
+
if (raw.netTotal !== void 0 && raw.grossTotal !== void 0) return {
|
|
198
|
+
netTotal: raw.netTotal,
|
|
199
|
+
grossTotal: raw.grossTotal
|
|
200
|
+
};
|
|
201
|
+
const computed = require_money.summarizeItems(items);
|
|
202
|
+
return {
|
|
203
|
+
netTotal: raw.netTotal ?? computed.netAmount,
|
|
204
|
+
grossTotal: raw.grossTotal ?? computed.grossAmount
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function parseCreateInvoiceResponse(response, items = []) {
|
|
208
|
+
const raw = readRawResponse(response);
|
|
209
|
+
if (raw.number === void 0) throw require_create.unexpectedResponse(response, "A sikeres válaszból hiányzik a számlaszám.");
|
|
210
|
+
return {
|
|
211
|
+
number: raw.number,
|
|
212
|
+
...totalsFor(raw, items),
|
|
213
|
+
outstanding: raw.outstanding,
|
|
214
|
+
buyerAccountUrl: raw.buyerAccountUrl,
|
|
215
|
+
pdf: raw.pdf,
|
|
216
|
+
items
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function parseInvoicePreviewResponse(response, items = []) {
|
|
220
|
+
const raw = readRawResponse(response);
|
|
221
|
+
if (raw.pdf === void 0) throw require_create.unexpectedResponse(response, "Az előnézeti válaszból hiányzik a PDF.");
|
|
222
|
+
return {
|
|
223
|
+
pdf: raw.pdf,
|
|
224
|
+
...totalsFor(raw, items),
|
|
225
|
+
items
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/invoices/create-xml.ts
|
|
230
|
+
const INVOICE_XML_NAMESPACE = "http://www.szamlazz.hu/xmlszamla";
|
|
231
|
+
const INVOICE_XML_SCHEMA_LOCATION = "https://www.szamlazz.hu/szamla/docs/xsds/agent/xmlszamla.xsd";
|
|
232
|
+
const RESPONSE_VERSION_XML = 2;
|
|
233
|
+
function textEl(name, value) {
|
|
234
|
+
return require_create.optionalEl(name, require_create.presentText(value));
|
|
235
|
+
}
|
|
236
|
+
function settingsNode(credentials, invoice, preview) {
|
|
237
|
+
return require_create.el("beallitasok", [
|
|
238
|
+
...credentials,
|
|
239
|
+
require_create.el("eszamla", invoice.eInvoice),
|
|
240
|
+
require_create.el("szamlaLetoltes", preview || invoice.downloadPdf),
|
|
241
|
+
require_create.el("valaszVerzio", RESPONSE_VERSION_XML),
|
|
242
|
+
textEl("aggregator", invoice.aggregator),
|
|
243
|
+
require_create.optionalEl("guardian", invoice.guardian),
|
|
244
|
+
require_create.optionalEl("cikkazoninvoice", invoice.articleIdentifierInvoice),
|
|
245
|
+
textEl("szamlaKulsoAzon", invoice.input.externalId)
|
|
246
|
+
]);
|
|
247
|
+
}
|
|
248
|
+
function documentTypeNodes(invoice) {
|
|
249
|
+
const { input, type } = invoice;
|
|
250
|
+
return [
|
|
251
|
+
type === "advance" && require_create.el("elolegszamla", true),
|
|
252
|
+
type === "final" && require_create.el("vegszamla", true),
|
|
253
|
+
input.type === "final" && textEl("elolegSzamlaszam", input.advanceInvoiceNumber),
|
|
254
|
+
type === "corrective" && require_create.el("helyesbitoszamla", true),
|
|
255
|
+
input.type === "corrective" && textEl("helyesbitettSzamlaszam", input.correctedInvoiceNumber),
|
|
256
|
+
type === "proforma" && require_create.el("dijbekero", true),
|
|
257
|
+
type === "deliveryNote" && require_create.el("szallitolevel", true)
|
|
258
|
+
];
|
|
259
|
+
}
|
|
260
|
+
function headerNode(invoice, preview) {
|
|
261
|
+
const { input } = invoice;
|
|
262
|
+
return require_create.el("fejlec", [
|
|
263
|
+
require_create.el("keltDatum", invoice.issueDate),
|
|
264
|
+
require_create.el("teljesitesDatum", invoice.fulfillmentDate),
|
|
265
|
+
require_create.el("fizetesiHataridoDatum", invoice.dueDate),
|
|
266
|
+
require_create.el("fizmod", invoice.paymentMethod),
|
|
267
|
+
require_create.el("penznem", invoice.currency),
|
|
268
|
+
require_create.el("szamlaNyelve", invoice.language),
|
|
269
|
+
textEl("megjegyzes", input.comment),
|
|
270
|
+
textEl("arfolyamBank", invoice.exchangeBank),
|
|
271
|
+
require_create.optionalEl("arfolyam", invoice.exchangeRate),
|
|
272
|
+
textEl("rendelesSzam", input.orderNumber),
|
|
273
|
+
textEl("dijbekeroSzamlaszam", input.proformaNumber),
|
|
274
|
+
...documentTypeNodes(invoice),
|
|
275
|
+
textEl("logoExtra", invoice.logoExtra),
|
|
276
|
+
textEl("szamlaszamElotag", invoice.prefix),
|
|
277
|
+
require_create.optionalEl("fizetendoKorrekcio", input.paymentCorrection),
|
|
278
|
+
require_create.optionalEl("fizetve", input.paid),
|
|
279
|
+
require_create.optionalEl("arresAfa", input.marginVat),
|
|
280
|
+
require_create.optionalEl("eusAfa", invoice.euVat),
|
|
281
|
+
require_create.optionalEl("szamlaSablon", invoice.template),
|
|
282
|
+
preview && require_create.el("elonezetpdf", true),
|
|
283
|
+
require_create.optionalEl("simpleItems", invoice.simpleItems)
|
|
284
|
+
]);
|
|
285
|
+
}
|
|
286
|
+
function sellerNode(seller) {
|
|
287
|
+
return require_create.el("elado", [
|
|
288
|
+
textEl("bank", seller.bank),
|
|
289
|
+
textEl("bankszamlaszam", seller.bankAccount),
|
|
290
|
+
textEl("emailReplyto", seller.emailReplyTo),
|
|
291
|
+
textEl("emailTargy", seller.emailSubject),
|
|
292
|
+
textEl("emailSzoveg", seller.emailText),
|
|
293
|
+
textEl("alairoNeve", seller.signatoryName)
|
|
294
|
+
]);
|
|
295
|
+
}
|
|
296
|
+
function buyerLedgerNode(ledger) {
|
|
297
|
+
if (!ledger) return void 0;
|
|
298
|
+
return require_create.optionalEl("vevoFokonyv", [
|
|
299
|
+
require_create.optionalEl("konyvelesDatum", require_create.optionalAgentDate(ledger.bookingDate, "buyer.ledger.bookingDate")),
|
|
300
|
+
textEl("vevoAzonosito", ledger.buyerId),
|
|
301
|
+
textEl("vevoFokonyviSzam", ledger.ledgerAccount),
|
|
302
|
+
require_create.optionalEl("folyamatosTelj", ledger.continuousFulfillment),
|
|
303
|
+
require_create.optionalEl("elszDatumTol", require_create.optionalAgentDate(ledger.settlementPeriodStart, "buyer.ledger.settlementPeriodStart")),
|
|
304
|
+
require_create.optionalEl("elszDatumIg", require_create.optionalAgentDate(ledger.settlementPeriodEnd, "buyer.ledger.settlementPeriodEnd"))
|
|
305
|
+
]);
|
|
306
|
+
}
|
|
307
|
+
function buyerNode(buyer, sendEmail) {
|
|
308
|
+
const taxpayerType = buyer.taxpayerType;
|
|
309
|
+
return require_create.el("vevo", [
|
|
310
|
+
require_create.el("nev", buyer.name),
|
|
311
|
+
textEl("orszag", buyer.country),
|
|
312
|
+
require_create.el("irsz", buyer.zip),
|
|
313
|
+
require_create.el("telepules", buyer.city),
|
|
314
|
+
require_create.el("cim", buyer.address),
|
|
315
|
+
textEl("email", buyer.email),
|
|
316
|
+
require_create.el("sendEmail", sendEmail),
|
|
317
|
+
require_create.optionalEl("adoalany", taxpayerType === void 0 ? void 0 : require_create.TAXPAYER_TYPE_CODES[taxpayerType]),
|
|
318
|
+
textEl("adoszam", buyer.taxNumber),
|
|
319
|
+
textEl("csoportazonosito", buyer.groupTaxNumber),
|
|
320
|
+
textEl("adoszamEU", buyer.euTaxNumber),
|
|
321
|
+
textEl("postazasiNev", buyer.postal?.name),
|
|
322
|
+
textEl("postazasiOrszag", buyer.postal?.country),
|
|
323
|
+
textEl("postazasiIrsz", buyer.postal?.zip),
|
|
324
|
+
textEl("postazasiTelepules", buyer.postal?.city),
|
|
325
|
+
textEl("postazasiCim", buyer.postal?.address),
|
|
326
|
+
buyerLedgerNode(buyer.ledger),
|
|
327
|
+
textEl("azonosito", buyer.identifier),
|
|
328
|
+
textEl("alairoNeve", buyer.signatoryName),
|
|
329
|
+
textEl("telefonszam", buyer.phone),
|
|
330
|
+
textEl("megjegyzes", buyer.comment)
|
|
331
|
+
]);
|
|
332
|
+
}
|
|
333
|
+
function waybillNode(waybill) {
|
|
334
|
+
if (!waybill) return void 0;
|
|
335
|
+
const { transOFlex: tof, pickPackPoint: ppp, sprinter, mpl } = waybill;
|
|
336
|
+
return require_create.el("fuvarlevel", [
|
|
337
|
+
textEl("futarSzolgalat", waybill.courier),
|
|
338
|
+
textEl("vonalkod", waybill.barcode),
|
|
339
|
+
textEl("megjegyzes", waybill.comment),
|
|
340
|
+
tof && require_create.el("tof", [
|
|
341
|
+
textEl("azonosito", tof.id),
|
|
342
|
+
textEl("shipmentID", tof.shipmentId),
|
|
343
|
+
require_create.optionalEl("csomagszam", tof.packageCount),
|
|
344
|
+
textEl("countryCode", tof.countryCode),
|
|
345
|
+
textEl("zip", tof.zip),
|
|
346
|
+
textEl("service", tof.service)
|
|
347
|
+
]),
|
|
348
|
+
ppp && require_create.el("ppp", [textEl("vonalkodPrefix", ppp.barcodePrefix), textEl("vonalkodPostfix", ppp.barcodePostfix)]),
|
|
349
|
+
sprinter && require_create.el("sprinter", [
|
|
350
|
+
textEl("azonosito", sprinter.id),
|
|
351
|
+
textEl("feladokod", sprinter.senderCode),
|
|
352
|
+
textEl("iranykod", sprinter.directionCode),
|
|
353
|
+
require_create.optionalEl("csomagszam", sprinter.packageCount),
|
|
354
|
+
textEl("vonalkodPostfix", sprinter.barcodePostfix),
|
|
355
|
+
textEl("szallitasiIdo", sprinter.deliveryTime)
|
|
356
|
+
]),
|
|
357
|
+
mpl && require_create.el("mpl", [
|
|
358
|
+
require_create.el("vevokod", mpl.customerCode),
|
|
359
|
+
require_create.el("vonalkod", mpl.barcode),
|
|
360
|
+
require_create.el("tomeg", String(mpl.weight)),
|
|
361
|
+
textEl("kulonszolgaltatasok", mpl.services),
|
|
362
|
+
require_create.optionalEl("erteknyilvanitas", mpl.declaredValue)
|
|
363
|
+
])
|
|
364
|
+
]);
|
|
365
|
+
}
|
|
366
|
+
function itemLedgerNode(ledger, label) {
|
|
367
|
+
if (!ledger) return void 0;
|
|
368
|
+
return require_create.optionalEl("tetelFokonyv", [
|
|
369
|
+
textEl("gazdasagiEsem", ledger.economicEvent),
|
|
370
|
+
textEl("gazdasagiEsemAfa", ledger.vatEconomicEvent),
|
|
371
|
+
textEl("arbevetelFokonyviSzam", ledger.revenueLedgerAccount),
|
|
372
|
+
textEl("afaFokonyviSzam", ledger.vatLedgerAccount),
|
|
373
|
+
require_create.optionalEl("elszDatumTol", require_create.optionalAgentDate(ledger.settlementPeriodStart, `${label} settlementPeriodStart`)),
|
|
374
|
+
require_create.optionalEl("elszDatumIg", require_create.optionalAgentDate(ledger.settlementPeriodEnd, `${label} settlementPeriodEnd`))
|
|
375
|
+
]);
|
|
376
|
+
}
|
|
377
|
+
function itemNode(item, index) {
|
|
378
|
+
const { input, amounts } = item;
|
|
379
|
+
return require_create.el("tetel", [
|
|
380
|
+
require_create.el("megnevezes", input.name),
|
|
381
|
+
textEl("azonosito", input.identifier),
|
|
382
|
+
require_create.el("mennyiseg", amounts.quantity),
|
|
383
|
+
require_create.el("mennyisegiEgyseg", item.unit),
|
|
384
|
+
require_create.el("nettoEgysegar", amounts.netUnitPrice),
|
|
385
|
+
require_create.el("afakulcs", require_money.formatVatRate(amounts.vat)),
|
|
386
|
+
require_create.optionalEl("arresAfaAlap", input.marginVatBase),
|
|
387
|
+
require_create.el("nettoErtek", amounts.netAmount),
|
|
388
|
+
require_create.el("afaErtek", amounts.vatAmount),
|
|
389
|
+
require_create.el("bruttoErtek", amounts.grossAmount),
|
|
390
|
+
textEl("megjegyzes", input.comment),
|
|
391
|
+
itemLedgerNode(input.ledger, `${index + 1}. tétel ledger`),
|
|
392
|
+
require_create.optionalEl("torloKod", input.dataDeletionCode)
|
|
393
|
+
]);
|
|
394
|
+
}
|
|
395
|
+
function renderInvoiceXml(credentials, invoice, options = {}) {
|
|
396
|
+
const preview = options.preview === true;
|
|
397
|
+
return require_create.buildXmlDocument({
|
|
398
|
+
root: "xmlszamla",
|
|
399
|
+
namespace: INVOICE_XML_NAMESPACE,
|
|
400
|
+
schemaLocation: INVOICE_XML_SCHEMA_LOCATION,
|
|
401
|
+
children: [
|
|
402
|
+
settingsNode(credentials, invoice, preview),
|
|
403
|
+
headerNode(invoice, preview),
|
|
404
|
+
sellerNode(invoice.seller),
|
|
405
|
+
buyerNode(invoice.input.buyer, invoice.sendEmail),
|
|
406
|
+
waybillNode(invoice.input.waybill),
|
|
407
|
+
require_create.el("tetelek", invoice.items.map(itemNode))
|
|
408
|
+
]
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
//#endregion
|
|
412
|
+
//#region src/invoices/create.ts
|
|
413
|
+
function buildRequest(ctx, invoice, preview, options) {
|
|
414
|
+
const xml = renderInvoiceXml(ctx.credentials, invoice, { preview });
|
|
415
|
+
const attachments = preview ? [] : invoice.attachments;
|
|
416
|
+
return {
|
|
417
|
+
action: "createInvoice",
|
|
418
|
+
xml,
|
|
419
|
+
signal: options.signal,
|
|
420
|
+
...attachments.length > 0 ? { attachments } : {}
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
function itemsOf(invoice) {
|
|
424
|
+
return invoice.items.map((item) => item.amounts);
|
|
425
|
+
}
|
|
426
|
+
async function createInvoice(ctx, defaults, input, options = {}) {
|
|
427
|
+
const invoice = require_create.resolveInvoice(defaults, input, /* @__PURE__ */ new Date());
|
|
428
|
+
const items = itemsOf(invoice);
|
|
429
|
+
return ctx.execute(buildRequest(ctx, invoice, false, options), (response) => parseCreateInvoiceResponse(response, items));
|
|
430
|
+
}
|
|
431
|
+
async function previewInvoice(ctx, defaults, input, options = {}) {
|
|
432
|
+
const invoice = require_create.resolveInvoice(defaults, input, /* @__PURE__ */ new Date());
|
|
433
|
+
const items = itemsOf(invoice);
|
|
434
|
+
return ctx.execute(buildRequest(ctx, invoice, true, options), (response) => parseInvoicePreviewResponse(response, items));
|
|
435
|
+
}
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region src/invoices/reference.ts
|
|
438
|
+
const AGENT_XSD_BASE_URL = "https://www.szamlazz.hu/szamla/docs/xsds/";
|
|
439
|
+
function validationError(message) {
|
|
440
|
+
return new require_errors.SzamlazzError(message, { category: "validation" });
|
|
441
|
+
}
|
|
442
|
+
function requireText(value, message) {
|
|
443
|
+
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
444
|
+
if (trimmed === "") throw validationError(message);
|
|
445
|
+
return trimmed;
|
|
446
|
+
}
|
|
447
|
+
function optionalText(value) {
|
|
448
|
+
const trimmed = value?.trim();
|
|
449
|
+
return trimmed ? trimmed : void 0;
|
|
450
|
+
}
|
|
451
|
+
function agentDate(input, field) {
|
|
452
|
+
try {
|
|
453
|
+
return require_dates.toAgentDate(input);
|
|
454
|
+
} catch (error) {
|
|
455
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
456
|
+
throw new require_errors.SzamlazzError(`Érvénytelen dátum (${field}): ${detail}`, {
|
|
457
|
+
category: "validation",
|
|
458
|
+
cause: error
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
function optionalAgentDate(input, field) {
|
|
463
|
+
return input === void 0 ? void 0 : agentDate(input, field);
|
|
464
|
+
}
|
|
465
|
+
const REFERENCE_KEYS = [
|
|
466
|
+
"invoiceNumber",
|
|
467
|
+
"orderNumber",
|
|
468
|
+
"externalId"
|
|
469
|
+
];
|
|
470
|
+
const REFERENCE_HINT$1 = "Add meg a számlaszámot szövegként, vagy pontosan egyet ezek közül: { invoiceNumber }, { orderNumber }, { externalId }.";
|
|
471
|
+
function resolveInvoiceReference(reference) {
|
|
472
|
+
if (typeof reference === "string") return {
|
|
473
|
+
kind: "invoiceNumber",
|
|
474
|
+
value: requireText(reference, `Üres számlaszám. ${REFERENCE_HINT$1}`)
|
|
475
|
+
};
|
|
476
|
+
if (typeof reference !== "object" || reference === null) throw validationError(`Érvénytelen bizonylat-hivatkozás. ${REFERENCE_HINT$1}`);
|
|
477
|
+
const record = reference;
|
|
478
|
+
const present = REFERENCE_KEYS.filter((key) => record[key] !== void 0);
|
|
479
|
+
const [kind] = present;
|
|
480
|
+
if (kind === void 0 || present.length > 1) throw validationError(`Érvénytelen bizonylat-hivatkozás. ${REFERENCE_HINT$1}`);
|
|
481
|
+
return {
|
|
482
|
+
kind,
|
|
483
|
+
value: requireText(record[kind], `Üres ${kind} érték. ${REFERENCE_HINT$1}`)
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
function referenceValue(reference, kind) {
|
|
487
|
+
return reference.kind === kind ? reference.value : void 0;
|
|
488
|
+
}
|
|
489
|
+
function readNumericHeader(headers, name) {
|
|
490
|
+
const value = require_create.readHeader(headers, name);
|
|
491
|
+
if (value === void 0) return void 0;
|
|
492
|
+
const parsed = Number(value.replace(",", "."));
|
|
493
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
494
|
+
}
|
|
495
|
+
function headerSummary(response) {
|
|
496
|
+
const headers = require_create.readDocumentHeaders(response.headers);
|
|
497
|
+
return {
|
|
498
|
+
number: headers.number,
|
|
499
|
+
netTotal: headers.netTotal,
|
|
500
|
+
grossTotal: headers.grossTotal,
|
|
501
|
+
outstanding: readNumericHeader(response.headers, "szlahu_kintlevoseg"),
|
|
502
|
+
buyerAccountUrl: headers.buyerAccountUrl
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
function decodeResponsePdf(root, response) {
|
|
506
|
+
const encoded = require_create.childText(root, "pdf");
|
|
507
|
+
if (encoded === void 0) return void 0;
|
|
508
|
+
try {
|
|
509
|
+
return require_binary.base64ToBytes(encoded);
|
|
510
|
+
} catch (error) {
|
|
511
|
+
throw new require_errors.SzamlazzError("A válaszban kapott PDF nem érvényes base64.", {
|
|
512
|
+
category: "unexpected_response",
|
|
513
|
+
action: response.action,
|
|
514
|
+
httpStatus: response.status,
|
|
515
|
+
cause: error
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function readInvoiceResultXml(root, response) {
|
|
520
|
+
const headers = headerSummary(response);
|
|
521
|
+
return {
|
|
522
|
+
number: require_create.childText(root, "szamlaszam") ?? headers.number,
|
|
523
|
+
netTotal: require_create.childNumber(root, "szamlanetto") ?? headers.netTotal,
|
|
524
|
+
grossTotal: require_create.childNumber(root, "szamlabrutto") ?? headers.grossTotal,
|
|
525
|
+
outstanding: require_create.childNumber(root, "kintlevoseg") ?? headers.outstanding,
|
|
526
|
+
buyerAccountUrl: require_create.childText(root, "vevoifiokurl") ?? headers.buyerAccountUrl,
|
|
527
|
+
pdf: decodeResponsePdf(root, response)
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
const INVOICE_RESULT_ROOT = "xmlszamlavalasz";
|
|
531
|
+
function parseInvoiceResult(response) {
|
|
532
|
+
require_create.throwIfHeaderError(response);
|
|
533
|
+
if (response.isPdf) return {
|
|
534
|
+
...headerSummary(response),
|
|
535
|
+
pdf: response.body
|
|
536
|
+
};
|
|
537
|
+
require_create.throwIfTextError(response);
|
|
538
|
+
require_create.throwIfHttpError(response);
|
|
539
|
+
if (require_create.looksLikeXml(response)) {
|
|
540
|
+
const root = require_create.parseResponseXml(response);
|
|
541
|
+
require_create.throwIfXmlFailure(root, response);
|
|
542
|
+
if (root.name !== INVOICE_RESULT_ROOT || require_create.childText(root, "sikeres")?.toLowerCase() !== "true") throw require_create.unexpectedResponse(response, `${INVOICE_RESULT_ROOT} XML választ vártunk.`);
|
|
543
|
+
return readInvoiceResultXml(root, response);
|
|
544
|
+
}
|
|
545
|
+
const headers = headerSummary(response);
|
|
546
|
+
const done = require_create.parseDoneText(response.text());
|
|
547
|
+
if (done) return {
|
|
548
|
+
...headers,
|
|
549
|
+
number: done.number ?? headers.number
|
|
550
|
+
};
|
|
551
|
+
if (headers.number !== void 0) return headers;
|
|
552
|
+
throw require_create.unexpectedResponse(response);
|
|
553
|
+
}
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region src/invoices/get.ts
|
|
556
|
+
const INVOICE_DOCUMENT_TYPE_CODES = {
|
|
557
|
+
invoice: "SZ",
|
|
558
|
+
proforma: "D",
|
|
559
|
+
advance: "ES",
|
|
560
|
+
final: "VS",
|
|
561
|
+
corrective: "HS",
|
|
562
|
+
reversal: "SS",
|
|
563
|
+
deliveryNote: "SL"
|
|
564
|
+
};
|
|
565
|
+
function buildGetInvoiceXml(credentials, reference, query = {}) {
|
|
566
|
+
const resolved = resolveInvoiceReference(reference);
|
|
567
|
+
return require_create.buildXmlDocument({
|
|
568
|
+
root: "xmlszamlaxml",
|
|
569
|
+
namespace: "http://www.szamlazz.hu/xmlszamlaxml",
|
|
570
|
+
schemaLocation: `${AGENT_XSD_BASE_URL}agentxml/xmlszamlaxml.xsd`,
|
|
571
|
+
children: [
|
|
572
|
+
...credentials,
|
|
573
|
+
require_create.optionalEl("szamlaszam", referenceValue(resolved, "invoiceNumber")),
|
|
574
|
+
require_create.optionalEl("rendelesSzam", referenceValue(resolved, "orderNumber")),
|
|
575
|
+
require_create.optionalEl("pdf", query.includePdf),
|
|
576
|
+
require_create.optionalEl("szamlaKulsoAzon", referenceValue(resolved, "externalId"))
|
|
577
|
+
]
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
var InvoiceReader = class {
|
|
581
|
+
response;
|
|
582
|
+
constructor(response) {
|
|
583
|
+
this.response = response;
|
|
584
|
+
}
|
|
585
|
+
missing(path) {
|
|
586
|
+
return require_create.unexpectedResponse(this.response, `Hiányzik a(z) <${path}> elem a számla XML-ből.`);
|
|
587
|
+
}
|
|
588
|
+
element(parent, name, path) {
|
|
589
|
+
const child = require_create.findChild(parent, name);
|
|
590
|
+
if (!child) throw this.missing(path);
|
|
591
|
+
return child;
|
|
592
|
+
}
|
|
593
|
+
text(parent, name, path) {
|
|
594
|
+
const value = require_create.childText(parent, name);
|
|
595
|
+
if (value === void 0) throw this.missing(`${path}/${name}`);
|
|
596
|
+
return value;
|
|
597
|
+
}
|
|
598
|
+
number(parent, name, path) {
|
|
599
|
+
const value = require_create.childNumber(parent, name);
|
|
600
|
+
if (value === void 0) throw this.missing(`${path}/${name}`);
|
|
601
|
+
return value;
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
function readAddress(element) {
|
|
605
|
+
if (!element) return void 0;
|
|
606
|
+
return {
|
|
607
|
+
name: require_create.childText(element, "nev"),
|
|
608
|
+
country: require_create.childText(element, "orszag"),
|
|
609
|
+
zip: require_create.childText(element, "irsz"),
|
|
610
|
+
city: require_create.childText(element, "telepules"),
|
|
611
|
+
address: require_create.childText(element, "cim")
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
function readSeller(root, reader) {
|
|
615
|
+
const seller = reader.element(root, "szallito", "szallito");
|
|
616
|
+
const bank = require_create.findChild(seller, "bank");
|
|
617
|
+
return {
|
|
618
|
+
id: require_create.childNumber(seller, "id"),
|
|
619
|
+
name: reader.text(seller, "nev", "szallito"),
|
|
620
|
+
address: readAddress(require_create.findChild(seller, "cim")),
|
|
621
|
+
postalAddress: readAddress(require_create.findChild(seller, "postacim")),
|
|
622
|
+
taxNumber: require_create.childText(seller, "adoszam"),
|
|
623
|
+
groupTaxNumber: require_create.childText(seller, "csoportazonosito"),
|
|
624
|
+
euTaxNumber: require_create.childText(seller, "adoszameu"),
|
|
625
|
+
bank: bank && {
|
|
626
|
+
name: require_create.childText(bank, "nev"),
|
|
627
|
+
accountNumber: require_create.childText(bank, "bankszamla")
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
const DOCUMENT_TYPES_BY_CODE = new Map(Object.entries(INVOICE_DOCUMENT_TYPE_CODES).map(([type, code]) => [code, type]));
|
|
632
|
+
const E_INVOICE_CODES = /* @__PURE__ */ new Set([2, 3]);
|
|
633
|
+
function readHeader(root, reader) {
|
|
634
|
+
const header = reader.element(root, "alap", "alap");
|
|
635
|
+
const typeCode = reader.text(header, "tipus", "alap");
|
|
636
|
+
const appearanceCode = require_create.childNumber(header, "eszamla");
|
|
637
|
+
return {
|
|
638
|
+
id: require_create.childNumber(header, "id"),
|
|
639
|
+
number: reader.text(header, "szamlaszam", "alap"),
|
|
640
|
+
economicEventId: require_create.childNumber(header, "gazdEsemAzon"),
|
|
641
|
+
sourceSystem: require_create.childNumber(header, "forras"),
|
|
642
|
+
registrationNumber: require_create.childText(header, "iktatoszam"),
|
|
643
|
+
type: DOCUMENT_TYPES_BY_CODE.get(typeCode) ?? "unknown",
|
|
644
|
+
typeCode,
|
|
645
|
+
eInvoice: appearanceCode !== void 0 && E_INVOICE_CODES.has(appearanceCode),
|
|
646
|
+
appearanceCode,
|
|
647
|
+
referencedInvoiceNumber: require_create.childText(header, "hivszamlaszam"),
|
|
648
|
+
referencedProformaNumber: require_create.childText(header, "hivdijbekszam"),
|
|
649
|
+
issueDate: reader.text(header, "kelt", "alap"),
|
|
650
|
+
fulfillmentDate: require_create.childText(header, "telj"),
|
|
651
|
+
dueDate: require_create.childText(header, "fizh"),
|
|
652
|
+
paymentMethod: require_create.childText(header, "fizmod"),
|
|
653
|
+
unifiedPaymentMethod: require_create.childText(header, "fizmodunified"),
|
|
654
|
+
cash: require_create.childBoolean(header, "keszpenz"),
|
|
655
|
+
orderNumber: require_create.childText(header, "rendelesszam"),
|
|
656
|
+
language: require_create.childText(header, "nyelv"),
|
|
657
|
+
currency: require_create.childText(header, "devizanem"),
|
|
658
|
+
exchangeBank: require_create.childText(header, "devizabank"),
|
|
659
|
+
exchangeRate: require_create.childNumber(header, "devizaarf"),
|
|
660
|
+
comment: require_create.childText(header, "megjegyzes"),
|
|
661
|
+
vatType: require_create.childText(header, "afatipus"),
|
|
662
|
+
cashAccounting: require_create.childBoolean(header, "penzforg"),
|
|
663
|
+
kata: require_create.childBoolean(header, "kata"),
|
|
664
|
+
kataLedger: require_create.childBoolean(header, "katafokonyv"),
|
|
665
|
+
email: require_create.childText(header, "email"),
|
|
666
|
+
test: require_create.childBoolean(header, "teszt"),
|
|
667
|
+
reversed: require_create.childBoolean(header, "sztornozott")
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
function readBuyerLedger(element) {
|
|
671
|
+
if (!element) return void 0;
|
|
672
|
+
return {
|
|
673
|
+
ledgerAccount: require_create.childText(element, "vevo"),
|
|
674
|
+
buyerId: require_create.childText(element, "vevoazon"),
|
|
675
|
+
bookingDate: require_create.childText(element, "datum"),
|
|
676
|
+
continuousFulfillment: require_create.childBoolean(element, "folyamatostelj"),
|
|
677
|
+
settlementPeriodStart: require_create.childText(element, "elszDatTol") ?? require_create.childText(element, "elszdattol"),
|
|
678
|
+
settlementPeriodEnd: require_create.childText(element, "elszDatIg") ?? require_create.childText(element, "elszdatig")
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
function readBuyer(root, reader) {
|
|
682
|
+
const buyer = reader.element(root, "vevo", "vevo");
|
|
683
|
+
return {
|
|
684
|
+
id: require_create.childNumber(buyer, "id"),
|
|
685
|
+
name: reader.text(buyer, "nev", "vevo"),
|
|
686
|
+
identifier: require_create.childText(buyer, "azonosito"),
|
|
687
|
+
address: readAddress(require_create.findChild(buyer, "cim")),
|
|
688
|
+
postalAddress: readAddress(require_create.findChild(buyer, "postacim")),
|
|
689
|
+
email: require_create.childText(buyer, "email"),
|
|
690
|
+
taxNumber: require_create.childText(buyer, "adoszam"),
|
|
691
|
+
groupTaxNumber: require_create.childText(buyer, "csoportazonosito"),
|
|
692
|
+
euTaxNumber: require_create.childText(buyer, "adoszameu"),
|
|
693
|
+
location: require_create.childNumber(buyer, "lokacio"),
|
|
694
|
+
privatePerson: require_create.childBoolean(buyer, "privatePersonIndicator"),
|
|
695
|
+
ledger: readBuyerLedger(require_create.findChild(buyer, "fokonyv"))
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
function readItemLedger(element) {
|
|
699
|
+
if (!element) return void 0;
|
|
700
|
+
return {
|
|
701
|
+
revenueLedgerAccount: require_create.childText(element, "arbevetel"),
|
|
702
|
+
vatLedgerAccount: require_create.childText(element, "afa"),
|
|
703
|
+
economicEvent: require_create.childText(element, "gazdasagiesemeny"),
|
|
704
|
+
vatEconomicEvent: require_create.childText(element, "gazdasagiesemenyafa"),
|
|
705
|
+
settlementPeriodStart: require_create.childText(element, "elszdattol"),
|
|
706
|
+
settlementPeriodEnd: require_create.childText(element, "elszdatig")
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
function readItem(item, reader) {
|
|
710
|
+
const path = "tetelek/tetel";
|
|
711
|
+
return {
|
|
712
|
+
name: reader.text(item, "nev", path),
|
|
713
|
+
identifier: require_create.childText(item, "azonosito"),
|
|
714
|
+
quantity: reader.number(item, "mennyiseg", path),
|
|
715
|
+
unit: require_create.childText(item, "mennyisegiegyseg"),
|
|
716
|
+
netUnitPrice: reader.number(item, "nettoegysegar", path),
|
|
717
|
+
vat: reader.number(item, "afakulcs", path),
|
|
718
|
+
vatCode: require_create.childText(item, "afatipus"),
|
|
719
|
+
netAmount: reader.number(item, "netto", path),
|
|
720
|
+
marginVatBase: require_create.childNumber(item, "arresafaalap"),
|
|
721
|
+
vatAmount: reader.number(item, "afa", path),
|
|
722
|
+
grossAmount: reader.number(item, "brutto", path),
|
|
723
|
+
comment: require_create.childText(item, "megjegyzes"),
|
|
724
|
+
position: require_create.childNumber(item, "sztetordering"),
|
|
725
|
+
ledger: readItemLedger(require_create.findChild(item, "fokonyv"))
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
function readLabels(element) {
|
|
729
|
+
return require_create.findChildren(element, "cimke").flatMap((label) => {
|
|
730
|
+
const value = label.text.trim();
|
|
731
|
+
return value === "" ? [] : [value];
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
function readFinancialItem(item, reader) {
|
|
735
|
+
const path = "qutetek/qutet";
|
|
736
|
+
return {
|
|
737
|
+
name: reader.text(item, "nev", path),
|
|
738
|
+
vat: reader.number(item, "afakulcs", path),
|
|
739
|
+
vatCode: require_create.childText(item, "afatipus"),
|
|
740
|
+
netAmount: reader.number(item, "netto", path),
|
|
741
|
+
vatAmount: reader.number(item, "afa", path),
|
|
742
|
+
grossAmount: reader.number(item, "brutto", path),
|
|
743
|
+
settlementPeriodStart: require_create.childText(item, "elszdattol"),
|
|
744
|
+
settlementPeriodEnd: require_create.childText(item, "elszdatig"),
|
|
745
|
+
vatDeduction: require_create.childNumber(item, "afalevon"),
|
|
746
|
+
labels: readLabels(require_create.findChild(item, "cimkek"))
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
function readTotals(root, reader) {
|
|
750
|
+
const totals = reader.element(root, "osszegek", "osszegek");
|
|
751
|
+
const total = reader.element(totals, "totalossz", "osszegek/totalossz");
|
|
752
|
+
const path = "osszegek/totalossz";
|
|
753
|
+
return {
|
|
754
|
+
netAmount: reader.number(total, "netto", path),
|
|
755
|
+
vatAmount: reader.number(total, "afa", path),
|
|
756
|
+
grossAmount: reader.number(total, "brutto", path),
|
|
757
|
+
byVat: require_create.findChildren(totals, "afakulcsossz").map((entry) => ({
|
|
758
|
+
vat: reader.number(entry, "afakulcs", "osszegek/afakulcsossz"),
|
|
759
|
+
vatCode: require_create.childText(entry, "afatipus"),
|
|
760
|
+
netAmount: reader.number(entry, "netto", "osszegek/afakulcsossz"),
|
|
761
|
+
vatAmount: reader.number(entry, "afa", "osszegek/afakulcsossz"),
|
|
762
|
+
grossAmount: reader.number(entry, "brutto", "osszegek/afakulcsossz")
|
|
763
|
+
}))
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
function readPayment(payment, reader) {
|
|
767
|
+
const path = "kifizetesek/kifizetes";
|
|
768
|
+
return {
|
|
769
|
+
date: reader.text(payment, "datum", path),
|
|
770
|
+
method: reader.text(payment, "jogcim", path),
|
|
771
|
+
amount: reader.number(payment, "osszeg", path),
|
|
772
|
+
comment: require_create.childText(payment, "megjegyzes"),
|
|
773
|
+
bankAccountNumber: require_create.childText(payment, "bankszamlaszam"),
|
|
774
|
+
bankTransactionId: require_create.childNumber(payment, "banktranzid"),
|
|
775
|
+
exchangeRate: require_create.childNumber(payment, "devizaarf")
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
function parseInvoiceDetailsXml(root, response) {
|
|
779
|
+
const reader = new InvoiceReader(response);
|
|
780
|
+
return {
|
|
781
|
+
seller: readSeller(root, reader),
|
|
782
|
+
header: readHeader(root, reader),
|
|
783
|
+
buyer: readBuyer(root, reader),
|
|
784
|
+
items: require_create.findChildren(require_create.findChild(root, "tetelek"), "tetel").map((item) => readItem(item, reader)),
|
|
785
|
+
financialItems: require_create.findChildren(require_create.findChild(root, "qutetek"), "qutet").map((item) => readFinancialItem(item, reader)),
|
|
786
|
+
labels: readLabels(require_create.findChild(root, "cimkek")),
|
|
787
|
+
totals: readTotals(root, reader),
|
|
788
|
+
payments: require_create.findChildren(require_create.findChild(root, "kifizetesek"), "kifizetes").map((payment) => readPayment(payment, reader)),
|
|
789
|
+
pdf: decodeResponsePdf(root, response)
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
function parseGetInvoiceResponse(response) {
|
|
793
|
+
require_create.throwIfHeaderError(response);
|
|
794
|
+
require_create.throwIfTextError(response);
|
|
795
|
+
require_create.throwIfHttpError(response);
|
|
796
|
+
const root = require_create.parseResponseXml(response);
|
|
797
|
+
require_create.throwIfXmlFailure(root, response);
|
|
798
|
+
if (root.name !== "szamla") throw require_create.unexpectedResponse(response, "A számla XML (<szamla>) helyett más válasz érkezett.");
|
|
799
|
+
return parseInvoiceDetailsXml(root, response);
|
|
800
|
+
}
|
|
801
|
+
async function getInvoice(ctx, reference, query = {}, options = {}) {
|
|
802
|
+
const xml = buildGetInvoiceXml(ctx.credentials, reference, query);
|
|
803
|
+
return ctx.execute({
|
|
804
|
+
action: "getInvoiceXml",
|
|
805
|
+
xml,
|
|
806
|
+
signal: options.signal,
|
|
807
|
+
safeToRetry: true
|
|
808
|
+
}, parseGetInvoiceResponse);
|
|
809
|
+
}
|
|
810
|
+
function normalizeRegisterInput(input) {
|
|
811
|
+
const payments = "payments" in input ? input.payments : [{
|
|
812
|
+
amount: input.amount,
|
|
813
|
+
method: input.method ?? "átutalás",
|
|
814
|
+
date: input.date,
|
|
815
|
+
description: input.description
|
|
816
|
+
}];
|
|
817
|
+
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.");
|
|
818
|
+
if (payments.length > 5) throw validationError(`Egy kérésben legfeljebb 5 befizetés rögzíthető, kapott: ${payments.length}.`);
|
|
819
|
+
return {
|
|
820
|
+
invoiceNumber: input.invoiceNumber,
|
|
821
|
+
taxNumber: input.taxNumber,
|
|
822
|
+
additive: input.additive ?? true,
|
|
823
|
+
payments
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
function normalizeClearInput(input) {
|
|
827
|
+
const target = typeof input === "string" ? { invoiceNumber: input } : input;
|
|
828
|
+
return {
|
|
829
|
+
invoiceNumber: target.invoiceNumber,
|
|
830
|
+
taxNumber: target.taxNumber,
|
|
831
|
+
additive: false,
|
|
832
|
+
payments: []
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
function paymentNode(payment, index) {
|
|
836
|
+
const position = index + 1;
|
|
837
|
+
if (typeof payment.amount !== "number" || !Number.isFinite(payment.amount)) throw validationError(`A(z) ${position}. befizetés összege (amount) nem véges szám.`);
|
|
838
|
+
return require_create.el("kifizetes", [
|
|
839
|
+
require_create.el("datum", payment.date === void 0 ? require_dates.todayInBudapest() : agentDate(payment.date, "date")),
|
|
840
|
+
require_create.el("jogcim", requireText(payment.method, `Add meg a(z) ${position}. befizetés módját (method).`)),
|
|
841
|
+
require_create.el("osszeg", payment.amount),
|
|
842
|
+
require_create.optionalEl("leiras", optionalText(payment.description))
|
|
843
|
+
]);
|
|
844
|
+
}
|
|
845
|
+
function buildPaymentXml(credentials, request) {
|
|
846
|
+
const invoiceNumber = requireText(request.invoiceNumber, "Add meg a számla számát (invoiceNumber), amelyhez a befizetés tartozik.");
|
|
847
|
+
return require_create.buildXmlDocument({
|
|
848
|
+
root: "xmlszamlakifiz",
|
|
849
|
+
namespace: "http://www.szamlazz.hu/xmlszamlakifiz",
|
|
850
|
+
schemaLocation: `${AGENT_XSD_BASE_URL}agentkifiz/xmlszamlakifiz.xsd`,
|
|
851
|
+
children: [require_create.el("beallitasok", [
|
|
852
|
+
...credentials,
|
|
853
|
+
require_create.el("szamlaszam", invoiceNumber),
|
|
854
|
+
require_create.optionalEl("adoszam", optionalText(request.taxNumber)),
|
|
855
|
+
require_create.el("additiv", request.additive),
|
|
856
|
+
require_create.el("valaszVerzio", 2)
|
|
857
|
+
]), ...request.payments.map(paymentNode)]
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
function parseRegisterPaymentResponse(response, invoiceNumber) {
|
|
861
|
+
const result = parseInvoiceResult(response);
|
|
862
|
+
return {
|
|
863
|
+
invoiceNumber: result.number ?? invoiceNumber.trim(),
|
|
864
|
+
netTotal: result.netTotal,
|
|
865
|
+
grossTotal: result.grossTotal,
|
|
866
|
+
outstanding: result.outstanding,
|
|
867
|
+
buyerAccountUrl: result.buyerAccountUrl
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
function sendPaymentRequest(ctx, request, options) {
|
|
871
|
+
const xml = buildPaymentXml(ctx.credentials, request);
|
|
872
|
+
return ctx.execute({
|
|
873
|
+
action: "registerPayment",
|
|
874
|
+
xml,
|
|
875
|
+
signal: options.signal,
|
|
876
|
+
safeToRetry: !request.additive
|
|
877
|
+
}, (response) => parseRegisterPaymentResponse(response, request.invoiceNumber));
|
|
878
|
+
}
|
|
879
|
+
async function registerPayment(ctx, input, options = {}) {
|
|
880
|
+
return sendPaymentRequest(ctx, normalizeRegisterInput(input), options);
|
|
881
|
+
}
|
|
882
|
+
async function clearPayments(ctx, input, options = {}) {
|
|
883
|
+
return sendPaymentRequest(ctx, normalizeClearInput(input), options);
|
|
884
|
+
}
|
|
885
|
+
//#endregion
|
|
886
|
+
//#region src/invoices/pdf.ts
|
|
887
|
+
function buildInvoicePdfXml(credentials, reference) {
|
|
888
|
+
const resolved = resolveInvoiceReference(reference);
|
|
889
|
+
return require_create.buildXmlDocument({
|
|
890
|
+
root: "xmlszamlapdf",
|
|
891
|
+
namespace: "http://www.szamlazz.hu/xmlszamlapdf",
|
|
892
|
+
schemaLocation: `${AGENT_XSD_BASE_URL}agentpdf/xmlszamlapdf.xsd`,
|
|
893
|
+
children: [
|
|
894
|
+
...credentials,
|
|
895
|
+
require_create.optionalEl("szamlaszam", referenceValue(resolved, "invoiceNumber")),
|
|
896
|
+
require_create.optionalEl("rendelesSzam", referenceValue(resolved, "orderNumber")),
|
|
897
|
+
require_create.el("valaszVerzio", 2),
|
|
898
|
+
require_create.optionalEl("szamlaKulsoAzon", referenceValue(resolved, "externalId"))
|
|
899
|
+
]
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
function parseInvoicePdfResponse(response) {
|
|
903
|
+
const { pdf, ...rest } = parseInvoiceResult(response);
|
|
904
|
+
if (pdf === void 0 || pdf.length === 0) throw require_create.unexpectedResponse(response, "A válasz nem tartalmaz PDF-et.");
|
|
905
|
+
return {
|
|
906
|
+
...rest,
|
|
907
|
+
pdf
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
async function getInvoicePdf(ctx, reference, options = {}) {
|
|
911
|
+
const xml = buildInvoicePdfXml(ctx.credentials, reference);
|
|
912
|
+
return ctx.execute({
|
|
913
|
+
action: "getInvoicePdf",
|
|
914
|
+
xml,
|
|
915
|
+
signal: options.signal,
|
|
916
|
+
safeToRetry: true
|
|
917
|
+
}, parseInvoicePdfResponse);
|
|
918
|
+
}
|
|
919
|
+
const RESPONSE_ROOTS = /* @__PURE__ */ new Set(["xmlszamladbkdelvalasz", "xmlszamlavalasz"]);
|
|
920
|
+
const REFERENCE_HINT = "Add meg a díjbekérő számát szövegként, vagy pontosan egyet ezek közül: { proformaNumber }, { orderNumber }.";
|
|
921
|
+
function resolveProformaReference(reference) {
|
|
922
|
+
if (typeof reference === "string") return { proformaNumber: requireText(reference, `Üres díjbekérőszám. ${REFERENCE_HINT}`) };
|
|
923
|
+
if (typeof reference !== "object" || reference === null) throw validationError(`Érvénytelen díjbekérő-hivatkozás. ${REFERENCE_HINT}`);
|
|
924
|
+
const record = reference;
|
|
925
|
+
const hasNumber = record.proformaNumber !== void 0;
|
|
926
|
+
if (hasNumber === (record.orderNumber !== void 0)) throw validationError(`Érvénytelen díjbekérő-hivatkozás. ${REFERENCE_HINT}`);
|
|
927
|
+
return hasNumber ? { proformaNumber: requireText(record.proformaNumber, `Üres proformaNumber. ${REFERENCE_HINT}`) } : { orderNumber: requireText(record.orderNumber, `Üres orderNumber. ${REFERENCE_HINT}`) };
|
|
928
|
+
}
|
|
929
|
+
function buildDeleteProformaXml(credentials, reference) {
|
|
930
|
+
const resolved = resolveProformaReference(reference);
|
|
931
|
+
return require_create.buildXmlDocument({
|
|
932
|
+
root: "xmlszamladbkdel",
|
|
933
|
+
namespace: "http://www.szamlazz.hu/xmlszamladbkdel",
|
|
934
|
+
schemaLocation: "http://www.szamlazz.hu/docs/xsds/szamladbkdel/xmlszamladbkdel.xsd",
|
|
935
|
+
children: [require_create.el("beallitasok", [...credentials]), require_create.el("fejlec", [require_create.optionalEl("szamlaszam", resolved.proformaNumber), require_create.optionalEl("rendelesszam", resolved.orderNumber)])]
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
function withProformaCategory(error) {
|
|
939
|
+
if (!(error instanceof require_errors.SzamlazzError) || error.code !== 335) return error;
|
|
940
|
+
return new require_errors.SzamlazzError(error.message, {
|
|
941
|
+
category: "not_found",
|
|
942
|
+
code: error.code,
|
|
943
|
+
hint: "A díjbekérő nem létezik, vagy már törölték.",
|
|
944
|
+
action: error.action,
|
|
945
|
+
httpStatus: error.httpStatus,
|
|
946
|
+
rawResponse: error.rawResponse,
|
|
947
|
+
cause: error
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
function parseDeleteProformaResponse(response) {
|
|
951
|
+
try {
|
|
952
|
+
require_create.throwIfHeaderError(response);
|
|
953
|
+
require_create.throwIfTextError(response);
|
|
954
|
+
require_create.throwIfHttpError(response);
|
|
955
|
+
const root = require_create.parseResponseXml(response);
|
|
956
|
+
require_create.throwIfXmlFailure(root, response);
|
|
957
|
+
if (!RESPONSE_ROOTS.has(root.name) || require_create.childText(root, "sikeres")?.toLowerCase() !== "true") throw require_create.unexpectedResponse(response, "xmlszamladbkdelvalasz XML választ vártunk.");
|
|
958
|
+
} catch (error) {
|
|
959
|
+
throw withProformaCategory(error);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
async function deleteProforma(ctx, reference, options = {}) {
|
|
963
|
+
const xml = buildDeleteProformaXml(ctx.credentials, reference);
|
|
964
|
+
await ctx.execute({
|
|
965
|
+
action: "deleteProforma",
|
|
966
|
+
xml,
|
|
967
|
+
signal: options.signal
|
|
968
|
+
}, parseDeleteProformaResponse);
|
|
969
|
+
}
|
|
970
|
+
const templates = new Set(require_create.INVOICE_TEMPLATES);
|
|
971
|
+
function normalizeInput$2(input) {
|
|
972
|
+
return typeof input === "string" ? { invoiceNumber: input } : input;
|
|
973
|
+
}
|
|
974
|
+
function validateTemplate(template) {
|
|
975
|
+
if (template === void 0 || templates.has(template)) return template;
|
|
976
|
+
throw validationError(`Ismeretlen számlasablon: ${String(template)}. Lehetséges értékek: ${require_create.INVOICE_TEMPLATES.join(", ")}.`);
|
|
977
|
+
}
|
|
978
|
+
function buildReverseInvoiceXml(credentials, input) {
|
|
979
|
+
const options = normalizeInput$2(input);
|
|
980
|
+
const invoiceNumber = requireText(options.invoiceNumber, "Add meg a sztornózandó számla számát (invoiceNumber).");
|
|
981
|
+
const email = options.email;
|
|
982
|
+
const buyer = options.buyer;
|
|
983
|
+
return require_create.buildXmlDocument({
|
|
984
|
+
root: "xmlszamlast",
|
|
985
|
+
namespace: "http://www.szamlazz.hu/xmlszamlast",
|
|
986
|
+
schemaLocation: `${AGENT_XSD_BASE_URL}agentst/xmlszamlast.xsd`,
|
|
987
|
+
children: [
|
|
988
|
+
require_create.el("beallitasok", [
|
|
989
|
+
...credentials,
|
|
990
|
+
require_create.el("eszamla", options.eInvoice ?? false),
|
|
991
|
+
require_create.el("szamlaLetoltes", options.downloadPdf ?? true),
|
|
992
|
+
require_create.el("valaszVerzio", 2),
|
|
993
|
+
require_create.optionalEl("szamlaKulsoAzon", optionalText(options.externalId))
|
|
994
|
+
]),
|
|
995
|
+
require_create.el("fejlec", [
|
|
996
|
+
require_create.el("szamlaszam", invoiceNumber),
|
|
997
|
+
require_create.optionalEl("keltDatum", optionalAgentDate(options.issueDate, "issueDate")),
|
|
998
|
+
require_create.optionalEl("teljesitesDatum", optionalAgentDate(options.fulfillmentDate, "fulfillmentDate")),
|
|
999
|
+
require_create.optionalEl("megjegyzes", optionalText(options.comment)),
|
|
1000
|
+
require_create.el("tipus", "SS"),
|
|
1001
|
+
require_create.optionalEl("szamlaSablon", validateTemplate(options.template))
|
|
1002
|
+
]),
|
|
1003
|
+
require_create.optionalEl("elado", [
|
|
1004
|
+
require_create.optionalEl("emailReplyto", optionalText(email?.replyTo)),
|
|
1005
|
+
require_create.optionalEl("emailTargy", optionalText(email?.subject)),
|
|
1006
|
+
require_create.optionalEl("emailSzoveg", optionalText(email?.text))
|
|
1007
|
+
]),
|
|
1008
|
+
require_create.optionalEl("vevo", [
|
|
1009
|
+
require_create.optionalEl("email", optionalText(buyer?.email)),
|
|
1010
|
+
require_create.optionalEl("adoszam", optionalText(buyer?.taxNumber)),
|
|
1011
|
+
require_create.optionalEl("adoszamEU", optionalText(buyer?.euTaxNumber))
|
|
1012
|
+
])
|
|
1013
|
+
]
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
function parseReverseInvoiceResponse(response, originalInvoiceNumber) {
|
|
1017
|
+
const result = parseInvoiceResult(response);
|
|
1018
|
+
if (result.number === void 0) throw require_create.unexpectedResponse(response, "A válaszban nincs sztornó számlaszám.");
|
|
1019
|
+
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.`, {
|
|
1020
|
+
category: "validation",
|
|
1021
|
+
action: response.action,
|
|
1022
|
+
httpStatus: response.status,
|
|
1023
|
+
hint: "Díjbekérő és szállítólevél nem sztornózható. Díjbekérőt a deleteProforma függvénnyel törölhetsz."
|
|
1024
|
+
});
|
|
1025
|
+
return {
|
|
1026
|
+
...result,
|
|
1027
|
+
number: result.number
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
async function reverseInvoice(ctx, input, options = {}) {
|
|
1031
|
+
const invoiceNumber = normalizeInput$2(input).invoiceNumber;
|
|
1032
|
+
const xml = buildReverseInvoiceXml(ctx.credentials, input);
|
|
1033
|
+
return ctx.execute({
|
|
1034
|
+
action: "reverseInvoice",
|
|
1035
|
+
xml,
|
|
1036
|
+
signal: options.signal
|
|
1037
|
+
}, (response) => parseReverseInvoiceResponse(response, invoiceNumber));
|
|
1038
|
+
}
|
|
1039
|
+
//#endregion
|
|
1040
|
+
//#region src/receipts/get.ts
|
|
1041
|
+
const GET_RECEIPT_NAMESPACE = "http://www.szamlazz.hu/xmlnyugtaget";
|
|
1042
|
+
function normalizeInput$1(input) {
|
|
1043
|
+
return typeof input === "string" ? { receiptNumber: input } : input;
|
|
1044
|
+
}
|
|
1045
|
+
function resolveIdentifier(input) {
|
|
1046
|
+
const receiptNumber = require_create.optionalText(input.receiptNumber);
|
|
1047
|
+
const orderNumber = require_create.optionalText(input.orderNumber);
|
|
1048
|
+
if (receiptNumber === void 0 && orderNumber === void 0) throw require_create.receiptValidationError("A nyugta lekérdezéséhez add meg a nyugtaszámot (receiptNumber) vagy a rendelésszámot (orderNumber).");
|
|
1049
|
+
if (receiptNumber !== void 0 && orderNumber !== void 0) throw require_create.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.");
|
|
1050
|
+
return {
|
|
1051
|
+
receiptNumber,
|
|
1052
|
+
orderNumber
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
function buildGetReceiptXml(credentials, input) {
|
|
1056
|
+
const normalized = normalizeInput$1(input);
|
|
1057
|
+
const { receiptNumber, orderNumber } = resolveIdentifier(normalized);
|
|
1058
|
+
return require_create.buildXmlDocument({
|
|
1059
|
+
root: "xmlnyugtaget",
|
|
1060
|
+
namespace: GET_RECEIPT_NAMESPACE,
|
|
1061
|
+
schemaLocation: `${require_create.RECEIPT_XSD_BASE_URL}nyugtaget/xmlnyugtaget.xsd`,
|
|
1062
|
+
children: [require_create.el("beallitasok", [...credentials, require_create.el("pdfLetoltes", normalized.downloadPdf ?? true)]), require_create.el("fejlec", [
|
|
1063
|
+
require_create.optionalEl("nyugtaszam", receiptNumber),
|
|
1064
|
+
require_create.optionalEl("rendelesSzam", orderNumber),
|
|
1065
|
+
require_create.optionalEl("hivasAzonosito", require_create.optionalText(normalized.callId)),
|
|
1066
|
+
require_create.optionalEl("pdfSablon", require_create.validateTemplate(normalized.template))
|
|
1067
|
+
])]
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
function getReceipt(ctx, input, options = {}) {
|
|
1071
|
+
const xml = buildGetReceiptXml(ctx.credentials, input);
|
|
1072
|
+
return ctx.execute({
|
|
1073
|
+
action: "getReceipt",
|
|
1074
|
+
xml,
|
|
1075
|
+
signal: options.signal,
|
|
1076
|
+
safeToRetry: true
|
|
1077
|
+
}, require_create.parseReceiptResponse);
|
|
1078
|
+
}
|
|
1079
|
+
//#endregion
|
|
1080
|
+
//#region src/receipts/reverse.ts
|
|
1081
|
+
const REVERSE_RECEIPT_NAMESPACE = "http://www.szamlazz.hu/xmlnyugtast";
|
|
1082
|
+
function normalizeInput(input) {
|
|
1083
|
+
return typeof input === "string" ? { receiptNumber: input } : input;
|
|
1084
|
+
}
|
|
1085
|
+
function buildReverseReceiptXml(credentials, input) {
|
|
1086
|
+
const normalized = normalizeInput(input);
|
|
1087
|
+
return require_create.buildXmlDocument({
|
|
1088
|
+
root: "xmlnyugtast",
|
|
1089
|
+
namespace: REVERSE_RECEIPT_NAMESPACE,
|
|
1090
|
+
schemaLocation: `${require_create.RECEIPT_XSD_BASE_URL}nyugtast/xmlnyugtast.xsd`,
|
|
1091
|
+
children: [require_create.el("beallitasok", [...credentials, require_create.el("pdfLetoltes", normalized.downloadPdf ?? true)]), require_create.el("fejlec", [
|
|
1092
|
+
require_create.el("nyugtaszam", require_create.requireReceiptNumber(normalized.receiptNumber)),
|
|
1093
|
+
require_create.optionalEl("pdfSablon", require_create.validateTemplate(normalized.template)),
|
|
1094
|
+
require_create.optionalEl("hivasAzonosito", require_create.optionalText(normalized.callId))
|
|
1095
|
+
])]
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
function reverseReceipt(ctx, input, options = {}) {
|
|
1099
|
+
const normalized = normalizeInput(input);
|
|
1100
|
+
const xml = buildReverseReceiptXml(ctx.credentials, normalized);
|
|
1101
|
+
return ctx.execute({
|
|
1102
|
+
action: "reverseReceipt",
|
|
1103
|
+
xml,
|
|
1104
|
+
signal: options.signal,
|
|
1105
|
+
safeToRetry: require_create.optionalText(normalized.callId) !== void 0
|
|
1106
|
+
}, require_create.parseReceiptResponse);
|
|
1107
|
+
}
|
|
1108
|
+
//#endregion
|
|
1109
|
+
//#region src/receipts/send.ts
|
|
1110
|
+
const SEND_RECEIPT_NAMESPACE = "http://www.szamlazz.hu/xmlnyugtasend";
|
|
1111
|
+
const EMAIL_PATTERN = /^[^\s@,;<>]+@[^\s@,;<>]+\.[^\s@,;<>]+$/;
|
|
1112
|
+
function isValidEmail(value) {
|
|
1113
|
+
return EMAIL_PATTERN.test(value);
|
|
1114
|
+
}
|
|
1115
|
+
function assertEmail(value, field) {
|
|
1116
|
+
if (!isValidEmail(value)) throw require_create.receiptValidationError(`Érvénytelen e-mail cím a(z) ${field} mezőben: ${value}`);
|
|
1117
|
+
return value;
|
|
1118
|
+
}
|
|
1119
|
+
function normalizeEmails(emails) {
|
|
1120
|
+
const list = (typeof emails === "string" ? [emails] : [...emails]).flatMap((entry) => entry.split(/[,;]/)).map((entry) => entry.trim()).filter((entry) => entry !== "");
|
|
1121
|
+
if (list.length === 0) throw require_create.receiptValidationError("Adj meg legalább egy címzett e-mail címet (emails).");
|
|
1122
|
+
return list.map((email) => assertEmail(email, "emails"));
|
|
1123
|
+
}
|
|
1124
|
+
function buildSendReceiptXml(credentials, input) {
|
|
1125
|
+
const receiptNumber = require_create.requireReceiptNumber(input.receiptNumber);
|
|
1126
|
+
const emails = normalizeEmails(input.emails);
|
|
1127
|
+
const replyTo = require_create.optionalText(input.replyTo);
|
|
1128
|
+
if (replyTo !== void 0) assertEmail(replyTo, "replyTo");
|
|
1129
|
+
return require_create.buildXmlDocument({
|
|
1130
|
+
root: "xmlnyugtasend",
|
|
1131
|
+
namespace: SEND_RECEIPT_NAMESPACE,
|
|
1132
|
+
schemaLocation: `${require_create.RECEIPT_XSD_BASE_URL}nyugtasend/xmlnyugtasend.xsd`,
|
|
1133
|
+
children: [
|
|
1134
|
+
require_create.el("beallitasok", credentials),
|
|
1135
|
+
require_create.el("fejlec", [require_create.el("nyugtaszam", receiptNumber)]),
|
|
1136
|
+
require_create.el("emailKuldes", [
|
|
1137
|
+
require_create.el("email", emails.join(",")),
|
|
1138
|
+
require_create.optionalEl("emailReplyto", replyTo),
|
|
1139
|
+
require_create.el("emailTargy", require_create.optionalText(input.subject) ?? `Nyugta ${receiptNumber}`),
|
|
1140
|
+
require_create.optionalEl("emailSzoveg", input.text?.trim() ? input.text : void 0)
|
|
1141
|
+
])
|
|
1142
|
+
]
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
function parseSendReceiptResponse(response) {
|
|
1146
|
+
require_create.throwIfHeaderError(response);
|
|
1147
|
+
require_create.throwIfTextError(response);
|
|
1148
|
+
if (!require_create.looksLikeXml(response)) {
|
|
1149
|
+
require_create.throwIfHttpError(response);
|
|
1150
|
+
if (require_create.parseDoneText(response.text())) return;
|
|
1151
|
+
throw require_create.unexpectedResponse(response, "XML választ vártunk a nyugta kiküldésére.");
|
|
1152
|
+
}
|
|
1153
|
+
const root = require_create.parseResponseXml(response);
|
|
1154
|
+
require_create.throwIfXmlFailure(root, response);
|
|
1155
|
+
if (require_create.childBoolean(root, "sikeres") !== true) {
|
|
1156
|
+
require_create.throwIfHttpError(response);
|
|
1157
|
+
throw require_create.unexpectedResponse(response, "A válasz nem jelez sikeres kiküldést.");
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
function sendReceipt(ctx, input, options = {}) {
|
|
1161
|
+
const xml = buildSendReceiptXml(ctx.credentials, input);
|
|
1162
|
+
return ctx.execute({
|
|
1163
|
+
action: "sendReceipt",
|
|
1164
|
+
xml,
|
|
1165
|
+
signal: options.signal
|
|
1166
|
+
}, parseSendReceiptResponse);
|
|
1167
|
+
}
|
|
1168
|
+
//#endregion
|
|
1169
|
+
//#region src/taxpayer/address.ts
|
|
1170
|
+
const ROMAN_NUMERAL = /^[IVX]{1,5}\.?$/;
|
|
1171
|
+
function isShouting(value) {
|
|
1172
|
+
return value === value.toUpperCase() && value !== value.toLowerCase();
|
|
1173
|
+
}
|
|
1174
|
+
function capitalizeWord(word) {
|
|
1175
|
+
if (ROMAN_NUMERAL.test(word)) return word;
|
|
1176
|
+
return word.split("-").map((part) => part.toLowerCase().replace(/\p{L}/u, (letter) => letter.toUpperCase())).join("-");
|
|
1177
|
+
}
|
|
1178
|
+
function toReadableName(value) {
|
|
1179
|
+
if (value === void 0 || !isShouting(value)) return value;
|
|
1180
|
+
return value.split(" ").map(capitalizeWord).join(" ");
|
|
1181
|
+
}
|
|
1182
|
+
function toLowerIfShouting(value) {
|
|
1183
|
+
return value !== void 0 && isShouting(value) ? value.toLowerCase() : value;
|
|
1184
|
+
}
|
|
1185
|
+
function withOrdinalDot(value) {
|
|
1186
|
+
if (value === void 0) return void 0;
|
|
1187
|
+
return /^\d+$/.test(value) ? `${value}.` : value;
|
|
1188
|
+
}
|
|
1189
|
+
function joinParts(parts) {
|
|
1190
|
+
return parts.filter((part) => part !== void 0 && part !== "").join(" ");
|
|
1191
|
+
}
|
|
1192
|
+
function formatAddress(address) {
|
|
1193
|
+
return [
|
|
1194
|
+
joinParts([address.postalCode, address.city]),
|
|
1195
|
+
joinParts([
|
|
1196
|
+
address.street,
|
|
1197
|
+
address.publicPlaceCategory,
|
|
1198
|
+
withOrdinalDot(address.number),
|
|
1199
|
+
address.building === void 0 ? void 0 : `${address.building} ép.`,
|
|
1200
|
+
address.staircase === void 0 ? void 0 : `${withOrdinalDot(address.staircase)} lh.`,
|
|
1201
|
+
address.floor === void 0 ? void 0 : `${withOrdinalDot(address.floor)} em.`,
|
|
1202
|
+
address.door === void 0 ? void 0 : `${withOrdinalDot(address.door)} ajtó`
|
|
1203
|
+
]),
|
|
1204
|
+
address.lotNumber === void 0 ? void 0 : `hrsz. ${address.lotNumber}`,
|
|
1205
|
+
address.countryCode === "" || address.countryCode === "HU" ? void 0 : address.countryCode
|
|
1206
|
+
].filter((part) => part !== void 0 && part !== "").join(", ");
|
|
1207
|
+
}
|
|
1208
|
+
function readDetailedAddress(element) {
|
|
1209
|
+
return {
|
|
1210
|
+
countryCode: require_create.childText(element, "countryCode"),
|
|
1211
|
+
region: require_create.childText(element, "region"),
|
|
1212
|
+
postalCode: require_create.childText(element, "postalCode"),
|
|
1213
|
+
city: require_create.childText(element, "city"),
|
|
1214
|
+
streetName: require_create.childText(element, "streetName"),
|
|
1215
|
+
publicPlaceCategory: require_create.childText(element, "publicPlaceCategory"),
|
|
1216
|
+
number: require_create.childText(element, "number"),
|
|
1217
|
+
building: require_create.childText(element, "building"),
|
|
1218
|
+
staircase: require_create.childText(element, "staircase"),
|
|
1219
|
+
floor: require_create.childText(element, "floor"),
|
|
1220
|
+
door: require_create.childText(element, "door"),
|
|
1221
|
+
lotNumber: require_create.childText(element, "lotNumber")
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
function parseTaxpayerAddress(item) {
|
|
1225
|
+
const raw = readDetailedAddress(require_create.findChild(item, "taxpayerAddress"));
|
|
1226
|
+
const address = {
|
|
1227
|
+
type: require_create.childText(item, "taxpayerAddressType")?.toUpperCase() ?? "",
|
|
1228
|
+
countryCode: raw.countryCode?.toUpperCase() ?? "",
|
|
1229
|
+
region: toReadableName(raw.region),
|
|
1230
|
+
postalCode: raw.postalCode ?? "",
|
|
1231
|
+
city: toReadableName(raw.city) ?? "",
|
|
1232
|
+
street: toReadableName(raw.streetName),
|
|
1233
|
+
publicPlaceCategory: toLowerIfShouting(raw.publicPlaceCategory),
|
|
1234
|
+
number: raw.number,
|
|
1235
|
+
building: raw.building,
|
|
1236
|
+
staircase: raw.staircase,
|
|
1237
|
+
floor: raw.floor,
|
|
1238
|
+
door: raw.door,
|
|
1239
|
+
lotNumber: raw.lotNumber
|
|
1240
|
+
};
|
|
1241
|
+
return {
|
|
1242
|
+
...address,
|
|
1243
|
+
formatted: formatAddress(address),
|
|
1244
|
+
raw
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
//#endregion
|
|
1248
|
+
//#region src/taxpayer/query-taxpayer.ts
|
|
1249
|
+
const TAXPAYER_NAMESPACE = "http://www.szamlazz.hu/xmltaxpayer";
|
|
1250
|
+
const TAXPAYER_SCHEMA_LOCATION = "http://www.szamlazz.hu/docs/xsds/agent/xmltaxpayer.xsd";
|
|
1251
|
+
function toTaxpayerId(taxNumber) {
|
|
1252
|
+
const digits = typeof taxNumber === "string" ? taxNumber.replace(/[\s-]+/g, "").replace(/^HU/i, "") : "";
|
|
1253
|
+
if (!/^(?:\d{8}|\d{11})$/.test(digits)) throw new require_errors.SzamlazzError(`Érvénytelen adószám: "${String(taxNumber)}". Add meg a 8 jegyű törzsszámot vagy a 11 jegyű adószámot (pl. 12345678-2-42).`, {
|
|
1254
|
+
category: "validation",
|
|
1255
|
+
action: "queryTaxpayer"
|
|
1256
|
+
});
|
|
1257
|
+
return digits.slice(0, 8);
|
|
1258
|
+
}
|
|
1259
|
+
function buildQueryTaxpayerXml(credentials, taxNumber) {
|
|
1260
|
+
return require_create.buildXmlDocument({
|
|
1261
|
+
root: "xmltaxpayer",
|
|
1262
|
+
namespace: TAXPAYER_NAMESPACE,
|
|
1263
|
+
schemaLocation: TAXPAYER_SCHEMA_LOCATION,
|
|
1264
|
+
children: [require_create.el("beallitasok", credentials), require_create.el("torzsszam", toTaxpayerId(taxNumber))]
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
function throwIfNavError(root, response) {
|
|
1268
|
+
const result = require_create.findChild(root, "result");
|
|
1269
|
+
if (require_create.childText(result, "funcCode")?.toUpperCase() !== "ERROR") return;
|
|
1270
|
+
const errorCode = require_create.childText(result, "errorCode");
|
|
1271
|
+
const code = require_errors.parseErrorCode(errorCode);
|
|
1272
|
+
const message = require_create.childText(result, "message");
|
|
1273
|
+
const textCode = code === void 0 ? errorCode : void 0;
|
|
1274
|
+
throw require_errors.createAgentError({
|
|
1275
|
+
code,
|
|
1276
|
+
message: textCode === void 0 ? message : [textCode, message].filter(Boolean).join(": "),
|
|
1277
|
+
action: response.action,
|
|
1278
|
+
httpStatus: response.status,
|
|
1279
|
+
rawResponse: response.text().slice(0, 2e3)
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
function readTaxNumber(data) {
|
|
1283
|
+
const detail = require_create.findChild(data, "taxNumberDetail");
|
|
1284
|
+
const taxpayerId = require_create.childText(detail, "taxpayerId");
|
|
1285
|
+
if (taxpayerId === void 0) return void 0;
|
|
1286
|
+
const vatCode = require_create.childText(detail, "vatCode");
|
|
1287
|
+
const countyCode = require_create.childText(detail, "countyCode");
|
|
1288
|
+
return {
|
|
1289
|
+
taxpayerId,
|
|
1290
|
+
vatCode,
|
|
1291
|
+
countyCode,
|
|
1292
|
+
formatted: vatCode !== void 0 && countyCode !== void 0 ? `${taxpayerId}-${vatCode}-${countyCode}` : void 0
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
function readAddresses(data) {
|
|
1296
|
+
return require_create.findChildren(require_create.findChild(data, "taxpayerAddressList"), "taxpayerAddressItem").map(parseTaxpayerAddress);
|
|
1297
|
+
}
|
|
1298
|
+
function readRequestId(root) {
|
|
1299
|
+
const requestId = require_create.childText(require_create.findChild(root, "header"), "requestId");
|
|
1300
|
+
return requestId === "-" ? void 0 : requestId;
|
|
1301
|
+
}
|
|
1302
|
+
function parseQueryTaxpayerResponse(response) {
|
|
1303
|
+
require_create.throwIfAnyError(response);
|
|
1304
|
+
const root = require_create.parseResponseXml(response);
|
|
1305
|
+
require_create.throwIfXmlFailure(root, response);
|
|
1306
|
+
if (root.name !== "QueryTaxpayerResponse") throw require_create.unexpectedResponse(response, "QueryTaxpayerResponse XML választ vártunk.");
|
|
1307
|
+
throwIfNavError(root, response);
|
|
1308
|
+
const requestId = readRequestId(root);
|
|
1309
|
+
const infoDate = require_create.childText(root, "infoDate");
|
|
1310
|
+
const data = require_create.findChild(root, "taxpayerData");
|
|
1311
|
+
const validity = require_create.childBoolean(root, "taxpayerValidity");
|
|
1312
|
+
if (validity === false || data === void 0) return {
|
|
1313
|
+
valid: validity === true,
|
|
1314
|
+
addresses: [],
|
|
1315
|
+
infoDate,
|
|
1316
|
+
requestId
|
|
1317
|
+
};
|
|
1318
|
+
const addresses = readAddresses(data);
|
|
1319
|
+
return {
|
|
1320
|
+
valid: true,
|
|
1321
|
+
name: require_create.childText(data, "taxpayerName"),
|
|
1322
|
+
shortName: require_create.childText(data, "taxpayerShortName"),
|
|
1323
|
+
taxNumber: readTaxNumber(data),
|
|
1324
|
+
address: addresses.find((address) => address.type === "HQ") ?? addresses[0],
|
|
1325
|
+
addresses,
|
|
1326
|
+
incorporation: require_create.childText(data, "incorporation"),
|
|
1327
|
+
vatGroupMembership: require_create.childText(data, "vatGroupMembership"),
|
|
1328
|
+
infoDate,
|
|
1329
|
+
requestId
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
async function queryTaxpayer(ctx, taxNumber, options = {}) {
|
|
1333
|
+
const xml = buildQueryTaxpayerXml(ctx.credentials, taxNumber);
|
|
1334
|
+
return ctx.execute({
|
|
1335
|
+
action: "queryTaxpayer",
|
|
1336
|
+
xml,
|
|
1337
|
+
signal: options.signal,
|
|
1338
|
+
safeToRetry: true
|
|
1339
|
+
}, parseQueryTaxpayerResponse);
|
|
1340
|
+
}
|
|
1341
|
+
//#endregion
|
|
1342
|
+
//#region src/client.ts
|
|
1343
|
+
const CREDENTIAL_PROBE_INVOICE_NUMBER = "KASSZA-CREDENTIAL-PROBE-0";
|
|
1344
|
+
async function nullIfNotFound(promise) {
|
|
1345
|
+
try {
|
|
1346
|
+
return await promise;
|
|
1347
|
+
} catch (error) {
|
|
1348
|
+
if (require_errors.isSzamlazzError(error) && (error.isNotFound || error.code === 7)) return null;
|
|
1349
|
+
throw error;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
function createInvoicesApi(ctx, defaults) {
|
|
1353
|
+
return {
|
|
1354
|
+
create: (input, options) => createInvoice(ctx, defaults, input, options),
|
|
1355
|
+
preview: (input, options) => previewInvoice(ctx, defaults, input, options),
|
|
1356
|
+
reverse: (input, options) => reverseInvoice(ctx, input, options),
|
|
1357
|
+
registerPayment: (input, options) => registerPayment(ctx, input, options),
|
|
1358
|
+
clearPayments: (input, options) => clearPayments(ctx, input, options),
|
|
1359
|
+
getPdf: (reference, options) => getInvoicePdf(ctx, reference, options),
|
|
1360
|
+
get: (reference, query, options) => getInvoice(ctx, reference, query, options),
|
|
1361
|
+
find: (reference, query, options) => nullIfNotFound(getInvoice(ctx, reference, query, options)),
|
|
1362
|
+
deleteProforma: (reference, options) => deleteProforma(ctx, reference, options)
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
function createReceiptsApi(ctx, defaults) {
|
|
1366
|
+
return {
|
|
1367
|
+
create: (input, options) => require_create.createReceipt(ctx, defaults, input, options),
|
|
1368
|
+
reverse: (input, options) => reverseReceipt(ctx, input, options),
|
|
1369
|
+
get: (input, options) => getReceipt(ctx, input, options),
|
|
1370
|
+
find: (input, options) => nullIfNotFound(getReceipt(ctx, input, options)),
|
|
1371
|
+
send: (input, options) => sendReceipt(ctx, input, options)
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
function createKassza(options = {}) {
|
|
1375
|
+
const ctx = createAgentContext(options);
|
|
1376
|
+
return {
|
|
1377
|
+
invoices: createInvoicesApi(ctx, options.defaults?.invoice ?? {}),
|
|
1378
|
+
receipts: createReceiptsApi(ctx, options.defaults?.receipt ?? {}),
|
|
1379
|
+
taxpayer: { query: (taxNumber, requestOptions) => queryTaxpayer(ctx, taxNumber, requestOptions) },
|
|
1380
|
+
async verifyCredentials(requestOptions) {
|
|
1381
|
+
try {
|
|
1382
|
+
await getInvoicePdf(ctx, CREDENTIAL_PROBE_INVOICE_NUMBER, requestOptions);
|
|
1383
|
+
return true;
|
|
1384
|
+
} catch (error) {
|
|
1385
|
+
if (!require_errors.isSzamlazzError(error)) throw error;
|
|
1386
|
+
if (error.category === "auth") return false;
|
|
1387
|
+
if (error.isNotFound || error.code === 7) return true;
|
|
1388
|
+
throw error;
|
|
1389
|
+
}
|
|
1390
|
+
},
|
|
1391
|
+
resetSession: () => ctx.resetSession()
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
//#endregion
|
|
1395
|
+
exports.AGENT_ACTIONS = require_create.AGENT_ACTIONS;
|
|
1396
|
+
exports.AGENT_ERROR_CODES = require_errors.AGENT_ERROR_CODES;
|
|
1397
|
+
exports.MAX_INVOICE_ATTACHMENTS = require_create.MAX_INVOICE_ATTACHMENTS;
|
|
1398
|
+
exports.SZAMLAZZ_AGENT_URL = require_create.SZAMLAZZ_AGENT_URL;
|
|
1399
|
+
exports.SzamlazzError = require_errors.SzamlazzError;
|
|
1400
|
+
exports.addBudapestDays = require_dates.addBudapestDays;
|
|
1401
|
+
exports.bytesToBase64 = require_binary.bytesToBase64;
|
|
1402
|
+
exports.createKassza = createKassza;
|
|
1403
|
+
exports.isSzamlazzError = require_errors.isSzamlazzError;
|
|
1404
|
+
exports.memoryCookieStore = require_session.memoryCookieStore;
|
|
1405
|
+
exports.toBudapestDate = require_dates.toBudapestDate;
|
|
1406
|
+
exports.todayInBudapest = require_dates.todayInBudapest;
|