@formancy/report-core 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 CHANGED
@@ -72,20 +72,108 @@ clamps when what it names is not there:
72
72
  already; a base that ends in a number is numbered as it stands, since
73
73
  it is a file's name (`img-4711` taken gives `img-4711-2`);
74
74
  - **components:** `insertComponent`, `removeComponent`, `moveComponent`,
75
- `updateComponent` (a patch typed per kind; the id and kind never change),
75
+ `updateComponent` (a patch typed per kind; the id and kind never change.
76
+ A chart's kind of chart is a property, so a bar chart becomes a line
77
+ chart through it, and its list of series changes through it too),
76
78
  `duplicateComponent` (fresh ids for the copy and all it holds), and
77
79
  `nextComponentId`, which also names a new component after its kind:
78
80
  `pageBreak` gives `page-break`, `qrCode` gives `qr-code`, `epcQrCode`
79
81
  gives `epc-qr-code`;
80
- - **the table:** `insertColumn`, `removeColumn` (with its footer cells),
82
+ - **a table:** `insertColumn`, `removeColumn` (with its footer cells),
81
83
  `moveColumn`, `updateColumn`, `setGroup`, `setSort`, and the footer rows
82
- under the table and under each group, row by row and cell by cell.
83
-
84
- No command edits a report's payment part yet, its Swiss QR-bill, or its
85
- e-invoice, and every one keeps each as it was: the very object, through
86
- every edit. `replaceDocument` takes them with the rest of the document. An
87
- edit that would leave an e-invoice's line with no column to print it, or
88
- with a column that may be hidden, is refused with the validator's reason.
84
+ under the table and under each group, row by row and cell by cell; its
85
+ condition, `rowsWhen`, changes through `updateComponent`, and a further
86
+ table comes in by `insertComponent` or `duplicateComponent`, which the
87
+ session refuses in a report that is an e-invoice
88
+ ([0062](../../docs/decisions/0062-a-report-holds-several-tables-over-its-detail-rows-each-printing-and-totalling-the-rows-its-condition-selects.md)). How
89
+ many of its first rows a group header is kept with, the group's
90
+ `keepWithRows`, has no command of its own: `setGroup` and
91
+ `updateComponent` carry it with the rest of the group, and the session
92
+ holds it to the validator, as every edit
93
+ ([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));
94
+ - **the first page header**, which page 1 prints in place of the page
95
+ header: `putFirstPageHeader(report, components)` gives page 1 a header of
96
+ its own, added or in place of the one it has, an empty one printing no
97
+ header; `removeFirstPageHeader` gives page 1 the page header back, what
98
+ its own held with it, and is refused as `not-found` where there is none.
99
+ Every component command works in it once it is there; a location in it
100
+ while it is not is refused as `not-found`
101
+ ([0060](../../docs/decisions/0060-a-reports-first-page-may-print-a-header-of-its-own-or-none-in-place-of-the-page-header.md));
102
+ - **the payment part**, the report's Swiss QR-bill: `putPaymentPart` (the
103
+ bill whole, added or in place of one), `updatePaymentPart` (a patch of
104
+ its properties, never its kind) and `removePaymentPart`, which judge
105
+ nothing of the bill: SIX's rules are report-spec's, which the session
106
+ asks
107
+ ([0039](../../docs/decisions/0039-a-person-selects-a-reports-qr-bill-and-edits-it-field-by-field-in-either-builder.md));
108
+ - **the e-invoice**, of either kind: `putEInvoice`, `updateEInvoice` (a
109
+ patch of its terms, never its kind) and `removeEInvoice`, which judge
110
+ nothing of it; and `setPaymentAccount(report, account)`, which writes
111
+ the account, as typed, into the e-invoice's BT-84, its QR-bill's account
112
+ and every EPC QR code's IBAN in one edit, since the validator holds each
113
+ code to BT-84 and refuses a change of any one alone. It is refused as
114
+ `not-found` without an e-invoice or an account, and as
115
+ `read-from-data`, naming the place, where one of them reads its account
116
+ from the data, which it would write over -- a builder's field writes its
117
+ own account then; whether each place takes the account is the
118
+ validator's to say, each by its own rule, and no BIC is changed
119
+ ([0044](../../docs/decisions/0044-a-person-edits-a-reports-e-invoice-in-either-builder-one-term-a-field-in-groups.md)).
120
+ - **the report's languages** ([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)): `addLanguage(report,
121
+ locale)`, a language with no words yet, refused as `already-declared`
122
+ for the report's own and one it has; `removeLanguage(report, locale)`,
123
+ with its words, the last leaving the report without translations;
124
+ `translateWord(report, locale, word, text)`, a word of the report's own
125
+ language written in a language it has, or taken back for `null`; and
126
+ `translateExpression(report, locale, cel, expression)`, an expression
127
+ that stands where words do written again in it. A word or a source the
128
+ report prints nowhere a word stands, and a language it has no
129
+ translation in, are refused as `not-found`; a blank translation and a
130
+ locale written otherwise are the validator's, which the session asks;
131
+ - **a field with what reads it:** `removeFieldWithReaders(report, role, id)`
132
+ removes the field and every component, column, footer cell, sort key,
133
+ group and aggregate that reads it, and every reader of such an
134
+ aggregate in turn; a style rule that reads it goes alone, what it
135
+ styled kept, and so does a chart's series that totals it, the chart's
136
+ other series kept; a footer row left with no cell goes whole, and so
137
+ does a table every column of which goes, a table whose condition reads
138
+ it, a chart every series of which goes and a chart whose category it
139
+ is, and what stands in a component that goes goes with it, once. What reads a
140
+ field is what the diagnostics find, from one walk, and in an
141
+ expression what the parser the compiler asks says it reads (an
142
+ expression that does not parse reads nothing). The outcome lists what
143
+ went, as JSON Pointers into the report before it, in `removed`. A field
144
+ the payment part or the e-invoice reads, directly or through an
145
+ aggregate, is refused as `read-by-part`: their own commands change them.
146
+ It is what a review of a form version offers where the version removed
147
+ a field. `fieldReaders(report)` makes that walk and reads every
148
+ expression once, for a review that asks of many fields: its
149
+ `removal(role, id)` is the command's, and its `expressions(role, id)`
150
+ the expressions a change of the field's type, or of whether it may be
151
+ null, reaches -- each that reads it, each that reads an aggregate that
152
+ does, in turn, and, for a field a table is grouped by, each that reads
153
+ that table's group's key, and no other table's (0062)
154
+ ([0048](../../docs/decisions/0048-a-form-version-that-removes-moves-or-retypes-a-field-a-report-reads-blocks-that-reports-submissions-of-it-until-reviewed-anything-else-prints.md));
155
+ - **several as one:** `batch(report, steps)` runs command descriptors one
156
+ after the other as one command -- a transaction written down, so that an
157
+ edit of several commands travels as data: one undo step, one
158
+ notification, validated once at its end, and refused whole with the
159
+ first refusal, word for word, nothing after it run. A step that is no
160
+ descriptor, or a batch itself, is refused as `invalid-arguments`, and so
161
+ is a batch of more than `MAX_BATCH_COMMANDS` (1,000) commands, before any
162
+ of it runs; and so is a step that throws on the report the steps before
163
+ it left, which no validator has seen (0048).
164
+
165
+ `PART_COMMANDS` names the commands that may change each part of the report's
166
+ own level -- the payment part's three, the e-invoice's three,
167
+ `setPaymentAccount` for both, and `replaceDocument` and `batch` for both,
168
+ whose document, or whose steps, may hold another part than the one it
169
+ replaces -- and every other command keeps each as it was: the very object,
170
+ through every edit. A review that looks for a change of whom a bill or an
171
+ e-invoice is paid by finds it by these names, and compares the part whole
172
+ for a replacement. An edit that would leave an e-invoice's line with no
173
+ column to print it, or with a column that may be hidden, is refused with the
174
+ validator's reason, and so is an edit of one payment code's account alone in
175
+ a report with an e-invoice, which pays BT-84: `setPaymentAccount` changes
176
+ them together.
89
177
 
90
178
  A patch removes an optional property with `null`, and `setGroup` and `setSort`
91
179
  remove theirs with `null`, never with `undefined`: a proposal carries its
@@ -96,7 +184,9 @@ and an index: where the component ends up. An index outside the list is
96
184
  refused, so a keyboard move and a pointer drop agree.
97
185
 
98
186
  `COMMANDS` holds every command by name, and a `CommandDescriptor` --
99
- `{ command, args }` -- is one as data, for a proposal. A descriptor read from
187
+ `{ command, args }` -- is one as data, for a proposal or a review's
188
+ resolution; a `StepDescriptor` is any of them but a batch, what a batch
189
+ holds. A descriptor read from
100
190
  JSON was never type-checked, so `describedCommand` checks its arguments
101
191
  against `ARGUMENTS` and refuses too few, too many or the wrong type with
102
192
  `invalid-arguments`. A descriptor never throws, whatever it holds. A typed
@@ -108,10 +198,11 @@ call to a command can pass none of these.
108
198
  move to it takes: the start of a keyboard move, the place to put focus
109
199
  after a deletion.
110
200
  - `locations(report)` is every place a component could be put, in reading
111
- order.
201
+ order, in every region the report holds: a first page header's only where
202
+ it has one.
112
203
  - `validLocations(report, componentOrId)` is the places the validator
113
- accepts it in: a page counter only in the page header and footer, a table
114
- never inside columns.
204
+ accepts it in: a page counter only in the page header and footer, never
205
+ in the first page's own header, a table never inside columns.
115
206
 
116
207
  The validator decides what may stand where (0007), so `validLocations` asks
117
208
  it, place by place, rather than copying its rules. It validates the whole
@@ -150,11 +241,16 @@ proposal's review shows before Apply.
150
241
  ## Expressions and diagnostics
151
242
 
152
243
  `compileReport(report)` compiles every expression where it stands, with
153
- `@formancy/expressions`, the compiler the runtime uses. It gives:
244
+ `@formancy/expressions`, the compiler the runtime uses; `compileReport(report,
245
+ only)` the expressions at the pointers `only` holds alone, with every
246
+ aggregate's, which what they read is computed from -- what a review asks
247
+ of a change to one field's type (0048). It gives:
154
248
 
155
249
  - the programs, keyed by the JSON Pointer to each expression;
156
250
  - what each program reads;
157
- - the members each name holds, typed;
251
+ - the members each name holds, typed: `table` the aggregates, as
252
+ `totals` and `group` are, and `groupKeys` the key of each table that
253
+ groups, by the table's id, typed by the field it groups by (0062);
158
254
  - the order to compute the aggregates in;
159
255
  - its errors.
160
256
 
@@ -169,6 +265,15 @@ decimal or null, by one rule for both. One that may be null is checked as
169
265
  `dyn`, which may be either, and the render checks what it holds. An integer
170
266
  or a string is a type error, with `dec()` as the hint.
171
267
 
268
+ A chart holds no expression
269
+ ([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)):
270
+ its category and each of its series read a detail field, whose type the
271
+ validator holds, and its formats may read a currency from a header field.
272
+ Each is named after the chart, as a field a text binds is, so a field only
273
+ a chart reads is not unused, and `fieldReaders` and a review find it.
274
+ Nothing of a chart is compiled but its `visibleWhen` and `styleWhen`, as
275
+ of every component.
276
+
172
277
  An e-invoice ([0027](../../docs/decisions/0027-a-report-carries-one-en-16931-invoice-written-from-the-values-its-page-prints.md)) is read as a payment part is: its texts in the
173
278
  report's scope, named by their paths alone. Its dates and its paid amount
174
279
  are values there, and the codes of each line -- its identifier, its unit
@@ -204,8 +309,10 @@ a report with an error, so the editor and the runtime cannot disagree about
204
309
  one.
205
310
 
206
311
  - **Errors:** syntax, limits, types, policy (a condition that is not a
207
- boolean), a name or member nothing declares, `row` or `group` where there is
208
- none, an image field read as a value, a name read whole (`size(params)`),
312
+ boolean), a name or member nothing declares, `row`, `group` or `table`
313
+ where there is none (`table` has a value in a table's total rows and
314
+ its group's header and footer, and a table's condition reads neither),
315
+ an image field read as a value, a name read whole (`size(params)`),
209
316
  a call to `now()`, `today()` or `random()`, an aggregate whose expression
210
317
  gives what its function cannot total, and aggregates that read their own
211
318
  total. And what would make a printed number inexact or a render unbounded:
@@ -213,12 +320,20 @@ one.
213
320
  `/`, which on integers drops the remainder (`divide(dec(a), dec(b), places)`
214
321
  is the exact one), and a call to `matches()`, whose pattern no step budget
215
322
  bounds. Each comes with the component, the table column where it is in
216
- one, and the position in its source. Two more are about totals: a rounding
217
- declared on an aggregate that computes an integer, a date or an instant,
218
- and a number format that prints a rounded total at fewer places than its
219
- rounding keeps, which would round it twice. And one is about an
220
- e-invoice: a total its XML holds that no text or table of the page
221
- prints (`e-invoice-total-unprinted`). Each of these is held: the total
323
+ one, and the position in its source. Two more are about totals, an
324
+ aggregate's or a chart's series': a rounding declared on one that
325
+ computes an integer, a date or an instant -- a series' count, or its
326
+ sum, least or greatest of integers -- and a number format that prints a
327
+ rounded total at fewer places than its rounding keeps, which would round
328
+ it twice, a series' printed in its chart's `valueFormat`. A series is
329
+ typed as the compiler types an aggregate of its function over its
330
+ field: `seriesType`, exported, is that type, by the one function the
331
+ compiler asks, `fieldTotalType`, and the runtime totals a series in it,
332
+ so the editor and a render cannot type a series apart
333
+ ([0055](../../docs/decisions/0055-the-runtime-resolves-a-chart-exactly-its-totals-as-every-total-and-every-word-it-prints.md)).
334
+ And one is about an e-invoice: a total its XML holds that no text or
335
+ table of the page prints (`e-invoice-total-unprinted`). Each of these is
336
+ held: the total
222
337
  without VAT, `invoice.taxBasisTotal` or `invoice.lineTotal`; the VAT
223
338
  total; the total with VAT; and each declared category's basis and amount.
224
339
  The paid amount and the amount due are held too where a paid amount is
@@ -230,10 +345,36 @@ one.
230
345
  A quantity's and a price's places are the data's, and the runtime holds
231
346
  them row by row.
232
347
  - **Warnings:** an unused style, asset, parameter, field or aggregate, an
233
- empty body, a text that prints nothing.
234
-
235
- Every member read is checked as its type. `@formancy/expressions` 0.6.0,
236
- as 0.5.0 before it, declares a variable only by its whole name, so each read of `row.amount` is
348
+ empty body, a text that prints nothing, a total of every detail row in
349
+ the total rows of a table that selects its rows -- an aggregate run
350
+ `over: 'report'`, or an expression that reads `totals` and not
351
+ `table` -- since printed there it reads as those rows'
352
+ (`total-of-every-row`, 0062), and a QR-bill that holds SIX's
353
+ examples, written in the report: an account of report-spec's
354
+ `QR_BILL_EXAMPLE_ACCOUNTS`, which pays no creditor, or the creditor, the
355
+ debtor or the QR reference a builder puts in, report-spec's
356
+ `QR_BILL_EXAMPLE` (`example-payment-part`, one warning on `/paymentPart`
357
+ naming each term that is an example).
358
+ - **In each language a report's translations declare**, after the
359
+ report's own and naming it as `language`, `languageDiagnostics(report,
360
+ locale)`'s (0063): each word the language does not translate, and each
361
+ expression that prints words, once where it first stands
362
+ (`word-missing`); a translated expression of another type than its
363
+ source, that reads another member or fails to read one, or that
364
+ translates an expression printing no words (`translation-differs`);
365
+ every diagnostic the report written in that language gives that its
366
+ own does not, a translated expression's at its translation; and a
367
+ translation of what the report no longer prints (`unused-translation`,
368
+ a warning). An expression where a word stands prints words where it
369
+ gives a string or a value the compiler cannot type, its run prints it
370
+ as text, and its source holds a quote. An error that names a language
371
+ refuses a render in that language alone; one that names none refuses
372
+ every render. `wordExpressions(report)` gives those expressions, every
373
+ place each stands, by the same verdict: what the builders mark and edit
374
+ as words, so that they ask for no translation the diagnostics do not.
375
+
376
+ Every member read is checked as its type. `@formancy/expressions` 0.12.0,
377
+ as 0.5.0 to 0.7.0 and 0.11.0 before it, declares a variable only by its whole name, so each read of `row.amount` is
237
378
  spliced, by upstream's own `rewritePath`, into a read of `row_amount`, a
238
379
  variable declared as a decimal. An exact value is used as what it is,
239
380
  `row.amount * dec("1.081")`, and `dec(row.amount)` is a type error. A member