@ekwo-ai/core 0.25.0 → 0.26.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.
Files changed (56) hide show
  1. package/dist/bank.d.ts +4 -1
  2. package/dist/bank.d.ts.map +1 -1
  3. package/dist/bank.js +4 -1
  4. package/dist/bank.js.map +1 -1
  5. package/dist/books/bank-accounts.d.ts +52 -0
  6. package/dist/books/bank-accounts.d.ts.map +1 -0
  7. package/dist/books/bank-accounts.js +91 -0
  8. package/dist/books/bank-accounts.js.map +1 -0
  9. package/dist/books/closing.d.ts +36 -0
  10. package/dist/books/closing.d.ts.map +1 -0
  11. package/dist/books/closing.js +65 -0
  12. package/dist/books/closing.js.map +1 -0
  13. package/dist/books/columns.d.ts.map +1 -1
  14. package/dist/books/columns.js +7 -0
  15. package/dist/books/columns.js.map +1 -1
  16. package/dist/books/documents.d.ts +53 -1
  17. package/dist/books/documents.d.ts.map +1 -1
  18. package/dist/books/documents.js +91 -6
  19. package/dist/books/documents.js.map +1 -1
  20. package/dist/books/format.d.ts +2 -0
  21. package/dist/books/format.d.ts.map +1 -1
  22. package/dist/books/format.js +14 -0
  23. package/dist/books/format.js.map +1 -1
  24. package/dist/books/index.d.ts +2 -0
  25. package/dist/books/index.d.ts.map +1 -1
  26. package/dist/books/index.js +2 -0
  27. package/dist/books/index.js.map +1 -1
  28. package/dist/books/reports.d.ts +33 -4
  29. package/dist/books/reports.d.ts.map +1 -1
  30. package/dist/books/reports.js +93 -8
  31. package/dist/books/reports.js.map +1 -1
  32. package/dist/books/statements.d.ts +46 -4
  33. package/dist/books/statements.d.ts.map +1 -1
  34. package/dist/books/statements.js +131 -8
  35. package/dist/books/statements.js.map +1 -1
  36. package/dist/client.d.ts +10 -1
  37. package/dist/client.d.ts.map +1 -1
  38. package/dist/client.js +15 -0
  39. package/dist/client.js.map +1 -1
  40. package/dist/crm/index.d.ts +33 -0
  41. package/dist/crm/index.d.ts.map +1 -1
  42. package/dist/crm/index.js +37 -0
  43. package/dist/crm/index.js.map +1 -1
  44. package/dist/einvoicing/formats.js +1 -1
  45. package/dist/einvoicing/formats.js.map +1 -1
  46. package/dist/einvoicing/issue.d.ts.map +1 -1
  47. package/dist/einvoicing/issue.js +1 -14
  48. package/dist/einvoicing/issue.js.map +1 -1
  49. package/dist/schema.d.ts +75 -0
  50. package/dist/schema.d.ts.map +1 -1
  51. package/dist/schema.js +75 -0
  52. package/dist/schema.js.map +1 -1
  53. package/dist/types.d.ts +38 -0
  54. package/dist/types.d.ts.map +1 -1
  55. package/dist/types.js.map +1 -1
  56. package/package.json +16 -15
package/dist/bank.d.ts CHANGED
@@ -16,9 +16,12 @@
16
16
  *
17
17
  * A format is added here the day a brick reads it, not the day a pack mentions
18
18
  * it — the test above is what keeps the two from being confused.
19
+ *
20
+ * `csv` is one reader for every lay-out, and a file of it is read only with
21
+ * the profile of its columns, which the caller gives (`@ekwo-ai/csv-statement`).
19
22
  */
20
23
  /** The statement formats a brick of this repository can read. */
21
- export declare const STATEMENT_FORMATS: readonly ["camt.053", "coda", "cfonb120"];
24
+ export declare const STATEMENT_FORMATS: readonly ["camt.053", "coda", "cfonb120", "csv"];
22
25
  /** One of the formats above. */
23
26
  export type StatementFormat = (typeof STATEMENT_FORMATS)[number];
24
27
  //# sourceMappingURL=bank.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bank.d.ts","sourceRoot":"","sources":["../src/bank.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,2CAA4C,CAAC;AAE3E,gCAAgC;AAChC,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"bank.d.ts","sourceRoot":"","sources":["../src/bank.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,kDAAmD,CAAC;AAElF,gCAAgC;AAChC,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC"}
package/dist/bank.js CHANGED
@@ -16,7 +16,10 @@
16
16
  *
17
17
  * A format is added here the day a brick reads it, not the day a pack mentions
18
18
  * it — the test above is what keeps the two from being confused.
19
+ *
20
+ * `csv` is one reader for every lay-out, and a file of it is read only with
21
+ * the profile of its columns, which the caller gives (`@ekwo-ai/csv-statement`).
19
22
  */
20
23
  /** The statement formats a brick of this repository can read. */
21
- export const STATEMENT_FORMATS = ['camt.053', 'coda', 'cfonb120'];
24
+ export const STATEMENT_FORMATS = ['camt.053', 'coda', 'cfonb120', 'csv'];
22
25
  //# sourceMappingURL=bank.js.map
package/dist/bank.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bank.js","sourceRoot":"","sources":["../src/bank.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAU,CAAC"}
1
+ {"version":3,"file":"bank.js","sourceRoot":"","sources":["../src/bank.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAU,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The bank accounts of a company, read and changed outside a statement.
3
+ *
4
+ * `create_bank_account()` of the schema creates one; what is here is the rest
5
+ * both surfaces need — the list, and the profile of an account's CSV
6
+ * statements (`bank_accounts.statement_profile`), the lay-out of its bank's
7
+ * export, described once on the account for every member and every way in.
8
+ * The MCP server's `list_bank_accounts` and `update_bank_account` and the
9
+ * command line's `ekwo bank` call these, and `importStatementFile()` reads and
10
+ * keeps the profile through them.
11
+ */
12
+ import { type CsvStatementProfile } from '@ekwo-ai/csv-statement';
13
+ import { type Backend, type Row } from './backend.js';
14
+ export interface ListBankAccountsArgs {
15
+ company_id: string;
16
+ /** Default false. */
17
+ include_inactive?: boolean | undefined;
18
+ }
19
+ /**
20
+ * The bank accounts of a company, by name, with the journal and the ledger
21
+ * account behind each and the profile of its CSV statements — left out of the
22
+ * row on a schema that does not keep one.
23
+ */
24
+ export declare function listBankAccounts(backend: Backend, args: ListBankAccountsArgs): Promise<Row[]>;
25
+ /** A profile as a row holds it: an object, or nothing. */
26
+ export declare function profileOf(value: unknown): CsvStatementProfile | null;
27
+ /** One bank account of the company, or the refusal that names it. */
28
+ export declare function bankAccountOf(backend: Backend, companyId: string, bankAccountId: string, select: string[]): Promise<Row>;
29
+ /**
30
+ * The profile of the CSV statements kept on a bank account, `null` when
31
+ * nobody has described them yet — and on a schema without the column, which
32
+ * keeps none.
33
+ */
34
+ export declare function bankAccountStatementProfile(backend: Backend, args: {
35
+ company_id: string;
36
+ bank_account_id: string;
37
+ }): Promise<CsvStatementProfile | null>;
38
+ export interface SetStatementProfileArgs {
39
+ company_id: string;
40
+ bank_account_id: string;
41
+ /** The profile of the account's CSV statements; `null` forgets it. */
42
+ statement_profile: CsvStatementProfile | null;
43
+ }
44
+ /**
45
+ * Keeps — or, with `null`, forgets — the profile of a bank account's CSV
46
+ * statements, outside an import: for a person who describes the lay-out
47
+ * before the first file, or corrects it. A profile no file could be read with
48
+ * is refused `invalid_profile`, as the reader would refuse it; a schema
49
+ * without the column refuses by name, `schema_too_old_for`.
50
+ */
51
+ export declare function setBankAccountStatementProfile(backend: Backend, args: SetStatementProfileArgs): Promise<Row>;
52
+ //# sourceMappingURL=bank-accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bank-accounts.d.ts","sourceRoot":"","sources":["../../src/books/bank-accounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAgE,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAChI,OAAO,EAAc,KAAK,OAAO,EAAe,KAAK,GAAG,EAAE,MAAM,cAAc,CAAC;AAG/E,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAUnG;AAED,0DAA0D;AAC1D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,GAAG,IAAI,CAEpE;AAED,qEAAqE;AACrE,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAa9H;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,GACpD,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAGrC;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,iBAAiB,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAC/C;AAED;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC,CA4BlH"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The bank accounts of a company, read and changed outside a statement.
3
+ *
4
+ * `create_bank_account()` of the schema creates one; what is here is the rest
5
+ * both surfaces need — the list, and the profile of an account's CSV
6
+ * statements (`bank_accounts.statement_profile`), the lay-out of its bank's
7
+ * export, described once on the account for every member and every way in.
8
+ * The MCP server's `list_bank_accounts` and `update_bank_account` and the
9
+ * command line's `ekwo bank` call these, and `importStatementFile()` reads and
10
+ * keeps the profile through them.
11
+ */
12
+ import { StatementFileError as CsvFileError, checkCsvStatementProfile } from '@ekwo-ai/csv-statement';
13
+ import { BooksError } from './backend.js';
14
+ import * as columns from './columns.js';
15
+ /**
16
+ * The bank accounts of a company, by name, with the journal and the ledger
17
+ * account behind each and the profile of its CSV statements — left out of the
18
+ * row on a schema that does not keep one.
19
+ */
20
+ export async function listBankAccounts(backend, args) {
21
+ return backend.select({
22
+ table: 'bank_accounts',
23
+ columns: [...columns.BANK_ACCOUNT],
24
+ where: [
25
+ { column: 'company_id', op: 'eq', value: args.company_id },
26
+ ...(args.include_inactive === true ? [] : [{ column: 'active', op: 'eq', value: true }]),
27
+ ],
28
+ order: [{ column: 'name' }],
29
+ });
30
+ }
31
+ /** A profile as a row holds it: an object, or nothing. */
32
+ export function profileOf(value) {
33
+ return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : null;
34
+ }
35
+ /** One bank account of the company, or the refusal that names it. */
36
+ export async function bankAccountOf(backend, companyId, bankAccountId, select) {
37
+ const [account] = await backend.select({
38
+ table: 'bank_accounts',
39
+ columns: select,
40
+ where: [
41
+ { column: 'id', op: 'eq', value: bankAccountId },
42
+ { column: 'company_id', op: 'eq', value: companyId },
43
+ ],
44
+ });
45
+ if (account === undefined) {
46
+ throw new BooksError(`unknown_bank_account: ${bankAccountId} is not a bank account of this company`, { code: 'unknown_bank_account' });
47
+ }
48
+ return account;
49
+ }
50
+ /**
51
+ * The profile of the CSV statements kept on a bank account, `null` when
52
+ * nobody has described them yet — and on a schema without the column, which
53
+ * keeps none.
54
+ */
55
+ export async function bankAccountStatementProfile(backend, args) {
56
+ const account = await bankAccountOf(backend, args.company_id, args.bank_account_id, ['id', 'statement_profile']);
57
+ return profileOf(account['statement_profile']);
58
+ }
59
+ /**
60
+ * Keeps — or, with `null`, forgets — the profile of a bank account's CSV
61
+ * statements, outside an import: for a person who describes the lay-out
62
+ * before the first file, or corrects it. A profile no file could be read with
63
+ * is refused `invalid_profile`, as the reader would refuse it; a schema
64
+ * without the column refuses by name, `schema_too_old_for`.
65
+ */
66
+ export async function setBankAccountStatementProfile(backend, args) {
67
+ if (args.statement_profile !== null) {
68
+ try {
69
+ checkCsvStatementProfile(args.statement_profile);
70
+ }
71
+ catch (error) {
72
+ if (error instanceof CsvFileError) {
73
+ throw new BooksError(`invalid_profile: ${error.message}`, {
74
+ code: 'invalid_profile',
75
+ hint: 'Nothing was changed. The profile is described in the README of @ekwo-ai/csv-statement.',
76
+ });
77
+ }
78
+ throw error;
79
+ }
80
+ }
81
+ await bankAccountOf(backend, args.company_id, args.bank_account_id, ['id']);
82
+ const [account] = await backend.update('bank_accounts', { statement_profile: args.statement_profile }, [
83
+ { column: 'id', op: 'eq', value: args.bank_account_id },
84
+ { column: 'company_id', op: 'eq', value: args.company_id },
85
+ ], [...columns.BANK_ACCOUNT]);
86
+ if (account === undefined) {
87
+ throw new BooksError('not_allowed: changing a bank account of this company needs bank.write', { code: 'not_allowed' });
88
+ }
89
+ return account;
90
+ }
91
+ //# sourceMappingURL=bank-accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bank-accounts.js","sourceRoot":"","sources":["../../src/books/bank-accounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,kBAAkB,IAAI,YAAY,EAAE,wBAAwB,EAA4B,MAAM,wBAAwB,CAAC;AAChI,OAAO,EAAE,UAAU,EAAuC,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAQxC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAgB,EAAE,IAA0B;IACjF,OAAO,OAAO,CAAC,MAAM,CAAM;Q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AAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE;KAC3D,EACD,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAC1B,CAAC;IACF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,UAAU,CAAC,uEAAuE,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;IACzH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Closing the books: the lock dates of a company, and the close of a
3
+ * financial year — ordinary, undone, or final.
4
+ *
5
+ * Each is one write the schema checks. A lock date is a column of the
6
+ * company, and the triggers on the ledger refuse anything dated on or before
7
+ * it; the close of a year is `close_fiscal_year()`, which decides the account
8
+ * the result travels through and which entries are written, from the country
9
+ * pack. Nothing of a rule is here. They lived in the MCP server until the
10
+ * command line closed the same months and years, as `ekwo close` and
11
+ * `ekwo reopen`.
12
+ */
13
+ import { type Backend } from './backend.js';
14
+ export interface LockPeriodArgs {
15
+ company_id: string;
16
+ /** Nothing may be booked on or before it. `null` lifts the lock; left out, unchanged. */
17
+ lock_date?: string | null | undefined;
18
+ /** Additionally freezes anything carrying a VAT box. `null` lifts it; left out, unchanged. */
19
+ tax_lock_date?: string | null | undefined;
20
+ }
21
+ /** Moves the lock date, the VAT lock date, or both. Only an owner of the company may. */
22
+ export declare function lockPeriod(backend: Backend, args: LockPeriodArgs): Promise<unknown>;
23
+ export interface FiscalYearArgs {
24
+ fiscal_year_id: string;
25
+ }
26
+ /**
27
+ * Closes a year: `close_fiscal_year()`, then what the country asks next —
28
+ * a final close, by when and under which article, or nothing — from
29
+ * `fiscal_year_final_close()`. The pack says it; this only passes it on.
30
+ */
31
+ export declare function closeFiscalYear(backend: Backend, args: FiscalYearArgs): Promise<unknown>;
32
+ /** Undoes an ordinary close: `reopen_fiscal_year()`. */
33
+ export declare function reopenFiscalYear(backend: Backend, args: FiscalYearArgs): Promise<unknown>;
34
+ /** The final close of a closed year: `close_fiscal_year_finally()`. Irreversible. */
35
+ export declare function closeFiscalYearFinally(backend: Backend, args: FiscalYearArgs): Promise<unknown>;
36
+ //# sourceMappingURL=closing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closing.d.ts","sourceRoot":"","sources":["../../src/books/closing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAc,KAAK,OAAO,EAAY,MAAM,cAAc,CAAC;AAGlE,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACtC,8FAA8F;IAC9F,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC3C;AAED,yFAAyF;AACzF,wBAAsB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBzF;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAQ9F;AAED,wDAAwD;AACxD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAM/F;AAED,qFAAqF;AACrF,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAMrG"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Closing the books: the lock dates of a company, and the close of a
3
+ * financial year — ordinary, undone, or final.
4
+ *
5
+ * Each is one write the schema checks. A lock date is a column of the
6
+ * company, and the triggers on the ledger refuse anything dated on or before
7
+ * it; the close of a year is `close_fiscal_year()`, which decides the account
8
+ * the result travels through and which entries are written, from the country
9
+ * pack. Nothing of a rule is here. They lived in the MCP server until the
10
+ * command line closed the same months and years, as `ekwo close` and
11
+ * `ekwo reopen`.
12
+ */
13
+ import { BooksError } from './backend.js';
14
+ import { only } from './shared.js';
15
+ /** Moves the lock date, the VAT lock date, or both. Only an owner of the company may. */
16
+ export async function lockPeriod(backend, args) {
17
+ const patch = {};
18
+ if (args.lock_date !== undefined)
19
+ patch['lock_date'] = args.lock_date;
20
+ if (args.tax_lock_date !== undefined)
21
+ patch['tax_lock_date'] = args.tax_lock_date;
22
+ if (Object.keys(patch).length === 0) {
23
+ throw new BooksError('nothing_to_lock: give lock_date, tax_lock_date, or both.');
24
+ }
25
+ const rows = await backend.update('companies', patch, [{ column: 'id', op: 'eq', value: args.company_id }], ['id', 'name', 'lock_date::text', 'tax_lock_date::text']);
26
+ const company = rows[0];
27
+ if (company === undefined) {
28
+ throw new BooksError('not_owner: only an owner of the company may move its lock dates, and nothing was changed.');
29
+ }
30
+ return {
31
+ company,
32
+ note: 'Locking is enforced by triggers on the ledger, not by this server. Everything on or before the date now refuses to move.',
33
+ };
34
+ }
35
+ /**
36
+ * Closes a year: `close_fiscal_year()`, then what the country asks next —
37
+ * a final close, by when and under which article, or nothing — from
38
+ * `fiscal_year_final_close()`. The pack says it; this only passes it on.
39
+ */
40
+ export async function closeFiscalYear(backend, args) {
41
+ const answer = await backend.rpc('close_fiscal_year', { p_fiscal_year_id: args.fiscal_year_id });
42
+ const finalClose = await backend.rpc('fiscal_year_final_close', { p_fiscal_year_id: args.fiscal_year_id });
43
+ return {
44
+ close: only(answer, `fiscal year ${args.fiscal_year_id}`),
45
+ final_close: only(finalClose, `fiscal year ${args.fiscal_year_id}`),
46
+ note: 'The income statement is back at zero and the year refuses new entries. It can still be reopened with reopen_fiscal_year. What a general meeting decides to do with the result — a dividend, a reserve — is a later entry, and the close never writes it. Where final_close.required is true, the country requires a final close by final_close.due_date: tell the user, and call close_fiscal_year_finally only when they ask for it.',
47
+ };
48
+ }
49
+ /** Undoes an ordinary close: `reopen_fiscal_year()`. */
50
+ export async function reopenFiscalYear(backend, args) {
51
+ const answer = await backend.rpc('reopen_fiscal_year', { p_fiscal_year_id: args.fiscal_year_id });
52
+ return {
53
+ reopen: only(answer, `fiscal year ${args.fiscal_year_id}`),
54
+ note: 'The entries the close wrote are reversed, not deleted, and the year accepts entries again. Entries of later years are untouched: they read this year from the ledger, so a new close carries the corrected result to them by itself.',
55
+ };
56
+ }
57
+ /** The final close of a closed year: `close_fiscal_year_finally()`. Irreversible. */
58
+ export async function closeFiscalYearFinally(backend, args) {
59
+ const answer = await backend.rpc('close_fiscal_year_finally', { p_fiscal_year_id: args.fiscal_year_id });
60
+ return {
61
+ final_close: only(answer, `fiscal year ${args.fiscal_year_id}`),
62
+ note: 'The year is closed for good: reopen_fiscal_year refuses it for everybody, and nothing about it changes any more. A correction is booked in an open year.',
63
+ };
64
+ }
65
+ //# sourceMappingURL=closing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closing.js","sourceRoot":"","sources":["../../src/books/closing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAA0B,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAUnC,yFAAyF;AACzF,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAgB,EAAE,IAAoB;IACrE,MAAM,KAAK,GAAQ,EAAE,CAAC;IACtB,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS;QAAE,KAAK,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;IACtE,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS;QAAE,KAAK,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC;IAClF,IAAI,MAAM,CAAC,IAAI,CAAC,K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C;AAEF,eAAO,MAAM,YAAY,UAcxB,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAiB5B,CAAC;AAEF,eAAO,MAAM,OAAO,UAgBnB,CAAC;AAEF;;;;GAIG;AACH,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,UAS5B,CAAC;AAEF,eAAO,MAAM,UAAU,UAYtB,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,OAAO,UAYnB,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"}
@@ -134,6 +134,11 @@ export const DOCUMENT = [
134
134
  'reversed_document_id',
135
135
  'entry_id',
136
136
  'sent_at::text',
137
+ // The answer to a quote or an order (schema 0.26.0; left out of the read
138
+ // below it, `SCHEMA_FEATURES.quote_answer`).
139
+ 'accepted_at::text',
140
+ 'accepted_by',
141
+ 'declined_at::text',
137
142
  ];
138
143
  /**
139
144
  * The mentions the law of a country puts on one document, from the view that
@@ -335,6 +340,8 @@ export const BANK_ACCOUNT = [
335
340
  'account_id',
336
341
  'journal_id',
337
342
  'active',
343
+ // The profile of its CSV statements; left out of a read below schema 0.26.0.
344
+ 'statement_profile',
338
345
  ];
339
346
  export const BANK_TRANSACTION = [
340
347
  'id',
@@ -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,SA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,YAAY;IACZ,sBAAsB;IACtB,cAAc;IACd,oBAAoB;IACpB,UAAU;IACV,SAAS;IACT,UAAU;IACV,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;IACR,OAAO;IACP,OAAO;IACP,SAAS;IACT,UAAU;IACV,qBAAqB;IACrB,wBAAwB;IACxB,eAAe;IACf,iBAAiB;IACjB,sBAAsB;IACtB,aAAa;IACb,mBAAmB;IACnB,sBAAsB;IACtB,uBAAuB;IACvB,eAAe;IACf,kBAAkB;IAClB,eAAe;IACf,8BAA8B;IAC9B,yBAAyB;IACzB,UAAU;IACV,eAAe;IACf,iBAAiB;IACjB,qBAAqB;IACrB,uBAAuB;IACvB,oBAAoB;IACpB,qBAAqB;IACrB,8BAA8B;IAC9B,kBAAkB;IAClB,qBAAqB;IACrB,0BAA0B;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAC;AAE7F,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI;IACJ,MAAM;IACN,MAAM;IACN,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,eAAe;IACf,YAAY;IACZ,QAAQ;CACT,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI;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,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;;;;;GAKG;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,UAAU;IACV,oBAAoB;CACrB,CAAC"}
@@ -9,9 +9,32 @@
9
9
  * draft documents and their lines.
10
10
  */
11
11
  import { type Backend, type Row } from './backend.js';
12
- import type { DocType } from '../types.js';
12
+ import type { DocType, QuoteStatus } from '../types.js';
13
13
  export declare const DOC_TYPES: readonly ["sale_invoice", "sale_credit_note", "sale_quote", "purchase_invoice", "purchase_credit_note", "purchase_order"];
14
14
  export declare const DOCUMENT_STATES: readonly ["draft", "posted", "cancelled"];
15
+ /** The documents an answer is given to: accepted or declined by the other party. */
16
+ export declare const ANSWERED_DOC_TYPES: readonly ["sale_quote", "purchase_order"];
17
+ /**
18
+ * The words of `quote_status()`, in the order a quote lives them. The schema
19
+ * derives the status; this list only names its values, and a test holds it
20
+ * equal to what the function can answer.
21
+ */
22
+ export declare const QUOTE_STATUSES: readonly ["draft", "sent", "accepted", "declined", "expired", "cancelled"];
23
+ /** Where the word of each status is, among the words of a document's language. */
24
+ export declare const QUOTE_STATUS_LABEL_KEYS: {
25
+ readonly draft: "quoteDraft";
26
+ readonly sent: "quoteSent";
27
+ readonly accepted: "quoteAccepted";
28
+ readonly declined: "quoteDeclined";
29
+ readonly expired: "quoteExpired";
30
+ readonly cancelled: "cancelled";
31
+ };
32
+ /**
33
+ * The word of a status in a language — the document's, the person's — from
34
+ * the same language files as the words of a document, English where the
35
+ * language has none.
36
+ */
37
+ export declare function quoteStatusLabel(status: QuoteStatus, language?: string | null): string;
15
38
  export declare const PAYMENT_STATES: readonly ["not_paid", "partially_paid", "paid", "overpaid", "reversed"];
16
39
  /** A line as a caller writes it: codes or ids, and whatever a product can fill in. */
17
40
  export interface LineArgs {
@@ -94,6 +117,35 @@ export interface ApproveDocumentArgs {
94
117
  * (`approval_by_a_person`) and to whoever may not post the document.
95
118
  */
96
119
  export declare function approveDocument(backend: Backend, args: ApproveDocumentArgs): Promise<unknown>;
120
+ export interface AcceptDocumentArgs {
121
+ document_id: string;
122
+ /** Who accepted it, in your words: a name, a role, the reference of a signed copy. */
123
+ accepted_by?: string | undefined;
124
+ /** When it was accepted. Left out: now. Never in the future. */
125
+ at?: string | undefined;
126
+ }
127
+ export interface DeclineDocumentArgs {
128
+ document_id: string;
129
+ /** When it was declined. Left out: now. Never in the future. */
130
+ at?: string | undefined;
131
+ }
132
+ export interface UndoDocumentAnswerArgs {
133
+ document_id: string;
134
+ }
135
+ /**
136
+ * Records that the other party accepted a quote or an order, through
137
+ * `accept_document()`: a dated fact on the document, nothing booked. The
138
+ * status is then `accepted`. The schema refuses an invoice
139
+ * (`document_not_answerable`), a declined document
140
+ * (`document_already_answered`), a date to come (`answer_in_the_future`), and
141
+ * an agent in review without a person's approval of the document as it
142
+ * stands (`approval_required`).
143
+ */
144
+ export declare function acceptDocument(backend: Backend, args: AcceptDocumentArgs): Promise<unknown>;
145
+ /** Records that the other party declined a quote or an order, through `decline_document()`. */
146
+ export declare function declineDocument(backend: Backend, args: DeclineDocumentArgs): Promise<unknown>;
147
+ /** Takes back the answer recorded on a quote or an order, through `undo_document_answer()`. */
148
+ export declare function undoDocumentAnswer(backend: Backend, args: UndoDocumentAnswerArgs): Promise<unknown>;
97
149
  export declare function postDocument(backend: Backend, args: PostDocumentArgs): Promise<unknown>;
98
150
  /** The lines of an entry, each beside the account it is on. */
99
151
  export declare function entryLinesWithAccounts(backend: Backend, entryId: string): Promise<Row[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/books/documents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAA+B,KAAK,OAAO,EAAe,KAAK,GAAG,EAAE,MAAM,cAAc,CAAC;AAGhG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C,eAAO,MAAM,SAAS,2HAOiB,CAAC;AAExC,eAAO,MAAM,eAAe,2CAA4C,CAAC;AACzE,eAAO,MAAM,cAAc,yEAA0E,CAAC;AAEtG,sFAAsF;AACtF,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC/C,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,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gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAmB7F;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,OAAO,CAAC,CA6BlB;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,OAAO,CAAC,CA4HlB;AAID;;;GAGG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBxG"}
@@ -8,6 +8,7 @@
8
8
  * or an `entry_lines` row. Direct inserts are for the objects a person types:
9
9
  * draft documents and their lines.
10
10
  */
11
+ import { labelsFor } from '@ekwo-ai/invoice-pdf';
11
12
  import { BooksError, backendSupports } from './backend.js';
12
13
  import * as columns from './columns.js';
13
14
  import { amountIn, moneyFields } from './format.js';
@@ -21,6 +22,31 @@ export const DOC_TYPES = [
21
22
  'purchase_order',
22
23
  ];
23
24
  export const DOCUMENT_STATES = ['draft', 'posted', 'cancelled'];
25
+ /** The documents an answer is given to: accepted or declined by the other party. */
26
+ export const ANSWERED_DOC_TYPES = ['sale_quote', 'purchase_order'];
27
+ /**
28
+ * The words of `quote_status()`, in the order a quote lives them. The schema
29
+ * derives the status; this list only names its values, and a test holds it
30
+ * equal to what the function can answer.
31
+ */
32
+ export const QUOTE_STATUSES = ['draft', 'sent', 'accepted', 'declined', 'expired', 'cancelled'];
33
+ /** Where the word of each status is, among the words of a document's language. */
34
+ export const QUOTE_STATUS_LABEL_KEYS = {
35
+ draft: 'quoteDraft',
36
+ sent: 'quoteSent',
37
+ accepted: 'quoteAccepted',
38
+ declined: 'quoteDeclined',
39
+ expired: 'quoteExpired',
40
+ cancelled: 'cancelled',
41
+ };
42
+ /**
43
+ * The word of a status in a language — the document's, the person's — from
44
+ * the same language files as the words of a document, English where the
45
+ * language has none.
46
+ */
47
+ export function quoteStatusLabel(status, language) {
48
+ return labelsFor(language).labels[QUOTE_STATUS_LABEL_KEYS[status]];
49
+ }
24
50
  export const PAYMENT_STATES = ['not_paid', 'partially_paid', 'paid', 'overpaid', 'reversed'];
25
51
  export async function createDocument(backend, args) {
26
52
  const resolved = await resolveLineInputs(backend, args.company_id, args.doc_type, args.lines);
@@ -248,6 +274,61 @@ export async function approveDocument(backend, args) {
248
274
  note: 'Approved as it stands. An agent may now post it; a change to the draft before then needs another approval.',
249
275
  };
250
276
  }
277
+ /** The document as `get_document` shows it, after an answer was recorded on it. */
278
+ async function answered(backend, documentId, note) {
279
+ const read = (await getDocument(backend, { document_id: documentId }));
280
+ return { document: read['document'], note };
281
+ }
282
+ /**
283
+ * Records that the other party accepted a quote or an order, through
284
+ * `accept_document()`: a dated fact on the document, nothing booked. The
285
+ * status is then `accepted`. The schema refuses an invoice
286
+ * (`document_not_answerable`), a declined document
287
+ * (`document_already_answered`), a date to come (`answer_in_the_future`), and
288
+ * an agent in review without a person's approval of the document as it
289
+ * stands (`approval_required`).
290
+ */
291
+ export async function acceptDocument(backend, args) {
292
+ only(await backend.rpc('accept_document', {
293
+ p_document_id: args.document_id,
294
+ ...(args.accepted_by === undefined ? {} : { p_accepted_by: args.accepted_by }),
295
+ ...(args.at === undefined ? {} : { p_at: args.at }),
296
+ }), `document ${args.document_id}`);
297
+ return answered(backend, args.document_id, 'The acceptance is recorded on the document; nothing is booked. Where a deal of the crm module carries it, the deal is won. undo_document_answer takes it back.');
298
+ }
299
+ /** Records that the other party declined a quote or an order, through `decline_document()`. */
300
+ export async function declineDocument(backend, args) {
301
+ only(await backend.rpc('decline_document', {
302
+ p_document_id: args.document_id,
303
+ ...(args.at === undefined ? {} : { p_at: args.at }),
304
+ }), `document ${args.document_id}`);
305
+ return answered(backend, args.document_id, 'The refusal is recorded on the document; nothing is booked. Where a deal of the crm module carries it and no other quote of the deal is still alive, the deal is lost. undo_document_answer takes it back.');
306
+ }
307
+ /** Takes back the answer recorded on a quote or an order, through `undo_document_answer()`. */
308
+ export async function undoDocumentAnswer(backend, args) {
309
+ only(await backend.rpc('undo_document_answer', { p_document_id: args.document_id }), `document ${args.document_id}`);
310
+ return answered(backend, args.document_id, 'The answer is taken back: the document is unanswered again. A deal of the crm module its answer had closed is open again.');
311
+ }
312
+ /**
313
+ * Each document with `quote_status`, read from the schema's `quote_statuses()`
314
+ * — the status is derived there, once, and never worked out here. Null on a
315
+ * document no answer is given to. Below 0.26.0 the documents come back as
316
+ * they were read, without the field.
317
+ */
318
+ async function withQuoteStatus(backend, documents) {
319
+ if (!(await backendSupports(backend, 'quote_answer')))
320
+ return documents;
321
+ const answerable = documents
322
+ .filter((doc) => ANSWERED_DOC_TYPES.includes(doc['doc_type']))
323
+ .map((doc) => doc['id']);
324
+ const statuses = answerable.length === 0
325
+ ? []
326
+ : await backend.rpc('quote_statuses', {
327
+ p_document_ids: answerable,
328
+ });
329
+ const byId = new Map(statuses.map((row) => [row.document_id, row.quote_status]));
330
+ return documents.map((doc) => ({ ...doc, quote_status: byId.get(doc['id']) ?? null }));
331
+ }
251
332
  export async function postDocument(backend, args) {
252
333
  if (args.dry_run === true) {
253
334
  // The database posts for real and takes it back, so what comes out is
@@ -408,7 +489,7 @@ export async function listDocuments(backend, args) {
408
489
  });
409
490
  const names = await namesOf(backend, 'contacts', documents.map((doc) => doc['contact_id']));
410
491
  return {
411
- documents: documents.map((doc) => ({
492
+ documents: (await withQuoteStatus(backend, documents)).map((doc) => ({
412
493
  ...doc,
413
494
  contact_name: names[doc['contact_id']] ?? null,
414
495
  })),
@@ -416,11 +497,15 @@ export async function listDocuments(backend, args) {
416
497
  };
417
498
  }
418
499
  export async function getDocument(backend, args) {
419
- const document = onlyVisible(await backend.select({
420
- table: 'documents',
421
- columns: columns.DOCUMENT,
422
- where: [{ column: 'id', op: 'eq', value: args.document_id }],
423
- }), `document ${args.document_id}`);
500
+ const [document] = await withQuoteStatus(backend, [
501
+ onlyVisible(await backend.select({
502
+ table: 'documents',
503
+ columns: columns.DOCUMENT,
504
+ where: [{ column: 'id', op: 'eq', value: args.document_id }],
505
+ }), `document ${args.document_id}`),
506
+ ]);
507
+ if (document === undefined)
508
+ throw new BooksError(`document ${args.document_id}`);
424
509
  const lines = await backend.select({
425
510
  table: 'document_lines',
426
511
  columns: columns.DOCUMENT_LINE,