@formancy/report-runtime 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +434 -15
- package/dist/index.d.mts +661 -66
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2238 -644
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@ totals with exact decimals, and formats each value for the report's locale,
|
|
|
8
8
|
once. No framework, no PDF engine, no Node. What it decides, and why, is
|
|
9
9
|
decision
|
|
10
10
|
[0010](../../docs/decisions/0010-the-runtime-resolves-a-report-into-a-renderer-neutral-document.md).
|
|
11
|
+
It also holds the one rule every engine draws a code's symbol by
|
|
12
|
+
([A code's symbol](#a-codes-symbol)).
|
|
11
13
|
|
|
12
14
|
## Resolve
|
|
13
15
|
|
|
@@ -27,7 +29,7 @@ const images: ImageResolver = ({ asset, digest }) => approvedAssets.get(`${asset
|
|
|
27
29
|
const resolution = resolveReport(report, data, { mode: 'final', parameters: { copies: '2' }, images, creationDate: '2026-10-15T08:00:00Z', timeZone: 'Europe/Zurich' })
|
|
28
30
|
if (resolution.ok) {
|
|
29
31
|
resolution.document // what @formancy/report-render-pdf draws
|
|
30
|
-
resolution.manifest // the report's hash, locale, zone, mode, consistency, completeness, parameters
|
|
32
|
+
resolution.manifest // the report's hash, locale, zone, mode, consistency, completeness, parameters, and the data's source where it names one
|
|
31
33
|
} else {
|
|
32
34
|
resolution.errors // each with the stage that found it, a stable code, a JSON Pointer, never a value
|
|
33
35
|
}
|
|
@@ -59,10 +61,32 @@ if (resolution.ok) {
|
|
|
59
61
|
resolved it (`resolve`, `invalid-e-invoice`): a text, a date, a line's
|
|
60
62
|
term, a table of no rows in a final render, or a payment code that asks
|
|
61
63
|
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
|
|
64
|
+
where it stands, its business term and its rule, never by the value;
|
|
65
|
+
- a chart of more categories than `MAX_CHART_CATEGORIES`, or a pie of
|
|
66
|
+
more categories than its palette has colours (`resolve`,
|
|
67
|
+
`chart-too-many-categories`), and a pie with a negative value
|
|
68
|
+
(`chart-negative-share`), each naming the chart by its id and saying
|
|
69
|
+
counts, never a value or a category: see [A chart](#a-chart);
|
|
70
|
+
- a locale the report is not written in (`resolve`, `undeclared-locale`),
|
|
71
|
+
and a word missing in the one it names (`expressions`, `word-missing`):
|
|
72
|
+
see [A report in several languages](#a-report-in-several-languages).
|
|
63
73
|
|
|
64
74
|
It never returns part of a document.
|
|
65
75
|
|
|
76
|
+
A table's group header row carries `keepWithRows`, how many of its group's
|
|
77
|
+
first rows an engine keeps it on its page with: the number its group
|
|
78
|
+
states, or the group's rows where it has fewer, and only where that is
|
|
79
|
+
more than one. How many rows a group has is this package's grouping,
|
|
80
|
+
counted once, and a report that states no count resolves to the document
|
|
81
|
+
it did before
|
|
82
|
+
([0059](../../docs/decisions/0059-a-group-header-is-kept-on-its-page-with-as-many-of-its-groups-first-rows-as-the-report-states-or-as-fit.md)).
|
|
83
|
+
|
|
84
|
+
A table every column of which a render shows is titled with nothing, or
|
|
85
|
+
with white space alone, resolves with no `header` and no `headerStyle`,
|
|
86
|
+
decided here once, so that no engine prints a band of nothing over its
|
|
87
|
+
rows: code that reads a resolved table's `header` takes one without it
|
|
88
|
+
([0078](../../docs/decisions/0078-a-table-whose-every-column-title-prints-nothing-has-no-header-row.md)).
|
|
89
|
+
|
|
66
90
|
## The data
|
|
67
91
|
|
|
68
92
|
One header record and one detail list, with what the provider says about
|
|
@@ -95,6 +119,116 @@ preview lacked a value for it, since its code would scan as a payment no
|
|
|
95
119
|
bank makes. The host's objects are read
|
|
96
120
|
once, as data: a getter is never run, and a proxy that throws is refused.
|
|
97
121
|
|
|
122
|
+
**Where it came from.** The data may name its `source`, and the manifest
|
|
123
|
+
carries it as `source`, so that a PDF kept with its manifest says what
|
|
124
|
+
collected its data
|
|
125
|
+
([0041](../../docs/decisions/0041-a-renders-manifest-names-where-its-data-came-from-by-identifiers-alone.md)):
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
// Read from a formancy form: each submission, with the form's id and the schemaHash of the version that collected it.
|
|
129
|
+
source: { provider: 'formancy-form', submissions: [{ id: 'b682a5ed-ed01-4f8c-8d80-cf53db4e8380', form: 'site-visit', formHash: '767a65b36d4c02adf432d91ccdf7f8f285eebdbfc2987fb08fecd846b721dc42' }] }
|
|
130
|
+
// Read from Formancy Data: the published form each dataset was read from, as @formancy/report-data-provider names it.
|
|
131
|
+
source: { provider: 'formancy-data', forms: { header: 'order', detail: 'order-line' } }
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The form's id is each submission's, since a new version of a form may
|
|
135
|
+
change it. A source is for identifiers alone, since a manifest is kept
|
|
136
|
+
longer than any log, and is held to their syntax, not their meaning. A form's id
|
|
137
|
+
and a version's hash are held to the rules a report's provenance is,
|
|
138
|
+
report-spec's `isFormId` and `isSchemaHash`; a submission's id is
|
|
139
|
+
letters, digits, `.`, `_` and `-`, starting with a letter or a digit, at
|
|
140
|
+
most 128 characters, the rule `isSubmissionId` exports, which the form
|
|
141
|
+
bridge holds an id to before it reads a submission
|
|
142
|
+
([0042](../../docs/decisions/0042-a-report-reads-a-formancy-forms-submissions-against-the-exact-version-that-collected-them-as-the-host-hands-them-over.md)).
|
|
143
|
+
So a space, an `@`, a `/`, a `:`, a letter beyond
|
|
144
|
+
ASCII or a 129th character is refused, and with them a full name or an
|
|
145
|
+
email address; a single word, a personal number or any 64 hex digits as a
|
|
146
|
+
hash fits, and the syntax cannot tell it from an identifier. A key a
|
|
147
|
+
source's shape does not name, more submissions than the detail rows given
|
|
148
|
+
(or than one where none are), a submission named twice, a Formancy Data
|
|
149
|
+
source naming no form, a form for a dataset the report does not declare
|
|
150
|
+
or none for one it does, and a provider the runtime does not know are
|
|
151
|
+
each refused, as `invalid-source`, never naming the value or the key. Its
|
|
152
|
+
syntax is checked, not its truth: that the host read what it names is the
|
|
153
|
+
provider's word, as its completeness is. Data that names no source is
|
|
154
|
+
read as before, and its manifest has none. A formancy form's source names
|
|
155
|
+
the `locale` its labels were read in, where that is not the report's own,
|
|
156
|
+
held to the syntax a report's locale is (report-spec's `isLocale`): see
|
|
157
|
+
[A report in several languages](#a-report-in-several-languages).
|
|
158
|
+
|
|
159
|
+
## A report in several languages
|
|
160
|
+
|
|
161
|
+
A report may write its own words in each language its `translations`
|
|
162
|
+
declare, and a render names the one it prints in with `locale`
|
|
163
|
+
([0063](../../docs/decisions/0063-a-reports-own-words-are-written-in-each-language-it-declares-and-a-render-names-the-one-it-prints-in.md)):
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
const french = resolveReport(report, data, { mode: 'final', creationDate: '2026-10-15T08:00:00Z', locale: 'fr-CH' })
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
- **A declared locale, exactly.** The report's own `locale` or one its
|
|
170
|
+
translations declare; any other is refused as `undeclared-locale`, a
|
|
171
|
+
near one among them: `fr-FR` is not `fr-CH`, and `fr` is neither. A
|
|
172
|
+
render that names none prints in the report's own, and one that names
|
|
173
|
+
the report's own prints the same document as one that names none.
|
|
174
|
+
- **The report written in it.** What every stage reads is report-spec's
|
|
175
|
+
`reportIn`: each word and each expression that prints words in that
|
|
176
|
+
language, `locale` the render's, so that its values are formatted, its
|
|
177
|
+
rows, groups and a chart's categories ordered, in it, and a QR-bill's
|
|
178
|
+
headings in its language where SIX has headings in it. No stage of the
|
|
179
|
+
runtime has a language step of its own.
|
|
180
|
+
- **An error refuses its own language.** Of report-core's diagnostics, an
|
|
181
|
+
error that names a language -- a word missing in it, `word-missing`, a
|
|
182
|
+
translated expression that would print another thing -- refuses a
|
|
183
|
+
render in that language alone; one that names none refuses every
|
|
184
|
+
render. A report whose French lacks a word prints in German as the same
|
|
185
|
+
report without translations does. A word is never printed in another
|
|
186
|
+
language than the one a render names.
|
|
187
|
+
- **The manifest** names the template's hash, translations and all, and
|
|
188
|
+
the locale the render printed in.
|
|
189
|
+
- **A form's labels in it.** Data read from a formancy form whose labels
|
|
190
|
+
were read in another locale than the render's is refused as
|
|
191
|
+
`labels-locale-differs`: a source that names no locale was read in the
|
|
192
|
+
report's own, so submissions read once in German are refused in a French
|
|
193
|
+
render rather than print German labels in it. A report's other data, a
|
|
194
|
+
parameter's value among it, prints as the host hands it over, in
|
|
195
|
+
whatever language the host chose.
|
|
196
|
+
|
|
197
|
+
The runtime's own words -- a preview's label, an XRechnung copy's label and
|
|
198
|
+
paragraph, a boolean's `true` and `false` -- are English in every
|
|
199
|
+
language. The one exception is the label of a copy of an e-invoice, which
|
|
200
|
+
is written in the language the render prints in, or refused
|
|
201
|
+
([0077](../../docs/decisions/0077-a-report-that-carries-an-e-invoice-is-written-into-a-word-file-as-the-copy-the-runtime-labels-on-every-page.md)). A translation's locale the engine's `Intl` cannot write is
|
|
202
|
+
refused as `unsupported-locale`, at the translation that declares it.
|
|
203
|
+
|
|
204
|
+
## Several tables
|
|
205
|
+
|
|
206
|
+
A report may hold several tables over its detail rows
|
|
207
|
+
([0062](../../docs/decisions/0062-a-report-holds-several-tables-over-its-detail-rows-each-printing-and-totalling-the-rows-its-condition-selects.md)), and each prints the rows its own condition selects:
|
|
208
|
+
|
|
209
|
+
- **Its condition**, `rowsWhen`, is read once a detail row, in the row's
|
|
210
|
+
scope and the data's order, before anything is ordered, each reading
|
|
211
|
+
within the render's step budget; a table without one has every row.
|
|
212
|
+
One that fails for a row refuses the render (`evaluation`), naming the
|
|
213
|
+
row by its index in the data. A preview whose data lacks a field it
|
|
214
|
+
reads leaves the row out of that table, warned once for the field.
|
|
215
|
+
- **Its order and groups** are `sort-group.ts`'s, over the rows it
|
|
216
|
+
selected, each kept at its index in the data, so an error names the row
|
|
217
|
+
the provider gave and a total reads the right row's value.
|
|
218
|
+
- **Its totals** are the declared aggregates over those rows, by the
|
|
219
|
+
function a group's are, `Totals.over`, rounded once, read as
|
|
220
|
+
`table.<id>` in its total rows and its group's header and footer. A
|
|
221
|
+
table without a condition is handed the report's totals themselves, so
|
|
222
|
+
`table.net` and `totals.net` are one value there, and a report without
|
|
223
|
+
conditions resolves to the document it did. `totals` is every detail
|
|
224
|
+
row's everywhere, under such a table as in the summary, a payment code,
|
|
225
|
+
the e-invoice and a chart.
|
|
226
|
+
- **A table that selects no row** prints its empty text, and its total
|
|
227
|
+
rows beneath it, a count and a sum of nothing 0 and the rest nothing.
|
|
228
|
+
|
|
229
|
+
The document is unchanged: a table is the rows it prints, and the
|
|
230
|
+
renderer draws any number of them.
|
|
231
|
+
|
|
98
232
|
## A QR-bill
|
|
99
233
|
|
|
100
234
|
A report's payment part resolves to the document's `paymentPart`
|
|
@@ -143,13 +277,117 @@ or null for the payer to fill in, written as short as it can be --
|
|
|
143
277
|
with a third decimal is refused. The whole payload is at most 331 bytes in
|
|
144
278
|
UTF-8, counted in bytes, not in characters.
|
|
145
279
|
|
|
280
|
+
## A code's symbol
|
|
281
|
+
|
|
282
|
+
What a QR code, an EPC QR code and a QR-bill's Swiss QR Code are drawn
|
|
283
|
+
from, and what each is refused by, is decided here once, for every
|
|
284
|
+
engine
|
|
285
|
+
([0074](../../docs/decisions/0074-a-qr-code-and-an-epc-qr-code-are-written-into-a-word-file-and-what-refuses-a-code-stands-below-both-engines.md)).
|
|
286
|
+
The document carries a code's text; an engine asks for its symbol when it
|
|
287
|
+
checks the document, once, and draws what it is handed:
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
import { epcSymbol, qrSymbol, swissSymbol } from '@formancy/report-runtime'
|
|
291
|
+
|
|
292
|
+
qrSymbol(code, width) // a `qrCode` block's symbol where it stands `width` points wide
|
|
293
|
+
epcSymbol(code, width) // an `epcQrCode` block's
|
|
294
|
+
swissSymbol(payload) // a QR-bill's Swiss QR Code's
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Each returns a `QrSymbol`, the rows of its modules without a quiet zone,
|
|
298
|
+
or throws the `RenderRefusal` an engine refuses the document with, naming
|
|
299
|
+
the code by its id and never quoting what it holds. The text is encoded by
|
|
300
|
+
[uqr](https://github.com/unjs/uqr) 0.1.3, this package's one dependency
|
|
301
|
+
that is not formancy's: as UTF-8 in byte mode, or in the denser modes for
|
|
302
|
+
digits and capitals, in the smallest version that holds it at its level,
|
|
303
|
+
which is never raised.
|
|
304
|
+
|
|
305
|
+
- **A QR code** ([0020](../../docs/decisions/0020-a-qr-code-is-drawn-from-its-own-matrix-and-refused-where-it-may-not-scan.md)) is refused as `unsupported` where its size is
|
|
306
|
+
no positive number, its level none of L, M, Q and H, or its text no
|
|
307
|
+
string or half of a surrogate pair; and as `content-too-large` where it
|
|
308
|
+
is wider than where it stands, holds more than `QR_MAX_CHARACTERS`
|
|
309
|
+
characters, 7089, refused before it is encoded, or more bytes than a
|
|
310
|
+
version holds at its level, or would have modules finer than
|
|
311
|
+
`QR_MIN_MODULE`, 0.4 mm, in its square with its `QR_QUIET_ZONE` of four
|
|
312
|
+
modules a side.
|
|
313
|
+
- **An EPC QR code** ([0025](../../docs/decisions/0025-a-report-prints-an-epc-qr-code-held-to-the-epc-rules-beside-the-qr-bill.md)) is encoded at level M, in version 13 at
|
|
314
|
+
the most, and held to the same square and, without a caption, the same
|
|
315
|
+
floor; with Austria's caption, to the squares report-spec's
|
|
316
|
+
`epcCaptionBreak` prints one in, before it is encoded, and at the least
|
|
317
|
+
version whose modules are the PSA's (`epcLeastVersion`), to that
|
|
318
|
+
version's modules after.
|
|
319
|
+
- **A Swiss QR Code** ([0022](../../docs/decisions/0022-a-report-carries-one-swiss-qr-bill-at-the-foot-of-its-last-page.md)) is encoded at level M, in version 25 at
|
|
320
|
+
the most, and refused past `SWISS_QR_MAX_CHARACTERS`, 997, naming the
|
|
321
|
+
payment part. SIX prints it at 46 mm whatever its version, so it is
|
|
322
|
+
held to no floor.
|
|
323
|
+
|
|
324
|
+
`qrSymbolVersion(symbol)` is the version a symbol is. Whether a page is
|
|
325
|
+
tall enough for a code is an engine's to say: the PDF renderer measures
|
|
326
|
+
its body, and the Word writer its printable area. Resolving a report
|
|
327
|
+
calls none of these: a report whose code is too long for its square
|
|
328
|
+
resolves, and is refused where it is drawn or written.
|
|
329
|
+
|
|
330
|
+
## A QR-bill's slip
|
|
331
|
+
|
|
332
|
+
What refuses a QR-bill before an engine lays its slip out, and where SIX
|
|
333
|
+
puts each part of the slip, stand here too, below every engine
|
|
334
|
+
([0075](../../docs/decisions/0075-a-qr-bills-slip-is-written-into-a-word-file-on-a-page-of-its-own-and-every-line-of-it-is-shown-to-fit.md)):
|
|
335
|
+
the PDF renderer draws the slip at the foot of the last page and the
|
|
336
|
+
Word writer on a page of the file's own, from one set of numbers, and
|
|
337
|
+
both refuse the same bills in the same words.
|
|
338
|
+
|
|
339
|
+
`checkQrBill(bill, page, undrawn)` returns the bill with its Swiss QR
|
|
340
|
+
Code's symbol, encoded once, or throws the `RenderRefusal` an engine
|
|
341
|
+
refuses the document with, naming `paymentPart` and the field and never
|
|
342
|
+
quoting a value: a kind nobody knows, a page that is not A4 upright or
|
|
343
|
+
whose top margin reaches into the slip (`refuseBillPage`, report-spec's
|
|
344
|
+
`qrBillPageBreak`), text that is not text, a value longer than any SIX
|
|
345
|
+
allows, an address of other than two or three lines, more than two lines
|
|
346
|
+
of additional information, a currency that is none of
|
|
347
|
+
`QR_BILL_CURRENCIES`, and an amount not written as a slip prints one or
|
|
348
|
+
past SIX's range. `undrawn` is the one thing an engine says itself, since
|
|
349
|
+
only it knows the face it draws in: for a text and the face it prints in
|
|
350
|
+
(`BillFace`, each heading's in `BILL_HEADING_FACES`), the rest of the
|
|
351
|
+
sentence that says what its face does not draw, or nothing.
|
|
352
|
+
|
|
353
|
+
`SLIP_RECEIPT` and `SLIP_PAYMENT_PART` are the two parts as SIX's style
|
|
354
|
+
guide lays them out, in points from the slip's top left: where the
|
|
355
|
+
title, the information and the amount section stand, the sizes of
|
|
356
|
+
headings and values and the pitch of their lines, and the blank fields.
|
|
357
|
+
`slipBlocks(bill, part)` is a part's information in SIX's order, each
|
|
358
|
+
heading over its values or over a blank field. Beside them stand
|
|
359
|
+
`SLIP_RECEIPT_WIDTH`, `SLIP_CODE`, `SLIP_ACCEPTANCE`, `SLIP_INSTRUCTION`,
|
|
360
|
+
`SLIP_SEPARATION`, `SLIP_CORNER`, `SLIP_FIELD_GAP` and `SLIP_TITLE`, and
|
|
361
|
+
the code's `SWISS_CODE_SIZE`, 46 mm, and `SWISS_CROSS`. Resolving a
|
|
362
|
+
report calls none of these.
|
|
363
|
+
|
|
146
364
|
## An e-invoice
|
|
147
365
|
|
|
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
|
|
149
|
-
`eInvoice
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
366
|
+
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, in a final render, to the
|
|
367
|
+
document's `eInvoice`, an `EInvoiceFile` of its kind:
|
|
368
|
+
|
|
369
|
+
- **A Factur-X file** (`FacturXFile`, `kind: 'facturX'`): the CII XML of a
|
|
370
|
+
Factur-X 1.09.2 / ZUGFeRD 2.5.2 invoice in the EN 16931 profile, and what
|
|
371
|
+
the renderer embeds it as, `fileName`, `relationship` and
|
|
372
|
+
`conformanceLevel`, report-spec's `FACTUR_X` and `FACTUR_X_PROFILES` [S].
|
|
373
|
+
- **An XRechnung's file** (`XRechnungFile`, `kind: 'xrechnung'`,
|
|
374
|
+
[0038](../../docs/decisions/0038-a-reports-e-invoice-may-be-an-xrechnung-3-0-whose-xml-a-host-takes-and-whose-pdf-is-its-labelled-copy.md)):
|
|
375
|
+
the CII XML of an XRechnung 3.0, the invoice itself, which a host takes
|
|
376
|
+
from the document and sends -- to a portal, by email or over Peppol, as
|
|
377
|
+
the buyer asks; nothing here sends it -- with its `syntax`, `'cii'`, its
|
|
378
|
+
`guideline`, BT-24, and its `version`, report-spec's `XRECHNUNG`. Its XML
|
|
379
|
+
is the very XML a Factur-X invoice of the same terms is, BT-24 apart: one
|
|
380
|
+
writer. Every page of the document is headed `XRECHNUNG_COPY_LABEL`,
|
|
381
|
+
since a PDF drawn of it is a copy, in the paragraph the runtime exports
|
|
382
|
+
frozen as `XRECHNUNG_COPY_PARAGRAPH`, small, bold and red; the renderer
|
|
383
|
+
draws the document as a plain PDF that embeds nothing, and refuses one
|
|
384
|
+
whose page header, or page 1's own header where it has one, does not
|
|
385
|
+
open with that paragraph, style and all.
|
|
386
|
+
|
|
387
|
+
```ts
|
|
388
|
+
const resolution = resolveReport(xrechnung, data, { mode: 'final', creationDate })
|
|
389
|
+
if (resolution.ok && resolution.document.eInvoice?.kind === 'xrechnung') send(resolution.document.eInvoice.xml)
|
|
390
|
+
```
|
|
153
391
|
|
|
154
392
|
- **The lines are the table's.** Each row of the table the e-invoice names
|
|
155
393
|
is a line. The four columns it names -- the item, the quantity, the net
|
|
@@ -174,7 +412,17 @@ EN 16931 profile, and what the renderer embeds it as, `fileName`,
|
|
|
174
412
|
BIC, a day on the calendar, a net price not below zero, a net amount of
|
|
175
413
|
whole cents, never rounded, a category the invoice declares, a character
|
|
176
414
|
XML can hold, and no white space a token collapses in an identifier or a
|
|
177
|
-
code the XML writes as one
|
|
415
|
+
code the XML writes as one, and a contact's telephone number and email
|
|
416
|
+
address to XRechnung's shapes, and an electronic address under 0204 to a
|
|
417
|
+
Leitweg-ID's shape and check digits. An XRechnung's texts are held to its
|
|
418
|
+
kind's rules: each term XRechnung needs is needed, the contact's three
|
|
419
|
+
among them, and its payment terms hold no line led by `#`, which
|
|
420
|
+
XRechnung reads as its Skonto syntax. An optional text that prints nothing is
|
|
421
|
+
left out -- the business process, an electronic address with its scheme,
|
|
422
|
+
and the contact whole where it has none of its three, though a contact
|
|
423
|
+
given in part is refused at each term it lacks, since a contact gives
|
|
424
|
+
all three or none
|
|
425
|
+
([0037](../../docs/decisions/0037-an-e-invoice-may-name-electronic-addresses-the-sellers-contact-and-its-business-process-none-needed-for-german-b2b.md)); a needed one is
|
|
178
426
|
refused by the rule that needs it; one that prints something around a
|
|
179
427
|
null is refused as cut short. What only the whole says -- the seller's
|
|
180
428
|
and the buyer's identifiers, the time of supply, an exempt category's
|
|
@@ -190,6 +438,29 @@ EN 16931 profile, and what the renderer embeds it as, `fileName`,
|
|
|
190
438
|
reference so that a parser gives it back; a character XML 1.0 cannot hold
|
|
191
439
|
is refused where it is read. The same report and data are the same
|
|
192
440
|
bytes.
|
|
441
|
+
- **A copy, where a host asks for one**
|
|
442
|
+
([0077](../../docs/decisions/0077-a-report-that-carries-an-e-invoice-is-written-into-a-word-file-as-the-copy-the-runtime-labels-on-every-page.md)).
|
|
443
|
+
`resolveReport(report, data, { mode: 'final', eInvoice: 'copy' })`
|
|
444
|
+
resolves the same final render as its copy: the page header, and page
|
|
445
|
+
1's own where the report has one, each open with the copy's label, the
|
|
446
|
+
manifest says `eInvoice: 'copy'`, and the document carries no
|
|
447
|
+
`eInvoice`, so nothing can embed or send an invoice from it. It is
|
|
448
|
+
what a Word file is written of. The terms are held and the XML written
|
|
449
|
+
as for the invoice, then dropped, so a copy is refused wherever the
|
|
450
|
+
invoice is. The label says that the page is a copy, what the invoice
|
|
451
|
+
is -- the PDF that embeds its XML, of a Factur-X, or its XML, of an
|
|
452
|
+
XRechnung, whose copy carries this label in the place of
|
|
453
|
+
`XRECHNUNG_COPY_LABEL` -- and that this document is not it, in the
|
|
454
|
+
language of the render's locale: `E_INVOICE_COPY_LABELS`, written in
|
|
455
|
+
`E_INVOICE_COPY_LANGUAGES`, German, English, Spanish, French, Italian
|
|
456
|
+
and Dutch, four of which no native speaker has read.
|
|
457
|
+
`eInvoiceCopyParagraph(kind, locale)` is the paragraph as the runtime
|
|
458
|
+
writes it, frozen, and `readCopyLabel(header)` says which label a
|
|
459
|
+
header opens with and whether it stands as written, which is how an
|
|
460
|
+
engine knows a copy. Refused, `no-e-invoice-copy`: a copy of a preview,
|
|
461
|
+
which writes no XML to be a copy of; a copy in a language no label is
|
|
462
|
+
written in, at the locale; and any other value of the option. Of a
|
|
463
|
+
report that carries no e-invoice the option says nothing.
|
|
193
464
|
- **A preview is not the invoice.** It prints the totals of what it has,
|
|
194
465
|
takes a term it has no value for as one it lacks and holds what the data
|
|
195
466
|
does give to the rules; it writes no XML, warns `e-invoice-preview`, and
|
|
@@ -203,13 +474,135 @@ seconds, against 2.0 for the same report and rows without the e-invoice;
|
|
|
203
474
|
0.23 (five runs each, from the built package, Node 24.21.0, an Intel
|
|
204
475
|
i9-10900K, 17 October 2026). The e-invoice has no bound of its own yet.
|
|
205
476
|
|
|
477
|
+
## A chart
|
|
478
|
+
|
|
479
|
+
A `chart` component resolves to a `chart` block (`Chart`, an `AxisChart`
|
|
480
|
+
or a `PieChart`), which holds every word the chart prints and every number
|
|
481
|
+
as its exact digits beside its text
|
|
482
|
+
([0055](../../docs/decisions/0055-the-runtime-resolves-a-chart-exactly-its-totals-as-every-total-and-every-word-it-prints.md),
|
|
483
|
+
[0052](../../docs/decisions/0052-a-report-draws-a-bar-line-or-pie-chart-of-its-detail-rows-each-series-a-total-of-one-field-per-category.md)):
|
|
484
|
+
|
|
485
|
+
```ts
|
|
486
|
+
// A bar chart of sales by region, beside a table grouped by region, in a format of two places:
|
|
487
|
+
const chart = resolution.document.body.find((block) => block.kind === 'chart')
|
|
488
|
+
if (chart?.kind === 'chart' && chart.chart !== 'pie' && chart.empty === undefined) {
|
|
489
|
+
chart.categories // ['North', 'South', 'No region']: each key in the category's format, the rows without one under nullLabel
|
|
490
|
+
chart.series[0]?.values[0] // { exact: '10.25', text: '10.25' }: a coordinate from exact, the text printed; null where a series has no value
|
|
491
|
+
chart.ticks.map(({ text }) => text) // ['0.00', '5.00', '10.00', '15.00', '20.00', '25.00']: the value axis, fixed
|
|
492
|
+
}
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
- **Its categories** are grouped where a table's rows are: sorted by the
|
|
496
|
+
table's own order, the rows without one last, or in the order the data
|
|
497
|
+
first gives each, one key each, so that 1.0 and 1.00 are one category,
|
|
498
|
+
printed with no format as its first row in the data's order spells it.
|
|
499
|
+
The rows without a category are one category under its `nullLabel`. A
|
|
500
|
+
chart with no `nullLabel`, possible only over a field that may not be
|
|
501
|
+
null, prints an empty label in a preview that lacks the field, the data
|
|
502
|
+
check having warned; one with a label prints its label.
|
|
503
|
+
- **Each series** is totalled by `totalOf`, the function every aggregate
|
|
504
|
+
and every group's total is, in the decimals report-core's `seriesType`
|
|
505
|
+
gives an aggregate of the same function over the same field: a bar
|
|
506
|
+
prints what the table's group footer of the same rows prints in the same
|
|
507
|
+
format, a declared rounding applied once, and a rounding of an integer
|
|
508
|
+
total refused as `rounding-not-decimal`, as an aggregate's is.
|
|
509
|
+
- **The value axis** of a bar or a line chart is one, two or five times a
|
|
510
|
+
power of ten, the finest step that covers every value of every series
|
|
511
|
+
in at most `MAX_TICK_INTERVALS` intervals and no finer than the value
|
|
512
|
+
format prints, found by BigInt division. A bar's axis holds zero, and
|
|
513
|
+
so does a flat line's; any other line's is ticked over its own range.
|
|
514
|
+
An author cannot set either.
|
|
515
|
+
- **A pie's share** of each slice is its exact ratio to the sum of its
|
|
516
|
+
slices as they are totalled, rounded once, half away from zero, to
|
|
517
|
+
`SHARE_PLACES` places of a percentage, and printed by the formatter's
|
|
518
|
+
`percent`, which refuses a fraction Intl would round again
|
|
519
|
+
(`percent-rounds-again`), as no share is. Shares need not add up to
|
|
520
|
+
100.0 %, and a legend entry that labels its value reads
|
|
521
|
+
`label: value (share)` in every language. A slice's value prints only
|
|
522
|
+
in its legend entry, and a pie whose values its format cannot print is
|
|
523
|
+
refused though it labels none of them.
|
|
524
|
+
- **Nothing to draw** -- no rows, a bar or a line chart with no value, a
|
|
525
|
+
pie whose values are all zero -- is the chart's title and its empty text
|
|
526
|
+
alone, with no axis and no axis title.
|
|
527
|
+
- **Its colours** are the chart's own `palette` or `CHART_PALETTE`, a
|
|
528
|
+
series' at its place and a slice's at its category's.
|
|
529
|
+
|
|
530
|
+
A renderer prints the block's strings and no others, a pie's values only
|
|
531
|
+
in its legend, makes a coordinate of a value's `exact`, and formats no
|
|
532
|
+
number. This release's renderer does not
|
|
533
|
+
draw a chart yet, and refuses one.
|
|
534
|
+
|
|
535
|
+
## Page 1's own header
|
|
536
|
+
|
|
537
|
+
A report whose regions hold `firstPageHeader` gives page 1 a header of its
|
|
538
|
+
own, which page 1 prints in place of the page header
|
|
539
|
+
([0060](../../docs/decisions/0060-a-reports-first-page-may-print-a-header-of-its-own-or-none-in-place-of-the-page-header.md)).
|
|
540
|
+
The document carries it as `firstPageHeader`, beside `pageHeader`, present
|
|
541
|
+
exactly when the report's is:
|
|
542
|
+
|
|
543
|
+
- **Lowered as the page header is**, each component to the block it
|
|
544
|
+
prints, a component whose condition does not hold left out; one whose
|
|
545
|
+
every component is hidden is an empty list, page 1 with no header, never
|
|
546
|
+
the page header's blocks: the choice is the report's, not the data's.
|
|
547
|
+
- **An empty list is none.** Page 1 prints no header, and its body starts
|
|
548
|
+
at the top margin. A report without the region resolves to a document
|
|
549
|
+
without the key, as it always did.
|
|
550
|
+
- **Labelled as the page header is.** A preview's label, an e-invoice
|
|
551
|
+
preview's and an XRechnung's `XRECHNUNG_COPY_PARAGRAPH` head it too,
|
|
552
|
+
each header with a paragraph of its own, so that page 1 says it as every
|
|
553
|
+
page does; page 1's header that is none is the label alone.
|
|
554
|
+
- **No page field.** report-spec refuses a page number or count in it,
|
|
555
|
+
since the renderer draws it before the pages are counted; which page
|
|
556
|
+
prints which header is the renderer's to decide, and nothing here
|
|
557
|
+
evaluates anything per page.
|
|
558
|
+
|
|
559
|
+
## A run below or above the line
|
|
560
|
+
|
|
561
|
+
A paragraph's run carries the `baseline` its report's run sets,
|
|
562
|
+
`subscript` or `superscript`, a field's, a parameter's, an expression's
|
|
563
|
+
and an aggregate's value as literal text's, and a run that sets none
|
|
564
|
+
carries no key, so the document of a report that sets none is the one it
|
|
565
|
+
was ([0061](../../docs/decisions/0061-a-paragraphs-run-may-be-set-below-or-above-the-line-in-any-character-its-face-draws-and-prints-only-beside-a-run-on-the-line.md)).
|
|
566
|
+
A table's cell joins its runs into one string, as before, where
|
|
567
|
+
report-spec refuses a baseline. What such a run prints as is the
|
|
568
|
+
document's, for any engine:
|
|
569
|
+
|
|
570
|
+
```ts
|
|
571
|
+
import { SHIFTED_RISE, SHIFTED_SIZE } from '@formancy/report-runtime'
|
|
572
|
+
|
|
573
|
+
SHIFTED_SIZE // 0.58: the run's size, of its paragraph's, in the paragraph's face
|
|
574
|
+
SHIFTED_RISE // { superscript: 0.75 * 0.58, subscript: -0.35 * 0.58 }: its baseline's move, of the paragraph's size, up positive
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
They are pdfmake 0.3.11's own figures, 0.435 up and 0.203 down, which
|
|
578
|
+
the renderer has pdfmake draw and the corpus reads a PDF by: a renderer
|
|
579
|
+
that drew another fails there. `BASELINE_SHIFTS` and `BaselineShift` are
|
|
580
|
+
report-spec's, handed on, so that the format and the document name a
|
|
581
|
+
shift alike.
|
|
582
|
+
|
|
206
583
|
## What else is exported
|
|
207
584
|
|
|
208
585
|
Each stage is exported for a host or a tool that needs one alone:
|
|
209
586
|
`checkReport`, `checkData`, `checkParameters`, `readValue`,
|
|
210
|
-
`prepareExpressions`, `createFormatter`, `orderTable`
|
|
211
|
-
|
|
212
|
-
|
|
587
|
+
`isSubmissionId`, `prepareExpressions`, `createFormatter`, `orderTable`
|
|
588
|
+
-- given the rows a table's condition selected, as its optional fourth
|
|
589
|
+
argument, those alone, each kept at its index in the data (0062) -- and
|
|
590
|
+
the decimal arithmetic; the form bridge reads `readValue`,
|
|
591
|
+
`MAX_STRING_LENGTH`, `isSubmissionId` and `SUBMISSION_ID_SYNTAX`, the
|
|
592
|
+
words a refusal says that rule in, so that it holds an answer and an id
|
|
593
|
+
by this package's rules, and says them in its words, rather than a copy
|
|
594
|
+
of them (0042). `checkReport(report, locale?)` checks a report for a
|
|
595
|
+
render in a locale and hands back both the copy validation read and
|
|
596
|
+
`printed`, that copy written in the locale; `checkData` checks data
|
|
597
|
+
against the printed copy, told the report's own locale by
|
|
598
|
+
`reportLocale` (0063). The document's types, `RenderRefusal` and `REFUSAL_CODES` are
|
|
599
|
+
the renderer's contract, declared here so that no engine defines them; a
|
|
600
|
+
chart's among them, and `MAX_CHART_CATEGORIES`, `MAX_TICK_INTERVALS` and
|
|
601
|
+
`SHARE_PLACES`, the runtime's bounds on a chart, which a host that tells an
|
|
602
|
+
author of them reads rather than copies (0055), with report-spec's
|
|
603
|
+
`MAX_CHART_SERIES` beside them, which the renderer holds a chart's block to;
|
|
604
|
+
and `MAX_KEEP_WITH_ROWS`, report-spec's bound on the rows a group header
|
|
605
|
+
row keeps, is handed on for an engine to hold that row to (0059).
|
|
213
606
|
What report-spec decides of a QR-bill that an engine needs to draw its
|
|
214
607
|
slip is handed on as report-spec's own objects: `QR_BILL_SIZE` and
|
|
215
608
|
`QR_BILL_TOP`, the slip's size and place; `qrBillPageBreak` and its type
|
|
@@ -226,7 +619,9 @@ they are printed at and the least version that prints them. And of how an
|
|
|
226
619
|
e-invoice is embedded: `FACTUR_X`, the file's name and media type and the
|
|
227
620
|
XMP's namespace, prefix, document type and version, and
|
|
228
621
|
`FACTUR_X_PROFILES`, each profile's specification identifier,
|
|
229
|
-
conformance level and relationship [S]
|
|
622
|
+
conformance level and relationship [S]; and of what an XRechnung's file
|
|
623
|
+
says it is: `XRECHNUNG` and `XRECHNUNG_VERSIONS`, each version's
|
|
624
|
+
specification identifier, release and syntax (0038). And of an SVG asset
|
|
230
625
|
([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
626
|
`checkSvg`, which accepts only the drawing `cleanSvg` writes and says what
|
|
232
627
|
it costs to draw and how far the numbers the converter writes for it reach
|
|
@@ -242,10 +637,31 @@ this package held before and report-spec holds now, exported under the same
|
|
|
242
637
|
name; `MAX_ASSET_SIDE`, the most pixels a side of a PNG or a JPEG;
|
|
243
638
|
`sniffImage`, what bytes are by their first bytes; and `imageHeader` with
|
|
244
639
|
`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.
|
|
640
|
+
PNG's image data, which an engine inflates itself. And of a font's bytes
|
|
641
|
+
([0040](../../docs/decisions/0040-a-font-is-read-by-report-specs-own-reader-which-says-what-it-may-be-embedded-as-and-which-characters-it-draws.md)):
|
|
642
|
+
`readFont`, a font read whole or refused, for a host that approves fonts
|
|
643
|
+
beside its render code; `characterMap`, the characters a face maps as
|
|
644
|
+
fontkit maps them, which an engine reads its own faces with;
|
|
645
|
+
`FONT_REFUSAL_CODES`, `FONT_FORMATS` and `FONT_EMBEDDING_REFUSALS`; and
|
|
646
|
+
`MAX_FONT_BYTES` and `MAX_FONT_CHARACTERS`; `MIN_FONT_LINE` and
|
|
647
|
+
`MAX_FONT_LINE`, the line in ems a face may lay out, and `MIN_FONT_SIZE` and
|
|
648
|
+
`MAX_FONT_SIZE`, the sizes a report's text is set at, which an engine's page
|
|
649
|
+
bound counts a line by; and `PRINTED_BLOCKS`,
|
|
650
|
+
`BIDI_CONTROLS` and `refusedCharacter`, the characters a report prints,
|
|
651
|
+
Latin, Greek and Cyrillic and what is written with them (0043). An engine
|
|
246
652
|
depends on the runtime alone, and draws and refuses by the one decision the
|
|
247
653
|
editor refuses by.
|
|
248
654
|
|
|
655
|
+
A report that **maps** a font token to a host's font resolves to the bytes
|
|
656
|
+
the engine embeds ([0043](../../docs/decisions/0043-a-report-maps-its-font-tokens-to-fonts-the-host-approved-pinned-by-digest-and-the-renderer-embeds-them.md)):
|
|
657
|
+
`resolveReport` asks the host's lookup -- the image resolver, widened and
|
|
658
|
+
renamed `AssetResolver`, with `ImageResolver` kept as an alias -- for each
|
|
659
|
+
face by id and digest, reads its bytes with `readFont` before it hands them
|
|
660
|
+
on, and refuses the render where a mapped face cannot be had, is past
|
|
661
|
+
`MAX_FONT_BYTES`, which it holds before it copies the bytes, or the reader
|
|
662
|
+
refuses it, in a preview too. `ResolvedDocument.fonts` holds each token's
|
|
663
|
+
faces, bytes and all.
|
|
664
|
+
|
|
249
665
|
## What it does not do
|
|
250
666
|
|
|
251
667
|
- **Fetch anything.** The data and the asset bytes are the host's to hand
|
|
@@ -262,9 +678,12 @@ editor refuses by.
|
|
|
262
678
|
- **Format with one engine's results everywhere.** Grouping marks, month
|
|
263
679
|
names and currency symbols are the engine's ICU's, so the same report can
|
|
264
680
|
print differently on two engines.
|
|
265
|
-
- **Embed an e-invoice,
|
|
266
|
-
file; the engine embeds it, changed
|
|
681
|
+
- **Embed an e-invoice, make a PDF/A, or send an XRechnung.** It writes a
|
|
682
|
+
Factur-X invoice's XML and names the file; the engine embeds it, changed
|
|
683
|
+
in nothing, in the PDF/A-3b it draws
|
|
267
684
|
([0031](../../docs/decisions/0031-an-e-invoice-is-drawn-as-a-pdf-a-3b-that-embeds-its-xml.md)).
|
|
685
|
+
An XRechnung's XML no engine embeds: the host takes it from the
|
|
686
|
+
document and sends it, and nothing here sends it (0038).
|
|
268
687
|
- **Encode a QR code.** It hands the engine the text a QR code's content
|
|
269
688
|
prints, formatted as a paragraph with the same content prints it, and a
|
|
270
689
|
QR-bill's and an EPC QR code's payloads; the engine encodes and draws
|