@ekwo-ai/core 0.12.1 → 0.13.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.
@@ -62,7 +62,8 @@ export declare const AUDIT_LOG: string[];
62
62
  /**
63
63
  * `country_packs` — which pack this installation holds, and where its rules
64
64
  * come from. `sources` is the register the pack declares: a reader that wants
65
- * to check a rate rather than trust it starts there.
65
+ * to check a rate rather than trust it starts there. `evidence` is what a
66
+ * proven pack was proven on, per scope, and what was not tested.
66
67
  */
67
68
  export declare const COUNTRY_PACK: string[];
68
69
  //# sourceMappingURL=columns.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../../src/books/columns.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,OAAO,UAuCnB,CAAC;AAEF,eAAO,MAAM,WAAW,UAAoE,CAAC;AAE7F,eAAO,MAAM,OAAO,UAUnB,CAAC;AAEF,eAAO,MAAM,OAAO,UAAmD,CAAC;AAExE,eAAO,MAAM,OAAO,UAcnB,CAAC;AAEF,eAAO,MAAM,GAAG,UAsBf,CAAC;AAEF,eAAO,MAAM,QAAQ,UA2BpB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,UAQlC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,UAWlC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,UAoE3B,CAAC;AAEF,eAAO,MAAM,OAAO,UAgBnB,CAAC;AAEF,eAAO,MAAM,aAAa,UAmBzB,CAAC;AAEF,eAAO,MAAM,KAAK,UAejB,CAAC;AAEF,eAAO,MAAM,UAAU,UAsBtB,CAAC;AAEF,eAAO,MAAM,YAAY,UAYxB,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAiB5B,CAAC;AAEF,eAAO,MAAM,OAAO,UAgBnB,CAAC;AAEF;;;;GAIG;AACH,gFAAgF;AAChF,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tB,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,OAAO,UAWnB,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,cAAc,UAW1B,CAAC;AAEF,eAAO,MAAM,QAAQ,UAQpB,CAAC;AAEF,eAAO,MAAM,cAAc,UAa1B,CAAC;AAEF,eAAO,MAAM,SAAS,UAarB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAaxB,CAAC"}
@@ -455,7 +455,8 @@ export const AUDIT_LOG = [
455
455
  /**
456
456
  * `country_packs` — which pack this installation holds, and where its rules
457
457
  * come from. `sources` is the register the pack declares: a reader that wants
458
- * to check a rate rather than trust it starts there.
458
+ * to check a rate rather than trust it starts there. `evidence` is what a
459
+ * proven pack was proven on, per scope, and what was not tested.
459
460
  */
460
461
  export const COUNTRY_PACK = [
461
462
  'country',
@@ -468,6 +469,7 @@ export const COUNTRY_PACK = [
468
469
  'certified_at::text',
469
470
  'checksum',
470
471
  'sources',
472
+ 'evidence',
471
473
  'installed_at::text',
472
474
  ];
473
475
  //# sourceMappingURL=columns.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"columns.js","sourceRoot":"","sources":["../../src/books/columns.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI;IACJ,MAAM;IACN,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,qBAAqB;IACrB,eAAe;IACf,eAAe;IACf,aAAa;IACb,MAAM;IACN,SAAS;IACT,QAAQ;IACR,OAAO;IACP,OAAO;IACP,SAAS;IACT,UAAU;IACV,qBAAqB;IACrB,wBAAwB;IACxB,eAAe;IACf,iBAAiB;IACjB,mBAAmB;IACnB,sBAAsB;IACtB,uBAAuB;IACvB,yBAAyB;IACzB,UAAU;IACV,eAAe;IACf,iBAAiB;IACjB,qBAAqB;IACrB,uBAAuB;IACvB,oBAAoB;IACpB,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,+EAA+E;AAC/E,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI;IACJ,YAAY;IACZ,aAAa;IACb,cAAc;IACd,YAAY;IACZ,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,YAAY;IACZ,sBAAsB;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,aAAa;IACb,mBAAmB;IACnB,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,oBAAoB;IACpB,qBAAqB;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI;IACJ,eAAe;IACf,gBAAgB;IAChB,cAAc;IACd,iBAAiB;IACjB,kBAAkB;IAClB,yEAAyE;IACzE,4EAA4E;IAC5E,qEAAqE;IACrE,iCAAiC;IACjC,aAAa;IACb,uBAAuB;CACxB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,mBAAmB;IACnB,UAAU;IACV,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,WAAW;IACX,QAAQ;IACR,YAAY;IACZ,YAAY;CACb,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS;IACT,MAAM;IACN,SAAS;IACT,mBAAmB;IACnB,YAAY;IACZ,sBAAsB;IACtB,cAAc;IACd,oBAAoB;IACpB,UAAU;IACV,SAAS;IACT,oBAAoB;CACrB,CAAC"}
1
+ {"version":3,"file":"columns.js","sourceRoot":"","sources":["../../src/books/columns.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI;IACJ,MAAM;IACN,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,qBAAqB;IACrB,eAAe;IACf,eAAe;IACf,aAAa;IACb,MAAM;IACN,SAAS;IACT,QAAQ;IAC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ated: boolean;
69
69
  }
70
+ export interface CompanyJournal {
71
+ code: string;
72
+ journal_type: string;
73
+ }
70
74
  /**
71
75
  * How a proposed account was settled, so the user knows how much to trust it:
72
76
  * `given` by the caller, `exact` — the same code, and nothing in the files
@@ -105,6 +109,8 @@ export interface Proposal {
105
109
  /** Accounts the lines use whose proposal waits for the user's confirmation. */
106
110
  unconfirmed_accounts: string[];
107
111
  unmapped_journals: string[];
112
+ /** Why each journal the caller did not answer was proposed where it was. */
113
+ journal_reasons: Record<string, string>;
108
114
  /** The type of each account of the chart, by code: what says a party is a customer or a supplier. */
109
115
  account_types: Record<string, string>;
110
116
  }
@@ -114,7 +120,9 @@ export interface Proposal {
114
120
  * The codes give a candidate, never a country: the same code; the same digits
115
121
  * once the zeros a chart pads with on the right are set aside (`411` and
116
122
  * `411000`); else the account whose digits are the longest beginning of the old
117
- * code, three at least (`401ACME` to `401000`). A tie is no answer. Then what
123
+ * code, three at least (`401ACME` to `401000`). Where a heading and its detail
124
+ * account tie, the detail account, which takes entries, is the candidate; any
125
+ * other tie is no answer. Then what
118
126
  * the files say of the old account — its type, its name, the side of its
119
127
  * balance — is held against what the chart says the candidate is, because two
120
128
  * charts use the same digits for different things: `610` is a receivable in
@@ -135,6 +143,32 @@ export declare function proposeAccount(source: SourceAccount, chart: readonly Ch
135
143
  export declare function proposeMapping(backend: Backend, companyId: string, books: ImportedBooks, given?: Partial<ImportMapping>, options?: {
136
144
  accept_suggestions?: boolean | undefined;
137
145
  }): Promise<Proposal>;
146
+ /** What an old journal is held against: the company's journals, the codes opening journals go by, the days its years start on, and the type of the account each old account was proposed to. */
147
+ export interface JournalContext {
148
+ journals: readonly CompanyJournal[];
149
+ /** The codes of the opening journals of every pack this installation knows, and of the company's own, upper case. */
150
+ openingCodes: ReadonlySet<string>;
151
+ /** The month and day each fiscal year of the company starts on, `MM-DD`. */
152
+ yearStarts: ReadonlySet<string>;
153
+ typeOf: (sourceAccount: string) => string | null;
154
+ }
155
+ export interface JournalProposal {
156
+ target: string | null;
157
+ reason: string;
158
+ }
159
+ /**
160
+ * The journal of the company each old journal most probably goes to, and why.
161
+ *
162
+ * Its name is never read: what it holds is. The opening is the journal whose
163
+ * entries all fall on one day — the first day of a year of the company — and
164
+ * touch no income or expense account, or the one going by the code an opening
165
+ * journal has in a pack, its entries on one day. Then the journal of the
166
+ * company with the same code. Then sales, purchases or bank, where every entry
167
+ * of the old journal touches what one of them, and only one, is for — and the
168
+ * company has one journal of that type. Everything else goes to the general
169
+ * journal.
170
+ */
171
+ export declare function proposeJournals(books: ImportedBooks, context: JournalContext): Record<string, JournalProposal>;
138
172
  export interface ImportBooksArgs {
139
173
  company_id: string;
140
174
  source: BookSource;
@@ -145,8 +179,14 @@ export interface ImportBooksArgs {
145
179
  dry_run?: boolean | undefined;
146
180
  /** Open the fiscal years the entries fall in, where the company has none. */
147
181
  open_years?: boolean | undefined;
148
- /** The first day of the year a trial balance opens, where the file says none. */
182
+ /** The day a trial balance opens on, where the file says none: the first day of a fiscal year, or the day inside it the books were taken over. */
149
183
  opening_date?: string | undefined;
184
+ /**
185
+ * The invoices and credit notes still open on the day of the opening, as
186
+ * CSV (`readOpenItems()` of `@ekwo-ai/trial-balance`). Each becomes a
187
+ * posted document carrying its share of the receivable or payable balance.
188
+ */
189
+ open_items?: BookFile | undefined;
150
190
  /** Let a trial balance carry income and expense accounts: books taken over in the middle of a year. */
151
191
  allow_result_accounts?: boolean | undefined;
152
192
  /** Keep the numbers the entries had, where the country allows a number chosen by hand or the caller holds entries.import. */
@@ -1 +1 @@
1
- {"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../src/books/imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAW,KAAK,aAAa,EAAqB,MAAM,cAAc,CAAC;AAG9E,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAG5E,OAAO,EAAc,KAAK,OAAO,EAAY,MAAM,cAAc,CAAC;AA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CA+F3G"}
@@ -16,7 +16,7 @@
16
16
  */
17
17
  import { createHash } from 'node:crypto';
18
18
  import { readFec } from '@ekwo-ai/fec';
19
- import { readTrialBalance } from '@ekwo-ai/trial-balance';
19
+ import { readOpenItems, readTrialBalance } from '@ekwo-ai/trial-balance';
20
20
  import { readJournalItems } from '@ekwo-ai/journal-items';
21
21
  import { readJournalReport } from '@ekwo-ai/journal-report';
22
22
  import { readTransactionJournal } from '@ekwo-ai/transaction-journal';
@@ -257,13 +257,26 @@ function accountOfKind(source, live) {
257
257
  const named = ofKind.filter((account) => sameName(source.name, account.name));
258
258
  return named.length === 1 ? named[0] : null;
259
259
  }
260
+ /**
261
+ * Of accounts tied on their code, the ones that take entries. Once the padding
262
+ * zeros are set aside a heading and its detail account read the same — `110`
263
+ * and `110000`, `400` and `400000` — and the heading is the one with another
264
+ * account of the chart under its code. A tie of one is left as it is.
265
+ */
266
+ function postable(tied, live) {
267
+ if (tied.length < 2)
268
+ return tied;
269
+ return tied.filter((account) => !live.some((other) => other.code.length > account.code.length && other.code.startsWith(account.code)));
270
+ }
260
271
  /**
261
272
  * The account of the chart an old account most probably is, and why.
262
273
  *
263
274
  * The codes give a candidate, never a country: the same code; the same digits
264
275
  * once the zeros a chart pads with on the right are set aside (`411` and
265
276
  * `411000`); else the account whose digits are the longest beginning of the old
266
- * code, three at least (`401ACME` to `401000`). A tie is no answer. Then what
277
+ * code, three at least (`401ACME` to `401000`). Where a heading and its detail
278
+ * account tie, the detail account, which takes entries, is the candidate; any
279
+ * other tie is no answer. Then what
267
280
  * the files say of the old account — its type, its name, the side of its
268
281
  * balance — is held against what the chart says the candidate is, because two
269
282
  * charts use the same digits for different things: `610` is a receivable in
@@ -280,7 +293,7 @@ export function proposeAccount(source, chart) {
280
293
  const same = live.find((account) => account.code === source.code);
281
294
  if (same !== undefined)
282
295
  return { account: same, match: 'same-code' };
283
- const digits = live.filter((account) => unpadded(account.code) === unpadded(source.code));
296
+ const digits = postable(live.filter((account) => unpadded(account.code) === unpadded(source.code)), live);
284
297
  if (digits.length === 1)
285
298
  return { account: digits[0], match: 'same-digits' };
286
299
  let best = [];
@@ -295,6 +308,7 @@ export function proposeAccount(source, chart) {
295
308
  best.push(account);
296
309
  }
297
310
  }
311
+ best = postable(best, live);
298
312
  return best.length === 1 ? { account: best[0], match: 'prefix' } : null;
299
313
  };
300
314
  const found = byCode();
@@ -359,7 +373,7 @@ function millionths(amount) {
359
373
  * caller accepts the suggestions as a whole.
360
374
  */
361
375
  export async function proposeMapping(backend, companyId, books, given = {}, options = {}) {
362
- const [chart, journals, openingCode] = await Promise.all([
376
+ const [chart, journals, openingCodes, years] = await Promise.all([
363
377
  wholeChart(backend, companyId),
364
378
  backend.select({
365
379
  table: 'journals',
@@ -370,7 +384,12 @@ export async function proposeMapping(backend, companyId, books, given = {}, opti
370
384
  ],
371
385
  order: [{ column: 'code' }],
372
386
  }),
373
- openingJournalCode(backend, companyId),
387
+ backend.select({ table: 'journal_templates', columns: ['code'], where: [{ column: 'journal_type', op: 'eq', value: 'opening' }] }),
388
+ backend.select({
389
+ table: 'fiscal_years',
390
+ columns: ['start_date::text'],
391
+ where: [{ column: 'company_id', op: 'eq', value: companyId }],
392
+ }),
374
393
  ]);
375
394
  const byCode = new Map(chart.map((account) => [account.code, account]));
376
395
  const accounts = sourceAccounts(books).map((source) => {
@@ -389,19 +408,17 @@ export async function proposeMapping(backend, companyId, books, given = {}, opti
389
408
  }
390
409
  return { source: source.code, name: source.name, ...proposeAccount(source, chart) };
391
410
  });
392
- const known = new Set(journals.map((journal) => journal.code));
393
- const general = journals.find((journal) => journal.journal_type === 'general')?.code ?? null;
411
+ const targetOf = new Map(accounts.map((account) => [account.source, account.target]));
412
+ const journalProposals = proposeJournals(books, {
413
+ journals,
414
+ openingCodes: new Set([...openingCodes.map((row) => row.code), ...journals.filter((j) => j.journal_type === 'opening').map((j) => j.code)].map((code) => code.toUpperCase())),
415
+ yearStarts: new Set(years.map((year) => year.start_date.slice(5, 10))),
416
+ typeOf: (code) => byCode.get(targetOf.get(code) ?? '')?.account_type ?? null,
417
+ });
394
418
  const journalMap = {};
395
- for (const source of [...new Set(books.entries.map((entry) => entry.journal ?? NO_JOURNAL))].sort()) {
419
+ for (const [source, proposed] of Object.entries(journalProposals)) {
396
420
  const answer = given.journals?.[source];
397
- if (answer !== undefined && answer !== null)
398
- journalMap[source] = answer;
399
- else if (openingCode !== null && source.toUpperCase() === openingCode)
400
- journalMap[source] = OPENING;
401
- else if (known.has(source.toUpperCase()))
402
- journalMap[source] = source.toUpperCase();
403
- else
404
- journalMap[source] = general;
421
+ journalMap[source] = answer !== undefined && answer !== null ? answer : proposed.target;
405
422
  }
406
423
  const accept = options.accept_suggestions === true;
407
424
  const settled = (account) => account.basis === 'given' || account.basis === 'exact' || (accept && account.basis === 'suggested') ? account.target : null;
@@ -423,6 +440,7 @@ export async function proposeMapping(backend, companyId, books, given = {}, opti
423
440
  unmapped_accounts: accounts.filter((a) => a.basis === 'none' && used.has(a.source)).map((a) => a.source),
424
441
  unconfirmed_accounts: waiting.filter((a) => used.has(a.source)).map((a) => a.source),
425
442
  unmapped_journals: Object.entries(journalMap).filter(([, target]) => target === null).map(([source]) => source),
443
+ journal_reasons: Object.fromEntries(Object.entries(journalProposals).filter(([source]) => given.journals?.[source] == null).map(([source, proposed]) => [source, proposed.reason])),
426
444
  account_types: Object.fromEntries(chart.map((account) => [account.code, account.account_type])),
427
445
  };
428
446
  }
@@ -462,19 +480,74 @@ function usedAccounts(books) {
462
480
  used.add(line.account);
463
481
  return [...used];
464
482
  }
465
- /** The code of the journal the pack of this company opens its years on, or null. */
466
- async function openingJournalCode(backend, companyId) {
467
- const rows = await backend.select({
468
- table: 'journals',
469
- columns: ['code'],
470
- where: [
471
- { column: 'company_id', op: 'eq', value: companyId },
472
- { column: 'journal_type', op: 'eq', value: 'opening' },
473
- { column: 'active', op: 'eq', value: true },
474
- ],
475
- order: [{ column: 'code' }],
476
- });
477
- return rows.length === 1 ? rows[0].code : null;
483
+ /** The kinds of journal an old one is recognised as by what its entries touch, each with the account types every entry has to touch. */
484
+ const JOURNAL_SHAPES = [
485
+ { type: 'sales', words: 'a receivable and an income account', touches: [(t) => t === 'asset_receivable', (t) => t.startsWith('income')] },
486
+ { type: 'purchase', words: 'a payable and an expense account', touches: [(t) => t === 'liability_payable', (t) => t.startsWith('expense')] },
487
+ { type: 'bank', words: 'a bank or cash account', touches: [(t) => t === 'asset_cash'] },
488
+ ];
489
+ /**
490
+ * The journal of the company each old journal most probably goes to, and why.
491
+ *
492
+ * Its name is never read: what it holds is. The opening is the journal whose
493
+ * entries all fall on one day — the first day of a year of the company — and
494
+ * touch no income or expense account, or the one going by the code an opening
495
+ * journal has in a pack, its entries on one day. Then the journal of the
496
+ * company with the same code. Then sales, purchases or bank, where every entry
497
+ * of the old journal touches what one of them, and only one, is for — and the
498
+ * company has one journal of that type. Everything else goes to the general
499
+ * journal.
500
+ */
501
+ export function proposeJournals(books, context) {
502
+ const bySource = new Map();
503
+ for (const entry of books.entries) {
504
+ const source = entry.journal ?? NO_JOURNAL;
505
+ bySource.set(source, [...(bySource.get(source) ?? []), entry]);
506
+ }
507
+ const ofType = (type) => {
508
+ const found = context.journals.filter((journal) => journal.journal_type === type);
509
+ return found.length === 1 ? found[0].code : null;
510
+ };
511
+ const known = new Set(context.journals.map((journal) => journal.code));
512
+ const general = context.journals.find((journal) => journal.journal_type === 'general')?.code ?? null;
513
+ const typesOf = (entry) => entry.lines.map((line) => context.typeOf(line.account)).filter((type) => type !== null);
514
+ const oneDay = (entries) => (new Set(entries.map((entry) => entry.date)).size === 1 ? (entries[0]?.date ?? null) : null);
515
+ let opening = null;
516
+ if (context.journals.some((journal) => journal.journal_type === 'opening')) {
517
+ const byCode = [...bySource].filter(([source, entries]) => context.openingCodes.has(source.toUpperCase()) && oneDay(entries) !== null);
518
+ const byShape = [...bySource].filter(([, entries]) => {
519
+ const day = oneDay(entries);
520
+ return day !== null && context.yearStarts.has(day.slice(5, 10)) && entries.every((entry) => typesOf(entry).every((type) => !/^(income|expense)/.test(type)));
521
+ });
522
+ const [coded] = byCode;
523
+ const [shaped] = byShape;
524
+ if (byCode.length === 1 && coded !== undefined) {
525
+ opening = { source: coded[0], reason: 'its code is the one an opening journal has, and its entries fall on one day' };
526
+ }
527
+ else if (byCode.length === 0 && byShape.length === 1 && shaped !== undefined) {
528
+ const day = oneDay(shaped[1]);
529
+ opening = { source: shaped[0], reason: `its entries fall on ${day}, the first day of a year of the company, and touch no income or expense account` };
530
+ }
531
+ }
532
+ const proposals = {};
533
+ for (const [source, entries] of [...bySource].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {
534
+ if (opening?.source === source) {
535
+ proposals[source] = { target: OPENING, reason: `the opening balance: ${opening.reason}` };
536
+ continue;
537
+ }
538
+ if (known.has(source.toUpperCase())) {
539
+ proposals[source] = { target: source.toUpperCase(), reason: 'the journal of the company with the same code' };
540
+ continue;
541
+ }
542
+ const shapes = JOURNAL_SHAPES.filter((shape) => entries.every((entry) => shape.touches.every((touch) => typesOf(entry).some(touch))));
543
+ const [shape] = shapes;
544
+ const target = shapes.length === 1 && shape !== undefined ? ofType(shape.type) : null;
545
+ proposals[source] =
546
+ target !== null && shape !== undefined
547
+ ? { target, reason: `every entry touches ${shape.words}` }
548
+ : { target: general, reason: 'nothing its entries touch says it is a sales, purchase, bank or opening journal' };
549
+ }
550
+ return proposals;
478
551
  }
479
552
  /**
480
553
  * Reads the files, settles the correspondence and hands the books to
@@ -487,6 +560,10 @@ async function openingJournalCode(backend, companyId) {
487
560
  */
488
561
  export async function importBooks(backend, args) {
489
562
  const books = readBooks(args.source, args.files, { encoding: args.encoding, date_order: args.date_order });
563
+ const openItems = args.open_items === undefined
564
+ ? null
565
+ : readOpenItems(args.open_items.content, args.encoding === undefined ? {} : { encoding: args.encoding === 'iso-8859-15' ? 'iso-8859-1' : args.encoding });
566
+ const violations = [...books.violations, ...(openItems?.violations ?? [])];
490
567
  const proposal = await proposeMapping(backend, args.company_id, books, args.mapping ?? {}, { accept_suggestions: args.accept_suggestions });
491
568
  const read = {
492
569
  accounts: books.accounts.length,
@@ -494,6 +571,7 @@ export async function importBooks(backend, args) {
494
571
  entries: books.entries.length,
495
572
  lines: books.entries.reduce((sum, entry) => sum + entry.lines.length, 0),
496
573
  opening_lines: books.opening.length,
574
+ open_items: openItems?.items.length ?? 0,
497
575
  };
498
576
  const answer = {
499
577
  dry_run: args.dry_run === true,
@@ -504,7 +582,8 @@ export async function importBooks(backend, args) {
504
582
  unmapped_accounts: proposal.unmapped_accounts,
505
583
  unconfirmed_accounts: proposal.unconfirmed_accounts,
506
584
  unmapped_journals: proposal.unmapped_journals,
507
- violations: books.violations,
585
+ journal_reasons: proposal.journal_reasons,
586
+ violations,
508
587
  };
509
588
  const company = await backend.select({
510
589
  table: 'companies',
@@ -518,9 +597,9 @@ export async function importBooks(backend, args) {
518
597
  if (books.currency !== null && currency !== null && books.currency.toUpperCase() !== currency) {
519
598
  blocking.push(`import_currency_mismatch: the files are in ${books.currency} and the company keeps its books in ${currency}`);
520
599
  }
521
- if (books.violations.length > 0) {
522
- blocking.push(`import_violations: the files do not add up in ${books.violations.length} place${books.violations.length === 1 ? '' : 's'}; ` +
523
- books.violations.slice(0, 5).map((v) => `${v.row === null ? '' : `row ${v.row}: `}${v.message}`).join('; '));
600
+ if (violations.length > 0) {
601
+ blocking.push(`import_violations: the files do not add up in ${violations.length} place${violations.length === 1 ? '' : 's'}; ` +
602
+ violations.slice(0, 5).map((v) => `${v.row === null ? '' : `row ${v.row}: `}${v.message}`).join('; '));
524
603
  }
525
604
  if (proposal.unmapped_accounts.length > 0) {
526
605
  blocking.push(`import_unmapped_accounts: no account of the chart answers for ${proposal.unmapped_accounts.join(', ')}. Say which in the correspondence`);
@@ -542,12 +621,13 @@ export async function importBooks(backend, args) {
542
621
  hint: 'Nothing was imported. Run the same import with dry_run to see the correspondence proposed, save it, answer what is missing, and give it back.',
543
622
  });
544
623
  }
545
- const payload = buildPayload(books, proposal.mapping, proposal.account_types, currency, {
624
+ const payload = buildPayload(books, openItems, proposal.mapping, proposal.account_types, currency, {
546
625
  ...args,
547
626
  opening_date: args.opening_date ?? openingDateOf(books),
548
627
  });
549
- payload['checksum'] = booksChecksum(args.files);
550
- payload['file_names'] = args.files.map((file) => file.name);
628
+ const files = args.open_items === undefined ? args.files : [...args.files, args.open_items];
629
+ payload['checksum'] = booksChecksum(files);
630
+ payload['file_names'] = files.map((file) => file.name);
551
631
  const [result] = await backend.rpc('import_books', {
552
632
  p_company_id: args.company_id,
553
633
  p_books: payload,
@@ -566,7 +646,7 @@ export async function importBooks(backend, args) {
566
646
  };
567
647
  }
568
648
  /** The books, translated into this company's codes, in the shape `import_books()` takes. */
569
- function buildPayload(books, mapping, accountTypes, currency, args) {
649
+ function buildPayload(books, openItems, mapping, accountTypes, currency, args) {
570
650
  const account = (code) => mapping.accounts[code];
571
651
  // What a party is follows from where its lines are booked: on a receivable
572
652
  // it is a customer, on a payable a supplier, on both it is both.
@@ -620,7 +700,7 @@ function buildPayload(books, mapping, accountTypes, currency, args) {
620
700
  throw new BooksError('import_two_openings: these books carry a trial balance and entries mapped to the opening; one opening per import');
621
701
  }
622
702
  if (args.opening_date === undefined) {
623
- throw new BooksError('missing_opening_date: a trial balance says nothing of the day it opens. Give the first day of the fiscal year it opens (opening_date).');
703
+ throw new BooksError('missing_opening_date: a trial balance says nothing of the day it opens. Give the first day of the fiscal year it opens, or the day inside it the books were taken over (opening_date).');
624
704
  }
625
705
  openingDate = args.opening_date;
626
706
  openingLines.push(...books.opening.map(line));
@@ -628,11 +708,24 @@ function buildPayload(books, mapping, accountTypes, currency, args) {
628
708
  else if (args.opening_date !== undefined && openingDate === null) {
629
709
  throw new BooksError('unexpected_opening_date: an opening date was given and these books carry no balance to open');
630
710
  }
711
+ if (openItems !== null && openingDate === null) {
712
+ throw new BooksError('unexpected_open_items: open items were given and these books carry no balance to open; the open items are the detail of an opening');
713
+ }
714
+ // An open item is owed by a customer or to a supplier, and its type says which.
715
+ for (const item of openItems?.items ?? []) {
716
+ const seen = roles.get(item.contact) ?? new Set();
717
+ seen.add(item.type.startsWith('sale_') ? 'customer' : 'supplier');
718
+ roles.set(item.contact, seen);
719
+ }
631
720
  const typeOf = (key) => {
632
721
  const seen = roles.get(key) ?? new Set();
633
722
  return seen.size === 2 ? 'both' : seen.size === 1 ? [...seen][0] : 'other';
634
723
  };
635
- const contacts = books.contacts
724
+ const listed = [
725
+ ...books.contacts,
726
+ ...(openItems?.contacts ?? []).filter((contact) => !books.contacts.some((known) => known.code === contact.code)),
727
+ ];
728
+ const contacts = listed
636
729
  .filter((contact) => roles.has(contact.code))
637
730
  .map((contact) => ({
638
731
  key: contact.code,
@@ -654,7 +747,23 @@ function buildPayload(books, mapping, accountTypes, currency, args) {
654
747
  source: books.format,
655
748
  contacts,
656
749
  entries,
657
- opening: openingDate === null ? null : { date: openingDate, lines: openingLines },
750
+ opening: openingDate === null
751
+ ? null
752
+ : {
753
+ date: openingDate,
754
+ lines: openingLines,
755
+ items: (openItems?.items ?? []).map((item) => ({
756
+ doc_type: item.type,
757
+ number: item.number,
758
+ contact_key: item.contact,
759
+ amount: item.amount,
760
+ document_date: item.documentDate,
761
+ due_date: item.dueDate,
762
+ payment_reference: item.paymentReference,
763
+ supplier_reference: item.supplierReference,
764
+ label: item.label,
765
+ })),
766
+ },
658
767
  };
659
768
  }
660
769
  //# sourceMappingURL=imports.js.map