@feedmepos/mf-report 5.3.15-rc.9 → 5.4.0-beta.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.
@@ -0,0 +1,2585 @@
1
+ import { defineComponent as M, mergeModels as Ve, useModel as L, computed as R, resolveComponent as V, openBlock as u, createElementBlock as k, createElementVNode as l, normalizeClass as De, Fragment as K, renderList as j, createVNode as o, createBlock as T, withCtx as ue, toDisplayString as me, createCommentVNode as Y, unref as H, ref as P, watch as re, isRef as pe, h as F, resolveDynamicComponent as de, onMounted as Ce } from "vue";
2
+ import { useRouter as oe, useRoute as Se } from "vue-router";
3
+ import { I as le, x as Ue, d as Fe, s as ce, c as fe, b as ve, a as ne, y as Te, z as Ie, A as Ne, w as ge, B as ye, E as xe, G as $e, H as ae, J as ke } from "./app-eKZV2PPB.js";
4
+ import { useSnackbar as se } from "@feedmepos/ui-library";
5
+ import { storeToRefs as be } from "pinia";
6
+ import { _ as we } from "./DateRangeSelect.vue_vue_type_script_setup_true_lang-G0LCMQmy.js";
7
+ const Ae = { class: "flex flex-row items-center w-[100%] gap-[4px] justify-between" }, Pe = {
8
+ key: 0,
9
+ class: "w-[50%]"
10
+ }, Ke = { class: "text-nowrap w-[100%] overflow-hidden text-ellipsis" }, Re = {
11
+ key: 0,
12
+ class: "w-[24px] flex items-center"
13
+ }, S = /* @__PURE__ */ M({
14
+ __name: "MappingField",
15
+ props: /* @__PURE__ */ Ve({
16
+ removable: {
17
+ type: Boolean,
18
+ default: !1
19
+ },
20
+ options: {
21
+ type: Object,
22
+ default: () => ({})
23
+ },
24
+ type: {
25
+ type: String,
26
+ default: "text"
27
+ },
28
+ rules: {
29
+ type: Array,
30
+ default: () => []
31
+ }
32
+ }, {
33
+ modelValue: { required: !0 },
34
+ modelModifiers: {}
35
+ }),
36
+ emits: /* @__PURE__ */ Ve(["remove"], ["update:modelValue"]),
37
+ setup(C, { emit: e }) {
38
+ const x = L(C, "modelValue"), h = C, f = R(
39
+ () => Object.keys(h.options).map(($) => {
40
+ const i = h.options[$];
41
+ return {
42
+ placeholder: i.placeholder,
43
+ key: $,
44
+ editable: i.editable
45
+ };
46
+ })
47
+ ), y = e;
48
+ return ($, i) => {
49
+ const D = V("FmTextField"), s = V("FmTooltip"), c = V("FmIcon");
50
+ return u(), k("div", Ae, [
51
+ l("div", {
52
+ class: De(`${C.removable ? "w-[calc(100%-24px)]" : "w-[100%]"} flex flex-row items-center gap-[4px]`)
53
+ }, [
54
+ (u(!0), k(K, null, j(f.value, (v) => {
55
+ var r;
56
+ return u(), k(K, {
57
+ key: v.key
58
+ }, [
59
+ v.editable ? (u(), k("div", Pe, [
60
+ o(D, {
61
+ "model-value": x.value[v.key],
62
+ placeholder: v.placeholder,
63
+ type: C.type,
64
+ rules: C.rules,
65
+ "onUpdate:modelValue": (w) => {
66
+ let a = w;
67
+ C.type === "number" && (a = Number(w)), x.value = {
68
+ ...x.value,
69
+ [v.key]: a
70
+ };
71
+ }
72
+ }, null, 8, ["model-value", "placeholder", "type", "rules", "onUpdate:modelValue"])
73
+ ])) : (u(), T(s, {
74
+ key: 1,
75
+ content: (r = x.value[v.key]) == null ? void 0 : r.toString(),
76
+ class: "w-[50%]"
77
+ }, {
78
+ default: ue(() => [
79
+ l("div", Ke, me(x.value[v.key]), 1)
80
+ ]),
81
+ _: 2
82
+ }, 1032, ["content"]))
83
+ ], 64);
84
+ }), 128))
85
+ ], 2),
86
+ C.removable ? (u(), k("div", Re, [
87
+ o(c, {
88
+ color: "system-error-300",
89
+ class: "cursor-pointer",
90
+ name: "close",
91
+ size: "md",
92
+ onClick: i[0] || (i[0] = (v) => y("remove"))
93
+ })
94
+ ])) : Y("", !0)
95
+ ]);
96
+ };
97
+ }
98
+ }), Me = { class: "flex flex-row items-center" }, Be = { class: "flex flex-row items-center fm-typo-en-title-sm-800 h-[36px]" }, je = { class: "flex flex-row items-center w-[100%] justify-start" }, Le = {
99
+ key: 0,
100
+ class: "flex flex-row items-center w-[100%] justify-start"
101
+ }, Oe = { class: "w-[calc(75%+4px)]" }, Ee = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, He = { class: "flex flex-row items-center w-[100%] justify-between" }, Ye = { class: "text-nowrap w-[50%] overflow-hidden text-ellipsis" }, qe = { class: "w-[50%]" }, _e = /* @__PURE__ */ M({
102
+ __name: "UploadSection",
103
+ props: /* @__PURE__ */ Ve({
104
+ label: {
105
+ type: String,
106
+ default: "upload"
107
+ }
108
+ }, {
109
+ modelValue: { required: !0 },
110
+ modelModifiers: {}
111
+ }),
112
+ emits: ["update:modelValue"],
113
+ setup(C) {
114
+ const e = L(C, "modelValue"), x = R(() => {
115
+ switch (e.value.name) {
116
+ case le.AutoCount:
117
+ case le.SQL:
118
+ case le.iFlexi_HRMS:
119
+ return !0;
120
+ default:
121
+ return !1;
122
+ }
123
+ });
124
+ return (h, f) => {
125
+ var D, s;
126
+ const y = V("FmSwitch"), $ = V("FmTextField"), i = V("FmTimePicker");
127
+ return u(), k(K, null, [
128
+ l("div", Me, [
129
+ l("div", Be, "Auto " + me(C.label), 1)
130
+ ]),
131
+ l("div", je, [
132
+ f[4] || (f[4] = l("div", { class: "text-nowrap w-[calc(25%-4px)] overflow-hidden text-ellipsis" }, "Enable", -1)),
133
+ o(y, {
134
+ modelValue: e.value.enable,
135
+ "onUpdate:modelValue": f[0] || (f[0] = (c) => e.value.enable = c),
136
+ style: { gap: "0px" }
137
+ }, null, 8, ["modelValue"])
138
+ ]),
139
+ x.value ? (u(), k("div", Le, [
140
+ f[5] || (f[5] = l("div", { class: "text-nowrap w-[calc(25%-4px)] overflow-hidden text-ellipsis" }, "Email", -1)),
141
+ l("div", Oe, [
142
+ o($, {
143
+ "model-value": (e.value.emails || []).join(","),
144
+ placeholder: "Email",
145
+ "onUpdate:modelValue": f[1] || (f[1] = (c) => {
146
+ switch (e.value.name) {
147
+ case H(le).AutoCount:
148
+ case H(le).SQL:
149
+ case H(le).iFlexi_HRMS:
150
+ e.value.emails = c.split(",");
151
+ break;
152
+ }
153
+ })
154
+ }, null, 8, ["model-value"])
155
+ ])
156
+ ])) : Y("", !0),
157
+ l("div", Ee, [
158
+ l("div", He, [
159
+ l("div", Ye, me(H(Ue)(C.label)) + " time ", 1),
160
+ l("div", qe, [
161
+ o(i, {
162
+ class: "gap-[0px]",
163
+ "model-value": H(Fe)().hour(((D = e.value.triggerTime) == null ? void 0 : D.hour) ?? 0).minute(((s = e.value.triggerTime) == null ? void 0 : s.minute) ?? 0).format("HH:mm"),
164
+ "onUpdate:modelValue": f[2] || (f[2] = (c) => {
165
+ c && (e.value.triggerTime.hour = Number(c.split(":")[0]), e.value.triggerTime.minute = Number(c.split(":")[1]));
166
+ })
167
+ }, null, 8, ["model-value"])
168
+ ])
169
+ ]),
170
+ o(S, {
171
+ "model-value": {
172
+ label: "Delay day",
173
+ delayDay: e.value.delayDay
174
+ },
175
+ type: "number",
176
+ options: {
177
+ label: { placeholder: "Delay day", editable: !1 },
178
+ delayDay: { placeholder: "Delay day", editable: !0 }
179
+ },
180
+ rules: [(c) => c > 0 || "Delay days must be greater than 0"],
181
+ "onUpdate:modelValue": f[3] || (f[3] = (c) => {
182
+ e.value.delayDay = c.delayDay;
183
+ })
184
+ }, null, 8, ["model-value", "rules"])
185
+ ])
186
+ ], 64);
187
+ };
188
+ }
189
+ }), Ge = {
190
+ key: 0,
191
+ class: "flex flex-col h-full"
192
+ }, Qe = { class: "flex flex-col gap-[16px] pb-[24px]" }, Xe = { class: "flex flex-row justify-between items-center gap-2" }, ze = { class: "flex flex-row gap-2" }, Je = { class: "flex flex-col gap-16 pt-[24px] overflow-scroll" }, We = { class: "flex flex-row items-center justify-between gap-2" }, Ze = { class: "w-[25%]" }, et = { class: "flex flex-col gap-[16px]" }, tt = { class: "flex flex-row items-center max-w-[100%] justify-between" }, lt = { class: "flex-grow" }, at = { class: "flex flex-row items-center max-w-[100%] justify-between" }, ot = { class: "flex flex-col gap-[16px]" }, nt = { class: "flex flex-row items-center max-w-[100%] justify-between" }, st = { class: "flex-grow" }, it = { class: "flex flex-row items-center max-w-[100%] justify-between" }, rt = { class: "flex-grow" }, mt = {
193
+ key: 0,
194
+ class: "flex flex-row items-center max-w-[100%] justify-between"
195
+ }, ut = { class: "flex-grow" }, dt = { class: "w-[25%]" }, ct = { class: "flex-grow" }, pt = { class: "flex-grow" }, ft = { class: "w-[25%]" }, vt = { class: "flex-grow" }, gt = { class: "w-[25%]" }, yt = { class: "flex-grow" }, xt = /* @__PURE__ */ M({
196
+ __name: "Setting",
197
+ props: {
198
+ modelValue: { required: !0 },
199
+ modelModifiers: {}
200
+ },
201
+ emits: ["update:modelValue"],
202
+ setup(C) {
203
+ const e = L(C, "modelValue"), x = se(), h = ce(), f = oe(), { promptLoader: y } = fe(), { promptMessage: $ } = ve(), { restaurants: i } = ne(), D = P(!1), s = R(
204
+ () => i.map((p) => ({ label: p.name, value: p.id }))
205
+ ), c = P([]), v = R(() => {
206
+ var p, d;
207
+ return D.value ? "Connecting" : (d = (p = e.value) == null ? void 0 : p.platform) != null && d.accessToken ? "Disconnect" : "Connect";
208
+ });
209
+ re(
210
+ () => {
211
+ var p;
212
+ return (p = e.value.platform) == null ? void 0 : p.accessToken;
213
+ },
214
+ (p) => {
215
+ p && w();
216
+ },
217
+ { immediate: !0 }
218
+ );
219
+ const r = P(0);
220
+ async function w() {
221
+ e.value._id && (c.value = (await Te(e.value._id)).map((p) => ({
222
+ value: p.id,
223
+ label: p.name
224
+ })));
225
+ }
226
+ async function a() {
227
+ var p, d, N;
228
+ if (D.value)
229
+ x.open({ type: "error", message: "Connecting in progress" });
230
+ else if ((p = e.value.platform) != null && p.accessToken)
231
+ await $({
232
+ message: `Confirm disconnect ${(N = (d = e.value.platform) == null ? void 0 : d.tenant) == null ? void 0 : N.name}`,
233
+ title: "Disconnect Xero"
234
+ }) && (await Ie(e.value._id), await h.getSettings(), c.value = []);
235
+ else if (e.value._id)
236
+ try {
237
+ const I = await Ne(e.value._id);
238
+ D.value = !0;
239
+ const O = setInterval(async () => {
240
+ var A;
241
+ r.value += 1;
242
+ try {
243
+ await h.getSettings();
244
+ } finally {
245
+ (r.value === 12 || (A = e.value.platform) != null && A.accessToken) && (D.value = !1, O && clearInterval(O), r.value = 0);
246
+ }
247
+ }, 5e3);
248
+ window.open(I.redirect, "_blank");
249
+ } catch (I) {
250
+ x.open({ type: "error", message: I.message });
251
+ }
252
+ else
253
+ x.open({ type: "error", message: `invalid accounting ${e.value._id}` });
254
+ }
255
+ async function b() {
256
+ await $({
257
+ message: `Confirm delete ${e.value.name}?`,
258
+ title: "Delete"
259
+ }) && await y(async () => {
260
+ try {
261
+ await ge(e.value._id), await h.getSettings(), f.back();
262
+ } catch (d) {
263
+ x.open({ type: "error", message: d.message });
264
+ }
265
+ });
266
+ }
267
+ async function m() {
268
+ await y(async () => {
269
+ try {
270
+ await ye(e.value._id, e.value), await h.getSettings();
271
+ } catch (p) {
272
+ x.open({ type: "error", message: p.message });
273
+ }
274
+ });
275
+ }
276
+ function t(p) {
277
+ const d = c.value.find((N) => N.value === p);
278
+ d && e.value.platform && (e.value.platform.tenant = {
279
+ id: d.value,
280
+ name: d.label
281
+ });
282
+ }
283
+ return (p, d) => {
284
+ var E, q, G, Q, X, z, J, W, Z, ee, te, g;
285
+ const N = V("FmButton"), I = V("FmMenuDivider"), O = V("FmSelect"), A = V("FmTextField"), B = V("FmSwitch");
286
+ return (q = (E = e.value) == null ? void 0 : E.platform) != null && q.mappings ? (u(), k("div", Ge, [
287
+ l("div", Qe, [
288
+ l("div", Xe, [
289
+ d[5] || (d[5] = l("div", { class: "fm-typo-en-title-sm-800" }, "Connect", -1)),
290
+ l("div", ze, [
291
+ o(N, {
292
+ variant: "tertiary",
293
+ label: "Delete",
294
+ onClick: b
295
+ }),
296
+ o(N, {
297
+ variant: "primary",
298
+ label: "Update",
299
+ onClick: m
300
+ })
301
+ ])
302
+ ])
303
+ ]),
304
+ o(I, { style: { margin: 0 } }),
305
+ l("div", Je, [
306
+ d[14] || (d[14] = l("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Authenticate with your official Xero account to enable FeedMe to securely upload data to Xero. ", -1)),
307
+ l("div", We, [
308
+ l("div", Ze, [
309
+ o(N, {
310
+ disabled: D.value,
311
+ variant: "primary",
312
+ label: v.value,
313
+ onClick: a
314
+ }, null, 8, ["disabled", "label"])
315
+ ]),
316
+ c.value.length > 0 ? (u(), T(O, {
317
+ key: 0,
318
+ class: "flex-grow",
319
+ items: c.value,
320
+ "model-value": (G = e.value.platform.tenant) == null ? void 0 : G.id,
321
+ placeholder: "Select tenant",
322
+ "onUpdate:modelValue": t
323
+ }, null, 8, ["items", "model-value"])) : Y("", !0)
324
+ ]),
325
+ l("div", et, [
326
+ d[8] || (d[8] = l("div", { class: "flex flex-row items-center fm-typo-en-title-sm-800 h-[36px]" }, "General", -1)),
327
+ l("div", tt, [
328
+ d[6] || (d[6] = l("div", { class: "w-[25%]" }, "Name", -1)),
329
+ l("div", lt, [
330
+ o(A, {
331
+ modelValue: e.value.name,
332
+ "onUpdate:modelValue": d[0] || (d[0] = (n) => e.value.name = n)
333
+ }, null, 8, ["modelValue"])
334
+ ])
335
+ ]),
336
+ l("div", at, [
337
+ d[7] || (d[7] = l("div", { class: "w-[25%]" }, "Location", -1)),
338
+ o(O, {
339
+ modelValue: e.value.platform.locationIds,
340
+ "onUpdate:modelValue": d[1] || (d[1] = (n) => e.value.platform.locationIds = n),
341
+ multiselect: !0,
342
+ items: s.value,
343
+ placeholder: "Select location",
344
+ class: "flex-grow"
345
+ }, null, 8, ["modelValue", "items"])
346
+ ])
347
+ ]),
348
+ l("div", ot, [
349
+ d[12] || (d[12] = l("div", { class: "flex flex-row items-center fm-typo-en-title-sm-800 h-[36px]" }, "Mapping", -1)),
350
+ l("div", nt, [
351
+ d[9] || (d[9] = l("div", { class: "w-[25%]" }, "Contact", -1)),
352
+ l("div", st, [
353
+ o(A, {
354
+ modelValue: e.value.platform.mappings.contact.xero.key,
355
+ "onUpdate:modelValue": d[2] || (d[2] = (n) => e.value.platform.mappings.contact.xero.key = n),
356
+ placeholder: "Contact account number"
357
+ }, null, 8, ["modelValue"])
358
+ ])
359
+ ]),
360
+ l("div", it, [
361
+ d[10] || (d[10] = l("div", { class: "w-[25%]" }, "Discount as Item", -1)),
362
+ l("div", rt, [
363
+ o(B, {
364
+ "model-value": e.value.platform.discountItem ?? !1,
365
+ style: { gap: 0 },
366
+ "onUpdate:modelValue": d[3] || (d[3] = (n) => {
367
+ e.value.platform.discountItem = n;
368
+ })
369
+ }, null, 8, ["model-value"])
370
+ ])
371
+ ]),
372
+ e.value.platform.mappings.rounding ? (u(), k("div", mt, [
373
+ d[11] || (d[11] = l("div", { class: "w-[25%]" }, "Rounding", -1)),
374
+ l("div", ut, [
375
+ o(A, {
376
+ modelValue: e.value.platform.mappings.rounding.xero.key,
377
+ "onUpdate:modelValue": d[4] || (d[4] = (n) => e.value.platform.mappings.rounding.xero.key = n),
378
+ placeholder: "Item account code"
379
+ }, null, 8, ["modelValue"])
380
+ ])
381
+ ])) : Y("", !0),
382
+ (u(!0), k(K, null, j((z = (X = (Q = e.value) == null ? void 0 : Q.platform) == null ? void 0 : X.mappings) == null ? void 0 : z.items, (n, _) => (u(), k("div", {
383
+ key: `item-${_}`,
384
+ class: "flex flex-row items-center max-w-[100%] justify-between"
385
+ }, [
386
+ l("div", dt, me(n.feedme.name), 1),
387
+ l("div", ct, [
388
+ n.xeroTax ? (u(), T(A, {
389
+ key: 0,
390
+ modelValue: n.xeroTax.key,
391
+ "onUpdate:modelValue": (U) => n.xeroTax.key = U,
392
+ placeholder: "Tax name"
393
+ }, null, 8, ["modelValue", "onUpdate:modelValue"])) : Y("", !0)
394
+ ]),
395
+ l("div", pt, [
396
+ o(A, {
397
+ modelValue: n.xero.key,
398
+ "onUpdate:modelValue": (U) => n.xero.key = U,
399
+ placeholder: "Item account code"
400
+ }, null, 8, ["modelValue", "onUpdate:modelValue"])
401
+ ])
402
+ ]))), 128)),
403
+ (u(!0), k(K, null, j((Z = (W = (J = e.value) == null ? void 0 : J.platform) == null ? void 0 : W.mappings) == null ? void 0 : Z.charges, (n, _) => (u(), k("div", {
404
+ key: `charge-${_}`,
405
+ class: "flex flex-row items-center max-w-[100%] justify-between"
406
+ }, [
407
+ l("div", ft, me(n.feedme.name), 1),
408
+ l("div", vt, [
409
+ o(A, {
410
+ modelValue: n.xero.key,
411
+ "onUpdate:modelValue": (U) => n.xero.key = U,
412
+ placeholder: "Item account code"
413
+ }, null, 8, ["modelValue", "onUpdate:modelValue"])
414
+ ])
415
+ ]))), 128)),
416
+ d[13] || (d[13] = l("div", { class: "flex flex-row items-center fm-typo-en-title-sm-800 h-[36px]" }, "Payments", -1)),
417
+ (u(!0), k(K, null, j((g = (te = (ee = e.value) == null ? void 0 : ee.platform) == null ? void 0 : te.mappings) == null ? void 0 : g.payments, (n, _) => (u(), k("div", {
418
+ key: `payment-${_}`,
419
+ class: "flex flex-row items-center max-w-[100%] justify-between"
420
+ }, [
421
+ l("div", gt, me(n.feedme.name), 1),
422
+ l("div", yt, [
423
+ o(A, {
424
+ modelValue: n.xero.key,
425
+ "onUpdate:modelValue": (U) => n.xero.key = U,
426
+ placeholder: "Payment account code"
427
+ }, null, 8, ["modelValue", "onUpdate:modelValue"])
428
+ ])
429
+ ]))), 128))
430
+ ])
431
+ ])
432
+ ])) : Y("", !0);
433
+ };
434
+ }
435
+ }), bt = { class: "h-full flex flex-col gap-16" }, wt = { class: "flex flex-row gap-2 justify-between items-center" }, _t = {
436
+ key: 0,
437
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
438
+ }, Vt = /* @__PURE__ */ M({
439
+ __name: "Preview",
440
+ props: {
441
+ modelValue: { required: !0 },
442
+ modelModifiers: {}
443
+ },
444
+ emits: ["update:modelValue"],
445
+ setup(C) {
446
+ const e = P([]), x = R(
447
+ () => e.value.reduce((s, c) => {
448
+ const v = s.length, { invoice: r, payments: w } = c;
449
+ s[v] = {
450
+ date: r.Date,
451
+ contact: r.Contact.ContactID,
452
+ status: r.Status,
453
+ ref: r.Reference
454
+ };
455
+ for (let a = 0; a < Math.max(r.LineItems.length, w.length); a++) {
456
+ const b = v + a;
457
+ s[b] || (s[b] = {}), r.LineItems[a] && (s[b] = {
458
+ ...s[b],
459
+ itemDescription: r.LineItems[a].Description,
460
+ itemQuantity: r.LineItems[a].Quantity,
461
+ itemUnitAmount: r.LineItems[a].UnitAmount,
462
+ itemCode: r.LineItems[a].ItemCode,
463
+ itemAccount: r.LineItems[a].AccountCode,
464
+ itemTax: r.LineItems[a].TaxAmount,
465
+ itemTaxType: r.LineItems[a].TaxType,
466
+ itemAmount: r.LineItems[a].LineAmount,
467
+ itemDiscount: r.LineItems[a].DiscountAmount
468
+ }), w[a] && (s[b] = {
469
+ ...s[b],
470
+ paymentAccount: w[a].Account.Code,
471
+ paymentReference: w[a].Reference,
472
+ paymentAmount: w[a].Amount
473
+ });
474
+ }
475
+ return s;
476
+ }, [])
477
+ ), h = [
478
+ {
479
+ accessorKey: "date",
480
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
481
+ enableSorting: !1
482
+ },
483
+ {
484
+ accessorKey: "status",
485
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Status"),
486
+ enableSorting: !1
487
+ },
488
+ {
489
+ accessorKey: "ref",
490
+ header: "Reference",
491
+ enableSorting: !1
492
+ },
493
+ {
494
+ accessorKey: "itemDescription",
495
+ header: () => F("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
496
+ enableSorting: !1
497
+ },
498
+ {
499
+ accessorKey: "itemQuantity",
500
+ header: "Item Quantity",
501
+ enableSorting: !1
502
+ },
503
+ {
504
+ accessorKey: "itemUnitAmount",
505
+ header: "Item Unit Amount",
506
+ enableSorting: !1
507
+ },
508
+ {
509
+ accessorKey: "itemCode",
510
+ header: "Item Code",
511
+ enableSorting: !1
512
+ },
513
+ {
514
+ accessorKey: "itemAccount",
515
+ header: () => F("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
516
+ enableSorting: !1
517
+ },
518
+ {
519
+ accessorKey: "itemTaxType",
520
+ header: "Item Tax Type",
521
+ enableSorting: !1
522
+ },
523
+ {
524
+ accessorKey: "itemTax",
525
+ header: "Item Tax",
526
+ enableSorting: !1
527
+ },
528
+ {
529
+ accessorKey: "itemAmount",
530
+ header: "Item Amount",
531
+ enableSorting: !1
532
+ },
533
+ {
534
+ accessorKey: "itemDiscount",
535
+ header: "Item Discount",
536
+ enableSorting: !1
537
+ },
538
+ {
539
+ accessorKey: "paymentAccount",
540
+ header: "Payment Account",
541
+ enableSorting: !1
542
+ },
543
+ {
544
+ accessorKey: "paymentReference",
545
+ header: "Payment Reference",
546
+ enableSorting: !1
547
+ },
548
+ {
549
+ accessorKey: "paymentAmount",
550
+ header: "Payment Amount",
551
+ enableSorting: !1
552
+ }
553
+ ], f = L(C, "modelValue"), y = P(!1), $ = se(), { dateRange: i } = be(ne());
554
+ re(
555
+ () => i.value,
556
+ async () => {
557
+ if (f.value._id)
558
+ try {
559
+ y.value = !0, e.value = await xe(f.value._id);
560
+ } catch (s) {
561
+ $.open({ message: s.message, type: "error" });
562
+ } finally {
563
+ y.value = !1;
564
+ }
565
+ },
566
+ {
567
+ immediate: !0
568
+ }
569
+ );
570
+ async function D() {
571
+ try {
572
+ f.value._id ? (y.value = !0, await $e(f.value._id), $.open({ message: "Upload successful", type: "success" })) : $.open({ message: "Invalid accounting setting", type: "error" });
573
+ } catch {
574
+ $.open({ message: "Failed to upload", type: "error" });
575
+ } finally {
576
+ y.value = !1;
577
+ }
578
+ }
579
+ return (s, c) => {
580
+ const v = V("FmButton"), r = V("FmCircularProgress"), w = V("FmTable");
581
+ return u(), k("div", bt, [
582
+ l("div", wt, [
583
+ o(we, {
584
+ "date-range": H(i),
585
+ "onUpdate:dateRange": c[0] || (c[0] = (a) => pe(i) ? i.value = a : null),
586
+ compare: !1
587
+ }, null, 8, ["date-range"]),
588
+ o(v, {
589
+ loading: y.value,
590
+ variant: "primary",
591
+ label: "Upload",
592
+ onClick: D
593
+ }, null, 8, ["loading"])
594
+ ]),
595
+ y.value ? (u(), k("div", _t, [
596
+ o(r, { size: "xl" }),
597
+ c[1] || (c[1] = l("span", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Loading data... ", -1))
598
+ ])) : x.value.length > 0 ? (u(), T(w, {
599
+ key: 1,
600
+ class: "flex overflow-scroll",
601
+ "row-data": x.value,
602
+ "column-defs": h
603
+ }, null, 8, ["row-data"])) : Y("", !0)
604
+ ]);
605
+ };
606
+ }
607
+ }), kt = { class: "h-full relative flex flex-col" }, ht = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, $t = /* @__PURE__ */ M({
608
+ __name: "Xero",
609
+ props: {
610
+ modelValue: {},
611
+ modelModifiers: {}
612
+ },
613
+ emits: ["update:modelValue"],
614
+ setup(C) {
615
+ const e = L(C, "modelValue"), x = P("setting"), h = [
616
+ {
617
+ label: "Setting",
618
+ value: "setting",
619
+ icon: "settings"
620
+ },
621
+ {
622
+ label: "Preview",
623
+ value: "preview",
624
+ icon: "table"
625
+ }
626
+ ], f = oe(), y = R(() => {
627
+ switch (x.value) {
628
+ case "preview":
629
+ return Vt;
630
+ case "setting":
631
+ return xt;
632
+ default:
633
+ return null;
634
+ }
635
+ });
636
+ return ($, i) => {
637
+ var c;
638
+ const D = V("FmPageHead"), s = V("FmTabs");
639
+ return u(), k("div", kt, [
640
+ o(D, {
641
+ title: ((c = e.value) == null ? void 0 : c.name) || "Xero",
642
+ "back-button": !0,
643
+ style: { paddingLeft: "0px", paddingRight: "0px" },
644
+ "onClick:back": H(f).back
645
+ }, {
646
+ description: ue(() => i[2] || (i[2] = [
647
+ l("div", null, null, -1)
648
+ ])),
649
+ _: 1
650
+ }, 8, ["title", "onClick:back"]),
651
+ o(s, {
652
+ "model-value": x.value,
653
+ "onUpdate:modelValue": i[0] || (i[0] = (v) => x.value = v),
654
+ items: h
655
+ }, null, 8, ["model-value"]),
656
+ l("div", ht, [
657
+ (u(), T(de(y.value), {
658
+ modelValue: e.value,
659
+ "onUpdate:modelValue": i[1] || (i[1] = (v) => e.value = v)
660
+ }, null, 8, ["modelValue"]))
661
+ ])
662
+ ]);
663
+ };
664
+ }
665
+ }), Dt = {
666
+ key: 0,
667
+ class: "flex flex-col h-full"
668
+ }, Ct = { class: "flex flex-col gap-16 pb-[24px]" }, St = { class: "flex flex-row justify-between items-center gap-2" }, Ut = { class: "flex flex-row gap-2" }, Ft = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, Tt = { class: "flex flex-row items-center justify-between" }, It = { class: "flex-grow" }, Nt = { class: "flex flex-row items-center justify-between" }, At = { class: "flex-grow" }, Pt = { class: "flex flex-col gap-16" }, Kt = { class: "flex flex-row items-center max-w-[100%]" }, Rt = { class: "flex-grow" }, Mt = { class: "flex flex-row items-center max-w-[100%]" }, Bt = { class: "flex flex-row items-center max-w-[100%]" }, jt = { class: "flex flex-col gap-16" }, Lt = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Ot = { class: "flex flex-row items-center gap-x-16" }, Et = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Ht = { class: "flex flex-row items-center gap-x-16" }, Yt = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, qt = { class: "flex flex-row items-center gap-x-16" }, Gt = { class: "flex flex-row items-center" }, Qt = /* @__PURE__ */ M({
669
+ __name: "Setting",
670
+ props: {
671
+ modelValue: { required: !0 },
672
+ modelModifiers: {}
673
+ },
674
+ emits: ["update:modelValue"],
675
+ setup(C) {
676
+ const e = L(C, "modelValue"), x = se(), h = ce(), f = oe(), { promptLoader: y } = fe(), { promptMessage: $ } = ve(), { restaurants: i } = ne(), D = R(
677
+ () => i.map((m) => ({ label: m.name, value: m.id }))
678
+ );
679
+ async function s() {
680
+ await $({
681
+ message: `Confirm delete ${e.value.name}?`,
682
+ title: "Delete"
683
+ }) && await y(async () => {
684
+ try {
685
+ await ge(e.value._id), await h.getSettings(), f.back();
686
+ } catch (t) {
687
+ x.open({ type: "error", message: t.message });
688
+ }
689
+ });
690
+ }
691
+ async function c() {
692
+ await y(async () => {
693
+ try {
694
+ await ye(e.value._id, e.value), await h.getSettings();
695
+ } catch (m) {
696
+ x.open({ type: "error", message: m.message });
697
+ }
698
+ });
699
+ }
700
+ function v(m, t) {
701
+ var p, d;
702
+ (d = (p = e.value.platform) == null ? void 0 : p.mappings) != null && d[m] && (e.value.platform.mappings[m] = e.value.platform.mappings[m].filter(
703
+ (N, I) => I !== t
704
+ ));
705
+ }
706
+ function r(m) {
707
+ var t, p;
708
+ if ((p = (t = e.value.platform) == null ? void 0 : t.mappings) != null && p[m]) {
709
+ let d;
710
+ switch (m) {
711
+ case "items":
712
+ d = {
713
+ key: "",
714
+ account: "",
715
+ accountName: ""
716
+ };
717
+ break;
718
+ case "payments":
719
+ d = {
720
+ key: "",
721
+ account: "",
722
+ accountName: "",
723
+ method: ""
724
+ };
725
+ break;
726
+ default:
727
+ d = {
728
+ key: "",
729
+ account: ""
730
+ };
731
+ break;
732
+ }
733
+ e.value.platform.mappings[m] = [
734
+ ...e.value.platform.mappings[m],
735
+ d
736
+ ];
737
+ }
738
+ }
739
+ const w = [
740
+ {
741
+ label: "By day",
742
+ value: ae.BY_DAY
743
+ },
744
+ {
745
+ label: "By day and item",
746
+ value: ae.BY_DAY_ITEM
747
+ },
748
+ {
749
+ label: "By invoice",
750
+ value: ae.BY_INVOICE
751
+ },
752
+ {
753
+ label: "By day and separate payment",
754
+ value: ae.BY_DAY_SEPARATE_PAYMENT
755
+ }
756
+ ];
757
+ function a({
758
+ key: m,
759
+ value: t
760
+ }) {
761
+ var p, d;
762
+ (d = (p = e.value) == null ? void 0 : p.platform) != null && d.mappings && (e.value.platform.mappings[m] = t);
763
+ }
764
+ function b(m) {
765
+ return {
766
+ key: { placeholder: m, editable: !1 },
767
+ account: { placeholder: m, editable: !0 }
768
+ };
769
+ }
770
+ return (m, t) => {
771
+ var A, B, E, q, G, Q, X, z, J, W, Z, ee, te, g;
772
+ const p = V("FmButton"), d = V("FmMenuDivider"), N = V("FmTextField"), I = V("FmSelect"), O = V("FmCheckbox");
773
+ return (B = (A = e.value) == null ? void 0 : A.platform) != null && B.mappings ? (u(), k("div", Dt, [
774
+ l("div", Ct, [
775
+ l("div", St, [
776
+ t[15] || (t[15] = l("div", { class: "fm-typo-en-title-sm-800" }, "Connect", -1)),
777
+ l("div", Ut, [
778
+ o(p, {
779
+ variant: "tertiary",
780
+ label: "Delete",
781
+ onClick: s
782
+ }),
783
+ o(p, {
784
+ variant: "primary",
785
+ label: "Update",
786
+ onClick: c
787
+ })
788
+ ])
789
+ ])
790
+ ]),
791
+ o(d, { style: { margin: 0 } }),
792
+ l("div", Ft, [
793
+ t[25] || (t[25] = l("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Authenticate with your official Bukku account to enable FeedMe to securely upload data to Bukku. ", -1)),
794
+ l("div", Tt, [
795
+ t[16] || (t[16] = l("div", { class: "w-[25%]" }, "Subdomain", -1)),
796
+ l("div", It, [
797
+ o(N, {
798
+ modelValue: e.value.platform.subdomain,
799
+ "onUpdate:modelValue": t[0] || (t[0] = (n) => e.value.platform.subdomain = n),
800
+ placeholder: "Subdomain"
801
+ }, null, 8, ["modelValue"])
802
+ ])
803
+ ]),
804
+ l("div", Nt, [
805
+ t[17] || (t[17] = l("div", { class: "w-[25%]" }, "Token", -1)),
806
+ l("div", At, [
807
+ o(N, {
808
+ modelValue: e.value.platform.token,
809
+ "onUpdate:modelValue": t[1] || (t[1] = (n) => e.value.platform.token = n),
810
+ placeholder: "Token"
811
+ }, null, 8, ["modelValue"])
812
+ ])
813
+ ]),
814
+ l("div", Pt, [
815
+ t[21] || (t[21] = l("div", { class: "fm-typo-en-title-sm-800" }, "General", -1)),
816
+ l("div", Kt, [
817
+ t[18] || (t[18] = l("div", { class: "w-[25%]" }, "Name", -1)),
818
+ l("div", Rt, [
819
+ o(N, {
820
+ modelValue: e.value.name,
821
+ "onUpdate:modelValue": t[2] || (t[2] = (n) => e.value.name = n)
822
+ }, null, 8, ["modelValue"])
823
+ ])
824
+ ]),
825
+ l("div", Mt, [
826
+ t[19] || (t[19] = l("div", { class: "w-[25%]" }, "Location", -1)),
827
+ o(I, {
828
+ modelValue: e.value.platform.locationIds,
829
+ "onUpdate:modelValue": t[3] || (t[3] = (n) => e.value.platform.locationIds = n),
830
+ multiselect: !0,
831
+ items: D.value,
832
+ placeholder: "Select location",
833
+ class: "flex-grow"
834
+ }, null, 8, ["modelValue", "items"])
835
+ ]),
836
+ l("div", Bt, [
837
+ t[20] || (t[20] = l("div", { class: "w-[25%]" }, "Grouping", -1)),
838
+ o(I, {
839
+ modelValue: e.value.platform.grouping,
840
+ "onUpdate:modelValue": t[4] || (t[4] = (n) => e.value.platform.grouping = n),
841
+ multiselect: !1,
842
+ items: w,
843
+ placeholder: "Select grouping",
844
+ class: "flex-grow"
845
+ }, null, 8, ["modelValue"])
846
+ ])
847
+ ]),
848
+ l("div", jt, [
849
+ l("div", Lt, [
850
+ o(S, {
851
+ "model-value": {
852
+ key: "Contact",
853
+ account: e.value.platform.mappings.contact.account
854
+ },
855
+ options: {
856
+ key: { placeholder: "Contact", editable: !1 },
857
+ account: { placeholder: "Contact", editable: !0 }
858
+ },
859
+ "onUpdate:modelValue": t[5] || (t[5] = (n) => {
860
+ var _, U, ie;
861
+ (ie = (U = (_ = e.value) == null ? void 0 : _.platform) == null ? void 0 : U.mappings) != null && ie.contact && (e.value.platform.mappings.contact.account = n.account);
862
+ })
863
+ }, null, 8, ["model-value"]),
864
+ o(S, {
865
+ "model-value": {
866
+ key: "Invoice no",
867
+ account: e.value.platform.mappings.invoiceDocNo
868
+ },
869
+ options: b("Invoice no"),
870
+ "onUpdate:modelValue": t[6] || (t[6] = (n) => a({ key: "invoiceDocNo", value: n.account }))
871
+ }, null, 8, ["model-value", "options"]),
872
+ o(S, {
873
+ "model-value": {
874
+ key: "Credit note no",
875
+ account: e.value.platform.mappings.creditNoteDocNo
876
+ },
877
+ options: b("Credit note no"),
878
+ "onUpdate:modelValue": t[7] || (t[7] = (n) => a({ key: "creditNoteDocNo", value: n.account }))
879
+ }, null, 8, ["model-value", "options"]),
880
+ o(S, {
881
+ "model-value": {
882
+ key: "Payment no",
883
+ account: e.value.platform.mappings.paymentDocNo
884
+ },
885
+ options: b("Payment no"),
886
+ "onUpdate:modelValue": t[8] || (t[8] = (n) => a({ key: "paymentDocNo", value: n.account }))
887
+ }, null, 8, ["model-value", "options"]),
888
+ o(S, {
889
+ "model-value": {
890
+ key: "Refund no",
891
+ account: e.value.platform.mappings.refundDocNo
892
+ },
893
+ options: b("Refund no"),
894
+ "onUpdate:modelValue": t[9] || (t[9] = (n) => a({ key: "refundDocNo", value: n.account }))
895
+ }, null, 8, ["model-value", "options"]),
896
+ o(S, {
897
+ "model-value": {
898
+ key: "Rounding",
899
+ account: e.value.platform.mappings.rounding.account
900
+ },
901
+ options: b("Rounding"),
902
+ "onUpdate:modelValue": t[10] || (t[10] = (n) => {
903
+ var _, U, ie;
904
+ (ie = (U = (_ = e.value) == null ? void 0 : _.platform) == null ? void 0 : U.mappings) != null && ie.rounding && (e.value.platform.mappings.rounding.account = n.account);
905
+ })
906
+ }, null, 8, ["model-value", "options"]),
907
+ (u(!0), k(K, null, j((G = (q = (E = e.value) == null ? void 0 : E.platform) == null ? void 0 : q.mappings) == null ? void 0 : G.charges, (n, _) => (u(), T(S, {
908
+ key: `charge-${_}`,
909
+ modelValue: e.value.platform.mappings.charges[_],
910
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.charges[_] = U,
911
+ options: {
912
+ key: { placeholder: "Key", editable: !1 },
913
+ account: { placeholder: "Account code", editable: !0 }
914
+ }
915
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]))), 128))
916
+ ])
917
+ ]),
918
+ o(_e, {
919
+ modelValue: e.value.platform,
920
+ "onUpdate:modelValue": t[11] || (t[11] = (n) => e.value.platform = n),
921
+ label: "upload"
922
+ }, null, 8, ["modelValue"]),
923
+ l("div", Ot, [
924
+ t[22] || (t[22] = l("div", { class: "fm-typo-en-title-sm-800" }, "Items", -1)),
925
+ o(p, {
926
+ variant: "primary",
927
+ icon: "add",
928
+ onClick: t[12] || (t[12] = () => r("items"))
929
+ })
930
+ ]),
931
+ l("div", Et, [
932
+ (u(!0), k(K, null, j((z = (X = (Q = e.value) == null ? void 0 : Q.platform) == null ? void 0 : X.mappings) == null ? void 0 : z.items, (n, _) => (u(), T(S, {
933
+ key: `item-${_}`,
934
+ modelValue: e.value.platform.mappings.items[_],
935
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.items[_] = U,
936
+ options: {
937
+ key: { placeholder: "Key", editable: !0 },
938
+ account: { placeholder: "Account code", editable: !0 }
939
+ },
940
+ removable: !0,
941
+ onRemove: () => v("items", _)
942
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
943
+ ]),
944
+ l("div", Ht, [
945
+ t[23] || (t[23] = l("div", { class: "fm-typo-en-title-sm-800" }, "Taxes", -1)),
946
+ o(p, {
947
+ variant: "primary",
948
+ icon: "add",
949
+ onClick: t[13] || (t[13] = () => r("taxes"))
950
+ })
951
+ ]),
952
+ l("div", Yt, [
953
+ (u(!0), k(K, null, j((Z = (W = (J = e.value) == null ? void 0 : J.platform) == null ? void 0 : W.mappings) == null ? void 0 : Z.taxes, (n, _) => (u(), T(S, {
954
+ key: `tax-${_}`,
955
+ modelValue: e.value.platform.mappings.taxes[_],
956
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.taxes[_] = U,
957
+ options: {
958
+ key: { placeholder: "Key", editable: !0 },
959
+ account: { placeholder: "Account code", editable: !0 }
960
+ },
961
+ removable: !0,
962
+ onRemove: () => v("taxes", _)
963
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
964
+ ]),
965
+ l("div", qt, [
966
+ t[24] || (t[24] = l("div", { class: "fm-typo-en-title-sm-800" }, "Payments", -1)),
967
+ o(p, {
968
+ variant: "primary",
969
+ icon: "add",
970
+ onClick: t[14] || (t[14] = () => r("payments"))
971
+ })
972
+ ]),
973
+ (u(!0), k(K, null, j((g = (te = (ee = e.value) == null ? void 0 : ee.platform) == null ? void 0 : te.mappings) == null ? void 0 : g.payments, (n, _) => (u(), k("div", {
974
+ key: `payment-${_}`,
975
+ class: "grid-cols-1 grid gap-x-16"
976
+ }, [
977
+ l("div", Gt, [
978
+ o(O, {
979
+ "model-value": !e.value.platform.mappings.payments[_].skip,
980
+ value: "",
981
+ "onUpdate:modelValue": (U) => {
982
+ var ie, he;
983
+ (he = (ie = e.value.platform) == null ? void 0 : ie.mappings) != null && he.payments[_] && (e.value.platform.mappings.payments[_].skip = !U);
984
+ }
985
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
986
+ o(S, {
987
+ modelValue: e.value.platform.mappings.payments[_],
988
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.payments[_] = U,
989
+ options: {
990
+ key: { placeholder: "Key", editable: !0 },
991
+ method: { placeholder: "Method", editable: !0 },
992
+ account: { placeholder: "Account code", editable: !0 }
993
+ },
994
+ removable: !0,
995
+ onRemove: () => v("payments", _)
996
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"])
997
+ ])
998
+ ]))), 128))
999
+ ])
1000
+ ])) : Y("", !0);
1001
+ };
1002
+ }
1003
+ }), Xt = { class: "h-full flex flex-col gap-16" }, zt = { class: "flex flex-row gap-2 justify-between items-center" }, Jt = {
1004
+ key: 0,
1005
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
1006
+ }, Wt = /* @__PURE__ */ M({
1007
+ __name: "Preview",
1008
+ props: {
1009
+ modelValue: { required: !0 },
1010
+ modelModifiers: {}
1011
+ },
1012
+ emits: ["update:modelValue"],
1013
+ setup(C) {
1014
+ const e = P([]), x = R(
1015
+ () => e.value.reduce((s, c) => {
1016
+ const v = s.length, { invoice: r, payments: w } = c;
1017
+ s[v] = {
1018
+ no: r.number,
1019
+ date: r.date,
1020
+ contact: r._contact_name,
1021
+ status: r.status,
1022
+ title: r.title
1023
+ };
1024
+ for (let a = 0; a < Math.max(r.form_items.length, w.length); a++) {
1025
+ const b = v + a;
1026
+ s[b] || (s[b] = {});
1027
+ const m = r.form_items[a];
1028
+ m && (s[b] = {
1029
+ ...s[b],
1030
+ itemDescription: m.description,
1031
+ itemQuantity: m.quantity,
1032
+ itemUnitPrice: m.unit_price,
1033
+ itemAccount: m._account_name,
1034
+ itemTaxCode: m._tax_code_name,
1035
+ itemDiscount: m.discount
1036
+ });
1037
+ const t = w[a];
1038
+ t && (s[b] = {
1039
+ ...s[b],
1040
+ paymentNo: t.number,
1041
+ paymentMethod: t.deposit_items[0]._payment_method_name,
1042
+ paymentAccount: t.deposit_items[0]._account_name,
1043
+ paymentDescription: t.description,
1044
+ paymentAmount: t.amount,
1045
+ paymentSkip: t.skip
1046
+ });
1047
+ }
1048
+ return s;
1049
+ }, [])
1050
+ ), h = [
1051
+ {
1052
+ accessorKey: "date",
1053
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
1054
+ enableSorting: !1
1055
+ },
1056
+ {
1057
+ accessorKey: "no",
1058
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "No"),
1059
+ enableSorting: !1
1060
+ },
1061
+ {
1062
+ accessorKey: "contact",
1063
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Contact"),
1064
+ enableSorting: !1
1065
+ },
1066
+ {
1067
+ accessorKey: "status",
1068
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Status"),
1069
+ enableSorting: !1
1070
+ },
1071
+ {
1072
+ accessorKey: "title",
1073
+ header: "Title",
1074
+ enableSorting: !1
1075
+ },
1076
+ {
1077
+ accessorKey: "itemDescription",
1078
+ header: () => F("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
1079
+ enableSorting: !1
1080
+ },
1081
+ {
1082
+ accessorKey: "itemQuantity",
1083
+ header: "Item Quantity",
1084
+ enableSorting: !1
1085
+ },
1086
+ {
1087
+ accessorKey: "itemUnitPrice",
1088
+ header: "Item Unit Price",
1089
+ enableSorting: !1
1090
+ },
1091
+ {
1092
+ accessorKey: "itemAccount",
1093
+ header: () => F("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
1094
+ enableSorting: !1
1095
+ },
1096
+ {
1097
+ accessorKey: "itemTaxCode",
1098
+ header: "Item Tax Code",
1099
+ enableSorting: !1
1100
+ },
1101
+ {
1102
+ accessorKey: "itemDiscount",
1103
+ header: "Item Discount",
1104
+ enableSorting: !1
1105
+ },
1106
+ {
1107
+ accessorKey: "paymentNo",
1108
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment No"),
1109
+ enableSorting: !1
1110
+ },
1111
+ {
1112
+ accessorKey: "paymentMethod",
1113
+ header: "Payment Method",
1114
+ enableSorting: !1
1115
+ },
1116
+ {
1117
+ accessorKey: "paymentAccount",
1118
+ header: "Payment Account",
1119
+ enableSorting: !1
1120
+ },
1121
+ {
1122
+ accessorKey: "paymentDescription",
1123
+ header: "Payment Description",
1124
+ enableSorting: !1
1125
+ },
1126
+ {
1127
+ accessorKey: "paymentAmount",
1128
+ header: "Payment Amount",
1129
+ enableSorting: !1
1130
+ },
1131
+ {
1132
+ accessorKey: "paymentSkip",
1133
+ header: "Skip",
1134
+ enableSorting: !1
1135
+ }
1136
+ ], f = L(C, "modelValue"), y = P(!1), $ = se(), { dateRange: i } = be(ne());
1137
+ re(
1138
+ () => i.value,
1139
+ async () => {
1140
+ if (f.value._id)
1141
+ try {
1142
+ y.value = !0, e.value = await xe(f.value._id);
1143
+ } catch (s) {
1144
+ $.open({ message: s.message, type: "error" });
1145
+ } finally {
1146
+ y.value = !1;
1147
+ }
1148
+ },
1149
+ {
1150
+ immediate: !0
1151
+ }
1152
+ );
1153
+ async function D() {
1154
+ try {
1155
+ f.value._id ? (y.value = !0, await $e(f.value._id), $.open({ message: "Upload successful", type: "success" })) : $.open({ message: "Invalid accounting setting", type: "error" });
1156
+ } catch (s) {
1157
+ $.open({ message: s.message, type: "error" });
1158
+ } finally {
1159
+ y.value = !1;
1160
+ }
1161
+ }
1162
+ return (s, c) => {
1163
+ const v = V("FmButton"), r = V("FmCircularProgress"), w = V("FmTable");
1164
+ return u(), k("div", Xt, [
1165
+ l("div", zt, [
1166
+ o(we, {
1167
+ "date-range": H(i),
1168
+ "onUpdate:dateRange": c[0] || (c[0] = (a) => pe(i) ? i.value = a : null),
1169
+ compare: !1
1170
+ }, null, 8, ["date-range"]),
1171
+ o(v, {
1172
+ loading: y.value,
1173
+ variant: "primary",
1174
+ label: "Upload",
1175
+ onClick: D
1176
+ }, null, 8, ["loading"])
1177
+ ]),
1178
+ y.value ? (u(), k("div", Jt, [
1179
+ o(r, { size: "xl" }),
1180
+ c[1] || (c[1] = l("span", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Loading data... ", -1))
1181
+ ])) : x.value.length > 0 ? (u(), T(w, {
1182
+ key: 1,
1183
+ class: "flex overflow-scroll",
1184
+ "row-data": x.value,
1185
+ "column-defs": h
1186
+ }, null, 8, ["row-data"])) : Y("", !0)
1187
+ ]);
1188
+ };
1189
+ }
1190
+ }), Zt = { class: "h-full relative flex flex-col" }, el = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, tl = /* @__PURE__ */ M({
1191
+ __name: "Bukku",
1192
+ props: {
1193
+ modelValue: {},
1194
+ modelModifiers: {}
1195
+ },
1196
+ emits: ["update:modelValue"],
1197
+ setup(C) {
1198
+ const e = L(C, "modelValue"), x = P("setting"), h = [
1199
+ {
1200
+ label: "Setting",
1201
+ value: "setting",
1202
+ icon: "settings"
1203
+ },
1204
+ {
1205
+ label: "Preview",
1206
+ value: "preview",
1207
+ icon: "table"
1208
+ }
1209
+ ], f = oe(), y = R(() => {
1210
+ switch (x.value) {
1211
+ case "preview":
1212
+ return Wt;
1213
+ case "setting":
1214
+ return Qt;
1215
+ default:
1216
+ return null;
1217
+ }
1218
+ });
1219
+ return ($, i) => {
1220
+ var c;
1221
+ const D = V("FmPageHead"), s = V("FmTabs");
1222
+ return u(), k("div", Zt, [
1223
+ o(D, {
1224
+ title: ((c = e.value) == null ? void 0 : c.name) || "Bukku",
1225
+ "back-button": !0,
1226
+ style: { paddingLeft: "0px", paddingRight: "0px" },
1227
+ "onClick:back": H(f).back
1228
+ }, {
1229
+ description: ue(() => i[2] || (i[2] = [
1230
+ l("div", null, null, -1)
1231
+ ])),
1232
+ _: 1
1233
+ }, 8, ["title", "onClick:back"]),
1234
+ o(s, {
1235
+ "model-value": x.value,
1236
+ "onUpdate:modelValue": i[0] || (i[0] = (v) => x.value = v),
1237
+ items: h
1238
+ }, null, 8, ["model-value"]),
1239
+ l("div", el, [
1240
+ (u(), T(de(y.value), {
1241
+ modelValue: e.value,
1242
+ "onUpdate:modelValue": i[1] || (i[1] = (v) => e.value = v)
1243
+ }, null, 8, ["modelValue"]))
1244
+ ])
1245
+ ]);
1246
+ };
1247
+ }
1248
+ }), ll = {
1249
+ key: 0,
1250
+ class: "flex flex-col h-full"
1251
+ }, al = { class: "flex flex-col gap-16 pb-[24px]" }, ol = { class: "flex flex-row justify-between items-center gap-2" }, nl = { class: "flex flex-row gap-2" }, sl = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, il = { class: "flex flex-col gap-16" }, rl = { class: "flex flex-row items-center max-w-[100%]" }, ml = { class: "flex-grow" }, ul = { class: "flex flex-row items-center max-w-[100%]" }, dl = { class: "flex flex-row items-center max-w-[100%]" }, cl = { class: "flex flex-col gap-16" }, pl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, fl = { class: "flex flex-row items-center gap-x-16" }, vl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, gl = { class: "flex flex-row items-center gap-x-16" }, yl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, xl = { class: "flex flex-row items-center gap-x-16" }, bl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, wl = /* @__PURE__ */ M({
1252
+ __name: "Setting",
1253
+ props: {
1254
+ modelValue: { required: !0 },
1255
+ modelModifiers: {}
1256
+ },
1257
+ emits: ["update:modelValue"],
1258
+ setup(C) {
1259
+ const e = L(C, "modelValue"), x = se(), h = ce(), f = oe(), { promptLoader: y } = fe(), { promptMessage: $ } = ve(), { restaurants: i } = ne(), D = R(
1260
+ () => i.map((m) => ({ label: m.name, value: m.id }))
1261
+ );
1262
+ async function s() {
1263
+ await $({
1264
+ message: `Confirm delete ${e.value.name}?`,
1265
+ title: "Delete"
1266
+ }) && await y(async () => {
1267
+ try {
1268
+ await ge(e.value._id), await h.getSettings(), f.back();
1269
+ } catch (t) {
1270
+ x.open({ type: "error", message: t.message });
1271
+ }
1272
+ });
1273
+ }
1274
+ async function c() {
1275
+ await y(async () => {
1276
+ try {
1277
+ await ye(e.value._id, e.value), await h.getSettings();
1278
+ } catch (m) {
1279
+ x.open({ type: "error", message: m.message });
1280
+ }
1281
+ });
1282
+ }
1283
+ function v(m, t) {
1284
+ var p, d;
1285
+ (d = (p = e.value.platform) == null ? void 0 : p.mappings) != null && d[m] && (e.value.platform.mappings[m] = e.value.platform.mappings[m].filter(
1286
+ (N, I) => I !== t
1287
+ ));
1288
+ }
1289
+ function r(m) {
1290
+ var t, p;
1291
+ (p = (t = e.value.platform) == null ? void 0 : t.mappings) != null && p[m] && (e.value.platform.mappings[m] = [
1292
+ ...e.value.platform.mappings[m],
1293
+ m === "items" ? {
1294
+ key: "",
1295
+ account: "",
1296
+ description: ""
1297
+ } : {
1298
+ key: "",
1299
+ account: ""
1300
+ }
1301
+ ]);
1302
+ }
1303
+ const w = [
1304
+ {
1305
+ label: "By day",
1306
+ value: ae.BY_DAY
1307
+ },
1308
+ {
1309
+ label: "By invoice",
1310
+ value: ae.BY_INVOICE
1311
+ },
1312
+ {
1313
+ label: "By day and category",
1314
+ value: ae.BY_DAY_CATEGORY
1315
+ }
1316
+ ];
1317
+ function a({
1318
+ key: m,
1319
+ value: t
1320
+ }) {
1321
+ var p, d;
1322
+ (d = (p = e.value) == null ? void 0 : p.platform) != null && d.mappings && (e.value.platform.mappings[m] = t);
1323
+ }
1324
+ function b(m) {
1325
+ return {
1326
+ key: { placeholder: m, editable: !1 },
1327
+ account: { placeholder: m, editable: !0 }
1328
+ };
1329
+ }
1330
+ return (m, t) => {
1331
+ var O, A, B, E, q, G, Q, X, z, J, W, Z, ee, te;
1332
+ const p = V("FmButton"), d = V("FmMenuDivider"), N = V("FmTextField"), I = V("FmSelect");
1333
+ return (A = (O = e.value) == null ? void 0 : O.platform) != null && A.mappings ? (u(), k("div", ll, [
1334
+ l("div", al, [
1335
+ l("div", ol, [
1336
+ t[14] || (t[14] = l("div", { class: "fm-typo-en-title-sm-800" }, null, -1)),
1337
+ l("div", nl, [
1338
+ o(p, {
1339
+ variant: "tertiary",
1340
+ label: "Delete",
1341
+ onClick: s
1342
+ }),
1343
+ o(p, {
1344
+ variant: "primary",
1345
+ label: "Update",
1346
+ onClick: c
1347
+ })
1348
+ ])
1349
+ ])
1350
+ ]),
1351
+ o(d, { style: { margin: 0 } }),
1352
+ l("div", sl, [
1353
+ l("div", il, [
1354
+ t[18] || (t[18] = l("div", { class: "fm-typo-en-title-sm-800" }, "General", -1)),
1355
+ l("div", rl, [
1356
+ t[15] || (t[15] = l("div", { class: "w-[25%]" }, "Name", -1)),
1357
+ l("div", ml, [
1358
+ o(N, {
1359
+ modelValue: e.value.name,
1360
+ "onUpdate:modelValue": t[0] || (t[0] = (g) => e.value.name = g)
1361
+ }, null, 8, ["modelValue"])
1362
+ ])
1363
+ ]),
1364
+ l("div", ul, [
1365
+ t[16] || (t[16] = l("div", { class: "w-[25%]" }, "Location", -1)),
1366
+ o(I, {
1367
+ modelValue: e.value.platform.locationIds,
1368
+ "onUpdate:modelValue": t[1] || (t[1] = (g) => e.value.platform.locationIds = g),
1369
+ multiselect: !0,
1370
+ items: D.value,
1371
+ placeholder: "Select location",
1372
+ class: "flex-grow",
1373
+ rules: [(g) => g.length !== 0 || "Please select at least 1 location"]
1374
+ }, null, 8, ["modelValue", "items", "rules"])
1375
+ ]),
1376
+ l("div", dl, [
1377
+ t[17] || (t[17] = l("div", { class: "w-[25%]" }, "Grouping", -1)),
1378
+ o(I, {
1379
+ modelValue: e.value.platform.grouping,
1380
+ "onUpdate:modelValue": t[2] || (t[2] = (g) => e.value.platform.grouping = g),
1381
+ multiselect: !1,
1382
+ items: w,
1383
+ placeholder: "Select grouping",
1384
+ class: "flex-grow"
1385
+ }, null, 8, ["modelValue"])
1386
+ ])
1387
+ ]),
1388
+ l("div", cl, [
1389
+ l("div", pl, [
1390
+ o(S, {
1391
+ "model-value": { key: "Project", account: e.value.platform.mappings.project },
1392
+ options: b("Project"),
1393
+ "onUpdate:modelValue": t[3] || (t[3] = (g) => a({ key: "project", value: g.account }))
1394
+ }, null, 8, ["model-value", "options"]),
1395
+ o(S, {
1396
+ "model-value": { key: "Debtor", account: e.value.platform.mappings.debtor },
1397
+ options: b("Debtor"),
1398
+ "onUpdate:modelValue": t[4] || (t[4] = (g) => a({ key: "debtor", value: g.account }))
1399
+ }, null, 8, ["model-value", "options"]),
1400
+ o(S, {
1401
+ "model-value": {
1402
+ key: "Invoice no",
1403
+ account: e.value.platform.mappings.invoiceDocNo
1404
+ },
1405
+ options: b("Invoice no"),
1406
+ "onUpdate:modelValue": t[5] || (t[5] = (g) => a({ key: "invoiceDocNo", value: g.account }))
1407
+ }, null, 8, ["model-value", "options"]),
1408
+ o(S, {
1409
+ "model-value": {
1410
+ key: "Credit note no",
1411
+ account: e.value.platform.mappings.creditNoteDocNo
1412
+ },
1413
+ options: b("Credit note no"),
1414
+ "onUpdate:modelValue": t[6] || (t[6] = (g) => a({ key: "creditNoteDocNo", value: g.account }))
1415
+ }, null, 8, ["model-value", "options"]),
1416
+ o(S, {
1417
+ "model-value": {
1418
+ key: "Payment no",
1419
+ account: e.value.platform.mappings.paymentDocNo
1420
+ },
1421
+ options: b("Payment no"),
1422
+ "onUpdate:modelValue": t[7] || (t[7] = (g) => a({ key: "paymentDocNo", value: g.account }))
1423
+ }, null, 8, ["model-value", "options"]),
1424
+ o(S, {
1425
+ "model-value": {
1426
+ key: "Refund no",
1427
+ account: e.value.platform.mappings.refundDocNo
1428
+ },
1429
+ options: b("Refund no"),
1430
+ "onUpdate:modelValue": t[8] || (t[8] = (g) => a({ key: "refundDocNo", value: g.account }))
1431
+ }, null, 8, ["model-value", "options"]),
1432
+ o(S, {
1433
+ "model-value": {
1434
+ key: "Rounding",
1435
+ account: e.value.platform.mappings.rounding.account
1436
+ },
1437
+ options: b("Rounding"),
1438
+ "onUpdate:modelValue": t[9] || (t[9] = (g) => {
1439
+ var n, _, U;
1440
+ (U = (_ = (n = e.value) == null ? void 0 : n.platform) == null ? void 0 : _.mappings) != null && U.rounding && (e.value.platform.mappings.rounding.account = g.account);
1441
+ })
1442
+ }, null, 8, ["model-value", "options"]),
1443
+ (u(!0), k(K, null, j((q = (E = (B = e.value) == null ? void 0 : B.platform) == null ? void 0 : E.mappings) == null ? void 0 : q.charges, (g, n) => (u(), T(S, {
1444
+ key: `charge-${n}`,
1445
+ modelValue: e.value.platform.mappings.charges[n],
1446
+ "onUpdate:modelValue": (_) => e.value.platform.mappings.charges[n] = _,
1447
+ options: {
1448
+ key: { placeholder: "Key", editable: !1 },
1449
+ account: { placeholder: "Account code", editable: !0 }
1450
+ }
1451
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]))), 128))
1452
+ ])
1453
+ ]),
1454
+ o(_e, {
1455
+ modelValue: e.value.platform,
1456
+ "onUpdate:modelValue": t[10] || (t[10] = (g) => e.value.platform = g),
1457
+ label: "email"
1458
+ }, null, 8, ["modelValue"]),
1459
+ l("div", fl, [
1460
+ t[19] || (t[19] = l("div", { class: "fm-typo-en-title-sm-800" }, "Items", -1)),
1461
+ o(p, {
1462
+ variant: "primary",
1463
+ icon: "add",
1464
+ onClick: t[11] || (t[11] = () => r("items"))
1465
+ })
1466
+ ]),
1467
+ l("div", vl, [
1468
+ (u(!0), k(K, null, j((X = (Q = (G = e.value) == null ? void 0 : G.platform) == null ? void 0 : Q.mappings) == null ? void 0 : X.items, (g, n) => (u(), T(S, {
1469
+ key: `item-${n}`,
1470
+ modelValue: e.value.platform.mappings.items[n],
1471
+ "onUpdate:modelValue": (_) => e.value.platform.mappings.items[n] = _,
1472
+ options: {
1473
+ key: { placeholder: "Key", editable: !0 },
1474
+ account: { placeholder: "Account code", editable: !0 }
1475
+ },
1476
+ removable: !0,
1477
+ onRemove: () => v("items", n)
1478
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1479
+ ]),
1480
+ l("div", gl, [
1481
+ t[20] || (t[20] = l("div", { class: "fm-typo-en-title-sm-800" }, "Taxes", -1)),
1482
+ o(p, {
1483
+ variant: "primary",
1484
+ icon: "add",
1485
+ onClick: t[12] || (t[12] = () => r("taxes"))
1486
+ })
1487
+ ]),
1488
+ l("div", yl, [
1489
+ (u(!0), k(K, null, j((W = (J = (z = e.value) == null ? void 0 : z.platform) == null ? void 0 : J.mappings) == null ? void 0 : W.taxes, (g, n) => (u(), T(S, {
1490
+ key: `tax-${n}`,
1491
+ modelValue: e.value.platform.mappings.taxes[n],
1492
+ "onUpdate:modelValue": (_) => e.value.platform.mappings.taxes[n] = _,
1493
+ options: {
1494
+ key: { placeholder: "Key", editable: !0 },
1495
+ account: { placeholder: "Account code", editable: !0 }
1496
+ },
1497
+ removable: !0,
1498
+ onRemove: () => v("taxes", n)
1499
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1500
+ ]),
1501
+ l("div", xl, [
1502
+ t[21] || (t[21] = l("div", { class: "fm-typo-en-title-sm-800" }, "Payments", -1)),
1503
+ o(p, {
1504
+ variant: "primary",
1505
+ icon: "add",
1506
+ onClick: t[13] || (t[13] = () => r("payments"))
1507
+ })
1508
+ ]),
1509
+ l("div", bl, [
1510
+ (u(!0), k(K, null, j((te = (ee = (Z = e.value) == null ? void 0 : Z.platform) == null ? void 0 : ee.mappings) == null ? void 0 : te.payments, (g, n) => (u(), T(S, {
1511
+ key: `payment-${n}`,
1512
+ modelValue: e.value.platform.mappings.payments[n],
1513
+ "onUpdate:modelValue": (_) => e.value.platform.mappings.payments[n] = _,
1514
+ options: {
1515
+ key: { placeholder: "Key", editable: !0 },
1516
+ account: { placeholder: "Payment name", editable: !0 }
1517
+ },
1518
+ removable: !0,
1519
+ onRemove: () => v("payments", n)
1520
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1521
+ ])
1522
+ ])
1523
+ ])) : Y("", !0);
1524
+ };
1525
+ }
1526
+ }), _l = { class: "h-full flex flex-col gap-16" }, Vl = { class: "flex flex-row gap-2 justify-between items-center" }, kl = {
1527
+ key: 0,
1528
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
1529
+ }, hl = /* @__PURE__ */ M({
1530
+ __name: "Preview",
1531
+ props: {
1532
+ modelValue: { required: !0 },
1533
+ modelModifiers: {}
1534
+ },
1535
+ emits: ["update:modelValue"],
1536
+ setup(C) {
1537
+ const e = P([]), x = R(
1538
+ () => e.value.reduce((s, c) => {
1539
+ const v = s.length, { invoice: r, payments: w } = c;
1540
+ s[v] = {
1541
+ date: r.DocDate,
1542
+ docNo: r.DocNo,
1543
+ projNo: r.ProjNo,
1544
+ debtor: r.DebtorCode,
1545
+ description: r.Description
1546
+ };
1547
+ for (let a = 0; a < Math.max(r._items.length, w.length); a++) {
1548
+ const b = v + a;
1549
+ s[b] || (s[b] = {}), r._items[a] && (s[b] = {
1550
+ ...s[b],
1551
+ itemDescription: r._items[a].DetailDescription,
1552
+ itemUnitPrice: r._items[a].Amount,
1553
+ itemAccount: r._items[a].AccNo,
1554
+ itemTaxCode: r._items[a].TaxType,
1555
+ itemTax: r._items[a].Tax
1556
+ }), w[a] && (s[b] = {
1557
+ ...s[b],
1558
+ paymentDocNo: w[a].DocNo,
1559
+ paymentMethod: w[a].paymentMethod,
1560
+ paymentDescription: w[a].Description,
1561
+ paymentAmount: w[a].PaymentAmt
1562
+ });
1563
+ }
1564
+ return s;
1565
+ }, [])
1566
+ ), h = [
1567
+ {
1568
+ accessorKey: "date",
1569
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
1570
+ enableSorting: !1
1571
+ },
1572
+ {
1573
+ accessorKey: "docNo",
1574
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Doc No"),
1575
+ enableSorting: !1
1576
+ },
1577
+ {
1578
+ accessorKey: "projNo",
1579
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Project"),
1580
+ enableSorting: !1
1581
+ },
1582
+ {
1583
+ accessorKey: "debtor",
1584
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Debtor"),
1585
+ enableSorting: !1
1586
+ },
1587
+ {
1588
+ accessorKey: "description",
1589
+ header: "Description",
1590
+ enableSorting: !1
1591
+ },
1592
+ {
1593
+ accessorKey: "itemAccount",
1594
+ header: () => F("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
1595
+ enableSorting: !1
1596
+ },
1597
+ {
1598
+ accessorKey: "itemTaxCode",
1599
+ header: "Item Tax Code",
1600
+ enableSorting: !1
1601
+ },
1602
+ {
1603
+ accessorKey: "itemDescription",
1604
+ header: () => F("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
1605
+ enableSorting: !1
1606
+ },
1607
+ {
1608
+ accessorKey: "itemUnitPrice",
1609
+ header: "Item Unit Price",
1610
+ enableSorting: !1
1611
+ },
1612
+ {
1613
+ accessorKey: "itemTax",
1614
+ header: "Item Tax",
1615
+ enableSorting: !1
1616
+ },
1617
+ {
1618
+ accessorKey: "paymentDocNo",
1619
+ header: "Payment Doc No",
1620
+ enableSorting: !1
1621
+ },
1622
+ {
1623
+ accessorKey: "paymentMethod",
1624
+ header: "Payment Method",
1625
+ enableSorting: !1
1626
+ },
1627
+ {
1628
+ accessorKey: "paymentDescription",
1629
+ header: "Payment Description",
1630
+ enableSorting: !1
1631
+ },
1632
+ {
1633
+ accessorKey: "paymentAmount",
1634
+ header: "Payment Amount",
1635
+ enableSorting: !1
1636
+ }
1637
+ ], f = L(C, "modelValue"), y = P(!1), $ = se(), { dateRange: i } = be(ne());
1638
+ re(
1639
+ () => i.value,
1640
+ async () => {
1641
+ if (f.value._id)
1642
+ try {
1643
+ y.value = !0, e.value = await xe(f.value._id);
1644
+ } catch (s) {
1645
+ $.open({ message: s.message, type: "error" });
1646
+ } finally {
1647
+ y.value = !1;
1648
+ }
1649
+ },
1650
+ {
1651
+ immediate: !0
1652
+ }
1653
+ );
1654
+ async function D() {
1655
+ try {
1656
+ f.value._id ? (y.value = !0, await ke(f.value._id)) : $.open({ message: "Invalid accounting setting", type: "error" });
1657
+ } catch (s) {
1658
+ $.open({ message: s.message, type: "error" });
1659
+ } finally {
1660
+ y.value = !1;
1661
+ }
1662
+ }
1663
+ return (s, c) => {
1664
+ const v = V("FmButton"), r = V("FmCircularProgress"), w = V("FmTable");
1665
+ return u(), k("div", _l, [
1666
+ l("div", Vl, [
1667
+ o(we, {
1668
+ "date-range": H(i),
1669
+ "onUpdate:dateRange": c[0] || (c[0] = (a) => pe(i) ? i.value = a : null),
1670
+ compare: !1
1671
+ }, null, 8, ["date-range"]),
1672
+ o(v, {
1673
+ loading: y.value,
1674
+ variant: "primary",
1675
+ label: "Download",
1676
+ onClick: D
1677
+ }, null, 8, ["loading"])
1678
+ ]),
1679
+ y.value ? (u(), k("div", kl, [
1680
+ o(r, { size: "xl" }),
1681
+ c[1] || (c[1] = l("span", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Loading data... ", -1))
1682
+ ])) : x.value.length > 0 ? (u(), T(w, {
1683
+ key: 1,
1684
+ class: "flex overflow-scroll",
1685
+ "row-data": x.value,
1686
+ "column-defs": h
1687
+ }, null, 8, ["row-data"])) : Y("", !0)
1688
+ ]);
1689
+ };
1690
+ }
1691
+ }), $l = { class: "h-full relative flex flex-col" }, Dl = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, Cl = /* @__PURE__ */ M({
1692
+ __name: "AutoCount",
1693
+ props: {
1694
+ modelValue: {},
1695
+ modelModifiers: {}
1696
+ },
1697
+ emits: ["update:modelValue"],
1698
+ setup(C) {
1699
+ const e = L(C, "modelValue"), x = P("setting"), h = [
1700
+ {
1701
+ label: "Setting",
1702
+ value: "setting",
1703
+ icon: "settings"
1704
+ },
1705
+ {
1706
+ label: "Preview",
1707
+ value: "preview",
1708
+ icon: "table"
1709
+ }
1710
+ ], f = oe(), y = R(() => {
1711
+ switch (x.value) {
1712
+ case "preview":
1713
+ return hl;
1714
+ case "setting":
1715
+ return wl;
1716
+ default:
1717
+ return null;
1718
+ }
1719
+ });
1720
+ return ($, i) => {
1721
+ var c;
1722
+ const D = V("FmPageHead"), s = V("FmTabs");
1723
+ return u(), k("div", $l, [
1724
+ o(D, {
1725
+ title: ((c = e.value) == null ? void 0 : c.name) || "AutoCount",
1726
+ "back-button": !0,
1727
+ style: { paddingLeft: "0px", paddingRight: "0px" },
1728
+ "onClick:back": H(f).back
1729
+ }, {
1730
+ description: ue(() => i[2] || (i[2] = [
1731
+ l("div", null, null, -1)
1732
+ ])),
1733
+ _: 1
1734
+ }, 8, ["title", "onClick:back"]),
1735
+ o(s, {
1736
+ "model-value": x.value,
1737
+ "onUpdate:modelValue": i[0] || (i[0] = (v) => x.value = v),
1738
+ items: h
1739
+ }, null, 8, ["model-value"]),
1740
+ l("div", Dl, [
1741
+ (u(), T(de(y.value), {
1742
+ modelValue: e.value,
1743
+ "onUpdate:modelValue": i[1] || (i[1] = (v) => e.value = v)
1744
+ }, null, 8, ["modelValue"]))
1745
+ ])
1746
+ ]);
1747
+ };
1748
+ }
1749
+ }), Sl = {
1750
+ key: 0,
1751
+ class: "flex flex-col h-full"
1752
+ }, Ul = { class: "flex flex-col gap-16 pb-[24px]" }, Fl = { class: "flex flex-row justify-between items-center gap-2" }, Tl = { class: "flex flex-row gap-2" }, Il = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, Nl = { class: "flex flex-col gap-16" }, Al = { class: "flex flex-row items-center max-w-[100%]" }, Pl = { class: "flex-grow" }, Kl = { class: "flex flex-row items-center max-w-[100%]" }, Rl = { class: "flex flex-row items-center max-w-[100%]" }, Ml = { class: "flex flex-col gap-16" }, Bl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, jl = { class: "grid-cols-1 grid gap-16" }, Ll = { class: "flex flex-row items-center gap-x-16" }, Ol = { class: "grid-cols-1 grid gap-16" }, El = { class: "flex flex-row items-center gap-x-16" }, Hl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Yl = { class: "flex flex-row items-center gap-x-16" }, ql = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Gl = /* @__PURE__ */ M({
1753
+ __name: "Setting",
1754
+ props: {
1755
+ modelValue: { required: !0 },
1756
+ modelModifiers: {}
1757
+ },
1758
+ emits: ["update:modelValue"],
1759
+ setup(C) {
1760
+ const e = L(C, "modelValue"), x = se(), h = ce(), f = oe(), { promptLoader: y } = fe(), { promptMessage: $ } = ve(), { restaurants: i } = ne(), D = R(
1761
+ () => i.map((m) => ({ label: m.name, value: m.id }))
1762
+ );
1763
+ async function s() {
1764
+ await $({
1765
+ message: `Confirm delete ${e.value.name}?`,
1766
+ title: "Delete"
1767
+ }) && await y(async () => {
1768
+ try {
1769
+ await ge(e.value._id), await h.getSettings(), f.back();
1770
+ } catch (t) {
1771
+ x.open({ type: "error", message: t.message });
1772
+ }
1773
+ });
1774
+ }
1775
+ async function c() {
1776
+ await y(async () => {
1777
+ try {
1778
+ await ye(e.value._id, e.value), await h.getSettings();
1779
+ } catch (m) {
1780
+ x.open({ type: "error", message: m.message });
1781
+ }
1782
+ });
1783
+ }
1784
+ function v(m, t) {
1785
+ var p, d;
1786
+ (d = (p = e.value.platform) == null ? void 0 : p.mappings) != null && d[m] && (e.value.platform.mappings[m] = e.value.platform.mappings[m].filter(
1787
+ (N, I) => I !== t
1788
+ ));
1789
+ }
1790
+ function r(m) {
1791
+ var t, p;
1792
+ (p = (t = e.value.platform) == null ? void 0 : t.mappings) != null && p[m] && (e.value.platform.mappings[m] = [
1793
+ ...e.value.platform.mappings[m],
1794
+ m === "items" ? {
1795
+ key: "",
1796
+ account: "",
1797
+ description: ""
1798
+ } : {
1799
+ key: "",
1800
+ account: ""
1801
+ }
1802
+ ]);
1803
+ }
1804
+ const w = [
1805
+ {
1806
+ label: "By day",
1807
+ value: ae.BY_DAY
1808
+ },
1809
+ {
1810
+ label: "By invoice",
1811
+ value: ae.BY_INVOICE
1812
+ },
1813
+ {
1814
+ label: "By day and category",
1815
+ value: ae.BY_DAY_CATEGORY
1816
+ }
1817
+ ];
1818
+ function a({
1819
+ key: m,
1820
+ value: t
1821
+ }) {
1822
+ var p, d;
1823
+ (d = (p = e.value) == null ? void 0 : p.platform) != null && d.mappings && (e.value.platform.mappings[m] = t);
1824
+ }
1825
+ function b(m) {
1826
+ return {
1827
+ key: { placeholder: m, editable: !1 },
1828
+ account: { placeholder: m, editable: !0 }
1829
+ };
1830
+ }
1831
+ return (m, t) => {
1832
+ var O, A, B, E, q, G, Q, X, z, J, W, Z, ee, te;
1833
+ const p = V("FmButton"), d = V("FmMenuDivider"), N = V("FmTextField"), I = V("FmSelect");
1834
+ return (A = (O = e.value) == null ? void 0 : O.platform) != null && A.mappings ? (u(), k("div", Sl, [
1835
+ l("div", Ul, [
1836
+ l("div", Fl, [
1837
+ t[15] || (t[15] = l("div", { class: "fm-typo-en-title-sm-800" }, null, -1)),
1838
+ l("div", Tl, [
1839
+ o(p, {
1840
+ variant: "tertiary",
1841
+ label: "Delete",
1842
+ onClick: s
1843
+ }),
1844
+ o(p, {
1845
+ variant: "primary",
1846
+ label: "Update",
1847
+ onClick: c
1848
+ })
1849
+ ])
1850
+ ])
1851
+ ]),
1852
+ o(d, { style: { margin: 0 } }),
1853
+ l("div", Il, [
1854
+ l("div", Nl, [
1855
+ t[19] || (t[19] = l("div", { class: "fm-typo-en-title-sm-800" }, "General", -1)),
1856
+ l("div", Al, [
1857
+ t[16] || (t[16] = l("div", { class: "w-[25%]" }, "Name", -1)),
1858
+ l("div", Pl, [
1859
+ o(N, {
1860
+ modelValue: e.value.name,
1861
+ "onUpdate:modelValue": t[0] || (t[0] = (g) => e.value.name = g)
1862
+ }, null, 8, ["modelValue"])
1863
+ ])
1864
+ ]),
1865
+ l("div", Kl, [
1866
+ t[17] || (t[17] = l("div", { class: "w-[25%]" }, "Location", -1)),
1867
+ o(I, {
1868
+ modelValue: e.value.platform.locationIds,
1869
+ "onUpdate:modelValue": t[1] || (t[1] = (g) => e.value.platform.locationIds = g),
1870
+ multiselect: !0,
1871
+ items: D.value,
1872
+ placeholder: "Select location",
1873
+ class: "flex-grow",
1874
+ rules: [(g) => g.length !== 0 || "Please select at least 1 location"]
1875
+ }, null, 8, ["modelValue", "items", "rules"])
1876
+ ]),
1877
+ l("div", Rl, [
1878
+ t[18] || (t[18] = l("div", { class: "w-[25%]" }, "Grouping", -1)),
1879
+ o(I, {
1880
+ modelValue: e.value.platform.grouping,
1881
+ "onUpdate:modelValue": t[2] || (t[2] = (g) => e.value.platform.grouping = g),
1882
+ multiselect: !1,
1883
+ items: w,
1884
+ placeholder: "Select grouping",
1885
+ class: "flex-grow"
1886
+ }, null, 8, ["modelValue"])
1887
+ ])
1888
+ ]),
1889
+ l("div", Ml, [
1890
+ l("div", Bl, [
1891
+ o(S, {
1892
+ "model-value": { key: "Debtor", account: e.value.platform.mappings.debtor },
1893
+ options: b("Debtor"),
1894
+ "onUpdate:modelValue": t[3] || (t[3] = (g) => a({ key: "debtor", value: g.account }))
1895
+ }, null, 8, ["model-value", "options"]),
1896
+ o(S, {
1897
+ "model-value": {
1898
+ key: "Invoice no",
1899
+ account: e.value.platform.mappings.invoiceDocNo
1900
+ },
1901
+ options: b("Invoice no"),
1902
+ "onUpdate:modelValue": t[4] || (t[4] = (g) => a({ key: "invoiceDocNo", value: g.account }))
1903
+ }, null, 8, ["model-value", "options"]),
1904
+ o(S, {
1905
+ "model-value": {
1906
+ key: "Credit note no",
1907
+ account: e.value.platform.mappings.creditNoteDocNo
1908
+ },
1909
+ options: b("Credit note no"),
1910
+ "onUpdate:modelValue": t[5] || (t[5] = (g) => a({ key: "creditNoteDocNo", value: g.account }))
1911
+ }, null, 8, ["model-value", "options"]),
1912
+ o(S, {
1913
+ "model-value": {
1914
+ key: "Payment no",
1915
+ account: e.value.platform.mappings.paymentDocNo
1916
+ },
1917
+ options: b("Payment no"),
1918
+ "onUpdate:modelValue": t[6] || (t[6] = (g) => a({ key: "paymentDocNo", value: g.account }))
1919
+ }, null, 8, ["model-value", "options"]),
1920
+ o(S, {
1921
+ "model-value": {
1922
+ key: "Refund no",
1923
+ account: e.value.platform.mappings.refundDocNo
1924
+ },
1925
+ options: b("Refund no"),
1926
+ "onUpdate:modelValue": t[7] || (t[7] = (g) => a({ key: "refundDocNo", value: g.account }))
1927
+ }, null, 8, ["model-value", "options"]),
1928
+ o(S, {
1929
+ "model-value": {
1930
+ key: "Project header",
1931
+ account: e.value.platform.mappings.projectHeader
1932
+ },
1933
+ options: b("Project header"),
1934
+ "onUpdate:modelValue": t[8] || (t[8] = (g) => a({ key: "projectHeader", value: g.account }))
1935
+ }, null, 8, ["model-value", "options"]),
1936
+ o(S, {
1937
+ "model-value": {
1938
+ key: "Project detail",
1939
+ account: e.value.platform.mappings.projectDetail
1940
+ },
1941
+ options: b("Project detail"),
1942
+ "onUpdate:modelValue": t[9] || (t[9] = (g) => a({ key: "projectDetail", value: g.account }))
1943
+ }, null, 8, ["model-value", "options"])
1944
+ ]),
1945
+ l("div", jl, [
1946
+ o(S, {
1947
+ "model-value": {
1948
+ key: "Rounding",
1949
+ account: e.value.platform.mappings.rounding.account,
1950
+ code: e.value.platform.mappings.rounding.code
1951
+ },
1952
+ options: {
1953
+ key: { placeholder: "Rounding", editable: !1 },
1954
+ account: { placeholder: "Account code", editable: !0 },
1955
+ code: { placeholder: "Item code", editable: !0 }
1956
+ },
1957
+ "onUpdate:modelValue": t[10] || (t[10] = (g) => {
1958
+ var n, _, U;
1959
+ (U = (_ = (n = e.value) == null ? void 0 : n.platform) == null ? void 0 : _.mappings) != null && U.rounding && (e.value.platform.mappings.rounding.account = g.account, e.value.platform.mappings.rounding.code = g.code);
1960
+ })
1961
+ }, null, 8, ["model-value"]),
1962
+ (u(!0), k(K, null, j((q = (E = (B = e.value) == null ? void 0 : B.platform) == null ? void 0 : E.mappings) == null ? void 0 : q.charges, (g, n) => (u(), T(S, {
1963
+ key: `charge-${n}`,
1964
+ modelValue: e.value.platform.mappings.charges[n],
1965
+ "onUpdate:modelValue": (_) => e.value.platform.mappings.charges[n] = _,
1966
+ options: {
1967
+ key: { placeholder: "Key", editable: !1 },
1968
+ account: { placeholder: "Account code", editable: !0 },
1969
+ code: { placeholder: "Item code", editable: !0 }
1970
+ }
1971
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]))), 128))
1972
+ ])
1973
+ ]),
1974
+ o(_e, {
1975
+ modelValue: e.value.platform,
1976
+ "onUpdate:modelValue": t[11] || (t[11] = (g) => e.value.platform = g),
1977
+ label: "email"
1978
+ }, null, 8, ["modelValue"]),
1979
+ l("div", Ll, [
1980
+ t[20] || (t[20] = l("div", { class: "fm-typo-en-title-sm-800" }, "Items", -1)),
1981
+ o(p, {
1982
+ variant: "primary",
1983
+ icon: "add",
1984
+ onClick: t[12] || (t[12] = () => r("items"))
1985
+ })
1986
+ ]),
1987
+ l("div", Ol, [
1988
+ (u(!0), k(K, null, j((X = (Q = (G = e.value) == null ? void 0 : G.platform) == null ? void 0 : Q.mappings) == null ? void 0 : X.items, (g, n) => (u(), T(S, {
1989
+ key: `item-${n}`,
1990
+ modelValue: e.value.platform.mappings.items[n],
1991
+ "onUpdate:modelValue": (_) => e.value.platform.mappings.items[n] = _,
1992
+ options: {
1993
+ key: { placeholder: "Key", editable: !0 },
1994
+ account: { placeholder: "Account code", editable: !0 },
1995
+ code: { placeholder: "Item code", editable: !0 }
1996
+ },
1997
+ removable: !0,
1998
+ onRemove: () => v("items", n)
1999
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2000
+ ]),
2001
+ l("div", El, [
2002
+ t[21] || (t[21] = l("div", { class: "fm-typo-en-title-sm-800" }, "Taxes", -1)),
2003
+ o(p, {
2004
+ variant: "primary",
2005
+ icon: "add",
2006
+ onClick: t[13] || (t[13] = () => r("taxes"))
2007
+ })
2008
+ ]),
2009
+ l("div", Hl, [
2010
+ (u(!0), k(K, null, j((W = (J = (z = e.value) == null ? void 0 : z.platform) == null ? void 0 : J.mappings) == null ? void 0 : W.taxes, (g, n) => (u(), T(S, {
2011
+ key: `tax-${n}`,
2012
+ modelValue: e.value.platform.mappings.taxes[n],
2013
+ "onUpdate:modelValue": (_) => e.value.platform.mappings.taxes[n] = _,
2014
+ options: {
2015
+ key: { placeholder: "Key", editable: !0 },
2016
+ account: { placeholder: "Account code", editable: !0 }
2017
+ },
2018
+ removable: !0,
2019
+ onRemove: () => v("taxes", n)
2020
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2021
+ ]),
2022
+ l("div", Yl, [
2023
+ t[22] || (t[22] = l("div", { class: "fm-typo-en-title-sm-800" }, "Payments", -1)),
2024
+ o(p, {
2025
+ variant: "primary",
2026
+ icon: "add",
2027
+ onClick: t[14] || (t[14] = () => r("payments"))
2028
+ })
2029
+ ]),
2030
+ l("div", ql, [
2031
+ (u(!0), k(K, null, j((te = (ee = (Z = e.value) == null ? void 0 : Z.platform) == null ? void 0 : ee.mappings) == null ? void 0 : te.payments, (g, n) => (u(), T(S, {
2032
+ key: `payment-${n}`,
2033
+ modelValue: e.value.platform.mappings.payments[n],
2034
+ "onUpdate:modelValue": (_) => e.value.platform.mappings.payments[n] = _,
2035
+ options: {
2036
+ key: { placeholder: "Key", editable: !0 },
2037
+ account: { placeholder: "Method", editable: !0 }
2038
+ },
2039
+ removable: !0,
2040
+ onRemove: () => v("payments", n)
2041
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2042
+ ])
2043
+ ])
2044
+ ])) : Y("", !0);
2045
+ };
2046
+ }
2047
+ }), Ql = { class: "h-full flex flex-col gap-16" }, Xl = { class: "flex flex-row gap-2 justify-between items-center" }, zl = {
2048
+ key: 0,
2049
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
2050
+ }, Jl = /* @__PURE__ */ M({
2051
+ __name: "Preview",
2052
+ props: {
2053
+ modelValue: { required: !0 },
2054
+ modelModifiers: {}
2055
+ },
2056
+ emits: ["update:modelValue"],
2057
+ setup(C) {
2058
+ const e = P([]), x = R(
2059
+ () => e.value.reduce((s, c) => {
2060
+ const v = s.length, { invoice: r, payments: w } = c;
2061
+ s[v] = {
2062
+ date: r.DocDate,
2063
+ docNo: r.DocNo,
2064
+ debtor: r.Code,
2065
+ description: r.Description_HDR
2066
+ };
2067
+ for (let a = 0; a < Math.max(r._items.length, w.length); a++) {
2068
+ const b = v + a;
2069
+ s[b] || (s[b] = {}), r._items[a] && (s[b] = {
2070
+ ...s[b],
2071
+ itemDescription: r._items[a].Description_DTL,
2072
+ itemUnitPrice: r._items[a].UnitPrice,
2073
+ itemAccount: r._items[a].ACCOUNT,
2074
+ itemTaxCode: r._items[a].Tax,
2075
+ itemTax: r._items[a].TaxAmt
2076
+ }), w[a] && (s[b] = {
2077
+ ...s[b],
2078
+ paymentDocNo: w[a].DOCNO_Header,
2079
+ paymentMethod: w[a].PAYMENTMETHOD,
2080
+ paymentAccount: w[a].CODE,
2081
+ paymentDescription: w[a].DESCRIPTION,
2082
+ paymentAmount: w[a].KOAMT
2083
+ });
2084
+ }
2085
+ return s;
2086
+ }, [])
2087
+ ), h = [
2088
+ {
2089
+ accessorKey: "date",
2090
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
2091
+ enableSorting: !1
2092
+ },
2093
+ {
2094
+ accessorKey: "docNo",
2095
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Doc No"),
2096
+ enableSorting: !1
2097
+ },
2098
+ {
2099
+ accessorKey: "debtor",
2100
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Debtor"),
2101
+ enableSorting: !1
2102
+ },
2103
+ {
2104
+ accessorKey: "description",
2105
+ header: "Description",
2106
+ enableSorting: !1
2107
+ },
2108
+ {
2109
+ accessorKey: "itemAccount",
2110
+ header: () => F("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
2111
+ enableSorting: !1
2112
+ },
2113
+ {
2114
+ accessorKey: "itemTaxCode",
2115
+ header: "Item Tax Code",
2116
+ enableSorting: !1
2117
+ },
2118
+ {
2119
+ accessorKey: "itemDescription",
2120
+ header: () => F("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
2121
+ enableSorting: !1
2122
+ },
2123
+ {
2124
+ accessorKey: "itemUnitPrice",
2125
+ header: "Item Unit Price",
2126
+ enableSorting: !1
2127
+ },
2128
+ {
2129
+ accessorKey: "itemTax",
2130
+ header: "Item Tax",
2131
+ enableSorting: !1
2132
+ },
2133
+ {
2134
+ accessorKey: "paymentDocNo",
2135
+ header: "Payment Doc No",
2136
+ enableSorting: !1
2137
+ },
2138
+ {
2139
+ accessorKey: "paymentMethod",
2140
+ header: "Payment Method",
2141
+ enableSorting: !1
2142
+ },
2143
+ {
2144
+ accessorKey: "paymentDescription",
2145
+ header: "Payment Description",
2146
+ enableSorting: !1
2147
+ },
2148
+ {
2149
+ accessorKey: "paymentAmount",
2150
+ header: "Payment Amount",
2151
+ enableSorting: !1
2152
+ }
2153
+ ], f = L(C, "modelValue"), y = P(!1), $ = se(), { dateRange: i } = be(ne());
2154
+ re(
2155
+ () => i.value,
2156
+ async () => {
2157
+ if (f.value._id)
2158
+ try {
2159
+ y.value = !0, e.value = await xe(f.value._id);
2160
+ } catch (s) {
2161
+ $.open({ message: s.message, type: "error" });
2162
+ } finally {
2163
+ y.value = !1;
2164
+ }
2165
+ },
2166
+ {
2167
+ immediate: !0
2168
+ }
2169
+ );
2170
+ async function D() {
2171
+ try {
2172
+ f.value._id ? (y.value = !0, await ke(f.value._id)) : $.open({ message: "Invalid accounting setting", type: "error" });
2173
+ } catch (s) {
2174
+ $.open({ message: s.message, type: "error" });
2175
+ } finally {
2176
+ y.value = !1;
2177
+ }
2178
+ }
2179
+ return (s, c) => {
2180
+ const v = V("FmButton"), r = V("FmCircularProgress"), w = V("FmTable");
2181
+ return u(), k("div", Ql, [
2182
+ l("div", Xl, [
2183
+ o(we, {
2184
+ "date-range": H(i),
2185
+ "onUpdate:dateRange": c[0] || (c[0] = (a) => pe(i) ? i.value = a : null),
2186
+ compare: !1
2187
+ }, null, 8, ["date-range"]),
2188
+ o(v, {
2189
+ loading: y.value,
2190
+ variant: "primary",
2191
+ label: "Download",
2192
+ onClick: D
2193
+ }, null, 8, ["loading"])
2194
+ ]),
2195
+ y.value ? (u(), k("div", zl, [
2196
+ o(r, { size: "xl" }),
2197
+ c[1] || (c[1] = l("span", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Loading data... ", -1))
2198
+ ])) : x.value.length > 0 ? (u(), T(w, {
2199
+ key: 1,
2200
+ class: "flex overflow-scroll",
2201
+ "row-data": x.value,
2202
+ "column-defs": h
2203
+ }, null, 8, ["row-data"])) : Y("", !0)
2204
+ ]);
2205
+ };
2206
+ }
2207
+ }), Wl = { class: "h-full relative flex flex-col" }, Zl = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, ea = /* @__PURE__ */ M({
2208
+ __name: "SQL",
2209
+ props: {
2210
+ modelValue: {},
2211
+ modelModifiers: {}
2212
+ },
2213
+ emits: ["update:modelValue"],
2214
+ setup(C) {
2215
+ const e = L(C, "modelValue"), x = P("setting"), h = [
2216
+ {
2217
+ label: "Setting",
2218
+ value: "setting",
2219
+ icon: "settings"
2220
+ },
2221
+ {
2222
+ label: "Preview",
2223
+ value: "preview",
2224
+ icon: "table"
2225
+ }
2226
+ ], f = oe(), y = R(() => {
2227
+ switch (x.value) {
2228
+ case "preview":
2229
+ return Jl;
2230
+ case "setting":
2231
+ return Gl;
2232
+ default:
2233
+ return null;
2234
+ }
2235
+ });
2236
+ return ($, i) => {
2237
+ var c;
2238
+ const D = V("FmPageHead"), s = V("FmTabs");
2239
+ return u(), k("div", Wl, [
2240
+ o(D, {
2241
+ title: ((c = e.value) == null ? void 0 : c.name) || "SQL",
2242
+ "back-button": !0,
2243
+ style: { paddingLeft: "0px", paddingRight: "0px" },
2244
+ "onClick:back": H(f).back
2245
+ }, {
2246
+ description: ue(() => i[2] || (i[2] = [
2247
+ l("div", null, null, -1)
2248
+ ])),
2249
+ _: 1
2250
+ }, 8, ["title", "onClick:back"]),
2251
+ o(s, {
2252
+ "model-value": x.value,
2253
+ "onUpdate:modelValue": i[0] || (i[0] = (v) => x.value = v),
2254
+ items: h
2255
+ }, null, 8, ["model-value"]),
2256
+ l("div", Zl, [
2257
+ (u(), T(de(y.value), {
2258
+ modelValue: e.value,
2259
+ "onUpdate:modelValue": i[1] || (i[1] = (v) => e.value = v)
2260
+ }, null, 8, ["modelValue"]))
2261
+ ])
2262
+ ]);
2263
+ };
2264
+ }
2265
+ }), ta = {
2266
+ key: 0,
2267
+ class: "flex flex-col h-full"
2268
+ }, la = { class: "flex flex-col gap-16 pb-[24px]" }, aa = { class: "flex flex-row justify-between items-center gap-2" }, oa = { class: "flex flex-row gap-2" }, na = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, sa = { class: "flex flex-col gap-16" }, ia = { class: "flex flex-row items-center max-w-[100%]" }, ra = { class: "flex-grow" }, ma = { class: "flex flex-row items-center max-w-[100%]" }, ua = { class: "flex flex-row items-center gap-x-16" }, da = { class: "grid-cols-1 grid gap-16" }, ca = /* @__PURE__ */ M({
2269
+ __name: "Setting",
2270
+ props: {
2271
+ modelValue: { required: !0 },
2272
+ modelModifiers: {}
2273
+ },
2274
+ emits: ["update:modelValue"],
2275
+ setup(C) {
2276
+ const e = L(C, "modelValue"), x = se(), h = ce(), f = oe(), { promptLoader: y } = fe(), { promptMessage: $ } = ve(), { restaurants: i } = ne(), D = R(
2277
+ () => i.map((w) => ({ label: w.name, value: w.id }))
2278
+ );
2279
+ async function s() {
2280
+ await $({
2281
+ message: `Confirm delete ${e.value.name}?`,
2282
+ title: "Delete"
2283
+ }) && await y(async () => {
2284
+ try {
2285
+ await ge(e.value._id), await h.getSettings(), f.back();
2286
+ } catch (a) {
2287
+ x.open({ type: "error", message: a.message });
2288
+ }
2289
+ });
2290
+ }
2291
+ async function c() {
2292
+ await y(async () => {
2293
+ try {
2294
+ await ye(e.value._id, e.value), await h.getSettings();
2295
+ } catch (w) {
2296
+ x.open({ type: "error", message: w.message });
2297
+ }
2298
+ });
2299
+ }
2300
+ function v(w, a) {
2301
+ var b, m;
2302
+ (m = (b = e.value.platform) == null ? void 0 : b.mappings) != null && m[w] && (e.value.platform.mappings[w] = e.value.platform.mappings[w].filter(
2303
+ (t, p) => p !== a
2304
+ ));
2305
+ }
2306
+ function r(w) {
2307
+ var a, b;
2308
+ (b = (a = e.value.platform) == null ? void 0 : a.mappings) != null && b[w] && (e.value.platform.mappings[w] = [
2309
+ ...e.value.platform.mappings[w],
2310
+ {
2311
+ key: "",
2312
+ name: "",
2313
+ badgeNo: "",
2314
+ employeeNo: ""
2315
+ }
2316
+ ]);
2317
+ }
2318
+ return (w, a) => {
2319
+ var d, N, I, O, A;
2320
+ const b = V("FmButton"), m = V("FmMenuDivider"), t = V("FmTextField"), p = V("FmSelect");
2321
+ return (N = (d = e.value) == null ? void 0 : d.platform) != null && N.mappings ? (u(), k("div", ta, [
2322
+ l("div", la, [
2323
+ l("div", aa, [
2324
+ a[4] || (a[4] = l("div", { class: "fm-typo-en-title-sm-800" }, null, -1)),
2325
+ l("div", oa, [
2326
+ o(b, {
2327
+ variant: "tertiary",
2328
+ label: "Delete",
2329
+ onClick: s
2330
+ }),
2331
+ o(b, {
2332
+ variant: "primary",
2333
+ label: "Update",
2334
+ onClick: c
2335
+ })
2336
+ ])
2337
+ ])
2338
+ ]),
2339
+ o(m, { style: { margin: 0 } }),
2340
+ l("div", na, [
2341
+ l("div", sa, [
2342
+ a[7] || (a[7] = l("div", { class: "fm-typo-en-title-sm-800" }, "General", -1)),
2343
+ l("div", ia, [
2344
+ a[5] || (a[5] = l("div", { class: "w-[25%]" }, "Name", -1)),
2345
+ l("div", ra, [
2346
+ o(t, {
2347
+ modelValue: e.value.name,
2348
+ "onUpdate:modelValue": a[0] || (a[0] = (B) => e.value.name = B)
2349
+ }, null, 8, ["modelValue"])
2350
+ ])
2351
+ ]),
2352
+ l("div", ma, [
2353
+ a[6] || (a[6] = l("div", { class: "w-[25%]" }, "Location", -1)),
2354
+ o(p, {
2355
+ "model-value": e.value.platform.locationIds[0],
2356
+ multiselect: !1,
2357
+ items: D.value,
2358
+ placeholder: "Select location",
2359
+ class: "flex-grow",
2360
+ "onUpdate:modelValue": a[1] || (a[1] = (B) => e.value.platform.locationIds[0] = B)
2361
+ }, null, 8, ["model-value", "items"])
2362
+ ])
2363
+ ]),
2364
+ o(_e, {
2365
+ modelValue: e.value.platform,
2366
+ "onUpdate:modelValue": a[2] || (a[2] = (B) => e.value.platform = B),
2367
+ label: "email"
2368
+ }, null, 8, ["modelValue"]),
2369
+ l("div", ua, [
2370
+ a[8] || (a[8] = l("div", { class: "fm-typo-en-title-sm-800" }, "Employees", -1)),
2371
+ o(b, {
2372
+ variant: "primary",
2373
+ icon: "add",
2374
+ onClick: a[3] || (a[3] = () => r("employees"))
2375
+ })
2376
+ ]),
2377
+ l("div", da, [
2378
+ (u(!0), k(K, null, j((A = (O = (I = e.value) == null ? void 0 : I.platform) == null ? void 0 : O.mappings) == null ? void 0 : A.employees, (B, E) => (u(), T(S, {
2379
+ key: `employee-${E}`,
2380
+ modelValue: e.value.platform.mappings.employees[E],
2381
+ "onUpdate:modelValue": (q) => e.value.platform.mappings.employees[E] = q,
2382
+ options: {
2383
+ key: { placeholder: "Name", editable: !0 },
2384
+ badgeNo: { placeholder: "Badge No", editable: !0 },
2385
+ employeeNo: { placeholder: "Employee No", editable: !0 }
2386
+ },
2387
+ removable: !0,
2388
+ onRemove: () => v("employees", E)
2389
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2390
+ ])
2391
+ ])
2392
+ ])) : Y("", !0);
2393
+ };
2394
+ }
2395
+ }), pa = { class: "h-full flex flex-col gap-16" }, fa = { class: "flex flex-row gap-2 justify-between items-center" }, va = {
2396
+ key: 0,
2397
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
2398
+ }, ga = /* @__PURE__ */ M({
2399
+ __name: "Preview",
2400
+ props: {
2401
+ modelValue: { required: !0 },
2402
+ modelModifiers: {}
2403
+ },
2404
+ emits: ["update:modelValue"],
2405
+ setup(C) {
2406
+ const e = P([]), x = [
2407
+ {
2408
+ accessorKey: "name",
2409
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Name"),
2410
+ enableSorting: !1
2411
+ },
2412
+ {
2413
+ accessorKey: "badgeNo",
2414
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Badge No"),
2415
+ enableSorting: !1
2416
+ },
2417
+ {
2418
+ accessorKey: "employeeNo",
2419
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Employee No"),
2420
+ enableSorting: !1
2421
+ },
2422
+ {
2423
+ accessorKey: "date",
2424
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
2425
+ enableSorting: !1
2426
+ },
2427
+ {
2428
+ accessorKey: "time",
2429
+ header: () => F("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Time"),
2430
+ enableSorting: !1
2431
+ }
2432
+ ], h = L(C, "modelValue"), f = P(!1), y = se(), { dateRange: $ } = be(ne());
2433
+ re(
2434
+ () => $.value,
2435
+ async () => {
2436
+ if (h.value._id)
2437
+ try {
2438
+ f.value = !0, e.value = await xe(h.value._id);
2439
+ } catch (D) {
2440
+ y.open({ message: D.message, type: "error" });
2441
+ } finally {
2442
+ f.value = !1;
2443
+ }
2444
+ },
2445
+ {
2446
+ immediate: !0
2447
+ }
2448
+ );
2449
+ async function i() {
2450
+ try {
2451
+ h.value._id ? (f.value = !0, await ke(h.value._id)) : y.open({ message: "Invalid setting", type: "error" });
2452
+ } catch (D) {
2453
+ y.open({ message: D.message, type: "error" });
2454
+ } finally {
2455
+ f.value = !1;
2456
+ }
2457
+ }
2458
+ return (D, s) => {
2459
+ const c = V("FmButton"), v = V("FmCircularProgress"), r = V("FmTable");
2460
+ return u(), k("div", pa, [
2461
+ l("div", fa, [
2462
+ o(we, {
2463
+ "date-range": H($),
2464
+ "onUpdate:dateRange": s[0] || (s[0] = (w) => pe($) ? $.value = w : null),
2465
+ compare: !1
2466
+ }, null, 8, ["date-range"]),
2467
+ o(c, {
2468
+ loading: f.value,
2469
+ variant: "primary",
2470
+ label: "Download",
2471
+ onClick: i
2472
+ }, null, 8, ["loading"])
2473
+ ]),
2474
+ f.value ? (u(), k("div", va, [
2475
+ o(v, { size: "xl" }),
2476
+ s[1] || (s[1] = l("span", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Loading data... ", -1))
2477
+ ])) : e.value.length > 0 ? (u(), T(r, {
2478
+ key: 1,
2479
+ class: "flex overflow-scroll",
2480
+ "row-data": e.value,
2481
+ "column-defs": x
2482
+ }, null, 8, ["row-data"])) : Y("", !0)
2483
+ ]);
2484
+ };
2485
+ }
2486
+ }), ya = { class: "h-full relative flex flex-col" }, xa = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, ba = /* @__PURE__ */ M({
2487
+ __name: "IFlexiHRMS",
2488
+ props: {
2489
+ modelValue: {},
2490
+ modelModifiers: {}
2491
+ },
2492
+ emits: ["update:modelValue"],
2493
+ setup(C) {
2494
+ const e = L(C, "modelValue"), x = P("setting"), h = [
2495
+ {
2496
+ label: "Setting",
2497
+ value: "setting",
2498
+ icon: "settings"
2499
+ },
2500
+ {
2501
+ label: "Preview",
2502
+ value: "preview",
2503
+ icon: "table"
2504
+ }
2505
+ ], f = oe(), y = R(() => {
2506
+ switch (x.value) {
2507
+ case "preview":
2508
+ return ga;
2509
+ case "setting":
2510
+ return ca;
2511
+ default:
2512
+ return null;
2513
+ }
2514
+ });
2515
+ return ($, i) => {
2516
+ var c;
2517
+ const D = V("FmPageHead"), s = V("FmTabs");
2518
+ return u(), k("div", ya, [
2519
+ o(D, {
2520
+ title: ((c = e.value) == null ? void 0 : c.name) || "AutoCount",
2521
+ "back-button": !0,
2522
+ style: { paddingLeft: "0px", paddingRight: "0px" },
2523
+ "onClick:back": H(f).back
2524
+ }, {
2525
+ description: ue(() => i[2] || (i[2] = [
2526
+ l("div", null, null, -1)
2527
+ ])),
2528
+ _: 1
2529
+ }, 8, ["title", "onClick:back"]),
2530
+ o(s, {
2531
+ "model-value": x.value,
2532
+ "onUpdate:modelValue": i[0] || (i[0] = (v) => x.value = v),
2533
+ items: h
2534
+ }, null, 8, ["model-value"]),
2535
+ l("div", xa, [
2536
+ (u(), T(de(y.value), {
2537
+ modelValue: e.value,
2538
+ "onUpdate:modelValue": i[1] || (i[1] = (v) => e.value = v)
2539
+ }, null, 8, ["modelValue"]))
2540
+ ])
2541
+ ]);
2542
+ };
2543
+ }
2544
+ }), wa = { class: "px-24 h-full relative" }, Ca = /* @__PURE__ */ M({
2545
+ __name: "Integration",
2546
+ setup(C) {
2547
+ const e = P(void 0), { params: x } = Se(), h = ce(), f = P();
2548
+ Ce(async () => {
2549
+ h.settings.length === 0 && await h.getSettings();
2550
+ }), re(
2551
+ () => h.settings,
2552
+ ($) => {
2553
+ var D;
2554
+ const i = $.find((s) => s._id === x.id);
2555
+ i && (f.value = i, e.value = (D = f.value.platform) == null ? void 0 : D.name);
2556
+ },
2557
+ { immediate: !0 }
2558
+ );
2559
+ const y = R(() => {
2560
+ switch (e.value) {
2561
+ case le.Xero:
2562
+ return $t;
2563
+ case le.Bukku:
2564
+ return tl;
2565
+ case le.AutoCount:
2566
+ return Cl;
2567
+ case le.SQL:
2568
+ return ea;
2569
+ case le.iFlexi_HRMS:
2570
+ return ba;
2571
+ default:
2572
+ return null;
2573
+ }
2574
+ });
2575
+ return ($, i) => (u(), k("div", wa, [
2576
+ (u(), T(de(y.value), {
2577
+ modelValue: f.value,
2578
+ "onUpdate:modelValue": i[0] || (i[0] = (D) => f.value = D)
2579
+ }, null, 8, ["modelValue"]))
2580
+ ]));
2581
+ }
2582
+ });
2583
+ export {
2584
+ Ca as default
2585
+ };