@le-space/eigenbeleg 0.7.0 → 0.9.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.
@@ -7,12 +7,15 @@
7
7
  // bookkeeper needs. German, for German bookkeeping. Aleph Cloud credits get
8
8
  // the same layout titled »Verbrauchsauszug« (`st.title`). Above each list of
9
9
  // bookings a small diagram (#889, statement-chart.js): the balance over the
10
- // period, or what was consumed per day.
10
+ // period, or what was consumed per day. A token not in the chain's list (#93)
11
+ // is named by its contract, its symbol the contract's own claim; a section
12
+ // that does not fit on the rest of the page starts on a new one.
11
13
 
12
14
  import { asset, createPdfA, LOGOS, savePdfA, wrapText } from '@le-space/pdf';
13
15
  import { round } from '@le-space/ledger';
14
16
 
15
- import { DATA_SOURCES, conversionText, deDate, deFixed, deMoney, deNumber } from './document.js';
17
+ import { DATA_SOURCES, DATA_SOURCES_EN, conversionText, formats } from './document.js';
18
+ import { localizeSource, say } from './language.js';
16
19
  import { CREATOR, PRODUCER } from './pdf.js';
17
20
  import { isDust, reconciled } from './statement.js';
18
21
  import { drawScene, sceneMeasure } from './chart-pdf.js';
@@ -23,6 +26,7 @@ import { BLACK, GREY, INK, MARK_SIZE, TYPE, WARN, pageLayout } from './layout.js
23
26
  const M = 48;
24
27
 
25
28
  const MARKET_RATE = 'Tageskurs (Kurs 00:00 UTC: CoinGecko, sonst Kraken)';
29
+ const MARKET_RATE_EN = "the day's rate (rate at 00:00 UTC: CoinGecko, else Kraken)";
26
30
 
27
31
  /**
28
32
  * What a section's values are at, for its note: the market rate of the day, a
@@ -30,28 +34,39 @@ const MARKET_RATE = 'Tageskurs (Kurs 00:00 UTC: CoinGecko, sonst Kraken)';
30
34
  * rate's name for another currency.
31
35
  *
32
36
  * @param {{ marketRate?: boolean, referenceValues?: string[] }} s
37
+ * @param {import('./language.js').DocumentLanguage} [language]
33
38
  * @returns {[string, string]}
34
39
  */
35
- function marketOrReference({ marketRate = true, referenceValues = [] }) {
40
+ function marketOrReference({ marketRate = true, referenceValues = [] }, language = 'de') {
41
+ const en = language === 'en';
36
42
  const names = [
37
- ...(marketRate || !referenceValues.length ? [MARKET_RATE] : []),
38
- ...referenceValues
43
+ ...(marketRate || !referenceValues.length ? [en ? MARKET_RATE_EN : MARKET_RATE] : []),
44
+ ...referenceValues.map((r) => localizeSource(r, language))
39
45
  ];
40
- return [names.map((n) => `zum ${n}`).join(' und '), names.join(' und ')];
46
+ return en
47
+ ? [names.map((n) => `at ${n}`).join(' and '), names.join(' and ')]
48
+ : [names.map((n) => `zum ${n}`).join(' und '), names.join(' und ')];
41
49
  }
42
50
 
43
- /** The table of bookings; its last column names the statement's currency. @param {string} currency */
44
- const columns = (currency) => [
45
- { title: 'Buchungstag', width: 52 },
46
- { title: 'Vorgang', width: 167 },
47
- { title: 'Soll', width: 72, right: true },
48
- { title: 'Haben', width: 72, right: true },
49
- { title: 'Saldo', width: 80, right: true },
50
- { title: `Wert ${currency}`, width: 56, right: true }
51
- ];
52
-
53
- /** Quantities in the table: at most 12 decimals, the CSV keeps them all. @param {string} q */
54
- const qty = (q) => (q ? deNumber(round(q, 12)) : '');
51
+ /** The table of bookings; its last column names the statement's currency. @param {string} currency @param {import('./language.js').DocumentLanguage} [language] */
52
+ const columns = (currency, language = 'de') =>
53
+ language === 'en'
54
+ ? [
55
+ { title: 'Date', width: 52 },
56
+ { title: 'Transaction', width: 167 },
57
+ { title: 'Debit', width: 72, right: true },
58
+ { title: 'Credit', width: 72, right: true },
59
+ { title: 'Balance', width: 80, right: true },
60
+ { title: `Value ${currency}`, width: 56, right: true }
61
+ ]
62
+ : [
63
+ { title: 'Buchungstag', width: 52 },
64
+ { title: 'Vorgang', width: 167 },
65
+ { title: 'Soll', width: 72, right: true },
66
+ { title: 'Haben', width: 72, right: true },
67
+ { title: 'Saldo', width: 80, right: true },
68
+ { title: `Wert ${currency}`, width: 56, right: true }
69
+ ];
55
70
 
56
71
  /**
57
72
  * @param {import('./statement.js').Statement} st
@@ -72,12 +87,21 @@ export async function statementPdf(
72
87
  const pay = st.chain === 'filecoin-pay';
73
88
  // The statement's currency (EUR unless another): its code in the column heads and sums.
74
89
  const cur = st.currency ?? 'EUR';
75
- const COLS = columns(cur);
90
+ // The statement's language (German unless it says English) and its formats.
91
+ const L = st.language ?? 'de';
92
+ /** @param {string} de @param {string} en */
93
+ const t = (de, en) => say(L, de, en);
94
+ const { number: deNumber, fixed: deFixed, money: fmtMoney, date: deDate } = formats(L);
95
+ /** Quantities in the table: at most 12 decimals, the CSV keeps them all. @param {string} q */
96
+ const qty = (q) => (q ? deNumber(round(q, 12)) : '');
97
+ const COLS = columns(cur, L);
76
98
  /** @param {string} amount */
77
- const money = (amount) => deMoney(amount, cur);
99
+ const money = (amount) => fmtMoney(amount, cur);
78
100
  /** What the values are: in euro as it always said, or how they became another currency. @param {string} eur @param {string} rate */
79
101
  const valued = (eur, rate) =>
80
- cur === 'EUR' ? `Euro-Werte ${eur}` : `Werte in ${cur}: ${rate}, ${conversionText(cur)}`;
102
+ cur === 'EUR'
103
+ ? `${t('Euro-Werte', 'Euro values')} ${eur}`
104
+ : `${t('Werte in', 'Values in')} ${cur}: ${rate}, ${conversionText(cur, L)}`;
81
105
  const title = `${st.title} ${st.number}`;
82
106
  const subject = `${st.title} ${st.chainName} ${st.account}, ${deDate(st.period.from)} – ${deDate(st.period.to)}`;
83
107
  const { pdf, fonts } = await createPdfA();
@@ -107,18 +131,24 @@ export async function statementPdf(
107
131
 
108
132
  // ---- head: the title first, as on every document; below the rule the holder and the facts
109
133
  if (st.testnet) {
110
- text('TESTNET – keine echten Werte. Kurse des Mainnet-Assets nur zur Veranschaulichung.', {
111
- face: bold,
112
- size: TYPE.table,
113
- color: WARN
114
- });
134
+ text(
135
+ t(
136
+ 'TESTNET – keine echten Werte. Kurse des Mainnet-Assets nur zur Veranschaulichung.',
137
+ 'TESTNET – no real values. Rates of the mainnet asset for illustration only.'
138
+ ),
139
+ {
140
+ face: bold,
141
+ size: TYPE.table,
142
+ color: WARN
143
+ }
144
+ );
115
145
  l.y -= 6;
116
146
  }
117
147
  // The chain's mark, larger: a statement shows what the network's account did. The issuer's logo is
118
148
  // not on it: a statement is not the issuer's own receipt.
119
149
  l.head(st.title, { image: mark, mark: MARK_SIZE.large });
120
150
  const top = l.y;
121
- label('Kontoinhaber', { max: 250 });
151
+ label(t('Kontoinhaber', 'Account holder'), { max: 250 });
122
152
  text(st.holder.name, { face: bold, size: TYPE.lead, max: 250 });
123
153
  text(st.holder.address, { max: 250 });
124
154
  const leftEnd = l.y;
@@ -126,10 +156,10 @@ export async function statementPdf(
126
156
  const rx = M + width / 2 + 10;
127
157
  const facts = [
128
158
  // The label column is 72 pt wide: »Verbrauchsauszug« does not fit.
129
- [st.title === 'Kontoauszug' ? 'Kontoauszug' : 'Auszug-Nr.', st.number],
130
- ['Zeitraum', `${deDate(st.period.from)} – ${deDate(st.period.to)}`],
159
+ [st.title === 'Kontoauszug' ? 'Kontoauszug' : t('Auszug-Nr.', 'Statement no.'), st.number],
160
+ [t('Zeitraum', 'Period'), `${deDate(st.period.from)} – ${deDate(st.period.to)}`],
131
161
  ['Chain', `${st.chainName} (${st.network})`],
132
- ['Erstellt am', `${deDate(st.issuedAt)}, ${st.issuedAt.slice(11, 16)} UTC`]
162
+ [t('Erstellt am', 'Made on'), `${deDate(st.issuedAt)}, ${st.issuedAt.slice(11, 16)} UTC`]
133
163
  ];
134
164
  for (const [k, v] of facts) {
135
165
  regular.draw(l.page, k, { x: rx, y: l.y - TYPE.body, size: TYPE.small, color: GREY });
@@ -137,20 +167,72 @@ export async function statementPdf(
137
167
  l.y -= 13;
138
168
  }
139
169
  l.y = Math.min(l.y, leftEnd) - 8;
140
- label('Konto');
170
+ label(t('Konto', 'Account'));
141
171
  text(st.account, { face: mono, size: TYPE.body });
142
172
  l.y -= 10;
143
173
  l.note(st.note, TYPE.table);
144
174
  l.y -= 18;
145
175
 
176
+ /** A booking's two lines of text, and the height of its row. @param {import('./statement.js').StatementRow} r */
177
+ const rowText = (r) => {
178
+ const detail = [
179
+ r.counterparty && `${r.debit ? t('an', 'to') : t('von', 'from')} ${r.counterparty}`,
180
+ r.hash && `${r.hashLabel} ${r.hash.slice(0, 10)}…${r.hash.slice(-6)}`,
181
+ r.beleg && `Eigenbeleg ${r.beleg}`
182
+ ]
183
+ .filter(Boolean)
184
+ .join(' · ');
185
+ const lines = wrapText(r.text, regular, 8, COLS[1].width - 6);
186
+ const sub = wrapText(detail, regular, 6.5, COLS[1].width - 6);
187
+ return { lines, sub, h: lines.length * 10 + sub.length * 8.5 + 6 };
188
+ };
189
+ /** What a page holds below its running head, above the footer. */
190
+ const pageRoom = l.page.getHeight() - 2 * M - 18 - 16;
191
+
146
192
  // ---- one section per asset
147
- for (const s of st.sections) {
148
- l.ensure(90);
149
- // A section: its head on a hairline. No band, no fill.
150
- text(`${s.asset} · ${st.account}`, { face: bold, size: TYPE.lead });
193
+ for (const [i, s] of st.sections.entries()) {
194
+ // The diagram, above the list of bookings (#889); every figure in it is in the tables.
195
+ const drawn = chart ? statementChart(st, s, { width, measure: sceneMeasure(fonts) }) : null;
196
+ const monthLines =
197
+ aleph || pay
198
+ ? [s.monthly.usage, s.monthly.usageTotal, s.monthly.purchases, s.monthly.transfersIn]
199
+ .concat([s.monthly.transfersOut])
200
+ .flat()
201
+ .filter((x) => x !== null).length
202
+ : 0;
203
+ // A section that does not fit on the rest of the page starts on a new one (#93: a wallet with
204
+ // many tokens): its head never stands apart from its bookings. The first follows the head.
205
+ const tall =
206
+ (s.contract ? 70 : 40) +
207
+ (monthLines ? 14 + monthLines * 12 + 15 : 0) +
208
+ (drawn ? drawn.scene.height + 14 : 0) +
209
+ 30 +
210
+ (s.rows.length ? s.rows.reduce((h, r) => h + rowText(r).h, 0) : 13) +
211
+ 110;
212
+ if (i > 0 && l.y - (M + 16) < Math.min(tall, pageRoom)) l.newPage();
213
+ else l.ensure(90);
214
+ // A section: its head on a hairline. No band, no fill. A token not in the list is named by its
215
+ // contract; what it calls itself is the contract's own claim.
216
+ if (s.contract) {
217
+ text(`${s.asset} (${t('laut Token-Vertrag', 'as the token contract says')})`, {
218
+ face: bold,
219
+ size: TYPE.lead
220
+ });
221
+ text(s.contract, { face: mono, size: TYPE.body });
222
+ } else text(`${s.asset} · ${st.account}`, { face: bold, size: TYPE.lead });
151
223
  l.y -= 3;
152
224
  l.rule();
153
225
  l.y -= 10;
226
+ if (s.contract) {
227
+ text(
228
+ t(
229
+ `Token außerhalb der Liste geprüfter Token dieser Chain: Name »${s.asset}« und Nachkommastellen nennt der Vertrag selbst; maßgeblich ist seine Adresse oben.`,
230
+ `A token outside this chain's list of checked tokens: its name "${s.asset}" and decimals are what the contract says of itself; its address above is what counts.`
231
+ ),
232
+ { size: TYPE.small, color: GREY }
233
+ );
234
+ l.y -= 6;
235
+ }
154
236
  // The month in sums, first (#24): what the books take as one booking each; the rows below are the proof.
155
237
  if (aleph || pay) {
156
238
  const m = s.monthly;
@@ -159,9 +241,9 @@ export async function statementPdf(
159
241
  .filter((x) => x !== null);
160
242
  if (lines.length) {
161
243
  l.ensure(14 + lines.length * 11 + 8);
162
- l.at('Monatsübersicht', M, TYPE.label, regular, GREY);
163
- l.right(pay ? s.asset : 'Credits', edge(CREDIT), TYPE.label, regular, GREY);
164
- l.right(`Wert ${cur}`, edge(VALUE), TYPE.label, regular, GREY);
244
+ l.at(t('Monatsübersicht', 'The month in sums'), M, TYPE.label, regular, GREY);
245
+ l.right(pay ? s.asset : t('Credits', 'Credits'), edge(CREDIT), TYPE.label, regular, GREY);
246
+ l.right(`${t('Wert', 'Value')} ${cur}`, edge(VALUE), TYPE.label, regular, GREY);
165
247
  l.y -= 11;
166
248
  l.strong();
167
249
  l.y -= 4;
@@ -184,8 +266,6 @@ export async function statementPdf(
184
266
  l.y -= 14;
185
267
  }
186
268
  }
187
- // The diagram, above the list of bookings (#889); every figure in it is in the tables.
188
- const drawn = chart ? statementChart(st, s, { width, measure: sceneMeasure(fonts) }) : null;
189
269
  if (drawn) {
190
270
  l.ensure(drawn.scene.height + 40);
191
271
  drawScene(l.page, drawn.scene, { x: M, top: l.y, fonts });
@@ -204,22 +284,21 @@ export async function statementPdf(
204
284
  };
205
285
  head();
206
286
  // opening balance
207
- l.at(`Kontostand am ${deDate(st.period.from)} (Beginn)`, M + COLS[0].width, 8, bold);
287
+ l.at(
288
+ t(
289
+ `Kontostand am ${deDate(st.period.from)} (Beginn)`,
290
+ `Balance on ${deDate(st.period.from)} (start)`
291
+ ),
292
+ M + COLS[0].width,
293
+ 8,
294
+ bold
295
+ );
208
296
  l.right(qty(s.opening), edge(BALANCE), 8, bold);
209
297
  l.y -= 13;
210
298
  l.rule();
211
299
  l.y -= 2;
212
300
  for (const r of s.rows) {
213
- const detail = [
214
- r.counterparty && `${r.debit ? 'an' : 'von'} ${r.counterparty}`,
215
- r.hash && `${r.hashLabel} ${r.hash.slice(0, 10)}…${r.hash.slice(-6)}`,
216
- r.beleg && `Eigenbeleg ${r.beleg}`
217
- ]
218
- .filter(Boolean)
219
- .join(' · ');
220
- const lines = wrapText(r.text, regular, 8, COLS[1].width - 6);
221
- const sub = wrapText(detail, regular, 6.5, COLS[1].width - 6);
222
- const h = lines.length * 10 + sub.length * 8.5 + 6;
301
+ const { lines, sub, h } = rowText(r);
223
302
  if (l.ensure(h)) head();
224
303
  const y = l.y;
225
304
  regular.draw(l.page, deDate(r.date), { x: M, y: y - 8, size: 8, color: INK });
@@ -255,7 +334,13 @@ export async function statementPdf(
255
334
  l.y -= 1;
256
335
  }
257
336
  if (s.rows.length === 0) {
258
- l.at('Keine Buchungen in diesem Zeitraum.', M + COLS[0].width, 8, regular, GREY);
337
+ l.at(
338
+ t('Keine Buchungen in diesem Zeitraum.', 'No bookings in this period.'),
339
+ M + COLS[0].width,
340
+ 8,
341
+ regular,
342
+ GREY
343
+ );
259
344
  l.y -= 13;
260
345
  }
261
346
  // sums and closing balance
@@ -264,11 +349,16 @@ export async function statementPdf(
264
349
  l.y += 1;
265
350
  l.strong();
266
351
  l.y -= 5;
267
- l.at('Summe', M + COLS[0].width, 8, regular);
352
+ l.at(t('Summe', 'Total'), M + COLS[0].width, 8, regular);
268
353
  l.right(qty(s.debit), edge(DEBIT), 8, regular);
269
354
  l.right(qty(s.credit), edge(CREDIT), 8, regular);
270
355
  l.y -= 14;
271
- l.at(`Kontostand am ${deDate(st.period.to)} (Ende)`, M + COLS[0].width, TYPE.lead, bold);
356
+ l.at(
357
+ t(`Kontostand am ${deDate(st.period.to)} (Ende)`, `Balance on ${deDate(st.period.to)} (end)`),
358
+ M + COLS[0].width,
359
+ TYPE.lead,
360
+ bold
361
+ );
272
362
  l.right(`${qty(s.closing)} ${s.asset}`, edge(BALANCE), TYPE.lead, bold);
273
363
  l.y -= 17;
274
364
  l.strong();
@@ -282,43 +372,92 @@ export async function statementPdf(
282
372
  : '';
283
373
  text(
284
374
  ok && isDust(difference)
285
- ? `Abgestimmt: Der Kontostand laut Chain nach dem Zeitraum${when} ist ${qty(s.reported)} ${s.asset}; die Differenz von ${deNumber(difference)} ${s.asset} liegt unter der dargestellten Genauigkeit (das 1 yoctoNEAR, das ein Token-Transfer als Sicherheit mitgibt, zählt nicht als Zahlung).`
375
+ ? t(
376
+ `Abgestimmt: Der Kontostand laut Chain nach dem Zeitraum${when} ist ${qty(s.reported)} ${s.asset}; die Differenz von ${deNumber(difference)} ${s.asset} liegt unter der dargestellten Genauigkeit (das 1 yoctoNEAR, das ein Token-Transfer als Sicherheit mitgibt, zählt nicht als Zahlung).`,
377
+ `Reconciled: the balance the chain reports after the period${when} is ${qty(s.reported)} ${s.asset}; the difference of ${deNumber(difference)} ${s.asset} is below the precision shown (the 1 yoctoNEAR a token transfer attaches as its security deposit is no payment).`
378
+ )
286
379
  : ok
287
- ? `Abgestimmt: Der Kontostand laut Chain nach dem Zeitraum${when} ist ${qty(s.reported)} ${s.asset} und stimmt mit Anfangsstand plus Buchungen überein.`
288
- : `Nicht abgestimmt: Der Kontostand laut Chain${when} ist ${qty(s.reported)} ${s.asset}; Differenz ${deNumber(difference)} ${s.asset} (Bewegungen, die der Leser nicht sieht, etwa Auszahlungen eines Staking-Pools).`,
380
+ ? t(
381
+ `Abgestimmt: Der Kontostand laut Chain nach dem Zeitraum${when} ist ${qty(s.reported)} ${s.asset} und stimmt mit Anfangsstand plus Buchungen überein.`,
382
+ `Reconciled: the balance the chain reports after the period${when} is ${qty(s.reported)} ${s.asset} and equals the opening balance plus the bookings.`
383
+ )
384
+ : t(
385
+ `Nicht abgestimmt: Der Kontostand laut Chain${when} ist ${qty(s.reported)} ${s.asset}; Differenz ${deNumber(difference)} ${s.asset} (Bewegungen, die der Leser nicht sieht, etwa Auszahlungen eines Staking-Pools).`,
386
+ `Not reconciled: the balance the chain reports${when} is ${qty(s.reported)} ${s.asset}; difference ${deNumber(difference)} ${s.asset} (movements the reader does not see, such as payouts of a staking pool).`
387
+ ),
289
388
  // Reconciled is the normal case and reads as text; only a difference is a warning.
290
389
  { size: TYPE.small, color: ok ? INK : WARN }
291
390
  );
292
391
  } else {
293
392
  text(
294
- `Anfangs- und Endstand abgeleitet aus dem heutigen Kontostand abzüglich aller Bewegungen seither (${aleph ? 'die Aleph-API nennt den heutigen Stand und die Summen seither' : pay ? 'der Zahlungsvertrag nennt nur den heutigen Stand' : 'die Chain hält keine alten Kontostände vor'}).`,
393
+ t(
394
+ `Anfangs- und Endstand abgeleitet aus dem heutigen Kontostand abzüglich aller Bewegungen seither (${aleph ? 'die Aleph-API nennt den heutigen Stand und die Summen seither' : pay ? 'der Zahlungsvertrag nennt nur den heutigen Stand' : 'die Chain hält keine alten Kontostände vor'}).`,
395
+ `Opening and closing balance derived from today's balance less every movement since (${aleph ? "the Aleph API names today's balance and the sums since" : pay ? "the payment contract names only today's balance" : 'the chain keeps no old balances'}).`
396
+ ),
295
397
  { size: TYPE.small, color: GREY }
296
398
  );
297
399
  }
298
400
  l.y -= 4;
299
401
  text(
300
- pay
301
- ? `Ausgänge ${money(s.eurOut)} · Eingänge ${money(s.eurIn)} · davon Verbrauch (Aufwand) ${money(s.eurUsage)}${s.unvalued ? ` · ${s.unvalued} Buchung(en) ohne Kurs` : ''} – ${valued(`zum Tageskurs von USDC, an den US-Dollar gebunden wie ${s.asset} (Kurs 00:00 UTC: CoinGecko, sonst Kraken)`, `Tageskurs von USDC, an den US-Dollar gebunden wie ${s.asset} (Kurs 00:00 UTC: CoinGecko, sonst Kraken)`)}.`
302
- : aleph
303
- ? `Ausgänge ${money(s.eurOut)} · Eingänge ${money(s.eurIn)} · davon Verbrauch (Aufwand) ${money(s.eurUsage)}${s.unvalued ? ` · ${s.unvalued} Buchung(en) ohne Kurs` : ''} – ${
304
- cur === 'EUR'
305
- ? 'Euro-Werte: USD-Preis je Credit (letzter Kauf am oder vor dem Tag, sonst Listenpreis) × EZB-Referenzkurs USD/EUR des Tages'
306
- : `Werte in ${cur}: USD-Preis je Credit (letzter Kauf am oder vor dem Tag, sonst Listenpreis)${cur === 'USD' ? '' : `, ${conversionText(cur)}`}`
307
- }.`
308
- : `Ausgänge ${money(s.eurOut)} · Eingänge ${money(s.eurIn)} · davon Netzwerkgebühren (Aufwand) ${money(s.eurFees)}${s.unvalued ? ` · ${s.unvalued} Buchung(en) ohne Kurs` : ''} – ${valued(...marketOrReference(s))}.`,
402
+ L === 'en'
403
+ ? pay
404
+ ? `Out ${money(s.eurOut)} · in ${money(s.eurIn)} · of which usage (expense) ${money(s.eurUsage)}${s.unvalued ? ` · ${s.unvalued} booking(s) without a rate` : ''} – ${valued(`at the day's rate of USDC, pegged to the US dollar like ${s.asset} (rate at 00:00 UTC: CoinGecko, else Kraken)`, `the day's rate of USDC, pegged to the US dollar like ${s.asset} (rate at 00:00 UTC: CoinGecko, else Kraken)`)}.`
405
+ : aleph
406
+ ? `Out ${money(s.eurOut)} · in ${money(s.eurIn)} · of which usage (expense) ${money(s.eurUsage)}${s.unvalued ? ` · ${s.unvalued} booking(s) without a rate` : ''} – ${
407
+ cur === 'EUR'
408
+ ? 'Euro values: the USD price per credit (the last purchase on or before the day, else the list price) × the ECB reference rate USD/EUR of the day'
409
+ : `Values in ${cur}: the USD price per credit (the last purchase on or before the day, else the list price)${cur === 'USD' ? '' : `, ${conversionText(cur, L)}`}`
410
+ }.`
411
+ : `Out ${money(s.eurOut)} · in ${money(s.eurIn)} · of which network fees (expense) ${money(s.eurFees)}${s.unvalued ? ` · ${s.unvalued} booking(s) without a rate` : ''} – ${
412
+ !s.contract
413
+ ? valued(...marketOrReference(s, L))
414
+ : s.sources?.length
415
+ ? valued(
416
+ `at the rate by the contract's address: ${s.sources.map((x) => localizeSource(x, L)).join(' and ')}`,
417
+ `rate by the contract's address: ${s.sources.map((x) => localizeSource(x, L)).join(' and ')}`
418
+ )
419
+ : 'no rate source names a rate for this token'
420
+ }.`
421
+ : pay
422
+ ? `Ausgänge ${money(s.eurOut)} · Eingänge ${money(s.eurIn)} · davon Verbrauch (Aufwand) ${money(s.eurUsage)}${s.unvalued ? ` · ${s.unvalued} Buchung(en) ohne Kurs` : ''} – ${valued(`zum Tageskurs von USDC, an den US-Dollar gebunden wie ${s.asset} (Kurs 00:00 UTC: CoinGecko, sonst Kraken)`, `Tageskurs von USDC, an den US-Dollar gebunden wie ${s.asset} (Kurs 00:00 UTC: CoinGecko, sonst Kraken)`)}.`
423
+ : aleph
424
+ ? `Ausgänge ${money(s.eurOut)} · Eingänge ${money(s.eurIn)} · davon Verbrauch (Aufwand) ${money(s.eurUsage)}${s.unvalued ? ` · ${s.unvalued} Buchung(en) ohne Kurs` : ''} – ${
425
+ cur === 'EUR'
426
+ ? 'Euro-Werte: USD-Preis je Credit (letzter Kauf am oder vor dem Tag, sonst Listenpreis) × EZB-Referenzkurs USD/EUR des Tages'
427
+ : `Werte in ${cur}: USD-Preis je Credit (letzter Kauf am oder vor dem Tag, sonst Listenpreis)${cur === 'USD' ? '' : `, ${conversionText(cur)}`}`
428
+ }.`
429
+ : `Ausgänge ${money(s.eurOut)} · Eingänge ${money(s.eurIn)} · davon Netzwerkgebühren (Aufwand) ${money(s.eurFees)}${s.unvalued ? ` · ${s.unvalued} Buchung(en) ohne Kurs` : ''} – ${
430
+ !s.contract
431
+ ? valued(...marketOrReference(s))
432
+ : s.sources?.length
433
+ ? valued(
434
+ `zum Kurs nach der Vertragsadresse: ${s.sources.join(' und ')}`,
435
+ `Kurs nach der Vertragsadresse: ${s.sources.join(' und ')}`
436
+ )
437
+ : 'für diesen Token nennt keine Kursquelle einen Kurs'
438
+ }.`,
309
439
  { size: TYPE.small, color: GREY }
310
440
  );
311
441
  l.y -= 20;
312
442
  }
313
443
  if (st.unlisted)
314
444
  text(
315
- `${st.unlisted} Bewegung(en) in Token ohne verlässlichen Kurs (oft Spam) sind nur in der CSV-Datei aufgeführt.`,
445
+ t(
446
+ `${st.unlisted} Bewegung(en) in Token ohne verlässlichen Kurs (oft Spam) sind nur in der CSV-Datei aufgeführt.`,
447
+ `${st.unlisted} movement(s) in tokens without a reliable rate (often spam) are listed in the CSV file only.`
448
+ ),
316
449
  { size: TYPE.small, color: GREY }
317
450
  );
318
451
 
319
452
  // page numbers and footer on every page
320
- const data = `Daten: ${st.dataSource ?? DATA_SOURCES[st.chain] ?? st.chainName} · kein Dokument eines Kreditinstituts`;
321
- l.pages.forEach((p, i) => l.foot(p, `${st.number} · Seite ${i + 1} von ${l.pages.length}`, data));
453
+ const data = `${t('Daten', 'Data')}: ${st.dataSource ?? (L === 'en' ? DATA_SOURCES_EN : DATA_SOURCES)[st.chain] ?? st.chainName} · ${t('kein Dokument eines Kreditinstituts', 'no document of a bank')}`;
454
+ l.pages.forEach((p, i) =>
455
+ l.foot(
456
+ p,
457
+ `${st.number} · ${t('Seite', 'Page')} ${i + 1} ${t('von', 'of')} ${l.pages.length}`,
458
+ data
459
+ )
460
+ );
322
461
 
323
462
  return savePdfA(pdf, {
324
463
  title,