@feedmepos/mf-report 5.4.15-beta.1 → 5.4.15-beta.3

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 (45) hide show
  1. package/dist/App-DufL3Y8h.js +152 -0
  2. package/dist/DateRangeSelect.vue_vue_type_script_setup_true_lang-DLDk5l4R.js +162 -0
  3. package/dist/{Default.vue_vue_type_script_setup_true_lang-Bxuyjrkr.js → Default.vue_vue_type_script_setup_true_lang-DVLxkOOQ.js} +2 -2
  4. package/dist/DynamicWidget.vue_vue_type_script_setup_true_lang-C29g9w6o.js +999 -0
  5. package/dist/{InsightView-D78TK2E8.js → InsightView-tyeJBlRm.js} +1051 -1049
  6. package/dist/Integration-ILSIf-OL.js +3695 -0
  7. package/dist/Integrations-DwgNrM3U.js +334 -0
  8. package/dist/{Layout-DERpCrQk.js → Layout-Bw1oh6Q-.js} +1 -1
  9. package/dist/{LocationSelect.vue_vue_type_script_setup_true_lang-DurYBXa5.js → LocationSelect.vue_vue_type_script_setup_true_lang-BFj4d-UF.js} +1861 -1859
  10. package/dist/MenuTab.vue_vue_type_script_setup_true_lang-DzZeasAK.js +277 -0
  11. package/dist/{NavigationTab.vue_vue_type_script_setup_true_lang-C8yzWDXs.js → NavigationTab.vue_vue_type_script_setup_true_lang-_eC_tMk_.js} +5526 -5482
  12. package/dist/NoData.vue_vue_type_script_setup_true_lang-BtQobm-7.js +31 -0
  13. package/dist/OverviewView-Dl8oOobn.js +61 -0
  14. package/dist/Report-BqD8KVZ8.js +424 -0
  15. package/dist/ReportEditor-DkzFUgbO.js +532 -0
  16. package/dist/ReportView-DpWZHV0o.js +169 -0
  17. package/dist/SelectComponent.vue_vue_type_script_setup_true_lang-C3VG1mi_.js +104 -0
  18. package/dist/Setting-CYrg_50p.js +320 -0
  19. package/dist/TileEditor-CDrzLbqc.js +2320 -0
  20. package/dist/{TransitionFade-BLDfpF7R.js → TransitionFade-D19wC3tb.js} +225 -220
  21. package/dist/app.js +915 -27
  22. package/dist/{global-loader-CMC9fgBi.js → global-loader-C3JC7z-H.js} +4966 -2240
  23. package/dist/index-9IDzTnHw.js +147 -0
  24. package/dist/{report-schema-G0x3CoJb.js → report-schema-1zQJbLyB.js} +4 -4
  25. package/dist/style.css +1 -1
  26. package/dist/timeFormat-CjNvJMgk.js +9 -0
  27. package/dist/{v4-DF7wffYN.js → v4-D29FkHfi.js} +2666 -1927
  28. package/package.json +1 -1
  29. package/dist/App-mcSgbcVY.js +0 -133
  30. package/dist/DateRangeSelect.vue_vue_type_script_setup_true_lang-DPuhMR6i.js +0 -160
  31. package/dist/DynamicWidget.vue_vue_type_script_setup_true_lang-B6IzlHmr.js +0 -996
  32. package/dist/HeaderTab.vue_vue_type_script_setup_true_lang-B5VBDNwX.js +0 -19
  33. package/dist/Integration-Cm6_YEEE.js +0 -3554
  34. package/dist/Integrations-WWnSho0Q.js +0 -334
  35. package/dist/MenuTab.vue_vue_type_script_setup_true_lang-h87kWy1E.js +0 -261
  36. package/dist/NoData.vue_vue_type_script_setup_true_lang-DlBNFLa3.js +0 -30
  37. package/dist/OverviewView-D7zAR7_7.js +0 -60
  38. package/dist/Report-BnX5amn0.js +0 -409
  39. package/dist/ReportEditor-DW7uWg_a.js +0 -530
  40. package/dist/ReportView-xSaJA5F6.js +0 -166
  41. package/dist/SelectComponent.vue_vue_type_script_setup_true_lang-DBI9op0g.js +0 -103
  42. package/dist/Setting-D8JspXTN.js +0 -326
  43. package/dist/TileEditor-DQ8C5I_M.js +0 -2301
  44. package/dist/index-SmIkb24L.js +0 -143
  45. package/dist/timeFormat-BF-F4Rnt.js +0 -9
@@ -0,0 +1,3695 @@
1
+ import { defineComponent as H, mergeModels as ge, useModel as Q, computed as Y, resolveComponent as $, createElementBlock as U, openBlock as p, createElementVNode as t, createCommentVNode as L, normalizeClass as Ue, Fragment as z, renderList as q, createBlock as A, createVNode as i, withCtx as ve, toDisplayString as T, unref as f, ref as B, watch as fe, isRef as _e, h as M, resolveDynamicComponent as ye, mergeProps as Ae, onMounted as Pe } from "vue";
2
+ import { useRouter as me, useRoute as Ne } from "vue-router";
3
+ import { u as W, I as re, d as Ke, e as xe, f as be, b as ce, q as Re, m as Be, p as we, r as he, s as Ve, t as ke, v as Te, w as je, x as Oe, y as Le, A as ue, z as Ie, B as ze, E as Ee } from "./global-loader-C3JC7z-H.js";
4
+ import { u as $e } from "./message-dialog-UoMWOnil.js";
5
+ import { useSnackbar as pe } from "@feedmepos/ui-library";
6
+ import { s as Ye } from "./index-9IDzTnHw.js";
7
+ import { storeToRefs as Se } from "pinia";
8
+ import { _ as Ce } from "./DateRangeSelect.vue_vue_type_script_setup_true_lang-DLDk5l4R.js";
9
+ const He = { class: "flex flex-row items-center w-[100%] gap-[4px] justify-between" }, qe = { class: "text-nowrap w-[100%] overflow-hidden text-ellipsis" }, Qe = {
10
+ key: 0,
11
+ class: "w-[24px] flex items-center"
12
+ }, K = /* @__PURE__ */ H({
13
+ __name: "MappingField",
14
+ props: /* @__PURE__ */ ge({
15
+ removable: {
16
+ type: Boolean,
17
+ default: !1
18
+ },
19
+ options: {
20
+ type: Object,
21
+ default: () => ({})
22
+ },
23
+ type: {
24
+ type: String,
25
+ default: "text"
26
+ },
27
+ rules: {
28
+ type: Array,
29
+ default: () => []
30
+ }
31
+ }, {
32
+ modelValue: { required: !0 },
33
+ modelModifiers: {}
34
+ }),
35
+ emits: /* @__PURE__ */ ge(["remove"], ["update:modelValue"]),
36
+ setup(x, { emit: o }) {
37
+ const e = Q(x, "modelValue"), n = x, h = Y(
38
+ () => Object.keys(n.options).map((w) => {
39
+ const C = n.options[w];
40
+ return {
41
+ placeholder: C.placeholder,
42
+ key: w,
43
+ editable: C.editable
44
+ };
45
+ })
46
+ ), _ = o;
47
+ return (w, C) => {
48
+ const V = $("FmTextField"), r = $("FmTooltip"), d = $("FmIcon");
49
+ return p(), U("div", He, [
50
+ t("div", {
51
+ class: Ue(`${x.removable ? "w-[calc(100%-24px)]" : "w-[100%]"} flex flex-row items-center gap-[4px]`)
52
+ }, [
53
+ (p(!0), U(z, null, q(h.value, (k) => {
54
+ var v;
55
+ return p(), U(z, {
56
+ key: k.key
57
+ }, [
58
+ k.editable ? (p(), U("div", {
59
+ key: 0,
60
+ class: Ue(`${x.removable ? "w-[50%]" : "w-[100%]"}`)
61
+ }, [
62
+ i(V, {
63
+ "model-value": e.value[k.key],
64
+ placeholder: k.placeholder,
65
+ type: x.type,
66
+ rules: x.rules,
67
+ "onUpdate:modelValue": (g) => {
68
+ let u = g;
69
+ x.type === "number" && (u = Number(g)), e.value = {
70
+ ...e.value,
71
+ [k.key]: u
72
+ };
73
+ }
74
+ }, null, 8, ["model-value", "placeholder", "type", "rules", "onUpdate:modelValue"])
75
+ ], 2)) : (p(), A(r, {
76
+ key: 1,
77
+ content: (v = e.value[k.key]) == null ? void 0 : v.toString(),
78
+ class: "w-[50%]"
79
+ }, {
80
+ default: ve(() => [
81
+ t("div", qe, T(e.value[k.key]), 1)
82
+ ]),
83
+ _: 2
84
+ }, 1032, ["content"]))
85
+ ], 64);
86
+ }), 128))
87
+ ], 2),
88
+ x.removable ? (p(), U("div", Qe, [
89
+ i(d, {
90
+ color: "system-error-300",
91
+ class: "cursor-pointer",
92
+ name: "close",
93
+ size: "md",
94
+ onClick: C[0] || (C[0] = (k) => _("remove"))
95
+ })
96
+ ])) : L("", !0)
97
+ ]);
98
+ };
99
+ }
100
+ }), Xe = { class: "flex flex-col" }, Ge = { class: "flex flex-row items-center fm-typo-en-title-sm-800 h-[36px]" }, Je = {
101
+ key: 0,
102
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
103
+ }, We = { class: "flex flex-row items-center w-[100%] justify-start" }, Ze = { class: "text-nowrap w-[calc(25%-4px)] overflow-hidden text-ellipsis" }, et = {
104
+ key: 0,
105
+ class: "flex flex-row items-center w-[100%] justify-start"
106
+ }, tt = { class: "text-nowrap w-[calc(25%-4px)] overflow-hidden text-ellipsis" }, ot = { class: "w-[calc(75%+4px)]" }, at = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, lt = { class: "flex flex-row items-center w-[100%] justify-between" }, nt = { class: "text-nowrap w-[50%] overflow-hidden text-ellipsis" }, st = { class: "w-[50%]" }, Fe = /* @__PURE__ */ H({
107
+ __name: "UploadSection",
108
+ props: /* @__PURE__ */ ge({
109
+ label: {
110
+ type: String,
111
+ default: "upload"
112
+ },
113
+ lastUploadDate: {
114
+ type: String,
115
+ default: null
116
+ }
117
+ }, {
118
+ modelValue: { required: !0 },
119
+ modelModifiers: {}
120
+ }),
121
+ emits: ["update:modelValue"],
122
+ setup(x) {
123
+ const { t: o } = W(), e = Q(x, "modelValue"), n = Y(() => {
124
+ switch (e.value.name) {
125
+ case re.AutoCount:
126
+ case re.SQL:
127
+ case re.iFlexi_HRMS:
128
+ return !0;
129
+ default:
130
+ return !1;
131
+ }
132
+ });
133
+ return (h, _) => {
134
+ var r, d;
135
+ const w = $("FmSwitch"), C = $("FmTextField"), V = $("FmTimePicker");
136
+ return p(), U(z, null, [
137
+ t("div", Xe, [
138
+ t("div", Ge, T(f(o)("report.integration.auto", { label: x.label })), 1),
139
+ x.label == "upload" ? (p(), U("div", Je, T(f(o)("report.integration.lastUploadDate")) + ": " + T(x.lastUploadDate ? f(Ke)(x.lastUploadDate).format("MMMM D, YYYY h:mm A") : f(o)("report.integration.noData.title")), 1)) : L("", !0)
140
+ ]),
141
+ t("div", We, [
142
+ t("div", Ze, T(f(o)("report.common.enable")), 1),
143
+ i(w, {
144
+ modelValue: e.value.enable,
145
+ "onUpdate:modelValue": _[0] || (_[0] = (k) => e.value.enable = k),
146
+ style: { gap: "0px" }
147
+ }, null, 8, ["modelValue"])
148
+ ]),
149
+ n.value ? (p(), U("div", et, [
150
+ t("div", tt, T(f(o)("report.common.email")), 1),
151
+ t("div", ot, [
152
+ i(C, {
153
+ "model-value": (e.value.emails || []).join(","),
154
+ placeholder: "Email",
155
+ "onUpdate:modelValue": _[1] || (_[1] = (k) => {
156
+ switch (e.value.name) {
157
+ case f(re).AutoCount:
158
+ case f(re).SQL:
159
+ case f(re).iFlexi_HRMS:
160
+ e.value.emails = k.split(",");
161
+ break;
162
+ }
163
+ })
164
+ }, null, 8, ["model-value"])
165
+ ])
166
+ ])) : L("", !0),
167
+ t("div", at, [
168
+ t("div", lt, [
169
+ t("div", nt, T(f(Ye)(x.label)) + " time ", 1),
170
+ t("div", st, [
171
+ i(V, {
172
+ class: "gap-[0px]",
173
+ "model-value": f(Ke)().hour(((r = e.value.triggerTime) == null ? void 0 : r.hour) ?? 0).minute(((d = e.value.triggerTime) == null ? void 0 : d.minute) ?? 0).format("HH:mm"),
174
+ "onUpdate:modelValue": _[2] || (_[2] = (k) => {
175
+ k && (e.value.triggerTime.hour = Number(k.split(":")[0]), e.value.triggerTime.minute = Number(k.split(":")[1]));
176
+ })
177
+ }, null, 8, ["model-value"])
178
+ ])
179
+ ]),
180
+ i(K, {
181
+ "model-value": {
182
+ label: f(o)("report.integration.delayDay"),
183
+ delayDay: e.value.delayDay
184
+ },
185
+ type: "number",
186
+ options: {
187
+ label: { placeholder: f(o)("report.integration.delayDay"), editable: !1 },
188
+ delayDay: { placeholder: f(o)("report.integration.delayDay"), editable: !0 }
189
+ },
190
+ rules: [(k) => k > 0 || "Delay days must be greater than 0"],
191
+ "onUpdate:modelValue": _[3] || (_[3] = (k) => {
192
+ e.value.delayDay = k.delayDay;
193
+ })
194
+ }, null, 8, ["model-value", "options", "rules"])
195
+ ])
196
+ ], 64);
197
+ };
198
+ }
199
+ }), it = { class: "flex flex-row items-center w-[100%] gap-[4px] justify-between" }, rt = {
200
+ key: 0,
201
+ class: "w-[50%]"
202
+ }, mt = { class: "text-nowrap w-[100%] overflow-hidden text-ellipsis" }, ct = {
203
+ key: 0,
204
+ class: "w-[24px] flex items-center"
205
+ }, De = /* @__PURE__ */ H({
206
+ __name: "MappingDropdown",
207
+ props: /* @__PURE__ */ ge({
208
+ removable: {
209
+ type: Boolean,
210
+ default: !1
211
+ },
212
+ singleValueMode: {
213
+ type: Boolean,
214
+ default: !1
215
+ },
216
+ options: {
217
+ type: Object,
218
+ default: () => ({})
219
+ },
220
+ type: {
221
+ type: String,
222
+ default: "text"
223
+ },
224
+ rules: {
225
+ type: Array,
226
+ default: () => []
227
+ }
228
+ }, {
229
+ modelValue: { required: !0 },
230
+ modelModifiers: {}
231
+ }),
232
+ emits: /* @__PURE__ */ ge(["remove"], ["update:modelValue"]),
233
+ setup(x, { emit: o }) {
234
+ const e = Q(x, "modelValue"), n = x, h = Y(
235
+ () => Object.keys(n.options).map((r) => {
236
+ const d = n.options[r];
237
+ return {
238
+ placeholder: d.placeholder,
239
+ key: r,
240
+ editable: d.editable,
241
+ dropdownOptions: d.dropdownOptions
242
+ };
243
+ })
244
+ ), _ = (r, d) => {
245
+ n.singleValueMode ? e.value = n.type === "number" ? Number(r) : r : d && (e.value = {
246
+ ...e.value,
247
+ [d]: n.type === "number" ? Number(r) : r
248
+ });
249
+ }, w = (r) => {
250
+ var d;
251
+ return n.singleValueMode ? n.options.key.placeholder : (d = e.value[r.key]) == null ? void 0 : d.toString();
252
+ }, C = (r) => n.singleValueMode ? e.value : e.value[r.key], V = o;
253
+ return (r, d) => {
254
+ const k = $("FmSelect"), v = $("FmTextField"), g = $("FmTooltip"), u = $("FmIcon");
255
+ return p(), U("div", it, [
256
+ t("div", {
257
+ class: Ue(`${x.removable ? "w-[calc(100%-24px)]" : "w-[100%]"} flex flex-row items-center gap-[4px]`)
258
+ }, [
259
+ (p(!0), U(z, null, q(h.value, (m) => (p(), U(z, {
260
+ key: m.key
261
+ }, [
262
+ m.editable ? (p(), U("div", rt, [
263
+ m.dropdownOptions ? (p(), A(k, {
264
+ key: 0,
265
+ "model-value": C(m),
266
+ placeholder: m.placeholder,
267
+ items: m.dropdownOptions,
268
+ "shift-menu": !0,
269
+ "onUpdate:modelValue": (b) => _(b, m.key)
270
+ }, null, 8, ["model-value", "placeholder", "items", "onUpdate:modelValue"])) : (p(), A(v, {
271
+ key: 1,
272
+ "model-value": C(m),
273
+ placeholder: m.placeholder,
274
+ type: x.type,
275
+ rules: x.rules,
276
+ "onUpdate:modelValue": (b) => _(b, m.key)
277
+ }, null, 8, ["model-value", "placeholder", "type", "rules", "onUpdate:modelValue"]))
278
+ ])) : (p(), A(g, {
279
+ key: 1,
280
+ content: w(m),
281
+ class: "w-[50%]"
282
+ }, {
283
+ default: ve(() => [
284
+ t("div", mt, T(w(m)), 1)
285
+ ]),
286
+ _: 2
287
+ }, 1032, ["content"]))
288
+ ], 64))), 128))
289
+ ], 2),
290
+ x.removable ? (p(), U("div", ct, [
291
+ i(u, {
292
+ color: "system-error-300",
293
+ class: "cursor-pointer",
294
+ name: "close",
295
+ size: "md",
296
+ onClick: d[0] || (d[0] = (m) => V("remove"))
297
+ })
298
+ ])) : L("", !0)
299
+ ]);
300
+ };
301
+ }
302
+ }), pt = {
303
+ key: 0,
304
+ class: "flex flex-col h-full"
305
+ }, dt = { class: "flex flex-col gap-[16px] pb-[24px]" }, ut = { class: "flex flex-row justify-between items-center gap-2" }, ft = { class: "flex flex-row gap-2 items-center" }, vt = { class: "relative group cursor-pointer" }, gt = { class: "flex flex-col gap-16 pt-[24px] overflow-scroll" }, yt = { class: "flex flex-row items-center justify-between gap-2" }, xt = { class: "w-[25%]" }, _t = { class: "flex flex-col gap-[16px]" }, bt = { class: "flex flex-row items-center max-w-[100%] justify-between" }, wt = { class: "flex-grow" }, ht = { class: "flex flex-row items-center max-w-[100%] justify-between" }, Vt = { class: "flex flex-col gap-[16px]" }, kt = { class: "flex flex-row items-center max-w-[100%] justify-between" }, $t = { class: "flex-grow" }, St = { class: "flex flex-row items-center max-w-[100%] justify-between" }, Ct = { class: "flex-grow" }, Ft = { class: "flex flex-row items-center max-w-[100%] justify-between" }, Dt = { class: "flex-grow" }, Ut = { class: "flex flex-row items-center gap-x-16" }, Tt = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, It = { class: "flex flex-row items-center gap-x-16" }, Mt = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Kt = { class: "flex flex-row items-center gap-x-16" }, At = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Pt = /* @__PURE__ */ H({
306
+ __name: "Setting",
307
+ props: /* @__PURE__ */ ge({
308
+ tenantOptions: {
309
+ type: [],
310
+ default: () => []
311
+ },
312
+ taxOptions: {
313
+ type: [],
314
+ default: () => []
315
+ },
316
+ accountCodeOptions: {
317
+ type: [],
318
+ default: () => []
319
+ }
320
+ }, {
321
+ modelValue: { required: !0 },
322
+ modelModifiers: {}
323
+ }),
324
+ emits: ["update:modelValue"],
325
+ setup(x) {
326
+ const { t: o } = W(), e = Q(x, "modelValue"), n = pe(), h = xe(), _ = me(), { promptLoader: w } = be(), { promptMessage: C } = $e(), { restaurants: V } = ce(), r = B(!1), d = Y(
327
+ () => V.map((c) => ({ label: c.name, value: c.id }))
328
+ ), k = Y(() => {
329
+ var c, s;
330
+ return r.value ? "Connecting" : (s = (c = e.value) == null ? void 0 : c.platform) != null && s.accessToken ? "Disconnect" : "Connect";
331
+ }), v = B(0);
332
+ async function g() {
333
+ var c;
334
+ if (r.value)
335
+ n.open({ type: "error", message: "Connecting in progress" });
336
+ else if ((c = e.value.platform) != null && c.accessToken)
337
+ await C({
338
+ message: o("report.integration.xero.confirmDisconnect", { name: e.value.name }),
339
+ title: o("report.integration.xero.disconnectTitle")
340
+ }) && (await Re(e.value._id), await h.getSettings(), x.tenantOptions.length = 0);
341
+ else if (e.value._id)
342
+ try {
343
+ const s = await Be(e.value._id);
344
+ r.value = !0;
345
+ const P = setInterval(async () => {
346
+ var N;
347
+ v.value += 1;
348
+ try {
349
+ await h.getSettings();
350
+ } finally {
351
+ (v.value === 12 || (N = e.value.platform) != null && N.accessToken) && (r.value = !1, P && clearInterval(P), v.value = 0);
352
+ }
353
+ }, 5e3);
354
+ window.open(s.redirect, "_blank");
355
+ } catch (s) {
356
+ n.open({ type: "error", message: s.message });
357
+ }
358
+ else
359
+ n.open({ type: "error", message: `invalid accounting ${e.value._id}` });
360
+ }
361
+ async function u() {
362
+ await C({
363
+ message: `Confirm delete ${e.value.name}?`,
364
+ title: "Delete"
365
+ }) && await w(async () => {
366
+ try {
367
+ await we(e.value._id), await h.getSettings(), _.back();
368
+ } catch (s) {
369
+ n.open({ type: "error", message: s.message });
370
+ }
371
+ });
372
+ }
373
+ async function m() {
374
+ await w(async () => {
375
+ try {
376
+ await he(e.value._id, e.value), await h.getSettings();
377
+ } catch (c) {
378
+ n.open({ type: "error", message: c.message });
379
+ }
380
+ });
381
+ }
382
+ function b(c) {
383
+ const s = x.tenantOptions.find((P) => P.value === c);
384
+ s && e.value.platform && (e.value.platform.tenant = {
385
+ id: s.value,
386
+ name: s.label
387
+ });
388
+ }
389
+ function F(c, s) {
390
+ var P, N;
391
+ (N = (P = e.value.platform) == null ? void 0 : P.mappings) != null && N[c] && (e.value.platform.mappings[c] = e.value.platform.mappings[c].filter(
392
+ (J, X) => X !== s
393
+ ));
394
+ }
395
+ function l(c) {
396
+ var s, P;
397
+ (P = (s = e.value.platform) == null ? void 0 : s.mappings) != null && P[c] && (e.value.platform.mappings[c] = [
398
+ ...e.value.platform.mappings[c],
399
+ c === "items" ? {
400
+ feedmeKey: "",
401
+ xeroAccount: "",
402
+ name: ""
403
+ } : c === "taxes" ? {
404
+ feedmeKey: "",
405
+ xeroAccount: ""
406
+ } : {
407
+ feedmeKey: "",
408
+ xeroAccount: ""
409
+ }
410
+ ]);
411
+ }
412
+ async function a() {
413
+ await w(async () => {
414
+ try {
415
+ await Ve(e.value._id), await h.getSettings();
416
+ } catch (c) {
417
+ n.open({ type: "error", message: c.message });
418
+ }
419
+ });
420
+ }
421
+ return (c, s) => {
422
+ var j, E, Z, ee, te, oe, ae, le, ne, se, ie, y, D;
423
+ const P = $("FmIcon"), N = $("FmButton"), J = $("FmMenuDivider"), X = $("FmSelect"), G = $("FmTextField"), R = $("FmSwitch");
424
+ return (E = (j = e.value) == null ? void 0 : j.platform) != null && E.mappings ? (p(), U("div", pt, [
425
+ t("div", dt, [
426
+ t("div", ut, [
427
+ s[10] || (s[10] = t("div", { class: "fm-typo-en-title-sm-800" }, "Connect", -1)),
428
+ t("div", ft, [
429
+ t("div", vt, [
430
+ i(P, {
431
+ name: "refresh",
432
+ class: "p-2 bg-gray-100 rounded-full",
433
+ onClick: a
434
+ }),
435
+ s[9] || (s[9] = t("span", { class: "absolute left-1/2 -translate-x-2/3 top-full mt-2 w-max bg-gray-900 text-white text-sm px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity" }, " Repopulate the fields based on the dates selected in Preview. ", -1))
436
+ ]),
437
+ i(N, {
438
+ variant: "tertiary",
439
+ label: "Delete",
440
+ onClick: u
441
+ }),
442
+ i(N, {
443
+ variant: "primary",
444
+ label: "Update",
445
+ onClick: m
446
+ })
447
+ ])
448
+ ])
449
+ ]),
450
+ i(J, { style: { margin: 0 } }),
451
+ t("div", gt, [
452
+ s[21] || (s[21] = t("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)),
453
+ t("div", yt, [
454
+ t("div", xt, [
455
+ i(N, {
456
+ disabled: r.value,
457
+ variant: "primary",
458
+ label: k.value,
459
+ onClick: g
460
+ }, null, 8, ["disabled", "label"])
461
+ ]),
462
+ x.tenantOptions.length > 0 ? (p(), A(X, {
463
+ key: 0,
464
+ class: "flex-grow",
465
+ items: x.tenantOptions,
466
+ "model-value": (Z = e.value.platform.tenant) == null ? void 0 : Z.id,
467
+ placeholder: "Select tenant",
468
+ "onUpdate:modelValue": b
469
+ }, null, 8, ["items", "model-value"])) : L("", !0)
470
+ ]),
471
+ t("div", _t, [
472
+ s[13] || (s[13] = t("div", { class: "flex flex-row items-center fm-typo-en-title-sm-800 h-[36px]" }, "General", -1)),
473
+ t("div", bt, [
474
+ s[11] || (s[11] = t("div", { class: "w-[25%]" }, "Name", -1)),
475
+ t("div", wt, [
476
+ i(G, {
477
+ modelValue: e.value.name,
478
+ "onUpdate:modelValue": s[0] || (s[0] = (S) => e.value.name = S)
479
+ }, null, 8, ["modelValue"])
480
+ ])
481
+ ]),
482
+ t("div", ht, [
483
+ s[12] || (s[12] = t("div", { class: "w-[25%]" }, "Location", -1)),
484
+ i(X, {
485
+ modelValue: e.value.platform.locationIds,
486
+ "onUpdate:modelValue": s[1] || (s[1] = (S) => e.value.platform.locationIds = S),
487
+ multiselect: !0,
488
+ items: d.value,
489
+ placeholder: "Select location",
490
+ class: "flex-grow"
491
+ }, null, 8, ["modelValue", "items"])
492
+ ])
493
+ ]),
494
+ i(Fe, {
495
+ modelValue: e.value.platform,
496
+ "onUpdate:modelValue": s[2] || (s[2] = (S) => e.value.platform = S),
497
+ label: "upload",
498
+ "last-upload-date": (ee = e.value.platform) == null ? void 0 : ee.lastUploadDate
499
+ }, null, 8, ["modelValue", "last-upload-date"]),
500
+ t("div", Vt, [
501
+ s[20] || (s[20] = t("div", { class: "flex flex-row items-center fm-typo-en-title-sm-800 h-[36px]" }, "Mapping", -1)),
502
+ t("div", kt, [
503
+ s[14] || (s[14] = t("div", { class: "w-[25%]" }, "Contact", -1)),
504
+ t("div", $t, [
505
+ i(G, {
506
+ modelValue: e.value.platform.mappings.contact.xeroAccount,
507
+ "onUpdate:modelValue": s[3] || (s[3] = (S) => e.value.platform.mappings.contact.xeroAccount = S),
508
+ placeholder: "Contact account number"
509
+ }, null, 8, ["modelValue"])
510
+ ])
511
+ ]),
512
+ t("div", St, [
513
+ s[15] || (s[15] = t("div", { class: "w-[25%]" }, "Discount as Item", -1)),
514
+ t("div", Ct, [
515
+ i(R, {
516
+ "model-value": e.value.platform.discountItem ?? !1,
517
+ style: { gap: 0 },
518
+ "onUpdate:modelValue": s[4] || (s[4] = (S) => {
519
+ e.value.platform.discountItem = S;
520
+ })
521
+ }, null, 8, ["model-value"])
522
+ ])
523
+ ]),
524
+ t("div", Ft, [
525
+ s[16] || (s[16] = t("div", { class: "w-[25%]" }, "Combine Refund", -1)),
526
+ t("div", Dt, [
527
+ i(R, {
528
+ "model-value": e.value.platform.mappings.isCombineRefund ?? !1,
529
+ style: { gap: 0 },
530
+ "onUpdate:modelValue": s[5] || (s[5] = (S) => {
531
+ e.value.platform.mappings.isCombineRefund = S;
532
+ })
533
+ }, null, 8, ["model-value"])
534
+ ])
535
+ ]),
536
+ t("div", Ut, [
537
+ s[17] || (s[17] = t("div", { class: "fm-typo-en-title-sm-800" }, "Taxes", -1)),
538
+ i(N, {
539
+ variant: "primary",
540
+ icon: "add",
541
+ onClick: s[6] || (s[6] = () => l("taxes"))
542
+ })
543
+ ]),
544
+ t("div", Tt, [
545
+ (p(!0), U(z, null, q((ae = (oe = (te = e.value) == null ? void 0 : te.platform) == null ? void 0 : oe.mappings) == null ? void 0 : ae.taxes, (S, I) => (p(), A(De, {
546
+ key: `tax-${I}`,
547
+ modelValue: e.value.platform.mappings.taxes[I],
548
+ "onUpdate:modelValue": (O) => e.value.platform.mappings.taxes[I] = O,
549
+ options: {
550
+ feedmeKey: { placeholder: "Feedme Key", editable: !0 },
551
+ xeroAccount: {
552
+ placeholder: "Select Tax",
553
+ editable: !0,
554
+ dropdownOptions: x.taxOptions ?? []
555
+ }
556
+ },
557
+ removable: !0,
558
+ onRemove: () => F("taxes", I)
559
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"]))), 128))
560
+ ]),
561
+ t("div", It, [
562
+ s[18] || (s[18] = t("div", { class: "fm-typo-en-title-sm-800" }, "Items", -1)),
563
+ i(N, {
564
+ variant: "primary",
565
+ icon: "add",
566
+ onClick: s[7] || (s[7] = () => l("items"))
567
+ })
568
+ ]),
569
+ t("div", Mt, [
570
+ (p(!0), U(z, null, q((se = (ne = (le = e.value) == null ? void 0 : le.platform) == null ? void 0 : ne.mappings) == null ? void 0 : se.items, (S, I) => (p(), A(De, {
571
+ key: `item-${I}`,
572
+ modelValue: e.value.platform.mappings.items[I],
573
+ "onUpdate:modelValue": (O) => e.value.platform.mappings.items[I] = O,
574
+ options: {
575
+ feedmeKey: { placeholder: "Feedme Key", editable: !0 },
576
+ xeroAccount: {
577
+ placeholder: "Select Item Code",
578
+ editable: !0,
579
+ dropdownOptions: x.accountCodeOptions ?? []
580
+ }
581
+ },
582
+ removable: !0,
583
+ onRemove: () => F("items", I)
584
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"]))), 128))
585
+ ]),
586
+ t("div", Kt, [
587
+ s[19] || (s[19] = t("div", { class: "fm-typo-en-title-sm-800" }, "Payments", -1)),
588
+ i(N, {
589
+ variant: "primary",
590
+ icon: "add",
591
+ onClick: s[8] || (s[8] = () => l("payments"))
592
+ })
593
+ ]),
594
+ t("div", At, [
595
+ (p(!0), U(z, null, q((D = (y = (ie = e.value) == null ? void 0 : ie.platform) == null ? void 0 : y.mappings) == null ? void 0 : D.payments, (S, I) => (p(), A(De, {
596
+ key: `payment-${I}`,
597
+ modelValue: e.value.platform.mappings.payments[I],
598
+ "onUpdate:modelValue": (O) => e.value.platform.mappings.payments[I] = O,
599
+ options: {
600
+ feedmeKey: { placeholder: "Feedme Key", editable: !0 },
601
+ xeroAccount: {
602
+ placeholder: "Select Payment Code",
603
+ editable: !0,
604
+ dropdownOptions: x.accountCodeOptions ?? []
605
+ }
606
+ },
607
+ removable: !0,
608
+ onRemove: () => F("payments", I)
609
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"]))), 128))
610
+ ])
611
+ ])
612
+ ])
613
+ ])) : L("", !0);
614
+ };
615
+ }
616
+ }), Nt = { class: "h-full flex flex-col gap-16" }, Rt = { class: "flex flex-row gap-2 justify-between items-center" }, Bt = {
617
+ key: 0,
618
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
619
+ }, jt = /* @__PURE__ */ H({
620
+ __name: "Preview",
621
+ props: {
622
+ modelValue: { required: !0 },
623
+ modelModifiers: {}
624
+ },
625
+ emits: ["update:modelValue"],
626
+ setup(x) {
627
+ const o = B([]), e = Y(
628
+ () => o.value.reduce((r, d) => {
629
+ const k = r.length, { invoice: v, payments: g } = d;
630
+ r[k] = {
631
+ date: v.Date,
632
+ contact: v.Contact.ContactID,
633
+ status: v.Status,
634
+ ref: v.Reference
635
+ };
636
+ for (let u = 0; u < Math.max(v.LineItems.length, g.length); u++) {
637
+ const m = k + u;
638
+ r[m] || (r[m] = {}), v.LineItems[u] && (r[m] = {
639
+ ...r[m],
640
+ itemDescription: v.LineItems[u].Description,
641
+ itemQuantity: v.LineItems[u].Quantity,
642
+ itemUnitAmount: v.LineItems[u].UnitAmount,
643
+ // itemCode: invoice.LineItems[i].ItemCode,
644
+ itemAccount: v.LineItems[u].AccountCode,
645
+ itemTax: v.LineItems[u].TaxAmount,
646
+ itemTaxType: v.LineItems[u].TaxType,
647
+ itemAmount: v.LineItems[u].LineAmount,
648
+ itemDiscount: v.LineItems[u].DiscountAmount
649
+ }), g[u] && (r[m] = {
650
+ ...r[m],
651
+ paymentAccount: g[u].Account.Code,
652
+ paymentReference: g[u].Reference,
653
+ paymentAmount: g[u].Amount
654
+ });
655
+ }
656
+ return r;
657
+ }, [])
658
+ ), n = [
659
+ {
660
+ accessorKey: "date",
661
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
662
+ enableSorting: !1
663
+ },
664
+ {
665
+ accessorKey: "status",
666
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Status"),
667
+ enableSorting: !1
668
+ },
669
+ {
670
+ accessorKey: "ref",
671
+ header: "Reference",
672
+ enableSorting: !1
673
+ },
674
+ {
675
+ accessorKey: "itemDescription",
676
+ header: () => M("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
677
+ enableSorting: !1
678
+ },
679
+ {
680
+ accessorKey: "itemQuantity",
681
+ header: "Item Quantity",
682
+ enableSorting: !1
683
+ },
684
+ {
685
+ accessorKey: "itemUnitAmount",
686
+ header: "Item Unit Amount",
687
+ enableSorting: !1
688
+ },
689
+ // {
690
+ // accessorKey: "itemCode",
691
+ // header: "Item Code",
692
+ // enableSorting: false
693
+ // },
694
+ {
695
+ accessorKey: "itemAccount",
696
+ header: () => M("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
697
+ enableSorting: !1
698
+ },
699
+ {
700
+ accessorKey: "itemTaxType",
701
+ header: "Item Tax Type",
702
+ enableSorting: !1
703
+ },
704
+ {
705
+ accessorKey: "itemTax",
706
+ header: "Item Tax",
707
+ enableSorting: !1
708
+ },
709
+ {
710
+ accessorKey: "itemAmount",
711
+ header: "Item Amount",
712
+ enableSorting: !1
713
+ },
714
+ {
715
+ accessorKey: "itemDiscount",
716
+ header: "Item Discount",
717
+ enableSorting: !1
718
+ },
719
+ {
720
+ accessorKey: "paymentAccount",
721
+ header: "Payment Account",
722
+ enableSorting: !1
723
+ },
724
+ {
725
+ accessorKey: "paymentReference",
726
+ header: "Payment Reference",
727
+ enableSorting: !1
728
+ },
729
+ {
730
+ accessorKey: "paymentAmount",
731
+ header: "Payment Amount",
732
+ enableSorting: !1
733
+ }
734
+ ], h = Q(x, "modelValue"), _ = B(!1), w = pe(), { dateRange: C } = Se(ce());
735
+ fe(
736
+ () => C.value,
737
+ async () => {
738
+ if (h.value._id)
739
+ try {
740
+ _.value = !0, o.value = await ke(h.value._id);
741
+ } catch (r) {
742
+ w.open({ message: r.message, type: "error" });
743
+ } finally {
744
+ _.value = !1;
745
+ }
746
+ },
747
+ {
748
+ immediate: !0
749
+ }
750
+ );
751
+ async function V() {
752
+ try {
753
+ h.value._id ? (_.value = !0, await Te(h.value._id), w.open({ message: "Upload successful", type: "success" })) : w.open({ message: "Invalid accounting setting", type: "error" });
754
+ } catch (r) {
755
+ r.message && w.open({ message: r.message, type: "error" }), r.errors && r.errors.forEach((d) => w.open({ message: d.Message, type: "error" }));
756
+ } finally {
757
+ _.value = !1;
758
+ }
759
+ }
760
+ return (r, d) => {
761
+ const k = $("FmButton"), v = $("FmCircularProgress"), g = $("FmTable");
762
+ return p(), U("div", Nt, [
763
+ t("div", Rt, [
764
+ i(Ce, {
765
+ "date-range": f(C),
766
+ "onUpdate:dateRange": d[0] || (d[0] = (u) => _e(C) ? C.value = u : null),
767
+ compare: !1
768
+ }, null, 8, ["date-range"]),
769
+ i(k, {
770
+ loading: _.value,
771
+ variant: "primary",
772
+ label: "Upload",
773
+ onClick: V
774
+ }, null, 8, ["loading"])
775
+ ]),
776
+ _.value ? (p(), U("div", Bt, [
777
+ i(v, { size: "xl" }),
778
+ d[1] || (d[1] = t("span", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Loading data... ", -1))
779
+ ])) : e.value.length > 0 ? (p(), A(g, {
780
+ key: 1,
781
+ class: "flex overflow-scroll",
782
+ "row-data": e.value,
783
+ "column-defs": n
784
+ }, null, 8, ["row-data"])) : L("", !0)
785
+ ]);
786
+ };
787
+ }
788
+ }), Ot = { class: "h-full relative flex flex-col" }, Lt = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, zt = /* @__PURE__ */ H({
789
+ __name: "Xero",
790
+ props: {
791
+ modelValue: { required: !0 },
792
+ modelModifiers: {}
793
+ },
794
+ emits: ["update:modelValue"],
795
+ setup(x) {
796
+ const { t: o } = W(), e = Q(x, "modelValue"), n = B("setting"), h = B([]), _ = B([]), w = B([]), C = [
797
+ {
798
+ label: o("report.integration.setting"),
799
+ value: "setting",
800
+ icon: "settings"
801
+ },
802
+ {
803
+ label: o("report.integration.preview"),
804
+ value: "preview",
805
+ icon: "table"
806
+ }
807
+ ], V = me(), r = Y(() => {
808
+ switch (n.value) {
809
+ case "preview":
810
+ return { component: jt };
811
+ case "setting":
812
+ return {
813
+ component: Pt,
814
+ props: {
815
+ tenantOptions: h.value,
816
+ taxOptions: _.value,
817
+ accountCodeOptions: w.value
818
+ }
819
+ };
820
+ default:
821
+ return null;
822
+ }
823
+ });
824
+ async function d() {
825
+ e.value._id && (h.value = (await je(e.value._id)).map((g) => ({
826
+ value: g.id,
827
+ label: g.name
828
+ })));
829
+ }
830
+ async function k() {
831
+ e.value._id && (_.value = (await Oe(e.value._id)).map((g) => ({
832
+ value: g.Name,
833
+ label: `${g.Name} - (${g.EffectiveRate}%)`
834
+ })));
835
+ }
836
+ async function v() {
837
+ e.value._id && (w.value = (await Le(e.value._id)).map((g) => ({
838
+ value: g.Code,
839
+ label: `${g.Code} ${g.Name} - [${g.Class}_${g.Type}]`
840
+ })));
841
+ }
842
+ return fe(
843
+ () => {
844
+ var g;
845
+ return (g = e.value.platform) == null ? void 0 : g.accessToken;
846
+ },
847
+ (g) => {
848
+ g && (d(), k(), v());
849
+ },
850
+ { immediate: !0 }
851
+ ), (g, u) => {
852
+ var F, l, a;
853
+ const m = $("FmPageHead"), b = $("FmTabs");
854
+ return p(), U("div", Ot, [
855
+ i(m, {
856
+ title: ((F = e.value) == null ? void 0 : F.name) || "Xero",
857
+ "back-button": !0,
858
+ style: { paddingLeft: "0px", paddingRight: "0px" },
859
+ "onClick:back": f(V).back
860
+ }, {
861
+ description: ve(() => u[2] || (u[2] = [
862
+ t("div", null, null, -1)
863
+ ])),
864
+ _: 1
865
+ }, 8, ["title", "onClick:back"]),
866
+ i(b, {
867
+ "model-value": n.value,
868
+ "onUpdate:modelValue": u[0] || (u[0] = (c) => n.value = c),
869
+ items: C
870
+ }, null, 8, ["model-value"]),
871
+ t("div", Lt, [
872
+ (p(), A(ye((l = r.value) == null ? void 0 : l.component), Ae({
873
+ modelValue: e.value,
874
+ "onUpdate:modelValue": u[1] || (u[1] = (c) => e.value = c)
875
+ }, (a = r.value) == null ? void 0 : a.props), null, 16, ["modelValue"]))
876
+ ])
877
+ ]);
878
+ };
879
+ }
880
+ }), Et = {
881
+ key: 0,
882
+ class: "flex flex-col h-full"
883
+ }, Yt = { class: "flex flex-col gap-16 pb-[24px]" }, Ht = { class: "flex flex-row justify-between items-center gap-2" }, qt = { class: "fm-typo-en-title-sm-800" }, Qt = { class: "flex flex-row gap-2 items-center" }, Xt = { class: "relative group cursor-pointer" }, Gt = { class: "absolute left-1/2 -translate-x-2/3 top-full mt-2 w-max bg-gray-900 text-white text-sm px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity" }, Jt = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, Wt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Zt = { class: "flex flex-row items-center justify-between" }, eo = { class: "w-[25%]" }, to = { class: "flex-grow" }, oo = { class: "flex flex-row items-center justify-between" }, ao = { class: "w-[25%]" }, lo = { class: "flex-grow" }, no = { class: "flex flex-col gap-16" }, so = { class: "fm-typo-en-title-sm-800" }, io = { class: "flex flex-row items-center max-w-[100%]" }, ro = { class: "w-[25%]" }, mo = { class: "flex-grow" }, co = { class: "flex flex-row items-center max-w-[100%]" }, po = { class: "w-[25%]" }, uo = { class: "flex flex-row items-center max-w-[100%]" }, fo = { class: "w-[25%]" }, vo = { class: "flex flex-col gap-16" }, go = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, yo = { class: "flex flex-row items-center gap-x-16" }, xo = { class: "fm-typo-en-title-sm-800" }, _o = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, bo = { class: "flex flex-row items-center gap-x-16" }, wo = { class: "fm-typo-en-title-sm-800" }, ho = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Vo = { class: "flex flex-row items-center gap-x-16" }, ko = { class: "fm-typo-en-title-sm-800" }, $o = { class: "flex flex-row items-center" }, So = /* @__PURE__ */ H({
884
+ __name: "Setting",
885
+ props: {
886
+ modelValue: { required: !0 },
887
+ modelModifiers: {}
888
+ },
889
+ emits: ["update:modelValue"],
890
+ setup(x) {
891
+ const o = Q(x, "modelValue"), e = pe(), n = xe(), h = me(), { promptLoader: _ } = be(), { promptMessage: w } = $e(), { restaurants: C } = ce(), V = Y(
892
+ () => C.map((l) => ({ label: l.name, value: l.id }))
893
+ ), { t: r } = W();
894
+ async function d() {
895
+ await w({
896
+ message: r("report.messages.confirmDelete", { name: o.value.name }),
897
+ title: r("report.common.delete")
898
+ }) && await _(async () => {
899
+ try {
900
+ await we(o.value._id), await n.getSettings(), h.back();
901
+ } catch (a) {
902
+ e.open({ type: "error", message: a.message });
903
+ }
904
+ });
905
+ }
906
+ async function k() {
907
+ await _(async () => {
908
+ try {
909
+ await he(o.value._id, o.value), await n.getSettings();
910
+ } catch (l) {
911
+ e.open({ type: "error", message: l.message });
912
+ }
913
+ });
914
+ }
915
+ function v(l, a) {
916
+ var c, s;
917
+ (s = (c = o.value.platform) == null ? void 0 : c.mappings) != null && s[l] && (o.value.platform.mappings[l] = o.value.platform.mappings[l].filter(
918
+ (P, N) => N !== a
919
+ ));
920
+ }
921
+ function g(l) {
922
+ var a, c;
923
+ if ((c = (a = o.value.platform) == null ? void 0 : a.mappings) != null && c[l]) {
924
+ let s;
925
+ switch (l) {
926
+ case "items":
927
+ s = {
928
+ key: "",
929
+ account: "",
930
+ accountName: ""
931
+ };
932
+ break;
933
+ case "payments":
934
+ s = {
935
+ key: "",
936
+ account: "",
937
+ accountName: "",
938
+ method: ""
939
+ };
940
+ break;
941
+ default:
942
+ s = {
943
+ key: "",
944
+ account: ""
945
+ };
946
+ break;
947
+ }
948
+ o.value.platform.mappings[l] = [
949
+ ...o.value.platform.mappings[l],
950
+ s
951
+ ];
952
+ }
953
+ }
954
+ const u = [
955
+ {
956
+ label: r("report.integration.setting.grouping.byDay"),
957
+ value: ue.BY_DAY
958
+ },
959
+ {
960
+ label: r("report.integration.setting.grouping.byDayItem"),
961
+ value: ue.BY_DAY_ITEM
962
+ },
963
+ {
964
+ label: r("report.integration.setting.grouping.byInvoice"),
965
+ value: ue.BY_INVOICE
966
+ },
967
+ {
968
+ label: r("report.integration.setting.grouping.byDaySeparatePayment"),
969
+ value: ue.BY_DAY_SEPARATE_PAYMENT
970
+ }
971
+ ];
972
+ function m({
973
+ key: l,
974
+ value: a
975
+ }) {
976
+ var c, s;
977
+ (s = (c = o.value) == null ? void 0 : c.platform) != null && s.mappings && (o.value.platform.mappings[l] = a);
978
+ }
979
+ function b(l) {
980
+ return {
981
+ key: { placeholder: l, editable: !1 },
982
+ account: { placeholder: l, editable: !0 }
983
+ };
984
+ }
985
+ async function F() {
986
+ await _(async () => {
987
+ try {
988
+ await Ve(o.value._id), await n.getSettings();
989
+ } catch (l) {
990
+ e.open({ type: "error", message: l.message });
991
+ }
992
+ });
993
+ }
994
+ return (l, a) => {
995
+ var G, R, j, E, Z, ee, te, oe, ae, le, ne, se, ie, y, D;
996
+ const c = $("FmIcon"), s = $("FmButton"), P = $("FmMenuDivider"), N = $("FmTextField"), J = $("FmSelect"), X = $("FmCheckbox");
997
+ return (R = (G = o.value) == null ? void 0 : G.platform) != null && R.mappings ? (p(), U("div", Et, [
998
+ t("div", Yt, [
999
+ t("div", Ht, [
1000
+ t("div", qt, T(f(r)("report.integration.bukku.connect")), 1),
1001
+ t("div", Qt, [
1002
+ t("div", Xt, [
1003
+ i(c, {
1004
+ name: "refresh",
1005
+ class: "p-2 bg-gray-100 rounded-full",
1006
+ onClick: F
1007
+ }),
1008
+ t("span", Gt, T(f(r)("report.integration.setting.refreshTooltip")), 1)
1009
+ ]),
1010
+ i(s, {
1011
+ variant: "tertiary",
1012
+ label: f(r)("report.common.delete"),
1013
+ onClick: d
1014
+ }, null, 8, ["label"]),
1015
+ i(s, {
1016
+ variant: "primary",
1017
+ label: f(r)("report.common.update"),
1018
+ onClick: k
1019
+ }, null, 8, ["label"])
1020
+ ])
1021
+ ])
1022
+ ]),
1023
+ i(P, { style: { margin: 0 } }),
1024
+ t("div", Jt, [
1025
+ t("div", Wt, T(f(r)("report.integration.bukku.authentication")), 1),
1026
+ t("div", Zt, [
1027
+ t("div", eo, T(f(r)("report.integration.subdomain")), 1),
1028
+ t("div", to, [
1029
+ i(N, {
1030
+ modelValue: o.value.platform.subdomain,
1031
+ "onUpdate:modelValue": a[0] || (a[0] = (S) => o.value.platform.subdomain = S),
1032
+ placeholder: f(r)("report.integration.subdomain")
1033
+ }, null, 8, ["modelValue", "placeholder"])
1034
+ ])
1035
+ ]),
1036
+ t("div", oo, [
1037
+ t("div", ao, T(f(r)("report.integration.token")), 1),
1038
+ t("div", lo, [
1039
+ i(N, {
1040
+ modelValue: o.value.platform.token,
1041
+ "onUpdate:modelValue": a[1] || (a[1] = (S) => o.value.platform.token = S),
1042
+ placeholder: f(r)("report.integration.token")
1043
+ }, null, 8, ["modelValue", "placeholder"])
1044
+ ])
1045
+ ]),
1046
+ t("div", no, [
1047
+ t("div", so, T(f(r)("report.integration.bukku.general")), 1),
1048
+ t("div", io, [
1049
+ t("div", ro, T(f(r)("report.common.name")), 1),
1050
+ t("div", mo, [
1051
+ i(N, {
1052
+ modelValue: o.value.name,
1053
+ "onUpdate:modelValue": a[2] || (a[2] = (S) => o.value.name = S)
1054
+ }, null, 8, ["modelValue"])
1055
+ ])
1056
+ ]),
1057
+ t("div", co, [
1058
+ t("div", po, T(f(r)("report.common.location")), 1),
1059
+ i(J, {
1060
+ modelValue: o.value.platform.locationIds,
1061
+ "onUpdate:modelValue": a[3] || (a[3] = (S) => o.value.platform.locationIds = S),
1062
+ multiselect: !0,
1063
+ items: V.value,
1064
+ placeholder: "Select location",
1065
+ class: "flex-grow"
1066
+ }, null, 8, ["modelValue", "items"])
1067
+ ]),
1068
+ t("div", uo, [
1069
+ t("div", fo, T(f(r)("report.integration.bukku.grouping.title")), 1),
1070
+ i(J, {
1071
+ modelValue: o.value.platform.grouping,
1072
+ "onUpdate:modelValue": a[4] || (a[4] = (S) => o.value.platform.grouping = S),
1073
+ multiselect: !1,
1074
+ items: u,
1075
+ placeholder: "Select grouping",
1076
+ class: "flex-grow"
1077
+ }, null, 8, ["modelValue"])
1078
+ ])
1079
+ ]),
1080
+ t("div", vo, [
1081
+ t("div", go, [
1082
+ i(K, {
1083
+ "model-value": {
1084
+ key: "Contact",
1085
+ account: o.value.platform.mappings.contact.account
1086
+ },
1087
+ options: {
1088
+ key: {
1089
+ placeholder: "Contact",
1090
+ editable: !1
1091
+ },
1092
+ account: {
1093
+ placeholder: "Contact",
1094
+ editable: !0
1095
+ }
1096
+ },
1097
+ "onUpdate:modelValue": a[5] || (a[5] = (S) => {
1098
+ var I, O, de;
1099
+ (de = (O = (I = o.value) == null ? void 0 : I.platform) == null ? void 0 : O.mappings) != null && de.contact && (o.value.platform.mappings.contact.account = S.account);
1100
+ })
1101
+ }, null, 8, ["model-value"]),
1102
+ i(K, {
1103
+ "model-value": {
1104
+ key: "Invoice no",
1105
+ account: o.value.platform.mappings.invoiceDocNo
1106
+ },
1107
+ options: b("Invoice no"),
1108
+ "onUpdate:modelValue": a[6] || (a[6] = (S) => m({ key: "invoiceDocNo", value: S.account }))
1109
+ }, null, 8, ["model-value", "options"]),
1110
+ i(K, {
1111
+ "model-value": {
1112
+ key: "Credit note no",
1113
+ account: o.value.platform.mappings.creditNoteDocNo
1114
+ },
1115
+ options: b("Credit note no"),
1116
+ "onUpdate:modelValue": a[7] || (a[7] = (S) => m({ key: "creditNoteDocNo", value: S.account }))
1117
+ }, null, 8, ["model-value", "options"]),
1118
+ i(K, {
1119
+ "model-value": {
1120
+ key: "Payment no",
1121
+ account: o.value.platform.mappings.paymentDocNo
1122
+ },
1123
+ options: b("Payment no"),
1124
+ "onUpdate:modelValue": a[8] || (a[8] = (S) => m({ key: "paymentDocNo", value: S.account }))
1125
+ }, null, 8, ["model-value", "options"]),
1126
+ i(K, {
1127
+ "model-value": {
1128
+ key: "Refund no",
1129
+ account: o.value.platform.mappings.refundDocNo
1130
+ },
1131
+ options: b("Refund no"),
1132
+ "onUpdate:modelValue": a[9] || (a[9] = (S) => m({ key: "refundDocNo", value: S.account }))
1133
+ }, null, 8, ["model-value", "options"]),
1134
+ i(K, {
1135
+ "model-value": {
1136
+ key: "Rounding",
1137
+ account: o.value.platform.mappings.rounding.account
1138
+ },
1139
+ options: b("Rounding"),
1140
+ "onUpdate:modelValue": a[10] || (a[10] = (S) => {
1141
+ var I, O, de;
1142
+ (de = (O = (I = o.value) == null ? void 0 : I.platform) == null ? void 0 : O.mappings) != null && de.rounding && (o.value.platform.mappings.rounding.account = S.account);
1143
+ })
1144
+ }, null, 8, ["model-value", "options"]),
1145
+ (p(!0), U(z, null, q((Z = (E = (j = o.value) == null ? void 0 : j.platform) == null ? void 0 : E.mappings) == null ? void 0 : Z.charges, (S, I) => (p(), A(K, {
1146
+ key: `charge-${I}`,
1147
+ modelValue: o.value.platform.mappings.charges[I],
1148
+ "onUpdate:modelValue": (O) => o.value.platform.mappings.charges[I] = O,
1149
+ options: {
1150
+ key: {
1151
+ placeholder: f(r)(`report.integration.bukku.mapping.charge.${S.key}`),
1152
+ editable: !1
1153
+ },
1154
+ account: {
1155
+ placeholder: f(r)("report.integration.bukku.mapping.charge.account"),
1156
+ editable: !0
1157
+ }
1158
+ }
1159
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options"]))), 128))
1160
+ ])
1161
+ ]),
1162
+ i(Fe, {
1163
+ modelValue: o.value.platform,
1164
+ "onUpdate:modelValue": a[11] || (a[11] = (S) => o.value.platform = S),
1165
+ label: "upload",
1166
+ "last-upload-date": (ee = o.value.platform) == null ? void 0 : ee.lastUploadDate
1167
+ }, null, 8, ["modelValue", "last-upload-date"]),
1168
+ t("div", yo, [
1169
+ t("div", xo, T(f(r)("report.integration.items")), 1),
1170
+ i(s, {
1171
+ variant: "primary",
1172
+ icon: "add",
1173
+ onClick: a[12] || (a[12] = () => g("items"))
1174
+ })
1175
+ ]),
1176
+ t("div", _o, [
1177
+ (p(!0), U(z, null, q((ae = (oe = (te = o.value) == null ? void 0 : te.platform) == null ? void 0 : oe.mappings) == null ? void 0 : ae.items, (S, I) => (p(), A(K, {
1178
+ key: `item-${I}`,
1179
+ modelValue: o.value.platform.mappings.items[I],
1180
+ "onUpdate:modelValue": (O) => o.value.platform.mappings.items[I] = O,
1181
+ options: {
1182
+ key: { placeholder: "Key", editable: !0 },
1183
+ account: { placeholder: "Account code", editable: !0 },
1184
+ accountName: { placeholder: "Account name", editable: !0 }
1185
+ },
1186
+ removable: !0,
1187
+ onRemove: () => v("items", I)
1188
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1189
+ ]),
1190
+ t("div", bo, [
1191
+ t("div", wo, T(f(r)("report.integration.taxes")), 1),
1192
+ i(s, {
1193
+ variant: "primary",
1194
+ icon: "add",
1195
+ onClick: a[13] || (a[13] = () => g("taxes"))
1196
+ })
1197
+ ]),
1198
+ t("div", ho, [
1199
+ (p(!0), U(z, null, q((se = (ne = (le = o.value) == null ? void 0 : le.platform) == null ? void 0 : ne.mappings) == null ? void 0 : se.taxes, (S, I) => (p(), A(K, {
1200
+ key: `tax-${I}`,
1201
+ modelValue: o.value.platform.mappings.taxes[I],
1202
+ "onUpdate:modelValue": (O) => o.value.platform.mappings.taxes[I] = O,
1203
+ options: {
1204
+ key: { placeholder: "Key", editable: !0 },
1205
+ account: { placeholder: "Account code", editable: !0 }
1206
+ },
1207
+ removable: !0,
1208
+ onRemove: () => v("taxes", I)
1209
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1210
+ ]),
1211
+ t("div", Vo, [
1212
+ t("div", ko, T(f(r)("report.integration.payments")), 1),
1213
+ i(s, {
1214
+ variant: "primary",
1215
+ icon: "add",
1216
+ onClick: a[14] || (a[14] = () => g("payments"))
1217
+ })
1218
+ ]),
1219
+ (p(!0), U(z, null, q((D = (y = (ie = o.value) == null ? void 0 : ie.platform) == null ? void 0 : y.mappings) == null ? void 0 : D.payments, (S, I) => (p(), U("div", {
1220
+ key: `payment-${I}`,
1221
+ class: "grid-cols-1 grid gap-x-16"
1222
+ }, [
1223
+ t("div", $o, [
1224
+ i(X, {
1225
+ "model-value": !o.value.platform.mappings.payments[I].skip,
1226
+ value: "",
1227
+ "onUpdate:modelValue": (O) => {
1228
+ var de, Me;
1229
+ (Me = (de = o.value.platform) == null ? void 0 : de.mappings) != null && Me.payments[I] && (o.value.platform.mappings.payments[I].skip = !O);
1230
+ }
1231
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
1232
+ i(K, {
1233
+ modelValue: o.value.platform.mappings.payments[I],
1234
+ "onUpdate:modelValue": (O) => o.value.platform.mappings.payments[I] = O,
1235
+ options: {
1236
+ key: { placeholder: "Key", editable: !0 },
1237
+ method: { placeholder: "Method", editable: !0 },
1238
+ account: { placeholder: "Account code", editable: !0 }
1239
+ },
1240
+ removable: !0,
1241
+ onRemove: () => v("payments", I)
1242
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"])
1243
+ ])
1244
+ ]))), 128))
1245
+ ])
1246
+ ])) : L("", !0);
1247
+ };
1248
+ }
1249
+ }), Co = { class: "h-full flex flex-col gap-16" }, Fo = { class: "flex flex-row gap-2 justify-between items-center" }, Do = {
1250
+ key: 0,
1251
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
1252
+ }, Uo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, To = /* @__PURE__ */ H({
1253
+ __name: "Preview",
1254
+ props: {
1255
+ modelValue: { required: !0 },
1256
+ modelModifiers: {}
1257
+ },
1258
+ emits: ["update:modelValue"],
1259
+ setup(x) {
1260
+ const o = B([]), e = Y(
1261
+ () => o.value.reduce((d, k) => {
1262
+ const v = d.length, { invoice: g, payments: u } = k;
1263
+ d[v] = {
1264
+ no: g.number,
1265
+ date: g.date,
1266
+ contact: g._contact_name,
1267
+ status: g.status,
1268
+ title: g.title
1269
+ };
1270
+ for (let m = 0; m < Math.max(g.form_items.length, u.length); m++) {
1271
+ const b = v + m;
1272
+ d[b] || (d[b] = {});
1273
+ const F = g.form_items[m];
1274
+ F && (d[b] = {
1275
+ ...d[b],
1276
+ itemDescription: F.description,
1277
+ itemQuantity: F.quantity,
1278
+ itemUnitPrice: F.unit_price,
1279
+ itemAccount: F._account_name,
1280
+ itemTaxCode: F._tax_code_name,
1281
+ itemDiscount: F.discount
1282
+ });
1283
+ const l = u[m];
1284
+ l && (d[b] = {
1285
+ ...d[b],
1286
+ paymentNo: l.number,
1287
+ paymentMethod: l.deposit_items[0]._payment_method_name,
1288
+ paymentAccount: l.deposit_items[0]._account_name,
1289
+ paymentDescription: l.description,
1290
+ paymentAmount: l.amount,
1291
+ paymentSkip: l.skip
1292
+ });
1293
+ }
1294
+ return d;
1295
+ }, [])
1296
+ ), { t: n } = W(), h = [
1297
+ {
1298
+ accessorKey: "date",
1299
+ header: () => M(
1300
+ "p",
1301
+ { class: "min-w-[90px] text-nowrap text-ellipsis" },
1302
+ n("report.integration.preview.table.date")
1303
+ ),
1304
+ enableSorting: !1
1305
+ },
1306
+ {
1307
+ accessorKey: "no",
1308
+ header: () => M(
1309
+ "p",
1310
+ { class: "min-w-[90px] text-nowrap text-ellipsis" },
1311
+ n("report.integration.preview.table.no")
1312
+ ),
1313
+ enableSorting: !1
1314
+ },
1315
+ {
1316
+ accessorKey: "contact",
1317
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Contact"),
1318
+ enableSorting: !1
1319
+ },
1320
+ {
1321
+ accessorKey: "status",
1322
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Status"),
1323
+ enableSorting: !1
1324
+ },
1325
+ {
1326
+ accessorKey: "title",
1327
+ header: "Title",
1328
+ enableSorting: !1
1329
+ },
1330
+ {
1331
+ accessorKey: "itemDescription",
1332
+ header: () => M("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
1333
+ enableSorting: !1
1334
+ },
1335
+ {
1336
+ accessorKey: "itemQuantity",
1337
+ header: "Item Quantity",
1338
+ enableSorting: !1
1339
+ },
1340
+ {
1341
+ accessorKey: "itemUnitPrice",
1342
+ header: "Item Unit Price",
1343
+ enableSorting: !1
1344
+ },
1345
+ {
1346
+ accessorKey: "itemAccount",
1347
+ header: () => M("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
1348
+ enableSorting: !1
1349
+ },
1350
+ {
1351
+ accessorKey: "itemTaxCode",
1352
+ header: "Item Tax Code",
1353
+ enableSorting: !1
1354
+ },
1355
+ {
1356
+ accessorKey: "itemDiscount",
1357
+ header: "Item Discount",
1358
+ enableSorting: !1
1359
+ },
1360
+ {
1361
+ accessorKey: "paymentNo",
1362
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment No"),
1363
+ enableSorting: !1
1364
+ },
1365
+ {
1366
+ accessorKey: "paymentMethod",
1367
+ header: "Payment Method",
1368
+ enableSorting: !1
1369
+ },
1370
+ {
1371
+ accessorKey: "paymentAccount",
1372
+ header: "Payment Account",
1373
+ enableSorting: !1
1374
+ },
1375
+ {
1376
+ accessorKey: "paymentDescription",
1377
+ header: "Payment Description",
1378
+ enableSorting: !1
1379
+ },
1380
+ {
1381
+ accessorKey: "paymentAmount",
1382
+ header: "Payment Amount",
1383
+ enableSorting: !1
1384
+ },
1385
+ {
1386
+ accessorKey: "paymentSkip",
1387
+ header: "Skip",
1388
+ enableSorting: !1
1389
+ }
1390
+ ], _ = Q(x, "modelValue"), w = B(!1), C = pe(), { dateRange: V } = Se(ce());
1391
+ fe(
1392
+ () => V.value,
1393
+ async () => {
1394
+ if (_.value._id)
1395
+ try {
1396
+ w.value = !0, o.value = await ke(_.value._id);
1397
+ } catch (d) {
1398
+ C.open({ message: d.message, type: "error" });
1399
+ } finally {
1400
+ w.value = !1;
1401
+ }
1402
+ },
1403
+ {
1404
+ immediate: !0
1405
+ }
1406
+ );
1407
+ async function r() {
1408
+ try {
1409
+ _.value._id ? (w.value = !0, await Te(_.value._id), C.open({ message: n("report.integration.preview.uploadSuccess"), type: "success" })) : C.open({ message: n("report.integration.error.invalid"), type: "error" });
1410
+ } catch (d) {
1411
+ C.open({ message: d.message, type: "error" });
1412
+ } finally {
1413
+ w.value = !1;
1414
+ }
1415
+ }
1416
+ return (d, k) => {
1417
+ const v = $("FmButton"), g = $("FmCircularProgress"), u = $("FmTable");
1418
+ return p(), U("div", Co, [
1419
+ t("div", Fo, [
1420
+ i(Ce, {
1421
+ "date-range": f(V),
1422
+ "onUpdate:dateRange": k[0] || (k[0] = (m) => _e(V) ? V.value = m : null),
1423
+ compare: !1
1424
+ }, null, 8, ["date-range"]),
1425
+ i(v, {
1426
+ loading: w.value,
1427
+ variant: "primary",
1428
+ label: f(n)("report.common.upload"),
1429
+ onClick: r
1430
+ }, null, 8, ["loading", "label"])
1431
+ ]),
1432
+ w.value ? (p(), U("div", Do, [
1433
+ i(g, { size: "xl" }),
1434
+ t("span", Uo, T(f(n)("report.integration.preview.loading")), 1)
1435
+ ])) : e.value.length > 0 ? (p(), A(u, {
1436
+ key: 1,
1437
+ class: "flex overflow-scroll",
1438
+ "row-data": e.value,
1439
+ "column-defs": h
1440
+ }, null, 8, ["row-data"])) : L("", !0)
1441
+ ]);
1442
+ };
1443
+ }
1444
+ }), Io = { class: "h-full relative flex flex-col" }, Mo = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, Ko = /* @__PURE__ */ H({
1445
+ __name: "Bukku",
1446
+ props: {
1447
+ modelValue: {},
1448
+ modelModifiers: {}
1449
+ },
1450
+ emits: ["update:modelValue"],
1451
+ setup(x) {
1452
+ const { t: o } = W(), e = Q(x, "modelValue"), n = B("setting"), h = [
1453
+ {
1454
+ label: o("report.integration.setting"),
1455
+ value: "setting",
1456
+ icon: "settings"
1457
+ },
1458
+ {
1459
+ label: o("report.integration.preview"),
1460
+ value: "preview",
1461
+ icon: "table"
1462
+ }
1463
+ ], _ = me(), w = Y(() => {
1464
+ switch (n.value) {
1465
+ case "preview":
1466
+ return To;
1467
+ case "setting":
1468
+ return So;
1469
+ default:
1470
+ return null;
1471
+ }
1472
+ });
1473
+ return (C, V) => {
1474
+ var k;
1475
+ const r = $("FmPageHead"), d = $("FmTabs");
1476
+ return p(), U("div", Io, [
1477
+ i(r, {
1478
+ title: ((k = e.value) == null ? void 0 : k.name) || "Bukku",
1479
+ "back-button": !0,
1480
+ style: { paddingLeft: "0px", paddingRight: "0px" },
1481
+ "onClick:back": f(_).back
1482
+ }, {
1483
+ description: ve(() => V[2] || (V[2] = [
1484
+ t("div", null, null, -1)
1485
+ ])),
1486
+ _: 1
1487
+ }, 8, ["title", "onClick:back"]),
1488
+ i(d, {
1489
+ "model-value": n.value,
1490
+ "onUpdate:modelValue": V[0] || (V[0] = (v) => n.value = v),
1491
+ items: h
1492
+ }, null, 8, ["model-value"]),
1493
+ t("div", Mo, [
1494
+ (p(), A(ye(w.value), {
1495
+ modelValue: e.value,
1496
+ "onUpdate:modelValue": V[1] || (V[1] = (v) => e.value = v)
1497
+ }, null, 8, ["modelValue"]))
1498
+ ])
1499
+ ]);
1500
+ };
1501
+ }
1502
+ }), Ao = {
1503
+ key: 0,
1504
+ class: "flex flex-col h-full"
1505
+ }, Po = { class: "flex flex-col gap-16 pb-[24px]" }, No = { class: "flex flex-row justify-between items-center gap-2" }, Ro = { class: "flex flex-row gap-2 items-center" }, Bo = { class: "relative group cursor-pointer" }, jo = { class: "absolute left-1/2 -translate-x-2/3 top-full mt-2 w-max bg-gray-900 text-white text-sm px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity" }, Oo = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, Lo = { class: "flex flex-col gap-16" }, zo = { class: "fm-typo-en-title-sm-800" }, Eo = { class: "flex flex-row items-center max-w-[100%]" }, Yo = { class: "w-[25%]" }, Ho = { class: "flex-grow" }, qo = { class: "flex flex-row items-center max-w-[100%]" }, Qo = { class: "w-[25%]" }, Xo = { class: "flex flex-row items-center max-w-[100%]" }, Go = { class: "w-[25%]" }, Jo = { class: "flex flex-col gap-16" }, Wo = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Zo = { class: "flex flex-row items-center gap-x-16" }, ea = { class: "fm-typo-en-title-sm-800" }, ta = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, oa = { class: "flex flex-row items-center gap-x-16" }, aa = { class: "fm-typo-en-title-sm-800" }, la = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, na = { class: "flex flex-row items-center gap-x-16" }, sa = { class: "fm-typo-en-title-sm-800" }, ia = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, ra = /* @__PURE__ */ H({
1506
+ __name: "Setting",
1507
+ props: {
1508
+ modelValue: { required: !0 },
1509
+ modelModifiers: {}
1510
+ },
1511
+ emits: ["update:modelValue"],
1512
+ setup(x) {
1513
+ const { t: o } = W(), e = Q(x, "modelValue"), n = pe(), h = xe(), _ = me(), { promptLoader: w } = be(), { promptMessage: C } = $e(), { restaurants: V } = ce(), r = Y(
1514
+ () => V.map((l) => ({ label: l.name, value: l.id }))
1515
+ );
1516
+ async function d() {
1517
+ await C({
1518
+ message: o("report.messages.confirmDelete", { name: e.value.name }),
1519
+ title: o("report.common.delete")
1520
+ }) && await w(async () => {
1521
+ try {
1522
+ await we(e.value._id), await h.getSettings(), _.back();
1523
+ } catch (a) {
1524
+ n.open({ type: "error", message: a.message });
1525
+ }
1526
+ });
1527
+ }
1528
+ async function k() {
1529
+ await w(async () => {
1530
+ try {
1531
+ await he(e.value._id, e.value), await h.getSettings();
1532
+ } catch (l) {
1533
+ n.open({ type: "error", message: l.message });
1534
+ }
1535
+ });
1536
+ }
1537
+ function v(l, a) {
1538
+ var c, s;
1539
+ (s = (c = e.value.platform) == null ? void 0 : c.mappings) != null && s[l] && (e.value.platform.mappings[l] = e.value.platform.mappings[l].filter(
1540
+ (P, N) => N !== a
1541
+ ));
1542
+ }
1543
+ function g(l) {
1544
+ var a, c;
1545
+ (c = (a = e.value.platform) == null ? void 0 : a.mappings) != null && c[l] && (e.value.platform.mappings[l] = [
1546
+ ...e.value.platform.mappings[l],
1547
+ l === "items" ? {
1548
+ key: "",
1549
+ account: "",
1550
+ description: ""
1551
+ } : {
1552
+ key: "",
1553
+ account: ""
1554
+ }
1555
+ ]);
1556
+ }
1557
+ const u = [
1558
+ {
1559
+ label: "By day",
1560
+ value: ue.BY_DAY
1561
+ },
1562
+ {
1563
+ label: "By invoice",
1564
+ value: ue.BY_INVOICE
1565
+ },
1566
+ {
1567
+ label: "By day and category",
1568
+ value: ue.BY_DAY_CATEGORY
1569
+ }
1570
+ ];
1571
+ function m({
1572
+ key: l,
1573
+ value: a
1574
+ }) {
1575
+ var c, s;
1576
+ (s = (c = e.value) == null ? void 0 : c.platform) != null && s.mappings && (e.value.platform.mappings[l] = a);
1577
+ }
1578
+ function b(l) {
1579
+ return {
1580
+ key: { placeholder: l, editable: !1 },
1581
+ account: { placeholder: l, editable: !0 }
1582
+ };
1583
+ }
1584
+ async function F() {
1585
+ await w(async () => {
1586
+ try {
1587
+ await Ve(e.value._id), await h.getSettings();
1588
+ } catch (l) {
1589
+ n.open({ type: "error", message: l.message });
1590
+ }
1591
+ });
1592
+ }
1593
+ return (l, a) => {
1594
+ var X, G, R, j, E, Z, ee, te, oe, ae, le, ne, se, ie;
1595
+ const c = $("FmIcon"), s = $("FmButton"), P = $("FmMenuDivider"), N = $("FmTextField"), J = $("FmSelect");
1596
+ return (G = (X = e.value) == null ? void 0 : X.platform) != null && G.mappings ? (p(), U("div", Ao, [
1597
+ t("div", Po, [
1598
+ t("div", No, [
1599
+ a[14] || (a[14] = t("div", { class: "fm-typo-en-title-sm-800" }, null, -1)),
1600
+ t("div", Ro, [
1601
+ t("div", Bo, [
1602
+ i(c, {
1603
+ name: "refresh",
1604
+ class: "p-2 bg-gray-100 rounded-full",
1605
+ onClick: F
1606
+ }),
1607
+ t("span", jo, T(f(o)("report.integration.autoCount.repopulate")), 1)
1608
+ ]),
1609
+ i(s, {
1610
+ variant: "tertiary",
1611
+ label: f(o)("report.common.remove"),
1612
+ onClick: d
1613
+ }, null, 8, ["label"]),
1614
+ i(s, {
1615
+ variant: "primary",
1616
+ label: f(o)("report.common.update"),
1617
+ onClick: k
1618
+ }, null, 8, ["label"])
1619
+ ])
1620
+ ])
1621
+ ]),
1622
+ i(P, { style: { margin: 0 } }),
1623
+ t("div", Oo, [
1624
+ t("div", Lo, [
1625
+ t("div", zo, T(f(o)("report.integration.autocount.general")), 1),
1626
+ t("div", Eo, [
1627
+ t("div", Yo, T(f(o)("report.common.name")), 1),
1628
+ t("div", Ho, [
1629
+ i(N, {
1630
+ modelValue: e.value.name,
1631
+ "onUpdate:modelValue": a[0] || (a[0] = (y) => e.value.name = y)
1632
+ }, null, 8, ["modelValue"])
1633
+ ])
1634
+ ]),
1635
+ t("div", qo, [
1636
+ t("div", Qo, T(f(o)("report.integration.location")), 1),
1637
+ i(J, {
1638
+ modelValue: e.value.platform.locationIds,
1639
+ "onUpdate:modelValue": a[1] || (a[1] = (y) => e.value.platform.locationIds = y),
1640
+ multiselect: !0,
1641
+ items: r.value,
1642
+ placeholder: "Select location",
1643
+ class: "flex-grow",
1644
+ rules: [(y) => y.length !== 0 || "Please select at least 1 location"]
1645
+ }, null, 8, ["modelValue", "items", "rules"])
1646
+ ]),
1647
+ t("div", Xo, [
1648
+ t("div", Go, T(f(o)("report.integration.autoCount.grouping.title")), 1),
1649
+ i(J, {
1650
+ modelValue: e.value.platform.grouping,
1651
+ "onUpdate:modelValue": a[2] || (a[2] = (y) => e.value.platform.grouping = y),
1652
+ multiselect: !1,
1653
+ items: u,
1654
+ placeholder: "Select grouping",
1655
+ class: "flex-grow"
1656
+ }, null, 8, ["modelValue"])
1657
+ ])
1658
+ ]),
1659
+ t("div", Jo, [
1660
+ t("div", Wo, [
1661
+ i(K, {
1662
+ "model-value": { key: "Project", account: e.value.platform.mappings.project },
1663
+ options: b("Project"),
1664
+ "onUpdate:modelValue": a[3] || (a[3] = (y) => m({ key: "project", value: y.account }))
1665
+ }, null, 8, ["model-value", "options"]),
1666
+ i(K, {
1667
+ "model-value": { key: "Debtor", account: e.value.platform.mappings.debtor },
1668
+ options: b("Debtor"),
1669
+ "onUpdate:modelValue": a[4] || (a[4] = (y) => m({ key: "debtor", value: y.account }))
1670
+ }, null, 8, ["model-value", "options"]),
1671
+ i(K, {
1672
+ "model-value": {
1673
+ key: "Invoice no",
1674
+ account: e.value.platform.mappings.invoiceDocNo
1675
+ },
1676
+ options: b("Invoice no"),
1677
+ "onUpdate:modelValue": a[5] || (a[5] = (y) => m({ key: "invoiceDocNo", value: y.account }))
1678
+ }, null, 8, ["model-value", "options"]),
1679
+ i(K, {
1680
+ "model-value": {
1681
+ key: "Credit note no",
1682
+ account: e.value.platform.mappings.creditNoteDocNo
1683
+ },
1684
+ options: b("Credit note no"),
1685
+ "onUpdate:modelValue": a[6] || (a[6] = (y) => m({ key: "creditNoteDocNo", value: y.account }))
1686
+ }, null, 8, ["model-value", "options"]),
1687
+ i(K, {
1688
+ "model-value": {
1689
+ key: "Payment no",
1690
+ account: e.value.platform.mappings.paymentDocNo
1691
+ },
1692
+ options: b("Payment no"),
1693
+ "onUpdate:modelValue": a[7] || (a[7] = (y) => m({ key: "paymentDocNo", value: y.account }))
1694
+ }, null, 8, ["model-value", "options"]),
1695
+ i(K, {
1696
+ "model-value": {
1697
+ key: "Refund no",
1698
+ account: e.value.platform.mappings.refundDocNo
1699
+ },
1700
+ options: b("Refund no"),
1701
+ "onUpdate:modelValue": a[8] || (a[8] = (y) => m({ key: "refundDocNo", value: y.account }))
1702
+ }, null, 8, ["model-value", "options"]),
1703
+ i(K, {
1704
+ "model-value": {
1705
+ key: "Rounding",
1706
+ account: e.value.platform.mappings.rounding.account
1707
+ },
1708
+ options: b("Rounding"),
1709
+ "onUpdate:modelValue": a[9] || (a[9] = (y) => {
1710
+ var D, S, I;
1711
+ (I = (S = (D = e.value) == null ? void 0 : D.platform) == null ? void 0 : S.mappings) != null && I.rounding && (e.value.platform.mappings.rounding.account = y.account);
1712
+ })
1713
+ }, null, 8, ["model-value", "options"]),
1714
+ (p(!0), U(z, null, q((E = (j = (R = e.value) == null ? void 0 : R.platform) == null ? void 0 : j.mappings) == null ? void 0 : E.charges, (y, D) => (p(), A(K, {
1715
+ key: `charge-${D}`,
1716
+ modelValue: e.value.platform.mappings.charges[D],
1717
+ "onUpdate:modelValue": (S) => e.value.platform.mappings.charges[D] = S,
1718
+ options: {
1719
+ key: { placeholder: "Key", editable: !1 },
1720
+ account: { placeholder: "Account code", editable: !0 }
1721
+ }
1722
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]))), 128))
1723
+ ])
1724
+ ]),
1725
+ i(Fe, {
1726
+ modelValue: e.value.platform,
1727
+ "onUpdate:modelValue": a[10] || (a[10] = (y) => e.value.platform = y),
1728
+ label: f(o)("report.input.email")
1729
+ }, null, 8, ["modelValue", "label"]),
1730
+ t("div", Zo, [
1731
+ t("div", ea, T(f(o)("report.integration.items")), 1),
1732
+ i(s, {
1733
+ variant: "primary",
1734
+ icon: "add",
1735
+ onClick: a[11] || (a[11] = () => g("items"))
1736
+ })
1737
+ ]),
1738
+ t("div", ta, [
1739
+ (p(!0), U(z, null, q((te = (ee = (Z = e.value) == null ? void 0 : Z.platform) == null ? void 0 : ee.mappings) == null ? void 0 : te.items, (y, D) => (p(), A(K, {
1740
+ key: `item-${D}`,
1741
+ modelValue: e.value.platform.mappings.items[D],
1742
+ "onUpdate:modelValue": (S) => e.value.platform.mappings.items[D] = S,
1743
+ options: {
1744
+ key: { placeholder: "Key", editable: !0 },
1745
+ account: { placeholder: "Account code", editable: !0 }
1746
+ },
1747
+ removable: !0,
1748
+ onRemove: () => v("items", D)
1749
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1750
+ ]),
1751
+ t("div", oa, [
1752
+ t("div", aa, T(f(o)("report.integration.taxes")), 1),
1753
+ i(s, {
1754
+ variant: "primary",
1755
+ icon: "add",
1756
+ onClick: a[12] || (a[12] = () => g("taxes"))
1757
+ })
1758
+ ]),
1759
+ t("div", la, [
1760
+ (p(!0), U(z, null, q((le = (ae = (oe = e.value) == null ? void 0 : oe.platform) == null ? void 0 : ae.mappings) == null ? void 0 : le.taxes, (y, D) => (p(), A(K, {
1761
+ key: `tax-${D}`,
1762
+ modelValue: e.value.platform.mappings.taxes[D],
1763
+ "onUpdate:modelValue": (S) => e.value.platform.mappings.taxes[D] = S,
1764
+ options: {
1765
+ key: { placeholder: "Key", editable: !0 },
1766
+ account: { placeholder: "Account code", editable: !0 }
1767
+ },
1768
+ removable: !0,
1769
+ onRemove: () => v("taxes", D)
1770
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1771
+ ]),
1772
+ t("div", na, [
1773
+ t("div", sa, T(f(o)("report.integration.payments")), 1),
1774
+ i(s, {
1775
+ variant: "primary",
1776
+ icon: "add",
1777
+ onClick: a[13] || (a[13] = () => g("payments"))
1778
+ })
1779
+ ]),
1780
+ t("div", ia, [
1781
+ (p(!0), U(z, null, q((ie = (se = (ne = e.value) == null ? void 0 : ne.platform) == null ? void 0 : se.mappings) == null ? void 0 : ie.payments, (y, D) => (p(), A(K, {
1782
+ key: `payment-${D}`,
1783
+ modelValue: e.value.platform.mappings.payments[D],
1784
+ "onUpdate:modelValue": (S) => e.value.platform.mappings.payments[D] = S,
1785
+ options: {
1786
+ key: { placeholder: "Key", editable: !0 },
1787
+ account: { placeholder: "Payment name", editable: !0 }
1788
+ },
1789
+ removable: !0,
1790
+ onRemove: () => v("payments", D)
1791
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1792
+ ])
1793
+ ])
1794
+ ])) : L("", !0);
1795
+ };
1796
+ }
1797
+ }), ma = { class: "h-full flex flex-col gap-16" }, ca = { class: "flex flex-row gap-2 justify-between items-center" }, pa = {
1798
+ key: 0,
1799
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
1800
+ }, da = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ua = /* @__PURE__ */ H({
1801
+ __name: "Preview",
1802
+ props: {
1803
+ modelValue: { required: !0 },
1804
+ modelModifiers: {}
1805
+ },
1806
+ emits: ["update:modelValue"],
1807
+ setup(x) {
1808
+ const o = B([]), e = Y(
1809
+ () => o.value.reduce((r, d) => {
1810
+ const k = r.length, { invoice: v, payments: g } = d;
1811
+ r[k] = {
1812
+ date: v.DocDate,
1813
+ docNo: v.DocNo,
1814
+ projNo: v.ProjNo,
1815
+ debtor: v.DebtorCode,
1816
+ description: v.Description
1817
+ };
1818
+ for (let u = 0; u < Math.max(v._items.length, g.length); u++) {
1819
+ const m = k + u;
1820
+ r[m] || (r[m] = {}), v._items[u] && (r[m] = {
1821
+ ...r[m],
1822
+ itemDescription: v._items[u].DetailDescription,
1823
+ itemUnitPrice: v._items[u].Amount,
1824
+ itemAccount: v._items[u].AccNo,
1825
+ itemTaxCode: v._items[u].TaxType,
1826
+ itemTax: v._items[u].Tax
1827
+ }), g[u] && (r[m] = {
1828
+ ...r[m],
1829
+ paymentDocNo: g[u].DocNo,
1830
+ paymentMethod: g[u].paymentMethod,
1831
+ paymentDescription: g[u].Description,
1832
+ paymentAmount: g[u].PaymentAmt
1833
+ });
1834
+ }
1835
+ return r;
1836
+ }, [])
1837
+ ), n = [
1838
+ {
1839
+ accessorKey: "date",
1840
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
1841
+ enableSorting: !1
1842
+ },
1843
+ {
1844
+ accessorKey: "docNo",
1845
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Doc No"),
1846
+ enableSorting: !1
1847
+ },
1848
+ {
1849
+ accessorKey: "projNo",
1850
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Project"),
1851
+ enableSorting: !1
1852
+ },
1853
+ {
1854
+ accessorKey: "debtor",
1855
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Debtor"),
1856
+ enableSorting: !1
1857
+ },
1858
+ {
1859
+ accessorKey: "description",
1860
+ header: "Description",
1861
+ enableSorting: !1
1862
+ },
1863
+ {
1864
+ accessorKey: "itemAccount",
1865
+ header: () => M("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
1866
+ enableSorting: !1
1867
+ },
1868
+ {
1869
+ accessorKey: "itemTaxCode",
1870
+ header: "Item Tax Code",
1871
+ enableSorting: !1
1872
+ },
1873
+ {
1874
+ accessorKey: "itemDescription",
1875
+ header: () => M("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
1876
+ enableSorting: !1
1877
+ },
1878
+ {
1879
+ accessorKey: "itemUnitPrice",
1880
+ header: "Item Unit Price",
1881
+ enableSorting: !1
1882
+ },
1883
+ {
1884
+ accessorKey: "itemTax",
1885
+ header: "Item Tax",
1886
+ enableSorting: !1
1887
+ },
1888
+ {
1889
+ accessorKey: "paymentDocNo",
1890
+ header: "Payment Doc No",
1891
+ enableSorting: !1
1892
+ },
1893
+ {
1894
+ accessorKey: "paymentMethod",
1895
+ header: "Payment Method",
1896
+ enableSorting: !1
1897
+ },
1898
+ {
1899
+ accessorKey: "paymentDescription",
1900
+ header: "Payment Description",
1901
+ enableSorting: !1
1902
+ },
1903
+ {
1904
+ accessorKey: "paymentAmount",
1905
+ header: "Payment Amount",
1906
+ enableSorting: !1
1907
+ }
1908
+ ], h = Q(x, "modelValue"), _ = B(!1), w = pe(), { dateRange: C } = Se(ce());
1909
+ fe(
1910
+ () => C.value,
1911
+ async () => {
1912
+ if (h.value._id)
1913
+ try {
1914
+ _.value = !0, o.value = await ke(h.value._id);
1915
+ } catch (r) {
1916
+ w.open({ message: r.message, type: "error" });
1917
+ } finally {
1918
+ _.value = !1;
1919
+ }
1920
+ },
1921
+ {
1922
+ immediate: !0
1923
+ }
1924
+ );
1925
+ async function V() {
1926
+ try {
1927
+ h.value._id ? (_.value = !0, await Ie(h.value._id)) : w.open({ message: "Invalid accounting setting", type: "error" });
1928
+ } catch (r) {
1929
+ w.open({ message: r.message, type: "error" });
1930
+ } finally {
1931
+ _.value = !1;
1932
+ }
1933
+ }
1934
+ return (r, d) => {
1935
+ const k = $("FmButton"), v = $("FmCircularProgress"), g = $("FmTable");
1936
+ return p(), U("div", ma, [
1937
+ t("div", ca, [
1938
+ i(Ce, {
1939
+ "date-range": f(C),
1940
+ "onUpdate:dateRange": d[0] || (d[0] = (u) => _e(C) ? C.value = u : null),
1941
+ compare: !1
1942
+ }, null, 8, ["date-range"]),
1943
+ i(k, {
1944
+ loading: _.value,
1945
+ variant: "primary",
1946
+ label: r.t("report.common.download"),
1947
+ onClick: V
1948
+ }, null, 8, ["loading", "label"])
1949
+ ]),
1950
+ _.value ? (p(), U("div", pa, [
1951
+ i(v, { size: "xl" }),
1952
+ t("span", da, T(r.t("report.common.loading")), 1)
1953
+ ])) : e.value.length > 0 ? (p(), A(g, {
1954
+ key: 1,
1955
+ class: "flex overflow-scroll",
1956
+ "row-data": e.value,
1957
+ "column-defs": n
1958
+ }, null, 8, ["row-data"])) : L("", !0)
1959
+ ]);
1960
+ };
1961
+ }
1962
+ }), fa = { class: "h-full relative flex flex-col" }, va = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, ga = /* @__PURE__ */ H({
1963
+ __name: "AutoCount",
1964
+ props: {
1965
+ modelValue: {},
1966
+ modelModifiers: {}
1967
+ },
1968
+ emits: ["update:modelValue"],
1969
+ setup(x) {
1970
+ const { t: o } = W(), e = Q(x, "modelValue"), n = B("setting"), h = [
1971
+ {
1972
+ label: o("report.integration.setting"),
1973
+ value: "setting",
1974
+ icon: "settings"
1975
+ },
1976
+ {
1977
+ label: o("report.integration.preview"),
1978
+ value: "preview",
1979
+ icon: "table"
1980
+ }
1981
+ ], _ = me(), w = Y(() => {
1982
+ switch (n.value) {
1983
+ case "preview":
1984
+ return ua;
1985
+ case "setting":
1986
+ return ra;
1987
+ default:
1988
+ return null;
1989
+ }
1990
+ });
1991
+ return (C, V) => {
1992
+ var k;
1993
+ const r = $("FmPageHead"), d = $("FmTabs");
1994
+ return p(), U("div", fa, [
1995
+ i(r, {
1996
+ title: ((k = e.value) == null ? void 0 : k.name) || "AutoCount",
1997
+ "back-button": !0,
1998
+ style: { paddingLeft: "0px", paddingRight: "0px" },
1999
+ "onClick:back": f(_).back
2000
+ }, {
2001
+ description: ve(() => V[2] || (V[2] = [
2002
+ t("div", null, null, -1)
2003
+ ])),
2004
+ _: 1
2005
+ }, 8, ["title", "onClick:back"]),
2006
+ i(d, {
2007
+ "model-value": n.value,
2008
+ "onUpdate:modelValue": V[0] || (V[0] = (v) => n.value = v),
2009
+ items: h
2010
+ }, null, 8, ["model-value"]),
2011
+ t("div", va, [
2012
+ (p(), A(ye(w.value), {
2013
+ modelValue: e.value,
2014
+ "onUpdate:modelValue": V[1] || (V[1] = (v) => e.value = v)
2015
+ }, null, 8, ["modelValue"]))
2016
+ ])
2017
+ ]);
2018
+ };
2019
+ }
2020
+ }), ya = {
2021
+ key: 0,
2022
+ class: "flex flex-col h-full"
2023
+ }, xa = { class: "flex flex-col gap-16 pb-[24px]" }, _a = { class: "flex flex-row justify-between items-center gap-2" }, ba = { class: "flex flex-row gap-2 items-center" }, wa = { class: "relative group cursor-pointer" }, ha = { class: "absolute left-1/2 -translate-x-2/3 top-full mt-2 w-max bg-gray-900 text-white text-sm px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity" }, Va = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, ka = { class: "flex flex-col gap-16" }, $a = { class: "fm-typo-en-title-sm-800" }, Sa = { class: "flex flex-row items-center max-w-[100%]" }, Ca = { class: "w-[25%]" }, Fa = { class: "flex-grow" }, Da = { class: "flex flex-row items-center max-w-[100%]" }, Ua = { class: "w-[25%]" }, Ta = { class: "flex flex-row items-center max-w-[100%]" }, Ia = { class: "w-[25%]" }, Ma = { class: "flex flex-col gap-16" }, Ka = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Aa = { class: "grid-cols-1 grid gap-16" }, Pa = { class: "flex flex-row items-center gap-x-16" }, Na = { class: "fm-typo-en-title-sm-800" }, Ra = { class: "grid-cols-1 grid gap-16" }, Ba = { class: "flex flex-row items-center gap-x-16" }, ja = { class: "fm-typo-en-title-sm-800" }, Oa = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, La = { class: "flex flex-row items-center gap-x-16" }, za = { class: "fm-typo-en-title-sm-800" }, Ea = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Ya = /* @__PURE__ */ H({
2024
+ __name: "Setting",
2025
+ props: {
2026
+ modelValue: { required: !0 },
2027
+ modelModifiers: {}
2028
+ },
2029
+ emits: ["update:modelValue"],
2030
+ setup(x) {
2031
+ const { t: o } = W(), e = Q(x, "modelValue"), n = pe(), h = xe(), _ = me(), { promptLoader: w } = be(), { promptMessage: C } = $e(), { restaurants: V } = ce(), r = Y(
2032
+ () => V.map((l) => ({ label: l.name, value: l.id }))
2033
+ );
2034
+ async function d() {
2035
+ await C({
2036
+ message: o("report.messages.confirmDelete", { name: e.value.name }),
2037
+ title: o("report.common.delete")
2038
+ }) && await w(async () => {
2039
+ try {
2040
+ await we(e.value._id), await h.getSettings(), _.back();
2041
+ } catch (a) {
2042
+ n.open({ type: "error", message: a.message });
2043
+ }
2044
+ });
2045
+ }
2046
+ async function k() {
2047
+ await w(async () => {
2048
+ try {
2049
+ await he(e.value._id, e.value), await h.getSettings();
2050
+ } catch (l) {
2051
+ n.open({ type: "error", message: l.message });
2052
+ }
2053
+ });
2054
+ }
2055
+ function v(l, a) {
2056
+ var c, s;
2057
+ (s = (c = e.value.platform) == null ? void 0 : c.mappings) != null && s[l] && (e.value.platform.mappings[l] = e.value.platform.mappings[l].filter(
2058
+ (P, N) => N !== a
2059
+ ));
2060
+ }
2061
+ function g(l) {
2062
+ var a, c;
2063
+ (c = (a = e.value.platform) == null ? void 0 : a.mappings) != null && c[l] && (e.value.platform.mappings[l] = [
2064
+ ...e.value.platform.mappings[l],
2065
+ l === "items" ? {
2066
+ key: "",
2067
+ account: "",
2068
+ description: ""
2069
+ } : {
2070
+ key: "",
2071
+ account: "",
2072
+ description: ""
2073
+ }
2074
+ ]);
2075
+ }
2076
+ const u = [
2077
+ {
2078
+ label: "By day",
2079
+ value: ue.BY_DAY
2080
+ },
2081
+ {
2082
+ label: "By invoice",
2083
+ value: ue.BY_INVOICE
2084
+ },
2085
+ {
2086
+ label: "By day and category",
2087
+ value: ue.BY_DAY_CATEGORY
2088
+ }
2089
+ ];
2090
+ function m({
2091
+ key: l,
2092
+ value: a
2093
+ }) {
2094
+ var c, s;
2095
+ (s = (c = e.value) == null ? void 0 : c.platform) != null && s.mappings && (e.value.platform.mappings[l] = a);
2096
+ }
2097
+ function b(l) {
2098
+ return {
2099
+ key: { placeholder: l, editable: !1 },
2100
+ account: { placeholder: l, editable: !0 }
2101
+ };
2102
+ }
2103
+ async function F() {
2104
+ await w(async () => {
2105
+ try {
2106
+ await Ve(e.value._id), await h.getSettings();
2107
+ } catch (l) {
2108
+ n.open({ type: "error", message: l.message });
2109
+ }
2110
+ });
2111
+ }
2112
+ return (l, a) => {
2113
+ var X, G, R, j, E, Z, ee, te, oe, ae, le, ne, se, ie;
2114
+ const c = $("FmIcon"), s = $("FmButton"), P = $("FmMenuDivider"), N = $("FmTextField"), J = $("FmSelect");
2115
+ return (G = (X = e.value) == null ? void 0 : X.platform) != null && G.mappings ? (p(), U("div", ya, [
2116
+ t("div", xa, [
2117
+ t("div", _a, [
2118
+ a[15] || (a[15] = t("div", { class: "fm-typo-en-title-sm-800" }, null, -1)),
2119
+ t("div", ba, [
2120
+ t("div", wa, [
2121
+ i(c, {
2122
+ name: "refresh",
2123
+ class: "p-2 bg-gray-100 rounded-full",
2124
+ onClick: F
2125
+ }),
2126
+ t("span", ha, T(f(o)("report.integration.sql.refreshTooltip")), 1)
2127
+ ]),
2128
+ i(s, {
2129
+ variant: "tertiary",
2130
+ label: f(o)("report.action.delete"),
2131
+ onClick: d
2132
+ }, null, 8, ["label"]),
2133
+ i(s, {
2134
+ variant: "primary",
2135
+ label: f(o)("report.action.update"),
2136
+ onClick: k
2137
+ }, null, 8, ["label"])
2138
+ ])
2139
+ ])
2140
+ ]),
2141
+ i(P, { style: { margin: 0 } }),
2142
+ t("div", Va, [
2143
+ t("div", ka, [
2144
+ t("div", $a, T(f(o)("report.integration.sql.general")), 1),
2145
+ t("div", Sa, [
2146
+ t("div", Ca, T(f(o)("report.common.name")), 1),
2147
+ t("div", Fa, [
2148
+ i(N, {
2149
+ modelValue: e.value.name,
2150
+ "onUpdate:modelValue": a[0] || (a[0] = (y) => e.value.name = y)
2151
+ }, null, 8, ["modelValue"])
2152
+ ])
2153
+ ]),
2154
+ t("div", Da, [
2155
+ t("div", Ua, T(f(o)("report.integration.location")), 1),
2156
+ i(J, {
2157
+ modelValue: e.value.platform.locationIds,
2158
+ "onUpdate:modelValue": a[1] || (a[1] = (y) => e.value.platform.locationIds = y),
2159
+ multiselect: !0,
2160
+ items: r.value,
2161
+ placeholder: "Select location",
2162
+ class: "flex-grow",
2163
+ rules: [(y) => y.length !== 0 || "Please select at least 1 location"]
2164
+ }, null, 8, ["modelValue", "items", "rules"])
2165
+ ]),
2166
+ t("div", Ta, [
2167
+ t("div", Ia, T(f(o)("report.integration.grouping")), 1),
2168
+ i(J, {
2169
+ modelValue: e.value.platform.grouping,
2170
+ "onUpdate:modelValue": a[2] || (a[2] = (y) => e.value.platform.grouping = y),
2171
+ multiselect: !1,
2172
+ items: u,
2173
+ placeholder: "Select grouping",
2174
+ class: "flex-grow"
2175
+ }, null, 8, ["modelValue"])
2176
+ ])
2177
+ ]),
2178
+ t("div", Ma, [
2179
+ t("div", Ka, [
2180
+ i(K, {
2181
+ "model-value": { key: "Debtor", account: e.value.platform.mappings.debtor },
2182
+ options: b("Debtor"),
2183
+ "onUpdate:modelValue": a[3] || (a[3] = (y) => m({ key: "debtor", value: y.account }))
2184
+ }, null, 8, ["model-value", "options"]),
2185
+ i(K, {
2186
+ "model-value": {
2187
+ key: "Invoice no",
2188
+ account: e.value.platform.mappings.invoiceDocNo
2189
+ },
2190
+ options: b("Invoice no"),
2191
+ "onUpdate:modelValue": a[4] || (a[4] = (y) => m({ key: "invoiceDocNo", value: y.account }))
2192
+ }, null, 8, ["model-value", "options"]),
2193
+ i(K, {
2194
+ "model-value": {
2195
+ key: "Credit note no",
2196
+ account: e.value.platform.mappings.creditNoteDocNo
2197
+ },
2198
+ options: b("Credit note no"),
2199
+ "onUpdate:modelValue": a[5] || (a[5] = (y) => m({ key: "creditNoteDocNo", value: y.account }))
2200
+ }, null, 8, ["model-value", "options"]),
2201
+ i(K, {
2202
+ "model-value": {
2203
+ key: "Payment no",
2204
+ account: e.value.platform.mappings.paymentDocNo
2205
+ },
2206
+ options: b("Payment no"),
2207
+ "onUpdate:modelValue": a[6] || (a[6] = (y) => m({ key: "paymentDocNo", value: y.account }))
2208
+ }, null, 8, ["model-value", "options"]),
2209
+ i(K, {
2210
+ "model-value": {
2211
+ key: "Refund no",
2212
+ account: e.value.platform.mappings.refundDocNo
2213
+ },
2214
+ options: b("Refund no"),
2215
+ "onUpdate:modelValue": a[7] || (a[7] = (y) => m({ key: "refundDocNo", value: y.account }))
2216
+ }, null, 8, ["model-value", "options"]),
2217
+ i(K, {
2218
+ "model-value": {
2219
+ key: "Project header",
2220
+ account: e.value.platform.mappings.projectHeader
2221
+ },
2222
+ options: b("Project header"),
2223
+ "onUpdate:modelValue": a[8] || (a[8] = (y) => m({ key: "projectHeader", value: y.account }))
2224
+ }, null, 8, ["model-value", "options"]),
2225
+ i(K, {
2226
+ "model-value": {
2227
+ key: "Project detail",
2228
+ account: e.value.platform.mappings.projectDetail
2229
+ },
2230
+ options: b("Project detail"),
2231
+ "onUpdate:modelValue": a[9] || (a[9] = (y) => m({ key: "projectDetail", value: y.account }))
2232
+ }, null, 8, ["model-value", "options"])
2233
+ ]),
2234
+ t("div", Aa, [
2235
+ i(K, {
2236
+ "model-value": {
2237
+ key: "Rounding",
2238
+ account: e.value.platform.mappings.rounding.account,
2239
+ code: e.value.platform.mappings.rounding.code
2240
+ },
2241
+ options: {
2242
+ key: { placeholder: "Rounding", editable: !1 },
2243
+ account: { placeholder: "Account code", editable: !0 },
2244
+ code: { placeholder: "Item code", editable: !0 }
2245
+ },
2246
+ "onUpdate:modelValue": a[10] || (a[10] = (y) => {
2247
+ var D, S, I;
2248
+ (I = (S = (D = e.value) == null ? void 0 : D.platform) == null ? void 0 : S.mappings) != null && I.rounding && (e.value.platform.mappings.rounding.account = y.account, e.value.platform.mappings.rounding.code = y.code);
2249
+ })
2250
+ }, null, 8, ["model-value"]),
2251
+ (p(!0), U(z, null, q((E = (j = (R = e.value) == null ? void 0 : R.platform) == null ? void 0 : j.mappings) == null ? void 0 : E.charges, (y, D) => (p(), A(K, {
2252
+ key: `charge-${D}`,
2253
+ modelValue: e.value.platform.mappings.charges[D],
2254
+ "onUpdate:modelValue": (S) => e.value.platform.mappings.charges[D] = S,
2255
+ options: {
2256
+ key: { placeholder: "Key", editable: !1 },
2257
+ account: { placeholder: "Account code", editable: !0 },
2258
+ code: { placeholder: "Item code", editable: !0 }
2259
+ }
2260
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]))), 128))
2261
+ ])
2262
+ ]),
2263
+ i(Fe, {
2264
+ modelValue: e.value.platform,
2265
+ "onUpdate:modelValue": a[11] || (a[11] = (y) => e.value.platform = y),
2266
+ label: "email"
2267
+ }, null, 8, ["modelValue"]),
2268
+ t("div", Pa, [
2269
+ t("div", Na, T(f(o)("report.integration.items")), 1),
2270
+ i(s, {
2271
+ variant: "primary",
2272
+ label: f(o)("report.action.add"),
2273
+ onClick: a[12] || (a[12] = () => g("items"))
2274
+ }, null, 8, ["label"])
2275
+ ]),
2276
+ t("div", Ra, [
2277
+ (p(!0), U(z, null, q((te = (ee = (Z = e.value) == null ? void 0 : Z.platform) == null ? void 0 : ee.mappings) == null ? void 0 : te.items, (y, D) => (p(), A(K, {
2278
+ key: `item-${D}`,
2279
+ modelValue: e.value.platform.mappings.items[D],
2280
+ "onUpdate:modelValue": (S) => e.value.platform.mappings.items[D] = S,
2281
+ options: {
2282
+ key: { placeholder: "Key", editable: !0 },
2283
+ account: { placeholder: "Account code", editable: !0 },
2284
+ code: { placeholder: "Item code", editable: !0 }
2285
+ },
2286
+ removable: !0,
2287
+ onRemove: () => v("items", D)
2288
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2289
+ ]),
2290
+ t("div", Ba, [
2291
+ t("div", ja, T(f(o)("report.integration.taxes")), 1),
2292
+ i(s, {
2293
+ variant: "primary",
2294
+ icon: "add",
2295
+ onClick: a[13] || (a[13] = () => g("taxes"))
2296
+ })
2297
+ ]),
2298
+ t("div", Oa, [
2299
+ (p(!0), U(z, null, q((le = (ae = (oe = e.value) == null ? void 0 : oe.platform) == null ? void 0 : ae.mappings) == null ? void 0 : le.taxes, (y, D) => (p(), A(K, {
2300
+ key: `tax-${D}`,
2301
+ modelValue: e.value.platform.mappings.taxes[D],
2302
+ "onUpdate:modelValue": (S) => e.value.platform.mappings.taxes[D] = S,
2303
+ options: {
2304
+ key: { placeholder: "Key", editable: !0 },
2305
+ account: { placeholder: "Account code", editable: !0 }
2306
+ },
2307
+ removable: !0,
2308
+ onRemove: () => v("taxes", D)
2309
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2310
+ ]),
2311
+ t("div", La, [
2312
+ t("div", za, T(f(o)("report.integration.payments")), 1),
2313
+ i(s, {
2314
+ variant: "primary",
2315
+ icon: "add",
2316
+ onClick: a[14] || (a[14] = () => g("payments"))
2317
+ })
2318
+ ]),
2319
+ t("div", Ea, [
2320
+ (p(!0), U(z, null, q((ie = (se = (ne = e.value) == null ? void 0 : ne.platform) == null ? void 0 : se.mappings) == null ? void 0 : ie.payments, (y, D) => (p(), A(K, {
2321
+ key: `payment-${D}`,
2322
+ modelValue: e.value.platform.mappings.payments[D],
2323
+ "onUpdate:modelValue": (S) => e.value.platform.mappings.payments[D] = S,
2324
+ options: {
2325
+ key: { placeholder: "Key", editable: !0 },
2326
+ account: { placeholder: "Method", editable: !0 }
2327
+ },
2328
+ removable: !0,
2329
+ onRemove: () => v("payments", D)
2330
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2331
+ ])
2332
+ ])
2333
+ ])) : L("", !0);
2334
+ };
2335
+ }
2336
+ }), Ha = { class: "h-full flex flex-col gap-16" }, qa = { class: "flex flex-row gap-2 justify-between items-center" }, Qa = {
2337
+ key: 0,
2338
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
2339
+ }, Xa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ga = /* @__PURE__ */ H({
2340
+ __name: "Preview",
2341
+ props: {
2342
+ modelValue: { required: !0 },
2343
+ modelModifiers: {}
2344
+ },
2345
+ emits: ["update:modelValue"],
2346
+ setup(x) {
2347
+ const { t: o } = W(), e = B([]), n = Y(
2348
+ () => e.value.reduce((d, k) => {
2349
+ const v = d.length, { invoice: g, payments: u } = k;
2350
+ d[v] = {
2351
+ date: g.DocDate,
2352
+ docNo: g.DocNo,
2353
+ debtor: g.Code,
2354
+ description: g.Description_HDR
2355
+ };
2356
+ for (let m = 0; m < Math.max(g._items.length, u.length); m++) {
2357
+ const b = v + m;
2358
+ d[b] || (d[b] = {}), g._items[m] && (d[b] = {
2359
+ ...d[b],
2360
+ itemDescription: g._items[m].Description_DTL,
2361
+ itemUnitPrice: g._items[m].UnitPrice,
2362
+ itemAccount: g._items[m].ACCOUNT,
2363
+ itemTaxCode: g._items[m].Tax,
2364
+ itemTax: g._items[m].TaxAmt
2365
+ }), u[m] && (d[b] = {
2366
+ ...d[b],
2367
+ paymentDocNo: u[m].DOCNO_Header,
2368
+ paymentMethod: u[m].PAYMENTMETHOD,
2369
+ paymentAccount: u[m].CODE,
2370
+ paymentDescription: u[m].DESCRIPTION,
2371
+ paymentAmount: u[m].KOAMT
2372
+ });
2373
+ }
2374
+ return d;
2375
+ }, [])
2376
+ ), h = [
2377
+ {
2378
+ accessorKey: "date",
2379
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
2380
+ enableSorting: !1
2381
+ },
2382
+ {
2383
+ accessorKey: "docNo",
2384
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Doc No"),
2385
+ enableSorting: !1
2386
+ },
2387
+ {
2388
+ accessorKey: "debtor",
2389
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Debtor"),
2390
+ enableSorting: !1
2391
+ },
2392
+ {
2393
+ accessorKey: "description",
2394
+ header: "Description",
2395
+ enableSorting: !1
2396
+ },
2397
+ {
2398
+ accessorKey: "itemAccount",
2399
+ header: () => M("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
2400
+ enableSorting: !1
2401
+ },
2402
+ {
2403
+ accessorKey: "itemTaxCode",
2404
+ header: "Item Tax Code",
2405
+ enableSorting: !1
2406
+ },
2407
+ {
2408
+ accessorKey: "itemDescription",
2409
+ header: () => M("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
2410
+ enableSorting: !1
2411
+ },
2412
+ {
2413
+ accessorKey: "itemUnitPrice",
2414
+ header: "Item Unit Price",
2415
+ enableSorting: !1
2416
+ },
2417
+ {
2418
+ accessorKey: "itemTax",
2419
+ header: "Item Tax",
2420
+ enableSorting: !1
2421
+ },
2422
+ {
2423
+ accessorKey: "paymentDocNo",
2424
+ header: "Payment Doc No",
2425
+ enableSorting: !1
2426
+ },
2427
+ {
2428
+ accessorKey: "paymentMethod",
2429
+ header: "Payment Method",
2430
+ enableSorting: !1
2431
+ },
2432
+ {
2433
+ accessorKey: "paymentDescription",
2434
+ header: "Payment Description",
2435
+ enableSorting: !1
2436
+ },
2437
+ {
2438
+ accessorKey: "paymentAmount",
2439
+ header: "Payment Amount",
2440
+ enableSorting: !1
2441
+ }
2442
+ ], _ = Q(x, "modelValue"), w = B(!1), C = pe(), { dateRange: V } = Se(ce());
2443
+ fe(
2444
+ () => V.value,
2445
+ async () => {
2446
+ if (_.value._id)
2447
+ try {
2448
+ w.value = !0, e.value = await ke(_.value._id);
2449
+ } catch (d) {
2450
+ C.open({ message: d.message, type: "error" });
2451
+ } finally {
2452
+ w.value = !1;
2453
+ }
2454
+ },
2455
+ {
2456
+ immediate: !0
2457
+ }
2458
+ );
2459
+ async function r() {
2460
+ try {
2461
+ _.value._id ? (w.value = !0, await Ie(_.value._id)) : C.open({ message: "Invalid accounting setting", type: "error" });
2462
+ } catch (d) {
2463
+ C.open({ message: d.message, type: "error" });
2464
+ } finally {
2465
+ w.value = !1;
2466
+ }
2467
+ }
2468
+ return (d, k) => {
2469
+ const v = $("FmButton"), g = $("FmCircularProgress"), u = $("FmTable");
2470
+ return p(), U("div", Ha, [
2471
+ t("div", qa, [
2472
+ i(Ce, {
2473
+ "date-range": f(V),
2474
+ "onUpdate:dateRange": k[0] || (k[0] = (m) => _e(V) ? V.value = m : null),
2475
+ compare: !1
2476
+ }, null, 8, ["date-range"]),
2477
+ i(v, {
2478
+ loading: w.value,
2479
+ variant: "primary",
2480
+ label: f(o)("report.common.download"),
2481
+ onClick: r
2482
+ }, null, 8, ["loading", "label"])
2483
+ ]),
2484
+ w.value ? (p(), U("div", Qa, [
2485
+ i(g, { size: "xl" }),
2486
+ t("span", Xa, T(f(o)("report.common.loading")), 1)
2487
+ ])) : n.value.length > 0 ? (p(), A(u, {
2488
+ key: 1,
2489
+ class: "flex overflow-scroll",
2490
+ "row-data": n.value,
2491
+ "column-defs": h
2492
+ }, null, 8, ["row-data"])) : L("", !0)
2493
+ ]);
2494
+ };
2495
+ }
2496
+ }), Ja = { class: "h-full relative flex flex-col" }, Wa = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, Za = /* @__PURE__ */ H({
2497
+ __name: "SQL",
2498
+ props: {
2499
+ modelValue: {},
2500
+ modelModifiers: {}
2501
+ },
2502
+ emits: ["update:modelValue"],
2503
+ setup(x) {
2504
+ const { t: o } = W(), e = Q(x, "modelValue"), n = B("setting"), h = [
2505
+ {
2506
+ label: o("report.integration.setting"),
2507
+ value: "setting",
2508
+ icon: "settings"
2509
+ },
2510
+ {
2511
+ label: o("report.integration.preview"),
2512
+ value: "preview",
2513
+ icon: "table"
2514
+ }
2515
+ ], _ = me(), w = Y(() => {
2516
+ switch (n.value) {
2517
+ case "preview":
2518
+ return Ga;
2519
+ case "setting":
2520
+ return Ya;
2521
+ default:
2522
+ return null;
2523
+ }
2524
+ });
2525
+ return (C, V) => {
2526
+ var k;
2527
+ const r = $("FmPageHead"), d = $("FmTabs");
2528
+ return p(), U("div", Ja, [
2529
+ i(r, {
2530
+ title: ((k = e.value) == null ? void 0 : k.name) || "SQL",
2531
+ "back-button": !0,
2532
+ style: { paddingLeft: "0px", paddingRight: "0px" },
2533
+ "onClick:back": f(_).back
2534
+ }, {
2535
+ description: ve(() => V[2] || (V[2] = [
2536
+ t("div", null, null, -1)
2537
+ ])),
2538
+ _: 1
2539
+ }, 8, ["title", "onClick:back"]),
2540
+ i(d, {
2541
+ "model-value": n.value,
2542
+ "onUpdate:modelValue": V[0] || (V[0] = (v) => n.value = v),
2543
+ items: h
2544
+ }, null, 8, ["model-value"]),
2545
+ t("div", Wa, [
2546
+ (p(), A(ye(w.value), {
2547
+ modelValue: e.value,
2548
+ "onUpdate:modelValue": V[1] || (V[1] = (v) => e.value = v)
2549
+ }, null, 8, ["modelValue"]))
2550
+ ])
2551
+ ]);
2552
+ };
2553
+ }
2554
+ }), el = {
2555
+ key: 0,
2556
+ class: "flex flex-col h-full"
2557
+ }, tl = { class: "flex flex-col gap-16 pb-[24px]" }, ol = { class: "flex flex-row justify-between items-center gap-2" }, al = { class: "fm-typo-en-title-sm-800" }, ll = { class: "flex flex-row gap-2 items-center" }, nl = { class: "flex flex-row gap-2 items-center" }, sl = { class: "relative group cursor-pointer" }, il = { class: "absolute left-1/2 -translate-x-2/3 top-full mt-2 w-max bg-gray-900 text-white text-sm px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity" }, rl = { class: "flex flex-col gap-24 pt-[24px] overflow-y-auto overflow-x-hidden" }, ml = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, cl = { class: "flex flex-row items-center max-w-[100%]" }, pl = { class: "w-[25%]" }, dl = { class: "flex-grow" }, ul = { class: "flex flex-col gap-24 pt-[24px] overflow-y-auto overflow-x-hidden" }, fl = { class: "flex flex-row items-center justify-between" }, vl = { class: "w-[25%]" }, gl = { class: "flex-grow" }, yl = { class: "flex flex-row items-center justify-between" }, xl = { class: "w-[25%]" }, _l = { class: "flex-grow" }, bl = { class: "flex flex-col gap-16" }, wl = { class: "fm-typo-en-title-sm-800" }, hl = { class: "flex flex-row items-center max-w-[100%]" }, Vl = { class: "w-[25%]" }, kl = { class: "flex-grow" }, $l = { class: "flex flex-row items-center max-w-[100%]" }, Sl = { class: "w-[25%]" }, Cl = { class: "flex flex-row items-center max-w-[100%]" }, Fl = { class: "w-[25%]" }, Dl = {
2558
+ key: 0,
2559
+ class: "flex flex-row items-center max-w-[100%]"
2560
+ }, Ul = { class: "flex flex-col gap-16" }, Tl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Il = { class: "flex flex-row items-center gap-x-16" }, Ml = { class: "fm-typo-en-title-sm-800" }, Kl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Al = { class: "flex flex-row items-center gap-x-16" }, Pl = { class: "fm-typo-en-title-sm-800" }, Nl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Rl = { class: "flex flex-row items-center gap-x-16" }, Bl = { class: "fm-typo-en-title-sm-800" }, jl = { class: "flex flex-row items-center justify-between" }, Ol = { class: "flex-grow" }, Ll = {
2561
+ key: 0,
2562
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2563
+ }, zl = {
2564
+ key: 1,
2565
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2566
+ }, El = {
2567
+ key: 3,
2568
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2569
+ }, Yl = {
2570
+ key: 0,
2571
+ class: "flex flex-row items-center"
2572
+ }, Hl = /* @__PURE__ */ H({
2573
+ __name: "Setting",
2574
+ props: /* @__PURE__ */ ge({
2575
+ retrievedMethods: {
2576
+ type: Object,
2577
+ required: !0
2578
+ },
2579
+ retrievedCustomers: {
2580
+ type: Object,
2581
+ required: !0
2582
+ }
2583
+ }, {
2584
+ modelValue: { required: !0 },
2585
+ modelModifiers: {}
2586
+ }),
2587
+ emits: ["update:modelValue"],
2588
+ setup(x) {
2589
+ const { t: o } = W(), e = Q(x, "modelValue"), n = pe(), h = xe(), _ = me(), { promptLoader: w } = be(), { promptMessage: C } = $e(), { restaurants: V } = ce(), r = Y(
2590
+ () => V.map((F) => ({ label: F.name, value: F.id }))
2591
+ );
2592
+ function d(F) {
2593
+ var l;
2594
+ !((l = x.retrievedMethods) != null && l.data) || !Array.isArray(x.retrievedMethods.data) || F.forEach((a) => {
2595
+ const c = x.retrievedMethods.data.find((s) => s.value == a.id);
2596
+ c && (a.cnId = c.cnId);
2597
+ });
2598
+ }
2599
+ async function k() {
2600
+ await C({
2601
+ message: o("report.messages.confirmDelete", { name: e.value.name }),
2602
+ title: o("report.common.delete")
2603
+ }) && await w(async () => {
2604
+ try {
2605
+ await we(e.value._id), await h.getSettings(), _.back();
2606
+ } catch (l) {
2607
+ n.open({ type: "error", message: l.message });
2608
+ }
2609
+ });
2610
+ }
2611
+ async function v() {
2612
+ await w(async () => {
2613
+ var F, l, a;
2614
+ try {
2615
+ (a = (l = (F = e.value) == null ? void 0 : F.platform) == null ? void 0 : l.mappings) != null && a.paymentMethods && d(e.value.platform.mappings.paymentMethods), await he(e.value._id, e.value), await h.getSettings();
2616
+ } catch (c) {
2617
+ n.open({ type: "error", message: c.message });
2618
+ }
2619
+ });
2620
+ }
2621
+ function g(F, l) {
2622
+ var a, c;
2623
+ (c = (a = e.value.platform) == null ? void 0 : a.mappings) != null && c[F] && (e.value.platform.mappings[F] = e.value.platform.mappings[F].filter(
2624
+ (s, P) => P !== l
2625
+ ));
2626
+ }
2627
+ function u(F) {
2628
+ var l, a;
2629
+ (a = (l = e.value.platform) == null ? void 0 : l.mappings) != null && a[F] && (e.value.platform.mappings[F] = [
2630
+ ...e.value.platform.mappings[F],
2631
+ F === "items" ? {
2632
+ key: "",
2633
+ account: "",
2634
+ description: ""
2635
+ } : F === "taxes" ? {
2636
+ key: "",
2637
+ account: "SST-"
2638
+ } : {
2639
+ key: "",
2640
+ account: ""
2641
+ }
2642
+ ]);
2643
+ }
2644
+ const m = [
2645
+ {
2646
+ label: "By day",
2647
+ value: ue.BY_DAY
2648
+ }
2649
+ ];
2650
+ fe(
2651
+ () => {
2652
+ var F, l, a;
2653
+ return (a = (l = (F = e.value) == null ? void 0 : F.platform) == null ? void 0 : l.mappings) == null ? void 0 : a.taxes;
2654
+ },
2655
+ (F) => {
2656
+ F && F.forEach((l, a) => {
2657
+ var P;
2658
+ const c = l.key || "";
2659
+ let s = l.account;
2660
+ if (!s && c) {
2661
+ switch (c) {
2662
+ case "SST_SV":
2663
+ s = "SST-6";
2664
+ break;
2665
+ case "SST_SV8":
2666
+ s = "SST-8";
2667
+ break;
2668
+ case "SST_EX":
2669
+ s = "SST-0";
2670
+ break;
2671
+ }
2672
+ (P = e.value.platform) != null && P.mappings && (e.value.platform.mappings.taxes[a] = {
2673
+ ...l,
2674
+ account: s
2675
+ });
2676
+ }
2677
+ });
2678
+ },
2679
+ { immediate: !0, deep: !0 }
2680
+ ), fe(
2681
+ () => {
2682
+ var F, l, a;
2683
+ return (a = (l = (F = e.value) == null ? void 0 : F.platform) == null ? void 0 : l.mappings) == null ? void 0 : a.version;
2684
+ },
2685
+ (F) => {
2686
+ var l, a, c, s, P;
2687
+ F === "v1" && !((c = (a = (l = e.value) == null ? void 0 : l.platform) == null ? void 0 : a.mappings) != null && c.payee) && (P = (s = e.value) == null ? void 0 : s.platform) != null && P.mappings && (e.value.platform.mappings.payee = {
2688
+ id: 1,
2689
+ name: ""
2690
+ });
2691
+ },
2692
+ { immediate: !0 }
2693
+ );
2694
+ async function b() {
2695
+ await w(async () => {
2696
+ try {
2697
+ await Ve(e.value._id), await h.getSettings();
2698
+ } catch (F) {
2699
+ n.open({ type: "error", message: F.message });
2700
+ }
2701
+ });
2702
+ }
2703
+ return (F, l) => {
2704
+ var G, R, j, E, Z, ee, te, oe, ae, le, ne, se, ie;
2705
+ const a = $("FmIcon"), c = $("FmButton"), s = $("FmSelect"), P = $("FmMenuDivider"), N = $("FmTextField"), J = $("FmCircularProgress"), X = $("FmCheckbox");
2706
+ return (R = (G = e.value) == null ? void 0 : G.platform) != null && R.mappings ? (p(), U("div", el, [
2707
+ t("div", tl, [
2708
+ t("div", ol, [
2709
+ t("div", al, T(f(o)("report.integration.connect")), 1),
2710
+ t("div", ll, [
2711
+ t("div", nl, [
2712
+ t("div", sl, [
2713
+ i(a, {
2714
+ name: "refresh",
2715
+ class: "p-2 bg-gray-100 rounded-full",
2716
+ onClick: b
2717
+ }),
2718
+ t("span", il, T(f(o)("report.integration.biztory.refreshTooltip")), 1)
2719
+ ]),
2720
+ i(c, {
2721
+ variant: "tertiary",
2722
+ label: f(o)("report.common.delete"),
2723
+ onClick: k
2724
+ }, null, 8, ["label"]),
2725
+ i(c, {
2726
+ variant: "primary",
2727
+ label: f(o)("report.common.update"),
2728
+ onClick: v
2729
+ }, null, 8, ["label"])
2730
+ ])
2731
+ ])
2732
+ ])
2733
+ ]),
2734
+ t("div", rl, [
2735
+ t("div", ml, T(f(o)("report.integration.biztory.authenticate")), 1),
2736
+ t("div", cl, [
2737
+ t("div", pl, "Biztory " + T(f(o)("report.integration.biztory.version")), 1),
2738
+ t("div", dl, [
2739
+ i(s, {
2740
+ modelValue: e.value.platform.mappings.version,
2741
+ "onUpdate:modelValue": l[0] || (l[0] = (y) => e.value.platform.mappings.version = y),
2742
+ items: [
2743
+ { label: "v1", value: "v1" },
2744
+ { label: "v2", value: "v2" }
2745
+ ],
2746
+ placeholder: "Select Version"
2747
+ }, null, 8, ["modelValue"])
2748
+ ])
2749
+ ]),
2750
+ i(P, { style: { margin: 0 } }),
2751
+ t("div", ul, [
2752
+ t("div", fl, [
2753
+ t("div", vl, T(f(o)("report.integration.biztory.subdomain")), 1),
2754
+ t("div", gl, [
2755
+ i(N, {
2756
+ modelValue: e.value.platform.subdomain,
2757
+ "onUpdate:modelValue": l[1] || (l[1] = (y) => e.value.platform.subdomain = y),
2758
+ placeholder: "Subdomain"
2759
+ }, null, 8, ["modelValue"])
2760
+ ])
2761
+ ]),
2762
+ t("div", yl, [
2763
+ t("div", xl, T(f(o)("report.integration.biztory.apiKey")), 1),
2764
+ t("div", _l, [
2765
+ i(N, {
2766
+ modelValue: e.value.platform.api_key,
2767
+ "onUpdate:modelValue": l[2] || (l[2] = (y) => e.value.platform.api_key = y),
2768
+ placeholder: "API Key"
2769
+ }, null, 8, ["modelValue"])
2770
+ ])
2771
+ ]),
2772
+ t("div", bl, [
2773
+ t("div", wl, T(f(o)("report.integration.biztory.general")), 1),
2774
+ t("div", hl, [
2775
+ t("div", Vl, T(f(o)("report.common.name")), 1),
2776
+ t("div", kl, [
2777
+ i(N, {
2778
+ modelValue: e.value.name,
2779
+ "onUpdate:modelValue": l[3] || (l[3] = (y) => e.value.name = y)
2780
+ }, null, 8, ["modelValue"])
2781
+ ])
2782
+ ]),
2783
+ t("div", $l, [
2784
+ t("div", Sl, T(f(o)("report.integration.location")), 1),
2785
+ i(s, {
2786
+ modelValue: e.value.platform.locationIds,
2787
+ "onUpdate:modelValue": l[4] || (l[4] = (y) => e.value.platform.locationIds = y),
2788
+ multiselect: !0,
2789
+ items: r.value,
2790
+ placeholder: f(o)("report.integration.biztory.location"),
2791
+ class: "flex-grow"
2792
+ }, null, 8, ["modelValue", "items", "placeholder"])
2793
+ ]),
2794
+ t("div", Cl, [
2795
+ t("div", Fl, T(f(o)("report.integration.biztory.grouping")), 1),
2796
+ i(s, {
2797
+ modelValue: e.value.platform.grouping,
2798
+ "onUpdate:modelValue": l[5] || (l[5] = (y) => e.value.platform.grouping = y),
2799
+ multiselect: !1,
2800
+ items: m,
2801
+ placeholder: f(o)("report.integration.biztory.grouping"),
2802
+ class: "flex-grow",
2803
+ disabled: ""
2804
+ }, null, 8, ["modelValue", "placeholder"])
2805
+ ]),
2806
+ e.value.platform.mappings.version == "v1" ? (p(), U("div", Dl, [
2807
+ l[13] || (l[13] = t("div", { class: "w-[33%]" }, "Payee ID", -1)),
2808
+ e.value.platform.mappings.version == "v1" ? (p(), A(K, {
2809
+ key: 0,
2810
+ modelValue: e.value.platform.mappings.payee,
2811
+ "onUpdate:modelValue": l[6] || (l[6] = (y) => e.value.platform.mappings.payee = y),
2812
+ options: {
2813
+ id: { placeholder: "ID", editable: !0 }
2814
+ },
2815
+ removable: !1
2816
+ }, null, 8, ["modelValue"])) : L("", !0)
2817
+ ])) : L("", !0)
2818
+ ]),
2819
+ t("div", Ul, [
2820
+ t("div", Tl, [
2821
+ e.value.platform.mappings.version == "v2" ? (p(), A(De, {
2822
+ key: 0,
2823
+ modelValue: e.value.platform.mappings.payeeId,
2824
+ "onUpdate:modelValue": l[7] || (l[7] = (y) => e.value.platform.mappings.payeeId = y),
2825
+ options: {
2826
+ key: { placeholder: "Payee", editable: !1 },
2827
+ customer: {
2828
+ placeholder: "Select payee",
2829
+ editable: !0,
2830
+ dropdownOptions: ((j = x.retrievedCustomers) == null ? void 0 : j.data) ?? []
2831
+ }
2832
+ },
2833
+ removable: !1,
2834
+ "single-value-mode": ""
2835
+ }, null, 8, ["modelValue", "options"])) : L("", !0)
2836
+ ])
2837
+ ]),
2838
+ i(Fe, {
2839
+ modelValue: e.value.platform,
2840
+ "onUpdate:modelValue": l[8] || (l[8] = (y) => e.value.platform = y),
2841
+ label: "upload",
2842
+ "last-upload-date": (E = e.value.platform) == null ? void 0 : E.lastUploadDate
2843
+ }, null, 8, ["modelValue", "last-upload-date"]),
2844
+ t("div", Il, [
2845
+ t("div", Ml, T(f(o)("report.integration.biztory.items")), 1),
2846
+ i(c, {
2847
+ variant: "primary",
2848
+ icon: "add",
2849
+ onClick: l[9] || (l[9] = () => u("items"))
2850
+ })
2851
+ ]),
2852
+ t("div", Kl, [
2853
+ (p(!0), U(z, null, q((te = (ee = (Z = e.value) == null ? void 0 : Z.platform) == null ? void 0 : ee.mappings) == null ? void 0 : te.items, (y, D) => (p(), A(K, {
2854
+ key: `item-${D}`,
2855
+ modelValue: e.value.platform.mappings.items[D],
2856
+ "onUpdate:modelValue": (S) => e.value.platform.mappings.items[D] = S,
2857
+ options: {
2858
+ key: { placeholder: "Key", editable: !0 },
2859
+ code: { placeholder: "Account code", editable: !0 }
2860
+ },
2861
+ removable: !0,
2862
+ onRemove: () => g("items", D)
2863
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2864
+ ]),
2865
+ t("div", Al, [
2866
+ t("div", Pl, T(f(o)("report.integration.biztory.taxes")), 1),
2867
+ i(c, {
2868
+ variant: "primary",
2869
+ icon: "add",
2870
+ onClick: l[10] || (l[10] = () => u("taxes"))
2871
+ })
2872
+ ]),
2873
+ t("div", Nl, [
2874
+ (p(!0), U(z, null, q((le = (ae = (oe = e.value) == null ? void 0 : oe.platform) == null ? void 0 : ae.mappings) == null ? void 0 : le.taxes, (y, D) => (p(), A(K, {
2875
+ key: `tax-${D}`,
2876
+ modelValue: e.value.platform.mappings.taxes[D],
2877
+ "onUpdate:modelValue": (S) => e.value.platform.mappings.taxes[D] = S,
2878
+ options: {
2879
+ key: { placeholder: "Key", editable: !0 },
2880
+ account: { placeholder: "Account code", editable: !0 }
2881
+ },
2882
+ removable: !0,
2883
+ onRemove: () => g("taxes", D)
2884
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2885
+ ]),
2886
+ t("div", Rl, [
2887
+ t("div", Bl, T(f(o)("report.integration.biztory.payments")), 1),
2888
+ i(c, {
2889
+ variant: "primary",
2890
+ icon: "add",
2891
+ onClick: l[11] || (l[11] = () => u("paymentMethods"))
2892
+ })
2893
+ ]),
2894
+ t("div", jl, [
2895
+ l[14] || (l[14] = t("div", { class: "w-[25%]" }, "Payment Term", -1)),
2896
+ t("div", Ol, [
2897
+ i(K, {
2898
+ modelValue: e.value.platform.mappings.paymentTerm,
2899
+ "onUpdate:modelValue": l[12] || (l[12] = (y) => e.value.platform.mappings.paymentTerm = y),
2900
+ options: {
2901
+ id: { placeholder: "ID", editable: !0 },
2902
+ name: { placeholder: "Name", editable: !0 }
2903
+ },
2904
+ removable: !1
2905
+ }, null, 8, ["modelValue"])
2906
+ ])
2907
+ ]),
2908
+ x.retrievedMethods.isError ? L("", !0) : (p(), U("div", Ll, T(f(o)("report.integration.biztory.paymentTerm")), 1)),
2909
+ x.retrievedMethods.isLoaded && x.retrievedMethods.data && x.retrievedMethods.data.length == 0 && !x.retrievedMethods.isError ? (p(), U("span", zl, T(f(o)("report.integration.biztory.noPaymentMethods")), 1)) : L("", !0),
2910
+ x.retrievedMethods.isLoaded ? L("", !0) : (p(), A(J, {
2911
+ key: 2,
2912
+ size: "xl"
2913
+ })),
2914
+ x.retrievedMethods.isError ? (p(), U("span", El, T(f(o)("report.integration.biztory.error")), 1)) : L("", !0),
2915
+ (p(!0), U(z, null, q((ie = (se = (ne = e.value) == null ? void 0 : ne.platform) == null ? void 0 : se.mappings) == null ? void 0 : ie.paymentMethods, (y, D) => {
2916
+ var S;
2917
+ return p(), U("div", {
2918
+ key: `payment-${D}`,
2919
+ class: "grid-cols-1 grid gap-x-16"
2920
+ }, [
2921
+ x.retrievedMethods.isLoaded && x.retrievedMethods.data && ((S = x.retrievedMethods.data) == null ? void 0 : S.length) != 0 ? (p(), U("div", Yl, [
2922
+ i(X, {
2923
+ "model-value": !e.value.platform.mappings.paymentMethods[D].skip,
2924
+ value: "",
2925
+ "onUpdate:modelValue": (I) => {
2926
+ var O, de;
2927
+ (de = (O = e.value.platform) == null ? void 0 : O.mappings) != null && de.paymentMethods[D] && (e.value.platform.mappings.paymentMethods[D].skip = !I);
2928
+ }
2929
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2930
+ i(De, {
2931
+ modelValue: e.value.platform.mappings.paymentMethods[D],
2932
+ "onUpdate:modelValue": (I) => e.value.platform.mappings.paymentMethods[D] = I,
2933
+ options: {
2934
+ key: {
2935
+ placeholder: "Enter key",
2936
+ editable: !0
2937
+ },
2938
+ id: {
2939
+ placeholder: "Select mapping",
2940
+ editable: !0,
2941
+ dropdownOptions: x.retrievedMethods.data
2942
+ }
2943
+ },
2944
+ removable: !0,
2945
+ onRemove: () => g("paymentMethods", D)
2946
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"])
2947
+ ])) : L("", !0)
2948
+ ]);
2949
+ }), 128))
2950
+ ])
2951
+ ])
2952
+ ])) : L("", !0);
2953
+ };
2954
+ }
2955
+ });
2956
+ function ql(x) {
2957
+ return x.reduce((o, e) => {
2958
+ var _, w, C, V, r, d, k, v, g, u, m, b, F, l, a, c, s, P, N, J, X, G;
2959
+ const { invoice: n } = e, h = o.length;
2960
+ o[h] = {
2961
+ invoice_date: n.invoice_date,
2962
+ ref_num: n.ref_num,
2963
+ grandTotal: n.grandTotal,
2964
+ // tax_code: invoice.tax[0].tax_code,
2965
+ // tax: invoice.tax.reduce((sum, tax) => sum + tax.tax, 0),
2966
+ // service_charge: invoice.service_charge.total,
2967
+ item_code: (_ = n.items[0]) == null ? void 0 : _.code,
2968
+ item_desc: (w = n.items[0]) == null ? void 0 : w.description,
2969
+ item_price: (C = n.items[0]) == null ? void 0 : C.price,
2970
+ item_tax: (V = n.items[0]) == null ? void 0 : V.total_tax,
2971
+ item_tax_label: ((r = n.items[0]) == null ? void 0 : r.tax_label) || "-",
2972
+ payment_amount: ((k = (d = n.transactions) == null ? void 0 : d[0]) == null ? void 0 : k.amount) || void 0,
2973
+ payment_method: ((g = (v = n.transactions) == null ? void 0 : v[0]) == null ? void 0 : g.payment_method) || "-",
2974
+ payment_term: ((u = n == null ? void 0 : n.payment_term) == null ? void 0 : u.name) || ""
2975
+ };
2976
+ for (let R = 1; R < Math.max(((m = n.items) == null ? void 0 : m.length) || 0, ((b = n.transactions) == null ? void 0 : b.length) || 0); R++) {
2977
+ const j = h + R;
2978
+ o[j] || (o[j] = {});
2979
+ const E = n.items[R];
2980
+ E ? o[j] = {
2981
+ ...o[j],
2982
+ item_code: E.code,
2983
+ item_desc: E.description,
2984
+ item_price: E.price,
2985
+ item_tax: E.total_tax,
2986
+ item_tax_label: E.tax_label || "-",
2987
+ payment_amount: ((l = (F = n.transactions) == null ? void 0 : F[R]) == null ? void 0 : l.amount) || void 0,
2988
+ payment_method: ((c = (a = n.transactions) == null ? void 0 : a[R]) == null ? void 0 : c.payment_method) || "-",
2989
+ payment_term: ((s = n == null ? void 0 : n.payment_term) == null ? void 0 : s.name) || ""
2990
+ } : o[j] = {
2991
+ payment_amount: ((N = (P = n.transactions) == null ? void 0 : P[R]) == null ? void 0 : N.amount) || void 0,
2992
+ payment_method: ((X = (J = n.transactions) == null ? void 0 : J[R]) == null ? void 0 : X.payment_method) || "-",
2993
+ payment_term: ((G = n == null ? void 0 : n.payment_term) == null ? void 0 : G.name) || ""
2994
+ };
2995
+ }
2996
+ return o;
2997
+ }, []);
2998
+ }
2999
+ const Ql = [
3000
+ {
3001
+ accessorKey: "invoice_date",
3002
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
3003
+ enableSorting: !1
3004
+ },
3005
+ {
3006
+ accessorKey: "ref_num",
3007
+ header: () => M("p", { class: "min-w-[130px] text-nowrap text-ellipsis" }, "Doc No"),
3008
+ enableSorting: !1
3009
+ },
3010
+ {
3011
+ accessorKey: "grandTotal",
3012
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Total"),
3013
+ enableSorting: !1
3014
+ },
3015
+ // {
3016
+ // accessorKey: "tax_code",
3017
+ // header: () => h("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Tax Code"),
3018
+ // enableSorting: false
3019
+ // },
3020
+ // {
3021
+ // accessorKey: "tax",
3022
+ // header: () => h("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Tax"),
3023
+ // enableSorting: false
3024
+ // },
3025
+ // {
3026
+ // accessorKey: "service_charge",
3027
+ // header: () => h("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Service Charge"),
3028
+ // enableSorting: false
3029
+ // },
3030
+ {
3031
+ accessorKey: "item_code",
3032
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Code"),
3033
+ enableSorting: !1
3034
+ },
3035
+ {
3036
+ accessorKey: "item_desc",
3037
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Description"),
3038
+ enableSorting: !1
3039
+ },
3040
+ {
3041
+ accessorKey: "item_price",
3042
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Price"),
3043
+ enableSorting: !1
3044
+ },
3045
+ {
3046
+ accessorKey: "item_tax",
3047
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Tax"),
3048
+ enableSorting: !1
3049
+ },
3050
+ {
3051
+ accessorKey: "item_tax_label",
3052
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Tax Label"),
3053
+ enableSorting: !1
3054
+ },
3055
+ {
3056
+ accessorKey: "payment_amount",
3057
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Amount"),
3058
+ enableSorting: !1
3059
+ },
3060
+ {
3061
+ accessorKey: "payment_term",
3062
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Term"),
3063
+ enableSorting: !1
3064
+ },
3065
+ {
3066
+ accessorKey: "payment_method",
3067
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Method"),
3068
+ enableSorting: !1
3069
+ }
3070
+ ];
3071
+ function Xl(x) {
3072
+ return x.reduce((o, e) => {
3073
+ var w, C, V, r, d, k, v, g, u, m, b, F, l;
3074
+ const { invoice: n, payments: h } = e, _ = o.length;
3075
+ o[_] = {
3076
+ invoice_date: n.invoice_date,
3077
+ ref_num: n.ref_num,
3078
+ total: n.total,
3079
+ item_code: (w = n.items[0]) == null ? void 0 : w.code,
3080
+ item_description: (C = n.items[0]) == null ? void 0 : C.description,
3081
+ item_price: (V = n.items[0]) == null ? void 0 : V.price,
3082
+ item_tax_label: ((r = n.items[0]) == null ? void 0 : r.tax_label) ?? "-",
3083
+ item_tax_amount: ((d = n.items[0]) == null ? void 0 : d.total_tax) ?? "-",
3084
+ service_charge_amount: ((k = n.service_charges[0]) == null ? void 0 : k.total) ?? "-",
3085
+ rounding: n.rounding ?? 0,
3086
+ payment_term_id: n.payment_term.name ?? "-",
3087
+ payment_term_amount: ((v = n.terms[_]) == null ? void 0 : v.amount) ?? "-",
3088
+ payment_method: ((g = h[0]) == null ? void 0 : g.payment_method_name) || "-"
3089
+ };
3090
+ for (let a = 1; a < Math.max((u = n.items) == null ? void 0 : u.length, h == null ? void 0 : h.length); a++) {
3091
+ const c = _ + a;
3092
+ o[c] || (o[c] = {});
3093
+ const s = n.items[a];
3094
+ s ? o[c] = {
3095
+ ...o[c],
3096
+ item_code: s.code,
3097
+ item_description: s.description,
3098
+ item_price: s.total,
3099
+ item_tax_label: s.tax_label ?? "-",
3100
+ item_tax_amount: s.total_tax ?? "-",
3101
+ payment_term_id: n.payment_term.name ?? "-",
3102
+ payment_term_amount: ((m = n.terms[c]) == null ? void 0 : m.amount) ?? "-",
3103
+ payment_method: ((b = h[c]) == null ? void 0 : b.payment_method_name) || "-"
3104
+ } : o[c] = {
3105
+ payment_term_id: n.payment_term.name ?? "-",
3106
+ payment_term_amount: ((F = n.terms[c]) == null ? void 0 : F.amount) ?? "-",
3107
+ payment_method: ((l = h[c]) == null ? void 0 : l.payment_method_name) || "-"
3108
+ };
3109
+ }
3110
+ return o;
3111
+ }, []);
3112
+ }
3113
+ const Gl = [
3114
+ {
3115
+ accessorKey: "invoice_date",
3116
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
3117
+ enableSorting: !1
3118
+ },
3119
+ // {
3120
+ // accessorKey: "ref_num",
3121
+ // header: () => h("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Doc No"),
3122
+ // enableSorting: false
3123
+ // },
3124
+ {
3125
+ accessorKey: "total",
3126
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Total"),
3127
+ enableSorting: !1
3128
+ },
3129
+ {
3130
+ accessorKey: "item_code",
3131
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Code"),
3132
+ enableSorting: !1
3133
+ },
3134
+ {
3135
+ accessorKey: "item_description",
3136
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Description"),
3137
+ enableSorting: !1
3138
+ },
3139
+ {
3140
+ accessorKey: "item_price",
3141
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Price"),
3142
+ enableSorting: !1
3143
+ },
3144
+ {
3145
+ accessorKey: "item_tax_label",
3146
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Tax Label"),
3147
+ enableSorting: !1
3148
+ },
3149
+ {
3150
+ accessorKey: "item_tax_amount",
3151
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Tax Amount"),
3152
+ enableSorting: !1
3153
+ },
3154
+ {
3155
+ accessorKey: "service_charge_amount",
3156
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Service Charge Amount"),
3157
+ enableSorting: !1
3158
+ },
3159
+ {
3160
+ accessorKey: "rounding",
3161
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Rounding"),
3162
+ enableSorting: !1
3163
+ },
3164
+ {
3165
+ accessorKey: "payment_term_id",
3166
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Term"),
3167
+ enableSorting: !1
3168
+ },
3169
+ {
3170
+ accessorKey: "payment_term_amount",
3171
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Term Amount"),
3172
+ enableSorting: !1
3173
+ },
3174
+ {
3175
+ accessorKey: "payment_method",
3176
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Method (ID)"),
3177
+ enableSorting: !1
3178
+ }
3179
+ ], Jl = { class: "h-full flex flex-col gap-16" }, Wl = { class: "flex flex-row gap-2 justify-between items-center" }, Zl = {
3180
+ key: 0,
3181
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
3182
+ }, en = /* @__PURE__ */ H({
3183
+ __name: "Preview",
3184
+ props: {
3185
+ modelValue: { required: !0 },
3186
+ modelModifiers: {}
3187
+ },
3188
+ emits: ["update:modelValue"],
3189
+ setup(x) {
3190
+ const o = Q(x, "modelValue"), e = B(!1), n = pe(), { dateRange: h } = Se(ce()), _ = B([]);
3191
+ fe(
3192
+ () => h.value,
3193
+ async () => {
3194
+ if (o.value._id)
3195
+ try {
3196
+ e.value = !0, _.value = await ke(o.value._id);
3197
+ } catch (r) {
3198
+ n.open({ message: r.message, type: "error" });
3199
+ } finally {
3200
+ e.value = !1;
3201
+ }
3202
+ },
3203
+ {
3204
+ immediate: !0
3205
+ }
3206
+ );
3207
+ const w = Y(() => {
3208
+ switch (o.value.platform.mappings.version) {
3209
+ case "v1":
3210
+ return ql(_.value);
3211
+ case "v2":
3212
+ return Xl(_.value);
3213
+ }
3214
+ return [];
3215
+ }), C = Y(() => {
3216
+ switch (o.value.platform.mappings.version) {
3217
+ case "v1":
3218
+ return Ql;
3219
+ case "v2":
3220
+ return Gl;
3221
+ }
3222
+ return [];
3223
+ });
3224
+ async function V() {
3225
+ try {
3226
+ o.value._id && o.value.platform.subdomain && o.value.platform.api_key ? (e.value = !0, await Te(o.value._id), n.open({ message: "Upload successful", type: "success" })) : n.open({ message: "Invalid accounting setting", type: "error" });
3227
+ } catch (r) {
3228
+ r.message && n.open({ message: r.message, type: "error" }), r.errors && r.errors.forEach((d) => n.open({ message: d, type: "error" }));
3229
+ } finally {
3230
+ e.value = !1;
3231
+ }
3232
+ }
3233
+ return (r, d) => {
3234
+ const k = $("FmButton"), v = $("FmCircularProgress"), g = $("FmTable");
3235
+ return p(), U("div", Jl, [
3236
+ t("div", Wl, [
3237
+ i(Ce, {
3238
+ "date-range": f(h),
3239
+ "onUpdate:dateRange": d[0] || (d[0] = (u) => _e(h) ? h.value = u : null),
3240
+ compare: !1
3241
+ }, null, 8, ["date-range"]),
3242
+ i(k, {
3243
+ loading: e.value,
3244
+ variant: "primary",
3245
+ label: "Upload",
3246
+ onClick: V
3247
+ }, null, 8, ["loading"])
3248
+ ]),
3249
+ e.value ? (p(), U("div", Zl, [
3250
+ i(v, { size: "xl" }),
3251
+ d[1] || (d[1] = t("span", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Loading data... ", -1))
3252
+ ])) : (p(), A(g, {
3253
+ key: 1,
3254
+ class: "flex overflow-scroll",
3255
+ "row-data": w.value,
3256
+ "column-defs": C.value
3257
+ }, null, 8, ["row-data", "column-defs"]))
3258
+ ]);
3259
+ };
3260
+ }
3261
+ }), tn = { class: "h-full relative flex flex-col" }, on = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, an = /* @__PURE__ */ H({
3262
+ __name: "Biztory",
3263
+ props: {
3264
+ modelValue: { required: !0 },
3265
+ modelModifiers: {}
3266
+ },
3267
+ emits: ["update:modelValue"],
3268
+ setup(x) {
3269
+ const { t: o } = W(), e = Q(x, "modelValue"), n = B("setting"), h = [
3270
+ {
3271
+ label: o("report.integration.setting"),
3272
+ value: "setting",
3273
+ icon: "settings"
3274
+ },
3275
+ {
3276
+ label: o("report.integration.preview"),
3277
+ value: "preview",
3278
+ icon: "table"
3279
+ }
3280
+ ], _ = me(), w = Y(() => {
3281
+ switch (n.value) {
3282
+ case "preview":
3283
+ return {
3284
+ component: en
3285
+ };
3286
+ case "setting":
3287
+ return {
3288
+ component: Hl,
3289
+ props: {
3290
+ retrievedMethods: C.value,
3291
+ retrievedCustomers: V.value
3292
+ }
3293
+ };
3294
+ default:
3295
+ return null;
3296
+ }
3297
+ }), C = B({}), V = B({}), r = (u, m) => u.map((b) => ({
3298
+ label: m.length > 2 ? `ID:${b[m[2]]} [${b[m[0]]}] ${b[m[1]]}` : `[${b[m[0]]}] ${b[m[1]]}`,
3299
+ value: b.id,
3300
+ cnId: b.cnId ? b.cnId : null
3301
+ })), d = (u) => r(u, ["wallet", "name"]), k = (u) => r(u, ["id", "name"]), v = async (u, m, b, F) => {
3302
+ try {
3303
+ const l = await u(e.value._id);
3304
+ b.value.data = m(l);
3305
+ } catch (l) {
3306
+ console.error(F, l), b.value.isError = !0;
3307
+ } finally {
3308
+ b.value.isLoaded = !0;
3309
+ }
3310
+ }, g = async () => {
3311
+ var u, m;
3312
+ (u = e.value.platform.mappings) != null && u.version && await v(
3313
+ ze,
3314
+ d,
3315
+ C,
3316
+ "Failed to fetch payment methods:"
3317
+ ), ((m = e.value.platform.mappings) == null ? void 0 : m.version) == "v2" && await v(
3318
+ Ee,
3319
+ k,
3320
+ V,
3321
+ "Failed to fetch customers:"
3322
+ ), C.value.isLoaded = !0, V.value.isLoaded = !0;
3323
+ };
3324
+ return Pe(g), fe(() => {
3325
+ var u;
3326
+ return (u = e.value.platform.mappings) == null ? void 0 : u.version;
3327
+ }, g), (u, m) => {
3328
+ var l, a, c;
3329
+ const b = $("FmPageHead"), F = $("FmTabs");
3330
+ return p(), U("div", tn, [
3331
+ i(b, {
3332
+ title: ((l = e.value) == null ? void 0 : l.name) || "Biztory",
3333
+ "back-button": !0,
3334
+ style: { paddingLeft: "0px", paddingRight: "0px" },
3335
+ "onClick:back": f(_).back
3336
+ }, {
3337
+ description: ve(() => m[2] || (m[2] = [
3338
+ t("div", null, null, -1)
3339
+ ])),
3340
+ _: 1
3341
+ }, 8, ["title", "onClick:back"]),
3342
+ i(F, {
3343
+ "model-value": n.value,
3344
+ "onUpdate:modelValue": m[0] || (m[0] = (s) => n.value = s),
3345
+ items: h
3346
+ }, null, 8, ["model-value"]),
3347
+ t("div", on, [
3348
+ (p(), A(ye((a = w.value) == null ? void 0 : a.component), Ae({
3349
+ modelValue: e.value,
3350
+ "onUpdate:modelValue": m[1] || (m[1] = (s) => e.value = s)
3351
+ }, (c = w.value) == null ? void 0 : c.props), null, 16, ["modelValue"]))
3352
+ ])
3353
+ ]);
3354
+ };
3355
+ }
3356
+ }), ln = {
3357
+ key: 0,
3358
+ class: "flex flex-col h-full"
3359
+ }, nn = { class: "flex flex-col gap-16 pb-[24px]" }, sn = { class: "flex flex-row justify-between items-center gap-2" }, rn = { class: "flex flex-row gap-2 items-center" }, mn = { class: "relative group cursor-pointer" }, cn = { class: "absolute left-1/2 -translate-x-2/3 top-full mt-2 w-max bg-gray-900 text-white text-sm px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity" }, pn = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, dn = { class: "flex flex-col gap-16" }, un = { class: "fm-typo-en-title-sm-800" }, fn = { class: "flex flex-row items-center max-w-[100%]" }, vn = { class: "w-[25%]" }, gn = { class: "flex-grow" }, yn = { class: "flex flex-row items-center max-w-[100%]" }, xn = { class: "w-[25%]" }, _n = { class: "flex flex-row items-center gap-x-16" }, bn = { class: "fm-typo-en-title-sm-800" }, wn = { class: "grid-cols-1 grid gap-16" }, hn = /* @__PURE__ */ H({
3360
+ __name: "Setting",
3361
+ props: {
3362
+ modelValue: { required: !0 },
3363
+ modelModifiers: {}
3364
+ },
3365
+ emits: ["update:modelValue"],
3366
+ setup(x) {
3367
+ const { t: o } = W(), e = Q(x, "modelValue"), n = pe(), h = xe(), _ = me(), { promptLoader: w } = be(), { promptMessage: C } = $e(), { restaurants: V } = ce(), r = Y(
3368
+ () => V.map((m) => ({ label: m.name, value: m.id }))
3369
+ );
3370
+ async function d() {
3371
+ await C({
3372
+ message: o("report.messages.confirmDelete", { name: e.value.name }),
3373
+ title: o("report.common.delete")
3374
+ }) && await w(async () => {
3375
+ try {
3376
+ await we(e.value._id), await h.getSettings(), _.back();
3377
+ } catch (b) {
3378
+ n.open({ type: "error", message: b.message });
3379
+ }
3380
+ });
3381
+ }
3382
+ async function k() {
3383
+ await w(async () => {
3384
+ try {
3385
+ await he(e.value._id, e.value), await h.getSettings();
3386
+ } catch (m) {
3387
+ n.open({ type: "error", message: m.message });
3388
+ }
3389
+ });
3390
+ }
3391
+ function v(m, b) {
3392
+ var F, l;
3393
+ (l = (F = e.value.platform) == null ? void 0 : F.mappings) != null && l[m] && (e.value.platform.mappings[m] = e.value.platform.mappings[m].filter(
3394
+ (a, c) => c !== b
3395
+ ));
3396
+ }
3397
+ function g(m) {
3398
+ var b, F;
3399
+ (F = (b = e.value.platform) == null ? void 0 : b.mappings) != null && F[m] && (e.value.platform.mappings[m] = [
3400
+ ...e.value.platform.mappings[m],
3401
+ {
3402
+ key: "",
3403
+ name: "",
3404
+ badgeNo: "",
3405
+ employeeNo: ""
3406
+ }
3407
+ ]);
3408
+ }
3409
+ async function u() {
3410
+ await w(async () => {
3411
+ try {
3412
+ await Ve(e.value._id), await h.getSettings();
3413
+ } catch (m) {
3414
+ n.open({ type: "error", message: m.message });
3415
+ }
3416
+ });
3417
+ }
3418
+ return (m, b) => {
3419
+ var P, N, J, X, G;
3420
+ const F = $("FmIcon"), l = $("FmButton"), a = $("FmMenuDivider"), c = $("FmTextField"), s = $("FmSelect");
3421
+ return (N = (P = e.value) == null ? void 0 : P.platform) != null && N.mappings ? (p(), U("div", ln, [
3422
+ t("div", nn, [
3423
+ t("div", sn, [
3424
+ b[4] || (b[4] = t("div", { class: "fm-typo-en-title-sm-800" }, null, -1)),
3425
+ t("div", rn, [
3426
+ t("div", mn, [
3427
+ i(F, {
3428
+ name: "refresh",
3429
+ class: "p-2 bg-gray-100 rounded-full",
3430
+ onClick: u
3431
+ }),
3432
+ t("span", cn, T(f(o)("report.integration.iflexiHrms.refreshTooltip")), 1)
3433
+ ]),
3434
+ i(l, {
3435
+ variant: "tertiary",
3436
+ label: f(o)("report.action.delete"),
3437
+ onClick: d
3438
+ }, null, 8, ["label"]),
3439
+ i(l, {
3440
+ variant: "primary",
3441
+ label: f(o)("report.action.update"),
3442
+ onClick: k
3443
+ }, null, 8, ["label"])
3444
+ ])
3445
+ ])
3446
+ ]),
3447
+ i(a, { style: { margin: 0 } }),
3448
+ t("div", pn, [
3449
+ t("div", dn, [
3450
+ t("div", un, T(f(o)("report.integration.iflexiHrms.general")), 1),
3451
+ t("div", fn, [
3452
+ t("div", vn, T(f(o)("report.common.name")), 1),
3453
+ t("div", gn, [
3454
+ i(c, {
3455
+ modelValue: e.value.name,
3456
+ "onUpdate:modelValue": b[0] || (b[0] = (R) => e.value.name = R)
3457
+ }, null, 8, ["modelValue"])
3458
+ ])
3459
+ ]),
3460
+ t("div", yn, [
3461
+ t("div", xn, T(f(o)("report.integration.location")), 1),
3462
+ i(s, {
3463
+ "model-value": e.value.platform.locationIds[0],
3464
+ multiselect: !1,
3465
+ items: r.value,
3466
+ placeholder: "Select location",
3467
+ class: "flex-grow",
3468
+ "onUpdate:modelValue": b[1] || (b[1] = (R) => e.value.platform.locationIds[0] = R)
3469
+ }, null, 8, ["model-value", "items"])
3470
+ ])
3471
+ ]),
3472
+ i(Fe, {
3473
+ modelValue: e.value.platform,
3474
+ "onUpdate:modelValue": b[2] || (b[2] = (R) => e.value.platform = R),
3475
+ label: f(o)("report.input.email")
3476
+ }, null, 8, ["modelValue", "label"]),
3477
+ t("div", _n, [
3478
+ t("div", bn, T(f(o)("report.integration.iflexiHrms.employee")), 1),
3479
+ i(l, {
3480
+ variant: "primary",
3481
+ icon: "add",
3482
+ onClick: b[3] || (b[3] = () => g("employees"))
3483
+ })
3484
+ ]),
3485
+ t("div", wn, [
3486
+ (p(!0), U(z, null, q((G = (X = (J = e.value) == null ? void 0 : J.platform) == null ? void 0 : X.mappings) == null ? void 0 : G.employees, (R, j) => (p(), A(K, {
3487
+ key: `employee-${j}`,
3488
+ modelValue: e.value.platform.mappings.employees[j],
3489
+ "onUpdate:modelValue": (E) => e.value.platform.mappings.employees[j] = E,
3490
+ options: {
3491
+ key: { placeholder: "Name", editable: !0 },
3492
+ badgeNo: { placeholder: "Badge No", editable: !0 },
3493
+ employeeNo: { placeholder: "Employee No", editable: !0 }
3494
+ },
3495
+ removable: !0,
3496
+ onRemove: () => v("employees", j)
3497
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
3498
+ ])
3499
+ ])
3500
+ ])) : L("", !0);
3501
+ };
3502
+ }
3503
+ }), Vn = { class: "h-full flex flex-col gap-16" }, kn = { class: "flex flex-row gap-2 justify-between items-center" }, $n = {
3504
+ key: 0,
3505
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
3506
+ }, Sn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Cn = /* @__PURE__ */ H({
3507
+ __name: "Preview",
3508
+ props: {
3509
+ modelValue: { required: !0 },
3510
+ modelModifiers: {}
3511
+ },
3512
+ emits: ["update:modelValue"],
3513
+ setup(x) {
3514
+ const { t: o } = W(), e = B([]), n = [
3515
+ {
3516
+ accessorKey: "name",
3517
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Name"),
3518
+ enableSorting: !1
3519
+ },
3520
+ {
3521
+ accessorKey: "badgeNo",
3522
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Badge No"),
3523
+ enableSorting: !1
3524
+ },
3525
+ {
3526
+ accessorKey: "employeeNo",
3527
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Employee No"),
3528
+ enableSorting: !1
3529
+ },
3530
+ {
3531
+ accessorKey: "date",
3532
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
3533
+ enableSorting: !1
3534
+ },
3535
+ {
3536
+ accessorKey: "time",
3537
+ header: () => M("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Time"),
3538
+ enableSorting: !1
3539
+ }
3540
+ ], h = Q(x, "modelValue"), _ = B(!1), w = pe(), { dateRange: C } = Se(ce());
3541
+ fe(
3542
+ () => C.value,
3543
+ async () => {
3544
+ if (h.value._id)
3545
+ try {
3546
+ _.value = !0, e.value = await ke(h.value._id);
3547
+ } catch (r) {
3548
+ w.open({ message: r.message, type: "error" });
3549
+ } finally {
3550
+ _.value = !1;
3551
+ }
3552
+ },
3553
+ {
3554
+ immediate: !0
3555
+ }
3556
+ );
3557
+ async function V() {
3558
+ try {
3559
+ h.value._id ? (_.value = !0, await Ie(h.value._id)) : w.open({ message: "Invalid setting", type: "error" });
3560
+ } catch (r) {
3561
+ w.open({ message: r.message, type: "error" });
3562
+ } finally {
3563
+ _.value = !1;
3564
+ }
3565
+ }
3566
+ return (r, d) => {
3567
+ const k = $("FmButton"), v = $("FmCircularProgress"), g = $("FmTable");
3568
+ return p(), U("div", Vn, [
3569
+ t("div", kn, [
3570
+ i(Ce, {
3571
+ "date-range": f(C),
3572
+ "onUpdate:dateRange": d[0] || (d[0] = (u) => _e(C) ? C.value = u : null),
3573
+ compare: !1
3574
+ }, null, 8, ["date-range"]),
3575
+ i(k, {
3576
+ loading: _.value,
3577
+ variant: "primary",
3578
+ label: f(o)("report.common.download"),
3579
+ onClick: V
3580
+ }, null, 8, ["loading", "label"])
3581
+ ]),
3582
+ _.value ? (p(), U("div", $n, [
3583
+ i(v, { size: "xl" }),
3584
+ t("span", Sn, T(f(o)("report.common.loading")), 1)
3585
+ ])) : e.value.length > 0 ? (p(), A(g, {
3586
+ key: 1,
3587
+ class: "flex overflow-scroll",
3588
+ "row-data": e.value,
3589
+ "column-defs": n
3590
+ }, null, 8, ["row-data"])) : L("", !0)
3591
+ ]);
3592
+ };
3593
+ }
3594
+ }), Fn = { class: "h-full relative flex flex-col" }, Dn = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, Un = /* @__PURE__ */ H({
3595
+ __name: "IFlexiHRMS",
3596
+ props: {
3597
+ modelValue: {},
3598
+ modelModifiers: {}
3599
+ },
3600
+ emits: ["update:modelValue"],
3601
+ setup(x) {
3602
+ const { t: o } = W(), e = Q(x, "modelValue"), n = B("setting"), h = [
3603
+ {
3604
+ label: o("report.integration.setting"),
3605
+ value: "setting",
3606
+ icon: "settings"
3607
+ },
3608
+ {
3609
+ label: o("report.integration.preview"),
3610
+ value: "preview",
3611
+ icon: "table"
3612
+ }
3613
+ ], _ = me(), w = Y(() => {
3614
+ switch (n.value) {
3615
+ case "preview":
3616
+ return Cn;
3617
+ case "setting":
3618
+ return hn;
3619
+ default:
3620
+ return null;
3621
+ }
3622
+ });
3623
+ return (C, V) => {
3624
+ var k;
3625
+ const r = $("FmPageHead"), d = $("FmTabs");
3626
+ return p(), U("div", Fn, [
3627
+ i(r, {
3628
+ title: ((k = e.value) == null ? void 0 : k.name) || "AutoCount",
3629
+ "back-button": !0,
3630
+ style: { paddingLeft: "0px", paddingRight: "0px" },
3631
+ "onClick:back": f(_).back
3632
+ }, {
3633
+ description: ve(() => V[2] || (V[2] = [
3634
+ t("div", null, null, -1)
3635
+ ])),
3636
+ _: 1
3637
+ }, 8, ["title", "onClick:back"]),
3638
+ i(d, {
3639
+ "model-value": n.value,
3640
+ "onUpdate:modelValue": V[0] || (V[0] = (v) => n.value = v),
3641
+ items: h
3642
+ }, null, 8, ["model-value"]),
3643
+ t("div", Dn, [
3644
+ (p(), A(ye(w.value), {
3645
+ modelValue: e.value,
3646
+ "onUpdate:modelValue": V[1] || (V[1] = (v) => e.value = v)
3647
+ }, null, 8, ["modelValue"]))
3648
+ ])
3649
+ ]);
3650
+ };
3651
+ }
3652
+ }), Tn = { class: "px-24 h-full relative" }, jn = /* @__PURE__ */ H({
3653
+ __name: "Integration",
3654
+ setup(x) {
3655
+ const o = B(void 0), { params: e } = Ne(), n = xe(), h = B();
3656
+ Pe(async () => {
3657
+ n.settings.length === 0 && await n.getSettings();
3658
+ }), fe(
3659
+ () => n.settings,
3660
+ (w) => {
3661
+ var V;
3662
+ const C = w.find((r) => r._id === e.id);
3663
+ C && (h.value = C, o.value = (V = h.value.platform) == null ? void 0 : V.name);
3664
+ },
3665
+ { immediate: !0 }
3666
+ );
3667
+ const _ = Y(() => {
3668
+ switch (o.value) {
3669
+ case re.Xero:
3670
+ return zt;
3671
+ case re.Bukku:
3672
+ return Ko;
3673
+ case re.AutoCount:
3674
+ return ga;
3675
+ case re.SQL:
3676
+ return Za;
3677
+ case re.iFlexi_HRMS:
3678
+ return Un;
3679
+ case re.Biztory:
3680
+ return an;
3681
+ default:
3682
+ return null;
3683
+ }
3684
+ });
3685
+ return (w, C) => (p(), U("div", Tn, [
3686
+ (p(), A(ye(_.value), {
3687
+ modelValue: h.value,
3688
+ "onUpdate:modelValue": C[0] || (C[0] = (V) => h.value = V)
3689
+ }, null, 8, ["modelValue"]))
3690
+ ]));
3691
+ }
3692
+ });
3693
+ export {
3694
+ jn as default
3695
+ };