@ekwo-ai/core 0.12.2 → 0.14.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/dist/books/columns.d.ts +2 -1
- package/dist/books/columns.d.ts.map +1 -1
- package/dist/books/columns.js +3 -1
- package/dist/books/columns.js.map +1 -1
- package/dist/books/imports.d.ts +7 -1
- package/dist/books/imports.d.ts.map +1 -1
- package/dist/books/imports.js +47 -12
- package/dist/books/imports.js.map +1 -1
- package/dist/books/payments.d.ts +28 -2
- package/dist/books/payments.d.ts.map +1 -1
- package/dist/books/payments.js +28 -10
- package/dist/books/payments.js.map +1 -1
- package/dist/client.d.ts +8 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +14 -0
- package/dist/client.js.map +1 -1
- package/dist/einvoicing/fiscalisation.d.ts +213 -0
- package/dist/einvoicing/fiscalisation.d.ts.map +1 -0
- package/dist/einvoicing/fiscalisation.js +442 -0
- package/dist/einvoicing/fiscalisation.js.map +1 -0
- package/dist/einvoicing/index.d.ts +5 -1
- package/dist/einvoicing/index.d.ts.map +1 -1
- package/dist/einvoicing/index.js +5 -1
- package/dist/einvoicing/index.js.map +1 -1
- package/dist/einvoicing/issue.d.ts +6 -0
- package/dist/einvoicing/issue.d.ts.map +1 -1
- package/dist/einvoicing/issue.js +13 -5
- package/dist/einvoicing/issue.js.map +1 -1
- package/dist/einvoicing/peppol.d.ts +77 -0
- package/dist/einvoicing/peppol.d.ts.map +1 -0
- package/dist/einvoicing/peppol.js +100 -0
- package/dist/einvoicing/peppol.js.map +1 -0
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +15 -14
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fiscalisation: the chained record a country requires the invoicing
|
|
3
|
+
* software to leave for every invoice it issues.
|
|
4
|
+
*
|
|
5
|
+
* A capability of the `einvoicing` module, and the same shape as issuing an
|
|
6
|
+
* electronic invoice: a posted sale, an artefact a brick writes, a state the
|
|
7
|
+
* database records. Here the artefact is a fiscal record, and what the
|
|
8
|
+
* database keeps is a chain — each record carries the hash of the one before
|
|
9
|
+
* it, in one company and one invoicing system.
|
|
10
|
+
*
|
|
11
|
+
* **The core knows no country.** Whether a company has such a regime, and
|
|
12
|
+
* every rule of it, is the `einvoicing.fiscalisation` block of its country
|
|
13
|
+
* pack, which the socle compiles into `country_defaults.einvoice_fiscalisation`
|
|
14
|
+
* and `einvoicing.fiscal_regime()` reads back. Which brick writes the record
|
|
15
|
+
* is the pack's `format`, looked up in `FISCALISATION_FORMATS` — the same
|
|
16
|
+
* pattern as `EINVOICE_FORMATS` — and a format no brick of this release writes
|
|
17
|
+
* is refused by name, `format_without_brick`.
|
|
18
|
+
*
|
|
19
|
+
* **The gesture is explicit.** Nothing here runs on posting. A posted sale of
|
|
20
|
+
* a company whose pack declares a regime and that has no record is named by
|
|
21
|
+
* `fiscalisationStatus()`, and `fiscaliseDocument()` is called by somebody who
|
|
22
|
+
* decided to chain it — `ekwo einvoice fiscalise`, `einvoicing_fiscalise`.
|
|
23
|
+
*
|
|
24
|
+
* What only a program can do is here: run the brick, read the tail of the
|
|
25
|
+
* chain, read the hashed fields back out of the text the brick hashed. What
|
|
26
|
+
* can be checked without trusting this code is checked again by
|
|
27
|
+
* `einvoicing.append_fiscal_record()`: the regime, the digest, the fields, the
|
|
28
|
+
* tail, a record made once.
|
|
29
|
+
*/
|
|
30
|
+
import { VERIFACTU } from '@ekwo-ai/verifactu';
|
|
31
|
+
import { BooksError } from '../books/backend.js';
|
|
32
|
+
import { assertPostedSale, einvoiceChecksum, readEinvoiceSource } from './issue.js';
|
|
33
|
+
const SCHEMA = 'einvoicing';
|
|
34
|
+
export const FISCAL_SUBMISSION_MODES = ['realtime', 'batch', 'none'];
|
|
35
|
+
export const FISCAL_RECORD_KINDS = ['alta', 'anulacion'];
|
|
36
|
+
/** Every fiscalisation format a brick of this release writes, by the name a pack declares it under. */
|
|
37
|
+
export const FISCALISATION_FORMATS = {
|
|
38
|
+
[VERIFACTU.format]: VERIFACTU,
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The format of a pack's regime, or the refusal that names the missing brick.
|
|
42
|
+
* Nothing is written in the nearest format that exists: a record in another
|
|
43
|
+
* format is a record the authority refuses.
|
|
44
|
+
*/
|
|
45
|
+
export function fiscalisationFormat(format, formats = FISCALISATION_FORMATS) {
|
|
46
|
+
const found = formats[format];
|
|
47
|
+
if (found === undefined) {
|
|
48
|
+
throw new BooksError(`format_without_brick: the country pack of this company keeps its fiscal records as ${format}, and no brick of packages/formats/ writes ${format} yet. ` +
|
|
49
|
+
`This release writes ${Object.keys(formats).join(' and ') || 'none'}; a record in another format is not a ${format} record, and none is written in its place.`);
|
|
50
|
+
}
|
|
51
|
+
return found;
|
|
52
|
+
}
|
|
53
|
+
/** The fiscalisation regime of a company's fiscal country, or null. */
|
|
54
|
+
export async function fiscalRegime(backend, companyId) {
|
|
55
|
+
const [regime] = await backend.rpc('fiscal_regime', { p_company_id: companyId }, SCHEMA);
|
|
56
|
+
return regime ?? null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The fields a hash covers, read back out of the text the brick hashed, in
|
|
60
|
+
* the order the pack names them: `name=value` joined by the pack's separator.
|
|
61
|
+
* Null where the text does not hold them in that order — the pack and the
|
|
62
|
+
* brick then disagree about what is hashed, and nothing is chained.
|
|
63
|
+
*/
|
|
64
|
+
export function hashedFields(text, fields, separator) {
|
|
65
|
+
const out = {};
|
|
66
|
+
let rest = text;
|
|
67
|
+
for (const [index, field] of fields.entries()) {
|
|
68
|
+
const prefix = `${index === 0 ? '' : separator}${field}=`;
|
|
69
|
+
if (!rest.startsWith(prefix))
|
|
70
|
+
return null;
|
|
71
|
+
rest = rest.slice(prefix.length);
|
|
72
|
+
const next = fields[index + 1];
|
|
73
|
+
if (next === undefined) {
|
|
74
|
+
out[field] = rest;
|
|
75
|
+
rest = '';
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const at = rest.indexOf(`${separator}${next}=`);
|
|
79
|
+
if (at < 0)
|
|
80
|
+
return null;
|
|
81
|
+
out[field] = rest.slice(0, at);
|
|
82
|
+
rest = rest.slice(at);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
/** Now, as ISO 8601 with the offset of this machine: what a record says it was generated at. */
|
|
88
|
+
export function generatedNow(at = new Date()) {
|
|
89
|
+
const offset = -at.getTimezoneOffset();
|
|
90
|
+
const local = new Date(at.getTime() + offset * 60_000).toISOString().slice(0, 19);
|
|
91
|
+
const sign = offset < 0 ? '-' : '+';
|
|
92
|
+
const hours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, '0');
|
|
93
|
+
const minutes = String(Math.abs(offset) % 60).padStart(2, '0');
|
|
94
|
+
return `${local}${sign}${hours}:${minutes}`;
|
|
95
|
+
}
|
|
96
|
+
/** The chain a system keeps for a company: its identifier and its installation. */
|
|
97
|
+
export const fiscalSystemId = (system) => `${system.id}:${system.installation}`;
|
|
98
|
+
const CHAIN = [
|
|
99
|
+
'id', 'company_id', 'system_id', 'seq', 'document_id', 'kind', 'format', 'issuer_tax_id', 'series', 'number',
|
|
100
|
+
'issued_on::text', 'record', 'hash', 'previous_hash', 'is_first', 'generated_at', 'mode', 'verification_url',
|
|
101
|
+
'issue_id', 'recorded_at', 'recorded_by',
|
|
102
|
+
];
|
|
103
|
+
/**
|
|
104
|
+
* Writes the fiscal record of a posted sale with the brick its pack's regime
|
|
105
|
+
* names, and — unless it breaks a rule or `dryRun` is asked — chains it after
|
|
106
|
+
* the tail of the system's chain and keeps its file. A document whose record
|
|
107
|
+
* is in the chain already is answered with that record, not chained twice.
|
|
108
|
+
*/
|
|
109
|
+
export async function fiscaliseDocument(backend, documentId, options, formats = FISCALISATION_FORMATS) {
|
|
110
|
+
const source = await readEinvoiceSource(backend, documentId);
|
|
111
|
+
const { header } = source;
|
|
112
|
+
assertPostedSale(header, documentId);
|
|
113
|
+
const companyId = String(header['company_id']);
|
|
114
|
+
const what = `${String(header['doc_type'])} ${String(header['number'] ?? documentId)}`;
|
|
115
|
+
const regime = await fiscalRegime(backend, companyId);
|
|
116
|
+
if (regime === null) {
|
|
117
|
+
throw new BooksError(`no_fiscalisation_regime: the country pack of this company declares no fiscalisation regime, so ${what} has no fiscal record to keep.`, { hint: 'A pack declares one in einvoicing.fiscalisation; describe_pack (ekwo pack describe) shows it.' });
|
|
118
|
+
}
|
|
119
|
+
const format = fiscalisationFormat(regime.format, formats);
|
|
120
|
+
if (regime.hash === null) {
|
|
121
|
+
throw new BooksError(`fiscal_regime_without_chain: the country pack of this company declares a reporting regime, ${regime.format}: the data of its documents are reported to the authority and nothing is chained, so ${what} has no record to chain. The report is written by ${format.brick}, not by fiscaliseDocument().`);
|
|
122
|
+
}
|
|
123
|
+
const hashRule = regime.hash;
|
|
124
|
+
const kind = options.kind ?? 'alta';
|
|
125
|
+
const mode = options.mode ?? regime.submission.mode;
|
|
126
|
+
if (!regime.submission.modes.includes(mode)) {
|
|
127
|
+
throw new BooksError(`fiscal_mode_not_allowed: a record of this company is sent as one of ${regime.submission.modes.join(', ')}, not as ${mode}.`);
|
|
128
|
+
}
|
|
129
|
+
const systemId = fiscalSystemId(options.system);
|
|
130
|
+
const chain = await backend.select({
|
|
131
|
+
schema: SCHEMA,
|
|
132
|
+
table: 'fiscal_chain',
|
|
133
|
+
columns: CHAIN,
|
|
134
|
+
where: [
|
|
135
|
+
{ column: 'company_id', op: 'eq', value: companyId },
|
|
136
|
+
{ column: 'system_id', op: 'eq', value: systemId },
|
|
137
|
+
],
|
|
138
|
+
order: [{ column: 'seq', ascending: false }],
|
|
139
|
+
limit: 1,
|
|
140
|
+
});
|
|
141
|
+
const tail = chain[0] ?? null;
|
|
142
|
+
// Asking twice is not a second record.
|
|
143
|
+
const [last] = await backend.select({
|
|
144
|
+
schema: SCHEMA,
|
|
145
|
+
table: 'fiscal_chain',
|
|
146
|
+
columns: CHAIN,
|
|
147
|
+
where: [
|
|
148
|
+
{ column: 'document_id', op: 'eq', value: documentId },
|
|
149
|
+
{ column: 'system_id', op: 'eq', value: systemId },
|
|
150
|
+
],
|
|
151
|
+
order: [{ column: 'seq', ascending: false }],
|
|
152
|
+
limit: 1,
|
|
153
|
+
});
|
|
154
|
+
if (last !== undefined && last['kind'] === kind && options.dryRun !== true) {
|
|
155
|
+
return {
|
|
156
|
+
document_id: documentId,
|
|
157
|
+
number: header['number'] ?? null,
|
|
158
|
+
doc_type: header['doc_type'],
|
|
159
|
+
format: format.format,
|
|
160
|
+
brick: format.brick,
|
|
161
|
+
kind,
|
|
162
|
+
system_id: systemId,
|
|
163
|
+
chained: true,
|
|
164
|
+
already: true,
|
|
165
|
+
record: last,
|
|
166
|
+
violations: [],
|
|
167
|
+
verification_url: last['verification_url'] ?? null,
|
|
168
|
+
note: `${what} has its ${kind} record in this system already, number ${String(last['seq'])} of the chain; nothing was chained again.`,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
// The tax lines carry what the regime needs that the category does not decide alone.
|
|
172
|
+
const taxes = source.taxes.map((tax) => ({ ...tax, ...(regime.tax_attributes[String(tax['tax_code'])] ?? {}) }));
|
|
173
|
+
const input = {
|
|
174
|
+
header: {
|
|
175
|
+
...header,
|
|
176
|
+
...(source.preceding === null
|
|
177
|
+
? {}
|
|
178
|
+
: { rectified_number: source.preceding.number, rectified_date: source.preceding.issueDate }),
|
|
179
|
+
...(options.rectification === undefined ? {} : { rectification_type: options.rectification }),
|
|
180
|
+
},
|
|
181
|
+
lines: source.lines,
|
|
182
|
+
taxes,
|
|
183
|
+
kind,
|
|
184
|
+
generatedAt: options.generatedAt ?? generatedNow(),
|
|
185
|
+
system: options.system,
|
|
186
|
+
previous: tail === null
|
|
187
|
+
? null
|
|
188
|
+
: {
|
|
189
|
+
taxId: String(tail['issuer_tax_id']),
|
|
190
|
+
series: String(tail['series'] ?? ''),
|
|
191
|
+
number: String(tail['number']),
|
|
192
|
+
issuedOn: String(tail['issued_on']),
|
|
193
|
+
hash: String(tail['hash']),
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
const written = format.write(input);
|
|
197
|
+
const hashInput = format.hashInput(input);
|
|
198
|
+
const hash = format.hash(input);
|
|
199
|
+
const verificationUrl = format.verificationUrl(input, mode, options.environment ?? 'production');
|
|
200
|
+
const fields = hashRule.fields[kind] ?? hashRule.fields['*'] ?? [];
|
|
201
|
+
const record = hashRule.separator === null ? null : hashedFields(hashInput, fields, hashRule.separator);
|
|
202
|
+
if (record === null) {
|
|
203
|
+
throw new BooksError(`fiscal_hash_fields_unread: the pack says the hash of a ${kind} record covers ${fields.join(', ')}, and the text ${format.brick} hashed does not hold them in that order. The pack and the brick disagree about what is hashed; nothing is chained.`);
|
|
204
|
+
}
|
|
205
|
+
const base = {
|
|
206
|
+
document_id: documentId,
|
|
207
|
+
number: header['number'] ?? null,
|
|
208
|
+
doc_type: header['doc_type'],
|
|
209
|
+
format: format.format,
|
|
210
|
+
brick: format.brick,
|
|
211
|
+
specification: format.specification,
|
|
212
|
+
kind,
|
|
213
|
+
mode,
|
|
214
|
+
system_id: systemId,
|
|
215
|
+
generated_at: input.generatedAt,
|
|
216
|
+
hash,
|
|
217
|
+
previous_hash: input.previous?.hash ?? null,
|
|
218
|
+
fields: record,
|
|
219
|
+
verification_url: verificationUrl,
|
|
220
|
+
filename: written.filename,
|
|
221
|
+
violations: written.violations,
|
|
222
|
+
...(options.includeFile === true ? { file: written.content } : {}),
|
|
223
|
+
};
|
|
224
|
+
if (written.violations.length > 0 || options.dryRun === true) {
|
|
225
|
+
return {
|
|
226
|
+
...base,
|
|
227
|
+
chained: false,
|
|
228
|
+
record: null,
|
|
229
|
+
note: written.violations.length > 0
|
|
230
|
+
? 'The record breaks the rules listed, and a record that breaks one is not chained: the next one would follow a record the authority refuses. They are completed in the books, not in the record. Nothing was recorded.'
|
|
231
|
+
: 'The record breaks no rule this release re-reads. Nothing was recorded: fiscalise it without dry run to chain it.',
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const [row] = await backend.rpc('append_fiscal_record', {
|
|
235
|
+
p_document_id: documentId,
|
|
236
|
+
p_system_id: systemId,
|
|
237
|
+
p_kind: kind,
|
|
238
|
+
p_format: format.format,
|
|
239
|
+
p_mode: mode,
|
|
240
|
+
p_issuer_tax_id: String(header['seller_vat_number'] ?? ''),
|
|
241
|
+
p_series: '',
|
|
242
|
+
p_number: String(header['number'] ?? ''),
|
|
243
|
+
p_issued_on: header['document_date'],
|
|
244
|
+
p_record: record,
|
|
245
|
+
p_hash_input: hashInput,
|
|
246
|
+
p_hash: hash,
|
|
247
|
+
p_previous_hash: input.previous?.hash ?? null,
|
|
248
|
+
p_generated_at: input.generatedAt,
|
|
249
|
+
p_verification_url: verificationUrl,
|
|
250
|
+
p_brick: format.brick,
|
|
251
|
+
p_specification: format.specification,
|
|
252
|
+
p_filename: written.filename,
|
|
253
|
+
p_media_type: written.mediaType,
|
|
254
|
+
p_content: written.content,
|
|
255
|
+
p_checksum: einvoiceChecksum(written.content),
|
|
256
|
+
p_violations: written.violations,
|
|
257
|
+
}, SCHEMA);
|
|
258
|
+
if (row === undefined)
|
|
259
|
+
throw new BooksError('einvoicing_no_answer: einvoicing.append_fiscal_record answered nothing');
|
|
260
|
+
return {
|
|
261
|
+
...base,
|
|
262
|
+
chained: true,
|
|
263
|
+
record: row,
|
|
264
|
+
note: `Chained as record ${String(row['seq'])} of system ${systemId}${row['is_first'] === true ? ', the first of its chain' : ''}, and its file kept. ${mode === 'none'
|
|
265
|
+
? 'It is kept, and handed over when the authority asks.'
|
|
266
|
+
: 'It is to be sent to the authority: its file is an issue of artefact fiscal_record, sent by a transport the host brings.'}`,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/** The earliest day a regime binds anybody, or null where the pack names none. */
|
|
270
|
+
function earliestObligation(regime) {
|
|
271
|
+
const days = regime.mandatory_from.map((entry) => entry.from).sort();
|
|
272
|
+
return days[0] ?? null;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Whether the status counts posted sales as missing a record. Only under a
|
|
276
|
+
* chained regime in force: an announced day binds nobody, and a reporting
|
|
277
|
+
* regime keeps no chain — which documents it reports is its brick's to say.
|
|
278
|
+
*/
|
|
279
|
+
function countsMissing(regime) {
|
|
280
|
+
return regime !== null && regime.hash !== null && (regime.announced_from ?? null) === null;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Where the fiscal records of a company stand: its regime, each chain
|
|
284
|
+
* verified, the records still to be sent, the posted sales without a record,
|
|
285
|
+
* and the latest events. A posted sale without a record is named here and
|
|
286
|
+
* never fiscalised on the way.
|
|
287
|
+
*/
|
|
288
|
+
export async function fiscalisationStatus(backend, companyId, options = {}) {
|
|
289
|
+
const limit = options.limit ?? 50;
|
|
290
|
+
const regime = await fiscalRegime(backend, companyId);
|
|
291
|
+
const records = await backend.select({
|
|
292
|
+
schema: SCHEMA,
|
|
293
|
+
table: 'fiscal_chain',
|
|
294
|
+
columns: ['system_id', 'seq', 'document_id', 'kind', 'hash', 'mode', 'issue_id', 'recorded_at'],
|
|
295
|
+
where: [{ column: 'company_id', op: 'eq', value: companyId }],
|
|
296
|
+
order: [{ column: 'system_id' }, { column: 'seq' }],
|
|
297
|
+
});
|
|
298
|
+
const systems = [];
|
|
299
|
+
for (const systemId of [...new Set(records.map((r) => String(r['system_id'])))]) {
|
|
300
|
+
const own = records.filter((r) => r['system_id'] === systemId);
|
|
301
|
+
const tail = own[own.length - 1];
|
|
302
|
+
const breaks = await backend.rpc('verify_fiscal_chain', { p_company_id: companyId, p_system_id: systemId }, SCHEMA);
|
|
303
|
+
systems.push({
|
|
304
|
+
system_id: systemId,
|
|
305
|
+
records: own.length,
|
|
306
|
+
last_seq: tail['seq'],
|
|
307
|
+
last_hash: tail['hash'],
|
|
308
|
+
last_at: tail['recorded_at'],
|
|
309
|
+
verified: breaks.length === 0,
|
|
310
|
+
break: breaks[0] ?? null,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
// Sent means somebody on the way took charge of it.
|
|
314
|
+
const reached = new Set((await backend.select({
|
|
315
|
+
schema: SCHEMA,
|
|
316
|
+
table: 'transmissions',
|
|
317
|
+
columns: ['issue_id', 'state'],
|
|
318
|
+
where: [
|
|
319
|
+
{ column: 'company_id', op: 'eq', value: companyId },
|
|
320
|
+
{ column: 'artefact', op: 'eq', value: 'fiscal_record' },
|
|
321
|
+
{ column: 'state', op: 'in', value: ['accepted_by_access_point', 'delivered'] },
|
|
322
|
+
],
|
|
323
|
+
})).map((t) => String(t['issue_id'])));
|
|
324
|
+
const pending = records
|
|
325
|
+
.filter((r) => r['mode'] !== 'none' && !reached.has(String(r['issue_id'])))
|
|
326
|
+
.map((r) => ({ system_id: r['system_id'], seq: r['seq'], document_id: r['document_id'], kind: r['kind'], issue_id: r['issue_id'] }));
|
|
327
|
+
const fiscalised = new Set(records.filter((r) => r['kind'] === 'alta').map((r) => String(r['document_id'])));
|
|
328
|
+
const posted = await backend.select({
|
|
329
|
+
table: 'documents',
|
|
330
|
+
columns: ['id', 'doc_type', 'number', 'document_date::text'],
|
|
331
|
+
where: [
|
|
332
|
+
{ column: 'company_id', op: 'eq', value: companyId },
|
|
333
|
+
{ column: 'state', op: 'eq', value: 'posted' },
|
|
334
|
+
{ column: 'doc_type', op: 'in', value: ['sale_invoice', 'sale_credit_note'] },
|
|
335
|
+
],
|
|
336
|
+
order: [{ column: 'document_date' }, { column: 'number' }],
|
|
337
|
+
});
|
|
338
|
+
const from = regime === null ? null : earliestObligation(regime);
|
|
339
|
+
const counted = countsMissing(regime);
|
|
340
|
+
const without = counted ? posted.filter((d) => !fiscalised.has(String(d['id']))) : [];
|
|
341
|
+
const missing = without.filter((d) => from === null || String(d['document_date']) >= from);
|
|
342
|
+
const events = await backend.select({
|
|
343
|
+
schema: SCHEMA,
|
|
344
|
+
table: 'fiscal_events',
|
|
345
|
+
columns: ['system_id', 'seq', 'kind', 'detail', 'at', 'recorded_by'],
|
|
346
|
+
where: [{ column: 'company_id', op: 'eq', value: companyId }],
|
|
347
|
+
order: [{ column: 'at', ascending: false }, { column: 'seq', ascending: false }],
|
|
348
|
+
limit: 10,
|
|
349
|
+
});
|
|
350
|
+
const broken = systems.filter((s) => s['verified'] !== true);
|
|
351
|
+
return {
|
|
352
|
+
company_id: companyId,
|
|
353
|
+
regime: regime === null
|
|
354
|
+
? null
|
|
355
|
+
: {
|
|
356
|
+
kind: regime.kind,
|
|
357
|
+
format: regime.format,
|
|
358
|
+
brick: FISCALISATION_FORMATS[regime.format]?.brick ?? null,
|
|
359
|
+
mandatory_from: regime.mandatory_from,
|
|
360
|
+
announced_from: regime.announced_from,
|
|
361
|
+
announced_by: regime.announced_by,
|
|
362
|
+
announced_on: regime.announced_on,
|
|
363
|
+
mode: regime.submission.mode,
|
|
364
|
+
modes: regime.submission.modes,
|
|
365
|
+
channel: regime.submission.channel,
|
|
366
|
+
cadence: regime.submission.cadence,
|
|
367
|
+
events: regime.events,
|
|
368
|
+
reported: regime.reported,
|
|
369
|
+
legal_reference: regime.legal_reference,
|
|
370
|
+
},
|
|
371
|
+
systems,
|
|
372
|
+
verified: broken.length === 0,
|
|
373
|
+
pending: pending.slice(0, limit),
|
|
374
|
+
pending_count: pending.length,
|
|
375
|
+
missing: missing.slice(0, limit),
|
|
376
|
+
missing_count: missing.length,
|
|
377
|
+
before_obligation_count: without.length - missing.length,
|
|
378
|
+
events,
|
|
379
|
+
note: regime === null
|
|
380
|
+
? 'The country pack of this company declares no fiscalisation regime.'
|
|
381
|
+
: !counted
|
|
382
|
+
? uncountedNote(regime)
|
|
383
|
+
: broken.length > 0
|
|
384
|
+
? `The chain of ${broken.map((s) => String(s['system_id'])).join(', ')} breaks where break says. Nothing more is chained to it; this is for the company's accountant before anything else.`
|
|
385
|
+
: missing.length > 0
|
|
386
|
+
? `${missing.length} posted sale(s) dated from ${from ?? 'the start of the obligation'} have no fiscal record. Nothing is fiscalised on its own: einvoicing_fiscalise (ekwo einvoice fiscalise) chains one.`
|
|
387
|
+
: 'Every posted sale within the obligation has its record, and every chain is intact.',
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
/** Why the status counts no sale as missing a record under a regime that is announced only, or that reports. */
|
|
391
|
+
function uncountedNote(regime) {
|
|
392
|
+
if (regime.announced_from !== null) {
|
|
393
|
+
return `The fiscalisation of this company's country is only announced, from ${regime.announced_from} (${regime.announced_by ?? 'by nobody named'}, ${regime.announced_on ?? 'undated'}); no text in force sets it, so no sale is counted as missing a record.`;
|
|
394
|
+
}
|
|
395
|
+
const brick = FISCALISATION_FORMATS[regime.format]?.brick;
|
|
396
|
+
return `The fiscalisation of this company's country is a reporting regime, ${regime.format}: the data of its documents are reported to the authority and nothing is chained, so no sale is counted as missing a record. ${brick === undefined ? `No brick of packages/formats/ writes ${regime.format} yet (format_without_brick), and Ekwo writes no report for it.` : `${brick} writes the report.`}`;
|
|
397
|
+
}
|
|
398
|
+
/** The variable the command line and the MCP server read the invoicing system from, as JSON. */
|
|
399
|
+
export const FISCAL_SYSTEM_ENV = 'EKWO_FISCAL_SYSTEM';
|
|
400
|
+
/**
|
|
401
|
+
* The invoicing system, from the JSON an operator wrote: every text field
|
|
402
|
+
* present and not blank, the three booleans booleans where given. Nothing is
|
|
403
|
+
* filled in — a producer's tax number guessed is a record the authority
|
|
404
|
+
* attributes to somebody else.
|
|
405
|
+
*/
|
|
406
|
+
export function parseFiscalSystem(value, where = FISCAL_SYSTEM_ENV) {
|
|
407
|
+
let raw = value;
|
|
408
|
+
if (typeof raw === 'string') {
|
|
409
|
+
try {
|
|
410
|
+
raw = JSON.parse(raw);
|
|
411
|
+
}
|
|
412
|
+
catch (error) {
|
|
413
|
+
throw new BooksError(`bad_fiscal_system: ${where} is not JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
417
|
+
throw new BooksError(`bad_fiscal_system: ${where} describes the invoicing system as an object.`);
|
|
418
|
+
}
|
|
419
|
+
const entry = raw;
|
|
420
|
+
const missing = ['name', 'id', 'version', 'installation', 'producerName', 'producerTaxId'].filter((key) => typeof entry[key] !== 'string' || entry[key].trim() === '');
|
|
421
|
+
if (missing.length > 0) {
|
|
422
|
+
throw new BooksError(`bad_fiscal_system: ${where} names no ${missing.join(', ')}. The invoicing system is described by its operator — name, id, version, installation, producerName, producerTaxId — and none of it is invented.`);
|
|
423
|
+
}
|
|
424
|
+
const system = {
|
|
425
|
+
name: String(entry['name']),
|
|
426
|
+
id: String(entry['id']),
|
|
427
|
+
version: String(entry['version']),
|
|
428
|
+
installation: String(entry['installation']),
|
|
429
|
+
producerName: String(entry['producerName']),
|
|
430
|
+
producerTaxId: String(entry['producerTaxId']),
|
|
431
|
+
};
|
|
432
|
+
for (const key of ['verifactuOnly', 'multipleTaxpayers', 'multipleTaxpayersNow']) {
|
|
433
|
+
const flag = entry[key];
|
|
434
|
+
if (flag === undefined)
|
|
435
|
+
continue;
|
|
436
|
+
if (typeof flag !== 'boolean')
|
|
437
|
+
throw new BooksError(`bad_fiscal_system: ${key} in ${where} is true or false.`);
|
|
438
|
+
system[key] = flag;
|
|
439
|
+
}
|
|
440
|
+
return system;
|
|
441
|
+
}
|
|
442
|
+
//# sourceMappingURL=fiscalisation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fiscalisation.js","sourceRoot":"","sources":["../../src/einvoicing/fiscalisation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAA0B,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,gBA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M,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;KAC9C,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE,mBAAmB,EAAE,sBAAsB,CAAU,EAAE,CAAC;QAC1F,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,IAAI,KAAK,SAAS;YAAE,SAAS;QACjC,IAAI,OAAO,IAAI,KAAK,SAAS;YAAE,MAAM,IAAI,UAAU,CAAC,sBAAsB,GAAG,OAAO,KAAK,oBAAoB,CAAC,CAAC;QAC/G,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
* Electronic invoicing: the file of a posted sale, kept, and sent through a
|
|
3
3
|
* transport the caller brings. The schema is the `einvoicing` module's; the
|
|
4
4
|
* formats are the bricks of `packages/formats/`; the transports are the
|
|
5
|
-
* contract in `transport.ts`, and one of them — a folder — ships.
|
|
5
|
+
* contract in `transport.ts`, and one of them — a folder — ships. A fiscal
|
|
6
|
+
* record — the chained record a country's fiscalisation regime requires — is
|
|
7
|
+
* a second artefact of the same document, in `fiscalisation.ts`.
|
|
6
8
|
*/
|
|
7
9
|
export * from './transport.js';
|
|
8
10
|
export * from './directory.js';
|
|
9
11
|
export * from './formats.js';
|
|
10
12
|
export * from './issue.js';
|
|
13
|
+
export * from './fiscalisation.js';
|
|
14
|
+
export * from './peppol.js';
|
|
11
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/einvoicing/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/einvoicing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|
package/dist/einvoicing/index.js
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
* Electronic invoicing: the file of a posted sale, kept, and sent through a
|
|
3
3
|
* transport the caller brings. The schema is the `einvoicing` module's; the
|
|
4
4
|
* formats are the bricks of `packages/formats/`; the transports are the
|
|
5
|
-
* contract in `transport.ts`, and one of them — a folder — ships.
|
|
5
|
+
* contract in `transport.ts`, and one of them — a folder — ships. A fiscal
|
|
6
|
+
* record — the chained record a country's fiscalisation regime requires — is
|
|
7
|
+
* a second artefact of the same document, in `fiscalisation.ts`.
|
|
6
8
|
*/
|
|
7
9
|
export * from './transport.js';
|
|
8
10
|
export * from './directory.js';
|
|
9
11
|
export * from './formats.js';
|
|
10
12
|
export * from './issue.js';
|
|
13
|
+
export * from './fiscalisation.js';
|
|
14
|
+
export * from './peppol.js';
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/einvoicing/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/einvoicing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|
|
@@ -51,6 +51,12 @@ export interface ProducedEinvoice {
|
|
|
51
51
|
}
|
|
52
52
|
/** The three views of one document, and the invoice it credits where it is a credit note. */
|
|
53
53
|
export declare function readEinvoiceSource(backend: Backend, documentId: string): Promise<EinvoiceSource>;
|
|
54
|
+
/**
|
|
55
|
+
* Refuses, by name, a document that is not a posted sale: what an electronic
|
|
56
|
+
* invoice and a fiscal record are both written from. The database refuses it
|
|
57
|
+
* again; this says so before a brick is run.
|
|
58
|
+
*/
|
|
59
|
+
export declare function assertPostedSale(header: Row, documentId: string): void;
|
|
54
60
|
/**
|
|
55
61
|
* Writes the file of a posted sale, in the profile of its company's country
|
|
56
62
|
* pack, and says which rules it breaks. Records nothing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../src/einvoicing/issue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAc,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAkDxB,+FAA+F;AAC/F,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,C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,CAClC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,kBAAkB,EACxB,SAAS,CAAC,EAAE,iBAAiB,GAC5B,OAAO,CAAC,GAAG,CAAC,CA0Ed;AAED,MAAM,WAAW,6BAA6B;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,6GAA6G;AAC7G,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,GAAG,CAAC,CAyCnH"}
|
package/dist/einvoicing/issue.js
CHANGED
|
@@ -119,12 +119,11 @@ function addressOf(header, side) {
|
|
|
119
119
|
return typeof scheme === 'string' && typeof id === 'string' ? { scheme, id } : null;
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
122
|
+
* Refuses, by name, a document that is not a posted sale: what an electronic
|
|
123
|
+
* invoice and a fiscal record are both written from. The database refuses it
|
|
124
|
+
* again; this says so before a brick is run.
|
|
124
125
|
*/
|
|
125
|
-
export
|
|
126
|
-
const source = await readEinvoiceSource(backend, documentId);
|
|
127
|
-
const { header } = source;
|
|
126
|
+
export function assertPostedSale(header, documentId) {
|
|
128
127
|
const what = `${String(header['doc_type'])} ${String(header['number'] ?? documentId)}`;
|
|
129
128
|
if (header['doc_type'] !== 'sale_invoice' && header['doc_type'] !== 'sale_credit_note') {
|
|
130
129
|
throw new BooksError(`document_not_a_sale: ${what} is not a sale invoice or a sale credit note, and only a sale is issued electronically by its seller.`);
|
|
@@ -132,6 +131,15 @@ export async function produceEinvoice(backend, documentId) {
|
|
|
132
131
|
if (header['state'] !== 'posted') {
|
|
133
132
|
throw new BooksError(`document_not_posted: ${what} is ${String(header['state'])}, and only a posted document is issued: post it first, and the file says what the books say.`, { hint: 'post_document (ekwo post <document>) books it; --dry-run shows the entry first.' });
|
|
134
133
|
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Writes the file of a posted sale, in the profile of its company's country
|
|
137
|
+
* pack, and says which rules it breaks. Records nothing.
|
|
138
|
+
*/
|
|
139
|
+
export async function produceEinvoice(backend, documentId) {
|
|
140
|
+
const source = await readEinvoiceSource(backend, documentId);
|
|
141
|
+
const { header } = source;
|
|
142
|
+
assertPostedSale(header, documentId);
|
|
135
143
|
const format = einvoiceFormat(header['einvoice_profile']);
|
|
136
144
|
const written = format.write(source);
|
|
137
145
|
return {
|