@getpeppr/sdk 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.
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Offline Schematron-like Validation
3
+ *
4
+ * Reimplements the top ~25 Peppol BIS 3.0 business rules as pure TypeScript checks.
5
+ * This is NOT a full XSD/XSLT schematron processor — it's a fast, offline validator
6
+ * that catches the most commonly violated rules before the invoice reaches the network.
7
+ *
8
+ * Rules are grouped by category:
9
+ * - BR-xx — Required field rules (EN 16931)
10
+ * - BR-CO-xx — Calculation / cross-field consistency rules
11
+ * - BR-S-xx — Tax category rules
12
+ * - PEPPOL-xx — Peppol BIS 3.0 specific rules
13
+ *
14
+ * Design: each rule is a pure function (InvoiceInput) => SchematronViolation[].
15
+ * No side effects, no XML, no network.
16
+ */
17
+ import type { InvoiceInput } from "../types/invoice.js";
18
+ export interface SchematronViolation {
19
+ /** Peppol business rule identifier (e.g., "BR-02", "BR-S-01") */
20
+ ruleId: string;
21
+ /** Severity: "error" blocks sending, "warning" is advisory */
22
+ severity: "error" | "warning";
23
+ /** Human-readable description of the violation */
24
+ message: string;
25
+ /** Relevant field path (e.g., "lines[0].vatRate") */
26
+ field?: string;
27
+ }
28
+ export interface SchematronResult {
29
+ /** True if no errors (warnings are non-blocking) */
30
+ valid: boolean;
31
+ /** Blocking violations — invoice would be rejected */
32
+ errors: SchematronViolation[];
33
+ /** Advisory notices — invoice may be accepted but is suboptimal */
34
+ warnings: SchematronViolation[];
35
+ }
36
+ /**
37
+ * Validate an InvoiceInput against Peppol BIS 3.0 business rules (offline).
38
+ *
39
+ * Runs ~25 of the most commonly violated schematron rules as pure TypeScript checks.
40
+ * No XML generation, no network calls — instant feedback.
41
+ *
42
+ * @param input - The invoice to validate
43
+ * @returns Validation result with errors (blocking) and warnings (advisory)
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const result = validateSchematron({
48
+ * number: "INV-001",
49
+ * to: { name: "Acme", peppolId: "0208:BE0123456789", country: "BE" },
50
+ * lines: [{ description: "Widget", quantity: 1, unitPrice: 100, vatRate: 21 }],
51
+ * });
52
+ *
53
+ * if (!result.valid) {
54
+ * console.error("Validation failed:", result.errors);
55
+ * }
56
+ * ```
57
+ */
58
+ export declare function validateSchematron(input: InvoiceInput): SchematronResult;
59
+ //# sourceMappingURL=schematron.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schematron.d.ts","sourceRoot":"","sources":["../../src/core/schematron.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,qBAAqB,CAAC;AAKrE,MAAM,WAAW,mBAAmB;IAClC,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,KAAK,EAAE,OAAO,CAAC;IACf,sDAAsD;IACtD,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,mEAAmE;IACnE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;CACjC;AAolBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,gBAAgB,CAoBxE"}
@@ -0,0 +1,480 @@
1
+ /**
2
+ * Offline Schematron-like Validation
3
+ *
4
+ * Reimplements the top ~25 Peppol BIS 3.0 business rules as pure TypeScript checks.
5
+ * This is NOT a full XSD/XSLT schematron processor — it's a fast, offline validator
6
+ * that catches the most commonly violated rules before the invoice reaches the network.
7
+ *
8
+ * Rules are grouped by category:
9
+ * - BR-xx — Required field rules (EN 16931)
10
+ * - BR-CO-xx — Calculation / cross-field consistency rules
11
+ * - BR-S-xx — Tax category rules
12
+ * - PEPPOL-xx — Peppol BIS 3.0 specific rules
13
+ *
14
+ * Design: each rule is a pure function (InvoiceInput) => SchematronViolation[].
15
+ * No side effects, no XML, no network.
16
+ */
17
+ import { resolveUnit, getAllUnits } from "./code-lists.js";
18
+ // ─── Helpers ────────────────────────────────────────────────────────────────────
19
+ function violation(ruleId, severity, message, field) {
20
+ return { ruleId, severity, message, field };
21
+ }
22
+ /** Build a Set of all known UN/ECE Rec20 unit codes (lazy singleton). */
23
+ let _knownUnitCodes;
24
+ function getKnownUnitCodes() {
25
+ if (!_knownUnitCodes) {
26
+ _knownUnitCodes = new Set(getAllUnits().map((u) => u.code));
27
+ }
28
+ return _knownUnitCodes;
29
+ }
30
+ /** Peppol-allowed VAT category codes (UNCL 5305 subset). */
31
+ const VALID_VAT_CATEGORIES = new Set(["S", "Z", "E", "AE", "K", "G", "O", "L", "M"]);
32
+ /**
33
+ * Compute the net amount for a single invoice line.
34
+ * Formula: (quantity * unitPrice / baseQuantity) + charges - allowances
35
+ */
36
+ function computeLineNet(line) {
37
+ const baseQty = line.baseQuantity ?? 1;
38
+ if (baseQty === 0)
39
+ return NaN; // Will be caught by BR-CO-10
40
+ const baseAmount = (line.quantity * line.unitPrice) / baseQty;
41
+ const chargeTotal = (line.charges ?? []).reduce((sum, c) => sum + c.amount, 0);
42
+ const allowanceTotal = (line.allowances ?? []).reduce((sum, a) => sum + a.amount, 0);
43
+ return baseAmount + chargeTotal - allowanceTotal;
44
+ }
45
+ // ─── Required Field Rules (BR-01 to BR-10) ──────────────────────────────────────
46
+ /**
47
+ * BR-01: Invoice shall have a Specification identifier.
48
+ * Auto-pass: the gateway always sets "urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0".
49
+ */
50
+ // (no-op — always satisfied)
51
+ /**
52
+ * BR-02: An Invoice shall have an Invoice number.
53
+ */
54
+ const br02 = (input) => {
55
+ if (!input.number?.trim()) {
56
+ return [violation("BR-02", "error", "Invoice number is required.", "number")];
57
+ }
58
+ return [];
59
+ };
60
+ /**
61
+ * BR-03: An Invoice shall have an Invoice issue date.
62
+ * The SDK defaults to today if omitted, so this is a warning.
63
+ */
64
+ const br03 = (input) => {
65
+ if (!input.date) {
66
+ return [
67
+ violation("BR-03", "warning", "Invoice issue date is not set. The SDK will default to today's date.", "date"),
68
+ ];
69
+ }
70
+ return [];
71
+ };
72
+ /**
73
+ * BR-04: An Invoice shall have an Invoice currency code.
74
+ * Auto-pass: defaults to EUR.
75
+ */
76
+ // (no-op)
77
+ /**
78
+ * BR-05: An Invoice shall have an Invoice type code.
79
+ * Auto-pass: always set (380 for invoice, 381 for credit note).
80
+ */
81
+ // (no-op)
82
+ /**
83
+ * BR-06: An Invoice shall have the Seller VAT identifier or tax registration.
84
+ * The `from` field is deprecated — seller is determined by API key.
85
+ * Only warn if `from` IS provided but has no vatNumber.
86
+ */
87
+ const br06 = (input) => {
88
+ if (input.from && !input.from.vatNumber) {
89
+ return [
90
+ violation("BR-06", "warning", "Seller party has no VAT number. The gateway will use the account's VAT registration.", "from.vatNumber"),
91
+ ];
92
+ }
93
+ return [];
94
+ };
95
+ /**
96
+ * BR-07: An Invoice shall have the Buyer name.
97
+ */
98
+ const br07 = (input) => {
99
+ if (!input.to?.name?.trim()) {
100
+ return [violation("BR-07", "error", "Buyer name is required.", "to.name")];
101
+ }
102
+ return [];
103
+ };
104
+ /**
105
+ * BR-08: An Invoice shall have at least one Invoice line.
106
+ */
107
+ const br08 = (input) => {
108
+ if (!input.lines || input.lines.length === 0) {
109
+ return [violation("BR-08", "error", "Invoice must have at least one line item.", "lines")];
110
+ }
111
+ return [];
112
+ };
113
+ /**
114
+ * BR-09: An Invoice shall have the Payment due date or Payment terms.
115
+ */
116
+ const br09 = (input) => {
117
+ if (!input.dueDate && !input.paymentTerms) {
118
+ return [
119
+ violation("BR-09", "warning", "Neither due date nor payment terms specified. At least one is recommended.", "dueDate"),
120
+ ];
121
+ }
122
+ return [];
123
+ };
124
+ /**
125
+ * BR-10: An Invoice shall have the Buyer reference or Order reference.
126
+ */
127
+ const br10 = (input) => {
128
+ if (!input.buyerReference && !input.orderReference) {
129
+ return [
130
+ violation("BR-10", "warning", "Neither buyerReference nor orderReference specified. Peppol BIS 3.0 requires at least one.", "buyerReference"),
131
+ ];
132
+ }
133
+ return [];
134
+ };
135
+ // ─── Calculation Rules (BR-CO) ──────────────────────────────────────────────────
136
+ /**
137
+ * BR-CO-10: Sum of Invoice line net amounts = sum of (quantity x unit price / base quantity)
138
+ * adjusted by line allowances/charges.
139
+ *
140
+ * Since InvoiceInput has no explicit totals, we verify each line's computation is valid
141
+ * (no NaN, no Infinity, handles baseQuantity correctly).
142
+ */
143
+ const brCo10 = (input) => {
144
+ const violations = [];
145
+ if (!input.lines)
146
+ return violations;
147
+ for (let i = 0; i < input.lines.length; i++) {
148
+ const line = input.lines[i];
149
+ const net = computeLineNet(line);
150
+ if (!Number.isFinite(net)) {
151
+ const baseQty = line.baseQuantity ?? 1;
152
+ const detail = baseQty === 0
153
+ ? "baseQuantity is 0, causing division by zero."
154
+ : "Computed line amount is not a finite number.";
155
+ violations.push(violation("BR-CO-10", "error", `Line ${i}: invalid net amount. ${detail}`, `lines[${i}]`));
156
+ }
157
+ }
158
+ return violations;
159
+ };
160
+ /**
161
+ * BR-CO-13: Invoice total VAT amount = sum of (line net amount x VAT rate / 100) per category.
162
+ *
163
+ * We verify the VAT computation is valid and consistent. Since InvoiceInput has no explicit
164
+ * VAT total field, we check that the computed amount is finite and non-negative.
165
+ */
166
+ const brCo13 = (input) => {
167
+ if (!input.lines || input.lines.length === 0)
168
+ return [];
169
+ let totalVat = 0;
170
+ for (let i = 0; i < input.lines.length; i++) {
171
+ const line = input.lines[i];
172
+ const net = computeLineNet(line);
173
+ if (!Number.isFinite(net))
174
+ continue; // Already caught by BR-CO-10
175
+ totalVat += net * (line.vatRate / 100);
176
+ }
177
+ // Include document-level allowances/charges in VAT
178
+ for (const allowance of input.allowances ?? []) {
179
+ totalVat -= allowance.amount * (allowance.vatRate / 100);
180
+ }
181
+ for (const charge of input.charges ?? []) {
182
+ totalVat += charge.amount * (charge.vatRate / 100);
183
+ }
184
+ if (!Number.isFinite(totalVat)) {
185
+ return [
186
+ violation("BR-CO-13", "error", "Computed total VAT amount is not a finite number. Check line amounts and VAT rates."),
187
+ ];
188
+ }
189
+ if (totalVat < -0.01) {
190
+ return [
191
+ violation("BR-CO-13", "warning", `Computed total VAT is negative (${totalVat.toFixed(2)}). This is unusual for an invoice.`),
192
+ ];
193
+ }
194
+ return [];
195
+ };
196
+ /**
197
+ * BR-CO-15: Invoice tax inclusive amount = Invoice total amount without VAT + Invoice total VAT amount.
198
+ *
199
+ * We verify the computation produces a finite, non-negative result.
200
+ */
201
+ const brCo15 = (input) => {
202
+ if (!input.lines || input.lines.length === 0)
203
+ return [];
204
+ let lineTotal = 0;
205
+ let vatTotal = 0;
206
+ for (const line of input.lines) {
207
+ const net = computeLineNet(line);
208
+ if (!Number.isFinite(net))
209
+ continue;
210
+ lineTotal += net;
211
+ vatTotal += net * (line.vatRate / 100);
212
+ }
213
+ // Document-level allowances/charges
214
+ for (const allowance of input.allowances ?? []) {
215
+ lineTotal -= allowance.amount;
216
+ vatTotal -= allowance.amount * (allowance.vatRate / 100);
217
+ }
218
+ for (const charge of input.charges ?? []) {
219
+ lineTotal += charge.amount;
220
+ vatTotal += charge.amount * (charge.vatRate / 100);
221
+ }
222
+ const taxInclusive = lineTotal + vatTotal;
223
+ if (!Number.isFinite(taxInclusive)) {
224
+ return [
225
+ violation("BR-CO-15", "error", "Computed tax-inclusive amount is not a finite number."),
226
+ ];
227
+ }
228
+ if (taxInclusive < -0.01) {
229
+ return [
230
+ violation("BR-CO-15", "warning", `Computed tax-inclusive amount is negative (${taxInclusive.toFixed(2)}). Consider using a credit note instead.`),
231
+ ];
232
+ }
233
+ return [];
234
+ };
235
+ /**
236
+ * BR-CO-16: Amount due for payment = Invoice total amount with VAT - Paid amount + Rounding amount.
237
+ *
238
+ * Verifies payable amount is non-negative when prepaidAmount is used.
239
+ */
240
+ const brCo16 = (input) => {
241
+ if (!input.lines || input.lines.length === 0)
242
+ return [];
243
+ let lineTotal = 0;
244
+ let vatTotal = 0;
245
+ for (const line of input.lines) {
246
+ const net = computeLineNet(line);
247
+ if (!Number.isFinite(net))
248
+ continue;
249
+ lineTotal += net;
250
+ vatTotal += net * (line.vatRate / 100);
251
+ }
252
+ // Document-level allowances/charges
253
+ for (const allowance of input.allowances ?? []) {
254
+ lineTotal -= allowance.amount;
255
+ vatTotal -= allowance.amount * (allowance.vatRate / 100);
256
+ }
257
+ for (const charge of input.charges ?? []) {
258
+ lineTotal += charge.amount;
259
+ vatTotal += charge.amount * (charge.vatRate / 100);
260
+ }
261
+ const taxInclusive = lineTotal + vatTotal;
262
+ const prepaid = input.prepaidAmount ?? 0;
263
+ const rounding = input.roundingAmount ?? 0;
264
+ const payable = taxInclusive - prepaid + rounding;
265
+ if (!Number.isFinite(payable)) {
266
+ return [
267
+ violation("BR-CO-16", "error", "Computed payable amount is not a finite number."),
268
+ ];
269
+ }
270
+ if (payable < -0.01) {
271
+ return [
272
+ violation("BR-CO-16", "warning", `Computed payable amount is negative (${payable.toFixed(2)}). Prepaid amount (${prepaid}) exceeds the invoice total.`),
273
+ ];
274
+ }
275
+ return [];
276
+ };
277
+ // ─── Tax Category Rules (BR-S) ──────────────────────────────────────────────────
278
+ /**
279
+ * BR-S-01: An Invoice that contains a line where the VAT category code is "Standard rate" (S)
280
+ * shall have the VAT rate greater than zero.
281
+ */
282
+ const brS01 = (input) => {
283
+ const violations = [];
284
+ if (!input.lines)
285
+ return violations;
286
+ for (let i = 0; i < input.lines.length; i++) {
287
+ const line = input.lines[i];
288
+ const category = line.vatCategory ?? "S"; // Default is standard rate
289
+ if (category === "S" && (line.vatRate === undefined || line.vatRate <= 0)) {
290
+ violations.push(violation("BR-S-01", "error", `Line ${i}: standard rate (S) requires vatRate > 0, got ${line.vatRate ?? "undefined"}.`, `lines[${i}].vatRate`));
291
+ }
292
+ }
293
+ return violations;
294
+ };
295
+ /**
296
+ * BR-S-05: An Invoice that contains a line where the VAT category code is "Zero rated" (Z)
297
+ * shall have the VAT rate equal to 0.
298
+ */
299
+ const brS05 = (input) => {
300
+ const violations = [];
301
+ if (!input.lines)
302
+ return violations;
303
+ for (let i = 0; i < input.lines.length; i++) {
304
+ const line = input.lines[i];
305
+ if (line.vatCategory === "Z" && line.vatRate !== 0) {
306
+ violations.push(violation("BR-S-05", "error", `Line ${i}: zero-rated (Z) requires vatRate = 0, got ${line.vatRate}.`, `lines[${i}].vatRate`));
307
+ }
308
+ }
309
+ return violations;
310
+ };
311
+ /**
312
+ * BR-S-06: An Invoice that contains a line where the VAT category code is "Exempt" (E)
313
+ * shall have the VAT rate equal to 0.
314
+ */
315
+ const brS06 = (input) => {
316
+ const violations = [];
317
+ if (!input.lines)
318
+ return violations;
319
+ for (let i = 0; i < input.lines.length; i++) {
320
+ const line = input.lines[i];
321
+ if (line.vatCategory === "E" && line.vatRate !== 0) {
322
+ violations.push(violation("BR-S-06", "error", `Line ${i}: exempt (E) requires vatRate = 0, got ${line.vatRate}.`, `lines[${i}].vatRate`));
323
+ }
324
+ }
325
+ return violations;
326
+ };
327
+ /**
328
+ * BR-S-08: An Invoice that contains a line where the VAT category code is "Reverse charge" (AE)
329
+ * shall have the VAT rate equal to 0.
330
+ */
331
+ const brS08 = (input) => {
332
+ const violations = [];
333
+ if (!input.lines)
334
+ return violations;
335
+ for (let i = 0; i < input.lines.length; i++) {
336
+ const line = input.lines[i];
337
+ if (line.vatCategory === "AE" && line.vatRate !== 0) {
338
+ violations.push(violation("BR-S-08", "error", `Line ${i}: reverse charge (AE) requires vatRate = 0, got ${line.vatRate}.`, `lines[${i}].vatRate`));
339
+ }
340
+ }
341
+ return violations;
342
+ };
343
+ // ─── Peppol-Specific Rules ──────────────────────────────────────────────────────
344
+ /**
345
+ * PEPPOL-EN16931-R001: Business process MUST be provided.
346
+ * Auto-pass: the gateway always sets "urn:fdc:peppol.eu:2017:poacc:billing:01:1.0".
347
+ */
348
+ // (no-op)
349
+ /**
350
+ * PEPPOL-EN16931-R004: A Buyer electronic address SHALL exist.
351
+ */
352
+ const peppolR004 = (input) => {
353
+ if (!input.to?.peppolId) {
354
+ return [
355
+ violation("PEPPOL-EN16931-R004", "error", "Buyer electronic address (peppolId) is required for Peppol delivery.", "to.peppolId"),
356
+ ];
357
+ }
358
+ return [];
359
+ };
360
+ /**
361
+ * PEPPOL-EN16931-R006: VAT category code MUST follow the Peppol subset of UNCL 5305.
362
+ * Valid codes: S, Z, E, AE, K, G, O, L, M.
363
+ */
364
+ const peppolR006 = (input) => {
365
+ const violations = [];
366
+ if (!input.lines)
367
+ return violations;
368
+ for (let i = 0; i < input.lines.length; i++) {
369
+ const line = input.lines[i];
370
+ const cat = line.vatCategory;
371
+ if (cat !== undefined && !VALID_VAT_CATEGORIES.has(cat)) {
372
+ violations.push(violation("PEPPOL-EN16931-R006", "error", `Line ${i}: invalid VAT category "${cat}". Must be one of: S, Z, E, AE, K, G, O, L, M.`, `lines[${i}].vatCategory`));
373
+ }
374
+ }
375
+ // Also check document-level allowances/charges
376
+ for (let i = 0; i < (input.allowances ?? []).length; i++) {
377
+ const cat = input.allowances[i].vatCategory;
378
+ if (cat !== undefined && !VALID_VAT_CATEGORIES.has(cat)) {
379
+ violations.push(violation("PEPPOL-EN16931-R006", "error", `Allowance ${i}: invalid VAT category "${cat}".`, `allowances[${i}].vatCategory`));
380
+ }
381
+ }
382
+ for (let i = 0; i < (input.charges ?? []).length; i++) {
383
+ const cat = input.charges[i].vatCategory;
384
+ if (cat !== undefined && !VALID_VAT_CATEGORIES.has(cat)) {
385
+ violations.push(violation("PEPPOL-EN16931-R006", "error", `Charge ${i}: invalid VAT category "${cat}".`, `charges[${i}].vatCategory`));
386
+ }
387
+ }
388
+ return violations;
389
+ };
390
+ /**
391
+ * PEPPOL-EN16931-R080: Unit of measure MUST be coded using UN/ECE Recommendation 20.
392
+ * Warning-level since unknown codes pass through to B2BRouter which may accept them.
393
+ */
394
+ const peppolR080 = (input) => {
395
+ const violations = [];
396
+ if (!input.lines)
397
+ return violations;
398
+ const knownCodes = getKnownUnitCodes();
399
+ for (let i = 0; i < input.lines.length; i++) {
400
+ const line = input.lines[i];
401
+ if (line.unit) {
402
+ const resolved = resolveUnit(line.unit);
403
+ if (!knownCodes.has(resolved)) {
404
+ violations.push(violation("PEPPOL-EN16931-R080", "warning", `Line ${i}: unit "${line.unit}" (resolved: "${resolved}") is not a known UN/ECE Rec20 code. Common codes: EA, HUR, DAY, KGM.`, `lines[${i}].unit`));
405
+ }
406
+ }
407
+ // No unit specified → defaults to "EA" which is valid → no violation
408
+ }
409
+ return violations;
410
+ };
411
+ // ─── Rule Registry ──────────────────────────────────────────────────────────────
412
+ /** All active rules in evaluation order. */
413
+ const ALL_RULES = [
414
+ // Required fields (BR)
415
+ br02,
416
+ br03,
417
+ br06,
418
+ br07,
419
+ br08,
420
+ br09,
421
+ br10,
422
+ // Calculations (BR-CO)
423
+ brCo10,
424
+ brCo13,
425
+ brCo15,
426
+ brCo16,
427
+ // Tax categories (BR-S)
428
+ brS01,
429
+ brS05,
430
+ brS06,
431
+ brS08,
432
+ // Peppol-specific
433
+ peppolR004,
434
+ peppolR006,
435
+ peppolR080,
436
+ ];
437
+ // ─── Main Validation Function ───────────────────────────────────────────────────
438
+ /**
439
+ * Validate an InvoiceInput against Peppol BIS 3.0 business rules (offline).
440
+ *
441
+ * Runs ~25 of the most commonly violated schematron rules as pure TypeScript checks.
442
+ * No XML generation, no network calls — instant feedback.
443
+ *
444
+ * @param input - The invoice to validate
445
+ * @returns Validation result with errors (blocking) and warnings (advisory)
446
+ *
447
+ * @example
448
+ * ```ts
449
+ * const result = validateSchematron({
450
+ * number: "INV-001",
451
+ * to: { name: "Acme", peppolId: "0208:BE0123456789", country: "BE" },
452
+ * lines: [{ description: "Widget", quantity: 1, unitPrice: 100, vatRate: 21 }],
453
+ * });
454
+ *
455
+ * if (!result.valid) {
456
+ * console.error("Validation failed:", result.errors);
457
+ * }
458
+ * ```
459
+ */
460
+ export function validateSchematron(input) {
461
+ const errors = [];
462
+ const warnings = [];
463
+ for (const rule of ALL_RULES) {
464
+ const violations = rule(input);
465
+ for (const v of violations) {
466
+ if (v.severity === "error") {
467
+ errors.push(v);
468
+ }
469
+ else {
470
+ warnings.push(v);
471
+ }
472
+ }
473
+ }
474
+ return {
475
+ valid: errors.length === 0,
476
+ errors,
477
+ warnings,
478
+ };
479
+ }
480
+ //# sourceMappingURL=schematron.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schematron.js","sourceRoot":"","sources":["../../src/core/schematron.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA4B3D,mFAAmF;AAEnF,SAAS,SAAS,CAChB,MAAc,EACd,QAA6B,EAC7B,OAAe,EACf,KAAc;IAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9C,CAAC;AAED,yEAAyE;AACzE,IAAI,eAAwC,CAAC;AAC7C,SAAS,iBAAiB;IACxB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,eAAe,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,4DAA4D;AAC5D,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAErF;;;GAGG;AACH,SAAS,cAAc,CAAC,IAAiB;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,GAAsB;IACnC,uBAAuB;IACvB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,uBAAuB;IACvB,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,wBAAwB;IACxB,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,kBAAkB;IAClB,UAAU;IACV,UAAU;IACV,UAAU;CACX,CAAC;AAEF,mFAAmF;AAEnF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAmB;IACpD,MAAM,MAAM,GAA0B,EAAE,CAAC;IACzC,MAAM,QAAQ,GAA0B,EAAE,CAAC;IAE3C,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;YAC3B,IAAI,CAAC,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;gBAC3B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * UBL XML Builder
3
+ *
4
+ * Converts our clean JSON invoice format to Peppol BIS 3.0 compliant UBL 2.1 XML.
5
+ * This is the core abstraction that hides XML complexity from developers.
6
+ *
7
+ * Reference: https://docs.peppol.eu/poacc/billing/3.0/
8
+ */
9
+ import type { InvoiceInput, CreditNoteInput } from "../types/invoice.js";
10
+ /**
11
+ * Build a Peppol BIS 3.0 compliant UBL 2.1 Invoice XML from a simple JSON input.
12
+ */
13
+ export declare function buildInvoiceXml(input: InvoiceInput): string;
14
+ /**
15
+ * Build a Peppol BIS 3.0 compliant UBL 2.1 Credit Note XML.
16
+ *
17
+ * Generates XML directly with correct CreditNote elements — no string replacement.
18
+ */
19
+ export declare function buildCreditNoteXml(input: CreditNoteInput): string;
20
+ //# sourceMappingURL=ubl-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ubl-builder.d.ts","sourceRoot":"","sources":["../../src/core/ubl-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAA4E,MAAM,qBAAqB,CAAC;AA+hBnJ;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAgD3D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAiDjE"}