@alfadocs/ui-kit-debug 1.118.0 → 1.119.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/bill-line-table-DUMEHnQ4.js +1754 -0
- package/dist/_chunks/bill-line-table-DUMEHnQ4.js.map +1 -0
- package/dist/_chunks/{calendar-appointment-editor-dialog-BEmBcb61.js → calendar-appointment-editor-dialog-rw02sXGw.js} +4 -4
- package/dist/_chunks/{calendar-appointment-editor-dialog-BEmBcb61.js.map → calendar-appointment-editor-dialog-rw02sXGw.js.map} +1 -1
- package/dist/_chunks/{compact-editor-fields-6sTWRLtf.js → compact-editor-fields-cP6yh7xv.js} +3 -3
- package/dist/_chunks/{compact-editor-fields-6sTWRLtf.js.map → compact-editor-fields-cP6yh7xv.js.map} +1 -1
- package/dist/_chunks/counts-BXtzNv_G.js +92 -0
- package/dist/_chunks/counts-BXtzNv_G.js.map +1 -0
- package/dist/_chunks/{data-grid-DiBSbN2Y.js → data-grid-Bbf8t4z3.js} +2 -2
- package/dist/_chunks/{data-grid-DiBSbN2Y.js.map → data-grid-Bbf8t4z3.js.map} +1 -1
- package/dist/_chunks/{default-tabs-CD285u0C.js → default-tabs-Cxkw1Ws0.js} +332 -368
- package/dist/_chunks/default-tabs-Cxkw1Ws0.js.map +1 -0
- package/dist/_chunks/{document-scanner-5p-Uu8dy.js → document-scanner-CETscDea.js} +2 -2
- package/dist/_chunks/{document-scanner-5p-Uu8dy.js.map → document-scanner-CETscDea.js.map} +1 -1
- package/dist/_chunks/file-code-Cf-_gSzd.js +23 -0
- package/dist/_chunks/file-code-Cf-_gSzd.js.map +1 -0
- package/dist/_chunks/{file-manager-CV1_GtjC.js → file-manager-DNq-sEsy.js} +2 -2
- package/dist/_chunks/{file-manager-CV1_GtjC.js.map → file-manager-DNq-sEsy.js.map} +1 -1
- package/dist/_chunks/{file-upload-CxjCs7TX.js → file-upload-DQc0LsBM.js} +385 -311
- package/dist/_chunks/file-upload-DQc0LsBM.js.map +1 -0
- package/dist/_chunks/invoice-upload-list-CsFsRgbt.js +952 -0
- package/dist/_chunks/invoice-upload-list-CsFsRgbt.js.map +1 -0
- package/dist/_chunks/maps-MpMxTBov.js +63 -0
- package/dist/_chunks/maps-MpMxTBov.js.map +1 -0
- package/dist/_chunks/{notes-panel-CHR-Jv6N.js → notes-panel-BOwlTz2-.js} +2 -2
- package/dist/_chunks/{notes-panel-CHR-Jv6N.js.map → notes-panel-BOwlTz2-.js.map} +1 -1
- package/dist/_chunks/package-plus-CTecQK3x.js +25 -0
- package/dist/_chunks/package-plus-CTecQK3x.js.map +1 -0
- package/dist/_chunks/{public-footer-CB7ruuLI.js → public-footer-C8UIzqLJ.js} +326 -243
- package/dist/_chunks/public-footer-C8UIzqLJ.js.map +1 -0
- package/dist/_chunks/{radiograph-panel.agent-9jwXlOXB.js → radiograph-panel.agent-Dcv16n7u.js} +2 -2
- package/dist/_chunks/{radiograph-panel.agent-9jwXlOXB.js.map → radiograph-panel.agent-Dcv16n7u.js.map} +1 -1
- package/dist/_chunks/{rich-text-editor-CMPA5Wgy.js → rich-text-editor-BLEdXJ0l.js} +2 -2
- package/dist/_chunks/{rich-text-editor-CMPA5Wgy.js.map → rich-text-editor-BLEdXJ0l.js.map} +1 -1
- package/dist/_chunks/{signed-out-frame-bh7fn_Px.js → signed-out-frame-fUf7tqs3.js} +2 -2
- package/dist/_chunks/{signed-out-frame-bh7fn_Px.js.map → signed-out-frame-fUf7tqs3.js.map} +1 -1
- package/dist/_chunks/{task-editor-WdDCqbIL.js → task-editor-Czcx9B-3.js} +2 -2
- package/dist/_chunks/{task-editor-WdDCqbIL.js.map → task-editor-Czcx9B-3.js.map} +1 -1
- package/dist/_chunks/{toolbar-z8vXnpXz.js → toolbar-DoKcoE2q.js} +2 -2
- package/dist/_chunks/{toolbar-z8vXnpXz.js.map → toolbar-DoKcoE2q.js.map} +1 -1
- package/dist/_chunks/types-BrJRsnSG.js +291 -0
- package/dist/_chunks/types-BrJRsnSG.js.map +1 -0
- package/dist/_chunks/warehouse-load-summary-D88M4Ii7.js +255 -0
- package/dist/_chunks/warehouse-load-summary-D88M4Ii7.js.map +1 -0
- package/dist/agent-catalog.json +360 -14
- package/dist/agent-i18n/en.json +31 -2
- package/dist/browser-support.js +1 -1
- package/dist/components/_shared/warehouse-load/counts.d.ts +82 -0
- package/dist/components/_shared/warehouse-load/counts.d.ts.map +1 -0
- package/dist/components/_shared/warehouse-load/index.d.ts +4 -0
- package/dist/components/_shared/warehouse-load/index.d.ts.map +1 -0
- package/dist/components/_shared/warehouse-load/maps.d.ts +67 -0
- package/dist/components/_shared/warehouse-load/maps.d.ts.map +1 -0
- package/dist/components/_shared/warehouse-load/types.d.ts +18 -0
- package/dist/components/_shared/warehouse-load/types.d.ts.map +1 -0
- package/dist/components/bill-line-table/bill-line-table.columns.d.ts +2 -0
- package/dist/components/bill-line-table/bill-line-table.columns.d.ts.map +1 -1
- package/dist/components/bill-line-table/bill-line-table.d.ts.map +1 -1
- package/dist/components/bill-line-table/bill-line-table.header.d.ts +7 -0
- package/dist/components/bill-line-table/bill-line-table.header.d.ts.map +1 -0
- package/dist/components/bill-line-table/bill-line-table.model.d.ts +10 -1
- package/dist/components/bill-line-table/bill-line-table.model.d.ts.map +1 -1
- package/dist/components/bill-line-table/bill-line-table.types.d.ts +66 -1
- package/dist/components/bill-line-table/bill-line-table.types.d.ts.map +1 -1
- package/dist/components/bill-line-table/bill-line-table.variants.d.ts +12 -0
- package/dist/components/bill-line-table/bill-line-table.variants.d.ts.map +1 -1
- package/dist/components/bill-line-table/index.d.ts +2 -2
- package/dist/components/bill-line-table/index.d.ts.map +1 -1
- package/dist/components/bill-line-table/index.js +10 -8
- package/dist/components/bill-table/index.js +1 -1
- package/dist/components/data-grid/data-grid.variants.d.ts +1 -1
- package/dist/components/data-grid/index.js +2 -2
- package/dist/components/document-scanner/index.js +1 -1
- package/dist/components/file-manager/index.js +1 -1
- package/dist/components/file-upload/file-upload.d.ts +30 -1
- package/dist/components/file-upload/file-upload.d.ts.map +1 -1
- package/dist/components/file-upload/index.js +1 -1
- package/dist/components/flag/flag-view.d.ts +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/invoice-upload/index.d.ts +5 -0
- package/dist/components/invoice-upload/index.d.ts.map +1 -0
- package/dist/components/invoice-upload/index.js +7 -0
- package/dist/components/invoice-upload/index.js.map +1 -0
- package/dist/components/invoice-upload/invoice-upload.agent.d.ts +4 -0
- package/dist/components/invoice-upload/invoice-upload.agent.d.ts.map +1 -0
- package/dist/components/invoice-upload/invoice-upload.d.ts +3 -0
- package/dist/components/invoice-upload/invoice-upload.d.ts.map +1 -0
- package/dist/components/invoice-upload/types.d.ts +72 -0
- package/dist/components/invoice-upload/types.d.ts.map +1 -0
- package/dist/components/invoice-upload-list/cells.d.ts +36 -0
- package/dist/components/invoice-upload-list/cells.d.ts.map +1 -0
- package/dist/components/invoice-upload-list/columns.d.ts +14 -0
- package/dist/components/invoice-upload-list/columns.d.ts.map +1 -0
- package/dist/components/invoice-upload-list/handle.d.ts +18 -0
- package/dist/components/invoice-upload-list/handle.d.ts.map +1 -0
- package/dist/components/invoice-upload-list/index.d.ts +5 -0
- package/dist/components/invoice-upload-list/index.d.ts.map +1 -0
- package/dist/components/invoice-upload-list/index.js +10 -0
- package/dist/components/invoice-upload-list/index.js.map +1 -0
- package/dist/components/invoice-upload-list/invoice-upload-list.agent.d.ts +4 -0
- package/dist/components/invoice-upload-list/invoice-upload-list.agent.d.ts.map +1 -0
- package/dist/components/invoice-upload-list/invoice-upload-list.d.ts +10 -0
- package/dist/components/invoice-upload-list/invoice-upload-list.d.ts.map +1 -0
- package/dist/components/invoice-upload-list/invoice-upload-list.variants.d.ts +28 -0
- package/dist/components/invoice-upload-list/invoice-upload-list.variants.d.ts.map +1 -0
- package/dist/components/invoice-upload-list/model.d.ts +40 -0
- package/dist/components/invoice-upload-list/model.d.ts.map +1 -0
- package/dist/components/invoice-upload-list/types.d.ts +154 -0
- package/dist/components/invoice-upload-list/types.d.ts.map +1 -0
- package/dist/components/notes-panel/index.js +1 -1
- package/dist/components/public-footer/index.js +1 -1
- package/dist/components/public-footer/public-footer.d.ts +24 -0
- package/dist/components/public-footer/public-footer.d.ts.map +1 -1
- package/dist/components/public-header/public-header.d.ts +1 -1
- package/dist/components/radiograph-panel/index.js +1 -1
- package/dist/components/rich-text-editor/index.js +1 -1
- package/dist/components/task-editor/index.js +1 -1
- package/dist/components/warehouse-load-summary/index.d.ts +4 -0
- package/dist/components/warehouse-load-summary/index.d.ts.map +1 -0
- package/dist/components/warehouse-load-summary/index.js +6 -0
- package/dist/components/warehouse-load-summary/index.js.map +1 -0
- package/dist/components/warehouse-load-summary/model.d.ts +8 -0
- package/dist/components/warehouse-load-summary/model.d.ts.map +1 -0
- package/dist/components/warehouse-load-summary/types.d.ts +50 -0
- package/dist/components/warehouse-load-summary/types.d.ts.map +1 -0
- package/dist/components/warehouse-load-summary/warehouse-load-summary.agent.d.ts +4 -0
- package/dist/components/warehouse-load-summary/warehouse-load-summary.agent.d.ts.map +1 -0
- package/dist/components/warehouse-load-summary/warehouse-load-summary.d.ts +7 -0
- package/dist/components/warehouse-load-summary/warehouse-load-summary.d.ts.map +1 -0
- package/dist/core.css +1 -1
- package/dist/i18n/locales/ar.d.ts +203 -0
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +197 -4
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts +203 -0
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +201 -4
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/el.d.ts +203 -0
- package/dist/i18n/locales/el.d.ts.map +1 -1
- package/dist/i18n/locales/el.js +201 -4
- package/dist/i18n/locales/el.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +203 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +203 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +203 -0
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +199 -4
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +203 -0
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +199 -4
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts +203 -0
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +197 -4
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +203 -0
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +197 -4
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts +203 -0
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +197 -4
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts +203 -0
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +197 -4
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts +203 -0
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +197 -4
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts +203 -0
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +199 -4
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ro.d.ts +203 -0
- package/dist/i18n/locales/ro.d.ts.map +1 -1
- package/dist/i18n/locales/ro.js +197 -4
- package/dist/i18n/locales/ro.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts +203 -0
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +197 -4
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/sq.d.ts +203 -0
- package/dist/i18n/locales/sq.d.ts.map +1 -1
- package/dist/i18n/locales/sq.js +199 -4
- package/dist/i18n/locales/sq.js.map +1 -1
- package/dist/i18n/locales/sv.d.ts +203 -0
- package/dist/i18n/locales/sv.d.ts.map +1 -1
- package/dist/i18n/locales/sv.js +197 -4
- package/dist/i18n/locales/sv.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts +203 -0
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +197 -4
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +203 -0
- package/dist/i18n/locales/zh.d.ts.map +1 -1
- package/dist/i18n/locales/zh.js +197 -4
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.js +1189 -1173
- package/dist/index.js.map +1 -1
- package/dist/locales/ar.json +207 -4
- package/dist/locales/de.json +207 -4
- package/dist/locales/el.json +207 -4
- package/dist/locales/en.json +203 -0
- package/dist/locales/es.json +207 -4
- package/dist/locales/fr.json +207 -4
- package/dist/locales/hi.json +207 -4
- package/dist/locales/it.json +207 -4
- package/dist/locales/ja.json +207 -4
- package/dist/locales/nl.json +207 -4
- package/dist/locales/pl.json +207 -4
- package/dist/locales/pt.json +207 -4
- package/dist/locales/ro.json +207 -4
- package/dist/locales/ru.json +207 -4
- package/dist/locales/sq.json +207 -4
- package/dist/locales/sv.json +207 -4
- package/dist/locales/tr.json +207 -4
- package/dist/locales/zh.json +207 -4
- package/dist/patterns/calendar/index.js +1 -1
- package/dist/patterns/signed-out-frame/index.js +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +13 -1
- package/dist/_chunks/bill-line-table-vCnVo7_a.js +0 -1565
- package/dist/_chunks/bill-line-table-vCnVo7_a.js.map +0 -1
- package/dist/_chunks/default-tabs-CD285u0C.js.map +0 -1
- package/dist/_chunks/file-upload-CxjCs7TX.js.map +0 -1
- package/dist/_chunks/public-footer-CB7ruuLI.js.map +0 -1
|
@@ -0,0 +1,1754 @@
|
|
|
1
|
+
import { jsxs as p, jsx as r, Fragment as Je } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Mt, useContext as ge, useRef as k, useLayoutEffect as Tn, useMemo as w, forwardRef as In, useEffect as je, useState as _e, useCallback as C, useImperativeHandle as Nn, useId as wn } from "react";
|
|
3
|
+
import { useTranslation as Pt } from "react-i18next";
|
|
4
|
+
import { u as kn } from "./registry-DvAUVLHh.js";
|
|
5
|
+
import { e as xn } from "./data-grid-Bbf8t4z3.js";
|
|
6
|
+
import { a as q } from "./format-number-DdzqwMs1.js";
|
|
7
|
+
import { i as _n } from "./is-development-CLUAnsU7.js";
|
|
8
|
+
import { B as Ft } from "./badge-BUk4RjTS.js";
|
|
9
|
+
import { f as En } from "./intl-locale-FWh-Y5_3.js";
|
|
10
|
+
import { p as Cn } from "./privacy-mask-text-B8YfzB7L.js";
|
|
11
|
+
import { V as De } from "./visually-hidden-BHxEUGyT.js";
|
|
12
|
+
import { c as b } from "./index-D2ZczOXr.js";
|
|
13
|
+
import { a as Sn } from "./compact-editor-fields-cP6yh7xv.js";
|
|
14
|
+
import { E as An } from "./eye-off-C_4xkbRP.js";
|
|
15
|
+
import { C as On } from "./combobox-BBCVQS-S.js";
|
|
16
|
+
import { M as qn } from "./money-OE6_oDPH.js";
|
|
17
|
+
import { divideDecimal as Vn, formatDecimal as de, multiplyDecimal as Rn, sumDecimals as qe, parseDecimal as ce, FATTURAPA_VALUE as ue, compareDecimal as Le, decimalToNumber as Be, rescaleDecimal as Kt, numberToDecimal as Dn, shiftDecimal as Bn } from "../decimal/index.js";
|
|
18
|
+
import { W as pe, a as Un } from "./maps-MpMxTBov.js";
|
|
19
|
+
import { C as Mn } from "./check-DrFSN__t.js";
|
|
20
|
+
import { P as Pn } from "./plus-DzMQ_c6b.js";
|
|
21
|
+
import { A as Fn } from "./arrow-right-KsIrLdt0.js";
|
|
22
|
+
import { C as Kn } from "./circle-alert-rGDZ73Wh.js";
|
|
23
|
+
import { T as $n } from "./triangle-alert-CBnO6nq_.js";
|
|
24
|
+
function wt(e, t) {
|
|
25
|
+
throw new Error(`${e}: ${t}`);
|
|
26
|
+
}
|
|
27
|
+
const Yn = "^[0-9]{1,8}([.][0-9]{1,8})?$", he = { type: "string", minLength: 1 }, Ee = "{ id, lineNumber, matchState, selected, selectable, readOnly, quantityLocked, itemKind, itemId, quantity, removesStock, warningCodes, invalid }", Qn = {
|
|
28
|
+
id: "bill-line-table",
|
|
29
|
+
// select_multiple: ticks. set_value: a line's quantity and its item
|
|
30
|
+
// (whole-value assignment to a NumberInput and a Combobox, 26 section 4).
|
|
31
|
+
// scroll: focus_line. No `confirm`: loading is the host's.
|
|
32
|
+
capabilities: ["select_multiple", "set_value", "scroll"],
|
|
33
|
+
state: {
|
|
34
|
+
lines: {
|
|
35
|
+
type: `Array<${Ee}>`,
|
|
36
|
+
descriptionKey: "ui.agent.billLineTable.state.lines",
|
|
37
|
+
description: "Every invoice line in invoice order, with what Confirm will do with it. matchState is one of matched, newItem, itemToUpdate (a matched line whose price, VAT or discount will change; counted inside matchedCount), skip or alreadyLoaded. Quantities are exact decimal text as shown, unsigned; there are no descriptions or names.",
|
|
38
|
+
read: (e) => e.getLines()
|
|
39
|
+
},
|
|
40
|
+
selection: {
|
|
41
|
+
type: "string[]",
|
|
42
|
+
descriptionKey: "ui.agent.billLineTable.state.selection",
|
|
43
|
+
description: "Ids of the ticked lines: the lines Confirm will load.",
|
|
44
|
+
read: (e) => e.getSelection()
|
|
45
|
+
},
|
|
46
|
+
summary: {
|
|
47
|
+
type: "{ lineCount, selectedCount, matchedCount, newItemCount, itemUpdateCount, skippedCount, alreadyLoadedCount, warningLineCount, invoiceLoaded, invalidCount, net, vat, gross, canConfirm, dirty }",
|
|
48
|
+
descriptionKey: "ui.agent.billLineTable.state.summary",
|
|
49
|
+
description: 'Counts and totals of the ticked lines. net, vat and gross are exact decimal text with 2 places ("14.58"). canConfirm is false while no line is ticked, a ticked line cannot load, or the invoice is already loaded (invoiceLoaded).',
|
|
50
|
+
read: (e) => e.getSummary()
|
|
51
|
+
},
|
|
52
|
+
invalidLineIds: {
|
|
53
|
+
type: "string[]",
|
|
54
|
+
descriptionKey: "ui.agent.billLineTable.state.invalidLineIds",
|
|
55
|
+
description: "Ticked lines that cannot load as they are: an empty or zero quantity, an item no longer in the warehouse, or an error from the server.",
|
|
56
|
+
read: (e) => e.getInvalidLineIds()
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
actions: {
|
|
60
|
+
select_lines: {
|
|
61
|
+
safety: "write",
|
|
62
|
+
idempotent: !0,
|
|
63
|
+
argsType: "{ ids: string[]; mode?: 'replace' | 'add' | 'remove' }",
|
|
64
|
+
argsSchema: {
|
|
65
|
+
type: "object",
|
|
66
|
+
properties: {
|
|
67
|
+
ids: { type: "array", items: he, uniqueItems: !0 },
|
|
68
|
+
mode: { type: "string", enum: ["replace", "add", "remove"] }
|
|
69
|
+
},
|
|
70
|
+
required: ["ids"],
|
|
71
|
+
additionalProperties: !1
|
|
72
|
+
},
|
|
73
|
+
returns: "string[]",
|
|
74
|
+
errors: ["UNKNOWN_LINE", "LINE_READ_ONLY", "TABLE_READ_ONLY"],
|
|
75
|
+
examples: [{ args: { ids: ["ln-3", "ln-4"], mode: "add" } }],
|
|
76
|
+
descriptionKey: "ui.agent.billLineTable.actions.selectLines",
|
|
77
|
+
description: "Tick or untick lines. Lines of an invoice that is already loaded cannot be ticked. Returns the ticked ids.",
|
|
78
|
+
invoke: (e, t) => {
|
|
79
|
+
for (const c of t.ids)
|
|
80
|
+
e.getLine(c) || wt("UNKNOWN_LINE", `no line "${c}".`);
|
|
81
|
+
const n = e.getSelection(), i = t.mode ?? "replace", a = i === "replace" ? t.ids : i === "add" ? [...n, ...t.ids] : n.filter((c) => !t.ids.includes(c));
|
|
82
|
+
return e.setSelection(a), e.getSelection();
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
select_all_lines: {
|
|
86
|
+
safety: "write",
|
|
87
|
+
idempotent: !0,
|
|
88
|
+
returns: "string[]",
|
|
89
|
+
errors: ["TABLE_READ_ONLY"],
|
|
90
|
+
descriptionKey: "ui.agent.billLineTable.actions.selectAllLines",
|
|
91
|
+
description: "Tick every line that can load. Returns the ticked ids.",
|
|
92
|
+
invoke: (e) => (e.selectAll(), e.getSelection())
|
|
93
|
+
},
|
|
94
|
+
clear_selection: {
|
|
95
|
+
safety: "write",
|
|
96
|
+
idempotent: !0,
|
|
97
|
+
returns: "string[]",
|
|
98
|
+
errors: ["TABLE_READ_ONLY"],
|
|
99
|
+
descriptionKey: "ui.agent.billLineTable.actions.clearSelection",
|
|
100
|
+
description: "Untick every line.",
|
|
101
|
+
invoke: (e) => (e.clearSelection(), e.getSelection())
|
|
102
|
+
},
|
|
103
|
+
set_quantity: {
|
|
104
|
+
safety: "write",
|
|
105
|
+
idempotent: !0,
|
|
106
|
+
argsType: "{ lineId: string; quantity: string }",
|
|
107
|
+
argsSchema: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
lineId: he,
|
|
111
|
+
quantity: { type: "string", pattern: Yn }
|
|
112
|
+
},
|
|
113
|
+
required: ["lineId", "quantity"],
|
|
114
|
+
additionalProperties: !1
|
|
115
|
+
},
|
|
116
|
+
returns: Ee,
|
|
117
|
+
errors: [
|
|
118
|
+
"UNKNOWN_LINE",
|
|
119
|
+
"INVALID_QUANTITY",
|
|
120
|
+
"TABLE_READ_ONLY",
|
|
121
|
+
"LINE_READ_ONLY"
|
|
122
|
+
],
|
|
123
|
+
examples: [
|
|
124
|
+
{ args: { lineId: "ln-2", quantity: "2.5" } },
|
|
125
|
+
{
|
|
126
|
+
args: { lineId: "ln-7", quantity: "3" },
|
|
127
|
+
note: "On a credit note this removes 3 from stock."
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
descriptionKey: "ui.agent.billLineTable.actions.setQuantity",
|
|
131
|
+
description: "Set the quantity of a line as shown in the table: a decimal above 0 and at most 10000000, with a dot and up to 8 places, never signed. On a credit note it is the quantity to remove. The line amount stays as invoiced. Does not tick the line.",
|
|
132
|
+
invoke: (e, t) => (e.setQuantity(t.lineId, t.quantity), e.getLine(t.lineId))
|
|
133
|
+
},
|
|
134
|
+
set_item: {
|
|
135
|
+
safety: "write",
|
|
136
|
+
idempotent: !0,
|
|
137
|
+
argsType: "{ lineId: string; itemId: string }",
|
|
138
|
+
argsSchema: {
|
|
139
|
+
type: "object",
|
|
140
|
+
properties: {
|
|
141
|
+
lineId: he,
|
|
142
|
+
itemId: { type: "string", minLength: 1 }
|
|
143
|
+
},
|
|
144
|
+
required: ["lineId", "itemId"],
|
|
145
|
+
additionalProperties: !1
|
|
146
|
+
},
|
|
147
|
+
returns: Ee,
|
|
148
|
+
errors: [
|
|
149
|
+
"UNKNOWN_LINE",
|
|
150
|
+
"UNKNOWN_ITEM",
|
|
151
|
+
"TABLE_READ_ONLY",
|
|
152
|
+
"LINE_READ_ONLY"
|
|
153
|
+
],
|
|
154
|
+
descriptionKey: "ui.agent.billLineTable.actions.setItem",
|
|
155
|
+
description: "Load a line into an existing warehouse item, by item id. Does not tick the line.",
|
|
156
|
+
invoke: (e, t) => (e.setItem(t.lineId, { kind: "existing", itemId: t.itemId }), e.getLine(t.lineId))
|
|
157
|
+
},
|
|
158
|
+
create_new_item: {
|
|
159
|
+
safety: "write",
|
|
160
|
+
idempotent: !0,
|
|
161
|
+
argsType: "{ lineId: string; name?: string }",
|
|
162
|
+
argsSchema: {
|
|
163
|
+
type: "object",
|
|
164
|
+
properties: {
|
|
165
|
+
lineId: he,
|
|
166
|
+
// DoctorInventoryItem.name is a string of 255.
|
|
167
|
+
name: { type: "string", minLength: 1, maxLength: 255 }
|
|
168
|
+
},
|
|
169
|
+
required: ["lineId"],
|
|
170
|
+
additionalProperties: !1
|
|
171
|
+
},
|
|
172
|
+
returns: Ee,
|
|
173
|
+
errors: [
|
|
174
|
+
"UNKNOWN_LINE",
|
|
175
|
+
"INVALID_ARGS",
|
|
176
|
+
"TABLE_READ_ONLY",
|
|
177
|
+
"LINE_READ_ONLY"
|
|
178
|
+
],
|
|
179
|
+
descriptionKey: "ui.agent.billLineTable.actions.createNewItem",
|
|
180
|
+
description: "Mark a line to create a new warehouse item when the invoice is loaded. Without a name, the item takes the line description. Nothing is created until Confirm. Does not tick the line.",
|
|
181
|
+
invoke: (e, t) => {
|
|
182
|
+
var i;
|
|
183
|
+
const n = (i = t.name) == null ? void 0 : i.trim();
|
|
184
|
+
return t.name !== void 0 && !n && wt("INVALID_ARGS", "name is empty."), e.setItem(t.lineId, { kind: "new", name: n ?? "" }), e.getLine(t.lineId);
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
focus_line: {
|
|
188
|
+
safety: "read",
|
|
189
|
+
idempotent: !0,
|
|
190
|
+
argsType: "{ lineId: string; field?: 'select' | 'quantity' | 'item' }",
|
|
191
|
+
argsSchema: {
|
|
192
|
+
type: "object",
|
|
193
|
+
properties: {
|
|
194
|
+
lineId: he,
|
|
195
|
+
field: { type: "string", enum: ["select", "quantity", "item"] }
|
|
196
|
+
},
|
|
197
|
+
required: ["lineId"],
|
|
198
|
+
additionalProperties: !1
|
|
199
|
+
},
|
|
200
|
+
errors: ["UNKNOWN_LINE"],
|
|
201
|
+
descriptionKey: "ui.agent.billLineTable.actions.focusLine",
|
|
202
|
+
description: "Scroll a line into view and move focus to its checkbox, quantity or item field.",
|
|
203
|
+
invoke: (e, t) => {
|
|
204
|
+
e.focusLine(t.lineId, t.field);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
domHooks: {
|
|
209
|
+
root: {
|
|
210
|
+
attr: "data-component",
|
|
211
|
+
value: "bill-line-table",
|
|
212
|
+
description: "Marks the element as a kit BillLineTable."
|
|
213
|
+
},
|
|
214
|
+
instanceId: {
|
|
215
|
+
attr: "data-component-id",
|
|
216
|
+
sourceProp: "gridId",
|
|
217
|
+
description: "The agent instance id."
|
|
218
|
+
},
|
|
219
|
+
item: {
|
|
220
|
+
attr: "data-row-id",
|
|
221
|
+
sourceProp: "lines[].id",
|
|
222
|
+
description: "BillLine.id on each body row (written by DataGrid). The only line datum in the DOM."
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}, zn = b("ds:flex ds:min-w-0 ds:flex-col", {
|
|
226
|
+
variants: {
|
|
227
|
+
height: {
|
|
228
|
+
auto: "",
|
|
229
|
+
fill: "ds:min-h-0 ds:flex-1"
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
defaultVariants: { height: "fill" }
|
|
233
|
+
}), Wn = b([
|
|
234
|
+
"ds:w-full ds:min-w-0",
|
|
235
|
+
Sn
|
|
236
|
+
]), et = b("ds:flex ds:flex-col", {
|
|
237
|
+
variants: {
|
|
238
|
+
align: {
|
|
239
|
+
start: "ds:items-start",
|
|
240
|
+
end: "ds:items-end"
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
defaultVariants: { align: "start" }
|
|
244
|
+
}), Ve = b(
|
|
245
|
+
"type-body-sm ds:text-[color:var(--muted-foreground)]"
|
|
246
|
+
), tt = b(
|
|
247
|
+
"ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-2xs)] ds:p-0",
|
|
248
|
+
{
|
|
249
|
+
variants: {
|
|
250
|
+
align: {
|
|
251
|
+
start: "ds:items-start",
|
|
252
|
+
end: "ds:items-end"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
defaultVariants: { align: "start" }
|
|
256
|
+
}
|
|
257
|
+
), Ue = b("ds:tabular-nums"), jn = b(
|
|
258
|
+
"ds:flex ds:items-start ds:gap-[var(--spacing-xs)]"
|
|
259
|
+
), kt = b(
|
|
260
|
+
"ds:mt-[var(--spacing-2xs)] ds:size-4 ds:shrink-0",
|
|
261
|
+
{
|
|
262
|
+
variants: {
|
|
263
|
+
severity: {
|
|
264
|
+
warning: "ds:text-[color:var(--warning-foreground)]",
|
|
265
|
+
error: "ds:text-[color:var(--error-foreground)]"
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
defaultVariants: { severity: "warning" }
|
|
269
|
+
}
|
|
270
|
+
), Hn = b("ds:text-[color:var(--foreground)]"), Gn = b(
|
|
271
|
+
"ds:m-0 ds:grid ds:grid-cols-1 ds:justify-items-end ds:text-end"
|
|
272
|
+
), xt = b(
|
|
273
|
+
"type-meta ds:text-[color:var(--muted-foreground)]"
|
|
274
|
+
), _t = b(
|
|
275
|
+
"ds:m-0 ds:[&:not(:last-child)]:mb-[var(--spacing-2xs)]"
|
|
276
|
+
), Xn = b(
|
|
277
|
+
"ds:flex ds:flex-wrap ds:items-baseline ds:justify-end ds:gap-x-[var(--spacing-xs)]"
|
|
278
|
+
), Zn = b(
|
|
279
|
+
"ds:inline ds:size-3 ds:align-middle ds:rtl:-scale-x-100"
|
|
280
|
+
), Jn = b("ds:tabular-nums type-body-sm"), ei = b(
|
|
281
|
+
"ds:m-0 ds:flex ds:shrink-0 ds:flex-wrap ds:gap-x-[var(--spacing-lg)] ds:gap-y-[var(--spacing-sm)] ds:pb-[var(--spacing-md)]"
|
|
282
|
+
), Ce = b(
|
|
283
|
+
"type-meta ds:text-[color:var(--muted-foreground)]"
|
|
284
|
+
), Se = b(
|
|
285
|
+
"ds:m-0 ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:text-[color:var(--foreground)]"
|
|
286
|
+
), Et = /* @__PURE__ */ new Map(), ti = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
287
|
+
function ni(e, t) {
|
|
288
|
+
const n = ti.exec(e);
|
|
289
|
+
if (!n) return e;
|
|
290
|
+
const i = new Date(
|
|
291
|
+
Date.UTC(Number(n[1]), Number(n[2]) - 1, Number(n[3]))
|
|
292
|
+
);
|
|
293
|
+
if (Number.isNaN(i.getTime())) return e;
|
|
294
|
+
const a = En(t);
|
|
295
|
+
let c = Et.get(a);
|
|
296
|
+
return c || (c = new Intl.DateTimeFormat(a, {
|
|
297
|
+
dateStyle: "medium",
|
|
298
|
+
timeZone: "UTC"
|
|
299
|
+
}), Et.set(a, c)), c.format(i);
|
|
300
|
+
}
|
|
301
|
+
function ii({
|
|
302
|
+
invoice: e,
|
|
303
|
+
privacyMode: t
|
|
304
|
+
}) {
|
|
305
|
+
const { t: n, i18n: i } = Pt("ui"), a = t && e.supplier.kind === "person";
|
|
306
|
+
return /* @__PURE__ */ p(
|
|
307
|
+
"dl",
|
|
308
|
+
{
|
|
309
|
+
className: ei(),
|
|
310
|
+
"data-component": "bill-line-invoice-header",
|
|
311
|
+
"data-part": "invoice-header",
|
|
312
|
+
children: [
|
|
313
|
+
/* @__PURE__ */ p("div", { children: [
|
|
314
|
+
/* @__PURE__ */ r("dt", { className: Ce(), children: n("billLineTable.header.supplier", "Supplier") }),
|
|
315
|
+
/* @__PURE__ */ r("dd", { className: Se(), children: a ? /* @__PURE__ */ p(Je, { children: [
|
|
316
|
+
/* @__PURE__ */ r(An, { "aria-hidden": "true", className: "ds:size-4 ds:shrink-0" }),
|
|
317
|
+
/* @__PURE__ */ r(De, { children: n("billLineTable.header.supplierHidden", "Name hidden") }),
|
|
318
|
+
/* @__PURE__ */ r("span", { "aria-hidden": "true", children: Cn() })
|
|
319
|
+
] }) : /* @__PURE__ */ r("span", { dir: "auto", children: e.supplier.name }) })
|
|
320
|
+
] }),
|
|
321
|
+
/* @__PURE__ */ p("div", { children: [
|
|
322
|
+
/* @__PURE__ */ r("dt", { className: Ce(), children: n("billLineTable.header.number", "Invoice number") }),
|
|
323
|
+
/* @__PURE__ */ r("dd", { className: Se(), children: /* @__PURE__ */ r("span", { dir: "auto", children: e.number }) })
|
|
324
|
+
] }),
|
|
325
|
+
/* @__PURE__ */ p("div", { children: [
|
|
326
|
+
/* @__PURE__ */ r("dt", { className: Ce(), children: n("billLineTable.header.date", "Date") }),
|
|
327
|
+
/* @__PURE__ */ r("dd", { className: Se(), children: ni(e.date, i.language) })
|
|
328
|
+
] }),
|
|
329
|
+
/* @__PURE__ */ p("div", { children: [
|
|
330
|
+
/* @__PURE__ */ r("dt", { className: Ce(), children: n("billLineTable.header.source", "Source") }),
|
|
331
|
+
/* @__PURE__ */ r("dd", { className: Se(), children: /* @__PURE__ */ r(Ft, { size: "sm", variant: "neutral", children: e.source === "sdi" ? n("billLineTable.header.sourceSdi", "SDI") : n("billLineTable.header.sourceUpload", "Upload") }) })
|
|
332
|
+
] })
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
const oe = 8, Re = 8, ai = 2, be = 1e7, Ct = 255, se = "bill-line-table:new-item", $t = "quantityTooLarge", ye = { units: 0, scale: 0 }, Yt = { units: be, scale: 0 }, ri = {
|
|
338
|
+
...ue.quantity,
|
|
339
|
+
allowNegative: !0
|
|
340
|
+
};
|
|
341
|
+
function Me(e) {
|
|
342
|
+
let { units: t, scale: n } = e;
|
|
343
|
+
for (; n > 0 && t % 10 === 0; )
|
|
344
|
+
t /= 10, n -= 1;
|
|
345
|
+
return { units: t || 0, scale: n };
|
|
346
|
+
}
|
|
347
|
+
function Xe(e) {
|
|
348
|
+
return { units: Math.abs(e.units), scale: e.scale };
|
|
349
|
+
}
|
|
350
|
+
function D(e) {
|
|
351
|
+
const t = {
|
|
352
|
+
empty: !0,
|
|
353
|
+
wellFormed: !1,
|
|
354
|
+
positive: !1,
|
|
355
|
+
value: null,
|
|
356
|
+
editorNumber: null
|
|
357
|
+
};
|
|
358
|
+
if (e === null || e.trim() === "") return t;
|
|
359
|
+
const n = ce(e, ri);
|
|
360
|
+
if (n.ok) {
|
|
361
|
+
const i = Be(n.value);
|
|
362
|
+
return {
|
|
363
|
+
empty: !1,
|
|
364
|
+
wellFormed: !0,
|
|
365
|
+
positive: n.value.units > 0,
|
|
366
|
+
value: n.value,
|
|
367
|
+
editorNumber: i !== null && Math.abs(i) <= be ? i : null
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
return n.error === "unsafe" ? {
|
|
371
|
+
empty: !1,
|
|
372
|
+
wellFormed: !0,
|
|
373
|
+
positive: !e.trim().startsWith("-"),
|
|
374
|
+
value: null,
|
|
375
|
+
editorNumber: null
|
|
376
|
+
} : { ...t, empty: !1 };
|
|
377
|
+
}
|
|
378
|
+
function nt(e) {
|
|
379
|
+
const t = D(e);
|
|
380
|
+
return !t.wellFormed || t.editorNumber !== null;
|
|
381
|
+
}
|
|
382
|
+
function li(e) {
|
|
383
|
+
const t = Dn(e, oe);
|
|
384
|
+
return t ? de(Me(t)) : null;
|
|
385
|
+
}
|
|
386
|
+
function ne(e) {
|
|
387
|
+
const t = ce(e, ue.lineTotal);
|
|
388
|
+
return t.ok ? t.value : null;
|
|
389
|
+
}
|
|
390
|
+
function Qt(e) {
|
|
391
|
+
if (e === null) return null;
|
|
392
|
+
const t = ce(e, ue.rate);
|
|
393
|
+
return t.ok ? t.value : null;
|
|
394
|
+
}
|
|
395
|
+
function oi(e, t) {
|
|
396
|
+
const n = ne(e), i = D(t).value;
|
|
397
|
+
if (!n || !i || i.units === 0) return null;
|
|
398
|
+
const a = Vn(n, i, Re);
|
|
399
|
+
return a ? de(Me(a)) : null;
|
|
400
|
+
}
|
|
401
|
+
function si(e, t) {
|
|
402
|
+
const n = ne(e), i = ne(t);
|
|
403
|
+
return !n || !i ? e.trim() === t.trim() : Le(Xe(n), Xe(i)) === 0;
|
|
404
|
+
}
|
|
405
|
+
function H(e) {
|
|
406
|
+
const t = e.trim(), n = Array.from(t);
|
|
407
|
+
return n.length > Ct ? n.slice(0, Ct).join("").trim() : t;
|
|
408
|
+
}
|
|
409
|
+
function Ze(e, t) {
|
|
410
|
+
if (e.kind === "existing")
|
|
411
|
+
return { kind: "existing", itemId: e.itemId };
|
|
412
|
+
const n = H(e.name);
|
|
413
|
+
return {
|
|
414
|
+
kind: "new",
|
|
415
|
+
name: n === "" ? H(t.description) : n
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function ci(e) {
|
|
419
|
+
const t = D(e);
|
|
420
|
+
return t.wellFormed ? t.value === null ? !0 : Le(Xe(t.value), Yt) > 0 : !1;
|
|
421
|
+
}
|
|
422
|
+
function zt(e, t) {
|
|
423
|
+
return ci(t.quantity) && !Ht(t.quantity, e.quantity);
|
|
424
|
+
}
|
|
425
|
+
function Wt(e) {
|
|
426
|
+
return e.item.kind === "new" && H(e.item.name) === "";
|
|
427
|
+
}
|
|
428
|
+
function ui(e, t) {
|
|
429
|
+
if (t.item.kind !== "new") return !1;
|
|
430
|
+
const n = H(t.item.name);
|
|
431
|
+
return n !== "" && n === H(e.description);
|
|
432
|
+
}
|
|
433
|
+
function ie(e) {
|
|
434
|
+
return e.some((t) => t.alreadyLoaded);
|
|
435
|
+
}
|
|
436
|
+
function j(e) {
|
|
437
|
+
return {
|
|
438
|
+
quantity: e.quantity,
|
|
439
|
+
item: e.proposal === "existing" && e.proposedItemId !== null ? { kind: "existing", itemId: e.proposedItemId } : { kind: "new", name: H(e.description) }
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function da(e) {
|
|
443
|
+
const t = {};
|
|
444
|
+
for (const n of e) t[n.id] = j(n);
|
|
445
|
+
return t;
|
|
446
|
+
}
|
|
447
|
+
function He(e) {
|
|
448
|
+
return ie(e) ? [] : e.filter((t) => t.proposal !== "skip").map((t) => t.id);
|
|
449
|
+
}
|
|
450
|
+
function St(e, t) {
|
|
451
|
+
const n = {};
|
|
452
|
+
for (const i of e)
|
|
453
|
+
n[i.id] = t[i.id] ?? j(i);
|
|
454
|
+
return n;
|
|
455
|
+
}
|
|
456
|
+
function di(e, t) {
|
|
457
|
+
return !e.alreadyLoaded;
|
|
458
|
+
}
|
|
459
|
+
function W(e, t) {
|
|
460
|
+
if (ie(e) || t.length === 0) return [];
|
|
461
|
+
const i = new Set(t);
|
|
462
|
+
return e.filter((a) => i.has(a.id) && di(a)).map((a) => a.id);
|
|
463
|
+
}
|
|
464
|
+
function jt(e, t) {
|
|
465
|
+
return e.kind === "existing" ? t.kind === "existing" && e.itemId === t.itemId : t.kind === "new" && H(e.name) === H(t.name);
|
|
466
|
+
}
|
|
467
|
+
function Ht(e, t) {
|
|
468
|
+
if (e === t) return !0;
|
|
469
|
+
if (e === null || t === null) return !1;
|
|
470
|
+
const n = D(e).value, i = D(t).value;
|
|
471
|
+
return n && i ? Le(n, i) === 0 : e.trim() === t.trim();
|
|
472
|
+
}
|
|
473
|
+
function Gt(e, t) {
|
|
474
|
+
return Ht(e.quantity, t.quantity) && jt(e.item, t.item);
|
|
475
|
+
}
|
|
476
|
+
function mi(e, t, n) {
|
|
477
|
+
return e.alreadyLoaded ? "alreadyLoaded" : n ? t.item.kind !== "existing" ? "newItem" : it(e, t) ? "itemToUpdate" : "matched" : "skip";
|
|
478
|
+
}
|
|
479
|
+
function Oe(e) {
|
|
480
|
+
if (!e || e.from === e.to) return !1;
|
|
481
|
+
if (e.from === null || e.to === null) return !0;
|
|
482
|
+
const t = ce(e.from, ue.lineTotal), n = ce(e.to, ue.lineTotal);
|
|
483
|
+
return t.ok && n.ok ? Le(t.value, n.value) !== 0 : !0;
|
|
484
|
+
}
|
|
485
|
+
function fi(e) {
|
|
486
|
+
const t = e.itemUpdate;
|
|
487
|
+
return t ? Oe(t.unitPrice) || Oe(t.vatRate) || Oe(t.discountPercent) : !1;
|
|
488
|
+
}
|
|
489
|
+
function it(e, t) {
|
|
490
|
+
return t.item.kind === "existing" && e.proposal === "existing" && t.item.itemId === e.proposedItemId && fi(e);
|
|
491
|
+
}
|
|
492
|
+
function at(e, t, n = !0) {
|
|
493
|
+
const i = D(t.quantity);
|
|
494
|
+
return !i.wellFormed || !i.positive || zt(e, t) || !ne(e.lineTotal) || t.item.kind === "existing" && !n || Wt(t) ? !0 : e.warnings.some((a) => a.severity === "error");
|
|
495
|
+
}
|
|
496
|
+
const Xt = () => !0;
|
|
497
|
+
function Zt(e, t) {
|
|
498
|
+
return e.item.kind !== "existing" || t(e.item.itemId);
|
|
499
|
+
}
|
|
500
|
+
function At(e) {
|
|
501
|
+
const t = qe(e);
|
|
502
|
+
if (t) return t;
|
|
503
|
+
const n = [];
|
|
504
|
+
for (const i of e) {
|
|
505
|
+
const a = Kt(i, 2);
|
|
506
|
+
a && n.push(a);
|
|
507
|
+
}
|
|
508
|
+
return qe(n) ?? ye;
|
|
509
|
+
}
|
|
510
|
+
function Ae(e) {
|
|
511
|
+
return Kt(e, 2) ?? ye;
|
|
512
|
+
}
|
|
513
|
+
const Ge = (e) => de(e, 2);
|
|
514
|
+
function Ot(e, t, n, i, a = Xt) {
|
|
515
|
+
const c = ie(e), v = new Set(W(e, n));
|
|
516
|
+
let I = 0, y = 0, T = 0, _ = 0, E = 0, M = 0, V = 0, R = 0;
|
|
517
|
+
const X = [], B = /* @__PURE__ */ new Map();
|
|
518
|
+
for (const d of e) {
|
|
519
|
+
const K = t[d.id] ?? j(d);
|
|
520
|
+
if ((d.warnings.length > 0 || !nt(d.quantity)) && (V += 1), d.alreadyLoaded) {
|
|
521
|
+
M += 1;
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
if (!v.has(d.id)) {
|
|
525
|
+
E += 1;
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
I += 1, K.item.kind === "existing" ? (y += 1, it(d, K) && (_ += 1)) : T += 1, at(d, K, Zt(K, a)) && (R += 1);
|
|
529
|
+
const $ = ne(d.lineTotal);
|
|
530
|
+
if (!$) continue;
|
|
531
|
+
X.push($);
|
|
532
|
+
const f = Qt(d.vatPercent);
|
|
533
|
+
if (f) {
|
|
534
|
+
const Ie = de(Me(f)), Z = B.get(Ie);
|
|
535
|
+
Z ? Z.amounts.push($) : B.set(Ie, { rate: f, amounts: [$] });
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
const h = Ae(At(X)), P = [];
|
|
539
|
+
for (const d of B.values()) {
|
|
540
|
+
const K = {
|
|
541
|
+
units: d.rate.units,
|
|
542
|
+
scale: d.rate.scale + 2
|
|
543
|
+
}, $ = Ae(At(d.amounts));
|
|
544
|
+
P.push(Rn($, K, 2) ?? ye);
|
|
545
|
+
}
|
|
546
|
+
const N = qe(P) ?? ye, ae = qe([h, N]) ?? ye, F = W(e, i.selection), Te = F.length !== v.size || F.some((d) => !v.has(d)) || e.some(
|
|
547
|
+
(d) => !Gt(
|
|
548
|
+
t[d.id] ?? j(d),
|
|
549
|
+
i.values[d.id] ?? j(d)
|
|
550
|
+
)
|
|
551
|
+
);
|
|
552
|
+
return {
|
|
553
|
+
lineCount: e.length,
|
|
554
|
+
selectedCount: I,
|
|
555
|
+
matchedCount: y,
|
|
556
|
+
newItemCount: T,
|
|
557
|
+
itemUpdateCount: _,
|
|
558
|
+
skippedCount: E,
|
|
559
|
+
alreadyLoadedCount: M,
|
|
560
|
+
warningLineCount: V,
|
|
561
|
+
invoiceLoaded: c,
|
|
562
|
+
invalidCount: R,
|
|
563
|
+
net: Ge(h),
|
|
564
|
+
vat: Ge(Ae(N)),
|
|
565
|
+
gross: Ge(Ae(ae)),
|
|
566
|
+
canConfirm: I > 0 && R === 0,
|
|
567
|
+
dirty: Te
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
function pi(e) {
|
|
571
|
+
const t = D(e).value;
|
|
572
|
+
return t ? de(t) : e.trim();
|
|
573
|
+
}
|
|
574
|
+
function hi(e, t, n, i, a = Xt) {
|
|
575
|
+
if (ie(e)) return { ok: !1, invalidLineIds: [] };
|
|
576
|
+
const c = new Set(W(e, n)), v = [], I = [];
|
|
577
|
+
for (const y of e) {
|
|
578
|
+
if (!c.has(y.id)) continue;
|
|
579
|
+
const T = t[y.id] ?? j(y);
|
|
580
|
+
if (T.quantity === null || at(y, T, Zt(T, a))) {
|
|
581
|
+
I.push(y.id);
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
const _ = pi(T.quantity), E = {
|
|
585
|
+
lineId: y.id,
|
|
586
|
+
quantity: i === "creditNote" ? `-${_}` : _,
|
|
587
|
+
item: Ze(T.item, y)
|
|
588
|
+
};
|
|
589
|
+
it(y, T) && (E.updateItem = !0), v.push(E);
|
|
590
|
+
}
|
|
591
|
+
return I.length > 0 ? { ok: !1, invalidLineIds: I } : { ok: !0, lines: v };
|
|
592
|
+
}
|
|
593
|
+
function Jt(e, t, n) {
|
|
594
|
+
const i = n.ticked.has(e.id), a = t.item.kind === "existing" ? n.findItem(t.item.itemId) ?? null : null, c = t.item.kind !== "existing" || a !== null;
|
|
595
|
+
return {
|
|
596
|
+
line: e,
|
|
597
|
+
value: t,
|
|
598
|
+
selected: i,
|
|
599
|
+
matchState: mi(e, t, i),
|
|
600
|
+
invalid: i && at(e, t, c),
|
|
601
|
+
readOnly: n.invoiceLoaded,
|
|
602
|
+
quantityLocked: !nt(e.quantity),
|
|
603
|
+
item: a,
|
|
604
|
+
itemKnown: c
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
function yi(e, t) {
|
|
608
|
+
return e === t ? !0 : e === null || t === null ? !1 : e.id === t.id && e.name === t.name && e.code === t.code;
|
|
609
|
+
}
|
|
610
|
+
function gi(e, t) {
|
|
611
|
+
return e.line === t.line && e.value.quantity === t.value.quantity && jt(e.value.item, t.value.item) && e.selected === t.selected && e.matchState === t.matchState && e.invalid === t.invalid && e.readOnly === t.readOnly && e.quantityLocked === t.quantityLocked && e.itemKnown === t.itemKnown && yi(e.item, t.item);
|
|
612
|
+
}
|
|
613
|
+
function qt(e) {
|
|
614
|
+
const t = {
|
|
615
|
+
invoiceLoaded: ie(e.lines),
|
|
616
|
+
ticked: new Set(W(e.lines, e.selection)),
|
|
617
|
+
findItem: e.findItem
|
|
618
|
+
};
|
|
619
|
+
return e.lines.map((n) => {
|
|
620
|
+
var c;
|
|
621
|
+
const i = Jt(
|
|
622
|
+
n,
|
|
623
|
+
e.values[n.id] ?? j(n),
|
|
624
|
+
t
|
|
625
|
+
), a = (c = e.previous) == null ? void 0 : c.get(n.id);
|
|
626
|
+
return a && gi(a, i) ? a : i;
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
function Li(e, t) {
|
|
630
|
+
const n = e.line.warnings.map((a) => a.code);
|
|
631
|
+
e.quantityLocked && n.push($t);
|
|
632
|
+
const i = e.readOnly || e.line.alreadyLoaded;
|
|
633
|
+
return {
|
|
634
|
+
id: e.line.id,
|
|
635
|
+
lineNumber: e.line.lineNumber,
|
|
636
|
+
matchState: e.matchState,
|
|
637
|
+
selected: e.selected,
|
|
638
|
+
selectable: !i && !t.tableReadOnly,
|
|
639
|
+
readOnly: i || t.tableReadOnly,
|
|
640
|
+
quantityLocked: e.quantityLocked,
|
|
641
|
+
itemKind: e.value.item.kind,
|
|
642
|
+
itemId: e.value.item.kind === "existing" ? e.value.item.itemId : null,
|
|
643
|
+
quantity: e.value.quantity,
|
|
644
|
+
removesStock: t.documentKind === "creditNote",
|
|
645
|
+
warningCodes: n,
|
|
646
|
+
invalid: e.invalid
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
function bi(e) {
|
|
650
|
+
const t = ce(e, ue.quantity);
|
|
651
|
+
return !t.ok || t.value.units <= 0 || Le(t.value, Yt) > 0 ? null : de(Me(t.value));
|
|
652
|
+
}
|
|
653
|
+
const vi = {
|
|
654
|
+
itemOptions: [],
|
|
655
|
+
itemOptionIds: /* @__PURE__ */ new Set(),
|
|
656
|
+
serverSearch: !1,
|
|
657
|
+
itemsLoading: !1,
|
|
658
|
+
searchingLineId: null
|
|
659
|
+
}, en = Mt(vi), ve = Mt(
|
|
660
|
+
null
|
|
661
|
+
), Ti = {
|
|
662
|
+
matched: { variant: pe.matched, check: !1 },
|
|
663
|
+
newItem: { variant: pe.newItem, check: !1 },
|
|
664
|
+
itemToUpdate: {
|
|
665
|
+
variant: pe.itemToUpdate,
|
|
666
|
+
check: !1
|
|
667
|
+
},
|
|
668
|
+
skip: { variant: pe.skip, check: !1 },
|
|
669
|
+
alreadyLoaded: {
|
|
670
|
+
variant: pe.alreadyLoaded,
|
|
671
|
+
check: !0
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
function Vt(e, t) {
|
|
675
|
+
const n = Un[e];
|
|
676
|
+
return t(n.key, n.en);
|
|
677
|
+
}
|
|
678
|
+
function Pe(e, t) {
|
|
679
|
+
const n = Qt(e), i = n ? Be(n) : null;
|
|
680
|
+
return i === null ? e.trim() : q(Bn(i, -2), t, {
|
|
681
|
+
style: "percent",
|
|
682
|
+
minimumFractionDigits: 0,
|
|
683
|
+
maximumFractionDigits: ai
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
function G({
|
|
687
|
+
value: e,
|
|
688
|
+
currency: t,
|
|
689
|
+
fractionDigits: n = Re,
|
|
690
|
+
tone: i = "default"
|
|
691
|
+
}) {
|
|
692
|
+
const a = ne(e);
|
|
693
|
+
return a ? /* @__PURE__ */ r(
|
|
694
|
+
qn,
|
|
695
|
+
{
|
|
696
|
+
size: "sm",
|
|
697
|
+
tone: i,
|
|
698
|
+
value: a.units,
|
|
699
|
+
scale: a.scale,
|
|
700
|
+
currency: t,
|
|
701
|
+
minimumFractionDigits: Math.min(2, n),
|
|
702
|
+
maximumFractionDigits: n
|
|
703
|
+
}
|
|
704
|
+
) : /* @__PURE__ */ r("span", { dir: "ltr", className: Ue(), children: e.trim() });
|
|
705
|
+
}
|
|
706
|
+
function Ii(e, t) {
|
|
707
|
+
const n = e.value.quantity;
|
|
708
|
+
if (n === null) return null;
|
|
709
|
+
const i = D(n), a = i.value ? Be(i.value) : null;
|
|
710
|
+
return /* @__PURE__ */ p("span", { className: Ue(), children: [
|
|
711
|
+
a === null ? (
|
|
712
|
+
// More digits than a double holds: every digit, as sent.
|
|
713
|
+
/* @__PURE__ */ r("span", { dir: "ltr", children: n.trim() })
|
|
714
|
+
) : q(a, t, {
|
|
715
|
+
maximumFractionDigits: oe
|
|
716
|
+
}),
|
|
717
|
+
e.line.unitOfMeasure ? /* @__PURE__ */ p(Je, { children: [
|
|
718
|
+
" ",
|
|
719
|
+
/* @__PURE__ */ r("span", { dir: "auto", children: e.line.unitOfMeasure })
|
|
720
|
+
] }) : null
|
|
721
|
+
] });
|
|
722
|
+
}
|
|
723
|
+
function Ni(e, t) {
|
|
724
|
+
const { t: n } = t;
|
|
725
|
+
if (!e.selected) return;
|
|
726
|
+
const i = D(e.value.quantity);
|
|
727
|
+
if (i.empty)
|
|
728
|
+
return n("billLineTable.quantity.errorRequired", "Enter a quantity");
|
|
729
|
+
if (!i.wellFormed || !i.positive)
|
|
730
|
+
return n(
|
|
731
|
+
"billLineTable.quantity.errorNotPositive",
|
|
732
|
+
"Enter a quantity above 0"
|
|
733
|
+
);
|
|
734
|
+
if (zt(e.line, e.value))
|
|
735
|
+
return n("billLineTable.quantity.errorTooLarge", {
|
|
736
|
+
max: q(be, t.language),
|
|
737
|
+
defaultValue: "Enter a quantity of {{max}} or less"
|
|
738
|
+
});
|
|
739
|
+
const a = e.line.warnings.find(
|
|
740
|
+
(c) => c.severity === "error"
|
|
741
|
+
);
|
|
742
|
+
return a == null ? void 0 : a.message;
|
|
743
|
+
}
|
|
744
|
+
function wi(e, t) {
|
|
745
|
+
if (!e.itemKnown)
|
|
746
|
+
return t(
|
|
747
|
+
"billLineTable.item.errorUnknown",
|
|
748
|
+
"This item is no longer in the warehouse. Choose another."
|
|
749
|
+
);
|
|
750
|
+
if (e.selected && Wt(e.value))
|
|
751
|
+
return t(
|
|
752
|
+
"billLineTable.item.errorNameRequired",
|
|
753
|
+
"Enter a name for the new item"
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
function ki(e, t) {
|
|
757
|
+
const n = oi(e.line.lineTotal, e.value.quantity), i = n !== null && !si(n, e.line.unitPrice) ? n : null;
|
|
758
|
+
return /* @__PURE__ */ p("span", { className: et({ align: "end" }), children: [
|
|
759
|
+
/* @__PURE__ */ r(G, { value: e.line.unitPrice, currency: t.currency }),
|
|
760
|
+
i !== null ? /* @__PURE__ */ p("span", { className: Ve(), children: [
|
|
761
|
+
t.t("billLineTable.unitPrice.netLabel", "Net per unit"),
|
|
762
|
+
" ",
|
|
763
|
+
/* @__PURE__ */ r(
|
|
764
|
+
G,
|
|
765
|
+
{
|
|
766
|
+
value: i,
|
|
767
|
+
currency: t.currency,
|
|
768
|
+
tone: "muted"
|
|
769
|
+
}
|
|
770
|
+
)
|
|
771
|
+
] }) : null
|
|
772
|
+
] });
|
|
773
|
+
}
|
|
774
|
+
function xi(e, t) {
|
|
775
|
+
return e.line.adjustments.length === 0 ? null : /* @__PURE__ */ r("ul", { className: tt({ align: "end" }), children: e.line.adjustments.map((n, i) => (
|
|
776
|
+
// Index key: the blocks have no identity and never reorder.
|
|
777
|
+
/* @__PURE__ */ p("li", { className: Xn(), children: [
|
|
778
|
+
/* @__PURE__ */ r("span", { className: Ve(), children: n.type === "discount" ? t.t("billLineTable.adjustment.discount", "Discount") : t.t("billLineTable.adjustment.surcharge", "Surcharge") }),
|
|
779
|
+
/* @__PURE__ */ p("span", { className: Ue(), children: [
|
|
780
|
+
/* @__PURE__ */ r("span", { "aria-hidden": "true", children: n.type === "discount" ? "−" : "+" }),
|
|
781
|
+
n.percent !== null ? Pe(n.percent, t.language) : n.amount !== null ? /* @__PURE__ */ r(
|
|
782
|
+
G,
|
|
783
|
+
{
|
|
784
|
+
value: n.amount,
|
|
785
|
+
currency: t.currency
|
|
786
|
+
}
|
|
787
|
+
) : null
|
|
788
|
+
] })
|
|
789
|
+
] }, i)
|
|
790
|
+
)) });
|
|
791
|
+
}
|
|
792
|
+
function Rt(e, t, n) {
|
|
793
|
+
if (t === null)
|
|
794
|
+
return n.t("billLineTable.update.none", "none");
|
|
795
|
+
if (e !== "price") return Pe(t, n.language);
|
|
796
|
+
const i = ne(t);
|
|
797
|
+
return i ? q(i.units / 10 ** i.scale, n.language, {
|
|
798
|
+
style: "currency",
|
|
799
|
+
currency: n.currency,
|
|
800
|
+
minimumFractionDigits: Math.min(2, Re),
|
|
801
|
+
maximumFractionDigits: Re
|
|
802
|
+
}) : t.trim();
|
|
803
|
+
}
|
|
804
|
+
function Dt(e, t, n) {
|
|
805
|
+
return t === null ? n.t("billLineTable.update.none", "none") : e === "price" ? /* @__PURE__ */ r(G, { value: t, currency: n.currency }) : Pe(t, n.language);
|
|
806
|
+
}
|
|
807
|
+
function _i(e, t) {
|
|
808
|
+
if (e.matchState !== "itemToUpdate" || !e.line.itemUpdate) return null;
|
|
809
|
+
const n = e.line.itemUpdate, i = [
|
|
810
|
+
{
|
|
811
|
+
key: "price",
|
|
812
|
+
label: t.t("billLineTable.update.price", "Price"),
|
|
813
|
+
change: n.unitPrice
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
key: "vat",
|
|
817
|
+
label: t.t("billLineTable.update.vat", "VAT"),
|
|
818
|
+
change: n.vatRate
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
key: "discount",
|
|
822
|
+
label: t.t("billLineTable.update.discount", "Discount"),
|
|
823
|
+
change: n.discountPercent
|
|
824
|
+
}
|
|
825
|
+
].filter((a) => Oe(a.change));
|
|
826
|
+
return i.length === 0 ? null : /* @__PURE__ */ r(
|
|
827
|
+
"ul",
|
|
828
|
+
{
|
|
829
|
+
className: tt({ align: "start" }),
|
|
830
|
+
"aria-label": t.t("billLineTable.update.label", "Changes to the item"),
|
|
831
|
+
children: i.map(
|
|
832
|
+
({ key: a, label: c, change: v }) => v ? /* @__PURE__ */ p("li", { className: Jn(), children: [
|
|
833
|
+
/* @__PURE__ */ p("span", { "aria-hidden": "true", children: [
|
|
834
|
+
c,
|
|
835
|
+
" ",
|
|
836
|
+
Dt(a, v.from, t),
|
|
837
|
+
" ",
|
|
838
|
+
/* @__PURE__ */ r(Fn, { className: Zn() }),
|
|
839
|
+
" ",
|
|
840
|
+
Dt(a, v.to, t)
|
|
841
|
+
] }),
|
|
842
|
+
/* @__PURE__ */ r(De, { children: t.t("billLineTable.update.change", {
|
|
843
|
+
label: c,
|
|
844
|
+
from: Rt(a, v.from, t),
|
|
845
|
+
to: Rt(a, v.to, t),
|
|
846
|
+
defaultValue: "{{label}}: from {{from}} to {{to}}"
|
|
847
|
+
}) })
|
|
848
|
+
] }, a) : null
|
|
849
|
+
)
|
|
850
|
+
}
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
function Ei(e, t) {
|
|
854
|
+
if (e.line.vatPercent === null)
|
|
855
|
+
return /* @__PURE__ */ p(Je, { children: [
|
|
856
|
+
/* @__PURE__ */ r("span", { "aria-hidden": "true", children: "–" }),
|
|
857
|
+
/* @__PURE__ */ r(De, { children: t.t("billLineTable.vat.none", "No VAT rate") })
|
|
858
|
+
] });
|
|
859
|
+
const n = Pe(e.line.vatPercent, t.language);
|
|
860
|
+
return e.line.vatNature ? t.t("billLineTable.vat.withNature", {
|
|
861
|
+
rate: n,
|
|
862
|
+
nature: e.line.vatNature,
|
|
863
|
+
defaultValue: "{{rate}} ({{nature}})"
|
|
864
|
+
}) : n;
|
|
865
|
+
}
|
|
866
|
+
function rt(e, t) {
|
|
867
|
+
return t.privacyMode ? t.t("billLineTable.item.newOptionMasked", "New item") : t.t("billLineTable.item.newOption", {
|
|
868
|
+
name: e,
|
|
869
|
+
defaultValue: "New item: {{name}}"
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
function Ci(e, t) {
|
|
873
|
+
const n = [rt("", { ...t, privacyMode: !1 }).trim()];
|
|
874
|
+
t.privacyMode && n.push(t.t("billLineTable.item.newOptionMasked", "New item"));
|
|
875
|
+
for (const i of n)
|
|
876
|
+
if (i !== "" && e.startsWith(i))
|
|
877
|
+
return e.slice(i.length).trim();
|
|
878
|
+
return e.trim();
|
|
879
|
+
}
|
|
880
|
+
function Bt(e, t) {
|
|
881
|
+
var i;
|
|
882
|
+
const n = e.value.item;
|
|
883
|
+
return n.kind === "new" ? rt(n.name, t) : ((i = e.item) == null ? void 0 : i.name) ?? "";
|
|
884
|
+
}
|
|
885
|
+
function tn(e) {
|
|
886
|
+
return {
|
|
887
|
+
value: e.id,
|
|
888
|
+
label: e.name,
|
|
889
|
+
description: e.code ?? void 0,
|
|
890
|
+
// Item names are text a practice wrote.
|
|
891
|
+
dir: "auto"
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
const Si = () => 1;
|
|
895
|
+
function Ai(e, t) {
|
|
896
|
+
const n = [...e.line.warnings];
|
|
897
|
+
return e.quantityLocked && n.push({
|
|
898
|
+
code: $t,
|
|
899
|
+
message: t.t(
|
|
900
|
+
"billLineTable.quantity.tooLarge",
|
|
901
|
+
"This quantity is too large to edit here. It loads as on the invoice."
|
|
902
|
+
),
|
|
903
|
+
severity: "warning"
|
|
904
|
+
}), t.privacyMode && e.selected && ui(e.line, e.value) && n.push({
|
|
905
|
+
code: "newItemNameHidden",
|
|
906
|
+
message: t.t(
|
|
907
|
+
"billLineTable.item.checkNameHidden",
|
|
908
|
+
"The new item takes the line description as its name. Turn off privacy mode to check it before you load."
|
|
909
|
+
),
|
|
910
|
+
severity: "warning"
|
|
911
|
+
}), n.length === 0 ? null : /* @__PURE__ */ r("ul", { className: tt(), children: n.map((i, a) => (
|
|
912
|
+
// Index key: warnings have no identity of their own.
|
|
913
|
+
/* @__PURE__ */ p("li", { className: jn(), children: [
|
|
914
|
+
i.severity === "error" ? /* @__PURE__ */ r(
|
|
915
|
+
Kn,
|
|
916
|
+
{
|
|
917
|
+
"aria-hidden": "true",
|
|
918
|
+
className: kt({ severity: "error" })
|
|
919
|
+
}
|
|
920
|
+
) : /* @__PURE__ */ r(
|
|
921
|
+
$n,
|
|
922
|
+
{
|
|
923
|
+
"aria-hidden": "true",
|
|
924
|
+
className: kt({ severity: "warning" })
|
|
925
|
+
}
|
|
926
|
+
),
|
|
927
|
+
/* @__PURE__ */ p("span", { className: Hn(), children: [
|
|
928
|
+
/* @__PURE__ */ r(De, { children: i.severity === "error" ? t.t("billLineTable.warnings.error", "Error:") : t.t("billLineTable.warnings.warning", "Warning:") }),
|
|
929
|
+
/* @__PURE__ */ r("span", { dir: "auto", children: i.message })
|
|
930
|
+
] })
|
|
931
|
+
] }, a)
|
|
932
|
+
)) });
|
|
933
|
+
}
|
|
934
|
+
function Oi({
|
|
935
|
+
row: e,
|
|
936
|
+
context: t,
|
|
937
|
+
deps: n
|
|
938
|
+
}) {
|
|
939
|
+
const i = ge(en), { t: a, setItem: c, queryItems: v } = n, { line: I, value: y, item: T } = e, _ = y.item.kind === "new" ? y.item.name : null, E = k(null), M = k(n.privacyMode), V = k(0), R = k(!1);
|
|
940
|
+
if (M.current !== n.privacyMode) {
|
|
941
|
+
M.current = n.privacyMode;
|
|
942
|
+
const h = E.current;
|
|
943
|
+
h !== null && h.contains(h.ownerDocument.activeElement) && (V.current += 1, R.current = !0);
|
|
944
|
+
}
|
|
945
|
+
Tn(() => {
|
|
946
|
+
if (!R.current) return;
|
|
947
|
+
R.current = !1;
|
|
948
|
+
const h = () => {
|
|
949
|
+
var P, N;
|
|
950
|
+
return (N = (P = E.current) == null ? void 0 : P.querySelector('input[role="combobox"]')) == null ? void 0 : N.focus();
|
|
951
|
+
};
|
|
952
|
+
h(), queueMicrotask(h);
|
|
953
|
+
}, [n.privacyMode]);
|
|
954
|
+
const X = w(() => _ !== null ? [
|
|
955
|
+
{
|
|
956
|
+
value: se,
|
|
957
|
+
label: rt(_, n),
|
|
958
|
+
description: a(
|
|
959
|
+
"billLineTable.item.newOptionDescription",
|
|
960
|
+
"Created when you load the invoice"
|
|
961
|
+
)
|
|
962
|
+
},
|
|
963
|
+
...i.itemOptions
|
|
964
|
+
] : T && !i.itemOptionIds.has(T.id) ? [tn(T), ...i.itemOptions] : i.itemOptions, [_, T, i.itemOptions, i.itemOptionIds, n, a]), B = w(
|
|
965
|
+
() => ({
|
|
966
|
+
label: a("billLineTable.item.createNew", "Create new item"),
|
|
967
|
+
icon: /* @__PURE__ */ r(Pn, {}),
|
|
968
|
+
// Marks the line only; nothing is created before Confirm (D5). The
|
|
969
|
+
// typed text names the item; with none, the description does.
|
|
970
|
+
onSelect: (h) => c(I.id, {
|
|
971
|
+
kind: "new",
|
|
972
|
+
name: Ci(h, n)
|
|
973
|
+
})
|
|
974
|
+
}),
|
|
975
|
+
[a, c, I.id, n]
|
|
976
|
+
);
|
|
977
|
+
return /* @__PURE__ */ r("div", { ref: E, className: Wn(), children: /* @__PURE__ */ r(
|
|
978
|
+
On,
|
|
979
|
+
{
|
|
980
|
+
"aria-labelledby": t.labelledBy,
|
|
981
|
+
"aria-invalid": t.invalid || void 0,
|
|
982
|
+
"aria-describedby": [t.errorId, `${n.statusIdPrefix}-${I.id}`].filter(Boolean).join(" ") || void 0,
|
|
983
|
+
options: X,
|
|
984
|
+
value: y.item.kind === "existing" ? y.item.itemId : se,
|
|
985
|
+
onValueChange: (h) => {
|
|
986
|
+
h === "" || h === se || c(I.id, { kind: "existing", itemId: h });
|
|
987
|
+
},
|
|
988
|
+
placeholder: a("billLineTable.item.placeholder", "Choose an item"),
|
|
989
|
+
openOnFocus: !1,
|
|
990
|
+
popoverSize: "md",
|
|
991
|
+
wrapOptionLabels: !0,
|
|
992
|
+
action: B,
|
|
993
|
+
onQueryChange: i.serverSearch ? (h) => v(I.id, h) : void 0,
|
|
994
|
+
filter: i.serverSearch ? Si : void 0,
|
|
995
|
+
loading: i.serverSearch ? i.searchingLineId === I.id && i.itemsLoading : void 0
|
|
996
|
+
},
|
|
997
|
+
V.current
|
|
998
|
+
) });
|
|
999
|
+
}
|
|
1000
|
+
function qi({ deps: e }) {
|
|
1001
|
+
const t = ge(ve);
|
|
1002
|
+
if (!t) return null;
|
|
1003
|
+
const n = t.lineCount - t.alreadyLoadedCount;
|
|
1004
|
+
return /* @__PURE__ */ p("span", { className: et(), children: [
|
|
1005
|
+
/* @__PURE__ */ r("span", { children: e.t("billLineTable.footer.ticked", {
|
|
1006
|
+
count: n,
|
|
1007
|
+
selected: q(t.selectedCount, e.language),
|
|
1008
|
+
total: q(n, e.language),
|
|
1009
|
+
defaultValue: "{{selected}} of {{total}} lines ticked",
|
|
1010
|
+
defaultValue_one: "{{selected}} of {{total}} line ticked",
|
|
1011
|
+
defaultValue_other: "{{selected}} of {{total}} lines ticked"
|
|
1012
|
+
}) }),
|
|
1013
|
+
t.itemUpdateCount > 0 ? /* @__PURE__ */ r("span", { className: Ve(), children: e.t("billLineTable.footer.itemsToUpdate", {
|
|
1014
|
+
count: t.itemUpdateCount,
|
|
1015
|
+
countText: q(t.itemUpdateCount, e.language),
|
|
1016
|
+
defaultValue: "{{countText}} items to update",
|
|
1017
|
+
defaultValue_one: "{{countText}} item to update",
|
|
1018
|
+
defaultValue_other: "{{countText}} items to update"
|
|
1019
|
+
}) }) : null,
|
|
1020
|
+
t.newItemCount > 0 ? /* @__PURE__ */ r("span", { className: Ve(), children: e.t("billLineTable.footer.newItems", {
|
|
1021
|
+
count: t.newItemCount,
|
|
1022
|
+
countText: q(t.newItemCount, e.language),
|
|
1023
|
+
defaultValue: "{{countText}} new items",
|
|
1024
|
+
defaultValue_one: "{{countText}} new item",
|
|
1025
|
+
defaultValue_other: "{{countText}} new items"
|
|
1026
|
+
}) }) : null
|
|
1027
|
+
] });
|
|
1028
|
+
}
|
|
1029
|
+
function Vi({ currency: e }) {
|
|
1030
|
+
const t = ge(ve);
|
|
1031
|
+
return t ? /* @__PURE__ */ r(G, { value: t.vat, currency: e, fractionDigits: 2 }) : null;
|
|
1032
|
+
}
|
|
1033
|
+
function Ri({ deps: e }) {
|
|
1034
|
+
const t = ge(ve);
|
|
1035
|
+
return t ? /* @__PURE__ */ p("dl", { className: Gn(), children: [
|
|
1036
|
+
/* @__PURE__ */ r("dt", { className: xt(), children: e.t("billLineTable.footer.net", "Net") }),
|
|
1037
|
+
/* @__PURE__ */ r("dd", { className: _t(), children: /* @__PURE__ */ r(
|
|
1038
|
+
G,
|
|
1039
|
+
{
|
|
1040
|
+
value: t.net,
|
|
1041
|
+
currency: e.currency,
|
|
1042
|
+
fractionDigits: 2
|
|
1043
|
+
}
|
|
1044
|
+
) }),
|
|
1045
|
+
/* @__PURE__ */ r("dt", { className: xt(), children: e.t("billLineTable.footer.gross", "Total with VAT") }),
|
|
1046
|
+
/* @__PURE__ */ r("dd", { className: _t(), children: /* @__PURE__ */ r(
|
|
1047
|
+
G,
|
|
1048
|
+
{
|
|
1049
|
+
value: t.gross,
|
|
1050
|
+
currency: e.currency,
|
|
1051
|
+
fractionDigits: 2
|
|
1052
|
+
}
|
|
1053
|
+
) })
|
|
1054
|
+
] }) : null;
|
|
1055
|
+
}
|
|
1056
|
+
function Di({ deps: e }) {
|
|
1057
|
+
const t = ge(ve);
|
|
1058
|
+
return !t || t.warningLineCount === 0 ? null : /* @__PURE__ */ r("span", { children: e.t("billLineTable.footer.warningLines", {
|
|
1059
|
+
count: t.warningLineCount,
|
|
1060
|
+
countText: q(t.warningLineCount, e.language),
|
|
1061
|
+
defaultValue: "{{countText}} lines with warnings",
|
|
1062
|
+
defaultValue_one: "{{countText}} line with warnings",
|
|
1063
|
+
defaultValue_other: "{{countText}} lines with warnings"
|
|
1064
|
+
}) });
|
|
1065
|
+
}
|
|
1066
|
+
function Bi(e) {
|
|
1067
|
+
const { t } = e, n = {
|
|
1068
|
+
kind: "number",
|
|
1069
|
+
mode: "decimal",
|
|
1070
|
+
// The float lives only inside NumberInput: every change goes back to
|
|
1071
|
+
// exact text at once, within BILL_LINE_MAX_QUANTITY. Unsigned in the
|
|
1072
|
+
// field and in the value: the document carries the sign (D6).
|
|
1073
|
+
// A typed value above the limit stays in the field with its error
|
|
1074
|
+
// (`quantityError`); an invoiced one is locked by `isEditable`.
|
|
1075
|
+
getValue: (i) => {
|
|
1076
|
+
const a = D(i.value.quantity).value;
|
|
1077
|
+
return a ? Be(a) : null;
|
|
1078
|
+
},
|
|
1079
|
+
onChange: (i, a) => e.setQuantity(
|
|
1080
|
+
i.line.id,
|
|
1081
|
+
a === null ? null : li(a)
|
|
1082
|
+
),
|
|
1083
|
+
// A quantity the editor cannot hold exactly stays text, never clamped.
|
|
1084
|
+
isEditable: (i) => !i.readOnly && !i.quantityLocked,
|
|
1085
|
+
min: 0,
|
|
1086
|
+
max: be,
|
|
1087
|
+
step: 1,
|
|
1088
|
+
maximumFractionDigits: oe,
|
|
1089
|
+
// DG-1: FatturaPA UnitaMisura per line, as the supplier wrote it.
|
|
1090
|
+
unit: (i) => i.line.unitOfMeasure ?? void 0,
|
|
1091
|
+
error: (i) => Ni(i, e),
|
|
1092
|
+
// WCAG 3.3.2: the field says how many decimals it takes, since a digit
|
|
1093
|
+
// past the limit is refused as it is typed. Kit copy and a constant
|
|
1094
|
+
// only, so it shows in privacy mode too (`hostTextPrivacySafe`).
|
|
1095
|
+
description: () => t(
|
|
1096
|
+
"billLineTable.quantity.precision",
|
|
1097
|
+
"Up to {{formatted}} decimal places",
|
|
1098
|
+
{
|
|
1099
|
+
count: oe,
|
|
1100
|
+
formatted: q(
|
|
1101
|
+
oe,
|
|
1102
|
+
e.language
|
|
1103
|
+
)
|
|
1104
|
+
}
|
|
1105
|
+
)
|
|
1106
|
+
};
|
|
1107
|
+
return [
|
|
1108
|
+
{
|
|
1109
|
+
id: "description",
|
|
1110
|
+
header: t("billLineTable.column.description", "Description"),
|
|
1111
|
+
rowHeader: !0,
|
|
1112
|
+
pin: "start",
|
|
1113
|
+
wrap: !0,
|
|
1114
|
+
// Lab invoices can name a patient here (D9).
|
|
1115
|
+
privacy: "mask",
|
|
1116
|
+
cell: (i) => /* @__PURE__ */ r("span", { dir: "auto", children: i.line.description }),
|
|
1117
|
+
value: (i) => i.line.description,
|
|
1118
|
+
// No sorting in any mode (D10); privacy mode would turn it off anyway.
|
|
1119
|
+
sort: !1,
|
|
1120
|
+
size: 200,
|
|
1121
|
+
minSize: 192,
|
|
1122
|
+
hideable: !1,
|
|
1123
|
+
reorderable: !1,
|
|
1124
|
+
// The totals row's header cell.
|
|
1125
|
+
footer: () => /* @__PURE__ */ r(qi, { deps: e })
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
id: "quantity",
|
|
1129
|
+
header: e.documentKind === "creditNote" ? t("billLineTable.column.quantityCreditNote", "Quantity to remove") : t("billLineTable.column.quantity", "Quantity"),
|
|
1130
|
+
align: "end",
|
|
1131
|
+
// Read-only lines (a loaded invoice, the table while loading, or a
|
|
1132
|
+
// locked quantity): the unsigned value as text, plus the unit.
|
|
1133
|
+
cell: (i) => Ii(i, e.language),
|
|
1134
|
+
exportValue: (i) => i.value.quantity,
|
|
1135
|
+
edit: n,
|
|
1136
|
+
size: 128,
|
|
1137
|
+
hideable: !1,
|
|
1138
|
+
reorderable: !1
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
id: "item",
|
|
1142
|
+
header: t("billLineTable.column.item", "Warehouse item"),
|
|
1143
|
+
cell: (i) => /* @__PURE__ */ r("span", { dir: "auto", children: Bt(i, e) }),
|
|
1144
|
+
exportValue: (i) => Bt(i, e) || null,
|
|
1145
|
+
edit: {
|
|
1146
|
+
kind: "custom",
|
|
1147
|
+
render: (i, a) => /* @__PURE__ */ r(Oi, { row: i, context: a, deps: e }),
|
|
1148
|
+
error: (i) => wi(i, t)
|
|
1149
|
+
},
|
|
1150
|
+
size: 240,
|
|
1151
|
+
minSize: 192,
|
|
1152
|
+
hideable: !1,
|
|
1153
|
+
reorderable: !1
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
id: "match",
|
|
1157
|
+
header: t("billLineTable.column.match", "Status"),
|
|
1158
|
+
cell: (i) => {
|
|
1159
|
+
const a = Ti[i.matchState];
|
|
1160
|
+
return /* @__PURE__ */ p(
|
|
1161
|
+
"span",
|
|
1162
|
+
{
|
|
1163
|
+
id: `${e.statusIdPrefix}-${i.line.id}`,
|
|
1164
|
+
className: et(),
|
|
1165
|
+
children: [
|
|
1166
|
+
/* @__PURE__ */ r(
|
|
1167
|
+
Ft,
|
|
1168
|
+
{
|
|
1169
|
+
size: "sm",
|
|
1170
|
+
variant: a.variant,
|
|
1171
|
+
leading: a.check ? /* @__PURE__ */ r(Mn, {}) : void 0,
|
|
1172
|
+
children: Vt(i.matchState, t)
|
|
1173
|
+
}
|
|
1174
|
+
),
|
|
1175
|
+
_i(i, e)
|
|
1176
|
+
]
|
|
1177
|
+
}
|
|
1178
|
+
);
|
|
1179
|
+
},
|
|
1180
|
+
exportValue: (i) => Vt(i.matchState, t),
|
|
1181
|
+
wrap: !0,
|
|
1182
|
+
size: 176,
|
|
1183
|
+
hideable: !1,
|
|
1184
|
+
reorderable: !1
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
id: "warnings",
|
|
1188
|
+
header: t("billLineTable.column.warnings", "Warnings"),
|
|
1189
|
+
wrap: !0,
|
|
1190
|
+
// Not masked: a warning must not quote the description
|
|
1191
|
+
// (BillLineWarning.message), so errors stay readable (D9).
|
|
1192
|
+
cell: (i) => Ai(i, e),
|
|
1193
|
+
exportValue: (i) => i.line.warnings.map((a) => a.message).join("; ") || null,
|
|
1194
|
+
size: 168,
|
|
1195
|
+
hideable: !1,
|
|
1196
|
+
reorderable: !1,
|
|
1197
|
+
footer: () => /* @__PURE__ */ r(Di, { deps: e })
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
id: "lineTotal",
|
|
1201
|
+
header: t("billLineTable.column.lineTotal", "Amount"),
|
|
1202
|
+
align: "end",
|
|
1203
|
+
cell: (i) => /* @__PURE__ */ r(G, { value: i.line.lineTotal, currency: e.currency }),
|
|
1204
|
+
exportValue: (i) => i.line.lineTotal,
|
|
1205
|
+
size: 128,
|
|
1206
|
+
hideable: !1,
|
|
1207
|
+
reorderable: !1,
|
|
1208
|
+
// From the summary (exact decimals, ticked lines), not from the
|
|
1209
|
+
// footer context's rows.
|
|
1210
|
+
footer: () => /* @__PURE__ */ r(Ri, { deps: e })
|
|
1211
|
+
},
|
|
1212
|
+
{
|
|
1213
|
+
id: "unitPrice",
|
|
1214
|
+
header: t("billLineTable.column.unitPrice", "Unit price"),
|
|
1215
|
+
align: "end",
|
|
1216
|
+
cell: (i) => ki(i, e),
|
|
1217
|
+
exportValue: (i) => i.line.unitPrice,
|
|
1218
|
+
size: 128,
|
|
1219
|
+
hideable: !1,
|
|
1220
|
+
reorderable: !1
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
id: "vat",
|
|
1224
|
+
header: t("billLineTable.column.vat", "VAT"),
|
|
1225
|
+
align: "end",
|
|
1226
|
+
cell: (i) => Ei(i, e),
|
|
1227
|
+
exportValue: (i) => i.line.vatPercent,
|
|
1228
|
+
size: 88,
|
|
1229
|
+
hideable: !1,
|
|
1230
|
+
reorderable: !1,
|
|
1231
|
+
// VAT of the ticked lines, under the VAT header.
|
|
1232
|
+
footer: () => /* @__PURE__ */ r(Vi, { currency: e.currency })
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
id: "adjustment",
|
|
1236
|
+
header: t("billLineTable.column.adjustment", "Discount or surcharge"),
|
|
1237
|
+
align: "end",
|
|
1238
|
+
cell: (i) => xi(i, e),
|
|
1239
|
+
exportValue: (i) => i.line.adjustments.map(
|
|
1240
|
+
(a) => `${a.type === "discount" ? "-" : "+"}${a.percent !== null ? `${a.percent}%` : a.amount ?? ""}`
|
|
1241
|
+
).join(", ") || null,
|
|
1242
|
+
size: 128,
|
|
1243
|
+
hideable: !1,
|
|
1244
|
+
reorderable: !1
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
id: "supplierCode",
|
|
1248
|
+
header: t("billLineTable.column.supplierCode", "Supplier code"),
|
|
1249
|
+
cell: (i) => i.line.supplierCode === null ? null : /* @__PURE__ */ r("span", { dir: "ltr", className: Ue(), children: i.line.supplierCode }),
|
|
1250
|
+
exportValue: (i) => i.line.supplierCode,
|
|
1251
|
+
size: 112,
|
|
1252
|
+
hideable: !1,
|
|
1253
|
+
reorderable: !1
|
|
1254
|
+
}
|
|
1255
|
+
];
|
|
1256
|
+
}
|
|
1257
|
+
function Ui(e) {
|
|
1258
|
+
return e.map(tn);
|
|
1259
|
+
}
|
|
1260
|
+
const Ut = {};
|
|
1261
|
+
function te(e, t) {
|
|
1262
|
+
return new Error(`${e}: ${t}`);
|
|
1263
|
+
}
|
|
1264
|
+
function Mi(e, t) {
|
|
1265
|
+
return e.length === t.length && e.every((n, i) => n === t[i]);
|
|
1266
|
+
}
|
|
1267
|
+
function Pi(e) {
|
|
1268
|
+
return JSON.stringify(e);
|
|
1269
|
+
}
|
|
1270
|
+
const Fi = In(function({
|
|
1271
|
+
lines: t,
|
|
1272
|
+
items: n,
|
|
1273
|
+
selectedItems: i,
|
|
1274
|
+
documentKind: a = "invoice",
|
|
1275
|
+
currency: c = "EUR",
|
|
1276
|
+
gridId: v,
|
|
1277
|
+
caption: I,
|
|
1278
|
+
invoice: y,
|
|
1279
|
+
values: T,
|
|
1280
|
+
defaultValues: _,
|
|
1281
|
+
onValuesChange: E,
|
|
1282
|
+
selection: M,
|
|
1283
|
+
defaultSelection: V,
|
|
1284
|
+
onSelectionChange: R,
|
|
1285
|
+
onSummaryChange: X,
|
|
1286
|
+
onItemQueryChange: B,
|
|
1287
|
+
itemsLoading: h = !1,
|
|
1288
|
+
status: P = "ready",
|
|
1289
|
+
error: N,
|
|
1290
|
+
readOnly: ae = !1,
|
|
1291
|
+
privacyMode: F = !1,
|
|
1292
|
+
height: Te = "fill",
|
|
1293
|
+
className: d,
|
|
1294
|
+
...K
|
|
1295
|
+
}, $) {
|
|
1296
|
+
const { t: f, i18n: Ie } = Pt("ui"), Z = Ie.language, Fe = k(null), Ne = ae !== !1, nn = k(/* @__PURE__ */ new Map()), re = w(() => {
|
|
1297
|
+
const l = nn.current;
|
|
1298
|
+
for (const u of i ?? []) l.set(u.id, u);
|
|
1299
|
+
for (const u of n) l.set(u.id, u);
|
|
1300
|
+
return new Map(l);
|
|
1301
|
+
}, [n, i]);
|
|
1302
|
+
je(() => {
|
|
1303
|
+
_n() && n.some((l) => l.id === se) && console.warn(
|
|
1304
|
+
`[BillLineTable] an item id equals "${se}", the value of the new-item option, so that item cannot be chosen.`
|
|
1305
|
+
);
|
|
1306
|
+
}, [n]);
|
|
1307
|
+
const lt = w(() => Ui(n), [n]), ot = w(
|
|
1308
|
+
() => new Set(n.map((l) => l.id)),
|
|
1309
|
+
[n]
|
|
1310
|
+
), [st, an] = _e(null), ct = B !== void 0, rn = w(
|
|
1311
|
+
() => ({
|
|
1312
|
+
itemOptions: lt,
|
|
1313
|
+
itemOptionIds: ot,
|
|
1314
|
+
serverSearch: ct,
|
|
1315
|
+
itemsLoading: h,
|
|
1316
|
+
searchingLineId: st
|
|
1317
|
+
}),
|
|
1318
|
+
[lt, ot, ct, h, st]
|
|
1319
|
+
), ut = T !== void 0, [ln, on] = _e(
|
|
1320
|
+
() => _ ?? Ut
|
|
1321
|
+
), S = T ?? ln, Ke = M !== void 0, [$e, dt] = _e(
|
|
1322
|
+
() => V ?? He(t)
|
|
1323
|
+
), [mt, sn] = _e(t);
|
|
1324
|
+
if (mt !== t && (sn(t), !Ke && V === void 0)) {
|
|
1325
|
+
const l = new Set(mt.map((m) => m.id)), u = He(t).filter(
|
|
1326
|
+
(m) => !l.has(m) && !$e.includes(m)
|
|
1327
|
+
);
|
|
1328
|
+
u.length > 0 && dt([...$e, ...u]);
|
|
1329
|
+
}
|
|
1330
|
+
const A = M ?? $e, Y = k(S);
|
|
1331
|
+
Y.current = S;
|
|
1332
|
+
const Q = k(A);
|
|
1333
|
+
Q.current = A;
|
|
1334
|
+
const ft = k(null), pt = k(null), we = w(
|
|
1335
|
+
() => ({
|
|
1336
|
+
values: _ ?? Ut,
|
|
1337
|
+
selection: V ?? He(t)
|
|
1338
|
+
}),
|
|
1339
|
+
[_, V, t]
|
|
1340
|
+
), ht = k(/* @__PURE__ */ new Map()), Ye = w(() => {
|
|
1341
|
+
const l = qt({
|
|
1342
|
+
lines: t,
|
|
1343
|
+
values: S,
|
|
1344
|
+
selection: A,
|
|
1345
|
+
findItem: (u) => re.get(u),
|
|
1346
|
+
previous: ht.current
|
|
1347
|
+
});
|
|
1348
|
+
return ht.current = new Map(l.map((u) => [u.line.id, u])), l;
|
|
1349
|
+
}, [t, S, A, re]), cn = w(
|
|
1350
|
+
() => Ye.filter((l) => l.selected).map((l) => l.line.id),
|
|
1351
|
+
[Ye]
|
|
1352
|
+
), yt = C(
|
|
1353
|
+
(l) => re.has(l),
|
|
1354
|
+
[re]
|
|
1355
|
+
), me = w(
|
|
1356
|
+
() => Ot(
|
|
1357
|
+
t,
|
|
1358
|
+
S,
|
|
1359
|
+
A,
|
|
1360
|
+
we,
|
|
1361
|
+
yt
|
|
1362
|
+
),
|
|
1363
|
+
[t, S, A, we, yt]
|
|
1364
|
+
), gt = w(
|
|
1365
|
+
() => new Map(t.map((l) => [l.id, l])),
|
|
1366
|
+
[t]
|
|
1367
|
+
), g = k({
|
|
1368
|
+
lines: t,
|
|
1369
|
+
lineById: gt,
|
|
1370
|
+
itemIndex: re,
|
|
1371
|
+
defaults: we,
|
|
1372
|
+
documentKind: a,
|
|
1373
|
+
tableReadOnly: Ne,
|
|
1374
|
+
valuesControlled: ut,
|
|
1375
|
+
selectionControlled: Ke
|
|
1376
|
+
});
|
|
1377
|
+
g.current = {
|
|
1378
|
+
lines: t,
|
|
1379
|
+
lineById: gt,
|
|
1380
|
+
itemIndex: re,
|
|
1381
|
+
defaults: we,
|
|
1382
|
+
documentKind: a,
|
|
1383
|
+
tableReadOnly: Ne,
|
|
1384
|
+
valuesControlled: ut,
|
|
1385
|
+
selectionControlled: Ke
|
|
1386
|
+
};
|
|
1387
|
+
const fe = k({
|
|
1388
|
+
onValuesChange: E,
|
|
1389
|
+
onSelectionChange: R,
|
|
1390
|
+
onSummaryChange: X,
|
|
1391
|
+
onItemQueryChange: B
|
|
1392
|
+
});
|
|
1393
|
+
fe.current = {
|
|
1394
|
+
onValuesChange: E,
|
|
1395
|
+
onSelectionChange: R,
|
|
1396
|
+
onSummaryChange: X,
|
|
1397
|
+
onItemQueryChange: B
|
|
1398
|
+
};
|
|
1399
|
+
const Qe = k(/* @__PURE__ */ new Set()), z = C((l) => {
|
|
1400
|
+
for (const u of [...Qe.current]) u(l);
|
|
1401
|
+
}, []), J = C(
|
|
1402
|
+
(l, u, m, L) => {
|
|
1403
|
+
var ee, xe;
|
|
1404
|
+
const O = g.current;
|
|
1405
|
+
if (!O.lineById.has(l)) return;
|
|
1406
|
+
const U = St(O.lines, Y.current), o = U[l], s = { ...o, ...m };
|
|
1407
|
+
if (Gt(o, s)) return;
|
|
1408
|
+
const x = {
|
|
1409
|
+
...U,
|
|
1410
|
+
[l]: s
|
|
1411
|
+
};
|
|
1412
|
+
Y.current = x, ft.current = x, O.valuesControlled || on(x), (xe = (ee = fe.current).onValuesChange) == null || xe.call(ee, x, { lineId: l, field: u, source: L }), z({ event: "values", source: L });
|
|
1413
|
+
},
|
|
1414
|
+
[z]
|
|
1415
|
+
), le = C(
|
|
1416
|
+
(l, u) => {
|
|
1417
|
+
var U, o;
|
|
1418
|
+
const m = g.current, L = W(m.lines, l), O = W(
|
|
1419
|
+
m.lines,
|
|
1420
|
+
Q.current
|
|
1421
|
+
);
|
|
1422
|
+
Mi(L, O) || (Q.current = L, pt.current = L, m.selectionControlled || dt(L), (o = (U = fe.current).onSelectionChange) == null || o.call(U, L), z({ event: "selection", source: u }));
|
|
1423
|
+
},
|
|
1424
|
+
[z]
|
|
1425
|
+
), Lt = C(
|
|
1426
|
+
(l, u) => J(l, "quantity", { quantity: u }, "user"),
|
|
1427
|
+
[J]
|
|
1428
|
+
), bt = C(
|
|
1429
|
+
(l, u) => {
|
|
1430
|
+
const m = g.current.lineById.get(l);
|
|
1431
|
+
m && J(
|
|
1432
|
+
l,
|
|
1433
|
+
"item",
|
|
1434
|
+
{ item: Ze(u, m) },
|
|
1435
|
+
"user"
|
|
1436
|
+
);
|
|
1437
|
+
},
|
|
1438
|
+
[J]
|
|
1439
|
+
), vt = C((l, u) => {
|
|
1440
|
+
var m, L;
|
|
1441
|
+
an(l), (L = (m = fe.current).onItemQueryChange) == null || L.call(m, l, u);
|
|
1442
|
+
}, []), un = C(
|
|
1443
|
+
(l) => le(l, "user"),
|
|
1444
|
+
[le]
|
|
1445
|
+
), Tt = k(null);
|
|
1446
|
+
je(() => {
|
|
1447
|
+
var u, m;
|
|
1448
|
+
const l = Pi(me);
|
|
1449
|
+
l !== Tt.current && (Tt.current = l, (m = (u = fe.current).onSummaryChange) == null || m.call(u, me));
|
|
1450
|
+
}, [me]);
|
|
1451
|
+
const ke = `${P}:${Ne ? "readOnly" : "editable"}`, It = k({
|
|
1452
|
+
lines: t,
|
|
1453
|
+
values: S,
|
|
1454
|
+
selection: A,
|
|
1455
|
+
status: ke
|
|
1456
|
+
});
|
|
1457
|
+
je(() => {
|
|
1458
|
+
const l = It.current;
|
|
1459
|
+
(l.lines !== t || l.values !== S && S !== ft.current) && z({ event: "values", source: "host" }), l.selection !== A && A !== pt.current && z({ event: "selection", source: "host" }), l.status !== ke && z({ event: "status", source: "host" }), It.current = {
|
|
1460
|
+
lines: t,
|
|
1461
|
+
values: S,
|
|
1462
|
+
selection: A,
|
|
1463
|
+
status: ke
|
|
1464
|
+
};
|
|
1465
|
+
}, [t, S, A, ke, z]);
|
|
1466
|
+
const ze = w(() => {
|
|
1467
|
+
const l = () => {
|
|
1468
|
+
const o = g.current;
|
|
1469
|
+
return qt({
|
|
1470
|
+
lines: o.lines,
|
|
1471
|
+
values: Y.current,
|
|
1472
|
+
selection: Q.current,
|
|
1473
|
+
findItem: (s) => o.itemIndex.get(s)
|
|
1474
|
+
});
|
|
1475
|
+
}, u = (o) => Li(o, {
|
|
1476
|
+
tableReadOnly: g.current.tableReadOnly,
|
|
1477
|
+
documentKind: g.current.documentKind
|
|
1478
|
+
}), m = (o) => g.current.itemIndex.has(o), L = (o) => {
|
|
1479
|
+
const s = g.current.lineById.get(o);
|
|
1480
|
+
if (!s) throw te("UNKNOWN_LINE", `no line "${o}".`);
|
|
1481
|
+
return s;
|
|
1482
|
+
}, O = () => {
|
|
1483
|
+
if (g.current.tableReadOnly)
|
|
1484
|
+
throw te(
|
|
1485
|
+
"TABLE_READ_ONLY",
|
|
1486
|
+
"the table is read-only while the load request runs."
|
|
1487
|
+
);
|
|
1488
|
+
}, U = (o) => {
|
|
1489
|
+
if (ie(g.current.lines))
|
|
1490
|
+
throw te(
|
|
1491
|
+
"LINE_READ_ONLY",
|
|
1492
|
+
`line "${o}" belongs to an invoice that is already loaded.`
|
|
1493
|
+
);
|
|
1494
|
+
};
|
|
1495
|
+
return {
|
|
1496
|
+
getLineIds: () => g.current.lines.map((o) => o.id),
|
|
1497
|
+
getLine: (o) => {
|
|
1498
|
+
const s = g.current, x = s.lineById.get(o);
|
|
1499
|
+
if (!x) return null;
|
|
1500
|
+
const ee = Jt(
|
|
1501
|
+
x,
|
|
1502
|
+
Y.current[o] ?? j(x),
|
|
1503
|
+
{
|
|
1504
|
+
invoiceLoaded: ie(s.lines),
|
|
1505
|
+
ticked: new Set(
|
|
1506
|
+
W(s.lines, Q.current)
|
|
1507
|
+
),
|
|
1508
|
+
findItem: (xe) => s.itemIndex.get(xe)
|
|
1509
|
+
}
|
|
1510
|
+
);
|
|
1511
|
+
return u(ee);
|
|
1512
|
+
},
|
|
1513
|
+
getLines: () => l().map(u),
|
|
1514
|
+
getSelection: () => W(g.current.lines, Q.current),
|
|
1515
|
+
getValues: () => St(g.current.lines, Y.current),
|
|
1516
|
+
getSummary: () => {
|
|
1517
|
+
const o = g.current;
|
|
1518
|
+
return Ot(
|
|
1519
|
+
o.lines,
|
|
1520
|
+
Y.current,
|
|
1521
|
+
Q.current,
|
|
1522
|
+
o.defaults,
|
|
1523
|
+
m
|
|
1524
|
+
);
|
|
1525
|
+
},
|
|
1526
|
+
getInvalidLineIds: () => l().filter((o) => o.invalid).map((o) => o.line.id),
|
|
1527
|
+
getLoadPayload: () => {
|
|
1528
|
+
const o = g.current;
|
|
1529
|
+
return hi(
|
|
1530
|
+
o.lines,
|
|
1531
|
+
Y.current,
|
|
1532
|
+
Q.current,
|
|
1533
|
+
o.documentKind,
|
|
1534
|
+
m
|
|
1535
|
+
);
|
|
1536
|
+
},
|
|
1537
|
+
setSelection: (o) => {
|
|
1538
|
+
for (const s of o) L(s);
|
|
1539
|
+
O();
|
|
1540
|
+
for (const s of o) {
|
|
1541
|
+
if (L(s).alreadyLoaded)
|
|
1542
|
+
throw te(
|
|
1543
|
+
"LINE_READ_ONLY",
|
|
1544
|
+
`line "${s}" is already loaded.`
|
|
1545
|
+
);
|
|
1546
|
+
U(s);
|
|
1547
|
+
}
|
|
1548
|
+
le(o, "api");
|
|
1549
|
+
},
|
|
1550
|
+
selectAll: () => {
|
|
1551
|
+
O(), le(
|
|
1552
|
+
g.current.lines.map((o) => o.id),
|
|
1553
|
+
"api"
|
|
1554
|
+
);
|
|
1555
|
+
},
|
|
1556
|
+
clearSelection: () => {
|
|
1557
|
+
O(), le([], "api");
|
|
1558
|
+
},
|
|
1559
|
+
setQuantity: (o, s) => {
|
|
1560
|
+
const x = L(o), ee = bi(s);
|
|
1561
|
+
if (ee === null)
|
|
1562
|
+
throw te(
|
|
1563
|
+
"INVALID_QUANTITY",
|
|
1564
|
+
`"${s}" is not a quantity above 0 and at most ${be}, with at most ${oe} decimal places.`
|
|
1565
|
+
);
|
|
1566
|
+
if (O(), U(o), !nt(x.quantity))
|
|
1567
|
+
throw te(
|
|
1568
|
+
"LINE_READ_ONLY",
|
|
1569
|
+
`line "${o}" has a quantity too large to edit; it loads as invoiced.`
|
|
1570
|
+
);
|
|
1571
|
+
J(o, "quantity", { quantity: ee }, "api");
|
|
1572
|
+
},
|
|
1573
|
+
setItem: (o, s) => {
|
|
1574
|
+
const x = L(o);
|
|
1575
|
+
if (s.kind === "existing" && (s.itemId === se || !m(s.itemId)))
|
|
1576
|
+
throw te("UNKNOWN_ITEM", `no item "${s.itemId}".`);
|
|
1577
|
+
O(), U(o), J(
|
|
1578
|
+
o,
|
|
1579
|
+
"item",
|
|
1580
|
+
{ item: Ze(s, x) },
|
|
1581
|
+
"api"
|
|
1582
|
+
);
|
|
1583
|
+
},
|
|
1584
|
+
focusLine: (o, s = "select") => {
|
|
1585
|
+
var x;
|
|
1586
|
+
L(o), (x = Fe.current) == null || x.focusRow(
|
|
1587
|
+
o,
|
|
1588
|
+
s === "select" ? void 0 : s
|
|
1589
|
+
);
|
|
1590
|
+
},
|
|
1591
|
+
scrollToLine: (o) => {
|
|
1592
|
+
var s;
|
|
1593
|
+
L(o), (s = Fe.current) == null || s.scrollToRow(o);
|
|
1594
|
+
},
|
|
1595
|
+
subscribe: (o) => (Qe.current.add(o), () => {
|
|
1596
|
+
Qe.current.delete(o);
|
|
1597
|
+
})
|
|
1598
|
+
};
|
|
1599
|
+
}, [le, J]);
|
|
1600
|
+
Nn($, () => ze, [ze]), kn(Qn, ze, v);
|
|
1601
|
+
const Nt = `${wn()}-status`, dn = w(
|
|
1602
|
+
() => Bi({
|
|
1603
|
+
t: f,
|
|
1604
|
+
language: Z,
|
|
1605
|
+
documentKind: a,
|
|
1606
|
+
currency: c,
|
|
1607
|
+
privacyMode: F,
|
|
1608
|
+
setQuantity: Lt,
|
|
1609
|
+
setItem: bt,
|
|
1610
|
+
queryItems: vt,
|
|
1611
|
+
statusIdPrefix: Nt
|
|
1612
|
+
}),
|
|
1613
|
+
[
|
|
1614
|
+
f,
|
|
1615
|
+
Z,
|
|
1616
|
+
a,
|
|
1617
|
+
c,
|
|
1618
|
+
F,
|
|
1619
|
+
Lt,
|
|
1620
|
+
bt,
|
|
1621
|
+
vt,
|
|
1622
|
+
Nt
|
|
1623
|
+
]
|
|
1624
|
+
), mn = C((l) => l.line.id, []), fn = C((l) => l.readOnly, []), pn = C(
|
|
1625
|
+
(l) => f("billLineTable.rowLabel", {
|
|
1626
|
+
number: q(l.line.lineNumber, Z),
|
|
1627
|
+
defaultValue: "Line {{number}}"
|
|
1628
|
+
}),
|
|
1629
|
+
[f, Z]
|
|
1630
|
+
), hn = C(
|
|
1631
|
+
(l) => l.line.alreadyLoaded ? {
|
|
1632
|
+
state: "none",
|
|
1633
|
+
reason: f(
|
|
1634
|
+
"billLineTable.selection.alreadyLoadedReason",
|
|
1635
|
+
"Already loaded into the warehouse"
|
|
1636
|
+
)
|
|
1637
|
+
} : l.readOnly ? {
|
|
1638
|
+
state: "none",
|
|
1639
|
+
reason: f(
|
|
1640
|
+
"billLineTable.selection.invoiceLoadedReason",
|
|
1641
|
+
"This invoice was already loaded. Lines left out then cannot be loaded later."
|
|
1642
|
+
)
|
|
1643
|
+
} : "selectable",
|
|
1644
|
+
[f]
|
|
1645
|
+
), yn = me.invoiceLoaded, We = Ne ? typeof ae == "object" && ae.reason !== "" && !F ? ae.reason : f(
|
|
1646
|
+
"billLineTable.selection.readOnlyReason",
|
|
1647
|
+
"Loading into the warehouse"
|
|
1648
|
+
) : yn ? f(
|
|
1649
|
+
"billLineTable.selection.invoiceLoadedReason",
|
|
1650
|
+
"This invoice was already loaded. Lines left out then cannot be loaded later."
|
|
1651
|
+
) : null, gn = w(
|
|
1652
|
+
() => We === null ? !1 : { reason: We },
|
|
1653
|
+
[We]
|
|
1654
|
+
), Ln = w(
|
|
1655
|
+
() => ({
|
|
1656
|
+
title: (N == null ? void 0 : N.title) ?? f("billLineTable.error.title", "The invoice lines could not be read"),
|
|
1657
|
+
description: (N == null ? void 0 : N.description) ?? f(
|
|
1658
|
+
"billLineTable.error.description",
|
|
1659
|
+
"Try again. If it keeps failing, open the invoice to check it."
|
|
1660
|
+
),
|
|
1661
|
+
onRetry: N == null ? void 0 : N.onRetry
|
|
1662
|
+
}),
|
|
1663
|
+
[N, f]
|
|
1664
|
+
), bn = w(
|
|
1665
|
+
() => ({
|
|
1666
|
+
title: f(
|
|
1667
|
+
"billLineTable.empty.title",
|
|
1668
|
+
"This invoice has no lines to load"
|
|
1669
|
+
),
|
|
1670
|
+
description: f(
|
|
1671
|
+
"billLineTable.empty.description",
|
|
1672
|
+
"Open the invoice to check what the supplier sent."
|
|
1673
|
+
)
|
|
1674
|
+
}),
|
|
1675
|
+
[f]
|
|
1676
|
+
), vn = I ?? (a === "creditNote" ? f("billLineTable.captionCreditNote", "Credit note lines") : f("billLineTable.caption", "Invoice lines"));
|
|
1677
|
+
return /* @__PURE__ */ p(
|
|
1678
|
+
"div",
|
|
1679
|
+
{
|
|
1680
|
+
...K,
|
|
1681
|
+
"data-component": "bill-line-table",
|
|
1682
|
+
"data-component-id": v,
|
|
1683
|
+
className: zn({ height: Te, className: d }),
|
|
1684
|
+
children: [
|
|
1685
|
+
y ? /* @__PURE__ */ r(
|
|
1686
|
+
ii,
|
|
1687
|
+
{
|
|
1688
|
+
invoice: y,
|
|
1689
|
+
privacyMode: F
|
|
1690
|
+
}
|
|
1691
|
+
) : null,
|
|
1692
|
+
/* @__PURE__ */ r(en.Provider, { value: rn, children: /* @__PURE__ */ r(ve.Provider, { value: me, children: /* @__PURE__ */ r(
|
|
1693
|
+
xn,
|
|
1694
|
+
{
|
|
1695
|
+
ref: Fe,
|
|
1696
|
+
caption: vn,
|
|
1697
|
+
columns: dn,
|
|
1698
|
+
rows: Ye,
|
|
1699
|
+
getRowId: mn,
|
|
1700
|
+
registerAgent: !1,
|
|
1701
|
+
persistColumnState: !1,
|
|
1702
|
+
dataMode: "client",
|
|
1703
|
+
selectionMode: "multiple",
|
|
1704
|
+
rowSelection: cn,
|
|
1705
|
+
onRowSelectionChange: un,
|
|
1706
|
+
getRowSelectability: hn,
|
|
1707
|
+
selectAllScope: "all",
|
|
1708
|
+
rangeSelection: !0,
|
|
1709
|
+
isRowReadOnly: fn,
|
|
1710
|
+
readOnly: gn,
|
|
1711
|
+
getRowLabel: pn,
|
|
1712
|
+
rowLabelPrivacySafe: !0,
|
|
1713
|
+
hostTextPrivacySafe: !0,
|
|
1714
|
+
multiSort: !1,
|
|
1715
|
+
columnResizing: !1,
|
|
1716
|
+
responsiveColumns: !1,
|
|
1717
|
+
status: P,
|
|
1718
|
+
error: Ln,
|
|
1719
|
+
empty: bn,
|
|
1720
|
+
density: "default",
|
|
1721
|
+
height: Te,
|
|
1722
|
+
virtualization: "auto",
|
|
1723
|
+
privacyMode: F
|
|
1724
|
+
}
|
|
1725
|
+
) }) })
|
|
1726
|
+
]
|
|
1727
|
+
}
|
|
1728
|
+
);
|
|
1729
|
+
});
|
|
1730
|
+
Fi.displayName = "BillLineTable";
|
|
1731
|
+
export {
|
|
1732
|
+
Ct as B,
|
|
1733
|
+
be as a,
|
|
1734
|
+
se as b,
|
|
1735
|
+
ai as c,
|
|
1736
|
+
Re as d,
|
|
1737
|
+
oe as e,
|
|
1738
|
+
$t as f,
|
|
1739
|
+
Fi as g,
|
|
1740
|
+
Qn as h,
|
|
1741
|
+
hi as i,
|
|
1742
|
+
mi as j,
|
|
1743
|
+
He as k,
|
|
1744
|
+
j as l,
|
|
1745
|
+
da as m,
|
|
1746
|
+
fi as n,
|
|
1747
|
+
ie as o,
|
|
1748
|
+
at as p,
|
|
1749
|
+
it as q,
|
|
1750
|
+
nt as r,
|
|
1751
|
+
oi as s,
|
|
1752
|
+
Ot as t
|
|
1753
|
+
};
|
|
1754
|
+
//# sourceMappingURL=bill-line-table-DUMEHnQ4.js.map
|