@formancy/report-runtime 0.0.0-stage → 0.2.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.md +161 -0
- package/NOTICE +17 -0
- package/README.md +274 -2
- package/dist/index.d.mts +873 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4036 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Formancy Report Source-Available Licence
|
|
2
|
+
|
|
3
|
+
**Version 1 — in force from 14 October 2026. Not reviewed by a lawyer.**
|
|
4
|
+
|
|
5
|
+
This text states the terms Formancy Report is offered under. Version 1 is in
|
|
6
|
+
force from 14 October 2026. Its terms are those of the Formancy Data
|
|
7
|
+
Source-Available Licence, Version 1.1, with this product's names and with the
|
|
8
|
+
documents a reporting product generates named as yours. **This version has
|
|
9
|
+
not been reviewed by a lawyer.** It is published in the repository so that
|
|
10
|
+
the terms are visible to everyone who reads the source. Production licences,
|
|
11
|
+
which section 3 describes, can be had as section 9 says.
|
|
12
|
+
|
|
13
|
+
This is not an open-source licence. It is not Apache-2.0, and it is not the
|
|
14
|
+
licence of [formancy](https://github.com/sharkysan/formancy.ai), on which this
|
|
15
|
+
software builds and whose packages keep their own Apache-2.0 terms.
|
|
16
|
+
|
|
17
|
+
## The terms in one table
|
|
18
|
+
|
|
19
|
+
| Use | Terms |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| Read the source and fork the repository | Free |
|
|
22
|
+
| Evaluate, develop and test — including in companies | Free |
|
|
23
|
+
| Run in production, internally or customer-facing | Paid licence |
|
|
24
|
+
| Redistribute inside another software product | Separate commercial agreement |
|
|
25
|
+
| Customer data, report templates and generated documents | Remain the customer's |
|
|
26
|
+
|
|
27
|
+
The rest of this document says what each row means.
|
|
28
|
+
|
|
29
|
+
## 1. Definitions
|
|
30
|
+
|
|
31
|
+
**The Software** means the source code, declarations, documentation and
|
|
32
|
+
packages in this repository and the packages published from it under the
|
|
33
|
+
`@formancy/report-*` names, in any version, including modified versions.
|
|
34
|
+
|
|
35
|
+
**The Rightsholder** means Daniel Bacher, or whoever the Rightsholder later
|
|
36
|
+
designates in a revision of this document.
|
|
37
|
+
|
|
38
|
+
**Production Use** means running the Software, or anything that incorporates
|
|
39
|
+
it, in a way that serves real end users or real business operations: an
|
|
40
|
+
application people other than its developers and testers rely on, whether
|
|
41
|
+
inside one organisation or offered to others, whether or not it earns money.
|
|
42
|
+
Production is defined by operational use, not by revenue.
|
|
43
|
+
|
|
44
|
+
**Development Use** means any use that is not Production Use: reading,
|
|
45
|
+
evaluating, building, modifying, testing, demonstrating and running in
|
|
46
|
+
development, test, staging and continuous-integration environments, including
|
|
47
|
+
by and within a commercial organisation. A staging environment that real
|
|
48
|
+
users depend on is Production Use whatever it is called.
|
|
49
|
+
|
|
50
|
+
**Redistribution** means delivering the Software, or anything that
|
|
51
|
+
incorporates it, to a third party as part of a software product, a managed
|
|
52
|
+
service, a platform or a toolkit, such that the third party runs it rather
|
|
53
|
+
than you.
|
|
54
|
+
|
|
55
|
+
**Customer Data** means the contents of any dataset, submission, database or
|
|
56
|
+
file the Software is given or connects to, and anything the Software reads
|
|
57
|
+
from or writes to it.
|
|
58
|
+
|
|
59
|
+
**Generated Definitions** means the report definitions, templates, bindings,
|
|
60
|
+
styles, parameter forms, policies and other configuration the Software
|
|
61
|
+
generates or that a person creates with it, and the documents rendered from
|
|
62
|
+
them, PDF files included.
|
|
63
|
+
|
|
64
|
+
## 2. What is free
|
|
65
|
+
|
|
66
|
+
Subject to section 4, the Rightsholder grants you a worldwide, royalty-free,
|
|
67
|
+
non-exclusive licence to:
|
|
68
|
+
|
|
69
|
+
1. read, copy, fork and modify the Software;
|
|
70
|
+
2. use the Software and your modifications for Development Use, without limit
|
|
71
|
+
of time, number of people or size of organisation;
|
|
72
|
+
3. share the Software and your modifications with others for their
|
|
73
|
+
Development Use, under this licence and with this document attached.
|
|
74
|
+
|
|
75
|
+
No production licence is required to evaluate the Software for as long as you
|
|
76
|
+
like, and no evaluation period expires.
|
|
77
|
+
|
|
78
|
+
## 3. What is paid
|
|
79
|
+
|
|
80
|
+
**Production Use requires a production licence from the Rightsholder.** A
|
|
81
|
+
production licence is a separate written agreement. It is expected to be
|
|
82
|
+
granted per application, to cover that application's development, test and
|
|
83
|
+
replica environments without further charge, to specify support and update
|
|
84
|
+
entitlements, and to leave you the right to keep running the versions you
|
|
85
|
+
licensed if you later choose not to renew. Those are intentions; the agreement
|
|
86
|
+
you sign is what governs.
|
|
87
|
+
|
|
88
|
+
**Redistribution requires a separate commercial agreement.** Shipping the
|
|
89
|
+
Software inside a product, a platform or a managed service that other parties
|
|
90
|
+
run is not covered by a production licence for your own applications.
|
|
91
|
+
|
|
92
|
+
Running the Software in production without a production licence is a breach of
|
|
93
|
+
this licence.
|
|
94
|
+
|
|
95
|
+
## 4. Conditions
|
|
96
|
+
|
|
97
|
+
1. **Notices travel.** A copy of this document, and the NOTICE file, stays
|
|
98
|
+
with every copy and every modified version of the Software.
|
|
99
|
+
2. **Modified versions carry these terms.** A modified version of the Software
|
|
100
|
+
is the Software for the purposes of this licence. You may not remove or
|
|
101
|
+
circumvent the terms by modifying it.
|
|
102
|
+
3. **No trademark grant.** This licence grants no right to use the names
|
|
103
|
+
"Formancy", "Formancy Report", "Formancy Report Studio", "formancy.ai" or
|
|
104
|
+
any associated logo, beyond what is needed to identify the Software
|
|
105
|
+
truthfully.
|
|
106
|
+
4. **Third-party components keep their own licences.** The Software depends on
|
|
107
|
+
packages licensed under the Apache License, Version 2.0, among others. Those
|
|
108
|
+
licences continue to govern those components, their notices are preserved
|
|
109
|
+
in NOTICE, and nothing in this document narrows the rights they grant.
|
|
110
|
+
|
|
111
|
+
## 5. What stays yours
|
|
112
|
+
|
|
113
|
+
**Customer Data remains the customer's.** This licence grants the Rightsholder
|
|
114
|
+
no right of any kind over the data the Software is given or reads, and the
|
|
115
|
+
Software is designed not to send any of it anywhere.
|
|
116
|
+
|
|
117
|
+
**Generated Definitions remain yours.** Report definitions, templates,
|
|
118
|
+
bindings and policies you generate or author with the Software, and the
|
|
119
|
+
documents rendered from them, are yours, under whatever terms you choose.
|
|
120
|
+
They are not the Software, and this licence does not restrict them —
|
|
121
|
+
including after a production licence ends. A logo, a font or another asset
|
|
122
|
+
you place in a report keeps the rights it came with.
|
|
123
|
+
|
|
124
|
+
## 6. Contributions
|
|
125
|
+
|
|
126
|
+
Contributions to the Software are accepted under the Contributor License
|
|
127
|
+
Agreement in `CLA.md`, which grants the Rightsholder the right to distribute
|
|
128
|
+
them under this licence and under commercial agreements, and transfers no
|
|
129
|
+
ownership.
|
|
130
|
+
|
|
131
|
+
## 7. Termination
|
|
132
|
+
|
|
133
|
+
Your rights under this licence end automatically if you breach it and do not
|
|
134
|
+
cure the breach within thirty days of becoming aware of it. The rights in
|
|
135
|
+
section 5 do not end: your data, your definitions and your documents stay
|
|
136
|
+
yours in every case.
|
|
137
|
+
|
|
138
|
+
## 8. No warranty, limited liability
|
|
139
|
+
|
|
140
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
141
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
142
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
143
|
+
RIGHTSHOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
144
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
145
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
146
|
+
|
|
147
|
+
A production licence may provide warranties and support; this document does
|
|
148
|
+
not.
|
|
149
|
+
|
|
150
|
+
## 9. Obtaining a production licence
|
|
151
|
+
|
|
152
|
+
Production licences are requested from the Rightsholder at info@formancy.ai.
|
|
153
|
+
The separate commercial agreement that Redistribution requires, which
|
|
154
|
+
section 3 describes, is requested at the same address. The Software is new
|
|
155
|
+
and has no published price; the plan is to set the price after the first
|
|
156
|
+
design partners have established what the Software is worth to them.
|
|
157
|
+
|
|
158
|
+
## 10. Governing law and place of jurisdiction
|
|
159
|
+
|
|
160
|
+
This licence is governed by Swiss law, excluding its conflict-of-laws rules.
|
|
161
|
+
The place of jurisdiction is the Rightsholder's domicile in Switzerland.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Formancy Report
|
|
2
|
+
Copyright 2026 Daniel Bacher
|
|
3
|
+
|
|
4
|
+
This product is distributed under the Formancy Report Source-Available Licence
|
|
5
|
+
(LICENSE.md). It is not open source.
|
|
6
|
+
|
|
7
|
+
This product includes software developed by the formancy project
|
|
8
|
+
(https://github.com/sharkysan/formancy.ai), licensed under the Apache License,
|
|
9
|
+
Version 2.0. Those packages keep their licence; nothing here changes it.
|
|
10
|
+
|
|
11
|
+
@formancy/report-render-pdf includes the Liberation Sans fonts, version
|
|
12
|
+
2.1.5, Regular and Bold, in its fonts directory and, as base64, in its
|
|
13
|
+
browser build. Digitized data copyright (c) 2010 Google Corporation, with
|
|
14
|
+
Reserved Font Arimo, Tinos and Cousine. Copyright (c) 2012 Red Hat, Inc.,
|
|
15
|
+
with Reserved Font Name Liberation. They are licensed under the SIL Open
|
|
16
|
+
Font License, Version 1.1, whose text travels with them as
|
|
17
|
+
fonts/LICENSE-LiberationSans.txt; nothing here changes it.
|
package/README.md
CHANGED
|
@@ -1,3 +1,275 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @formancy/report-runtime
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Formancy Report's runtime: it resolves a report definition against the data
|
|
4
|
+
a host hands it, and returns the renderer-neutral document a PDF engine
|
|
5
|
+
draws, or every reason it will not. It holds the data to the report's
|
|
6
|
+
dataset contracts, evaluates the report's expressions, groups, sorts and
|
|
7
|
+
totals with exact decimals, and formats each value for the report's locale,
|
|
8
|
+
once. No framework, no PDF engine, no Node. What it decides, and why, is
|
|
9
|
+
decision
|
|
10
|
+
[0010](../../docs/decisions/0010-the-runtime-resolves-a-report-into-a-renderer-neutral-document.md).
|
|
11
|
+
|
|
12
|
+
## Resolve
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { resolveReport } from '@formancy/report-runtime'
|
|
16
|
+
import type { ImageResolver, ReportData } from '@formancy/report-runtime'
|
|
17
|
+
|
|
18
|
+
const data: ReportData = {
|
|
19
|
+
header: { customer: 'Bäckerei Müller AG', quotedOn: '2026-10-15' },
|
|
20
|
+
detail: [{ article: 'A-1001', quantity: '1.00', amount: '480.00' }],
|
|
21
|
+
completeness: { complete: true, captured: 1 },
|
|
22
|
+
consistency: 'host-captured',
|
|
23
|
+
}
|
|
24
|
+
// The host's approved assets, by id and digest: the runtime never follows an address.
|
|
25
|
+
const images: ImageResolver = ({ asset, digest }) => approvedAssets.get(`${asset}@${digest}`)
|
|
26
|
+
|
|
27
|
+
const resolution = resolveReport(report, data, { mode: 'final', parameters: { copies: '2' }, images, creationDate: '2026-10-15T08:00:00Z', timeZone: 'Europe/Zurich' })
|
|
28
|
+
if (resolution.ok) {
|
|
29
|
+
resolution.document // what @formancy/report-render-pdf draws
|
|
30
|
+
resolution.manifest // the report's hash, locale, zone, mode, consistency, completeness, parameters
|
|
31
|
+
} else {
|
|
32
|
+
resolution.errors // each with the stage that found it, a stable code, a JSON Pointer, never a value
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`resolveReport` refuses, with every reason at once up to a bound:
|
|
37
|
+
|
|
38
|
+
- a report `validateReport` refuses, or one `diagnose` gives an error for
|
|
39
|
+
(stage `report` or `expressions`): the editor and the runtime refuse the
|
|
40
|
+
same reports;
|
|
41
|
+
- parameters and data that break their contracts (`parameters`, `data`);
|
|
42
|
+
- an expression that fails for a row (`evaluation`), naming the component,
|
|
43
|
+
the column or the aggregate and the row;
|
|
44
|
+
- a value a format cannot show, a locale or time zone the engine lacks
|
|
45
|
+
(`format`);
|
|
46
|
+
- an image the host has no bytes for, or bytes past 20 MB -- an SVG's past
|
|
47
|
+
1 MiB, `MAX_SVG_BYTES` -- and a total that cannot be computed
|
|
48
|
+
(`resolve`);
|
|
49
|
+
- a QR-bill that breaks one of SIX's rules once its data has resolved it
|
|
50
|
+
(`resolve`, `invalid-qr-bill`): an account, a reference, an address part,
|
|
51
|
+
a message or an amount, named by the field and the rule, never by the
|
|
52
|
+
value;
|
|
53
|
+
- an EPC QR code that breaks one of the EPC's rules once its data has
|
|
54
|
+
resolved it (`resolve`, `invalid-epc-qr-code`): an IBAN, a BIC or none
|
|
55
|
+
where the account needs one, a name, a reference, a text, an amount, or a
|
|
56
|
+
payload past 331 bytes, named by the code, the field and the rule, never
|
|
57
|
+
by the value;
|
|
58
|
+
- an e-invoice that breaks one of EN 16931's rules once its data has
|
|
59
|
+
resolved it (`resolve`, `invalid-e-invoice`): a text, a date, a line's
|
|
60
|
+
term, a table of no rows in a final render, or a payment code that asks
|
|
61
|
+
for another amount or account than the e-invoice names, each named by
|
|
62
|
+
where it stands, its business term and its rule, never by the value.
|
|
63
|
+
|
|
64
|
+
It never returns part of a document.
|
|
65
|
+
|
|
66
|
+
## The data
|
|
67
|
+
|
|
68
|
+
One header record and one detail list, with what the provider says about
|
|
69
|
+
them. Every value is held to its field's type before anything reads it:
|
|
70
|
+
|
|
71
|
+
| Type | Accepted as |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `integer` | a string of its digits, or a JavaScript number that is a safe integer |
|
|
74
|
+
| `decimal` | a canonical string within the field's scale; never a number, which has already lost digits |
|
|
75
|
+
| `date` | `YYYY-MM-DD`, a day on the calendar from 0001 to 9999 |
|
|
76
|
+
| `datetime` | `YYYY-MM-DDTHH:mm:ss`, with up to nine digits of a second, no zone |
|
|
77
|
+
| `instant` | an ISO 8601 date-time with its zone, held in UTC |
|
|
78
|
+
| `image` | `{ asset, digest }`, an approved asset, never an address: a PNG, a JPEG or an SVG |
|
|
79
|
+
|
|
80
|
+
A field the report does not declare is refused: a report never carries what
|
|
81
|
+
it does not print. Null prints as nothing; a field the data lacks is an
|
|
82
|
+
error in a final render, never an empty cell. A code is the exception: a
|
|
83
|
+
final render refuses a value that is null in a QR code's content or in a
|
|
84
|
+
QR-bill's or an EPC QR code's text (`no-qr-value`) -- but in an EPC QR
|
|
85
|
+
code's optional text that prints nothing else, which is that text left
|
|
86
|
+
out -- and a QR code whose content prints nothing
|
|
87
|
+
(`empty-qr-code`), since a scanner cannot see the gap a reader would. A
|
|
88
|
+
final render refuses data the provider calls incomplete. A **preview**
|
|
89
|
+
prints what it has, encodes a QR code as its content resolves, warns once
|
|
90
|
+
for each field it lacks, labels every page as a preview of incomplete
|
|
91
|
+
data, and says so in its manifest. A QR-bill is held to SIX's rules in a
|
|
92
|
+
preview too, and an EPC QR code to the EPC's: one that a missing value
|
|
93
|
+
leaves without a text its rules require is refused, and the error says the
|
|
94
|
+
preview lacked a value for it, since its code would scan as a payment no
|
|
95
|
+
bank makes. The host's objects are read
|
|
96
|
+
once, as data: a getter is never run, and a proxy that throws is refused.
|
|
97
|
+
|
|
98
|
+
## A QR-bill
|
|
99
|
+
|
|
100
|
+
A report's payment part resolves to the document's `paymentPart`
|
|
101
|
+
([0022](../../docs/decisions/0022-a-report-carries-one-swiss-qr-bill-at-the-foot-of-its-last-page.md)): the
|
|
102
|
+
Swiss QR Code's payload, in the order of SIX's Table 8, and every text its
|
|
103
|
+
slip prints -- the headings in its language, the account, the reference
|
|
104
|
+
and the amount grouped as SIX prints them, the addresses line by line. The
|
|
105
|
+
rules a text is held to are report-spec's, the same functions its
|
|
106
|
+
validator applies to a literal. An amount is a decimal, or null for the
|
|
107
|
+
payer to fill in, and is never rounded: one with a third decimal is
|
|
108
|
+
refused. The bill has no "do not use for payment" variant and no
|
|
109
|
+
alternative procedure, and its ultimate creditor is empty, as SIX keeps it
|
|
110
|
+
for later use.
|
|
111
|
+
|
|
112
|
+
## An EPC QR code
|
|
113
|
+
|
|
114
|
+
An `epcQrCode` component resolves to an `epcQrCode` block
|
|
115
|
+
([0025](../../docs/decisions/0025-a-report-prints-an-epc-qr-code-held-to-the-epc-rules-beside-the-qr-bill.md)): its id, its
|
|
116
|
+
square, Austria's caption when the template asks for it, and the payload
|
|
117
|
+
of EPC069-12 version 3.1, section 2.2 -- `BCD`, the version, character set
|
|
118
|
+
`1` for UTF-8, `SCT`, then the BIC, the name, the IBAN, the amount in euro,
|
|
119
|
+
the purpose, the reference, the text and the information, each on its own
|
|
120
|
+
line, every element up to the last the code holds a line, empty when it is
|
|
121
|
+
unused, and nothing after the last. A code with a BIC is version `001`, as
|
|
122
|
+
the EPC's first example is: version 3.1 of the guidelines keeps both
|
|
123
|
+
versions, and a code with a BIC is what `001` asks for. One without is
|
|
124
|
+
`002`, the version that lets the BIC be left empty. The EPC's first
|
|
125
|
+
example is written byte for byte; its second, which is in ISO 8859-1, is
|
|
126
|
+
written in UTF-8: character set `1` where the example has
|
|
127
|
+
`2`, and one byte longer for its ç. No other character set is written.
|
|
128
|
+
|
|
129
|
+
Every text is read as a paragraph with the same runs prints it, and held to
|
|
130
|
+
report-spec's rules, the same functions its validator applies to a
|
|
131
|
+
literal: the IBAN's spaces are dropped and its letters made capitals, and
|
|
132
|
+
it must be of a country of SEPA, of that country's length, its check
|
|
133
|
+
digits right, and no QR-IBAN; the BIC, when there is one, a BIC of the
|
|
134
|
+
account's country, and required for an account outside the EEA; the
|
|
135
|
+
reference a creditor reference (ISO 11649), checked as a QR-bill's is and
|
|
136
|
+
written in capitals. Which texts are optional, and what a refusal calls
|
|
137
|
+
each, is report-spec's `EPC_TEXT_FIELDS`. An optional text the data gives
|
|
138
|
+
empty, blank or null is an element the code leaves unused, in a final
|
|
139
|
+
render as in a preview: a nullable field's null is how data says "none".
|
|
140
|
+
A null among runs that print something is refused, as a text cut short. The amount is a decimal,
|
|
141
|
+
or null for the payer to fill in, written as short as it can be --
|
|
142
|
+
`EUR12.3`, `EUR45` -- from 0.01 to 999999999.99, and never rounded: one
|
|
143
|
+
with a third decimal is refused. The whole payload is at most 331 bytes in
|
|
144
|
+
UTF-8, counted in bytes, not in characters.
|
|
145
|
+
|
|
146
|
+
## An e-invoice
|
|
147
|
+
|
|
148
|
+
A report's `eInvoice` (report-spec's, [0027](../../docs/decisions/0027-a-report-carries-one-en-16931-invoice-written-from-the-values-its-page-prints.md)) resolves to the document's
|
|
149
|
+
`eInvoice`: the CII XML of a Factur-X 1.09.2 / ZUGFeRD 2.5.2 invoice in the
|
|
150
|
+
EN 16931 profile, and what the renderer embeds it as, `fileName`,
|
|
151
|
+
`relationship` and `conformanceLevel`, report-spec's `FACTUR_X` and
|
|
152
|
+
`FACTUR_X_PROFILES` [S].
|
|
153
|
+
|
|
154
|
+
- **The lines are the table's.** Each row of the table the e-invoice names
|
|
155
|
+
is a line. The four columns it names -- the item, the quantity, the net
|
|
156
|
+
price and the net amount -- are read once for every row, before the
|
|
157
|
+
totals, and the table prints the value kept, so the page and the XML read
|
|
158
|
+
one evaluation of each line, in the order the table prints them. The
|
|
159
|
+
line's identifier, unit and VAT category are read from each row. A net
|
|
160
|
+
amount is refused unless it is its quantity times its net price, rounded
|
|
161
|
+
once to the cent, as EN 16931 defines it and Mustang recomputes it; a
|
|
162
|
+
line identifier unless no earlier line has it; and a quantity or a net
|
|
163
|
+
price that its column's format prints at fewer places than it has.
|
|
164
|
+
- **The totals are computed once, here** (`e-invoice-totals.ts`), in
|
|
165
|
+
`Decimal`: the sum of the lines, each category's basis, its tax -- the
|
|
166
|
+
basis times the rate over 100, rounded once to two places, half away from
|
|
167
|
+
zero, per category and never per line -- the VAT, the total with it, and
|
|
168
|
+
the amount due: the total less what was paid. The page reads them as
|
|
169
|
+
`invoice`, `vatBasis` and `vatAmount`, the very values the XML is written
|
|
170
|
+
from; a category no line is in is null, and has no breakdown in the XML.
|
|
171
|
+
- **Every text is held to EN 16931's rules**, report-spec's functions, the
|
|
172
|
+
ones its validator applies to a literal, once the data has resolved it:
|
|
173
|
+
a code from its closed list, a VAT identifier's prefix, an IBAN and a
|
|
174
|
+
BIC, a day on the calendar, a net price not below zero, a net amount of
|
|
175
|
+
whole cents, never rounded, a category the invoice declares, a character
|
|
176
|
+
XML can hold, and no white space a token collapses in an identifier or a
|
|
177
|
+
code the XML writes as one. An optional text that prints nothing is left out; a needed one is
|
|
178
|
+
refused by the rule that needs it; one that prints something around a
|
|
179
|
+
null is refused as cut short. What only the whole says -- the seller's
|
|
180
|
+
and the buyer's identifiers, the time of supply, an exempt category's
|
|
181
|
+
reason -- is said of the categories the lines are in.
|
|
182
|
+
- **A payment code printed with it** -- the QR-bill, an EPC QR code -- asks
|
|
183
|
+
for the amount due, or leaves the amount to the payer, and to be paid to
|
|
184
|
+
the e-invoice's account, compared by value once both have resolved.
|
|
185
|
+
- **The XML** is written one way (`xml.ts`, `cii.ts`, `cii-parties.ts`):
|
|
186
|
+
its declaration, no byte order mark, a line feed after each line, two
|
|
187
|
+
spaces a level, each element in the profile XSD's order at the path
|
|
188
|
+
CEN's binding gives its term, amounts at two places from their own
|
|
189
|
+
digits, dates as format 102. Text is escaped, a carriage return as a
|
|
190
|
+
reference so that a parser gives it back; a character XML 1.0 cannot hold
|
|
191
|
+
is refused where it is read. The same report and data are the same
|
|
192
|
+
bytes.
|
|
193
|
+
- **A preview is not the invoice.** It prints the totals of what it has,
|
|
194
|
+
takes a term it has no value for as one it lacks and holds what the data
|
|
195
|
+
does give to the rules; it writes no XML, warns `e-invoice-preview`, and
|
|
196
|
+
labels every page, `E_INVOICE_PREVIEW_LABEL` where nothing else is
|
|
197
|
+
lacking and `PREVIEW_LABEL` where data is.
|
|
198
|
+
|
|
199
|
+
At `MAX_DETAIL_ROWS` the XML is large: 100,000 lines of short names wrote
|
|
200
|
+
117,280,919 bytes, 1,173 a line, and `resolveReport` took a median of 5.4
|
|
201
|
+
seconds, against 2.0 for the same report and rows without the e-invoice;
|
|
202
|
+
10,000 lines wrote 11,710,910 bytes in a median of 0.44 seconds, against
|
|
203
|
+
0.23 (five runs each, from the built package, Node 24.21.0, an Intel
|
|
204
|
+
i9-10900K, 17 October 2026). The e-invoice has no bound of its own yet.
|
|
205
|
+
|
|
206
|
+
## What else is exported
|
|
207
|
+
|
|
208
|
+
Each stage is exported for a host or a tool that needs one alone:
|
|
209
|
+
`checkReport`, `checkData`, `checkParameters`, `readValue`,
|
|
210
|
+
`prepareExpressions`, `createFormatter`, `orderTable` and the decimal
|
|
211
|
+
arithmetic. The document's types, `RenderRefusal` and `REFUSAL_CODES` are
|
|
212
|
+
the renderer's contract, declared here so that no engine defines them.
|
|
213
|
+
What report-spec decides of a QR-bill that an engine needs to draw its
|
|
214
|
+
slip is handed on as report-spec's own objects: `QR_BILL_SIZE` and
|
|
215
|
+
`QR_BILL_TOP`, the slip's size and place; `qrBillPageBreak` and its type
|
|
216
|
+
`QrBillPageBreak`, the page it is printed on; `QR_BILL_CURRENCIES`;
|
|
217
|
+
`checkQrBillAmount`, the amounts a bill pays; and
|
|
218
|
+
`MAX_QR_BILL_ADDITIONAL_INFORMATION`, the longest value SIX allows. So is
|
|
219
|
+
what report-spec decides of how an EPC QR code is printed:
|
|
220
|
+
`EPC_MAX_BYTES` and `EPC_MAX_VERSION`, the most bytes and the largest
|
|
221
|
+
version the EPC allows; `qrSymbolModules`
|
|
222
|
+
and `epcModule`, the modules a symbol has and the side of one in a square;
|
|
223
|
+
and `EPC_FRAME`, `EPC_CAPTION`, `EPC_CAPTION_MODULE`, `epcLeastVersion`
|
|
224
|
+
and `epcCaptionBreak`, Austria's frame and caption, the modules' widths
|
|
225
|
+
they are printed at and the least version that prints them. And of how an
|
|
226
|
+
e-invoice is embedded: `FACTUR_X`, the file's name and media type and the
|
|
227
|
+
XMP's namespace, prefix, document type and version, and
|
|
228
|
+
`FACTUR_X_PROFILES`, each profile's specification identifier,
|
|
229
|
+
conformance level and relationship [S]. And of an SVG asset
|
|
230
|
+
([0030](../../docs/decisions/0030-an-image-asset-may-be-an-svg-of-drawing-elements-alone-cleaned-once-and-refused-at-print-in-any-other-form.md)):
|
|
231
|
+
`checkSvg`, which accepts only the drawing `cleanSvg` writes and says what
|
|
232
|
+
it costs to draw and how far the numbers the converter writes for it reach
|
|
233
|
+
(`SvgExtent`); `cleanSvg` itself, for a host that approves assets beside
|
|
234
|
+
its render code; `SVG_REFUSAL_CODES`; `SVG_ELEMENTS`, the elements an
|
|
235
|
+
approved drawing is written with, which an engine's own guard is held to;
|
|
236
|
+
`MAX_SVG_BYTES`; `MAX_SVG_SEGMENTS` and `MAX_SVG_GROUPS`, what a page
|
|
237
|
+
may cost a reader to paint; and `MAX_SVG_COORDINATE` and `MAX_SVG_DEPTH`,
|
|
238
|
+
from which an engine derives how far its arithmetic may stray from that
|
|
239
|
+
extent. And of an image's bytes, where a builder reads them when a person
|
|
240
|
+
adds an image (0033): `MAX_ASSET_BYTES`, the most an asset may have, which
|
|
241
|
+
this package held before and report-spec holds now, exported under the same
|
|
242
|
+
name; `MAX_ASSET_SIDE`, the most pixels a side of a PNG or a JPEG;
|
|
243
|
+
`sniffImage`, what bytes are by their first bytes; and `imageHeader` with
|
|
244
|
+
`IMAGE_REFUSAL_CODES`, a PNG's or a JPEG's structure, read whole but for a
|
|
245
|
+
PNG's image data, which an engine inflates itself. An engine
|
|
246
|
+
depends on the runtime alone, and draws and refuses by the one decision the
|
|
247
|
+
editor refuses by.
|
|
248
|
+
|
|
249
|
+
## What it does not do
|
|
250
|
+
|
|
251
|
+
- **Fetch anything.** The data and the asset bytes are the host's to hand
|
|
252
|
+
over; the runtime reads no database and follows no address.
|
|
253
|
+
- **Check an image's digest.** The host's lookup is trusted to return the
|
|
254
|
+
bytes the digest pins. Not for want of a hash: a pure SHA-256,
|
|
255
|
+
`@noble/hashes`', reaches the runtime through `@formancy/spec`, and
|
|
256
|
+
report-spec's `assetDigest` names an added image by it; checking
|
|
257
|
+
digests changes what every host's resolver must satisfy, and is a
|
|
258
|
+
decision of its own
|
|
259
|
+
([0030](../../docs/decisions/0030-an-image-asset-may-be-an-svg-of-drawing-elements-alone-cleaned-once-and-refused-at-print-in-any-other-form.md)).
|
|
260
|
+
So what prints of an SVG is in the approved form, and that it is the
|
|
261
|
+
approved drawing is the host's to keep.
|
|
262
|
+
- **Format with one engine's results everywhere.** Grouping marks, month
|
|
263
|
+
names and currency symbols are the engine's ICU's, so the same report can
|
|
264
|
+
print differently on two engines.
|
|
265
|
+
- **Embed an e-invoice, or make a PDF/A.** It writes the XML and names the
|
|
266
|
+
file; the engine embeds it, changed in nothing, in the PDF/A-3b it draws
|
|
267
|
+
([0031](../../docs/decisions/0031-an-e-invoice-is-drawn-as-a-pdf-a-3b-that-embeds-its-xml.md)).
|
|
268
|
+
- **Encode a QR code.** It hands the engine the text a QR code's content
|
|
269
|
+
prints, formatted as a paragraph with the same content prints it, and a
|
|
270
|
+
QR-bill's and an EPC QR code's payloads; the engine encodes and draws
|
|
271
|
+
them, lays the slip out, and frames and captions the EPC QR code.
|
|
272
|
+
- **Compile once per render.** Each expression is compiled twice: once by
|
|
273
|
+
`diagnose`, once to evaluate.
|
|
274
|
+
|
|
275
|
+
Source-available, not open source: see [`LICENSE.md`](../../LICENSE.md).
|