kassza 0.12.0 → 0.14.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.en.md +48 -0
- package/README.md +427 -32
- package/agents/README.md +26 -6
- package/agents/api.md +218 -3
- package/agents/pitfalls.md +27 -3
- package/agents/recipes.md +280 -51
- package/agents/skills/kassza/SKILL.md +14 -8
- package/agents/skills/migrate-from-szamlazz-js/SKILL.md +39 -0
- package/dist/batch/index.cjs +346 -0
- package/dist/batch/index.d.cts +91 -0
- package/dist/batch/index.d.ts +91 -0
- package/dist/batch/index.js +339 -0
- package/dist/cli.cjs +643 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +643 -0
- package/dist/client-CLFvJCVW.cjs +1452 -0
- package/dist/{client-CL3fuH6A.js → client-Cvf-hTz_.js} +306 -515
- package/dist/client-DeWWQ-RZ.d.ts +341 -0
- package/dist/client-SVZu25MB.d.cts +341 -0
- package/dist/context-CFNKzStE.d.cts +449 -0
- package/dist/context-kb33TgzE.d.ts +449 -0
- package/dist/cookie-stores/index.cjs +21 -150
- package/dist/cookie-stores/index.d.cts +4 -63
- package/dist/cookie-stores/index.d.ts +4 -63
- package/dist/cookie-stores/index.js +3 -144
- package/dist/create-CflXrPip.js +204 -0
- package/dist/create-CvUvLUaT.cjs +257 -0
- package/dist/{create-once-D0pwuenl.cjs → create-once-9yxR_Er_.cjs} +291 -33
- package/dist/create-once-Bh6fOWkW.d.cts +20 -0
- package/dist/{create-once-CqdYmQD8.js → create-once-Ca2gMk1h.js} +250 -34
- package/dist/create-once-VKp0tVow.d.ts +20 -0
- 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 +29 -0
- package/dist/data-link/index.d.ts +29 -0
- package/dist/data-link/index.js +224 -0
- package/dist/delegation/index.cjs +35 -34
- package/dist/delegation/index.d.cts +2 -1
- package/dist/delegation/index.d.ts +2 -1
- package/dist/delegation/index.js +4 -3
- package/dist/{errors-DLrb0g64.js → errors-DtN4g5Z9.js} +9 -1
- package/dist/{errors-DxeuTslP.cjs → errors-EE96_6D_.cjs} +20 -0
- package/dist/get-BdMTseh4.cjs +271 -0
- package/dist/get-Byc9T5WO.d.cts +151 -0
- package/dist/get-Byc9T5WO.d.ts +151 -0
- package/dist/get-CZEShCcj.js +260 -0
- package/dist/index-BhUPY_EH.d.cts +109 -0
- package/dist/index-BqGgQ4t3.d.ts +109 -0
- package/dist/{index-CYAGCdKJ.d.cts → index-C-7yWV7L.d.cts} +24 -1
- package/dist/{index-CYAGCdKJ.d.ts → index-C-7yWV7L.d.ts} +24 -1
- package/dist/index.cjs +19 -5
- package/dist/index.d.cts +11 -19
- package/dist/index.d.ts +11 -19
- package/dist/index.js +6 -6
- package/dist/ipn/index.cjs +26 -5
- package/dist/ipn/index.d.cts +12 -1
- package/dist/ipn/index.d.ts +12 -1
- package/dist/ipn/index.js +26 -6
- package/dist/issue-Bin4tKD_.cjs +988 -0
- package/dist/issue-DMA1Nbr1.js +905 -0
- package/dist/journal/index.cjs +454 -0
- package/dist/journal/index.d.cts +18 -0
- package/dist/journal/index.d.ts +18 -0
- package/dist/journal/index.js +445 -0
- package/dist/journal-DvI81Kt7.d.cts +114 -0
- package/dist/journal-Y9qrIB8G.d.ts +114 -0
- 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 +2 -1
- package/dist/money/index.d.cts +2 -2
- package/dist/money/index.d.ts +2 -2
- package/dist/money/index.js +2 -2
- package/dist/{money-DAA7OwiO.js → money-Cw457SD6.js} +120 -12
- package/dist/{money-DrhGkWHW.cjs → money-K9j0wPit.cjs} +124 -10
- 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-BNbc8U0R.cjs +203 -0
- package/dist/nav-BcCerwWS.js +156 -0
- package/dist/node/index.cjs +124 -0
- package/dist/node/index.d.cts +35 -0
- package/dist/node/index.d.ts +35 -0
- package/dist/node/index.js +120 -0
- package/dist/observe/index.cjs +311 -0
- package/dist/observe/index.d.cts +53 -0
- package/dist/observe/index.d.ts +53 -0
- package/dist/observe/index.js +303 -0
- package/dist/once-BN_3B5OF.cjs +103 -0
- package/dist/once-CqqZxsXG.js +74 -0
- package/dist/parse-Cr7yQ3_z.js +291 -0
- package/dist/parse-DOA2XQ3e.cjs +380 -0
- package/dist/payments/barion.cjs +26 -2
- package/dist/payments/barion.d.cts +2 -2
- package/dist/payments/barion.d.ts +2 -2
- package/dist/payments/barion.js +26 -2
- package/dist/payments/index.cjs +7 -2
- package/dist/payments/index.d.cts +4 -4
- package/dist/payments/index.d.ts +4 -4
- package/dist/payments/index.js +3 -3
- package/dist/payments/paypal.cjs +16 -2
- package/dist/payments/paypal.d.cts +2 -2
- package/dist/payments/paypal.d.ts +2 -2
- package/dist/payments/paypal.js +16 -2
- package/dist/payments/revolut.cjs +17 -3
- package/dist/payments/revolut.d.cts +2 -2
- package/dist/payments/revolut.d.ts +2 -2
- package/dist/payments/revolut.js +17 -3
- package/dist/payments/simplepay.cjs +37 -5
- package/dist/payments/simplepay.d.cts +2 -2
- package/dist/payments/simplepay.d.ts +2 -2
- package/dist/payments/simplepay.js +37 -5
- package/dist/payments/stripe.cjs +20 -3
- package/dist/payments/stripe.d.cts +2 -2
- package/dist/payments/stripe.d.ts +2 -2
- package/dist/payments/stripe.js +20 -3
- package/dist/push-BXj0Sf0Z.d.ts +52 -0
- package/dist/push-D4nNbCNV.d.cts +52 -0
- package/dist/reference-B5TATqb5.js +124 -0
- package/dist/reference-BIdYMK0t.cjs +183 -0
- package/dist/reports/index.cjs +11 -164
- package/dist/reports/index.d.cts +1 -1
- package/dist/reports/index.d.ts +1 -1
- 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-B2eFh3D-.js +219 -0
- package/dist/serialize-CquIsxA-.cjs +290 -0
- package/dist/server-BrJUbXs7.js +1505 -0
- package/dist/server-Dw9j8Mnd.cjs +1558 -0
- package/dist/session-Ckl5eJhV.d.ts +7 -0
- package/dist/{session-CKOuE6Jc.cjs → session-DeM5vjvC.cjs} +69 -13
- package/dist/{session-rMKaJcmq.js → session-SaEEXu2N.js} +58 -14
- package/dist/session-YbChChx7.d.cts +7 -0
- package/dist/storage/fs.cjs +1 -1
- package/dist/storage/fs.js +1 -1
- package/dist/storage/index.cjs +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/store-C1rHd9DB.d.cts +19 -0
- package/dist/store-C1rHd9DB.d.ts +19 -0
- package/dist/stores/index.cjs +24 -0
- package/dist/stores/index.d.cts +4 -0
- package/dist/stores/index.d.ts +4 -0
- package/dist/stores/index.js +3 -0
- package/dist/stores-BNrS0dWl.cjs +506 -0
- package/dist/stores-DhjGBrl_.js +441 -0
- package/dist/testing/index.cjs +1500 -15
- package/dist/testing/index.d.cts +198 -3
- package/dist/testing/index.d.ts +198 -3
- package/dist/testing/index.js +1498 -15
- package/dist/{types-COf1LAD-.d.ts → types-B1A8mUIE.d.cts} +14 -2
- package/dist/{types-COf1LAD-.d.cts → types-ByAEvGsZ.d.ts} +14 -2
- package/dist/{types-k--zHf4l.d.ts → types-D1zDOH_F.d.ts} +1 -1
- package/dist/{types-DH8QoNZK.d.cts → types-lnKkQdot.d.cts} +1 -1
- package/dist/warnings-B3DXnveC.d.cts +31 -0
- package/dist/warnings-B3DXnveC.d.ts +31 -0
- package/dist/warnings-DeIw5RFj.cjs +20 -0
- package/dist/warnings-DwTl5J-2.js +15 -0
- package/dist/{webhook-D4lvtex1.js → webhook-CQVShAfI.js} +47 -26
- package/dist/{webhook-C76bV-4R.cjs → webhook-Ckj-_hPD.cjs} +70 -25
- package/dist/webhook-CmdhGiH5.d.cts +11 -0
- package/dist/webhook-D6lEejob.d.ts +11 -0
- package/llms.txt +6 -5
- package/package.json +134 -4
- package/dist/client-CickRRFr.d.ts +0 -838
- package/dist/client-CsmGIFRS.cjs +0 -1637
- package/dist/client-DvWZoX_E.d.cts +0 -838
- package/dist/issue-BsyYdrIG.cjs +0 -1531
- package/dist/issue-C6Fcjvln.js +0 -1274
- package/dist/session-Dm_45x8K.d.cts +0 -11
- package/dist/session-Dm_45x8K.d.ts +0 -11
- package/dist/webhook-CfaDgcL0.d.cts +0 -6
- package/dist/webhook-q2OzNwd7.d.ts +0 -6
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { i as KasszaOptions } from "../client-SVZu25MB.cjs";
|
|
2
|
+
//#region src/mcp/protocol.d.ts
|
|
3
|
+
export declare const MCP_MODERN_VERSIONS: readonly string[];
|
|
4
|
+
export declare const MCP_LEGACY_VERSIONS: readonly string[];
|
|
5
|
+
export declare const MCP_SUPPORTED_VERSIONS: readonly string[];
|
|
6
|
+
type JsonRpcId = string | number;
|
|
7
|
+
type JsonObject = Readonly<Record<string, unknown>>;
|
|
8
|
+
interface JsonRpcSuccess {
|
|
9
|
+
readonly jsonrpc: "2.0";
|
|
10
|
+
readonly id: JsonRpcId;
|
|
11
|
+
readonly result: JsonObject;
|
|
12
|
+
}
|
|
13
|
+
interface JsonRpcErrorObject {
|
|
14
|
+
readonly code: number;
|
|
15
|
+
readonly message: string;
|
|
16
|
+
readonly data?: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface JsonRpcFailure {
|
|
19
|
+
readonly jsonrpc: "2.0";
|
|
20
|
+
readonly id: JsonRpcId | null;
|
|
21
|
+
readonly error: JsonRpcErrorObject;
|
|
22
|
+
}
|
|
23
|
+
type JsonRpcResponse = JsonRpcSuccess | JsonRpcFailure;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/mcp/arguments.d.ts
|
|
26
|
+
export declare class ToolInputError extends Error {
|
|
27
|
+
override readonly name: string;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/mcp/confirmation.d.ts
|
|
31
|
+
export declare const DEFAULT_CONFIRMATION_TTL_MS = 9e5;
|
|
32
|
+
interface ConfirmationOptions {
|
|
33
|
+
readonly secret?: string | Uint8Array | undefined;
|
|
34
|
+
readonly ttlMs?: number | undefined;
|
|
35
|
+
readonly now: () => Date;
|
|
36
|
+
}
|
|
37
|
+
interface IssuedConfirmation {
|
|
38
|
+
readonly token: string;
|
|
39
|
+
readonly expiresAt: string;
|
|
40
|
+
}
|
|
41
|
+
interface Confirmations {
|
|
42
|
+
issue(action: string, payload: unknown): Promise<IssuedConfirmation>;
|
|
43
|
+
verify(action: string, payload: unknown, token: unknown, previewTool: string): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export declare function canonicalJson(value: unknown): string;
|
|
46
|
+
export declare function createConfirmations(options: ConfirmationOptions): Confirmations;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/mcp/server.d.ts
|
|
49
|
+
interface KasszaMcpServerOptions extends KasszaOptions {
|
|
50
|
+
readonly allowWrite?: boolean | undefined;
|
|
51
|
+
readonly confirmationSecret?: string | Uint8Array | undefined;
|
|
52
|
+
readonly confirmationTtlMs?: number | undefined;
|
|
53
|
+
readonly recoveryDelayMs?: number | undefined;
|
|
54
|
+
readonly now?: (() => Date) | undefined;
|
|
55
|
+
}
|
|
56
|
+
interface McpToolInfo {
|
|
57
|
+
readonly name: string;
|
|
58
|
+
readonly title: string;
|
|
59
|
+
readonly write: boolean;
|
|
60
|
+
}
|
|
61
|
+
interface McpConnection {
|
|
62
|
+
handle(message: unknown): Promise<JsonRpcResponse | readonly JsonRpcResponse[] | undefined>;
|
|
63
|
+
handleLine(line: string): Promise<string | undefined>;
|
|
64
|
+
}
|
|
65
|
+
interface KasszaMcpServer {
|
|
66
|
+
readonly tools: readonly McpToolInfo[];
|
|
67
|
+
connect(): McpConnection;
|
|
68
|
+
}
|
|
69
|
+
export declare function createKasszaMcpServer(options?: KasszaMcpServerOptions): KasszaMcpServer;
|
|
70
|
+
//#endregion
|
|
71
|
+
export type { Confirmations, IssuedConfirmation, JsonRpcFailure, JsonRpcId, JsonRpcResponse, JsonRpcSuccess, KasszaMcpServer, KasszaMcpServerOptions, McpConnection, McpToolInfo };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { i as KasszaOptions } from "../client-DeWWQ-RZ.js";
|
|
2
|
+
//#region src/mcp/protocol.d.ts
|
|
3
|
+
export declare const MCP_MODERN_VERSIONS: readonly string[];
|
|
4
|
+
export declare const MCP_LEGACY_VERSIONS: readonly string[];
|
|
5
|
+
export declare const MCP_SUPPORTED_VERSIONS: readonly string[];
|
|
6
|
+
type JsonRpcId = string | number;
|
|
7
|
+
type JsonObject = Readonly<Record<string, unknown>>;
|
|
8
|
+
interface JsonRpcSuccess {
|
|
9
|
+
readonly jsonrpc: "2.0";
|
|
10
|
+
readonly id: JsonRpcId;
|
|
11
|
+
readonly result: JsonObject;
|
|
12
|
+
}
|
|
13
|
+
interface JsonRpcErrorObject {
|
|
14
|
+
readonly code: number;
|
|
15
|
+
readonly message: string;
|
|
16
|
+
readonly data?: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface JsonRpcFailure {
|
|
19
|
+
readonly jsonrpc: "2.0";
|
|
20
|
+
readonly id: JsonRpcId | null;
|
|
21
|
+
readonly error: JsonRpcErrorObject;
|
|
22
|
+
}
|
|
23
|
+
type JsonRpcResponse = JsonRpcSuccess | JsonRpcFailure;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/mcp/arguments.d.ts
|
|
26
|
+
export declare class ToolInputError extends Error {
|
|
27
|
+
override readonly name: string;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/mcp/confirmation.d.ts
|
|
31
|
+
export declare const DEFAULT_CONFIRMATION_TTL_MS = 9e5;
|
|
32
|
+
interface ConfirmationOptions {
|
|
33
|
+
readonly secret?: string | Uint8Array | undefined;
|
|
34
|
+
readonly ttlMs?: number | undefined;
|
|
35
|
+
readonly now: () => Date;
|
|
36
|
+
}
|
|
37
|
+
interface IssuedConfirmation {
|
|
38
|
+
readonly token: string;
|
|
39
|
+
readonly expiresAt: string;
|
|
40
|
+
}
|
|
41
|
+
interface Confirmations {
|
|
42
|
+
issue(action: string, payload: unknown): Promise<IssuedConfirmation>;
|
|
43
|
+
verify(action: string, payload: unknown, token: unknown, previewTool: string): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export declare function canonicalJson(value: unknown): string;
|
|
46
|
+
export declare function createConfirmations(options: ConfirmationOptions): Confirmations;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/mcp/server.d.ts
|
|
49
|
+
interface KasszaMcpServerOptions extends KasszaOptions {
|
|
50
|
+
readonly allowWrite?: boolean | undefined;
|
|
51
|
+
readonly confirmationSecret?: string | Uint8Array | undefined;
|
|
52
|
+
readonly confirmationTtlMs?: number | undefined;
|
|
53
|
+
readonly recoveryDelayMs?: number | undefined;
|
|
54
|
+
readonly now?: (() => Date) | undefined;
|
|
55
|
+
}
|
|
56
|
+
interface McpToolInfo {
|
|
57
|
+
readonly name: string;
|
|
58
|
+
readonly title: string;
|
|
59
|
+
readonly write: boolean;
|
|
60
|
+
}
|
|
61
|
+
interface McpConnection {
|
|
62
|
+
handle(message: unknown): Promise<JsonRpcResponse | readonly JsonRpcResponse[] | undefined>;
|
|
63
|
+
handleLine(line: string): Promise<string | undefined>;
|
|
64
|
+
}
|
|
65
|
+
interface KasszaMcpServer {
|
|
66
|
+
readonly tools: readonly McpToolInfo[];
|
|
67
|
+
connect(): McpConnection;
|
|
68
|
+
}
|
|
69
|
+
export declare function createKasszaMcpServer(options?: KasszaMcpServerOptions): KasszaMcpServer;
|
|
70
|
+
//#endregion
|
|
71
|
+
export type { Confirmations, IssuedConfirmation, JsonRpcFailure, JsonRpcId, JsonRpcResponse, JsonRpcSuccess, KasszaMcpServer, KasszaMcpServerOptions, McpConnection, McpToolInfo };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as createConfirmations, c as MCP_MODERN_VERSIONS, i as canonicalJson, l as MCP_SUPPORTED_VERSIONS, o as ToolInputError, r as DEFAULT_CONFIRMATION_TTL_MS, s as MCP_LEGACY_VERSIONS, t as createKasszaMcpServer } from "../server-BrJUbXs7.js";
|
|
2
|
+
export { DEFAULT_CONFIRMATION_TTL_MS, MCP_LEGACY_VERSIONS, MCP_MODERN_VERSIONS, MCP_SUPPORTED_VERSIONS, ToolInputError, canonicalJson, createConfirmations, createKasszaMcpServer };
|
package/dist/money/index.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rounding = require("../rounding-TxoWy2ww.cjs");
|
|
3
3
|
const require_vat = require("../vat-g35srbNG.cjs");
|
|
4
|
-
const require_money = require("../money-
|
|
4
|
+
const require_money = require("../money-K9j0wPit.cjs");
|
|
5
5
|
exports.NUMERIC_VAT_RATES = require_vat.NUMERIC_VAT_RATES;
|
|
6
6
|
exports.SPECIAL_VAT_CODES = require_vat.SPECIAL_VAT_CODES;
|
|
7
7
|
exports.addMoney = require_rounding.addMoney;
|
|
8
|
+
exports.allocateRefund = require_money.allocateRefund;
|
|
8
9
|
exports.calculateInvoiceItem = require_money.calculateInvoiceItem;
|
|
9
10
|
exports.calculateItemAmounts = require_money.calculateItemAmounts;
|
|
10
11
|
exports.calculateReceiptItem = require_money.calculateReceiptItem;
|
package/dist/money/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { type DocumentKind, type DocumentTotals, type ItemAmounts, type ItemPriceInput, NUMERIC_VAT_RATES, type NumericVatRate, SPECIAL_VAT_CODES, type SpecialVatCode, type VatBreakdown, type VatRate, addMoney, calculateInvoiceItem, calculateItemAmounts, calculateReceiptItem, decimalPlaces, formatVatRate, isHuf, isVatRate, roundMoney, summarizeItems, vatPercentage };
|
|
1
|
+
import { C as formatVatRate, E as vatPercentage, S as VatRate, T as isVatRate, _ as summarizeItems, a as RefundAllocation, b as SPECIAL_VAT_CODES, c as allocateRefund, d as ItemAmounts, f as ItemPriceInput, g as calculateReceiptItem, h as calculateItemAmounts, i as AllocateRefundOptions, l as DocumentKind, m as calculateInvoiceItem, n as decimalPlaces, o as RefundVat, p as VatBreakdown, r as roundMoney, s as RefundableItem, t as addMoney, u as DocumentTotals, v as NUMERIC_VAT_RATES, w as isHuf, x as SpecialVatCode, y as NumericVatRate } from "../index-C-7yWV7L.cjs";
|
|
2
|
+
export { type AllocateRefundOptions, type DocumentKind, type DocumentTotals, type ItemAmounts, type ItemPriceInput, NUMERIC_VAT_RATES, type NumericVatRate, type RefundAllocation, type RefundVat, type RefundableItem, SPECIAL_VAT_CODES, type SpecialVatCode, type VatBreakdown, type VatRate, addMoney, allocateRefund, calculateInvoiceItem, calculateItemAmounts, calculateReceiptItem, decimalPlaces, formatVatRate, isHuf, isVatRate, roundMoney, summarizeItems, vatPercentage };
|
package/dist/money/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { type DocumentKind, type DocumentTotals, type ItemAmounts, type ItemPriceInput, NUMERIC_VAT_RATES, type NumericVatRate, SPECIAL_VAT_CODES, type SpecialVatCode, type VatBreakdown, type VatRate, addMoney, calculateInvoiceItem, calculateItemAmounts, calculateReceiptItem, decimalPlaces, formatVatRate, isHuf, isVatRate, roundMoney, summarizeItems, vatPercentage };
|
|
1
|
+
import { C as formatVatRate, E as vatPercentage, S as VatRate, T as isVatRate, _ as summarizeItems, a as RefundAllocation, b as SPECIAL_VAT_CODES, c as allocateRefund, d as ItemAmounts, f as ItemPriceInput, g as calculateReceiptItem, h as calculateItemAmounts, i as AllocateRefundOptions, l as DocumentKind, m as calculateInvoiceItem, n as decimalPlaces, o as RefundVat, p as VatBreakdown, r as roundMoney, s as RefundableItem, t as addMoney, u as DocumentTotals, v as NUMERIC_VAT_RATES, w as isHuf, x as SpecialVatCode, y as NumericVatRate } from "../index-C-7yWV7L.js";
|
|
2
|
+
export { type AllocateRefundOptions, type DocumentKind, type DocumentTotals, type ItemAmounts, type ItemPriceInput, NUMERIC_VAT_RATES, type NumericVatRate, type RefundAllocation, type RefundVat, type RefundableItem, SPECIAL_VAT_CODES, type SpecialVatCode, type VatBreakdown, type VatRate, addMoney, allocateRefund, calculateInvoiceItem, calculateItemAmounts, calculateReceiptItem, decimalPlaces, formatVatRate, isHuf, isVatRate, roundMoney, summarizeItems, vatPercentage };
|
package/dist/money/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { n as decimalPlaces, r as roundMoney, t as addMoney } from "../rounding-BLyHjjI5.js";
|
|
2
2
|
import { a as isVatRate, i as isHuf, n as SPECIAL_VAT_CODES, o as vatPercentage, r as formatVatRate, t as NUMERIC_VAT_RATES } from "../vat-v_dcWCto.js";
|
|
3
|
-
import {
|
|
4
|
-
export { NUMERIC_VAT_RATES, SPECIAL_VAT_CODES, addMoney, calculateInvoiceItem, calculateItemAmounts, calculateReceiptItem, decimalPlaces, formatVatRate, isHuf, isVatRate, roundMoney, summarizeItems, vatPercentage };
|
|
3
|
+
import { a as summarizeItems, i as calculateReceiptItem, n as calculateInvoiceItem, r as calculateItemAmounts, t as allocateRefund } from "../money-Cw457SD6.js";
|
|
4
|
+
export { NUMERIC_VAT_RATES, SPECIAL_VAT_CODES, addMoney, allocateRefund, calculateInvoiceItem, calculateItemAmounts, calculateReceiptItem, decimalPlaces, formatVatRate, isHuf, isVatRate, roundMoney, summarizeItems, vatPercentage };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as roundMoney } from "./rounding-BLyHjjI5.js";
|
|
1
|
+
import { r as SzamlazzError } from "./errors-DtN4g5Z9.js";
|
|
2
|
+
import { n as decimalPlaces, r as roundMoney } from "./rounding-BLyHjjI5.js";
|
|
3
3
|
import { a as isVatRate, i as isHuf, o as vatPercentage } from "./vat-v_dcWCto.js";
|
|
4
4
|
//#region src/money/items.ts
|
|
5
5
|
const FOREIGN_CURRENCY_DECIMALS = 2;
|
|
@@ -36,27 +36,44 @@ function roundingRuleFor(kind, currency) {
|
|
|
36
36
|
grossDecimals: 0
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
+
function splitGross(grossAmount, percentage, rule) {
|
|
40
|
+
const vatAmount = roundMoney(grossAmount * percentage / (100 + percentage), rule.vatDecimals);
|
|
41
|
+
return {
|
|
42
|
+
netAmount: roundMoney(grossAmount - vatAmount, rule.netDecimals),
|
|
43
|
+
vatAmount
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function hasConsistentVat(netAmount, vatAmount, percentage) {
|
|
47
|
+
if (percentage === 0) return vatAmount === 0;
|
|
48
|
+
return Math.sign(vatAmount) === Math.sign(netAmount);
|
|
49
|
+
}
|
|
39
50
|
function fromNet(input, quantity, rule) {
|
|
40
51
|
const percentage = vatPercentage(input.vat);
|
|
52
|
+
const base = {
|
|
53
|
+
quantity,
|
|
54
|
+
vat: input.vat,
|
|
55
|
+
netUnitPrice: input.netUnitPrice
|
|
56
|
+
};
|
|
41
57
|
const netAmount = roundMoney(input.netUnitPrice * quantity, rule.netDecimals);
|
|
42
58
|
if (rule.grossDecimals < rule.netDecimals) {
|
|
43
59
|
const grossAmount = roundMoney(netAmount * (1 + percentage / 100), rule.grossDecimals);
|
|
44
60
|
const vatAmount = roundMoney(grossAmount - netAmount, rule.vatDecimals);
|
|
45
|
-
return {
|
|
46
|
-
|
|
47
|
-
vat: input.vat,
|
|
48
|
-
netUnitPrice: input.netUnitPrice,
|
|
61
|
+
if (hasConsistentVat(netAmount, vatAmount, percentage)) return {
|
|
62
|
+
...base,
|
|
49
63
|
netAmount,
|
|
50
64
|
vatAmount,
|
|
51
65
|
grossAmount
|
|
52
66
|
};
|
|
67
|
+
return {
|
|
68
|
+
...base,
|
|
69
|
+
...splitGross(grossAmount, percentage, rule),
|
|
70
|
+
grossAmount
|
|
71
|
+
};
|
|
53
72
|
}
|
|
54
73
|
const vatAmount = roundMoney(netAmount * percentage / 100, rule.vatDecimals);
|
|
55
74
|
const grossAmount = roundMoney(netAmount + vatAmount, rule.grossDecimals);
|
|
56
75
|
return {
|
|
57
|
-
|
|
58
|
-
vat: input.vat,
|
|
59
|
-
netUnitPrice: input.netUnitPrice,
|
|
76
|
+
...base,
|
|
60
77
|
netAmount,
|
|
61
78
|
vatAmount,
|
|
62
79
|
grossAmount
|
|
@@ -65,8 +82,7 @@ function fromNet(input, quantity, rule) {
|
|
|
65
82
|
function fromGross(input, quantity, rule) {
|
|
66
83
|
const percentage = vatPercentage(input.vat);
|
|
67
84
|
const grossAmount = roundMoney(input.grossUnitPrice * quantity, rule.grossDecimals);
|
|
68
|
-
const vatAmount =
|
|
69
|
-
const netAmount = roundMoney(grossAmount - vatAmount, rule.netDecimals);
|
|
85
|
+
const { netAmount, vatAmount } = splitGross(grossAmount, percentage, rule);
|
|
70
86
|
return {
|
|
71
87
|
quantity,
|
|
72
88
|
vat: input.vat,
|
|
@@ -158,4 +174,96 @@ function summarizeItems(items) {
|
|
|
158
174
|
};
|
|
159
175
|
}
|
|
160
176
|
//#endregion
|
|
161
|
-
|
|
177
|
+
//#region src/money/refund.ts
|
|
178
|
+
function invalid(message) {
|
|
179
|
+
return new SzamlazzError(message, { category: "validation" });
|
|
180
|
+
}
|
|
181
|
+
function toMinor(value, decimals, field) {
|
|
182
|
+
if (!Number.isFinite(value)) throw invalid(`A(z) ${field} nem véges szám: ${value}`);
|
|
183
|
+
if (decimalPlaces(value) > decimals) throw invalid(`A(z) ${field} (${value}) több tizedesjegyet tartalmaz, mint amennyit a bizonylat pénzneme enged (${decimals}).`);
|
|
184
|
+
return BigInt(Math.round(Number((value * 10 ** decimals).toPrecision(15))));
|
|
185
|
+
}
|
|
186
|
+
function fromMinor(value, decimals) {
|
|
187
|
+
return Number(value) / 10 ** decimals;
|
|
188
|
+
}
|
|
189
|
+
function resolveDecimals(value) {
|
|
190
|
+
if (value === void 0) return 0;
|
|
191
|
+
if (!Number.isInteger(value) || value < 0 || value > 6) throw invalid(`A decimals értéke 0 és 6 közötti egész legyen, kapott: ${value}`);
|
|
192
|
+
return value;
|
|
193
|
+
}
|
|
194
|
+
function outranks(weights, first, firstUnit, second, secondUnit) {
|
|
195
|
+
const left = (weights[first] ?? 0n) * (2n * secondUnit + 1n);
|
|
196
|
+
const right = (weights[second] ?? 0n) * (2n * firstUnit + 1n);
|
|
197
|
+
if (left !== right) return left > right;
|
|
198
|
+
return first < second;
|
|
199
|
+
}
|
|
200
|
+
function bestOpen(weights, shares) {
|
|
201
|
+
let best = -1;
|
|
202
|
+
for (let index = 0; index < weights.length; index++) {
|
|
203
|
+
const share = shares[index] ?? 0n;
|
|
204
|
+
if (share >= (weights[index] ?? 0n)) continue;
|
|
205
|
+
if (best === -1 || outranks(weights, index, share, best, shares[best] ?? 0n)) best = index;
|
|
206
|
+
}
|
|
207
|
+
return best;
|
|
208
|
+
}
|
|
209
|
+
function worstTaken(weights, shares) {
|
|
210
|
+
let worst = -1;
|
|
211
|
+
for (let index = 0; index < weights.length; index++) {
|
|
212
|
+
const share = shares[index] ?? 0n;
|
|
213
|
+
if (share === 0n) continue;
|
|
214
|
+
if (worst === -1 || outranks(weights, worst, (shares[worst] ?? 0n) - 1n, index, share - 1n)) worst = index;
|
|
215
|
+
}
|
|
216
|
+
return worst;
|
|
217
|
+
}
|
|
218
|
+
function apportion(weights, amount) {
|
|
219
|
+
const total = weights.reduce((sum, weight) => sum + weight, 0n);
|
|
220
|
+
if (amount === 0n || total === 0n) return weights.map(() => 0n);
|
|
221
|
+
if (amount === total) return [...weights];
|
|
222
|
+
const shares = weights.map((weight) => amount * weight / total);
|
|
223
|
+
let left = amount - shares.reduce((sum, share) => sum + share, 0n);
|
|
224
|
+
while (left > 0n) {
|
|
225
|
+
const best = bestOpen(weights, shares);
|
|
226
|
+
shares[best] = (shares[best] ?? 0n) + 1n;
|
|
227
|
+
left -= 1n;
|
|
228
|
+
}
|
|
229
|
+
for (;;) {
|
|
230
|
+
const best = bestOpen(weights, shares);
|
|
231
|
+
const worst = worstTaken(weights, shares);
|
|
232
|
+
if (best === -1 || worst === -1 || best === worst) break;
|
|
233
|
+
if (!outranks(weights, best, shares[best] ?? 0n, worst, (shares[worst] ?? 0n) - 1n)) break;
|
|
234
|
+
shares[best] = (shares[best] ?? 0n) + 1n;
|
|
235
|
+
shares[worst] = (shares[worst] ?? 0n) - 1n;
|
|
236
|
+
}
|
|
237
|
+
return shares;
|
|
238
|
+
}
|
|
239
|
+
function allocateRefund(items, refundGross, options = {}) {
|
|
240
|
+
const decimals = resolveDecimals(options.decimals);
|
|
241
|
+
if (items.length === 0) throw invalid("A visszatérítés szétosztásához legalább egy tétel kell.");
|
|
242
|
+
const gross = items.map((item, index) => {
|
|
243
|
+
const minor = toMinor(item.grossAmount, decimals, `${index + 1}. tétel bruttó összege`);
|
|
244
|
+
if (minor < 0n) throw invalid(`A(z) ${index + 1}. tétel bruttó összege negatív.`);
|
|
245
|
+
return minor;
|
|
246
|
+
});
|
|
247
|
+
const total = gross.reduce((sum, value) => sum + value, 0n);
|
|
248
|
+
const refund = toMinor(refundGross, decimals, "visszatérített összeg");
|
|
249
|
+
const before = toMinor(options.refundedBefore ?? 0, decimals, "korábban visszatérített összeg");
|
|
250
|
+
if (refund <= 0n) throw invalid("A visszatérített összeg legyen pozitív.");
|
|
251
|
+
if (before < 0n) throw invalid("A korábban visszatérített összeg nem lehet negatív.");
|
|
252
|
+
if (before + refund > total) throw invalid(`A visszatérítések összege (${fromMinor(before + refund, decimals)}) nagyobb, mint az eredeti bizonylat bruttó összege (${fromMinor(total, decimals)}).`);
|
|
253
|
+
const earlier = apportion(gross, before);
|
|
254
|
+
const shares = apportion(gross, before + refund).map((value, index) => value - (earlier[index] ?? 0n));
|
|
255
|
+
return items.flatMap((item, index) => {
|
|
256
|
+
const share = shares[index] ?? 0n;
|
|
257
|
+
if (share === 0n) return [];
|
|
258
|
+
return [{
|
|
259
|
+
index,
|
|
260
|
+
name: item.name,
|
|
261
|
+
vat: item.vat,
|
|
262
|
+
grossAmount: fromMinor(share, decimals),
|
|
263
|
+
...item.unit === void 0 ? {} : { unit: item.unit },
|
|
264
|
+
...item.identifier === void 0 ? {} : { identifier: item.identifier }
|
|
265
|
+
}];
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
269
|
+
export { summarizeItems as a, calculateReceiptItem as i, calculateInvoiceItem as n, calculateItemAmounts as r, allocateRefund as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_errors = require("./errors-
|
|
1
|
+
const require_errors = require("./errors-EE96_6D_.cjs");
|
|
2
2
|
const require_rounding = require("./rounding-TxoWy2ww.cjs");
|
|
3
3
|
const require_vat = require("./vat-g35srbNG.cjs");
|
|
4
4
|
//#region src/money/items.ts
|
|
@@ -36,27 +36,44 @@ function roundingRuleFor(kind, currency) {
|
|
|
36
36
|
grossDecimals: 0
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
+
function splitGross(grossAmount, percentage, rule) {
|
|
40
|
+
const vatAmount = require_rounding.roundMoney(grossAmount * percentage / (100 + percentage), rule.vatDecimals);
|
|
41
|
+
return {
|
|
42
|
+
netAmount: require_rounding.roundMoney(grossAmount - vatAmount, rule.netDecimals),
|
|
43
|
+
vatAmount
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function hasConsistentVat(netAmount, vatAmount, percentage) {
|
|
47
|
+
if (percentage === 0) return vatAmount === 0;
|
|
48
|
+
return Math.sign(vatAmount) === Math.sign(netAmount);
|
|
49
|
+
}
|
|
39
50
|
function fromNet(input, quantity, rule) {
|
|
40
51
|
const percentage = require_vat.vatPercentage(input.vat);
|
|
52
|
+
const base = {
|
|
53
|
+
quantity,
|
|
54
|
+
vat: input.vat,
|
|
55
|
+
netUnitPrice: input.netUnitPrice
|
|
56
|
+
};
|
|
41
57
|
const netAmount = require_rounding.roundMoney(input.netUnitPrice * quantity, rule.netDecimals);
|
|
42
58
|
if (rule.grossDecimals < rule.netDecimals) {
|
|
43
59
|
const grossAmount = require_rounding.roundMoney(netAmount * (1 + percentage / 100), rule.grossDecimals);
|
|
44
60
|
const vatAmount = require_rounding.roundMoney(grossAmount - netAmount, rule.vatDecimals);
|
|
45
|
-
return {
|
|
46
|
-
|
|
47
|
-
vat: input.vat,
|
|
48
|
-
netUnitPrice: input.netUnitPrice,
|
|
61
|
+
if (hasConsistentVat(netAmount, vatAmount, percentage)) return {
|
|
62
|
+
...base,
|
|
49
63
|
netAmount,
|
|
50
64
|
vatAmount,
|
|
51
65
|
grossAmount
|
|
52
66
|
};
|
|
67
|
+
return {
|
|
68
|
+
...base,
|
|
69
|
+
...splitGross(grossAmount, percentage, rule),
|
|
70
|
+
grossAmount
|
|
71
|
+
};
|
|
53
72
|
}
|
|
54
73
|
const vatAmount = require_rounding.roundMoney(netAmount * percentage / 100, rule.vatDecimals);
|
|
55
74
|
const grossAmount = require_rounding.roundMoney(netAmount + vatAmount, rule.grossDecimals);
|
|
56
75
|
return {
|
|
57
|
-
|
|
58
|
-
vat: input.vat,
|
|
59
|
-
netUnitPrice: input.netUnitPrice,
|
|
76
|
+
...base,
|
|
60
77
|
netAmount,
|
|
61
78
|
vatAmount,
|
|
62
79
|
grossAmount
|
|
@@ -65,8 +82,7 @@ function fromNet(input, quantity, rule) {
|
|
|
65
82
|
function fromGross(input, quantity, rule) {
|
|
66
83
|
const percentage = require_vat.vatPercentage(input.vat);
|
|
67
84
|
const grossAmount = require_rounding.roundMoney(input.grossUnitPrice * quantity, rule.grossDecimals);
|
|
68
|
-
const vatAmount =
|
|
69
|
-
const netAmount = require_rounding.roundMoney(grossAmount - vatAmount, rule.netDecimals);
|
|
85
|
+
const { netAmount, vatAmount } = splitGross(grossAmount, percentage, rule);
|
|
70
86
|
return {
|
|
71
87
|
quantity,
|
|
72
88
|
vat: input.vat,
|
|
@@ -158,6 +174,104 @@ function summarizeItems(items) {
|
|
|
158
174
|
};
|
|
159
175
|
}
|
|
160
176
|
//#endregion
|
|
177
|
+
//#region src/money/refund.ts
|
|
178
|
+
function invalid(message) {
|
|
179
|
+
return new require_errors.SzamlazzError(message, { category: "validation" });
|
|
180
|
+
}
|
|
181
|
+
function toMinor(value, decimals, field) {
|
|
182
|
+
if (!Number.isFinite(value)) throw invalid(`A(z) ${field} nem véges szám: ${value}`);
|
|
183
|
+
if (require_rounding.decimalPlaces(value) > decimals) throw invalid(`A(z) ${field} (${value}) több tizedesjegyet tartalmaz, mint amennyit a bizonylat pénzneme enged (${decimals}).`);
|
|
184
|
+
return BigInt(Math.round(Number((value * 10 ** decimals).toPrecision(15))));
|
|
185
|
+
}
|
|
186
|
+
function fromMinor(value, decimals) {
|
|
187
|
+
return Number(value) / 10 ** decimals;
|
|
188
|
+
}
|
|
189
|
+
function resolveDecimals(value) {
|
|
190
|
+
if (value === void 0) return 0;
|
|
191
|
+
if (!Number.isInteger(value) || value < 0 || value > 6) throw invalid(`A decimals értéke 0 és 6 közötti egész legyen, kapott: ${value}`);
|
|
192
|
+
return value;
|
|
193
|
+
}
|
|
194
|
+
function outranks(weights, first, firstUnit, second, secondUnit) {
|
|
195
|
+
const left = (weights[first] ?? 0n) * (2n * secondUnit + 1n);
|
|
196
|
+
const right = (weights[second] ?? 0n) * (2n * firstUnit + 1n);
|
|
197
|
+
if (left !== right) return left > right;
|
|
198
|
+
return first < second;
|
|
199
|
+
}
|
|
200
|
+
function bestOpen(weights, shares) {
|
|
201
|
+
let best = -1;
|
|
202
|
+
for (let index = 0; index < weights.length; index++) {
|
|
203
|
+
const share = shares[index] ?? 0n;
|
|
204
|
+
if (share >= (weights[index] ?? 0n)) continue;
|
|
205
|
+
if (best === -1 || outranks(weights, index, share, best, shares[best] ?? 0n)) best = index;
|
|
206
|
+
}
|
|
207
|
+
return best;
|
|
208
|
+
}
|
|
209
|
+
function worstTaken(weights, shares) {
|
|
210
|
+
let worst = -1;
|
|
211
|
+
for (let index = 0; index < weights.length; index++) {
|
|
212
|
+
const share = shares[index] ?? 0n;
|
|
213
|
+
if (share === 0n) continue;
|
|
214
|
+
if (worst === -1 || outranks(weights, worst, (shares[worst] ?? 0n) - 1n, index, share - 1n)) worst = index;
|
|
215
|
+
}
|
|
216
|
+
return worst;
|
|
217
|
+
}
|
|
218
|
+
function apportion(weights, amount) {
|
|
219
|
+
const total = weights.reduce((sum, weight) => sum + weight, 0n);
|
|
220
|
+
if (amount === 0n || total === 0n) return weights.map(() => 0n);
|
|
221
|
+
if (amount === total) return [...weights];
|
|
222
|
+
const shares = weights.map((weight) => amount * weight / total);
|
|
223
|
+
let left = amount - shares.reduce((sum, share) => sum + share, 0n);
|
|
224
|
+
while (left > 0n) {
|
|
225
|
+
const best = bestOpen(weights, shares);
|
|
226
|
+
shares[best] = (shares[best] ?? 0n) + 1n;
|
|
227
|
+
left -= 1n;
|
|
228
|
+
}
|
|
229
|
+
for (;;) {
|
|
230
|
+
const best = bestOpen(weights, shares);
|
|
231
|
+
const worst = worstTaken(weights, shares);
|
|
232
|
+
if (best === -1 || worst === -1 || best === worst) break;
|
|
233
|
+
if (!outranks(weights, best, shares[best] ?? 0n, worst, (shares[worst] ?? 0n) - 1n)) break;
|
|
234
|
+
shares[best] = (shares[best] ?? 0n) + 1n;
|
|
235
|
+
shares[worst] = (shares[worst] ?? 0n) - 1n;
|
|
236
|
+
}
|
|
237
|
+
return shares;
|
|
238
|
+
}
|
|
239
|
+
function allocateRefund(items, refundGross, options = {}) {
|
|
240
|
+
const decimals = resolveDecimals(options.decimals);
|
|
241
|
+
if (items.length === 0) throw invalid("A visszatérítés szétosztásához legalább egy tétel kell.");
|
|
242
|
+
const gross = items.map((item, index) => {
|
|
243
|
+
const minor = toMinor(item.grossAmount, decimals, `${index + 1}. tétel bruttó összege`);
|
|
244
|
+
if (minor < 0n) throw invalid(`A(z) ${index + 1}. tétel bruttó összege negatív.`);
|
|
245
|
+
return minor;
|
|
246
|
+
});
|
|
247
|
+
const total = gross.reduce((sum, value) => sum + value, 0n);
|
|
248
|
+
const refund = toMinor(refundGross, decimals, "visszatérített összeg");
|
|
249
|
+
const before = toMinor(options.refundedBefore ?? 0, decimals, "korábban visszatérített összeg");
|
|
250
|
+
if (refund <= 0n) throw invalid("A visszatérített összeg legyen pozitív.");
|
|
251
|
+
if (before < 0n) throw invalid("A korábban visszatérített összeg nem lehet negatív.");
|
|
252
|
+
if (before + refund > total) throw invalid(`A visszatérítések összege (${fromMinor(before + refund, decimals)}) nagyobb, mint az eredeti bizonylat bruttó összege (${fromMinor(total, decimals)}).`);
|
|
253
|
+
const earlier = apportion(gross, before);
|
|
254
|
+
const shares = apportion(gross, before + refund).map((value, index) => value - (earlier[index] ?? 0n));
|
|
255
|
+
return items.flatMap((item, index) => {
|
|
256
|
+
const share = shares[index] ?? 0n;
|
|
257
|
+
if (share === 0n) return [];
|
|
258
|
+
return [{
|
|
259
|
+
index,
|
|
260
|
+
name: item.name,
|
|
261
|
+
vat: item.vat,
|
|
262
|
+
grossAmount: fromMinor(share, decimals),
|
|
263
|
+
...item.unit === void 0 ? {} : { unit: item.unit },
|
|
264
|
+
...item.identifier === void 0 ? {} : { identifier: item.identifier }
|
|
265
|
+
}];
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
269
|
+
Object.defineProperty(exports, "allocateRefund", {
|
|
270
|
+
enumerable: true,
|
|
271
|
+
get: function() {
|
|
272
|
+
return allocateRefund;
|
|
273
|
+
}
|
|
274
|
+
});
|
|
161
275
|
Object.defineProperty(exports, "calculateInvoiceItem", {
|
|
162
276
|
enumerable: true,
|
|
163
277
|
get: function() {
|