@alfadocs/ui-kit-debug 1.130.2 → 1.131.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/_chunks/bill-line-table-DHKb_O7c.js +2000 -0
  2. package/dist/_chunks/bill-line-table-DHKb_O7c.js.map +1 -0
  3. package/dist/_chunks/{data-grid-C9xlUMLt.js → data-grid-B2oaI7Lt.js} +2345 -2328
  4. package/dist/_chunks/data-grid-B2oaI7Lt.js.map +1 -0
  5. package/dist/_chunks/{default-tabs-BryvhiHv.js → default-tabs-DbebYO04.js} +3 -3
  6. package/dist/_chunks/{default-tabs-BryvhiHv.js.map → default-tabs-DbebYO04.js.map} +1 -1
  7. package/dist/_chunks/{invoice-upload-list-868v1oDe.js → invoice-upload-list-B5aMffTy.js} +21 -21
  8. package/dist/_chunks/{invoice-upload-list-868v1oDe.js.map → invoice-upload-list-B5aMffTy.js.map} +1 -1
  9. package/dist/_chunks/{toolbar-BK6S9PhI.js → toolbar-CfdoJzMV.js} +2 -2
  10. package/dist/_chunks/{toolbar-BK6S9PhI.js.map → toolbar-CfdoJzMV.js.map} +1 -1
  11. package/dist/_chunks/{warehouse-load-summary-DkAKXcw0.js → warehouse-load-summary-CMMYzTDv.js} +75 -66
  12. package/dist/_chunks/warehouse-load-summary-CMMYzTDv.js.map +1 -0
  13. package/dist/agent-catalog.json +10 -10
  14. package/dist/agent-i18n/en.json +3 -3
  15. package/dist/browser-support.js +1 -1
  16. package/dist/components/_shared/decimal.d.ts +2 -0
  17. package/dist/components/_shared/decimal.d.ts.map +1 -1
  18. package/dist/components/bill-line-table/bill-line-table.agent.d.ts.map +1 -1
  19. package/dist/components/bill-line-table/bill-line-table.columns.d.ts +4 -0
  20. package/dist/components/bill-line-table/bill-line-table.columns.d.ts.map +1 -1
  21. package/dist/components/bill-line-table/bill-line-table.d.ts.map +1 -1
  22. package/dist/components/bill-line-table/bill-line-table.header.d.ts +6 -0
  23. package/dist/components/bill-line-table/bill-line-table.header.d.ts.map +1 -1
  24. package/dist/components/bill-line-table/bill-line-table.invoice-cell.d.ts +6 -0
  25. package/dist/components/bill-line-table/bill-line-table.invoice-cell.d.ts.map +1 -0
  26. package/dist/components/bill-line-table/bill-line-table.model.d.ts +23 -10
  27. package/dist/components/bill-line-table/bill-line-table.model.d.ts.map +1 -1
  28. package/dist/components/bill-line-table/bill-line-table.scope.d.ts +56 -0
  29. package/dist/components/bill-line-table/bill-line-table.scope.d.ts.map +1 -0
  30. package/dist/components/bill-line-table/bill-line-table.types.d.ts +90 -10
  31. package/dist/components/bill-line-table/bill-line-table.types.d.ts.map +1 -1
  32. package/dist/components/bill-line-table/bill-line-table.variants.d.ts +2 -0
  33. package/dist/components/bill-line-table/bill-line-table.variants.d.ts.map +1 -1
  34. package/dist/components/bill-line-table/index.d.ts +3 -2
  35. package/dist/components/bill-line-table/index.d.ts.map +1 -1
  36. package/dist/components/bill-line-table/index.js +20 -18
  37. package/dist/components/bill-table/index.js +1 -1
  38. package/dist/components/data-grid/body.d.ts.map +1 -1
  39. package/dist/components/data-grid/data-grid.d.ts.map +1 -1
  40. package/dist/components/data-grid/data-grid.variants.d.ts.map +1 -1
  41. package/dist/components/data-grid/index.js +2 -2
  42. package/dist/components/data-grid/types.d.ts +6 -0
  43. package/dist/components/data-grid/types.d.ts.map +1 -1
  44. package/dist/components/data-grid/use-data-grid-engine.d.ts.map +1 -1
  45. package/dist/components/invoice-upload-list/index.js +1 -1
  46. package/dist/components/invoice-upload-list/invoice-upload-list.d.ts.map +1 -1
  47. package/dist/components/warehouse-load-summary/index.js +1 -1
  48. package/dist/components/warehouse-load-summary/warehouse-load-summary.d.ts.map +1 -1
  49. package/dist/core.css +1 -1
  50. package/dist/decimal/index.js +32 -28
  51. package/dist/decimal/index.js.map +1 -1
  52. package/dist/host-compat.css +4 -1
  53. package/dist/index.js +1060 -1058
  54. package/dist/tokens.css +1 -1
  55. package/package.json +1 -1
  56. package/dist/_chunks/bill-line-table-CzYzg-Qh.js +0 -1757
  57. package/dist/_chunks/bill-line-table-CzYzg-Qh.js.map +0 -1
  58. package/dist/_chunks/data-grid-C9xlUMLt.js.map +0 -1
  59. package/dist/_chunks/warehouse-load-summary-DkAKXcw0.js.map +0 -1
@@ -1,1757 +0,0 @@
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-C9xlUMLt.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
- // 112 px of text: "EENHEIDSPRIJS" (nl) is the longest word.
1219
- size: 144,
1220
- hideable: !1,
1221
- reorderable: !1
1222
- },
1223
- {
1224
- id: "vat",
1225
- header: t("billLineTable.column.vat", "VAT"),
1226
- align: "end",
1227
- cell: (i) => Ei(i, e),
1228
- exportValue: (i) => i.line.vatPercent,
1229
- size: 88,
1230
- hideable: !1,
1231
- reorderable: !1,
1232
- // VAT of the ticked lines, under the VAT header.
1233
- footer: () => /* @__PURE__ */ r(Vi, { currency: e.currency })
1234
- },
1235
- {
1236
- id: "adjustment",
1237
- header: t("billLineTable.column.adjustment", "Discount or surcharge"),
1238
- align: "end",
1239
- cell: (i) => xi(i, e),
1240
- exportValue: (i) => i.line.adjustments.map(
1241
- (a) => `${a.type === "discount" ? "-" : "+"}${a.percent !== null ? `${a.percent}%` : a.amount ?? ""}`
1242
- ).join(", ") || null,
1243
- // 112 px of text: "MAGGIORAZIONE" (it) is the longest word.
1244
- size: 144,
1245
- hideable: !1,
1246
- reorderable: !1
1247
- },
1248
- {
1249
- id: "supplierCode",
1250
- header: t("billLineTable.column.supplierCode", "Supplier code"),
1251
- cell: (i) => i.line.supplierCode === null ? null : /* @__PURE__ */ r("span", { dir: "ltr", className: Ue(), children: i.line.supplierCode }),
1252
- exportValue: (i) => i.line.supplierCode,
1253
- // 136 px of text: "LEVERANCIERSCODE" (nl) is the longest word.
1254
- size: 168,
1255
- hideable: !1,
1256
- reorderable: !1
1257
- }
1258
- ];
1259
- }
1260
- function Ui(e) {
1261
- return e.map(tn);
1262
- }
1263
- const Ut = {};
1264
- function te(e, t) {
1265
- return new Error(`${e}: ${t}`);
1266
- }
1267
- function Mi(e, t) {
1268
- return e.length === t.length && e.every((n, i) => n === t[i]);
1269
- }
1270
- function Pi(e) {
1271
- return JSON.stringify(e);
1272
- }
1273
- const Fi = In(function({
1274
- lines: t,
1275
- items: n,
1276
- selectedItems: i,
1277
- documentKind: a = "invoice",
1278
- currency: c = "EUR",
1279
- gridId: v,
1280
- caption: I,
1281
- invoice: y,
1282
- values: T,
1283
- defaultValues: _,
1284
- onValuesChange: E,
1285
- selection: M,
1286
- defaultSelection: V,
1287
- onSelectionChange: R,
1288
- onSummaryChange: X,
1289
- onItemQueryChange: B,
1290
- itemsLoading: h = !1,
1291
- status: P = "ready",
1292
- error: N,
1293
- readOnly: ae = !1,
1294
- privacyMode: F = !1,
1295
- height: Te = "fill",
1296
- className: d,
1297
- ...K
1298
- }, $) {
1299
- const { t: f, i18n: Ie } = Pt("ui"), Z = Ie.language, Fe = k(null), Ne = ae !== !1, nn = k(/* @__PURE__ */ new Map()), re = w(() => {
1300
- const l = nn.current;
1301
- for (const u of i ?? []) l.set(u.id, u);
1302
- for (const u of n) l.set(u.id, u);
1303
- return new Map(l);
1304
- }, [n, i]);
1305
- je(() => {
1306
- _n() && n.some((l) => l.id === se) && console.warn(
1307
- `[BillLineTable] an item id equals "${se}", the value of the new-item option, so that item cannot be chosen.`
1308
- );
1309
- }, [n]);
1310
- const lt = w(() => Ui(n), [n]), ot = w(
1311
- () => new Set(n.map((l) => l.id)),
1312
- [n]
1313
- ), [st, an] = _e(null), ct = B !== void 0, rn = w(
1314
- () => ({
1315
- itemOptions: lt,
1316
- itemOptionIds: ot,
1317
- serverSearch: ct,
1318
- itemsLoading: h,
1319
- searchingLineId: st
1320
- }),
1321
- [lt, ot, ct, h, st]
1322
- ), ut = T !== void 0, [ln, on] = _e(
1323
- () => _ ?? Ut
1324
- ), S = T ?? ln, Ke = M !== void 0, [$e, dt] = _e(
1325
- () => V ?? He(t)
1326
- ), [mt, sn] = _e(t);
1327
- if (mt !== t && (sn(t), !Ke && V === void 0)) {
1328
- const l = new Set(mt.map((m) => m.id)), u = He(t).filter(
1329
- (m) => !l.has(m) && !$e.includes(m)
1330
- );
1331
- u.length > 0 && dt([...$e, ...u]);
1332
- }
1333
- const A = M ?? $e, Y = k(S);
1334
- Y.current = S;
1335
- const Q = k(A);
1336
- Q.current = A;
1337
- const ft = k(null), pt = k(null), we = w(
1338
- () => ({
1339
- values: _ ?? Ut,
1340
- selection: V ?? He(t)
1341
- }),
1342
- [_, V, t]
1343
- ), ht = k(/* @__PURE__ */ new Map()), Ye = w(() => {
1344
- const l = qt({
1345
- lines: t,
1346
- values: S,
1347
- selection: A,
1348
- findItem: (u) => re.get(u),
1349
- previous: ht.current
1350
- });
1351
- return ht.current = new Map(l.map((u) => [u.line.id, u])), l;
1352
- }, [t, S, A, re]), cn = w(
1353
- () => Ye.filter((l) => l.selected).map((l) => l.line.id),
1354
- [Ye]
1355
- ), yt = C(
1356
- (l) => re.has(l),
1357
- [re]
1358
- ), me = w(
1359
- () => Ot(
1360
- t,
1361
- S,
1362
- A,
1363
- we,
1364
- yt
1365
- ),
1366
- [t, S, A, we, yt]
1367
- ), gt = w(
1368
- () => new Map(t.map((l) => [l.id, l])),
1369
- [t]
1370
- ), g = k({
1371
- lines: t,
1372
- lineById: gt,
1373
- itemIndex: re,
1374
- defaults: we,
1375
- documentKind: a,
1376
- tableReadOnly: Ne,
1377
- valuesControlled: ut,
1378
- selectionControlled: Ke
1379
- });
1380
- g.current = {
1381
- lines: t,
1382
- lineById: gt,
1383
- itemIndex: re,
1384
- defaults: we,
1385
- documentKind: a,
1386
- tableReadOnly: Ne,
1387
- valuesControlled: ut,
1388
- selectionControlled: Ke
1389
- };
1390
- const fe = k({
1391
- onValuesChange: E,
1392
- onSelectionChange: R,
1393
- onSummaryChange: X,
1394
- onItemQueryChange: B
1395
- });
1396
- fe.current = {
1397
- onValuesChange: E,
1398
- onSelectionChange: R,
1399
- onSummaryChange: X,
1400
- onItemQueryChange: B
1401
- };
1402
- const Qe = k(/* @__PURE__ */ new Set()), z = C((l) => {
1403
- for (const u of [...Qe.current]) u(l);
1404
- }, []), J = C(
1405
- (l, u, m, L) => {
1406
- var ee, xe;
1407
- const O = g.current;
1408
- if (!O.lineById.has(l)) return;
1409
- const U = St(O.lines, Y.current), o = U[l], s = { ...o, ...m };
1410
- if (Gt(o, s)) return;
1411
- const x = {
1412
- ...U,
1413
- [l]: s
1414
- };
1415
- 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 });
1416
- },
1417
- [z]
1418
- ), le = C(
1419
- (l, u) => {
1420
- var U, o;
1421
- const m = g.current, L = W(m.lines, l), O = W(
1422
- m.lines,
1423
- Q.current
1424
- );
1425
- 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 }));
1426
- },
1427
- [z]
1428
- ), Lt = C(
1429
- (l, u) => J(l, "quantity", { quantity: u }, "user"),
1430
- [J]
1431
- ), bt = C(
1432
- (l, u) => {
1433
- const m = g.current.lineById.get(l);
1434
- m && J(
1435
- l,
1436
- "item",
1437
- { item: Ze(u, m) },
1438
- "user"
1439
- );
1440
- },
1441
- [J]
1442
- ), vt = C((l, u) => {
1443
- var m, L;
1444
- an(l), (L = (m = fe.current).onItemQueryChange) == null || L.call(m, l, u);
1445
- }, []), un = C(
1446
- (l) => le(l, "user"),
1447
- [le]
1448
- ), Tt = k(null);
1449
- je(() => {
1450
- var u, m;
1451
- const l = Pi(me);
1452
- l !== Tt.current && (Tt.current = l, (m = (u = fe.current).onSummaryChange) == null || m.call(u, me));
1453
- }, [me]);
1454
- const ke = `${P}:${Ne ? "readOnly" : "editable"}`, It = k({
1455
- lines: t,
1456
- values: S,
1457
- selection: A,
1458
- status: ke
1459
- });
1460
- je(() => {
1461
- const l = It.current;
1462
- (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 = {
1463
- lines: t,
1464
- values: S,
1465
- selection: A,
1466
- status: ke
1467
- };
1468
- }, [t, S, A, ke, z]);
1469
- const ze = w(() => {
1470
- const l = () => {
1471
- const o = g.current;
1472
- return qt({
1473
- lines: o.lines,
1474
- values: Y.current,
1475
- selection: Q.current,
1476
- findItem: (s) => o.itemIndex.get(s)
1477
- });
1478
- }, u = (o) => Li(o, {
1479
- tableReadOnly: g.current.tableReadOnly,
1480
- documentKind: g.current.documentKind
1481
- }), m = (o) => g.current.itemIndex.has(o), L = (o) => {
1482
- const s = g.current.lineById.get(o);
1483
- if (!s) throw te("UNKNOWN_LINE", `no line "${o}".`);
1484
- return s;
1485
- }, O = () => {
1486
- if (g.current.tableReadOnly)
1487
- throw te(
1488
- "TABLE_READ_ONLY",
1489
- "the table is read-only while the load request runs."
1490
- );
1491
- }, U = (o) => {
1492
- if (ie(g.current.lines))
1493
- throw te(
1494
- "LINE_READ_ONLY",
1495
- `line "${o}" belongs to an invoice that is already loaded.`
1496
- );
1497
- };
1498
- return {
1499
- getLineIds: () => g.current.lines.map((o) => o.id),
1500
- getLine: (o) => {
1501
- const s = g.current, x = s.lineById.get(o);
1502
- if (!x) return null;
1503
- const ee = Jt(
1504
- x,
1505
- Y.current[o] ?? j(x),
1506
- {
1507
- invoiceLoaded: ie(s.lines),
1508
- ticked: new Set(
1509
- W(s.lines, Q.current)
1510
- ),
1511
- findItem: (xe) => s.itemIndex.get(xe)
1512
- }
1513
- );
1514
- return u(ee);
1515
- },
1516
- getLines: () => l().map(u),
1517
- getSelection: () => W(g.current.lines, Q.current),
1518
- getValues: () => St(g.current.lines, Y.current),
1519
- getSummary: () => {
1520
- const o = g.current;
1521
- return Ot(
1522
- o.lines,
1523
- Y.current,
1524
- Q.current,
1525
- o.defaults,
1526
- m
1527
- );
1528
- },
1529
- getInvalidLineIds: () => l().filter((o) => o.invalid).map((o) => o.line.id),
1530
- getLoadPayload: () => {
1531
- const o = g.current;
1532
- return hi(
1533
- o.lines,
1534
- Y.current,
1535
- Q.current,
1536
- o.documentKind,
1537
- m
1538
- );
1539
- },
1540
- setSelection: (o) => {
1541
- for (const s of o) L(s);
1542
- O();
1543
- for (const s of o) {
1544
- if (L(s).alreadyLoaded)
1545
- throw te(
1546
- "LINE_READ_ONLY",
1547
- `line "${s}" is already loaded.`
1548
- );
1549
- U(s);
1550
- }
1551
- le(o, "api");
1552
- },
1553
- selectAll: () => {
1554
- O(), le(
1555
- g.current.lines.map((o) => o.id),
1556
- "api"
1557
- );
1558
- },
1559
- clearSelection: () => {
1560
- O(), le([], "api");
1561
- },
1562
- setQuantity: (o, s) => {
1563
- const x = L(o), ee = bi(s);
1564
- if (ee === null)
1565
- throw te(
1566
- "INVALID_QUANTITY",
1567
- `"${s}" is not a quantity above 0 and at most ${be}, with at most ${oe} decimal places.`
1568
- );
1569
- if (O(), U(o), !nt(x.quantity))
1570
- throw te(
1571
- "LINE_READ_ONLY",
1572
- `line "${o}" has a quantity too large to edit; it loads as invoiced.`
1573
- );
1574
- J(o, "quantity", { quantity: ee }, "api");
1575
- },
1576
- setItem: (o, s) => {
1577
- const x = L(o);
1578
- if (s.kind === "existing" && (s.itemId === se || !m(s.itemId)))
1579
- throw te("UNKNOWN_ITEM", `no item "${s.itemId}".`);
1580
- O(), U(o), J(
1581
- o,
1582
- "item",
1583
- { item: Ze(s, x) },
1584
- "api"
1585
- );
1586
- },
1587
- focusLine: (o, s = "select") => {
1588
- var x;
1589
- L(o), (x = Fe.current) == null || x.focusRow(
1590
- o,
1591
- s === "select" ? void 0 : s
1592
- );
1593
- },
1594
- scrollToLine: (o) => {
1595
- var s;
1596
- L(o), (s = Fe.current) == null || s.scrollToRow(o);
1597
- },
1598
- subscribe: (o) => (Qe.current.add(o), () => {
1599
- Qe.current.delete(o);
1600
- })
1601
- };
1602
- }, [le, J]);
1603
- Nn($, () => ze, [ze]), kn(Qn, ze, v);
1604
- const Nt = `${wn()}-status`, dn = w(
1605
- () => Bi({
1606
- t: f,
1607
- language: Z,
1608
- documentKind: a,
1609
- currency: c,
1610
- privacyMode: F,
1611
- setQuantity: Lt,
1612
- setItem: bt,
1613
- queryItems: vt,
1614
- statusIdPrefix: Nt
1615
- }),
1616
- [
1617
- f,
1618
- Z,
1619
- a,
1620
- c,
1621
- F,
1622
- Lt,
1623
- bt,
1624
- vt,
1625
- Nt
1626
- ]
1627
- ), mn = C((l) => l.line.id, []), fn = C((l) => l.readOnly, []), pn = C(
1628
- (l) => f("billLineTable.rowLabel", {
1629
- number: q(l.line.lineNumber, Z),
1630
- defaultValue: "Line {{number}}"
1631
- }),
1632
- [f, Z]
1633
- ), hn = C(
1634
- (l) => l.line.alreadyLoaded ? {
1635
- state: "none",
1636
- reason: f(
1637
- "billLineTable.selection.alreadyLoadedReason",
1638
- "Already loaded into the warehouse"
1639
- )
1640
- } : l.readOnly ? {
1641
- state: "none",
1642
- reason: f(
1643
- "billLineTable.selection.invoiceLoadedReason",
1644
- "This invoice was already loaded. Lines left out then cannot be loaded later."
1645
- )
1646
- } : "selectable",
1647
- [f]
1648
- ), yn = me.invoiceLoaded, We = Ne ? typeof ae == "object" && ae.reason !== "" && !F ? ae.reason : f(
1649
- "billLineTable.selection.readOnlyReason",
1650
- "Loading into the warehouse"
1651
- ) : yn ? f(
1652
- "billLineTable.selection.invoiceLoadedReason",
1653
- "This invoice was already loaded. Lines left out then cannot be loaded later."
1654
- ) : null, gn = w(
1655
- () => We === null ? !1 : { reason: We },
1656
- [We]
1657
- ), Ln = w(
1658
- () => ({
1659
- title: (N == null ? void 0 : N.title) ?? f("billLineTable.error.title", "The invoice lines could not be read"),
1660
- description: (N == null ? void 0 : N.description) ?? f(
1661
- "billLineTable.error.description",
1662
- "Try again. If it keeps failing, open the invoice to check it."
1663
- ),
1664
- onRetry: N == null ? void 0 : N.onRetry
1665
- }),
1666
- [N, f]
1667
- ), bn = w(
1668
- () => ({
1669
- title: f(
1670
- "billLineTable.empty.title",
1671
- "This invoice has no lines to load"
1672
- ),
1673
- description: f(
1674
- "billLineTable.empty.description",
1675
- "Open the invoice to check what the supplier sent."
1676
- )
1677
- }),
1678
- [f]
1679
- ), vn = I ?? (a === "creditNote" ? f("billLineTable.captionCreditNote", "Credit note lines") : f("billLineTable.caption", "Invoice lines"));
1680
- return /* @__PURE__ */ p(
1681
- "div",
1682
- {
1683
- ...K,
1684
- "data-component": "bill-line-table",
1685
- "data-component-id": v,
1686
- className: zn({ height: Te, className: d }),
1687
- children: [
1688
- y ? /* @__PURE__ */ r(
1689
- ii,
1690
- {
1691
- invoice: y,
1692
- privacyMode: F
1693
- }
1694
- ) : null,
1695
- /* @__PURE__ */ r(en.Provider, { value: rn, children: /* @__PURE__ */ r(ve.Provider, { value: me, children: /* @__PURE__ */ r(
1696
- xn,
1697
- {
1698
- ref: Fe,
1699
- caption: vn,
1700
- columns: dn,
1701
- rows: Ye,
1702
- getRowId: mn,
1703
- registerAgent: !1,
1704
- persistColumnState: !1,
1705
- dataMode: "client",
1706
- selectionMode: "multiple",
1707
- rowSelection: cn,
1708
- onRowSelectionChange: un,
1709
- getRowSelectability: hn,
1710
- selectAllScope: "all",
1711
- rangeSelection: !0,
1712
- isRowReadOnly: fn,
1713
- readOnly: gn,
1714
- getRowLabel: pn,
1715
- rowLabelPrivacySafe: !0,
1716
- hostTextPrivacySafe: !0,
1717
- multiSort: !1,
1718
- columnResizing: !1,
1719
- responsiveColumns: !1,
1720
- status: P,
1721
- error: Ln,
1722
- empty: bn,
1723
- density: "default",
1724
- height: Te,
1725
- virtualization: "auto",
1726
- privacyMode: F
1727
- }
1728
- ) }) })
1729
- ]
1730
- }
1731
- );
1732
- });
1733
- Fi.displayName = "BillLineTable";
1734
- export {
1735
- Ct as B,
1736
- be as a,
1737
- se as b,
1738
- ai as c,
1739
- Re as d,
1740
- oe as e,
1741
- $t as f,
1742
- Fi as g,
1743
- Qn as h,
1744
- hi as i,
1745
- mi as j,
1746
- He as k,
1747
- j as l,
1748
- da as m,
1749
- fi as n,
1750
- ie as o,
1751
- at as p,
1752
- it as q,
1753
- nt as r,
1754
- oi as s,
1755
- Ot as t
1756
- };
1757
- //# sourceMappingURL=bill-line-table-CzYzg-Qh.js.map