@booki-aui/core 0.0.0-stage → 0.2.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/CHANGELOG.md +78 -0
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/activity.d.ts +74 -0
- package/dist/activity.js +30 -0
- package/dist/activity.js.map +1 -0
- package/dist/aging.d.ts +85 -0
- package/dist/aging.js +18 -0
- package/dist/aging.js.map +1 -0
- package/dist/approval.d.ts +78 -0
- package/dist/approval.js +14 -0
- package/dist/approval.js.map +1 -0
- package/dist/attachments.d.ts +59 -0
- package/dist/attachments.js +26 -0
- package/dist/attachments.js.map +1 -0
- package/dist/audit.d.ts +161 -0
- package/dist/audit.js +42 -0
- package/dist/audit.js.map +1 -0
- package/dist/chunk-2H3DAON4.js +132 -0
- package/dist/chunk-2H3DAON4.js.map +1 -0
- package/dist/chunk-32RQTDSR.js +46 -0
- package/dist/chunk-32RQTDSR.js.map +1 -0
- package/dist/chunk-3PAJMQ5H.js +272 -0
- package/dist/chunk-3PAJMQ5H.js.map +1 -0
- package/dist/chunk-3WGVKVPL.js +156 -0
- package/dist/chunk-3WGVKVPL.js.map +1 -0
- package/dist/chunk-4OAXKS34.js +388 -0
- package/dist/chunk-4OAXKS34.js.map +1 -0
- package/dist/chunk-4ONDQS7Q.js +178 -0
- package/dist/chunk-4ONDQS7Q.js.map +1 -0
- package/dist/chunk-5MYAIV42.js +753 -0
- package/dist/chunk-5MYAIV42.js.map +1 -0
- package/dist/chunk-5Z6LU5LH.js +105 -0
- package/dist/chunk-5Z6LU5LH.js.map +1 -0
- package/dist/chunk-6BK7VPNH.js +227 -0
- package/dist/chunk-6BK7VPNH.js.map +1 -0
- package/dist/chunk-A2424P6Y.js +88 -0
- package/dist/chunk-A2424P6Y.js.map +1 -0
- package/dist/chunk-AGNXTHJA.js +229 -0
- package/dist/chunk-AGNXTHJA.js.map +1 -0
- package/dist/chunk-BJ3O7L5C.js +9 -0
- package/dist/chunk-BJ3O7L5C.js.map +1 -0
- package/dist/chunk-BMSGD3FU.js +122 -0
- package/dist/chunk-BMSGD3FU.js.map +1 -0
- package/dist/chunk-CUKV2KU3.js +360 -0
- package/dist/chunk-CUKV2KU3.js.map +1 -0
- package/dist/chunk-DJPVY5F2.js +277 -0
- package/dist/chunk-DJPVY5F2.js.map +1 -0
- package/dist/chunk-EGSWMJ7L.js +122 -0
- package/dist/chunk-EGSWMJ7L.js.map +1 -0
- package/dist/chunk-F2GGXRAH.js +68 -0
- package/dist/chunk-F2GGXRAH.js.map +1 -0
- package/dist/chunk-FP52SC7S.js +156 -0
- package/dist/chunk-FP52SC7S.js.map +1 -0
- package/dist/chunk-FR2XIJID.js +62 -0
- package/dist/chunk-FR2XIJID.js.map +1 -0
- package/dist/chunk-HWGE4OOL.js +97 -0
- package/dist/chunk-HWGE4OOL.js.map +1 -0
- package/dist/chunk-I4YPEKDY.js +135 -0
- package/dist/chunk-I4YPEKDY.js.map +1 -0
- package/dist/chunk-ICBA5A2V.js +11 -0
- package/dist/chunk-ICBA5A2V.js.map +1 -0
- package/dist/chunk-IF7T7ZAP.js +30 -0
- package/dist/chunk-IF7T7ZAP.js.map +1 -0
- package/dist/chunk-JIYWHAO3.js +164 -0
- package/dist/chunk-JIYWHAO3.js.map +1 -0
- package/dist/chunk-JQFQM2K3.js +151 -0
- package/dist/chunk-JQFQM2K3.js.map +1 -0
- package/dist/chunk-LJAY7P3Q.js +340 -0
- package/dist/chunk-LJAY7P3Q.js.map +1 -0
- package/dist/chunk-MV3NCGG4.js +263 -0
- package/dist/chunk-MV3NCGG4.js.map +1 -0
- package/dist/chunk-N77E7ZP7.js +120 -0
- package/dist/chunk-N77E7ZP7.js.map +1 -0
- package/dist/chunk-NY6TSOQO.js +287 -0
- package/dist/chunk-NY6TSOQO.js.map +1 -0
- package/dist/chunk-O7PLFRE7.js +84 -0
- package/dist/chunk-O7PLFRE7.js.map +1 -0
- package/dist/chunk-OUWAGY5G.js +423 -0
- package/dist/chunk-OUWAGY5G.js.map +1 -0
- package/dist/chunk-QUMUL4OH.js +342 -0
- package/dist/chunk-QUMUL4OH.js.map +1 -0
- package/dist/chunk-R2HUF2DV.js +116 -0
- package/dist/chunk-R2HUF2DV.js.map +1 -0
- package/dist/chunk-ROCF6IEK.js +59 -0
- package/dist/chunk-ROCF6IEK.js.map +1 -0
- package/dist/chunk-SRB5MG5C.js +94 -0
- package/dist/chunk-SRB5MG5C.js.map +1 -0
- package/dist/chunk-T3M424SP.js +60 -0
- package/dist/chunk-T3M424SP.js.map +1 -0
- package/dist/chunk-U5T5SUPP.js +681 -0
- package/dist/chunk-U5T5SUPP.js.map +1 -0
- package/dist/chunk-V37IQ36D.js +202 -0
- package/dist/chunk-V37IQ36D.js.map +1 -0
- package/dist/chunk-XXMOQEIG.js +139 -0
- package/dist/chunk-XXMOQEIG.js.map +1 -0
- package/dist/chunk-ZJXNLPER.js +34 -0
- package/dist/chunk-ZJXNLPER.js.map +1 -0
- package/dist/client-request.d.ts +84 -0
- package/dist/client-request.js +32 -0
- package/dist/client-request.js.map +1 -0
- package/dist/close.d.ts +47 -0
- package/dist/close.js +20 -0
- package/dist/close.js.map +1 -0
- package/dist/closest.d.ts +10 -0
- package/dist/closest.js +9 -0
- package/dist/closest.js.map +1 -0
- package/dist/document-signoff.d.ts +88 -0
- package/dist/document-signoff.js +18 -0
- package/dist/document-signoff.js.map +1 -0
- package/dist/expense.d.ts +124 -0
- package/dist/expense.js +42 -0
- package/dist/expense.js.map +1 -0
- package/dist/financial-date.d.ts +23 -0
- package/dist/financial-date.js +23 -0
- package/dist/financial-date.js.map +1 -0
- package/dist/findings.d.ts +115 -0
- package/dist/findings.js +40 -0
- package/dist/findings.js.map +1 -0
- package/dist/fixed-assets.d.ts +117 -0
- package/dist/fixed-assets.js +31 -0
- package/dist/fixed-assets.js.map +1 -0
- package/dist/funnel.d.ts +38 -0
- package/dist/funnel.js +10 -0
- package/dist/funnel.js.map +1 -0
- package/dist/fx.d.ts +62 -0
- package/dist/fx.js +17 -0
- package/dist/fx.js.map +1 -0
- package/dist/iban.d.ts +6 -0
- package/dist/iban.js +14 -0
- package/dist/iban.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +747 -0
- package/dist/index.js.map +1 -0
- package/dist/invoice.d.ts +83 -0
- package/dist/invoice.js +26 -0
- package/dist/invoice.js.map +1 -0
- package/dist/kid.d.ts +9 -0
- package/dist/kid.js +18 -0
- package/dist/kid.js.map +1 -0
- package/dist/kontonummer.d.ts +7 -0
- package/dist/kontonummer.js +15 -0
- package/dist/kontonummer.js.map +1 -0
- package/dist/ledger.d.ts +136 -0
- package/dist/ledger.js +22 -0
- package/dist/ledger.js.map +1 -0
- package/dist/locale/index.d.ts +178 -0
- package/dist/locale/index.js +24 -0
- package/dist/locale/index.js.map +1 -0
- package/dist/messages.d.ts +37 -0
- package/dist/messages.js +19 -0
- package/dist/messages.js.map +1 -0
- package/dist/money.d.ts +87 -0
- package/dist/money.js +34 -0
- package/dist/money.js.map +1 -0
- package/dist/msg.d.ts +663 -0
- package/dist/msg.js +15 -0
- package/dist/msg.js.map +1 -0
- package/dist/organization-number.d.ts +28 -0
- package/dist/organization-number.js +24 -0
- package/dist/organization-number.js.map +1 -0
- package/dist/payment-batch.d.ts +57 -0
- package/dist/payment-batch.js +24 -0
- package/dist/payment-batch.js.map +1 -0
- package/dist/period-lock.d.ts +31 -0
- package/dist/period-lock.js +14 -0
- package/dist/period-lock.js.map +1 -0
- package/dist/period.d.ts +28 -0
- package/dist/period.js +22 -0
- package/dist/period.js.map +1 -0
- package/dist/permissions.d.ts +71 -0
- package/dist/permissions.js +20 -0
- package/dist/permissions.js.map +1 -0
- package/dist/pipeline.d.ts +187 -0
- package/dist/pipeline.js +44 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/reconciliation.d.ts +69 -0
- package/dist/reconciliation.js +16 -0
- package/dist/reconciliation.js.map +1 -0
- package/dist/recurring.d.ts +81 -0
- package/dist/recurring.js +30 -0
- package/dist/recurring.js.map +1 -0
- package/dist/routing-number.d.ts +6 -0
- package/dist/routing-number.js +14 -0
- package/dist/routing-number.js.map +1 -0
- package/dist/server.d.ts +276 -0
- package/dist/server.js +372 -0
- package/dist/server.js.map +1 -0
- package/dist/sheet-stack.d.ts +96 -0
- package/dist/sheet-stack.js +13 -0
- package/dist/sheet-stack.js.map +1 -0
- package/dist/supplier-invoice.d.ts +115 -0
- package/dist/supplier-invoice.js +34 -0
- package/dist/supplier-invoice.js.map +1 -0
- package/dist/table.d.ts +78 -0
- package/dist/table.js +20 -0
- package/dist/table.js.map +1 -0
- package/dist/vat-return.d.ts +114 -0
- package/dist/vat-return.js +28 -0
- package/dist/vat-return.js.map +1 -0
- package/dist/voucher.d.ts +211 -0
- package/dist/voucher.js +58 -0
- package/dist/voucher.js.map +1 -0
- package/package.json +207 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @booki/core
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#93](https://github.com/Walgermo/booki/pull/93) [`ec89785`](https://github.com/Walgermo/booki/commit/ec8978566d2a81ee14eb94cc5163a2490ea824a9) Thanks [@Walgermo](https://github.com/Walgermo)! - The packages are now named `@booki-aui/*` and are published to npm (the `@booki` scope on npm belongs to someone else). Install with `pnpm add @booki-aui/core @booki-aui/react @booki-aui/styles`, and replace `@booki/` with `@booki-aui/` in your imports, for example `import { createBookiAgent } from "@booki-aui/react"` and `import "@booki-aui/styles"`. Nothing else changed.
|
|
8
|
+
|
|
9
|
+
## 0.1.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#83](https://github.com/Walgermo/booki/pull/83) [`3fe7338`](https://github.com/Walgermo/booki/commit/3fe7338a650bbc8a6c900693bc8f93abba937a0a) Thanks [@Walgermo](https://github.com/Walgermo)! - An `act` call without `steps`, like `{ "step": [] }` from a model that got the shape wrong, now comes back with ui-sdk's sentence (`act takes { "steps": [...] }, not …`) instead of throwing a TypeError. Through WebMCP the model used to get only "Tool execution failed". With `language: "nb"`, ui-sdk's sentences about a call in the wrong shape (no `steps`, a field `act` doesn't take, a step without a ref, an action or a value) come back in Norwegian.
|
|
14
|
+
|
|
15
|
+
## 0.1.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#80](https://github.com/Walgermo/booki/pull/80) [`1054c6e`](https://github.com/Walgermo/booki/commit/1054c6e79f3418e1fb9560beea50b7b027f82bff) Thanks [@Walgermo](https://github.com/Walgermo)! - Booki and the bridge features of ui-sdk beta.17, lined up:
|
|
20
|
+
|
|
21
|
+
- **The bridge's new sentences in Norwegian.** With `createBookiAgent({ language: "nb" })`, a `set` step that didn't take ("tok ikke: verdien er fortsatt …"), one that landed on another value, a failed `expect`, and a number outside min and max now come back in Norwegian like the rest of the bridge's sentences.
|
|
22
|
+
- **A failed `expect` writes no audit row.** `actAndRecord` recorded it as `agent.failed`, but a check changes nothing and refuses nothing. A refused change is still recorded.
|
|
23
|
+
- **Long lists page with `from`.** The `itemsHint` of `AccountPicker`, `CurrencySelect`, `TaxCodeSelect` and `useBookiFieldCode` says that `query({ within, from: 50 })` reads the next 50, next to the bridge's own `more` count.
|
|
24
|
+
- **Docs.** The skill and the catalog show `expect` before a save, which components it works on (fields with a value, not record components), and what "didn't take" means for a controlled field.
|
|
25
|
+
|
|
26
|
+
## 0.1.5
|
|
27
|
+
|
|
28
|
+
No changes in this release.
|
|
29
|
+
|
|
30
|
+
## 0.1.4
|
|
31
|
+
|
|
32
|
+
No changes in this release.
|
|
33
|
+
|
|
34
|
+
## 0.1.3
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- [#69](https://github.com/Walgermo/booki/pull/69) [`85bde56`](https://github.com/Walgermo/booki/commit/85bde56ab298f00f1b08e326bb26610457d416f8) Thanks [@Walgermo](https://github.com/Walgermo)! - Four sales reports. `FunnelChart`: how many records reached each step, the conversion from the step before and from the first, the drop-off and the biggest drop; a step that rises is reported. `ForecastChart`: won, committed, best case and weighted revenue per month or quarter, from the same deals and stages as `DealPipeline`, naming the deals it leaves out (no close date, no amount or one without a source, another currency). `RecurringRevenue`: opening, new, expansion, contraction, churn and closing between two dates, as MRR or ARR; agreements billed per month, quarter or year are summed exactly per year, and the monthly view says what rounding moved. `StageDurationChart`: median and longest days per stage, a target per stage, and the deals over it. Rules in `@booki/core/funnel`, `@booki/core/recurring` and `forecastByPeriod` / `timeInStage` in `@booki/core/pipeline`. The catalog has recipes for win rate, a leaderboard, MRR over time, and working without stage history.
|
|
39
|
+
|
|
40
|
+
## 0.1.2
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- [#67](https://github.com/Walgermo/booki/pull/67) [`d7816ae`](https://github.com/Walgermo/booki/commit/d7816ae204780a08b4b1097699e57aaf47002626) Thanks [@Walgermo](https://github.com/Walgermo)! - `useBookiField` with `kind: "code"` takes `personOnly`: values only a person may choose, such as a deal's won and lost stages in a stage select the product already has. An agent's `setCode` to one of them is refused with a sentence that names it; a person's change, which passes its DOM event, goes through; the snapshot lists them.
|
|
45
|
+
|
|
46
|
+
`CurrencySelect` names its trigger in the person's language ("Valuta" on a Norwegian screen) and takes a `label` option, like the other pickers.
|
|
47
|
+
|
|
48
|
+
## 0.1.1
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- [#65](https://github.com/Walgermo/booki/pull/65) [`201f7c9`](https://github.com/Walgermo/booki/commit/201f7c9d1aa843ab3a7c75ebbeb87df831110c08) Thanks [@Walgermo](https://github.com/Walgermo)! - Two controls for sales and customer work. `DealPipeline` is a board of deals in stages with each stage's totals per currency and a weighted forecast: an agent moves open deals, records a value with its source (`setValue`), and sets the expected close date and the owner; a value without a source is shown and never summed; marking a deal won or lost, and reopening it, are a person's buttons. `ActivityTimeline` is a customer's history and next steps: an agent logs calls, emails, meetings and notes, and schedules, reschedules and completes tasks, each recorded as the agent's; removing an entry is a person's. Rules in `@booki/core/pipeline` and `@booki/core/activity`, the `deal.close` and `activity.remove` permissions, a `sales` starter role, and `guardCloseDeal` for the server. `deal.close` is a person's decision: `PERSON_ONLY` and the readiness check now list it.
|
|
53
|
+
|
|
54
|
+
## 0.1.0
|
|
55
|
+
|
|
56
|
+
The first release. It is not on npm: Booki is published once v1 has run in a real
|
|
57
|
+
product. Install it from a clone with `pnpm pack:local` (the install guide in
|
|
58
|
+
`skills/booki/SKILL.md` has the steps), with `@ui-sdk/core` and `@ui-sdk/react` at
|
|
59
|
+
exactly `0.1.0-beta.16`.
|
|
60
|
+
|
|
61
|
+
- **Supported:** React 19 (`@booki/react` with `@booki/core`, `@booki/primitives` and
|
|
62
|
+
`@booki/styles`), and the Norway (NO) and United States (US) country profiles.
|
|
63
|
+
- **Experimental:** Vue, Svelte, Solid and Web Components (`@booki/vue`,
|
|
64
|
+
`@booki/svelte`, `@booki/solid`, `@booki/web`), generated from the same primitives,
|
|
65
|
+
and the SE, DK, GB and DE starter profiles.
|
|
66
|
+
- Accounting and audit controls an agent operates by name through the ui-sdk bridge:
|
|
67
|
+
amounts in minor units, vouchers that must balance, bank account, IBAN and KID
|
|
68
|
+
redacted from the snapshot, periods, VAT, invoices, payment batches, reconciliation,
|
|
69
|
+
approvals, close, findings and workpapers. `useBookiField` gives a field you keep
|
|
70
|
+
Booki's agent action and rules.
|
|
71
|
+
- Approving, signing off, finalizing and releasing are a person's: never an agent
|
|
72
|
+
action, refused by `createBookiAgent` whatever the app allows, and by the server
|
|
73
|
+
guards in `@booki/core/server` (`PERSON_ONLY`). `data-agent-confirm` steps wait for
|
|
74
|
+
the person; `attachAudit` and `actAndRecord` record what the agent did, what it was
|
|
75
|
+
refused and who decided.
|
|
76
|
+
- Refusals, the bridge's own sentences and the agent cursor in English and Norwegian
|
|
77
|
+
(`createBookiAgent({ language: "nb" })`).
|
|
78
|
+
- Fixed in seven rounds of a product pilot in a real app, from the install guide.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stian Walgermo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @booki-aui/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Framework-free accounting rules for Booki: integer money, voucher lines with VAT codes and dimensions, bank reconciliation, and validators for Norwegian and US identifiers (kontonummer, KID, organisasjonsnummer, IBAN, ABA routing, EIN).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { parseToMinor, voucherIssues, validateMatch } from "@booki-aui/core"
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Every amount is an integer in minor units. Every rule either passes or throws an error that names what was wrong and what is allowed, so a person or an agent can repair it.
|
|
10
|
+
|
|
11
|
+
Country profiles: Norway and the United States are supported; Sweden, Denmark, the United Kingdom and Germany are experimental starter profiles.
|
|
12
|
+
|
|
13
|
+
Docs and source: https://github.com/Walgermo/booki
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What happened with a customer, and what is to be done next: calls, emails,
|
|
3
|
+
* meetings and notes that are logged, and tasks with a due date. An agent may
|
|
4
|
+
* log what happened, schedule and complete tasks; removing an entry is a
|
|
5
|
+
* person's. Logging an email records one that was sent or received; sending
|
|
6
|
+
* it is not this control's.
|
|
7
|
+
*
|
|
8
|
+
* A call or meeting may carry `evidence`: where it can be checked (a calendar
|
|
9
|
+
* event, a call log line, minutes). One without it is still logged, and the
|
|
10
|
+
* timeline says it has nothing to check it against.
|
|
11
|
+
*/
|
|
12
|
+
type ActivityKind = "call" | "email" | "meeting" | "note" | "task";
|
|
13
|
+
declare const ACTIVITY_KINDS: readonly ActivityKind[];
|
|
14
|
+
/** The kinds `logActivity` takes: what already happened. A task is scheduled. */
|
|
15
|
+
declare const LOGGED_KINDS: readonly ActivityKind[];
|
|
16
|
+
type Activity = {
|
|
17
|
+
id: string;
|
|
18
|
+
kind: ActivityKind;
|
|
19
|
+
subject: string;
|
|
20
|
+
body?: string;
|
|
21
|
+
/** When it happened (logged) or was created (task): an ISO timestamp, or YYYY-MM-DD when only the day is known. */
|
|
22
|
+
at: string;
|
|
23
|
+
/** Who logged or scheduled it. */
|
|
24
|
+
by: string;
|
|
25
|
+
/** Where a call or meeting can be checked: a calendar event, a call log line, minutes. */
|
|
26
|
+
evidence?: string;
|
|
27
|
+
/** A task's due date, YYYY-MM-DD. */
|
|
28
|
+
dueDate?: string;
|
|
29
|
+
/** Whom a task is for. */
|
|
30
|
+
assigneeId?: string;
|
|
31
|
+
/** When a task was done, ISO. */
|
|
32
|
+
doneAt?: string;
|
|
33
|
+
doneBy?: string;
|
|
34
|
+
};
|
|
35
|
+
type NewLoggedActivity = {
|
|
36
|
+
id: string;
|
|
37
|
+
kind: ActivityKind;
|
|
38
|
+
subject: string;
|
|
39
|
+
body?: string;
|
|
40
|
+
at: string;
|
|
41
|
+
evidence?: string;
|
|
42
|
+
};
|
|
43
|
+
type NewTask = {
|
|
44
|
+
id: string;
|
|
45
|
+
subject: string;
|
|
46
|
+
dueDate: string;
|
|
47
|
+
body?: string;
|
|
48
|
+
assigneeId?: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Log something that happened. `now` is the current ISO time: an entry dated
|
|
52
|
+
* after it is refused, since what is still to come is a task.
|
|
53
|
+
*/
|
|
54
|
+
declare function logActivity(input: NewLoggedActivity, by: string, now: string): Activity;
|
|
55
|
+
/** Schedule a task for later. */
|
|
56
|
+
declare function scheduleTask(input: NewTask, by: string, at: string): Activity;
|
|
57
|
+
/** Mark an open task done. */
|
|
58
|
+
declare function completeTask(activity: Activity, by: string, at: string): Activity;
|
|
59
|
+
/** Give an open task a new due date. */
|
|
60
|
+
declare function rescheduleTask(activity: Activity, date: string): Activity;
|
|
61
|
+
/** Newest first: by `at`, a day-only entry counting as the start of its day. */
|
|
62
|
+
declare function timeline(activities: readonly Activity[]): Activity[];
|
|
63
|
+
/** Open tasks, the earliest due first. */
|
|
64
|
+
declare function openTasks(activities: readonly Activity[]): Activity[];
|
|
65
|
+
/** Ids of open tasks due before `today` (YYYY-MM-DD). */
|
|
66
|
+
declare function overdueTasks(activities: readonly Activity[], today: string): string[];
|
|
67
|
+
/** The last call, email or meeting, or undefined when there has been none. */
|
|
68
|
+
declare function lastTouch(activities: readonly Activity[]): Activity | undefined;
|
|
69
|
+
/** What a person should know about an entry, as sentences. Warnings, never refusals. */
|
|
70
|
+
declare function activityIssues(activity: Activity, today: string): string[];
|
|
71
|
+
/** The entry with this id, or a refusal listing the ones there are. */
|
|
72
|
+
declare function findActivity(activities: readonly Activity[], id: unknown): Activity;
|
|
73
|
+
|
|
74
|
+
export { ACTIVITY_KINDS, type Activity, type ActivityKind, LOGGED_KINDS, type NewLoggedActivity, type NewTask, activityIssues, completeTask, findActivity, lastTouch, logActivity, openTasks, overdueTasks, rescheduleTask, scheduleTask, timeline };
|
package/dist/activity.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACTIVITY_KINDS,
|
|
3
|
+
LOGGED_KINDS,
|
|
4
|
+
activityIssues,
|
|
5
|
+
completeTask,
|
|
6
|
+
findActivity,
|
|
7
|
+
lastTouch,
|
|
8
|
+
logActivity,
|
|
9
|
+
openTasks,
|
|
10
|
+
overdueTasks,
|
|
11
|
+
rescheduleTask,
|
|
12
|
+
scheduleTask,
|
|
13
|
+
timeline
|
|
14
|
+
} from "./chunk-XXMOQEIG.js";
|
|
15
|
+
import "./chunk-U5T5SUPP.js";
|
|
16
|
+
export {
|
|
17
|
+
ACTIVITY_KINDS,
|
|
18
|
+
LOGGED_KINDS,
|
|
19
|
+
activityIssues,
|
|
20
|
+
completeTask,
|
|
21
|
+
findActivity,
|
|
22
|
+
lastTouch,
|
|
23
|
+
logActivity,
|
|
24
|
+
openTasks,
|
|
25
|
+
overdueTasks,
|
|
26
|
+
rescheduleTask,
|
|
27
|
+
scheduleTask,
|
|
28
|
+
timeline
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=activity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/aging.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
type OpenItemKind = "receivable" | "payable";
|
|
2
|
+
/** An invoice or credit note that is not fully settled. */
|
|
3
|
+
type OpenItem = {
|
|
4
|
+
id: string;
|
|
5
|
+
partyId: string;
|
|
6
|
+
partyName: string;
|
|
7
|
+
documentNumber: string;
|
|
8
|
+
/** ISO date, YYYY-MM-DD. */
|
|
9
|
+
dueDate: string;
|
|
10
|
+
/** What remains, in minor units. Negative for a credit, which reduces the party's total. */
|
|
11
|
+
amountMinor: number;
|
|
12
|
+
kind: OpenItemKind;
|
|
13
|
+
};
|
|
14
|
+
/** A column of the aging table. Days are whole calendar days past the due date. */
|
|
15
|
+
type AgingBucket = {
|
|
16
|
+
/** `not-due`, `1-30`, `31-60`, `61-90`, `over-90` for the default limits. */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Lowest number of days overdue in the bucket. Missing for the first bucket. */
|
|
19
|
+
fromDays?: number;
|
|
20
|
+
/** Highest number of days overdue in the bucket. Missing for the last bucket. */
|
|
21
|
+
toDays?: number;
|
|
22
|
+
};
|
|
23
|
+
type AgingRow = {
|
|
24
|
+
partyId: string;
|
|
25
|
+
partyName: string;
|
|
26
|
+
/** One amount per bucket, in the order of `buckets`. */
|
|
27
|
+
amountsMinor: number[];
|
|
28
|
+
totalMinor: number;
|
|
29
|
+
itemCount: number;
|
|
30
|
+
};
|
|
31
|
+
type AgingReport = {
|
|
32
|
+
kind: OpenItemKind;
|
|
33
|
+
asOf: string;
|
|
34
|
+
buckets: AgingBucket[];
|
|
35
|
+
/** Sorted by party name. */
|
|
36
|
+
rows: AgingRow[];
|
|
37
|
+
/** One total per bucket. */
|
|
38
|
+
totalsMinor: number[];
|
|
39
|
+
grandTotalMinor: number;
|
|
40
|
+
};
|
|
41
|
+
type AgedItem = OpenItem & {
|
|
42
|
+
/** Whole days past due on the as-of date. Zero or below when not yet due. */
|
|
43
|
+
daysOverdue: number;
|
|
44
|
+
bucket: string;
|
|
45
|
+
};
|
|
46
|
+
type OverdueParty = {
|
|
47
|
+
partyId: string;
|
|
48
|
+
partyName: string;
|
|
49
|
+
/** Sum of the items overdue by at least the asked number of days, credits included. */
|
|
50
|
+
overdueMinor: number;
|
|
51
|
+
/** Days overdue of the oldest such item. */
|
|
52
|
+
oldestDays: number;
|
|
53
|
+
itemCount: number;
|
|
54
|
+
};
|
|
55
|
+
declare const DEFAULT_AGING_LIMITS: readonly number[];
|
|
56
|
+
/** Whole calendar days from the due date to the as-of date, counted in UTC. Negative before the due date. */
|
|
57
|
+
declare function daysOverdue(dueDate: string, asOf: string): number;
|
|
58
|
+
/**
|
|
59
|
+
* The buckets for a list of limits. `[0, 30, 60, 90]` gives not due, 1–30,
|
|
60
|
+
* 31–60, 61–90 and over 90. The first limit must be 0 and the rest must rise.
|
|
61
|
+
*/
|
|
62
|
+
declare function agingBuckets(limits?: readonly number[]): AgingBucket[];
|
|
63
|
+
/**
|
|
64
|
+
* The aging table: per party, what is open in each bucket on the as-of date.
|
|
65
|
+
* A credit lands in the bucket of its own due date and reduces the party's
|
|
66
|
+
* total. Pass `kind` when the items hold both receivables and payables.
|
|
67
|
+
*/
|
|
68
|
+
declare function ageItems(items: OpenItem[], asOf: string, buckets?: readonly number[], kind?: OpenItemKind): AgingReport;
|
|
69
|
+
/**
|
|
70
|
+
* One party's open items with their days overdue and bucket, oldest due date
|
|
71
|
+
* first. Give `bucket` (an id such as `31-60`) to list only that column.
|
|
72
|
+
*/
|
|
73
|
+
declare function partyItems(items: OpenItem[], asOf: string, partyId: string, options?: {
|
|
74
|
+
bucket?: string;
|
|
75
|
+
buckets?: readonly number[];
|
|
76
|
+
kind?: OpenItemKind;
|
|
77
|
+
}): AgedItem[];
|
|
78
|
+
/**
|
|
79
|
+
* Parties with something overdue by at least `minDays` days, largest amount
|
|
80
|
+
* first. Credits that old count against the party; a party whose overdue items
|
|
81
|
+
* net to zero or less is left out.
|
|
82
|
+
*/
|
|
83
|
+
declare function overdueParties(items: OpenItem[], asOf: string, minDays?: number, kind?: OpenItemKind): OverdueParty[];
|
|
84
|
+
|
|
85
|
+
export { type AgedItem, type AgingBucket, type AgingReport, type AgingRow, DEFAULT_AGING_LIMITS, type OpenItem, type OpenItemKind, type OverdueParty, ageItems, agingBuckets, daysOverdue, overdueParties, partyItems };
|
package/dist/aging.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_AGING_LIMITS,
|
|
3
|
+
ageItems,
|
|
4
|
+
agingBuckets,
|
|
5
|
+
daysOverdue,
|
|
6
|
+
overdueParties,
|
|
7
|
+
partyItems
|
|
8
|
+
} from "./chunk-3WGVKVPL.js";
|
|
9
|
+
import "./chunk-U5T5SUPP.js";
|
|
10
|
+
export {
|
|
11
|
+
DEFAULT_AGING_LIMITS,
|
|
12
|
+
ageItems,
|
|
13
|
+
agingBuckets,
|
|
14
|
+
daysOverdue,
|
|
15
|
+
overdueParties,
|
|
16
|
+
partyItems
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=aging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Someone who may approve at a level. */
|
|
2
|
+
type Approver = {
|
|
3
|
+
id: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
/** Largest amount this person may approve, in minor units. Omit for no limit. */
|
|
6
|
+
limitMinor?: number;
|
|
7
|
+
/** Who may decide in this person's place, for example while they are away. */
|
|
8
|
+
substituteId?: string;
|
|
9
|
+
};
|
|
10
|
+
/** One step in an approval chain. Levels are decided in order. */
|
|
11
|
+
type ApprovalLevel = {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
approvers: Approver[];
|
|
15
|
+
/** The level only applies at or above this amount. Omit to always apply. */
|
|
16
|
+
fromMinor?: number;
|
|
17
|
+
/** Who the level goes to when it is escalated. */
|
|
18
|
+
escalateTo?: Approver;
|
|
19
|
+
};
|
|
20
|
+
type ApprovalDecision = {
|
|
21
|
+
levelId: string;
|
|
22
|
+
/** The person who actually decided. */
|
|
23
|
+
approverId: string;
|
|
24
|
+
/** Set when a substitute decided for someone else. */
|
|
25
|
+
onBehalfOf?: string;
|
|
26
|
+
decision: "approved" | "rejected" | "escalated";
|
|
27
|
+
/** ISO timestamp. */
|
|
28
|
+
at: string;
|
|
29
|
+
note?: string;
|
|
30
|
+
};
|
|
31
|
+
/** The thing waiting for approval: a voucher, an invoice, a payment batch. */
|
|
32
|
+
type ApprovalRequest = {
|
|
33
|
+
id: string;
|
|
34
|
+
/** Absolute amount in minor units. Limits are checked against it. */
|
|
35
|
+
amountMinor: number;
|
|
36
|
+
/** Who asked. They can never approve their own request. */
|
|
37
|
+
requesterId: string;
|
|
38
|
+
/**
|
|
39
|
+
* When an agent raised the request: the person whose session it ran in
|
|
40
|
+
* (`onBehalfOf`). They may not decide it either.
|
|
41
|
+
*/
|
|
42
|
+
requestedFor?: string;
|
|
43
|
+
decisions: ApprovalDecision[];
|
|
44
|
+
};
|
|
45
|
+
type ApprovalStatus = "pending" | "approved" | "rejected";
|
|
46
|
+
type ApprovalState = {
|
|
47
|
+
status: ApprovalStatus;
|
|
48
|
+
/** Levels that apply to this amount, in order. */
|
|
49
|
+
levels: ApprovalLevel[];
|
|
50
|
+
/** The level waiting for a decision. Undefined once approved or rejected. */
|
|
51
|
+
current?: ApprovalLevel;
|
|
52
|
+
/** True when the current level was escalated. */
|
|
53
|
+
escalated: boolean;
|
|
54
|
+
/** Ids of the people who may decide the current level right now. */
|
|
55
|
+
mayDecide: string[];
|
|
56
|
+
/** The item must not be edited while a request is pending or approved. */
|
|
57
|
+
locked: boolean;
|
|
58
|
+
};
|
|
59
|
+
/** The levels of a chain that apply to an amount. */
|
|
60
|
+
declare function requiredLevels(chain: ApprovalLevel[], amountMinor: number): ApprovalLevel[];
|
|
61
|
+
/** Where a request stands in its chain. */
|
|
62
|
+
declare function approvalState(chain: ApprovalLevel[], request: ApprovalRequest): ApprovalState;
|
|
63
|
+
/**
|
|
64
|
+
* Record one person's decision and return the updated request. Throws, with a
|
|
65
|
+
* sentence that says why, when that person may not decide: they asked for it
|
|
66
|
+
* themselves, it is not their level, their limit is too low, or they already
|
|
67
|
+
* approved an earlier level.
|
|
68
|
+
*/
|
|
69
|
+
declare function decide(chain: ApprovalLevel[], request: ApprovalRequest, input: {
|
|
70
|
+
approverId: string;
|
|
71
|
+
decision: ApprovalDecision["decision"];
|
|
72
|
+
at: string;
|
|
73
|
+
note?: string;
|
|
74
|
+
}): ApprovalRequest;
|
|
75
|
+
/** Throws unless every required level has approved. */
|
|
76
|
+
declare function assertApproved(chain: ApprovalLevel[], request: ApprovalRequest): ApprovalState;
|
|
77
|
+
|
|
78
|
+
export { type ApprovalDecision, type ApprovalLevel, type ApprovalRequest, type ApprovalState, type ApprovalStatus, type Approver, approvalState, assertApproved, decide, requiredLevels };
|
package/dist/approval.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
approvalState,
|
|
3
|
+
assertApproved,
|
|
4
|
+
decide,
|
|
5
|
+
requiredLevels
|
|
6
|
+
} from "./chunk-2H3DAON4.js";
|
|
7
|
+
import "./chunk-U5T5SUPP.js";
|
|
8
|
+
export {
|
|
9
|
+
approvalState,
|
|
10
|
+
assertApproved,
|
|
11
|
+
decide,
|
|
12
|
+
requiredLevels
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=approval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** What a piece of evidence is. */
|
|
2
|
+
declare const ATTACHMENT_KINDS: readonly ["invoice", "receipt", "contract", "bank-statement", "other"];
|
|
3
|
+
type AttachmentKind = (typeof ATTACHMENT_KINDS)[number];
|
|
4
|
+
/** Where in the file the evidence is. */
|
|
5
|
+
type AttachmentRegion = {
|
|
6
|
+
/** Page number, starting at 1. */
|
|
7
|
+
page?: number;
|
|
8
|
+
/** A box on the page as [x, y, width, height] in thousandths of the page (0 to 1000). */
|
|
9
|
+
box?: [number, number, number, number];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A file the host knows about. This module never reads or uploads file bytes:
|
|
13
|
+
* the host supplies the metadata, including the SHA-256 hash.
|
|
14
|
+
*/
|
|
15
|
+
type AttachmentFile = {
|
|
16
|
+
id: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
/** IANA media type, e.g. "application/pdf". */
|
|
19
|
+
mediaType: string;
|
|
20
|
+
/** Size in whole bytes. */
|
|
21
|
+
sizeBytes: number;
|
|
22
|
+
/** SHA-256 of the file as 64 hex characters. */
|
|
23
|
+
sha256: string;
|
|
24
|
+
/** What the host thinks it is. Used when linking without a kind. */
|
|
25
|
+
kind?: AttachmentKind;
|
|
26
|
+
region?: AttachmentRegion;
|
|
27
|
+
};
|
|
28
|
+
/** A file linked to an entry (voucher, invoice, claim) as evidence. */
|
|
29
|
+
type Attachment = Omit<AttachmentFile, "kind"> & {
|
|
30
|
+
kind: AttachmentKind;
|
|
31
|
+
/** Who linked it. */
|
|
32
|
+
addedBy: string;
|
|
33
|
+
/** ISO timestamp. */
|
|
34
|
+
addedAt: string;
|
|
35
|
+
};
|
|
36
|
+
/** Throws unless `kind` is one of the attachment kinds. */
|
|
37
|
+
declare function checkAttachmentKind(kind: unknown): AttachmentKind;
|
|
38
|
+
/** Throws unless the file's metadata is complete and well formed. */
|
|
39
|
+
declare function validateAttachmentFile<T extends AttachmentFile>(file: T): T;
|
|
40
|
+
/** Groups of attachments on the entry that are the same file (same hash). */
|
|
41
|
+
declare function duplicateAttachments(attachments: Attachment[]): Attachment[][];
|
|
42
|
+
/**
|
|
43
|
+
* Link a file to the entry. Refused when the id is already linked or a linked
|
|
44
|
+
* attachment has the same hash (the same file twice). Allowed on a locked
|
|
45
|
+
* entry: evidence can be added, never taken away.
|
|
46
|
+
*/
|
|
47
|
+
declare function linkAttachment(attachments: Attachment[], file: AttachmentFile, kind: AttachmentKind | undefined, addedBy: string, addedAt: string): Attachment[];
|
|
48
|
+
/** Change what a linked attachment is. Refused on a locked entry. */
|
|
49
|
+
declare function setAttachmentKind(attachments: Attachment[], id: string, kind: AttachmentKind, locked?: boolean): Attachment[];
|
|
50
|
+
/** Unlink an attachment. Refused on a locked entry. */
|
|
51
|
+
declare function removeAttachment(attachments: Attachment[], id: string, locked?: boolean): Attachment[];
|
|
52
|
+
/** Required kinds that no linked attachment has. */
|
|
53
|
+
declare function missingKinds(attachments: Attachment[], requires?: readonly AttachmentKind[]): AttachmentKind[];
|
|
54
|
+
/** True when every required kind is present. */
|
|
55
|
+
declare function isEvidenced(attachments: Attachment[], requires?: readonly AttachmentKind[]): boolean;
|
|
56
|
+
/** Throws naming the kinds of evidence that are still missing. */
|
|
57
|
+
declare function assertEvidenced(attachments: Attachment[], requires?: readonly AttachmentKind[]): void;
|
|
58
|
+
|
|
59
|
+
export { ATTACHMENT_KINDS, type Attachment, type AttachmentFile, type AttachmentKind, type AttachmentRegion, assertEvidenced, checkAttachmentKind, duplicateAttachments, isEvidenced, linkAttachment, missingKinds, removeAttachment, setAttachmentKind, validateAttachmentFile };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ATTACHMENT_KINDS,
|
|
3
|
+
assertEvidenced,
|
|
4
|
+
checkAttachmentKind,
|
|
5
|
+
duplicateAttachments,
|
|
6
|
+
isEvidenced,
|
|
7
|
+
linkAttachment,
|
|
8
|
+
missingKinds,
|
|
9
|
+
removeAttachment,
|
|
10
|
+
setAttachmentKind,
|
|
11
|
+
validateAttachmentFile
|
|
12
|
+
} from "./chunk-N77E7ZP7.js";
|
|
13
|
+
import "./chunk-U5T5SUPP.js";
|
|
14
|
+
export {
|
|
15
|
+
ATTACHMENT_KINDS,
|
|
16
|
+
assertEvidenced,
|
|
17
|
+
checkAttachmentKind,
|
|
18
|
+
duplicateAttachments,
|
|
19
|
+
isEvidenced,
|
|
20
|
+
linkAttachment,
|
|
21
|
+
missingKinds,
|
|
22
|
+
removeAttachment,
|
|
23
|
+
setAttachmentKind,
|
|
24
|
+
validateAttachmentFile
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|