@wisemen/wise-invoicing-web 0.0.0-alpha.1

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 (85) hide show
  1. package/dist/AddOpenBoundaryIcon-BEbt7idt.js +28 -0
  2. package/dist/AirlineIcon-CiRX64yU.js +31 -0
  3. package/dist/AirplaneIcon-ySlq4lyE.js +21 -0
  4. package/dist/AirportIcon-B84mgPeW.js +18 -0
  5. package/dist/AlertTriangleIcon-CBaygowk.js +24 -0
  6. package/dist/AllocationsIcon-BEq-KzFl.js +18 -0
  7. package/dist/ArrowNarrowRightIcon-CeV9G-PX.js +24 -0
  8. package/dist/AssetIcon-CgYKjgAv.js +18 -0
  9. package/dist/BarChartIcon-180sKdWD.js +24 -0
  10. package/dist/BellIcon-k_e3dHc9.js +23 -0
  11. package/dist/BillingDocumentDetailViewDataProvider.css +1 -0
  12. package/dist/BillingDocumentDetailViewDataProvider.vue_vue_type_script_setup_true_lang-CWKBYgXH.js +5161 -0
  13. package/dist/BuildingIcon-vsvoi83j.js +24 -0
  14. package/dist/ChargerIcon-Bp3Up7jS.js +18 -0
  15. package/dist/ChevronDownIcon-D9nXH3kA.js +24 -0
  16. package/dist/ChevronUpIcon-CkYZnNds.js +24 -0
  17. package/dist/ClockIcon-DltYwVJC.js +24 -0
  18. package/dist/ClockSnoozeIcon-x_plYT2B.js +24 -0
  19. package/dist/CopyIcon-DOqno1Gb.js +21 -0
  20. package/dist/CreditNoteDetailViewDataProvider-Dc_APzSS.js +873 -0
  21. package/dist/CreditNotePdfViewDataProvider-zdBDlMRD.js +36 -0
  22. package/dist/DownloadCloudIcon-CHztnC6f.js +24 -0
  23. package/dist/EditIcon-L73PCCiu.js +23 -0
  24. package/dist/EraserIcon-CRVRD-F9.js +24 -0
  25. package/dist/FileIcon-Fuwo_cD0.js +26 -0
  26. package/dist/FilterLinesIcon-CRaEthek.js +24 -0
  27. package/dist/GlobeIcon-UmFqS-_n.js +24 -0
  28. package/dist/HelpIcon-CyOF59jk.js +26 -0
  29. package/dist/HourGlassIcon-mbgmoOa_.js +24 -0
  30. package/dist/InfoCircleIcon-DdlwGcMV.js +24 -0
  31. package/dist/InvoiceDetailViewDataProvider-DeS1LPn1.js +1942 -0
  32. package/dist/InvoiceOverviewView-BELZjC4d.js +14297 -0
  33. package/dist/InvoicePdfViewDataProvider-CzzbJS9s.js +36 -0
  34. package/dist/InvoicePublicPdfViewDataProvider-B7fszuGq.js +4 -0
  35. package/dist/InvoiceSettlementStatusBadge.vue_vue_type_script_setup_true_lang-YngYVFcS.js +196 -0
  36. package/dist/IssuerSettingsViewDataProvider-CbKj-AK2.js +250 -0
  37. package/dist/KeyboardIcon-BYex7WoL.js +24 -0
  38. package/dist/LinkExternalIcon-QJt5WMfk.js +24 -0
  39. package/dist/LinkIcon-D9WPvO58.js +24 -0
  40. package/dist/MarkerIcon-Dacom7sa.js +31 -0
  41. package/dist/MobileBatteryIcon-i1TxVu66.js +18 -0
  42. package/dist/MonitorIcon-B6-by77x.js +24 -0
  43. package/dist/NotificationIcon-D5mgxQ3P.js +21 -0
  44. package/dist/ParkingIcon-DJzqSxFU.js +29 -0
  45. package/dist/PlanningIcon-Dj8UH1Cl.js +18 -0
  46. package/dist/PreferenceIcon-DrDfTl-0.js +24 -0
  47. package/dist/ReceiptCheckIcon-DfUkv_G6.js +24 -0
  48. package/dist/RefreshIcon-CykNw3qm.js +24 -0
  49. package/dist/RemoveOpenBoundaryIcon-8vTxISBg.js +31 -0
  50. package/dist/RewindIcon-K0KiISjE.js +24 -0
  51. package/dist/SettingsIcon-BA4bIP5a.js +28 -0
  52. package/dist/ShieldIcon-B6OfkWmr.js +21 -0
  53. package/dist/ShieldOffIcon-RppEweJ9.js +24 -0
  54. package/dist/SignOutIcon-C6x_Sv0W.js +23 -0
  55. package/dist/SlashCircleIcon-CbwLUV0p.js +24 -0
  56. package/dist/StandIcon-DW1SUHPC.js +24 -0
  57. package/dist/StarsIcon-I4S_hN5F.js +26 -0
  58. package/dist/StopwatchIcon-D8KogezG.js +24 -0
  59. package/dist/TargetIcon-DZL7Hi3v.js +24 -0
  60. package/dist/ThreeDotsIcon-CKO5p_ZD.js +32 -0
  61. package/dist/ToolIcon-Dbvw1D-H.js +24 -0
  62. package/dist/TrashIcon-02miWCrc.js +21 -0
  63. package/dist/TurnaroundIcon-Dee23oaX.js +30 -0
  64. package/dist/UploadCloudIcon-DhtpTfwc.js +24 -0
  65. package/dist/UserIcon-DbdAYeNN.js +24 -0
  66. package/dist/UsersIcon-CHaIEI5X.js +24 -0
  67. package/dist/VerifiedIcon-CTveuqDt.js +26 -0
  68. package/dist/WifiIcon-DHt-RpM2.js +24 -0
  69. package/dist/WifiOffIcon-D8xUKqLP.js +24 -0
  70. package/dist/ZapIcon-C95VuzXS.js +24 -0
  71. package/dist/ZoomInIcon-qDywyLfc.js +24 -0
  72. package/dist/ZoomOutIcon-KL3_B-6s.js +24 -0
  73. package/dist/_plugin-vue_export-helper-3S5xkc9H.js +453 -0
  74. package/dist/creditNoteDetail.query-JGvG5yYz.js +159 -0
  75. package/dist/formango.util-D66mMTWb.js +12 -0
  76. package/dist/index-Beg0OAsI.js +8082 -0
  77. package/dist/index-DCE3vzbe.js +7 -0
  78. package/dist/index.css +1 -0
  79. package/dist/index.d.ts +1608 -0
  80. package/dist/index.js +40 -0
  81. package/dist/invoiceDetail.query-C3Llz0nF.js +13 -0
  82. package/dist/issuerSettings.query-H83T7-h9.js +130 -0
  83. package/dist/style.css +1 -0
  84. package/dist/style.d.ts +1 -0
  85. package/package.json +103 -0
@@ -0,0 +1,1942 @@
1
+ import { openBlock as u, createElementBlock as K, createElementVNode as B, defineComponent as I, computed as c, createBlock as p, unref as e, withCtx as s, createVNode as o, Fragment as ae, renderList as Fe, ref as Te, watch as ci, createCommentVNode as k, mergeProps as A, createSlots as ri, toDisplayString as Me } from "vue";
2
+ import { useI18n as x } from "vue-i18n";
3
+ import { u as ui } from "./invoiceDetail.query-C3Llz0nF.js";
4
+ import { _ as ye, p as se, I as G, m as ve } from "./_plugin-vue_export-helper-3S5xkc9H.js";
5
+ import { UIBadge as V, UITooltip as di, UITooltipContent as vi, UIColumnLayout as Pe, UIText as q, useToast as z, UIFormDialog as le, UIDialogHeader as ce, UIDialogFooter as re, UIDialogFooterCancel as ue, UIDialogFooterSubmit as be, useOverlay as de, UIForm as Le, UIRowLayout as Y, UIDialogBody as we, UIFormFieldGroup as Ie, UIFormFieldGrid as xe, UIDateField as ne, UITextField as oe, UIDetailList as mi, UIDetailListGroup as me, UIDetailListGroupItem as $, UIDetailListGroupItemLabel as O, UIDetailListGroupItemValueText as j, UIIconButton as $e, UIDetailListGroupSeparator as Ce, UITableCell as De, UITableCellInteractiveElement as pi, defineTableColumns as _i, createComponent as J, UINumberField as fe, UIFormSubmitButton as fi, UIConfirmDialog as gi, UIBadgeLabel as Ee, UIBadgeSeparator as yi, UIButton as bi, UITable as wi, createSelectOptions as Ii, UISelect as xi } from "@wisemen/vue-core-design-system";
6
+ import { I as D, i as H, e as L, n as Di, j as ge, o as Ae, L as hi, p as qe, q as Ui, D as ki, r as Si, s as Ci, t as Ei, T as Ai, w as Fi, x as he, R as ze, u as X, y as Ti, z as Mi, E as Pi, B as Li, H as $i, U as qi, G as zi, J as pe, K as Re, M as Ri, C as Oe, N as Oi, O as N, Q as ji } from "./index-Beg0OAsI.js";
7
+ import { useForm as Q } from "formango";
8
+ import Ni, { z as w } from "zod";
9
+ import { _ as Bi, u as Vi, F as Ki, B as je, a as Ne, b as Gi, c as Hi, d as Qi, e as Zi, f as Wi, g as Ji, h as Yi, i as Be, j as Xi, k as et, l as it, m as tt, n as nt, o as ot, p as at, q as st, r as lt } from "./BillingDocumentDetailViewDataProvider.vue_vue_type_script_setup_true_lang-CWKBYgXH.js";
10
+ import { useMutation as S, useKeysetInfiniteQuery as ct, useQuery as rt } from "@wisemen/vue-core-api-utils";
11
+ import { Temporal as Ve } from "temporal-polyfill";
12
+ import { _ as ut, a as dt, C as vt } from "./InvoiceSettlementStatusBadge.vue_vue_type_script_setup_true_lang-YngYVFcS.js";
13
+ import { useRouter as Ke, RouterLink as mt } from "vue-router";
14
+ import { u as pt } from "./issuerSettings.query-H83T7-h9.js";
15
+ import { t as F } from "./formango.util-D66mMTWb.js";
16
+ const _t = {}, ft = {
17
+ width: "100%",
18
+ height: "100%",
19
+ viewBox: "0 0 24 24",
20
+ fill: "none",
21
+ xmlns: "http://www.w3.org/2000/svg"
22
+ };
23
+ function gt(i, t) {
24
+ return u(), K("svg", ft, [...t[0] || (t[0] = [
25
+ B("path", {
26
+ d: "M6 16C6 18.2091 7.79086 20 10 20H14C16.2091 20 18 18.2091 18 16C18 13.7909 16.2091 12 14 12H10C7.79086 12 6 10.2091 6 8C6 5.79086 7.79086 4 10 4H14C16.2091 4 18 5.79086 18 8M12 2V22",
27
+ stroke: "currentColor",
28
+ "stroke-width": "2",
29
+ "stroke-linecap": "round",
30
+ "stroke-linejoin": "round"
31
+ }, null, -1)
32
+ ])]);
33
+ }
34
+ const yt = /* @__PURE__ */ ye(_t, [["render", gt]]), bt = {}, wt = {
35
+ width: "100%",
36
+ height: "100%",
37
+ viewBox: "0 0 24 24",
38
+ fill: "none",
39
+ xmlns: "http://www.w3.org/2000/svg"
40
+ };
41
+ function It(i, t) {
42
+ return u(), K("svg", wt, [...t[0] || (t[0] = [
43
+ B("path", {
44
+ d: "M12 5V19M5 12H19",
45
+ stroke: "currentColor",
46
+ "stroke-width": "2",
47
+ "stroke-linecap": "round",
48
+ "stroke-linejoin": "round"
49
+ }, null, -1)
50
+ ])]);
51
+ }
52
+ const xt = /* @__PURE__ */ ye(bt, [["render", It]]), Dt = {}, ht = {
53
+ width: "100%",
54
+ height: "100%",
55
+ viewBox: "0 0 24 24",
56
+ fill: "none",
57
+ xmlns: "http://www.w3.org/2000/svg"
58
+ };
59
+ function Ut(i, t) {
60
+ return u(), K("svg", ht, [...t[0] || (t[0] = [
61
+ B("path", {
62
+ d: "M16 6V5.2C16 4.0799 16 3.51984 15.782 3.09202C15.5903 2.71569 15.2843 2.40973 14.908 2.21799C14.4802 2 13.9201 2 12.8 2H11.2C10.0799 2 9.51984 2 9.09202 2.21799C8.71569 2.40973 8.40973 2.71569 8.21799 3.09202C8 3.51984 8 4.0799 8 5.2V6M10 11.5V16.5M14 11.5V16.5M3 6H21M19 6V17.2C19 18.8802 19 19.7202 18.673 20.362C18.3854 20.9265 17.9265 21.3854 17.362 21.673C16.7202 22 15.8802 22 14.2 22H9.8C8.11984 22 7.27976 22 6.63803 21.673C6.07354 21.3854 5.6146 20.9265 5.32698 20.362C5 19.7202 5 18.8802 5 17.2V6",
63
+ stroke: "currentColor",
64
+ "stroke-width": "2",
65
+ "stroke-linecap": "round",
66
+ "stroke-linejoin": "round"
67
+ }, null, -1)
68
+ ])]);
69
+ }
70
+ const kt = /* @__PURE__ */ ye(Dt, [["render", Ut]]);
71
+ function Ue() {
72
+ return S({
73
+ queryFn: (i) => D.update(
74
+ i.params.invoiceUuid,
75
+ i.body
76
+ ),
77
+ queryKeysToInvalidate: {
78
+ invoiceDetail: {
79
+ invoiceUuid: (i) => i.invoiceUuid
80
+ },
81
+ invoiceIndex: {}
82
+ }
83
+ });
84
+ }
85
+ const St = {
86
+ [H.FAILED]: {
87
+ tone: "error",
88
+ translationKey: "wise_invoicing.invoice.delivery_status.failed"
89
+ },
90
+ [H.PROCESSING]: {
91
+ tone: "blue",
92
+ translationKey: "wise_invoicing.invoice.delivery_status.processing"
93
+ },
94
+ [H.SENT]: {
95
+ tone: "brand",
96
+ translationKey: "wise_invoicing.invoice.delivery_status.sent"
97
+ },
98
+ [H.UNSENT]: {
99
+ tone: "gray",
100
+ translationKey: "wise_invoicing.invoice.delivery_status.unsent"
101
+ },
102
+ [H.VIEWED]: {
103
+ tone: "success",
104
+ translationKey: "wise_invoicing.invoice.delivery_status.viewed"
105
+ }
106
+ };
107
+ class Ct {
108
+ static getMetadata(t) {
109
+ return St[t];
110
+ }
111
+ }
112
+ const Et = /* @__PURE__ */ I({
113
+ __name: "InvoiceDeliveryStatusBadge",
114
+ props: {
115
+ deliveryStatus: {},
116
+ size: { default: "sm" }
117
+ },
118
+ setup(i) {
119
+ const t = i, n = x(), l = c(
120
+ () => Ct.getMetadata(t.deliveryStatus)
121
+ ), a = c(() => n.t(l.value.translationKey));
122
+ return (m, d) => (u(), p(e(V), {
123
+ label: a.value,
124
+ color: l.value.tone,
125
+ size: t.size,
126
+ variant: "translucent"
127
+ }, null, 8, ["label", "color", "size"]));
128
+ }
129
+ }), At = /* @__PURE__ */ I({
130
+ __name: "InvoiceDisputedBadge",
131
+ props: {
132
+ size: { default: "sm" }
133
+ },
134
+ setup(i) {
135
+ const t = i, n = x(), l = c(() => n.t("wise_invoicing.invoice.status.disputed"));
136
+ return (a, m) => (u(), p(e(V), {
137
+ label: l.value,
138
+ size: t.size,
139
+ color: "warning",
140
+ variant: "translucent"
141
+ }, null, 8, ["label", "size"]));
142
+ }
143
+ }), Ft = /* @__PURE__ */ I({
144
+ __name: "InvoiceReminderBadge",
145
+ props: {
146
+ reminders: {},
147
+ size: { default: "sm" }
148
+ },
149
+ setup(i) {
150
+ const t = i, n = x(), l = se(), a = c(() => n.t("wise_invoicing.invoice.reminder.badge", {
151
+ count: t.reminders.length
152
+ }));
153
+ function m(d) {
154
+ return l.formatPlainDate(
155
+ d.toZonedDateTimeISO(Ve.Now.timeZoneId()).toPlainDate()
156
+ );
157
+ }
158
+ return (d, _) => (u(), p(e(di), {
159
+ "popover-side-offset": 8,
160
+ "popover-align": "start",
161
+ "popover-side": "bottom"
162
+ }, {
163
+ trigger: s(() => [
164
+ o(e(V), {
165
+ label: a.value,
166
+ size: t.size,
167
+ color: "gray",
168
+ variant: "translucent"
169
+ }, null, 8, ["label", "size"])
170
+ ]),
171
+ content: s(() => [
172
+ o(e(vi), null, {
173
+ default: s(() => [
174
+ o(e(Pe), {
175
+ gap: "xs",
176
+ class: "max-w-80"
177
+ }, {
178
+ default: s(() => [
179
+ (u(!0), K(ae, null, Fe(t.reminders, (f, v) => (u(), p(e(q), {
180
+ key: f.uuid,
181
+ text: e(n).t("wise_invoicing.invoice.reminder.tooltip_line", {
182
+ number: v + 1,
183
+ date: m(f.sentAt)
184
+ }),
185
+ class: "text-sm text-primary"
186
+ }, null, 8, ["text"]))), 128))
187
+ ]),
188
+ _: 1
189
+ })
190
+ ]),
191
+ _: 1
192
+ })
193
+ ]),
194
+ _: 1
195
+ }));
196
+ }
197
+ }), Tt = w.string().nullable(), Mt = w.object({
198
+ subject: Tt
199
+ });
200
+ function Pt() {
201
+ return S({
202
+ queryFn: (i) => D.createCreditNote(
203
+ i.params.invoiceUuid
204
+ ),
205
+ queryKeysToInvalidate: {
206
+ invoiceDetail: {
207
+ invoiceUuid: (i) => i.invoiceUuid
208
+ },
209
+ invoiceIndex: {}
210
+ }
211
+ });
212
+ }
213
+ function Lt() {
214
+ return S({
215
+ queryFn: (i) => D.duplicate(
216
+ i.params.invoiceUuid
217
+ ),
218
+ queryKeysToInvalidate: {
219
+ invoiceIndex: {}
220
+ }
221
+ });
222
+ }
223
+ function $t() {
224
+ return S({
225
+ queryFn: (i) => D.finalize(
226
+ i.params.invoiceUuid
227
+ ),
228
+ queryKeysToInvalidate: {
229
+ invoiceDetail: {
230
+ invoiceUuid: (i) => i.invoiceUuid
231
+ },
232
+ invoiceIndex: {}
233
+ }
234
+ });
235
+ }
236
+ function qt() {
237
+ return S({
238
+ queryFn: (i) => D.markAsDraft(
239
+ i.params.invoiceUuid
240
+ ),
241
+ queryKeysToInvalidate: {
242
+ invoiceDetail: {
243
+ invoiceUuid: (i) => i.invoiceUuid
244
+ },
245
+ invoiceIndex: {}
246
+ }
247
+ });
248
+ }
249
+ function zt() {
250
+ return S({
251
+ queryFn: (i) => D.markAsPaid(
252
+ i.params.invoiceUuid
253
+ ),
254
+ queryKeysToInvalidate: {
255
+ invoiceDetail: {
256
+ invoiceUuid: (i) => i.invoiceUuid
257
+ },
258
+ invoiceIndex: {}
259
+ }
260
+ });
261
+ }
262
+ function Rt() {
263
+ return S({
264
+ queryFn: (i) => D.markAsProtested(
265
+ i.params.invoiceUuid
266
+ ),
267
+ queryKeysToInvalidate: {
268
+ invoiceDetail: {
269
+ invoiceUuid: (i) => i.invoiceUuid
270
+ },
271
+ invoiceIndex: {}
272
+ }
273
+ });
274
+ }
275
+ function Ot() {
276
+ return S({
277
+ queryFn: (i) => D.markAsReady(
278
+ i.params.invoiceUuid
279
+ ),
280
+ queryKeysToInvalidate: {
281
+ invoiceDetail: {
282
+ invoiceUuid: (i) => i.invoiceUuid
283
+ },
284
+ invoiceIndex: {}
285
+ }
286
+ });
287
+ }
288
+ function jt() {
289
+ return S({
290
+ queryFn: (i) => D.send(
291
+ i.params.invoiceUuid
292
+ ),
293
+ queryKeysToInvalidate: {
294
+ invoiceDetail: {
295
+ invoiceUuid: (i) => i.invoiceUuid
296
+ },
297
+ invoiceIndex: {}
298
+ }
299
+ });
300
+ }
301
+ function Nt() {
302
+ return S({
303
+ queryFn: (i) => D.withdrawProtest(
304
+ i.params.invoiceUuid
305
+ ),
306
+ queryKeysToInvalidate: {
307
+ invoiceDetail: {
308
+ invoiceUuid: (i) => i.invoiceUuid
309
+ },
310
+ invoiceIndex: {}
311
+ }
312
+ });
313
+ }
314
+ function Bt() {
315
+ return S({
316
+ queryFn: (i) => D.delete(i.params.invoiceUuid),
317
+ queryKeysToInvalidate: {
318
+ invoiceIndex: {}
319
+ }
320
+ });
321
+ }
322
+ const Vt = /* @__PURE__ */ I({
323
+ __name: "InvoiceDeleteDialog",
324
+ props: {
325
+ invoice: {}
326
+ },
327
+ emits: ["close", "deleted"],
328
+ setup(i, { emit: t }) {
329
+ const n = i, l = t, a = x(), m = Ke(), d = z(), _ = Bt(), f = Q({
330
+ schema: Ni.object({}),
331
+ onSubmit: async () => {
332
+ const v = await _.execute({
333
+ params: {
334
+ invoiceUuid: n.invoice.uuid
335
+ }
336
+ });
337
+ if (v.isErr()) {
338
+ d.apiError(v.error);
339
+ return;
340
+ }
341
+ d.show({
342
+ message: a.t("wise_invoicing.invoice.delete.success_toast")
343
+ }), l("deleted"), l("close"), await m.push({
344
+ name: "invoicing-invoice-overview"
345
+ });
346
+ }
347
+ });
348
+ return (v, g) => (u(), p(e(le), {
349
+ form: e(f),
350
+ size: "xs",
351
+ onClose: g[0] || (g[0] = (h) => l("close"))
352
+ }, {
353
+ default: s(() => [
354
+ o(e(ce), {
355
+ title: e(a).t("wise_invoicing.invoice.delete.title"),
356
+ description: e(a).t("wise_invoicing.invoice.delete.description"),
357
+ "is-description-visible": !0
358
+ }, null, 8, ["title", "description"]),
359
+ o(e(re), null, {
360
+ right: s(() => [
361
+ o(e(ue), { label: "cancel" }),
362
+ o(e(be), {
363
+ "is-destructive": !0,
364
+ label: e(a).t("wise_invoicing.invoice.delete.submit_button")
365
+ }, null, 8, ["label"])
366
+ ]),
367
+ _: 1
368
+ })
369
+ ]),
370
+ _: 1
371
+ }, 8, ["form"]));
372
+ }
373
+ });
374
+ function Kt(i) {
375
+ const t = x(), n = z(), l = Ke(), a = de(), m = a.create(Vt), d = a.create(Bi), _ = jt(), f = Pt(), v = Lt(), g = $t(), h = qt(), T = zt(), M = Rt(), C = Ot(), U = Nt(), {
376
+ shouldSkipConfirmation: b
377
+ } = Vi(), y = Te(null), E = c(() => G.getMetadata(i.value.status)), P = c(() => y.value ?? i.value.isDisputed), Z = c(() => i.value.status !== L.DRAFT && i.value.status !== L.READY), ee = c(() => i.value.lifecycleStatus === Di.FINALIZED), He = c(() => (i.value.status === L.SENT || i.value.status === L.OVERDUE) && i.value.reminders.length < i.value.maxReminderCount);
378
+ function ie(r) {
379
+ return E.value.actions.includes(r);
380
+ }
381
+ ci(() => i.value.isDisputed, (r) => {
382
+ y.value === r && (y.value = null);
383
+ });
384
+ async function ke() {
385
+ const r = await g.execute({
386
+ params: {
387
+ invoiceUuid: i.value.uuid
388
+ }
389
+ });
390
+ return r.isErr() ? (n.apiError(r.error), !1) : (n.show({
391
+ message: t.t("wise_invoicing.invoice.finalize.success")
392
+ }), !0);
393
+ }
394
+ async function Qe() {
395
+ if (b.value) {
396
+ await ke();
397
+ return;
398
+ }
399
+ await d.open({
400
+ billingDocumentType: "invoice",
401
+ onConfirm: ke
402
+ });
403
+ }
404
+ async function Ze() {
405
+ const r = await C.execute({
406
+ params: {
407
+ invoiceUuid: i.value.uuid
408
+ }
409
+ });
410
+ if (r.isErr()) {
411
+ n.apiError(r.error);
412
+ return;
413
+ }
414
+ n.show({
415
+ message: t.t("wise_invoicing.invoice.mark_as_ready.success")
416
+ });
417
+ }
418
+ async function We() {
419
+ const r = await h.execute({
420
+ params: {
421
+ invoiceUuid: i.value.uuid
422
+ }
423
+ });
424
+ if (r.isErr()) {
425
+ n.apiError(r.error);
426
+ return;
427
+ }
428
+ n.show({
429
+ message: t.t("wise_invoicing.invoice.mark_as_draft.success")
430
+ });
431
+ }
432
+ async function Je() {
433
+ const r = await T.execute({
434
+ params: {
435
+ invoiceUuid: i.value.uuid
436
+ }
437
+ });
438
+ if (r.isErr()) {
439
+ n.apiError(r.error);
440
+ return;
441
+ }
442
+ n.show({
443
+ message: t.t("wise_invoicing.invoice.mark_as_paid.success")
444
+ });
445
+ }
446
+ async function Ye() {
447
+ y.value = !0;
448
+ const r = await M.execute({
449
+ params: {
450
+ invoiceUuid: i.value.uuid
451
+ }
452
+ });
453
+ if (r.isErr()) {
454
+ y.value = null, n.apiError(r.error);
455
+ return;
456
+ }
457
+ n.show({
458
+ message: t.t("wise_invoicing.invoice.mark_as_disputed.success")
459
+ });
460
+ }
461
+ async function Xe() {
462
+ y.value = !1;
463
+ const r = await U.execute({
464
+ params: {
465
+ invoiceUuid: i.value.uuid
466
+ }
467
+ });
468
+ if (r.isErr()) {
469
+ y.value = null, n.apiError(r.error);
470
+ return;
471
+ }
472
+ n.show({
473
+ message: t.t("wise_invoicing.invoice.withdraw_dispute.success")
474
+ });
475
+ }
476
+ async function ei() {
477
+ const r = await _.execute({
478
+ params: {
479
+ invoiceUuid: i.value.uuid
480
+ }
481
+ });
482
+ if (r.isErr()) {
483
+ n.apiError(r.error);
484
+ return;
485
+ }
486
+ n.show({
487
+ message: t.t("wise_invoicing.invoice.send.success")
488
+ });
489
+ }
490
+ async function ii() {
491
+ const r = await _.execute({
492
+ params: {
493
+ invoiceUuid: i.value.uuid
494
+ }
495
+ });
496
+ if (r.isErr()) {
497
+ n.apiError(r.error);
498
+ return;
499
+ }
500
+ n.show({
501
+ message: t.t("wise_invoicing.invoice.reminder.success")
502
+ });
503
+ }
504
+ async function ti() {
505
+ await m.open({
506
+ invoice: i.value
507
+ });
508
+ }
509
+ async function ni() {
510
+ const r = await D.getByUuid(i.value.uuid);
511
+ if (r.isErr()) {
512
+ n.apiError(r.error);
513
+ return;
514
+ }
515
+ const W = r.value.file;
516
+ if (W === null) {
517
+ n.show({
518
+ message: t.t("wise_invoicing.invoice.download_pdf.generation_in_progress")
519
+ });
520
+ return;
521
+ }
522
+ const te = await Ki.getDownloadUrl(W.uuid);
523
+ te !== null && Fi.downloadUrl(te, W.name);
524
+ }
525
+ async function oi() {
526
+ const r = await v.execute({
527
+ params: {
528
+ invoiceUuid: i.value.uuid
529
+ }
530
+ });
531
+ if (r.isErr()) {
532
+ n.apiError(r.error);
533
+ return;
534
+ }
535
+ n.show({
536
+ button: {
537
+ label: t.t("wise_invoicing.invoice.duplicate.view_action"),
538
+ onClick: () => {
539
+ l.push({
540
+ name: "invoicing-invoice-detail",
541
+ params: {
542
+ invoiceUuid: r.value
543
+ }
544
+ });
545
+ }
546
+ },
547
+ message: t.t("wise_invoicing.invoice.duplicate.success")
548
+ });
549
+ }
550
+ async function ai() {
551
+ const r = await f.execute({
552
+ params: {
553
+ invoiceUuid: i.value.uuid
554
+ }
555
+ });
556
+ if (r.isErr()) {
557
+ n.apiError(r.error);
558
+ return;
559
+ }
560
+ n.show({
561
+ button: {
562
+ label: t.t("wise_invoicing.credit_note.create.view_action"),
563
+ onClick: () => {
564
+ l.push({
565
+ name: "invoicing-credit-note-detail",
566
+ params: {
567
+ creditNoteUuid: r.value
568
+ }
569
+ });
570
+ }
571
+ },
572
+ message: t.t("wise_invoicing.credit_note.create.success")
573
+ });
574
+ }
575
+ const si = c(() => [
576
+ {
577
+ isLoading: _.isLoading.value,
578
+ iconLeft: ge,
579
+ key: "send",
580
+ label: t.t("wise_invoicing.invoice.detail.actions.send"),
581
+ variant: "primary",
582
+ visible: i.value.status === L.FINALIZED,
583
+ onClick: ei
584
+ },
585
+ {
586
+ isLoading: _.isLoading.value,
587
+ iconLeft: ge,
588
+ key: "sendReminder",
589
+ label: t.t("wise_invoicing.invoice.detail.header.send_reminder"),
590
+ variant: "primary",
591
+ visible: He.value,
592
+ onClick: ii
593
+ },
594
+ {
595
+ isLoading: C.isLoading.value,
596
+ iconRight: Ae,
597
+ key: "markAsReady",
598
+ label: t.t("wise_invoicing.invoice.detail.actions.mark_as_ready"),
599
+ visible: ie("markAsReady"),
600
+ onClick: Ze
601
+ },
602
+ {
603
+ isLoading: g.isLoading.value,
604
+ iconLeft: hi,
605
+ key: "finalize",
606
+ label: t.t("wise_invoicing.invoice.detail.actions.finalize"),
607
+ visible: ie("finalize"),
608
+ onClick: Qe
609
+ }
610
+ ].filter((r) => r.visible)), Se = c(() => {
611
+ const r = [
612
+ {
613
+ icon: qe,
614
+ key: "markAsProtested",
615
+ label: t.t("wise_invoicing.invoice.detail.actions.mark_as_disputed"),
616
+ visible: ee.value && !P.value,
617
+ onSelect: Ye
618
+ },
619
+ {
620
+ icon: Ui,
621
+ key: "markAsPaid",
622
+ label: t.t("wise_invoicing.invoice.detail.actions.mark_as_paid"),
623
+ visible: ie("markAsPaid"),
624
+ onSelect: Je
625
+ },
626
+ {
627
+ icon: Ae,
628
+ key: "withdrawProtest",
629
+ label: t.t("wise_invoicing.invoice.detail.actions.withdraw_dispute"),
630
+ visible: ee.value && P.value,
631
+ onSelect: Xe
632
+ }
633
+ ], W = [
634
+ L.FINALIZED,
635
+ L.PAID,
636
+ L.SENT,
637
+ L.OVERDUE,
638
+ L.PROTESTED
639
+ ].includes(i.value.status), te = [
640
+ {
641
+ icon: ki,
642
+ key: "downloadPdf",
643
+ label: t.t("wise_invoicing.common.download_pdf"),
644
+ visible: Z.value,
645
+ onSelect: ni
646
+ },
647
+ {
648
+ icon: Si,
649
+ key: "backToDraft",
650
+ label: t.t("wise_invoicing.invoice.detail.actions.mark_as_draft"),
651
+ visible: ie("markAsDraft"),
652
+ onSelect: We
653
+ },
654
+ {
655
+ icon: Ci,
656
+ key: "duplicate",
657
+ label: t.t("wise_invoicing.invoice.detail.actions.duplicate"),
658
+ visible: !0,
659
+ onSelect: oi
660
+ }
661
+ ], li = [
662
+ {
663
+ icon: Ei,
664
+ key: "createCreditNote",
665
+ label: t.t("wise_invoicing.invoice.detail.header.cancel_with_credit_note"),
666
+ visible: W,
667
+ onSelect: ai
668
+ },
669
+ {
670
+ icon: Ai,
671
+ key: "delete",
672
+ label: t.t("wise_invoicing.invoice.detail.actions.delete"),
673
+ visible: E.value.isEditable,
674
+ onSelect: ti
675
+ }
676
+ ];
677
+ return [
678
+ {
679
+ items: r.filter((R) => R.visible),
680
+ key: "lifecycle"
681
+ },
682
+ {
683
+ items: te.filter((R) => R.visible),
684
+ key: "secondary"
685
+ },
686
+ {
687
+ items: li.filter((R) => R.visible),
688
+ key: "destructive"
689
+ }
690
+ ].filter((R) => R.items.length > 0);
691
+ });
692
+ return {
693
+ isActionMenuVisible: c(() => Se.value.length > 0),
694
+ isDisputed: P,
695
+ menuGroups: Se,
696
+ primaryButtons: si
697
+ };
698
+ }
699
+ const Gt = /* @__PURE__ */ I({
700
+ __name: "InvoiceDetailHeaderSection",
701
+ props: {
702
+ isPdfViewActive: { type: Boolean },
703
+ invoice: {}
704
+ },
705
+ emits: ["togglePdfView"],
706
+ setup(i, { emit: t }) {
707
+ const n = i, l = t, a = x(), m = z(), {
708
+ isDisputed: d,
709
+ menuGroups: _,
710
+ primaryButtons: f
711
+ } = Kt(c(() => n.invoice)), v = Ue(), g = c(() => new je(n.invoice.status)), h = c(() => g.value.color), T = c(() => a.t(g.value.translationKey)), M = c(() => n.invoice.deliveryStatus !== H.UNSENT || n.invoice.reminders.length > 0), C = c(() => !G.isEditable(n.invoice.status)), U = Q({
712
+ initialState: {
713
+ subject: n.invoice.subject
714
+ },
715
+ schema: Mt,
716
+ onSubmit: async (y) => {
717
+ const E = await v.execute({
718
+ body: {
719
+ ...he.toForm(n.invoice),
720
+ subject: y.subject
721
+ },
722
+ params: {
723
+ invoiceUuid: n.invoice.uuid
724
+ }
725
+ });
726
+ E.isErr() && m.apiError(E.error);
727
+ }
728
+ }), b = U.register("subject");
729
+ return Ne({
730
+ form: U
731
+ }), (y, E) => (u(), p(e(Le), {
732
+ form: e(U),
733
+ "prompt-on-unsaved-changes": !1
734
+ }, {
735
+ default: s(() => [
736
+ o(Gi, {
737
+ "fallback-title": e(a).t("wise_invoicing.invoice.detail.fallback_title"),
738
+ "is-disabled": C.value,
739
+ sequence: n.invoice.sequence,
740
+ "status-color": h.value,
741
+ "status-label": T.value,
742
+ icon: e(ze),
743
+ "subject-field": e(b),
744
+ "subject-placeholder": e(a).t("wise_invoicing.invoice.detail.header.subject_placeholder")
745
+ }, {
746
+ actions: s(() => [
747
+ o(Qi, {
748
+ "is-pdf-view-active": n.isPdfViewActive,
749
+ "menu-groups": e(_),
750
+ "primary-buttons": e(f),
751
+ onTogglePdfView: E[0] || (E[0] = (P) => l("togglePdfView"))
752
+ }, null, 8, ["is-pdf-view-active", "menu-groups", "primary-buttons"])
753
+ ]),
754
+ status: s(() => [
755
+ o(e(Y), {
756
+ gap: "xs",
757
+ class: "flex-wrap items-start"
758
+ }, {
759
+ default: s(() => [
760
+ o(ut, {
761
+ "lifecycle-status": n.invoice.lifecycleStatus
762
+ }, null, 8, ["lifecycle-status"]),
763
+ o(dt, {
764
+ "balance-due-amount": n.invoice.balanceDueAmount,
765
+ "gross-amount": n.invoice.grossAmount,
766
+ "paid-amount": n.invoice.paidAmount,
767
+ "settlement-status": n.invoice.settlementStatus,
768
+ "total-credited-amount": n.invoice.totalCreditedAmount
769
+ }, null, 8, ["balance-due-amount", "gross-amount", "paid-amount", "settlement-status", "total-credited-amount"]),
770
+ n.invoice.isOverdue ? (u(), p(Hi, { key: 0 })) : k("", !0),
771
+ e(d) ? (u(), p(At, { key: 1 })) : k("", !0),
772
+ M.value ? (u(), p(Et, {
773
+ key: 2,
774
+ "delivery-status": n.invoice.deliveryStatus
775
+ }, null, 8, ["delivery-status"])) : k("", !0),
776
+ n.invoice.reminders.length > 0 ? (u(), p(Ft, {
777
+ key: 3,
778
+ reminders: n.invoice.reminders
779
+ }, null, 8, ["reminders"])) : k("", !0)
780
+ ]),
781
+ _: 1
782
+ })
783
+ ]),
784
+ _: 1
785
+ }, 8, ["fallback-title", "is-disabled", "sequence", "status-color", "status-label", "icon", "subject-field", "subject-placeholder"])
786
+ ]),
787
+ _: 1
788
+ }, 8, ["form"]));
789
+ }
790
+ }), Ht = { class: "grid w-full grid-cols-1 gap-md lg:grid-cols-3" }, Qt = /* @__PURE__ */ I({
791
+ __name: "InvoiceDetailLinkedCreditNotesSection",
792
+ props: {
793
+ invoice: {}
794
+ },
795
+ setup(i) {
796
+ const t = i, n = x(), l = X(), a = c(() => t.invoice.creditNotes.map((d) => {
797
+ const _ = new je(d.status);
798
+ return {
799
+ uuid: d.uuid,
800
+ title: d.sequence === null ? n.t("wise_invoicing.invoice.detail.credit_notes.untitled") : n.t("wise_invoicing.invoice.detail.credit_notes.card_title", {
801
+ sequence: d.sequence
802
+ }),
803
+ amountLabel: l.formatMonetary(m(d)),
804
+ statusColor: _.color,
805
+ statusLabel: n.t(_.translationKey)
806
+ };
807
+ }));
808
+ function m(d) {
809
+ return {
810
+ ...d.grossAmount,
811
+ amount: d.grossAmount.amount > 0 ? -d.grossAmount.amount : d.grossAmount.amount
812
+ };
813
+ }
814
+ return (d, _) => a.value.length > 0 ? (u(), p(e(Pe), {
815
+ key: 0,
816
+ as: "section",
817
+ gap: "md",
818
+ class: "w-full"
819
+ }, {
820
+ default: s(() => [
821
+ o(e(q), {
822
+ text: e(n).t("wise_invoicing.invoice.detail.credit_notes.title"),
823
+ as: "h2",
824
+ class: "text-sm font-semibold text-primary"
825
+ }, null, 8, ["text"]),
826
+ B("div", Ht, [
827
+ (u(!0), K(ae, null, Fe(a.value, (f) => (u(), p(e(mt), {
828
+ key: f.uuid,
829
+ to: {
830
+ name: "invoicing-credit-note-detail",
831
+ params: { creditNoteUuid: f.uuid }
832
+ },
833
+ class: "min-w-0 rounded-lg border border-secondary bg-primary p-lg transition-colors hover:bg-secondary"
834
+ }, {
835
+ default: s(() => [
836
+ o(e(Y), {
837
+ align: "center",
838
+ gap: "md",
839
+ class: "min-w-0"
840
+ }, {
841
+ default: s(() => [
842
+ o(e(q), {
843
+ text: f.title,
844
+ class: "min-w-0 flex-1 truncate text-xs font-semibold text-primary"
845
+ }, null, 8, ["text"]),
846
+ o(e(V), {
847
+ label: f.statusLabel,
848
+ color: f.statusColor,
849
+ size: "sm",
850
+ variant: "translucent"
851
+ }, null, 8, ["label", "color"]),
852
+ o(e(V), {
853
+ label: f.amountLabel,
854
+ variant: "translucent",
855
+ size: "sm"
856
+ }, null, 8, ["label"])
857
+ ]),
858
+ _: 2
859
+ }, 1024)
860
+ ]),
861
+ _: 2
862
+ }, 1032, ["to"]))), 128))
863
+ ])
864
+ ]),
865
+ _: 1
866
+ })) : k("", !0);
867
+ }
868
+ }), Ge = w.object({
869
+ deliveredOn: ve.nullable(),
870
+ dueOn: ve,
871
+ issuedOn: ve,
872
+ externalRemarks: w.string().nullable(),
873
+ poNumber: w.string().nullable(),
874
+ preparedBy: w.object({
875
+ uuid: w.uuid(),
876
+ name: w.string()
877
+ }),
878
+ subject: w.string().nullable()
879
+ }).superRefine((i, t) => {
880
+ Temporal.PlainDate.compare(i.dueOn, i.issuedOn) < 0 && t.addIssue({
881
+ code: "custom",
882
+ message: Ti.global.t("invoicing.invoice.validation.due_date_after_issue_date"),
883
+ path: [
884
+ "dueOn"
885
+ ]
886
+ });
887
+ }), Zt = /* @__PURE__ */ I({
888
+ __name: "InvoiceDetailRemarksSection",
889
+ props: {
890
+ invoice: {}
891
+ },
892
+ setup(i) {
893
+ const t = i, n = x(), l = z(), a = Ue(), m = Q({
894
+ initialState: c(() => he.toForm(t.invoice)),
895
+ schema: Ge,
896
+ onSubmit: async (f) => {
897
+ const v = await a.execute({
898
+ body: f,
899
+ params: {
900
+ invoiceUuid: t.invoice.uuid
901
+ }
902
+ });
903
+ v.isErr() && l.apiError(v.error);
904
+ }
905
+ }), d = m.register("externalRemarks"), _ = c(() => !G.isEditable(t.invoice.status));
906
+ return Ne({
907
+ form: m
908
+ }), (f, v) => (u(), p(e(Le), {
909
+ form: e(m),
910
+ "prompt-on-unsaved-changes": !1
911
+ }, {
912
+ default: s(() => [
913
+ o(Zi, {
914
+ "is-disabled": _.value,
915
+ placeholder: e(n).t("wise_invoicing.invoice.detail.remarks.placeholder"),
916
+ "remarks-field": e(d),
917
+ title: e(n).t("wise_invoicing.invoice.detail.remarks.title")
918
+ }, null, 8, ["is-disabled", "placeholder", "remarks-field", "title"])
919
+ ]),
920
+ _: 1
921
+ }, 8, ["form"]));
922
+ }
923
+ });
924
+ function Wt(i) {
925
+ return ct("invoiceActivityLogIndex", {
926
+ params: {
927
+ invoiceUuid: i
928
+ },
929
+ queryFn: (t) => D.getActivityLogs(i.value, {
930
+ pagination: t
931
+ })
932
+ });
933
+ }
934
+ const Jt = /* @__PURE__ */ I({
935
+ __name: "InvoiceDetailSidebarActivityTab",
936
+ props: {
937
+ invoice: {}
938
+ },
939
+ setup(i) {
940
+ const t = i, n = x(), {
941
+ hasNextPage: l,
942
+ isFetchingNextPage: a,
943
+ isLoading: m,
944
+ fetchNextPage: d,
945
+ result: _
946
+ } = Wt(c(() => t.invoice.uuid)), f = c(() => _.value.unwrapOr({
947
+ data: [],
948
+ meta: {
949
+ next: null
950
+ }
951
+ }).data);
952
+ return (v, g) => (u(), p(Wi, {
953
+ "current-billing-document": {
954
+ role: e(Mi).INVOICE,
955
+ uuid: t.invoice.uuid
956
+ },
957
+ "empty-message": e(n).t("wise_invoicing.invoice.detail.sidebar.activity_empty"),
958
+ entries: f.value,
959
+ "fetch-next-page": e(d),
960
+ "has-next-page": e(l),
961
+ "is-fetching-next-page": e(a),
962
+ "is-loading": e(m)
963
+ }, null, 8, ["current-billing-document", "empty-message", "entries", "fetch-next-page", "has-next-page", "is-fetching-next-page", "is-loading"]));
964
+ }
965
+ }), Yt = /* @__PURE__ */ I({
966
+ __name: "InvoiceUpdateDialog",
967
+ props: {
968
+ invoice: {}
969
+ },
970
+ emits: ["close"],
971
+ setup(i, { emit: t }) {
972
+ const n = i, l = t, a = x(), m = z(), d = Ue(), _ = pt(), f = c(() => {
973
+ const b = _.result.value;
974
+ return b.isOk() ? b.getValue().defaultPaymentTermDays ?? 0 : 0;
975
+ }), v = Q({
976
+ initialState: c(() => he.toForm(n.invoice)),
977
+ schema: Ge,
978
+ onSubmit: async (b) => {
979
+ const y = await d.execute({
980
+ body: b,
981
+ params: {
982
+ invoiceUuid: n.invoice.uuid
983
+ }
984
+ });
985
+ if (y.isErr()) {
986
+ m.apiError(y.error);
987
+ return;
988
+ }
989
+ l("close");
990
+ },
991
+ onSubmitError: () => {
992
+ m.unableToSave();
993
+ }
994
+ }), g = v.register("issuedOn"), h = v.register("dueOn"), T = v.register("deliveredOn"), M = v.register("poNumber"), C = v.register("subject");
995
+ function U(b) {
996
+ b !== null && h.setValue(b.add({
997
+ days: f.value
998
+ }));
999
+ }
1000
+ return (b, y) => (u(), p(e(le), {
1001
+ form: e(v),
1002
+ size: "sm",
1003
+ onClose: y[0] || (y[0] = (E) => l("close"))
1004
+ }, {
1005
+ default: s(() => [
1006
+ o(e(ce), {
1007
+ icon: e(Pi),
1008
+ "is-description-visible": !1,
1009
+ title: e(a).t("wise_invoicing.invoice.detail.header.edit_info"),
1010
+ description: ""
1011
+ }, null, 8, ["icon", "title"]),
1012
+ o(e(we), null, {
1013
+ default: s(() => [
1014
+ o(e(Ie), null, {
1015
+ default: s(() => [
1016
+ o(e(xe), {
1017
+ lg: 2,
1018
+ sm: 1
1019
+ }, {
1020
+ default: s(() => [
1021
+ o(e(ne), A(e(F)(e(g)), {
1022
+ label: e(a).t("wise_invoicing.invoice.detail.header.invoice_date"),
1023
+ "is-required": !0,
1024
+ "onUpdate:modelValue": U
1025
+ }), null, 16, ["label"]),
1026
+ o(e(ne), A(e(F)(e(h)), {
1027
+ label: e(a).t("wise_invoicing.invoice.detail.header.due_date"),
1028
+ "is-required": !0,
1029
+ "min-date": e(g).modelValue.value
1030
+ }), null, 16, ["label", "min-date"]),
1031
+ o(e(ne), A(e(F)(e(T)), {
1032
+ label: e(a).t("wise_invoicing.invoice.detail.header.delivery_date")
1033
+ }), null, 16, ["label"]),
1034
+ o(e(oe), A(e(F)(e(M)), {
1035
+ label: e(a).t("wise_invoicing.invoice.detail.header.po_number")
1036
+ }), null, 16, ["label"]),
1037
+ o(e(oe), A(e(F)(e(C)), {
1038
+ label: e(a).t("wise_invoicing.invoice.detail.header.subject"),
1039
+ placeholder: e(a).t("wise_invoicing.invoice.detail.header.subject_placeholder")
1040
+ }), null, 16, ["label", "placeholder"])
1041
+ ]),
1042
+ _: 1
1043
+ })
1044
+ ]),
1045
+ _: 1
1046
+ })
1047
+ ]),
1048
+ _: 1
1049
+ }),
1050
+ o(e(re), null, {
1051
+ right: s(() => [
1052
+ o(e(ue), { label: "cancel" }),
1053
+ o(e(be), {
1054
+ label: e(a).t("wise_invoicing.invoice.detail.header.edit_info")
1055
+ }, null, 8, ["label"])
1056
+ ]),
1057
+ _: 1
1058
+ })
1059
+ ]),
1060
+ _: 1
1061
+ }, 8, ["form"]));
1062
+ }
1063
+ }), Xt = /* @__PURE__ */ I({
1064
+ __name: "InvoiceDetailSidebarInfoTab",
1065
+ props: {
1066
+ invoice: {}
1067
+ },
1068
+ setup(i) {
1069
+ const t = i, n = x(), l = se(), m = de().create(Yt), d = c(() => G.isEditable(t.invoice.status)), _ = c(() => {
1070
+ if (!t.invoice.isOverdue)
1071
+ return null;
1072
+ const g = t.invoice.dueOn.toZonedDateTime(Ve.Now.timeZoneId()).toInstant();
1073
+ return l.toRelativeTime(g);
1074
+ });
1075
+ async function f() {
1076
+ await m.open({
1077
+ invoice: t.invoice
1078
+ });
1079
+ }
1080
+ function v(g) {
1081
+ return g === null ? "-" : l.formatPlainDate(g);
1082
+ }
1083
+ return (g, h) => (u(), p(e(mi), { class: "px-2xl py-xl" }, {
1084
+ default: s(() => [
1085
+ o(e(me), {
1086
+ label: e(n).t("wise_invoicing.invoice.detail.sidebar.general")
1087
+ }, ri({
1088
+ default: s(() => [
1089
+ o(e($), null, {
1090
+ default: s(() => [
1091
+ o(e(O), {
1092
+ icon: e(Li),
1093
+ label: e(n).t("wise_invoicing.invoice.detail.header.invoice_id")
1094
+ }, null, 8, ["icon", "label"]),
1095
+ o(e(j), {
1096
+ text: t.invoice.sequence ?? "-"
1097
+ }, null, 8, ["text"])
1098
+ ]),
1099
+ _: 1
1100
+ }),
1101
+ o(e($), null, {
1102
+ default: s(() => [
1103
+ o(e(O), {
1104
+ icon: e($i),
1105
+ label: e(n).t("wise_invoicing.invoice.detail.header.po_number")
1106
+ }, null, 8, ["icon", "label"]),
1107
+ o(e(j), {
1108
+ text: t.invoice.poNumber ?? "-"
1109
+ }, null, 8, ["text"])
1110
+ ]),
1111
+ _: 1
1112
+ }),
1113
+ o(e($), null, {
1114
+ default: s(() => [
1115
+ o(e(O), {
1116
+ icon: e(qi),
1117
+ label: e(n).t("wise_invoicing.invoice.detail.header.issuer")
1118
+ }, null, 8, ["icon", "label"]),
1119
+ o(e(j), {
1120
+ text: t.invoice.issuer.name ?? "-"
1121
+ }, null, 8, ["text"])
1122
+ ]),
1123
+ _: 1
1124
+ }),
1125
+ o(e($), null, {
1126
+ default: s(() => [
1127
+ o(e(O), {
1128
+ icon: e(ze),
1129
+ label: e(n).t("wise_invoicing.invoice.detail.header.invoice_date")
1130
+ }, null, 8, ["icon", "label"]),
1131
+ o(e(j), {
1132
+ text: v(t.invoice.issueOn)
1133
+ }, null, 8, ["text"])
1134
+ ]),
1135
+ _: 1
1136
+ }),
1137
+ o(e($), null, {
1138
+ default: s(() => [
1139
+ o(e(O), {
1140
+ icon: e(qe),
1141
+ label: e(n).t("wise_invoicing.invoice.detail.header.due_date"),
1142
+ variant: t.invoice.isOverdue ? "error" : "default"
1143
+ }, null, 8, ["icon", "label", "variant"]),
1144
+ o(e(Y), {
1145
+ gap: "xs",
1146
+ class: "items-center"
1147
+ }, {
1148
+ default: s(() => [
1149
+ o(e(j), {
1150
+ text: v(t.invoice.dueOn),
1151
+ variant: t.invoice.isOverdue ? "error" : "default"
1152
+ }, null, 8, ["text", "variant"]),
1153
+ _.value !== null ? (u(), p(e(V), {
1154
+ key: 0,
1155
+ label: _.value,
1156
+ color: "error",
1157
+ size: "sm",
1158
+ variant: "translucent"
1159
+ }, null, 8, ["label"])) : k("", !0)
1160
+ ]),
1161
+ _: 1
1162
+ })
1163
+ ]),
1164
+ _: 1
1165
+ }),
1166
+ o(e($), null, {
1167
+ default: s(() => [
1168
+ o(e(O), {
1169
+ icon: e(ge),
1170
+ label: e(n).t("wise_invoicing.invoice.detail.header.delivery_date")
1171
+ }, null, 8, ["icon", "label"]),
1172
+ o(e(j), {
1173
+ text: v(t.invoice.deliveredOn)
1174
+ }, null, 8, ["text"])
1175
+ ]),
1176
+ _: 1
1177
+ })
1178
+ ]),
1179
+ _: 2
1180
+ }, [
1181
+ d.value ? {
1182
+ name: "actions",
1183
+ fn: s(() => [
1184
+ o(e($e), {
1185
+ icon: e(zi),
1186
+ label: e(n).t("wise_invoicing.invoice.detail.header.edit_info"),
1187
+ variant: "tertiary",
1188
+ onClick: f
1189
+ }, null, 8, ["icon", "label"])
1190
+ ]),
1191
+ key: "0"
1192
+ } : void 0
1193
+ ]), 1032, ["label"]),
1194
+ o(Ji, {
1195
+ "original-invoice": t.invoice.originalInvoice
1196
+ }, null, 8, ["original-invoice"]),
1197
+ o(e(Ce)),
1198
+ o(e(me), {
1199
+ label: e(n).t("wise_invoicing.invoice.detail.header.bill_to"),
1200
+ "collapse-options": {
1201
+ isCollapsible: !0,
1202
+ isOpenByDefault: !0,
1203
+ badge: {
1204
+ label: t.invoice.customer.name ?? "-"
1205
+ }
1206
+ }
1207
+ }, {
1208
+ default: s(() => [
1209
+ o(e($), { orientation: "vertical" }, {
1210
+ default: s(() => [
1211
+ o(e(q), {
1212
+ text: t.invoice.customer.name ?? "-",
1213
+ class: "text-xs font-medium"
1214
+ }, null, 8, ["text"]),
1215
+ t.invoice.customer.address ? (u(), K(ae, { key: 0 }, [
1216
+ o(e(q), {
1217
+ text: e(pe).formatLines(t.invoice.customer.address)[0] ?? "",
1218
+ class: "text-xs"
1219
+ }, null, 8, ["text"]),
1220
+ t.invoice.customer.address ? (u(), p(e(q), {
1221
+ key: 0,
1222
+ text: e(pe).formatLines(t.invoice.customer.address)[1] ?? "",
1223
+ class: "text-xs"
1224
+ }, null, 8, ["text"])) : k("", !0)
1225
+ ], 64)) : k("", !0)
1226
+ ]),
1227
+ _: 1
1228
+ })
1229
+ ]),
1230
+ _: 1
1231
+ }, 8, ["label", "collapse-options"]),
1232
+ o(e(Ce)),
1233
+ o(e(me), {
1234
+ label: e(n).t("wise_invoicing.invoice.detail.header.bill_from"),
1235
+ "collapse-options": {
1236
+ isCollapsible: !0,
1237
+ isOpenByDefault: !1,
1238
+ badge: {
1239
+ label: t.invoice.issuer.email ?? "-"
1240
+ }
1241
+ }
1242
+ }, {
1243
+ default: s(() => [
1244
+ o(e($), { orientation: "vertical" }, {
1245
+ default: s(() => [
1246
+ o(e(O), {
1247
+ label: t.invoice.issuer.email ?? "-"
1248
+ }, null, 8, ["label"]),
1249
+ t.invoice.issuer.address ? (u(), p(e(j), {
1250
+ key: 0,
1251
+ text: e(pe).format(t.invoice.issuer.address)
1252
+ }, null, 8, ["text"])) : k("", !0)
1253
+ ]),
1254
+ _: 1
1255
+ })
1256
+ ]),
1257
+ _: 1
1258
+ }, 8, ["label", "collapse-options"])
1259
+ ]),
1260
+ _: 1
1261
+ }));
1262
+ }
1263
+ }), en = /* @__PURE__ */ I({
1264
+ __name: "InvoiceDetailSidebar",
1265
+ props: {
1266
+ invoice: {}
1267
+ },
1268
+ setup(i) {
1269
+ const t = i, n = x(), l = se(), a = c(() => n.t("wise_invoicing.invoice.detail.sidebar.updated_on", {
1270
+ date: l.toDateTime(t.invoice.updatedAt)
1271
+ }));
1272
+ return (m, d) => (u(), p(Yi, {
1273
+ "billing-document": t.invoice,
1274
+ "updated-footer": a.value
1275
+ }, {
1276
+ activity: s(() => [
1277
+ o(Jt, {
1278
+ invoice: t.invoice
1279
+ }, null, 8, ["invoice"])
1280
+ ]),
1281
+ info: s(() => [
1282
+ o(Xt, {
1283
+ invoice: t.invoice
1284
+ }, null, 8, ["invoice"])
1285
+ ]),
1286
+ _: 1
1287
+ }, 8, ["billing-document", "updated-footer"]));
1288
+ }
1289
+ });
1290
+ function tn() {
1291
+ return S({
1292
+ queryFn: (i) => D.deletePayment(
1293
+ i.params.invoiceUuid,
1294
+ i.params.paymentUuid
1295
+ ),
1296
+ queryKeysToInvalidate: {
1297
+ invoiceDetail: {
1298
+ invoiceUuid: (i) => i.invoiceUuid
1299
+ },
1300
+ invoicePaymentIndex: {
1301
+ invoiceUuid: (i) => i.invoiceUuid
1302
+ }
1303
+ }
1304
+ });
1305
+ }
1306
+ function nn(i) {
1307
+ return rt("invoicePaymentIndex", {
1308
+ params: {
1309
+ invoiceUuid: i
1310
+ },
1311
+ queryFn: () => D.getPayments(i.value)
1312
+ });
1313
+ }
1314
+ const on = /* @__PURE__ */ I({
1315
+ __name: "InvoiceDetailPaymentActionsCell",
1316
+ props: {
1317
+ payment: {},
1318
+ onDelete: { type: Function }
1319
+ },
1320
+ setup(i) {
1321
+ const t = i, n = x();
1322
+ return (l, a) => (u(), p(e(De), null, {
1323
+ default: s(() => [
1324
+ o(e(pi), null, {
1325
+ default: s(() => [
1326
+ t.payment.source === e(Re).MANUAL ? (u(), p(e($e), {
1327
+ key: 0,
1328
+ label: e(n).t("wise_invoicing.invoice.detail.payments.delete.title"),
1329
+ icon: e(kt),
1330
+ size: "sm",
1331
+ variant: "tertiary",
1332
+ onClick: a[0] || (a[0] = (m) => t.onDelete(t.payment))
1333
+ }, null, 8, ["label", "icon"])) : k("", !0)
1334
+ ]),
1335
+ _: 1
1336
+ })
1337
+ ]),
1338
+ _: 1
1339
+ }));
1340
+ }
1341
+ }), an = /* @__PURE__ */ I({
1342
+ __name: "InvoiceDetailPaymentManualCell",
1343
+ props: {
1344
+ payment: {}
1345
+ },
1346
+ setup(i) {
1347
+ const t = i;
1348
+ return (n, l) => (u(), p(e(De), null, {
1349
+ default: s(() => [
1350
+ t.payment.source === e(Re).MANUAL ? (u(), p(e(vt), {
1351
+ key: 0,
1352
+ class: "size-4 text-brand-600"
1353
+ })) : k("", !0)
1354
+ ]),
1355
+ _: 1
1356
+ }));
1357
+ }
1358
+ }), _e = /* @__PURE__ */ I({
1359
+ __name: "InvoiceDetailPaymentsTableTextCell",
1360
+ props: {
1361
+ text: {}
1362
+ },
1363
+ setup(i) {
1364
+ const t = i;
1365
+ return (n, l) => (u(), p(e(De), null, {
1366
+ default: s(() => [
1367
+ o(e(q), {
1368
+ text: t.text ?? "-",
1369
+ class: "text-sm/5 text-primary"
1370
+ }, null, 8, ["text"])
1371
+ ]),
1372
+ _: 1
1373
+ }));
1374
+ }
1375
+ });
1376
+ function sn(i) {
1377
+ const t = x(), n = se(), l = X();
1378
+ return c(() => _i()([
1379
+ {
1380
+ headerLabel: t.t("wise_invoicing.invoice.detail.payments.columns.timestamp"),
1381
+ key: "timestamp",
1382
+ size: {
1383
+ max: "12rem",
1384
+ min: "12rem"
1385
+ },
1386
+ component: (a) => J(_e, {
1387
+ text: n.toDateTime(a.createdAt)
1388
+ })
1389
+ },
1390
+ {
1391
+ headerLabel: t.t("wise_invoicing.invoice.detail.payments.columns.remark"),
1392
+ key: "remark",
1393
+ size: {
1394
+ max: "1fr",
1395
+ min: "12rem"
1396
+ },
1397
+ component: (a) => J(_e, {
1398
+ text: a.remarks ?? ""
1399
+ })
1400
+ },
1401
+ {
1402
+ headerLabel: t.t("wise_invoicing.invoice.detail.payments.columns.manual"),
1403
+ key: "manual",
1404
+ size: {
1405
+ max: "6rem",
1406
+ min: "6rem"
1407
+ },
1408
+ component: (a) => J(an, {
1409
+ payment: a
1410
+ })
1411
+ },
1412
+ {
1413
+ headerLabel: t.t("wise_invoicing.invoice.detail.payments.columns.amount"),
1414
+ key: "amount",
1415
+ size: {
1416
+ max: "10rem",
1417
+ min: "10rem"
1418
+ },
1419
+ component: (a) => J(_e, {
1420
+ text: l.formatMonetary(a.amount)
1421
+ })
1422
+ },
1423
+ {
1424
+ headerLabel: "",
1425
+ key: "actions",
1426
+ size: {
1427
+ max: "5rem",
1428
+ min: "5rem"
1429
+ },
1430
+ component: (a) => J(on, {
1431
+ payment: a,
1432
+ onDelete: i.onDelete
1433
+ })
1434
+ }
1435
+ ]));
1436
+ }
1437
+ function ln() {
1438
+ return S({
1439
+ queryFn: (i) => D.createPayment(
1440
+ i.params.invoiceUuid,
1441
+ i.body
1442
+ ),
1443
+ queryKeysToInvalidate: {
1444
+ invoiceDetail: {
1445
+ invoiceUuid: (i) => i.invoiceUuid
1446
+ },
1447
+ invoicePaymentIndex: {
1448
+ invoiceUuid: (i) => i.invoiceUuid
1449
+ }
1450
+ }
1451
+ });
1452
+ }
1453
+ const cn = w.object({
1454
+ amount: w.number().positive(),
1455
+ currency: w.enum(Oe),
1456
+ date: Ri,
1457
+ paymentReference: w.string().nullable(),
1458
+ precision: w.number().int().nonnegative(),
1459
+ remarks: w.string().nullable()
1460
+ }), rn = { class: "pr-md text-xs text-secondary" }, un = /* @__PURE__ */ I({
1461
+ __name: "InvoicePaymentCreateDialog",
1462
+ props: {
1463
+ invoice: {}
1464
+ },
1465
+ emits: ["close"],
1466
+ setup(i, { emit: t }) {
1467
+ const n = i, l = t, a = x(), m = z(), d = X(), _ = ln(), f = c(() => d.getSymbol(n.invoice.grossAmount.currency)), v = Q({
1468
+ initialState: {
1469
+ amount: null,
1470
+ currency: n.invoice.grossAmount.currency,
1471
+ date: Oi.getToday(),
1472
+ paymentReference: null,
1473
+ precision: n.invoice.grossAmount.precision,
1474
+ remarks: null
1475
+ },
1476
+ schema: cn,
1477
+ onSubmit: async (C) => {
1478
+ const U = await _.execute({
1479
+ body: C,
1480
+ params: {
1481
+ invoiceUuid: n.invoice.uuid
1482
+ }
1483
+ });
1484
+ if (U.isErr()) {
1485
+ m.apiError(U.error);
1486
+ return;
1487
+ }
1488
+ m.show({
1489
+ message: a.t("wise_invoicing.invoice.detail.payments.create.success")
1490
+ }), l("close");
1491
+ },
1492
+ onSubmitError: () => {
1493
+ m.unableToSave();
1494
+ }
1495
+ }), g = v.register("amount"), h = v.register("date"), T = v.register("paymentReference"), M = v.register("remarks");
1496
+ return (C, U) => (u(), p(e(le), {
1497
+ form: e(v),
1498
+ size: "sm",
1499
+ onClose: U[0] || (U[0] = (b) => l("close"))
1500
+ }, {
1501
+ default: s(() => [
1502
+ o(e(ce), {
1503
+ title: e(a).t("wise_invoicing.invoice.detail.payments.create.title"),
1504
+ description: e(a).t("wise_invoicing.invoice.detail.payments.create.description"),
1505
+ icon: e(yt),
1506
+ "is-description-visible": !0
1507
+ }, null, 8, ["title", "description", "icon"]),
1508
+ o(e(we), null, {
1509
+ default: s(() => [
1510
+ o(e(Ie), null, {
1511
+ default: s(() => [
1512
+ o(e(xe), {
1513
+ lg: 2,
1514
+ sm: 1
1515
+ }, {
1516
+ default: s(() => [
1517
+ o(e(fe), A(e(F)(e(g)), {
1518
+ "is-required": !0,
1519
+ label: e(a).t("wise_invoicing.invoice.detail.payments.create.fields.amount"),
1520
+ min: 0.01,
1521
+ step: 0.01
1522
+ }), {
1523
+ right: s(() => [
1524
+ B("span", rn, Me(f.value.symbol), 1)
1525
+ ]),
1526
+ _: 1
1527
+ }, 16, ["label"]),
1528
+ o(e(ne), A(e(F)(e(h)), {
1529
+ "is-required": !0,
1530
+ label: e(a).t("wise_invoicing.invoice.detail.payments.create.fields.date")
1531
+ }), null, 16, ["label"]),
1532
+ o(e(oe), A(e(F)(e(T)), {
1533
+ label: e(a).t("wise_invoicing.invoice.detail.payments.create.fields.reference")
1534
+ }), null, 16, ["label"]),
1535
+ o(e(oe), A(e(F)(e(M)), {
1536
+ label: e(a).t("wise_invoicing.invoice.detail.payments.create.fields.remarks")
1537
+ }), null, 16, ["label"])
1538
+ ]),
1539
+ _: 1
1540
+ })
1541
+ ]),
1542
+ _: 1
1543
+ })
1544
+ ]),
1545
+ _: 1
1546
+ }),
1547
+ o(e(re), null, {
1548
+ right: s(() => [
1549
+ o(e(ue), { label: "cancel" }),
1550
+ o(e(fi), {
1551
+ label: e(a).t("wise_invoicing.invoice.detail.payments.create.submit")
1552
+ }, null, 8, ["label"])
1553
+ ]),
1554
+ _: 1
1555
+ })
1556
+ ]),
1557
+ _: 1
1558
+ }, 8, ["form"]));
1559
+ }
1560
+ }), dn = /* @__PURE__ */ I({
1561
+ __name: "InvoiceDetailPaymentsSection",
1562
+ props: {
1563
+ invoice: {}
1564
+ },
1565
+ setup(i) {
1566
+ const t = i, n = x(), l = X(), a = c(() => t.invoice.uuid), m = c(() => t.invoice.balanceDueAmount === null ? null : l.formatMonetary(t.invoice.balanceDueAmount)), {
1567
+ isLoading: d,
1568
+ result: _
1569
+ } = nn(a), f = de(), v = z(), g = f.create(un), h = f.create(gi), T = tn(), M = c(() => _.value.match({
1570
+ err: () => [],
1571
+ loading: () => [],
1572
+ ok: (P) => P
1573
+ })), C = c(() => _.value.match({
1574
+ err: (P) => P,
1575
+ loading: () => null,
1576
+ ok: () => null
1577
+ })), U = c(() => !G.getMetadata(t.invoice.status).isTerminal);
1578
+ function b() {
1579
+ g.open({
1580
+ invoice: t.invoice
1581
+ });
1582
+ }
1583
+ function y(P) {
1584
+ h.open({
1585
+ title: n.t("wise_invoicing.invoice.detail.payments.delete.title"),
1586
+ isDestructive: !0,
1587
+ confirmLabel: n.t("wise_invoicing.invoice.detail.payments.delete.submit"),
1588
+ description: n.t("wise_invoicing.invoice.detail.payments.delete.description"),
1589
+ onConfirm: async () => {
1590
+ const Z = await T.execute({
1591
+ params: {
1592
+ invoiceUuid: t.invoice.uuid,
1593
+ paymentUuid: P.uuid
1594
+ }
1595
+ });
1596
+ if (Z.isErr()) {
1597
+ v.apiError(Z.error);
1598
+ return;
1599
+ }
1600
+ v.show({
1601
+ message: n.t("wise_invoicing.invoice.detail.payments.delete.success")
1602
+ }), h.close();
1603
+ }
1604
+ });
1605
+ }
1606
+ const E = sn({
1607
+ onDelete: y
1608
+ });
1609
+ return (P, Z) => (u(), p(Be, null, {
1610
+ default: s(() => [
1611
+ o(e(Y), {
1612
+ justify: "between",
1613
+ class: "w-full gap-lg border-b border-secondary px-lg py-md"
1614
+ }, {
1615
+ default: s(() => [
1616
+ o(e(Y), {
1617
+ gap: "sm",
1618
+ class: "items-center"
1619
+ }, {
1620
+ default: s(() => [
1621
+ o(e(q), {
1622
+ text: e(n).t("wise_invoicing.invoice.detail.payments.title"),
1623
+ as: "h2",
1624
+ class: "text-sm font-semibold text-primary"
1625
+ }, null, 8, ["text"]),
1626
+ m.value !== null ? (u(), p(e(V), {
1627
+ key: 0,
1628
+ color: "gray",
1629
+ size: "sm",
1630
+ variant: "outline"
1631
+ }, {
1632
+ default: s(() => [
1633
+ o(e(Ee), {
1634
+ label: e(n).t("wise_invoicing.invoice.detail.payments.balance_due")
1635
+ }, null, 8, ["label"]),
1636
+ o(e(yi)),
1637
+ o(e(Ee), { label: m.value }, null, 8, ["label"])
1638
+ ]),
1639
+ _: 1
1640
+ })) : k("", !0)
1641
+ ]),
1642
+ _: 1
1643
+ }),
1644
+ U.value ? (u(), p(e(bi), {
1645
+ key: 0,
1646
+ label: e(n).t("wise_invoicing.invoice.detail.payments.add"),
1647
+ "icon-left": e(xt),
1648
+ size: "sm",
1649
+ onClick: b
1650
+ }, null, 8, ["label", "icon-left"])) : k("", !0)
1651
+ ]),
1652
+ _: 1
1653
+ }),
1654
+ o(e(wi), {
1655
+ "active-filter-count": 0,
1656
+ columns: e(E),
1657
+ data: M.value,
1658
+ error: C.value,
1659
+ "get-key": (ee) => ee.uuid,
1660
+ "has-active-search": !1,
1661
+ "header-actions": [],
1662
+ "is-fetching-next-page": !1,
1663
+ "is-loading": e(d)
1664
+ }, null, 8, ["columns", "data", "error", "get-key", "is-loading"])
1665
+ ]),
1666
+ _: 1
1667
+ }));
1668
+ }
1669
+ });
1670
+ function vn() {
1671
+ return S({
1672
+ queryFn: (i) => D.updateLines(
1673
+ i.params.invoiceUuid,
1674
+ i.body
1675
+ ),
1676
+ queryKeysToInvalidate: {
1677
+ invoiceDetail: {
1678
+ invoiceUuid: (i) => i.invoiceUuid
1679
+ }
1680
+ }
1681
+ });
1682
+ }
1683
+ function mn() {
1684
+ return S({
1685
+ queryFn: (i) => D.applyDiscount(
1686
+ i.params.invoiceUuid,
1687
+ i.body
1688
+ ),
1689
+ queryKeysToInvalidate: {
1690
+ invoiceDetail: {
1691
+ invoiceUuid: (i) => i.invoiceUuid
1692
+ }
1693
+ }
1694
+ });
1695
+ }
1696
+ const pn = w.object({
1697
+ currency: w.enum(Oe),
1698
+ precision: w.number().int().nonnegative(),
1699
+ type: w.enum(N),
1700
+ value: w.number()
1701
+ }).refine((i) => i.type !== N.PERCENTAGE || i.value <= 100, {
1702
+ path: [
1703
+ "value"
1704
+ ]
1705
+ }), _n = { class: "pr-md text-xs text-secondary" }, fn = /* @__PURE__ */ I({
1706
+ __name: "InvoiceApplyDiscountDialog",
1707
+ props: {
1708
+ invoice: {}
1709
+ },
1710
+ emits: ["close"],
1711
+ setup(i, { emit: t }) {
1712
+ const n = i, l = t, a = x(), m = z(), d = X(), _ = mn(), f = c(() => Ii([
1713
+ N.PERCENTAGE,
1714
+ N.AMOUNT
1715
+ ])), v = Q({
1716
+ initialState: {
1717
+ currency: n.invoice.grossAmount.currency,
1718
+ precision: n.invoice.grossAmount.precision,
1719
+ type: N.PERCENTAGE,
1720
+ value: null
1721
+ },
1722
+ schema: pn,
1723
+ onSubmit: async (b) => {
1724
+ const y = await _.execute({
1725
+ body: b,
1726
+ params: {
1727
+ invoiceUuid: n.invoice.uuid
1728
+ }
1729
+ });
1730
+ if (y.isErr()) {
1731
+ m.apiError(y.error);
1732
+ return;
1733
+ }
1734
+ l("close");
1735
+ },
1736
+ onSubmitError: () => {
1737
+ m.unableToSave();
1738
+ }
1739
+ }), g = v.register("value"), h = v.register("type"), T = c(() => h.modelValue.value === N.PERCENTAGE), M = c(() => h.modelValue.value === N.AMOUNT), C = c(() => d.getSymbol(n.invoice.grossAmount.currency));
1740
+ function U(b) {
1741
+ return a.t(`wise_invoicing.invoice.detail.global_discount.type.${b}`);
1742
+ }
1743
+ return (b, y) => (u(), p(e(le), {
1744
+ form: e(v),
1745
+ size: "sm",
1746
+ onClose: y[0] || (y[0] = (E) => l("close"))
1747
+ }, {
1748
+ default: s(() => [
1749
+ o(e(ce), {
1750
+ title: e(a).t("wise_invoicing.invoice.detail.line_items.global_discount"),
1751
+ description: e(a).t("wise_invoicing.invoice.detail.global_discount.description"),
1752
+ icon: e(ji),
1753
+ "is-description-visible": !0
1754
+ }, null, 8, ["title", "description", "icon"]),
1755
+ o(e(we), null, {
1756
+ default: s(() => [
1757
+ o(e(Ie), null, {
1758
+ default: s(() => [
1759
+ o(e(xe), {
1760
+ lg: 2,
1761
+ sm: 1
1762
+ }, {
1763
+ default: s(() => [
1764
+ o(e(xi), A(e(F)(e(h)), {
1765
+ "display-fn": U,
1766
+ "is-required": !0,
1767
+ items: f.value,
1768
+ label: e(a).t("wise_invoicing.invoice.detail.global_discount.type.label")
1769
+ }), null, 16, ["items", "label"]),
1770
+ T.value ? (u(), p(e(fe), A({ key: 0 }, e(F)(e(g)), {
1771
+ hint: e(a).t("wise_invoicing.invoice.detail.global_discount.amount.hint"),
1772
+ "is-required": !0,
1773
+ label: e(a).t("wise_invoicing.invoice.detail.global_discount.amount.label"),
1774
+ max: 100,
1775
+ min: 0,
1776
+ step: 0.01
1777
+ }), {
1778
+ right: s(() => [...y[1] || (y[1] = [
1779
+ B("span", { class: "pr-md text-xs text-secondary" }, " % ", -1)
1780
+ ])]),
1781
+ _: 1
1782
+ }, 16, ["hint", "label"])) : k("", !0),
1783
+ M.value ? (u(), p(e(fe), A({ key: 1 }, e(F)(e(g)), {
1784
+ "is-required": !0,
1785
+ label: e(a).t("wise_invoicing.invoice.detail.global_discount.amount.label"),
1786
+ min: 0.01,
1787
+ step: 0.01
1788
+ }), {
1789
+ right: s(() => [
1790
+ B("span", _n, Me(C.value.symbol), 1)
1791
+ ]),
1792
+ _: 1
1793
+ }, 16, ["label"])) : k("", !0)
1794
+ ]),
1795
+ _: 1
1796
+ })
1797
+ ]),
1798
+ _: 1
1799
+ })
1800
+ ]),
1801
+ _: 1
1802
+ }),
1803
+ o(e(re), null, {
1804
+ right: s(() => [
1805
+ o(e(ue), { label: "cancel" }),
1806
+ o(e(be), {
1807
+ label: e(a).t("wise_invoicing.invoice.detail.global_discount.confirm")
1808
+ }, null, 8, ["label"])
1809
+ ]),
1810
+ _: 1
1811
+ })
1812
+ ]),
1813
+ _: 1
1814
+ }, 8, ["form"]));
1815
+ }
1816
+ }), gn = /* @__PURE__ */ I({
1817
+ __name: "InvoiceLineItemsTableSection",
1818
+ props: {
1819
+ invoice: {}
1820
+ },
1821
+ setup(i) {
1822
+ const t = i, n = c(() => t.invoice), l = vn(), a = c(() => G.isEditable(t.invoice.status)), m = Xi({
1823
+ isSaving: c(() => l.isLoading.value),
1824
+ billingDocument: () => n.value,
1825
+ canEdit: a,
1826
+ updateLines: (v) => l.execute({
1827
+ body: v,
1828
+ params: {
1829
+ invoiceUuid: t.invoice.uuid
1830
+ }
1831
+ })
1832
+ }), _ = de().create(fn);
1833
+ function f() {
1834
+ _.open({
1835
+ invoice: t.invoice
1836
+ });
1837
+ }
1838
+ return et(m), (v, g) => (u(), p(Be, null, {
1839
+ default: s(() => [
1840
+ o(it, {
1841
+ "show-apply-discount": !0,
1842
+ onApplyDiscount: f
1843
+ }),
1844
+ o(tt),
1845
+ o(nt, {
1846
+ "billing-document": t.invoice
1847
+ }, null, 8, ["billing-document"]),
1848
+ o(ot)
1849
+ ]),
1850
+ _: 1
1851
+ }));
1852
+ }
1853
+ }), yn = /* @__PURE__ */ I({
1854
+ __name: "InvoiceDetailView",
1855
+ props: {
1856
+ invoice: {}
1857
+ },
1858
+ setup(i) {
1859
+ const t = i, n = x(), l = Te(!1), a = c(() => [
1860
+ {
1861
+ label: n.t("wise_invoicing.invoice.overview.title"),
1862
+ to: {
1863
+ name: "invoicing-invoice-overview"
1864
+ }
1865
+ },
1866
+ {
1867
+ label: t.invoice.sequence ?? t.invoice.subject ?? n.t("wise_invoicing.invoice.detail.fallback_title")
1868
+ }
1869
+ ]);
1870
+ return (m, d) => (u(), p(at, {
1871
+ "billing-document": t.invoice,
1872
+ breadcrumbs: a.value,
1873
+ title: e(n).t("wise_invoicing.invoice.detail.fallback_title")
1874
+ }, {
1875
+ header: s(() => [
1876
+ o(Gt, {
1877
+ invoice: t.invoice,
1878
+ "is-pdf-view-active": l.value,
1879
+ class: "w-full",
1880
+ onTogglePdfView: d[0] || (d[0] = (_) => l.value = !l.value)
1881
+ }, null, 8, ["invoice", "is-pdf-view-active"])
1882
+ ]),
1883
+ default: s(() => [
1884
+ l.value ? (u(), p(st, {
1885
+ key: 0,
1886
+ "billing-document": t.invoice,
1887
+ class: "w-full"
1888
+ }, null, 8, ["billing-document"])) : (u(), K(ae, { key: 1 }, [
1889
+ o(gn, {
1890
+ invoice: t.invoice
1891
+ }, null, 8, ["invoice"]),
1892
+ e(G).isEditable(t.invoice.status) ? k("", !0) : (u(), p(dn, {
1893
+ key: 0,
1894
+ invoice: t.invoice,
1895
+ class: "w-full"
1896
+ }, null, 8, ["invoice"])),
1897
+ o(Qt, {
1898
+ invoice: t.invoice,
1899
+ class: "w-full"
1900
+ }, null, 8, ["invoice"]),
1901
+ o(Zt, {
1902
+ invoice: t.invoice,
1903
+ class: "w-full"
1904
+ }, null, 8, ["invoice"])
1905
+ ], 64))
1906
+ ]),
1907
+ sidebar: s(() => [
1908
+ o(en, {
1909
+ invoice: t.invoice
1910
+ }, null, 8, ["invoice"])
1911
+ ]),
1912
+ _: 1
1913
+ }, 8, ["billing-document", "breadcrumbs", "title"]));
1914
+ }
1915
+ }), Ln = /* @__PURE__ */ I({
1916
+ __name: "InvoiceDetailViewDataProvider",
1917
+ props: {
1918
+ invoiceUuid: {}
1919
+ },
1920
+ setup(i) {
1921
+ const t = i, n = x(), l = c(() => [
1922
+ {
1923
+ label: n.t("wise_invoicing.invoice.overview.title"),
1924
+ to: {
1925
+ name: "invoicing-invoice-overview"
1926
+ }
1927
+ }
1928
+ ]), a = ui(c(() => t.invoiceUuid));
1929
+ return (m, d) => (u(), p(lt, {
1930
+ query: e(a),
1931
+ "loading-breadcrumbs": l.value
1932
+ }, {
1933
+ default: s(({ billingDocument: _ }) => [
1934
+ o(yn, { invoice: _ }, null, 8, ["invoice"])
1935
+ ]),
1936
+ _: 1
1937
+ }, 8, ["query", "loading-breadcrumbs"]));
1938
+ }
1939
+ });
1940
+ export {
1941
+ Ln as default
1942
+ };