@feedmepos/mf-report 5.8.1 → 5.8.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/{App-bVkQiecI.js → App-CVBF-RIq.js} +25 -25
  2. package/dist/{DateRangeSelect.vue_vue_type_script_setup_true_lang-BAvBnJIi.js → DateRangeSelect.vue_vue_type_script_setup_true_lang-2O6NpHjE.js} +4 -4
  3. package/dist/{Default.vue_vue_type_script_setup_true_lang-CnW9a2_R.js → Default.vue_vue_type_script_setup_true_lang-CwNa_c74.js} +2 -2
  4. package/dist/{DynamicWidget.vue_vue_type_script_setup_true_lang-DQU-uRz0.js → DynamicWidget.vue_vue_type_script_setup_true_lang-DW-6QTKl.js} +4 -4
  5. package/dist/{InsightView-Bf_7_Wjc.js → InsightView-D6X9jnLz.js} +6 -6
  6. package/dist/Integration-oTDRNhG8.js +4751 -0
  7. package/dist/{Integrations-o4scI50k.js → Integrations-DN2WNYXH.js} +3 -3
  8. package/dist/{Layout-BXnKCxTV.js → Layout-0ZxLP82K.js} +1 -1
  9. package/dist/{MenuTab.vue_vue_type_script_setup_true_lang-CKHLNSX_.js → MenuTab.vue_vue_type_script_setup_true_lang-DI3QDb25.js} +3 -3
  10. package/dist/{NavigationTab.vue_vue_type_script_setup_true_lang-DhEzSNFT.js → NavigationTab.vue_vue_type_script_setup_true_lang-D1VWyu4i.js} +5 -5
  11. package/dist/{NoData.vue_vue_type_script_setup_true_lang-eaRJMGBE.js → NoData.vue_vue_type_script_setup_true_lang-C10GhV_H.js} +1 -1
  12. package/dist/{OverviewView-faNxJlGW.js → OverviewView-BFjjTkkR.js} +5 -5
  13. package/dist/{Report-CYKjv1L8.js → Report-Cvoqjnpe.js} +4 -4
  14. package/dist/{ReportEditor-NLpUP6DD.js → ReportEditor-DkdI7ZmZ.js} +5 -5
  15. package/dist/{ReportView-BptXTxx_.js → ReportView-6niCdR8K.js} +7 -7
  16. package/dist/{SelectComponent.vue_vue_type_script_setup_true_lang-DsaGcFfU.js → SelectComponent.vue_vue_type_script_setup_true_lang-B-9VcGRC.js} +1 -1
  17. package/dist/{Setting-BoprwHZP.js → Setting-BidP77Xr.js} +4 -4
  18. package/dist/{TileEditor-BnwUpljC.js → TileEditor-DCNCfcEY.js} +8 -8
  19. package/dist/{TransitionFade-lxIznBDk.js → TransitionFade-4Zow9tAu.js} +4 -4
  20. package/dist/app.js +143 -28
  21. package/dist/{global-loader-CIycgK0A.js → global-loader-BQlMgPFO.js} +2263 -2239
  22. package/dist/{index-N8fjljRM.js → index-Dw6wKcLo.js} +1 -1
  23. package/dist/{report-schema-vJw0vcwJ.js → report-schema-IaDHay9I.js} +1 -1
  24. package/dist/{v4-HgU9tmlv.js → v4-CLzZSDqm.js} +1 -1
  25. package/package.json +1 -1
  26. package/dist/Integration-BlBTzdBt.js +0 -3963
@@ -0,0 +1,4751 @@
1
+ import { defineComponent as G, mergeModels as he, useModel as W, computed as H, resolveComponent as D, createElementBlock as S, openBlock as d, createElementVNode as t, createCommentVNode as P, normalizeClass as Be, Fragment as O, renderList as Y, createBlock as M, createVNode as n, withCtx as we, toDisplayString as V, unref as m, ref as E, onUnmounted as Se, watch as _e, isRef as Ve, h as K, resolveDynamicComponent as ke, mergeProps as Oe, onMounted as Ee } from "vue";
2
+ import { useRouter as fe, useRoute as Ge } from "vue-router";
3
+ import { u as Z, I as xe, d as Xe, e as $e, f as De, b as ve, q as Qe, m as Je, p as Fe, r as Ue, s as Te, t as Ne, v as je, w as We, x as Ze, y as et, A as be, z as Le, B as tt, E as ot, G as at, H as lt } from "./global-loader-BQlMgPFO.js";
4
+ import { u as Ae } from "./message-dialog-UoMWOnil.js";
5
+ import { useSnackbar as ge } from "@feedmepos/ui-library";
6
+ import { s as nt } from "./index-Dw6wKcLo.js";
7
+ import { storeToRefs as Ke } from "pinia";
8
+ import { _ as Ie } from "./DateRangeSelect.vue_vue_type_script_setup_true_lang-2O6NpHjE.js";
9
+ const st = { class: "flex flex-row items-center w-[100%] gap-[4px] justify-between" }, it = { class: "text-nowrap w-[100%] overflow-hidden text-ellipsis" }, rt = {
10
+ key: 0,
11
+ class: "w-[24px] flex items-center"
12
+ }, R = /* @__PURE__ */ G({
13
+ __name: "MappingField",
14
+ props: /* @__PURE__ */ he({
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__ */ he(["remove"], ["update:modelValue"]),
36
+ setup(f, { emit: o }) {
37
+ const e = W(f, "modelValue"), s = f, x = H(
38
+ () => Object.keys(s.options).map((_) => {
39
+ const F = s.options[_];
40
+ return {
41
+ placeholder: F.placeholder,
42
+ key: _,
43
+ editable: F.editable
44
+ };
45
+ })
46
+ ), k = o;
47
+ return (_, F) => {
48
+ const w = D("FmTextField"), h = D("FmTooltip"), u = D("FmIcon");
49
+ return d(), S("div", st, [
50
+ t("div", {
51
+ class: Be(`${f.removable ? "w-[calc(100%-24px)]" : "w-[100%]"} flex flex-row items-center gap-[4px]`)
52
+ }, [
53
+ (d(!0), S(O, null, Y(x.value, (b) => {
54
+ var C;
55
+ return d(), S(O, {
56
+ key: b.key
57
+ }, [
58
+ b.editable ? (d(), S("div", {
59
+ key: 0,
60
+ class: Be(`${f.removable ? "w-[50%]" : "w-[100%]"}`)
61
+ }, [
62
+ n(w, {
63
+ "model-value": e.value[b.key],
64
+ placeholder: b.placeholder,
65
+ type: f.type,
66
+ rules: f.rules,
67
+ "onUpdate:modelValue": (p) => {
68
+ let v = p;
69
+ f.type === "number" && (v = Number(p)), e.value = {
70
+ ...e.value,
71
+ [b.key]: v
72
+ };
73
+ }
74
+ }, null, 8, ["model-value", "placeholder", "type", "rules", "onUpdate:modelValue"])
75
+ ], 2)) : (d(), M(h, {
76
+ key: 1,
77
+ content: (C = e.value[b.key]) == null ? void 0 : C.toString(),
78
+ class: "w-[50%]"
79
+ }, {
80
+ default: we(() => [
81
+ t("div", it, V(e.value[b.key]), 1)
82
+ ]),
83
+ _: 2
84
+ }, 1032, ["content"]))
85
+ ], 64);
86
+ }), 128))
87
+ ], 2),
88
+ f.removable ? (d(), S("div", rt, [
89
+ n(u, {
90
+ color: "system-error-300",
91
+ class: "cursor-pointer",
92
+ name: "close",
93
+ size: "md",
94
+ onClick: F[0] || (F[0] = (b) => k("remove"))
95
+ })
96
+ ])) : P("", !0)
97
+ ]);
98
+ };
99
+ }
100
+ }), mt = { class: "flex flex-col" }, dt = { class: "flex flex-row items-center fm-typo-en-title-sm-800 h-[36px]" }, ct = {
101
+ key: 0,
102
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
103
+ }, ut = { class: "flex flex-row items-center w-[100%] justify-start" }, pt = { class: "text-nowrap w-[calc(25%-4px)] overflow-hidden text-ellipsis" }, ft = {
104
+ key: 0,
105
+ class: "flex flex-row items-center w-[100%] justify-start"
106
+ }, vt = { class: "text-nowrap w-[calc(25%-4px)] overflow-hidden text-ellipsis" }, gt = { class: "w-[calc(75%+4px)]" }, yt = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, xt = { class: "flex flex-row items-center w-[100%] justify-between" }, _t = { class: "text-nowrap w-[50%] overflow-hidden text-ellipsis" }, bt = { class: "w-[50%]" }, Re = /* @__PURE__ */ G({
107
+ __name: "UploadSection",
108
+ props: /* @__PURE__ */ he({
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(f) {
123
+ const { t: o } = Z(), e = W(f, "modelValue"), s = H(() => {
124
+ switch (e.value.name) {
125
+ case xe.AutoCount:
126
+ case xe.SQL:
127
+ case xe.iFlexi_HRMS:
128
+ return !0;
129
+ default:
130
+ return !1;
131
+ }
132
+ });
133
+ return (x, k) => {
134
+ var h, u;
135
+ const _ = D("FmSwitch"), F = D("FmTextField"), w = D("FmTimePicker");
136
+ return d(), S(O, null, [
137
+ t("div", mt, [
138
+ t("div", dt, V(m(o)("report.integration.auto", { label: f.label })), 1),
139
+ f.label == "upload" ? (d(), S("div", ct, V(m(o)("report.integration.lastUploadDate")) + ": " + V(f.lastUploadDate ? m(Xe)(f.lastUploadDate).format("MMMM D, YYYY h:mm A") : m(o)("report.integration.noData.title")), 1)) : P("", !0)
140
+ ]),
141
+ t("div", ut, [
142
+ t("div", pt, V(m(o)("report.common.enable")), 1),
143
+ n(_, {
144
+ modelValue: e.value.enable,
145
+ "onUpdate:modelValue": k[0] || (k[0] = (b) => e.value.enable = b),
146
+ style: { gap: "0px" }
147
+ }, null, 8, ["modelValue"])
148
+ ]),
149
+ s.value ? (d(), S("div", ft, [
150
+ t("div", vt, V(m(o)("report.common.email")), 1),
151
+ t("div", gt, [
152
+ n(F, {
153
+ "model-value": (e.value.emails || []).join(","),
154
+ placeholder: "Email",
155
+ "onUpdate:modelValue": k[1] || (k[1] = (b) => {
156
+ switch (e.value.name) {
157
+ case m(xe).AutoCount:
158
+ case m(xe).SQL:
159
+ case m(xe).iFlexi_HRMS:
160
+ e.value.emails = b.split(",");
161
+ break;
162
+ }
163
+ })
164
+ }, null, 8, ["model-value"])
165
+ ])
166
+ ])) : P("", !0),
167
+ t("div", yt, [
168
+ t("div", xt, [
169
+ t("div", _t, V(m(nt)(f.label)) + " time ", 1),
170
+ t("div", bt, [
171
+ n(w, {
172
+ class: "gap-[0px]",
173
+ "model-value": m(Xe)().hour(((h = e.value.triggerTime) == null ? void 0 : h.hour) ?? 0).minute(((u = e.value.triggerTime) == null ? void 0 : u.minute) ?? 0).format("HH:mm"),
174
+ "onUpdate:modelValue": k[2] || (k[2] = (b) => {
175
+ b && (e.value.triggerTime.hour = Number(b.split(":")[0]), e.value.triggerTime.minute = Number(b.split(":")[1]));
176
+ })
177
+ }, null, 8, ["model-value"])
178
+ ])
179
+ ]),
180
+ n(R, {
181
+ "model-value": {
182
+ label: m(o)("report.integration.delayDay"),
183
+ delayDay: e.value.delayDay
184
+ },
185
+ type: "number",
186
+ options: {
187
+ label: { placeholder: m(o)("report.integration.delayDay"), editable: !1 },
188
+ delayDay: { placeholder: m(o)("report.integration.delayDay"), editable: !0 }
189
+ },
190
+ rules: [(b) => b > 0 || "Delay days must be greater than 0"],
191
+ "onUpdate:modelValue": k[3] || (k[3] = (b) => {
192
+ e.value.delayDay = b.delayDay;
193
+ })
194
+ }, null, 8, ["model-value", "options", "rules"])
195
+ ])
196
+ ], 64);
197
+ };
198
+ }
199
+ }), wt = { class: "flex flex-row items-center w-[100%] gap-[4px] justify-between" }, ht = {
200
+ key: 0,
201
+ class: "w-[50%]"
202
+ }, Vt = { class: "text-nowrap w-[100%] overflow-hidden text-ellipsis" }, kt = {
203
+ key: 0,
204
+ class: "w-[24px] flex items-center"
205
+ }, Me = /* @__PURE__ */ G({
206
+ __name: "MappingDropdown",
207
+ props: /* @__PURE__ */ he({
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__ */ he(["remove"], ["update:modelValue"]),
233
+ setup(f, { emit: o }) {
234
+ const e = W(f, "modelValue"), s = f, x = H(
235
+ () => Object.keys(s.options).map((h) => {
236
+ const u = s.options[h];
237
+ return {
238
+ placeholder: u.placeholder,
239
+ key: h,
240
+ editable: u.editable,
241
+ dropdownOptions: u.dropdownOptions
242
+ };
243
+ })
244
+ ), k = (h, u) => {
245
+ s.singleValueMode ? e.value = s.type === "number" ? Number(h) : h : u && (e.value = {
246
+ ...e.value,
247
+ [u]: s.type === "number" ? Number(h) : h
248
+ });
249
+ }, _ = (h) => {
250
+ var u;
251
+ return s.singleValueMode ? s.options.key.placeholder : (u = e.value[h.key]) == null ? void 0 : u.toString();
252
+ }, F = (h) => s.singleValueMode ? e.value : e.value[h.key], w = o;
253
+ return (h, u) => {
254
+ const b = D("FmSelect"), C = D("FmTextField"), p = D("FmTooltip"), v = D("FmIcon");
255
+ return d(), S("div", wt, [
256
+ t("div", {
257
+ class: Be(`${f.removable ? "w-[calc(100%-24px)]" : "w-[100%]"} flex flex-row items-center gap-[4px]`)
258
+ }, [
259
+ (d(!0), S(O, null, Y(x.value, (r) => (d(), S(O, {
260
+ key: r.key
261
+ }, [
262
+ r.editable ? (d(), S("div", ht, [
263
+ r.dropdownOptions ? (d(), M(b, {
264
+ key: 0,
265
+ "model-value": F(r),
266
+ placeholder: r.placeholder,
267
+ items: r.dropdownOptions,
268
+ "shift-menu": !0,
269
+ "onUpdate:modelValue": (y) => k(y, r.key)
270
+ }, null, 8, ["model-value", "placeholder", "items", "onUpdate:modelValue"])) : (d(), M(C, {
271
+ key: 1,
272
+ "model-value": F(r),
273
+ placeholder: r.placeholder,
274
+ type: f.type,
275
+ rules: f.rules,
276
+ "onUpdate:modelValue": (y) => k(y, r.key)
277
+ }, null, 8, ["model-value", "placeholder", "type", "rules", "onUpdate:modelValue"]))
278
+ ])) : (d(), M(p, {
279
+ key: 1,
280
+ content: _(r),
281
+ class: "w-[50%]"
282
+ }, {
283
+ default: we(() => [
284
+ t("div", Vt, V(_(r)), 1)
285
+ ]),
286
+ _: 2
287
+ }, 1032, ["content"]))
288
+ ], 64))), 128))
289
+ ], 2),
290
+ f.removable ? (d(), S("div", kt, [
291
+ n(v, {
292
+ color: "system-error-300",
293
+ class: "cursor-pointer",
294
+ name: "close",
295
+ size: "md",
296
+ onClick: u[0] || (u[0] = (r) => w("remove"))
297
+ })
298
+ ])) : P("", !0)
299
+ ]);
300
+ };
301
+ }
302
+ }), $t = {
303
+ key: 0,
304
+ class: "flex flex-col h-full"
305
+ }, Ct = { class: "flex flex-col gap-[16px] pb-[24px]" }, St = { class: "flex flex-row justify-between items-center gap-2" }, Dt = { class: "flex flex-row gap-2 items-center" }, Ft = { class: "relative group cursor-pointer" }, Ut = { class: "flex flex-col gap-16 pt-[24px] overflow-scroll" }, Tt = { class: "flex flex-row items-center justify-between gap-2" }, Nt = { class: "w-[25%]" }, At = { class: "flex flex-col gap-[16px]" }, Kt = { class: "flex flex-row items-center max-w-[100%] justify-between" }, It = { class: "flex-grow" }, Rt = { class: "flex flex-row items-center max-w-[100%] justify-between" }, Mt = { class: "flex flex-col gap-[16px]" }, Pt = { class: "flex flex-row items-center max-w-[100%] justify-between" }, jt = { class: "flex-grow" }, Lt = { class: "flex flex-row items-center max-w-[100%] justify-between" }, Bt = { class: "flex-grow" }, Ot = { class: "flex flex-row items-center max-w-[100%] justify-between" }, Et = { class: "flex-grow" }, zt = { class: "flex flex-row items-center gap-x-16" }, Yt = {
306
+ key: 0,
307
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
308
+ }, qt = {
309
+ key: 2,
310
+ class: "xs:grid-cols-1 grid-cols-2 grid gap-16"
311
+ }, Ht = { class: "flex flex-row items-center gap-x-16" }, Xt = {
312
+ key: 3,
313
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
314
+ }, Gt = {
315
+ key: 5,
316
+ class: "xs:grid-cols-1 grid-cols-2 grid gap-16"
317
+ }, Qt = { class: "flex flex-row items-center gap-x-16" }, Jt = {
318
+ key: 6,
319
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
320
+ }, Wt = {
321
+ key: 8,
322
+ class: "xs:grid-cols-1 grid-cols-2 grid gap-16"
323
+ }, Zt = /* @__PURE__ */ G({
324
+ __name: "Setting",
325
+ props: /* @__PURE__ */ he({
326
+ tenantOptions: {
327
+ type: Object,
328
+ required: !0
329
+ },
330
+ taxOptions: {
331
+ type: Object,
332
+ required: !0
333
+ },
334
+ accountCodeOptions: {
335
+ type: Object,
336
+ required: !0
337
+ }
338
+ }, {
339
+ modelValue: { required: !0 },
340
+ modelModifiers: {}
341
+ }),
342
+ emits: ["update:modelValue"],
343
+ setup(f) {
344
+ const { t: o } = Z(), e = W(f, "modelValue"), s = ge(), x = $e(), k = fe(), { promptLoader: _ } = De(), { promptMessage: F } = Ae(), { restaurants: w } = ve(), h = E(!1), u = H(
345
+ () => w.map((c) => ({ label: c.name, value: c.id }))
346
+ ), b = H(() => {
347
+ var c, a;
348
+ return h.value ? "Connecting" : (a = (c = e.value) == null ? void 0 : c.platform) != null && a.accessToken ? "Disconnect" : "Connect";
349
+ }), C = E(0);
350
+ async function p() {
351
+ var c;
352
+ if (h.value)
353
+ s.open({ type: "error", message: "Connecting in progress" });
354
+ else if ((c = e.value.platform) != null && c.accessToken)
355
+ await F({
356
+ message: o("report.integration.xero.confirmDisconnect", { name: e.value.name }),
357
+ title: o("report.integration.xero.disconnectTitle")
358
+ }) && (await Qe(e.value._id), await x.getSettings());
359
+ else if (e.value._id)
360
+ try {
361
+ const a = await Je(e.value._id);
362
+ h.value = !0;
363
+ const N = setInterval(async () => {
364
+ var A;
365
+ C.value += 1;
366
+ try {
367
+ await x.getSettings();
368
+ } finally {
369
+ (C.value === 12 || (A = e.value.platform) != null && A.accessToken) && (h.value = !1, N && clearInterval(N), C.value = 0);
370
+ }
371
+ }, 5e3);
372
+ window.open(a.redirect, "_blank");
373
+ } catch (a) {
374
+ s.open({ type: "error", message: a.message });
375
+ }
376
+ else
377
+ s.open({ type: "error", message: `invalid accounting ${e.value._id}` });
378
+ }
379
+ async function v() {
380
+ await F({
381
+ message: `Confirm delete ${e.value.name}?`,
382
+ title: "Delete"
383
+ }) && await _(async () => {
384
+ try {
385
+ await Fe(e.value._id), await x.getSettings(), k.back();
386
+ } catch (a) {
387
+ s.open({ type: "error", message: a.message });
388
+ }
389
+ });
390
+ }
391
+ async function r() {
392
+ await _(async () => {
393
+ try {
394
+ await Ue(e.value._id, e.value), await x.getSettings();
395
+ } catch (c) {
396
+ s.open({ type: "error", message: c.message });
397
+ }
398
+ });
399
+ }
400
+ function y(c) {
401
+ const a = f.tenantOptions.data.find((N) => N.value === c);
402
+ a && e.value.platform && (e.value.platform.tenant = {
403
+ id: a.value,
404
+ name: a.label
405
+ });
406
+ }
407
+ function $(c, a) {
408
+ var N, A;
409
+ (A = (N = e.value.platform) == null ? void 0 : N.mappings) != null && A[c] && (e.value.platform.mappings[c] = e.value.platform.mappings[c].filter(
410
+ (j, z) => z !== a
411
+ ));
412
+ }
413
+ function l(c) {
414
+ var a, N;
415
+ (N = (a = e.value.platform) == null ? void 0 : a.mappings) != null && N[c] && (e.value.platform.mappings[c] = [
416
+ ...e.value.platform.mappings[c],
417
+ c === "items" ? {
418
+ feedmeKey: "",
419
+ xeroAccount: "",
420
+ name: ""
421
+ } : c === "taxes" ? {
422
+ feedmeKey: "",
423
+ xeroAccount: ""
424
+ } : {
425
+ feedmeKey: "",
426
+ xeroAccount: ""
427
+ }
428
+ ]);
429
+ }
430
+ async function i() {
431
+ await _(async () => {
432
+ try {
433
+ await Te(e.value._id), await x.getSettings();
434
+ } catch (c) {
435
+ s.open({ type: "error", message: c.message });
436
+ }
437
+ });
438
+ }
439
+ return Se(async () => {
440
+ await x.getSettings();
441
+ }), (c, a) => {
442
+ var X, te, oe, ae, le, ne, se, ie, re, me, de, ce, ue, T, g, U, L, I, J, ye, ze, Ye, qe, He;
443
+ const N = D("FmIcon"), A = D("FmButton"), j = D("FmMenuDivider"), z = D("FmCircularProgress"), Q = D("FmSelect"), B = D("FmTextField"), q = D("FmSwitch");
444
+ return (te = (X = e.value) == null ? void 0 : X.platform) != null && te.mappings ? (d(), S("div", $t, [
445
+ t("div", Ct, [
446
+ t("div", St, [
447
+ a[10] || (a[10] = t("div", { class: "fm-typo-en-title-sm-800" }, "Connect", -1)),
448
+ t("div", Dt, [
449
+ t("div", Ft, [
450
+ n(N, {
451
+ name: "refresh",
452
+ class: "p-2 bg-gray-100 rounded-full",
453
+ onClick: i
454
+ }),
455
+ a[9] || (a[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))
456
+ ]),
457
+ n(A, {
458
+ variant: "tertiary",
459
+ label: "Delete",
460
+ onClick: v
461
+ }),
462
+ n(A, {
463
+ variant: "primary",
464
+ label: "Update",
465
+ onClick: r
466
+ })
467
+ ])
468
+ ])
469
+ ]),
470
+ n(j, { style: { margin: 0 } }),
471
+ t("div", Ut, [
472
+ a[21] || (a[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)),
473
+ t("div", Tt, [
474
+ t("div", Nt, [
475
+ n(A, {
476
+ disabled: h.value,
477
+ variant: "primary",
478
+ label: b.value,
479
+ onClick: p
480
+ }, null, 8, ["disabled", "label"])
481
+ ]),
482
+ !f.tenantOptions.isLoaded && ((oe = e.value.platform) != null && oe.accessToken) ? (d(), M(z, {
483
+ key: 0,
484
+ size: "xl"
485
+ })) : P("", !0),
486
+ n(Q, {
487
+ class: "flex-grow",
488
+ items: f.tenantOptions.data || [],
489
+ "model-value": (ae = e.value.platform.tenant) == null ? void 0 : ae.id,
490
+ placeholder: f.tenantOptions.data ? "Select tenant " : (le = e.value.platform.tenant) == null ? void 0 : le.name,
491
+ "onUpdate:modelValue": y
492
+ }, null, 8, ["items", "model-value", "placeholder"])
493
+ ]),
494
+ t("div", At, [
495
+ a[13] || (a[13] = t("div", { class: "flex flex-row items-center fm-typo-en-title-sm-800 h-[36px]" }, "General", -1)),
496
+ t("div", Kt, [
497
+ a[11] || (a[11] = t("div", { class: "w-[25%]" }, "Name", -1)),
498
+ t("div", It, [
499
+ n(B, {
500
+ modelValue: e.value.name,
501
+ "onUpdate:modelValue": a[0] || (a[0] = (pe) => e.value.name = pe)
502
+ }, null, 8, ["modelValue"])
503
+ ])
504
+ ]),
505
+ t("div", Rt, [
506
+ a[12] || (a[12] = t("div", { class: "w-[25%]" }, "Location", -1)),
507
+ n(Q, {
508
+ modelValue: e.value.platform.locationIds,
509
+ "onUpdate:modelValue": a[1] || (a[1] = (pe) => e.value.platform.locationIds = pe),
510
+ multiselect: !0,
511
+ items: u.value,
512
+ placeholder: "Select location",
513
+ class: "flex-grow"
514
+ }, null, 8, ["modelValue", "items"])
515
+ ])
516
+ ]),
517
+ n(Re, {
518
+ modelValue: e.value.platform,
519
+ "onUpdate:modelValue": a[2] || (a[2] = (pe) => e.value.platform = pe),
520
+ label: "upload",
521
+ "last-upload-date": (ne = e.value.platform) == null ? void 0 : ne.lastUploadDate
522
+ }, null, 8, ["modelValue", "last-upload-date"]),
523
+ t("div", Mt, [
524
+ a[20] || (a[20] = t("div", { class: "flex flex-row items-center fm-typo-en-title-sm-800 h-[36px]" }, "Mapping", -1)),
525
+ t("div", Pt, [
526
+ a[14] || (a[14] = t("div", { class: "w-[25%]" }, "Contact", -1)),
527
+ t("div", jt, [
528
+ n(B, {
529
+ modelValue: e.value.platform.mappings.contact.xeroAccount,
530
+ "onUpdate:modelValue": a[3] || (a[3] = (pe) => e.value.platform.mappings.contact.xeroAccount = pe),
531
+ placeholder: "Contact account number"
532
+ }, null, 8, ["modelValue"])
533
+ ])
534
+ ]),
535
+ t("div", Lt, [
536
+ a[15] || (a[15] = t("div", { class: "w-[25%]" }, "Discount as Item", -1)),
537
+ t("div", Bt, [
538
+ n(q, {
539
+ "model-value": e.value.platform.discountItem ?? !1,
540
+ style: { gap: 0 },
541
+ "onUpdate:modelValue": a[4] || (a[4] = (pe) => {
542
+ e.value.platform.discountItem = pe;
543
+ })
544
+ }, null, 8, ["model-value"])
545
+ ])
546
+ ]),
547
+ t("div", Ot, [
548
+ a[16] || (a[16] = t("div", { class: "w-[25%]" }, "Combine Refund", -1)),
549
+ t("div", Et, [
550
+ n(q, {
551
+ "model-value": e.value.platform.mappings.isCombineRefund ?? !1,
552
+ style: { gap: 0 },
553
+ "onUpdate:modelValue": a[5] || (a[5] = (pe) => {
554
+ e.value.platform.mappings.isCombineRefund = pe;
555
+ })
556
+ }, null, 8, ["model-value"])
557
+ ])
558
+ ]),
559
+ t("div", zt, [
560
+ a[17] || (a[17] = t("div", { class: "fm-typo-en-title-sm-800" }, "Taxes", -1)),
561
+ n(A, {
562
+ variant: "primary",
563
+ icon: "add",
564
+ onClick: a[6] || (a[6] = () => l("taxes"))
565
+ })
566
+ ]),
567
+ f.taxOptions.isError || e.value.platform.accessToken == null ? (d(), S("div", Yt, " Error connecting xero. Please connect to your Xero account to view the setting options. ")) : P("", !0),
568
+ !f.taxOptions.isLoaded && ((se = e.value.platform) != null && se.accessToken) ? (d(), M(z, {
569
+ key: 1,
570
+ size: "xl"
571
+ })) : P("", !0),
572
+ ((ie = f.taxOptions.data) == null ? void 0 : ie.length) > 0 ? (d(), S("div", qt, [
573
+ (d(!0), S(O, null, Y((de = (me = (re = e.value) == null ? void 0 : re.platform) == null ? void 0 : me.mappings) == null ? void 0 : de.taxes, (pe, ee) => (d(), M(Me, {
574
+ key: `tax-${ee}`,
575
+ modelValue: e.value.platform.mappings.taxes[ee],
576
+ "onUpdate:modelValue": (Ce) => e.value.platform.mappings.taxes[ee] = Ce,
577
+ options: {
578
+ feedmeKey: { placeholder: "Feedme Key", editable: !0 },
579
+ xeroAccount: {
580
+ placeholder: "Select Tax",
581
+ editable: !0,
582
+ dropdownOptions: f.taxOptions.data ?? []
583
+ }
584
+ },
585
+ removable: !0,
586
+ onRemove: () => $("taxes", ee)
587
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"]))), 128)),
588
+ (d(!0), S(O, null, Y((T = (ue = (ce = e.value) == null ? void 0 : ce.platform) == null ? void 0 : ue.mappings) == null ? void 0 : T.taxRoundingAdjustments, (pe, ee) => (d(), M(Me, {
589
+ key: `tax-rounding-adjustment-${ee}`,
590
+ modelValue: e.value.platform.mappings.taxRoundingAdjustments[ee],
591
+ "onUpdate:modelValue": (Ce) => e.value.platform.mappings.taxRoundingAdjustments[ee] = Ce,
592
+ options: {
593
+ feedmeKey: { placeholder: "Feedme Key", editable: !0 },
594
+ xeroAccount: {
595
+ placeholder: "Select Tax Rounding Adjustment",
596
+ editable: !0,
597
+ dropdownOptions: f.accountCodeOptions.data ?? []
598
+ }
599
+ },
600
+ removable: !0,
601
+ onRemove: () => $("taxRoundingAdjustments", ee)
602
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"]))), 128))
603
+ ])) : P("", !0),
604
+ t("div", Ht, [
605
+ a[18] || (a[18] = t("div", { class: "fm-typo-en-title-sm-800" }, "Items", -1)),
606
+ n(A, {
607
+ variant: "primary",
608
+ icon: "add",
609
+ onClick: a[7] || (a[7] = () => l("items"))
610
+ })
611
+ ]),
612
+ f.accountCodeOptions.isError || e.value.platform.accessToken == null ? (d(), S("div", Xt, " Error connecting xero. Please connect to your Xero account to view the setting options. ")) : P("", !0),
613
+ !f.accountCodeOptions.isLoaded && ((g = e.value.platform) != null && g.accessToken) ? (d(), M(z, {
614
+ key: 4,
615
+ size: "xl"
616
+ })) : P("", !0),
617
+ ((U = f.accountCodeOptions.data) == null ? void 0 : U.length) > 0 ? (d(), S("div", Gt, [
618
+ (d(!0), S(O, null, Y((J = (I = (L = e.value) == null ? void 0 : L.platform) == null ? void 0 : I.mappings) == null ? void 0 : J.items, (pe, ee) => (d(), M(Me, {
619
+ key: `item-${ee}`,
620
+ modelValue: e.value.platform.mappings.items[ee],
621
+ "onUpdate:modelValue": (Ce) => e.value.platform.mappings.items[ee] = Ce,
622
+ options: {
623
+ feedmeKey: { placeholder: "Feedme Key", editable: !0 },
624
+ xeroAccount: {
625
+ placeholder: "Select Item Code",
626
+ editable: !0,
627
+ dropdownOptions: f.accountCodeOptions.data ?? []
628
+ }
629
+ },
630
+ removable: !0,
631
+ onRemove: () => $("items", ee)
632
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"]))), 128))
633
+ ])) : P("", !0),
634
+ t("div", Qt, [
635
+ a[19] || (a[19] = t("div", { class: "fm-typo-en-title-sm-800" }, "Payments", -1)),
636
+ n(A, {
637
+ variant: "primary",
638
+ icon: "add",
639
+ onClick: a[8] || (a[8] = () => l("payments"))
640
+ })
641
+ ]),
642
+ f.accountCodeOptions.isError || e.value.platform.accessToken == null ? (d(), S("div", Jt, " Error connecting xero. Please connect to your Xero account to view the setting options. ")) : P("", !0),
643
+ !f.accountCodeOptions.isLoaded && ((ye = e.value.platform) != null && ye.accessToken) ? (d(), M(z, {
644
+ key: 7,
645
+ size: "xl"
646
+ })) : P("", !0),
647
+ ((ze = f.accountCodeOptions.data) == null ? void 0 : ze.length) > 0 ? (d(), S("div", Wt, [
648
+ (d(!0), S(O, null, Y((He = (qe = (Ye = e.value) == null ? void 0 : Ye.platform) == null ? void 0 : qe.mappings) == null ? void 0 : He.payments, (pe, ee) => (d(), M(Me, {
649
+ key: `payment-${ee}`,
650
+ modelValue: e.value.platform.mappings.payments[ee],
651
+ "onUpdate:modelValue": (Ce) => e.value.platform.mappings.payments[ee] = Ce,
652
+ options: {
653
+ feedmeKey: { placeholder: "Feedme Key", editable: !0 },
654
+ xeroAccount: {
655
+ placeholder: "Select Payment Code",
656
+ editable: !0,
657
+ dropdownOptions: f.accountCodeOptions.data ?? []
658
+ }
659
+ },
660
+ removable: !0,
661
+ onRemove: () => $("payments", ee)
662
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"]))), 128))
663
+ ])) : P("", !0)
664
+ ])
665
+ ])
666
+ ])) : P("", !0);
667
+ };
668
+ }
669
+ }), eo = { class: "h-full flex flex-col gap-16" }, to = { class: "flex flex-row gap-2 justify-between items-center" }, oo = {
670
+ key: 0,
671
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
672
+ }, ao = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, lo = /* @__PURE__ */ G({
673
+ __name: "Preview",
674
+ props: {
675
+ modelValue: { required: !0 },
676
+ modelModifiers: {}
677
+ },
678
+ emits: ["update:modelValue"],
679
+ setup(f) {
680
+ const o = E([]), { t: e } = Z(), s = H(
681
+ () => o.value.reduce((u, b) => {
682
+ const C = u.length, { invoice: p, payments: v } = b;
683
+ u[C] = {
684
+ date: p.Date,
685
+ contact: p.Contact.ContactID,
686
+ status: p.Status,
687
+ ref: p.Reference
688
+ };
689
+ for (let r = 0; r < Math.max(p.LineItems.length, v.length); r++) {
690
+ const y = C + r;
691
+ u[y] || (u[y] = {}), p.LineItems[r] && (u[y] = {
692
+ ...u[y],
693
+ itemDescription: p.LineItems[r].Description,
694
+ itemQuantity: p.LineItems[r].Quantity,
695
+ itemUnitAmount: p.LineItems[r].UnitAmount,
696
+ // itemCode: invoice.LineItems[i].ItemCode,
697
+ itemAccount: p.LineItems[r].AccountCode,
698
+ itemTax: p.LineItems[r].TaxAmount,
699
+ itemTaxType: p.LineItems[r].TaxType,
700
+ itemAmount: p.LineItems[r].LineAmount,
701
+ itemDiscount: p.LineItems[r].DiscountAmount
702
+ }), v[r] && (u[y] = {
703
+ ...u[y],
704
+ paymentAccount: v[r].Account.Code,
705
+ paymentReference: v[r].Reference,
706
+ paymentAmount: v[r].Amount
707
+ });
708
+ }
709
+ return u;
710
+ }, [])
711
+ ), x = [
712
+ {
713
+ accessorKey: "date",
714
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
715
+ enableSorting: !1
716
+ },
717
+ {
718
+ accessorKey: "status",
719
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Status"),
720
+ enableSorting: !1
721
+ },
722
+ {
723
+ accessorKey: "ref",
724
+ header: "Reference",
725
+ enableSorting: !1
726
+ },
727
+ {
728
+ accessorKey: "itemDescription",
729
+ header: () => K("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
730
+ enableSorting: !1
731
+ },
732
+ {
733
+ accessorKey: "itemQuantity",
734
+ header: "Item Quantity",
735
+ enableSorting: !1
736
+ },
737
+ {
738
+ accessorKey: "itemUnitAmount",
739
+ header: "Item Unit Amount",
740
+ enableSorting: !1
741
+ },
742
+ // {
743
+ // accessorKey: "itemCode",
744
+ // header: "Item Code",
745
+ // enableSorting: false
746
+ // },
747
+ {
748
+ accessorKey: "itemAccount",
749
+ header: () => K("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
750
+ enableSorting: !1
751
+ },
752
+ {
753
+ accessorKey: "itemTaxType",
754
+ header: "Item Tax Type",
755
+ enableSorting: !1
756
+ },
757
+ {
758
+ accessorKey: "itemTax",
759
+ header: "Item Tax",
760
+ enableSorting: !1
761
+ },
762
+ {
763
+ accessorKey: "itemAmount",
764
+ header: "Item Amount",
765
+ enableSorting: !1
766
+ },
767
+ {
768
+ accessorKey: "itemDiscount",
769
+ header: "Item Discount",
770
+ enableSorting: !1
771
+ },
772
+ {
773
+ accessorKey: "paymentAccount",
774
+ header: "Payment Account",
775
+ enableSorting: !1
776
+ },
777
+ {
778
+ accessorKey: "paymentReference",
779
+ header: "Payment Reference",
780
+ enableSorting: !1
781
+ },
782
+ {
783
+ accessorKey: "paymentAmount",
784
+ header: "Payment Amount",
785
+ enableSorting: !1
786
+ }
787
+ ], k = W(f, "modelValue"), _ = E(!1), F = ge(), { dateRange: w } = Ke(ve());
788
+ _e(
789
+ () => w.value,
790
+ async () => {
791
+ if (k.value._id)
792
+ try {
793
+ _.value = !0, o.value = await Ne(k.value._id);
794
+ } catch (u) {
795
+ F.open({ message: u.message, type: "error" });
796
+ } finally {
797
+ _.value = !1;
798
+ }
799
+ },
800
+ {
801
+ immediate: !0
802
+ }
803
+ );
804
+ async function h() {
805
+ try {
806
+ k.value._id ? (_.value = !0, await je(k.value._id), F.open({ message: "Upload successful", type: "success" })) : F.open({ message: "Invalid accounting setting", type: "error" });
807
+ } catch (u) {
808
+ u.message && F.open({ message: u.message, type: "error" }), u.errors && u.errors.forEach((b) => F.open({ message: b.Message, type: "error" }));
809
+ } finally {
810
+ _.value = !1;
811
+ }
812
+ }
813
+ return (u, b) => {
814
+ const C = D("FmButton"), p = D("FmCircularProgress"), v = D("FmTable");
815
+ return d(), S("div", eo, [
816
+ t("div", to, [
817
+ n(Ie, {
818
+ "date-range": m(w),
819
+ "onUpdate:dateRange": b[0] || (b[0] = (r) => Ve(w) ? w.value = r : null),
820
+ compare: !1
821
+ }, null, 8, ["date-range"]),
822
+ n(C, {
823
+ loading: _.value,
824
+ variant: "primary",
825
+ label: "Upload",
826
+ onClick: h
827
+ }, null, 8, ["loading"])
828
+ ]),
829
+ _.value ? (d(), S("div", oo, [
830
+ n(p, { size: "xl" }),
831
+ t("span", ao, V(m(e)("report.common.isLoading")), 1)
832
+ ])) : s.value.length > 0 ? (d(), M(v, {
833
+ key: 1,
834
+ class: "flex overflow-y-auto",
835
+ "row-data": s.value,
836
+ "column-defs": x
837
+ }, null, 8, ["row-data"])) : P("", !0)
838
+ ]);
839
+ };
840
+ }
841
+ }), no = { class: "h-full relative flex flex-col" }, so = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, io = /* @__PURE__ */ G({
842
+ __name: "Xero",
843
+ props: {
844
+ modelValue: { required: !0 },
845
+ modelModifiers: {}
846
+ },
847
+ emits: ["update:modelValue"],
848
+ setup(f) {
849
+ const { t: o } = Z(), e = W(f, "modelValue"), s = E("setting"), x = E({}), k = E({}), _ = E({}), F = [
850
+ {
851
+ label: o("report.integration.setting"),
852
+ value: "setting",
853
+ icon: "settings"
854
+ },
855
+ {
856
+ label: o("report.integration.preview"),
857
+ value: "preview",
858
+ icon: "table"
859
+ }
860
+ ], w = fe(), h = H(() => {
861
+ switch (s.value) {
862
+ case "preview":
863
+ return { component: lo };
864
+ case "setting":
865
+ return {
866
+ component: Zt,
867
+ props: {
868
+ tenantOptions: x.value,
869
+ taxOptions: k.value,
870
+ accountCodeOptions: _.value
871
+ }
872
+ };
873
+ default:
874
+ return null;
875
+ }
876
+ });
877
+ async function u() {
878
+ if (e.value._id)
879
+ try {
880
+ const p = await We(e.value._id);
881
+ x.value.data = p.map((v) => ({
882
+ value: v.id,
883
+ label: v.name
884
+ }));
885
+ } catch (p) {
886
+ console.error("Failed to fetch tenants:", p), x.value.isError = !0;
887
+ } finally {
888
+ x.value.isLoaded = !0;
889
+ }
890
+ }
891
+ async function b() {
892
+ if (e.value._id)
893
+ try {
894
+ const p = await Ze(e.value._id);
895
+ k.value.data = p.map((v) => ({
896
+ value: v.Name,
897
+ label: `${v.Name} - (${v.EffectiveRate}%)`
898
+ }));
899
+ } catch (p) {
900
+ console.error("Failed to fetch taxes:", p), k.value.isError = !0;
901
+ } finally {
902
+ k.value.isLoaded = !0;
903
+ }
904
+ }
905
+ async function C() {
906
+ if (e.value._id)
907
+ try {
908
+ const p = await et(e.value._id);
909
+ _.value.data = p.map((v) => ({
910
+ value: v.Code,
911
+ label: `${v.Code} ${v.Name} - [${v.Class}_${v.Type}]`
912
+ }));
913
+ } catch (p) {
914
+ console.error("Failed to fetch accounts:", p), _.value.isError = !0;
915
+ } finally {
916
+ _.value.isLoaded = !0;
917
+ }
918
+ }
919
+ return _e(
920
+ () => {
921
+ var p;
922
+ return (p = e.value.platform) == null ? void 0 : p.accessToken;
923
+ },
924
+ (p) => {
925
+ p && (u(), b(), C());
926
+ },
927
+ { immediate: !0 }
928
+ ), (p, v) => {
929
+ var $, l, i;
930
+ const r = D("FmPageHead"), y = D("FmTabs");
931
+ return d(), S("div", no, [
932
+ n(r, {
933
+ title: (($ = e.value) == null ? void 0 : $.name) || "Xero",
934
+ "back-button": !0,
935
+ style: { paddingLeft: "0px", paddingRight: "0px" },
936
+ "onClick:back": m(w).back
937
+ }, {
938
+ description: we(() => v[2] || (v[2] = [
939
+ t("div", null, null, -1)
940
+ ])),
941
+ _: 1
942
+ }, 8, ["title", "onClick:back"]),
943
+ n(y, {
944
+ "model-value": s.value,
945
+ "onUpdate:modelValue": v[0] || (v[0] = (c) => s.value = c),
946
+ items: F
947
+ }, null, 8, ["model-value"]),
948
+ t("div", so, [
949
+ (d(), M(ke((l = h.value) == null ? void 0 : l.component), Oe({
950
+ modelValue: e.value,
951
+ "onUpdate:modelValue": v[1] || (v[1] = (c) => e.value = c)
952
+ }, (i = h.value) == null ? void 0 : i.props), null, 16, ["modelValue"]))
953
+ ])
954
+ ]);
955
+ };
956
+ }
957
+ }), ro = { class: "mt-6 mb-6" }, mo = { class: "list-disc pl-6 space-y-1" }, Pe = /* @__PURE__ */ G({
958
+ __name: "ReferenceNumberGuideButton",
959
+ setup(f) {
960
+ const { t: o } = Z(), e = [
961
+ {
962
+ placeholder: "[NO]",
963
+ category: o("report.integration.refNumExplain.no.category"),
964
+ meaning: o("report.integration.refNumExplain.no.meaning"),
965
+ output: "123"
966
+ },
967
+ {
968
+ placeholder: "[DD]",
969
+ category: o("report.integration.refNumExplain.dd.category"),
970
+ meaning: o("report.integration.refNumExplain.dd.meaning"),
971
+ output: "27"
972
+ },
973
+ {
974
+ placeholder: "[MM]",
975
+ category: o("report.integration.refNumExplain.mm.category"),
976
+ meaning: o("report.integration.refNumExplain.mm.meaning"),
977
+ output: "09"
978
+ },
979
+ {
980
+ placeholder: "[YYYY]",
981
+ category: o("report.integration.refNumExplain.yyyy.category"),
982
+ meaning: o("report.integration.refNumExplain.yyyy.meaning"),
983
+ output: "2024"
984
+ },
985
+ {
986
+ placeholder: "[PAYMENT4]",
987
+ category: o("report.integration.refNumExplain.payment4.category"),
988
+ meaning: o("report.integration.refNumExplain.payment4.meaning"),
989
+ output: "CRED"
990
+ },
991
+ {
992
+ placeholder: "[PAYMENT5]",
993
+ category: o("report.integration.refNumExplain.payment5.category"),
994
+ meaning: o("report.integration.refNumExplain.payment5.meaning"),
995
+ output: "CREDI"
996
+ },
997
+ {
998
+ placeholder: "[5DIGIT]",
999
+ category: o("report.integration.refNumExplain.5digit.category"),
1000
+ meaning: o("report.integration.refNumExplain.5digit.meaning"),
1001
+ output: "[5DIGIT]"
1002
+ }
1003
+ ], s = [
1004
+ {
1005
+ accessorKey: "placeholder",
1006
+ header: o("report.integration.placeholder")
1007
+ },
1008
+ {
1009
+ accessorKey: "category",
1010
+ header: o("report.integration.category")
1011
+ },
1012
+ {
1013
+ accessorKey: "meaning",
1014
+ header: o("report.integration.meaning")
1015
+ },
1016
+ {
1017
+ accessorKey: "output",
1018
+ header: o("report.integration.output")
1019
+ }
1020
+ ];
1021
+ return (x, k) => {
1022
+ const _ = D("FmIcon"), F = D("FmTable"), w = D("FmSideSheet");
1023
+ return d(), M(w, {
1024
+ header: m(o)("report.integration.refNumFormatInfo"),
1025
+ "dismiss-away": "",
1026
+ "max-width": 780
1027
+ }, {
1028
+ "side-sheet-button": we(() => [
1029
+ n(_, {
1030
+ name: "info",
1031
+ color: "primary",
1032
+ class: "cursor-pointer p-2"
1033
+ })
1034
+ ]),
1035
+ default: we(() => [
1036
+ t("div", ro, [
1037
+ t("ul", mo, [
1038
+ t("li", null, V(m(o)("report.integration.refNumGuide.1stPoint")), 1),
1039
+ t("li", null, V(m(o)("report.integration.refNumGuide.2ndPoint")), 1),
1040
+ t("li", null, V(m(o)("report.integration.refNumGuide.3ndPoint")), 1),
1041
+ t("li", null, V(m(o)("report.integration.refNumGuide.4thPoint")), 1)
1042
+ ])
1043
+ ]),
1044
+ n(F, {
1045
+ "row-data": e,
1046
+ "column-defs": s,
1047
+ "shrink-at": !1,
1048
+ "hide-footer": !0
1049
+ })
1050
+ ]),
1051
+ _: 1
1052
+ }, 8, ["header"]);
1053
+ };
1054
+ }
1055
+ }), co = {
1056
+ key: 0,
1057
+ class: "flex flex-col h-full"
1058
+ }, uo = { class: "flex flex-col gap-16 pb-[24px]" }, po = { class: "flex flex-row justify-between items-center gap-2" }, fo = { class: "fm-typo-en-title-sm-800" }, vo = { class: "flex flex-row gap-2 items-center" }, go = { class: "relative group cursor-pointer" }, yo = { 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" }, xo = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, _o = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, bo = { class: "flex flex-row items-center justify-between" }, wo = { class: "w-[25%]" }, ho = { class: "flex-grow" }, Vo = { class: "flex flex-row items-center justify-between" }, ko = { class: "w-[25%]" }, $o = { class: "flex-grow" }, Co = { class: "flex flex-col gap-16" }, So = { class: "fm-typo-en-title-sm-800" }, Do = { class: "flex flex-row items-center max-w-[100%]" }, Fo = { class: "w-[25%]" }, Uo = { class: "flex-grow" }, To = { class: "flex flex-row items-center max-w-[100%]" }, No = { class: "w-[25%]" }, Ao = { class: "flex flex-row items-center max-w-[100%]" }, Ko = { class: "w-[25%]" }, Io = { class: "flex flex-col gap-16" }, Ro = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Mo = { class: "flex flex-col gap-16 pt-3 pb-3" }, Po = { class: "flex flex-row items-center gap-5" }, jo = { class: "fm-typo-en-title-sm-800" }, Lo = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Bo = { class: "flex flex-row items-center gap-x-16" }, Oo = { class: "fm-typo-en-title-sm-800" }, Eo = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, zo = { class: "flex flex-row items-center gap-x-16" }, Yo = { class: "fm-typo-en-title-sm-800" }, qo = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Ho = { class: "flex flex-row items-center gap-x-16" }, Xo = { class: "fm-typo-en-title-sm-800" }, Go = /* @__PURE__ */ G({
1059
+ __name: "Setting",
1060
+ props: {
1061
+ modelValue: { required: !0 },
1062
+ modelModifiers: {}
1063
+ },
1064
+ emits: ["update:modelValue"],
1065
+ setup(f) {
1066
+ const o = W(f, "modelValue"), e = ge(), s = $e(), x = fe(), { promptLoader: k } = De(), { promptMessage: _ } = Ae(), { restaurants: F } = ve(), w = H(
1067
+ () => F.map((l) => ({ label: l.name, value: l.id }))
1068
+ ), { t: h } = Z();
1069
+ async function u() {
1070
+ await _({
1071
+ message: h("report.messages.confirmDelete", { name: o.value.name }),
1072
+ title: h("report.common.delete")
1073
+ }) && await k(async () => {
1074
+ try {
1075
+ await Fe(o.value._id), await s.getSettings(), x.back();
1076
+ } catch (i) {
1077
+ e.open({ type: "error", message: i.message });
1078
+ }
1079
+ });
1080
+ }
1081
+ async function b() {
1082
+ await k(async () => {
1083
+ try {
1084
+ await Ue(o.value._id, o.value), await s.getSettings();
1085
+ } catch (l) {
1086
+ e.open({ type: "error", message: l.message });
1087
+ }
1088
+ });
1089
+ }
1090
+ function C(l, i) {
1091
+ var c, a;
1092
+ (a = (c = o.value.platform) == null ? void 0 : c.mappings) != null && a[l] && (o.value.platform.mappings[l] = o.value.platform.mappings[l].filter(
1093
+ (N, A) => A !== i
1094
+ ));
1095
+ }
1096
+ function p(l) {
1097
+ var i, c;
1098
+ if ((c = (i = o.value.platform) == null ? void 0 : i.mappings) != null && c[l]) {
1099
+ let a;
1100
+ switch (l) {
1101
+ case "items":
1102
+ a = {
1103
+ key: "",
1104
+ account: "",
1105
+ accountName: ""
1106
+ };
1107
+ break;
1108
+ case "payments":
1109
+ a = {
1110
+ key: "",
1111
+ account: "",
1112
+ accountName: "",
1113
+ method: ""
1114
+ };
1115
+ break;
1116
+ default:
1117
+ a = {
1118
+ key: "",
1119
+ account: ""
1120
+ };
1121
+ break;
1122
+ }
1123
+ o.value.platform.mappings[l] = [
1124
+ ...o.value.platform.mappings[l],
1125
+ a
1126
+ ];
1127
+ }
1128
+ }
1129
+ const v = [
1130
+ {
1131
+ label: h("report.integration.grouping.byDay"),
1132
+ value: be.BY_DAY
1133
+ },
1134
+ {
1135
+ label: h("report.integration.grouping.byDayItem"),
1136
+ value: be.BY_DAY_ITEM
1137
+ },
1138
+ {
1139
+ label: h("report.integration.grouping.byInvoice"),
1140
+ value: be.BY_INVOICE
1141
+ },
1142
+ {
1143
+ label: h("report.integration.grouping.byDaySeparatePayment"),
1144
+ value: be.BY_DAY_SEPARATE_PAYMENT
1145
+ }
1146
+ ];
1147
+ function r({
1148
+ key: l,
1149
+ value: i
1150
+ }) {
1151
+ var c, a;
1152
+ (a = (c = o.value) == null ? void 0 : c.platform) != null && a.mappings && (o.value.platform.mappings[l] = i);
1153
+ }
1154
+ function y(l) {
1155
+ return {
1156
+ key: { placeholder: l, editable: !1 },
1157
+ account: { placeholder: l, editable: !0 }
1158
+ };
1159
+ }
1160
+ async function $() {
1161
+ await k(async () => {
1162
+ try {
1163
+ await Te(o.value._id), await s.getSettings();
1164
+ } catch (l) {
1165
+ e.open({ type: "error", message: l.message });
1166
+ }
1167
+ });
1168
+ }
1169
+ return Se(async () => {
1170
+ await s.getSettings();
1171
+ }), (l, i) => {
1172
+ var z, Q, B, q, X, te, oe, ae, le, ne, se, ie, re, me, de, ce, ue, T;
1173
+ const c = D("FmIcon"), a = D("FmButton"), N = D("FmMenuDivider"), A = D("FmTextField"), j = D("FmSelect");
1174
+ return (Q = (z = o.value) == null ? void 0 : z.platform) != null && Q.mappings ? (d(), S("div", co, [
1175
+ t("div", uo, [
1176
+ t("div", po, [
1177
+ t("div", fo, V(m(h)("report.integration.bukku.connect")), 1),
1178
+ t("div", vo, [
1179
+ t("div", go, [
1180
+ n(c, {
1181
+ name: "refresh",
1182
+ class: "p-2 bg-gray-100 rounded-full",
1183
+ onClick: $
1184
+ }),
1185
+ t("span", yo, V(m(h)("report.integration.refreshSetting")), 1)
1186
+ ]),
1187
+ n(a, {
1188
+ variant: "tertiary",
1189
+ label: m(h)("report.common.delete"),
1190
+ onClick: u
1191
+ }, null, 8, ["label"]),
1192
+ n(a, {
1193
+ variant: "primary",
1194
+ label: m(h)("report.common.update"),
1195
+ onClick: b
1196
+ }, null, 8, ["label"])
1197
+ ])
1198
+ ])
1199
+ ]),
1200
+ n(N, { style: { margin: 0 } }),
1201
+ t("div", xo, [
1202
+ t("div", _o, V(m(h)("report.integration.bukku.authentication")), 1),
1203
+ t("div", bo, [
1204
+ t("div", wo, V(m(h)("report.integration.subdomain")), 1),
1205
+ t("div", ho, [
1206
+ n(A, {
1207
+ modelValue: o.value.platform.subdomain,
1208
+ "onUpdate:modelValue": i[0] || (i[0] = (g) => o.value.platform.subdomain = g),
1209
+ placeholder: m(h)("report.integration.subdomain")
1210
+ }, null, 8, ["modelValue", "placeholder"])
1211
+ ])
1212
+ ]),
1213
+ t("div", Vo, [
1214
+ t("div", ko, V(m(h)("report.integration.token")), 1),
1215
+ t("div", $o, [
1216
+ n(A, {
1217
+ modelValue: o.value.platform.token,
1218
+ "onUpdate:modelValue": i[1] || (i[1] = (g) => o.value.platform.token = g),
1219
+ placeholder: m(h)("report.integration.token")
1220
+ }, null, 8, ["modelValue", "placeholder"])
1221
+ ])
1222
+ ]),
1223
+ t("div", Co, [
1224
+ t("div", So, V(m(h)("report.integration.general")), 1),
1225
+ t("div", Do, [
1226
+ t("div", Fo, V(m(h)("report.common.name")), 1),
1227
+ t("div", Uo, [
1228
+ n(A, {
1229
+ modelValue: o.value.name,
1230
+ "onUpdate:modelValue": i[2] || (i[2] = (g) => o.value.name = g)
1231
+ }, null, 8, ["modelValue"])
1232
+ ])
1233
+ ]),
1234
+ t("div", To, [
1235
+ t("div", No, V(m(h)("report.common.location")), 1),
1236
+ n(j, {
1237
+ modelValue: o.value.platform.locationIds,
1238
+ "onUpdate:modelValue": i[3] || (i[3] = (g) => o.value.platform.locationIds = g),
1239
+ multiselect: !0,
1240
+ items: w.value,
1241
+ placeholder: "Select location",
1242
+ class: "flex-grow"
1243
+ }, null, 8, ["modelValue", "items"])
1244
+ ]),
1245
+ t("div", Ao, [
1246
+ t("div", Ko, V(m(h)("report.integration.grouping.title")), 1),
1247
+ n(j, {
1248
+ modelValue: o.value.platform.grouping,
1249
+ "onUpdate:modelValue": i[4] || (i[4] = (g) => o.value.platform.grouping = g),
1250
+ multiselect: !1,
1251
+ items: v,
1252
+ placeholder: "Select grouping",
1253
+ class: "flex-grow"
1254
+ }, null, 8, ["modelValue"])
1255
+ ])
1256
+ ]),
1257
+ t("div", Io, [
1258
+ t("div", Ro, [
1259
+ n(R, {
1260
+ "model-value": {
1261
+ key: "Contact",
1262
+ account: o.value.platform.mappings.contact.account
1263
+ },
1264
+ options: {
1265
+ key: {
1266
+ placeholder: "Contact",
1267
+ editable: !1
1268
+ },
1269
+ account: {
1270
+ placeholder: "Contact",
1271
+ editable: !0
1272
+ }
1273
+ },
1274
+ "onUpdate:modelValue": i[5] || (i[5] = (g) => {
1275
+ var U, L, I;
1276
+ (I = (L = (U = o.value) == null ? void 0 : U.platform) == null ? void 0 : L.mappings) != null && I.contact && (o.value.platform.mappings.contact.account = g.account);
1277
+ })
1278
+ }, null, 8, ["model-value"]),
1279
+ n(R, {
1280
+ "model-value": {
1281
+ key: "Rounding",
1282
+ account: o.value.platform.mappings.rounding.account
1283
+ },
1284
+ options: y("Rounding"),
1285
+ "onUpdate:modelValue": i[6] || (i[6] = (g) => {
1286
+ var U, L, I;
1287
+ (I = (L = (U = o.value) == null ? void 0 : U.platform) == null ? void 0 : L.mappings) != null && I.rounding && (o.value.platform.mappings.rounding.account = g.account);
1288
+ })
1289
+ }, null, 8, ["model-value", "options"]),
1290
+ (d(!0), S(O, null, Y((X = (q = (B = o.value) == null ? void 0 : B.platform) == null ? void 0 : q.mappings) == null ? void 0 : X.charges, (g, U) => (d(), M(R, {
1291
+ key: `charge-${U}`,
1292
+ modelValue: o.value.platform.mappings.charges[U],
1293
+ "onUpdate:modelValue": (L) => o.value.platform.mappings.charges[U] = L,
1294
+ options: {
1295
+ key: {
1296
+ placeholder: "Key",
1297
+ editable: !1
1298
+ },
1299
+ account: {
1300
+ placeholder: "Account code",
1301
+ editable: !0
1302
+ }
1303
+ }
1304
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]))), 128))
1305
+ ])
1306
+ ]),
1307
+ t("div", Mo, [
1308
+ t("div", Po, [
1309
+ t("div", jo, V(m(h)("report.integration.refNumFormat")), 1),
1310
+ n(Pe)
1311
+ ]),
1312
+ t("div", Lo, [
1313
+ n(R, {
1314
+ "model-value": {
1315
+ key: "Invoice no",
1316
+ account: o.value.platform.mappings.invoiceDocNo
1317
+ },
1318
+ options: y("Invoice no"),
1319
+ "onUpdate:modelValue": i[7] || (i[7] = (g) => r({ key: "invoiceDocNo", value: g.account }))
1320
+ }, null, 8, ["model-value", "options"]),
1321
+ n(R, {
1322
+ "model-value": {
1323
+ key: "Credit note no",
1324
+ account: o.value.platform.mappings.creditNoteDocNo
1325
+ },
1326
+ options: y("Credit note no"),
1327
+ "onUpdate:modelValue": i[8] || (i[8] = (g) => r({ key: "creditNoteDocNo", value: g.account }))
1328
+ }, null, 8, ["model-value", "options"]),
1329
+ n(R, {
1330
+ "model-value": {
1331
+ key: "Payment no",
1332
+ account: o.value.platform.mappings.paymentDocNo
1333
+ },
1334
+ options: y("Payment no"),
1335
+ "onUpdate:modelValue": i[9] || (i[9] = (g) => r({ key: "paymentDocNo", value: g.account }))
1336
+ }, null, 8, ["model-value", "options"]),
1337
+ n(R, {
1338
+ "model-value": {
1339
+ key: "Refund no",
1340
+ account: o.value.platform.mappings.refundDocNo
1341
+ },
1342
+ options: y("Refund no"),
1343
+ "onUpdate:modelValue": i[10] || (i[10] = (g) => r({ key: "refundDocNo", value: g.account }))
1344
+ }, null, 8, ["model-value", "options"])
1345
+ ])
1346
+ ]),
1347
+ n(Re, {
1348
+ modelValue: o.value.platform,
1349
+ "onUpdate:modelValue": i[11] || (i[11] = (g) => o.value.platform = g),
1350
+ label: "upload",
1351
+ "last-upload-date": (te = o.value.platform) == null ? void 0 : te.lastUploadDate
1352
+ }, null, 8, ["modelValue", "last-upload-date"]),
1353
+ t("div", Bo, [
1354
+ t("div", Oo, V(m(h)("report.integration.items")), 1),
1355
+ n(a, {
1356
+ variant: "primary",
1357
+ icon: "add",
1358
+ onClick: i[12] || (i[12] = () => p("items"))
1359
+ })
1360
+ ]),
1361
+ t("div", Eo, [
1362
+ (d(!0), S(O, null, Y((le = (ae = (oe = o.value) == null ? void 0 : oe.platform) == null ? void 0 : ae.mappings) == null ? void 0 : le.items, (g, U) => (d(), M(R, {
1363
+ key: `item-${U}`,
1364
+ modelValue: o.value.platform.mappings.items[U],
1365
+ "onUpdate:modelValue": (L) => o.value.platform.mappings.items[U] = L,
1366
+ options: {
1367
+ key: { placeholder: "Key", editable: !0 },
1368
+ account: { placeholder: "Account code", editable: !0 }
1369
+ },
1370
+ removable: !0,
1371
+ onRemove: () => C("items", U)
1372
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1373
+ ]),
1374
+ t("div", zo, [
1375
+ t("div", Yo, V(m(h)("report.integration.taxes")), 1),
1376
+ n(a, {
1377
+ variant: "primary",
1378
+ icon: "add",
1379
+ onClick: i[13] || (i[13] = () => p("taxes"))
1380
+ })
1381
+ ]),
1382
+ t("div", qo, [
1383
+ (d(!0), S(O, null, Y((ie = (se = (ne = o.value) == null ? void 0 : ne.platform) == null ? void 0 : se.mappings) == null ? void 0 : ie.taxes, (g, U) => (d(), M(R, {
1384
+ key: `tax-${U}`,
1385
+ modelValue: o.value.platform.mappings.taxes[U],
1386
+ "onUpdate:modelValue": (L) => o.value.platform.mappings.taxes[U] = L,
1387
+ options: {
1388
+ key: { placeholder: "Key", editable: !0 },
1389
+ account: { placeholder: "Account code", editable: !0 }
1390
+ },
1391
+ removable: !0,
1392
+ onRemove: () => C("taxes", U)
1393
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128)),
1394
+ (d(!0), S(O, null, Y((de = (me = (re = o.value) == null ? void 0 : re.platform) == null ? void 0 : me.mappings) == null ? void 0 : de.taxRoundingAdjustments, (g, U) => (d(), M(R, {
1395
+ key: `tax-rounding-adjustment-${U}`,
1396
+ modelValue: o.value.platform.mappings.taxRoundingAdjustments[U],
1397
+ "onUpdate:modelValue": (L) => o.value.platform.mappings.taxRoundingAdjustments[U] = L,
1398
+ options: {
1399
+ key: { placeholder: "Key", editable: !0 },
1400
+ account: { placeholder: "Account code", editable: !0 }
1401
+ },
1402
+ removable: !0,
1403
+ onRemove: () => C("taxRoundingAdjustments", U)
1404
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1405
+ ]),
1406
+ t("div", Ho, [
1407
+ t("div", Xo, V(m(h)("report.integration.payments")), 1),
1408
+ n(a, {
1409
+ variant: "primary",
1410
+ icon: "add",
1411
+ onClick: i[14] || (i[14] = () => p("payments"))
1412
+ })
1413
+ ]),
1414
+ (d(!0), S(O, null, Y((T = (ue = (ce = o.value) == null ? void 0 : ce.platform) == null ? void 0 : ue.mappings) == null ? void 0 : T.payments, (g, U) => (d(), S("div", {
1415
+ key: `payment-${U}`,
1416
+ class: "grid-cols-1 grid gap-x-16"
1417
+ }, [
1418
+ n(R, {
1419
+ modelValue: o.value.platform.mappings.payments[U],
1420
+ "onUpdate:modelValue": (L) => o.value.platform.mappings.payments[U] = L,
1421
+ options: {
1422
+ key: { placeholder: "Key", editable: !0 },
1423
+ method: { placeholder: "Method", editable: !0 },
1424
+ account: { placeholder: "Account code", editable: !0 }
1425
+ },
1426
+ removable: !0,
1427
+ onRemove: () => C("payments", U)
1428
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"])
1429
+ ]))), 128))
1430
+ ])
1431
+ ])) : P("", !0);
1432
+ };
1433
+ }
1434
+ }), Qo = { class: "h-full flex flex-col gap-16" }, Jo = { class: "flex flex-row gap-2 justify-between items-center" }, Wo = {
1435
+ key: 0,
1436
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
1437
+ }, Zo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ea = /* @__PURE__ */ G({
1438
+ __name: "Preview",
1439
+ props: {
1440
+ modelValue: { required: !0 },
1441
+ modelModifiers: {}
1442
+ },
1443
+ emits: ["update:modelValue"],
1444
+ setup(f) {
1445
+ const o = E([]), e = H(
1446
+ () => o.value.reduce((u, b) => {
1447
+ const C = u.length, { invoice: p, payments: v } = b;
1448
+ u[C] = {
1449
+ no: p.number,
1450
+ date: p.date,
1451
+ contact: p._contact_name,
1452
+ status: p.status,
1453
+ title: p.title
1454
+ };
1455
+ for (let r = 0; r < Math.max(p.form_items.length, v.length); r++) {
1456
+ const y = C + r;
1457
+ u[y] || (u[y] = {});
1458
+ const $ = p.form_items[r];
1459
+ $ && (u[y] = {
1460
+ ...u[y],
1461
+ itemDescription: $.description,
1462
+ itemQuantity: $.quantity,
1463
+ itemUnitPrice: $.unit_price,
1464
+ itemAccount: $._account_name,
1465
+ itemTaxCode: $._tax_code_name,
1466
+ itemDiscount: $.discount
1467
+ });
1468
+ const l = v[r];
1469
+ l && (u[y] = {
1470
+ ...u[y],
1471
+ paymentNo: l.number,
1472
+ paymentMethod: l.deposit_items[0]._payment_method_name,
1473
+ paymentAccount: l.deposit_items[0]._account_name,
1474
+ paymentDescription: l.description,
1475
+ paymentAmount: l.amount
1476
+ });
1477
+ }
1478
+ return u;
1479
+ }, [])
1480
+ ), { t: s } = Z(), x = [
1481
+ {
1482
+ accessorKey: "date",
1483
+ header: () => K(
1484
+ "p",
1485
+ { class: "min-w-[90px] text-nowrap text-ellipsis" },
1486
+ s("report.integration.table.date")
1487
+ ),
1488
+ enableSorting: !1
1489
+ },
1490
+ {
1491
+ accessorKey: "no",
1492
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, s("report.integration.table.no")),
1493
+ enableSorting: !1
1494
+ },
1495
+ {
1496
+ accessorKey: "contact",
1497
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Contact"),
1498
+ enableSorting: !1
1499
+ },
1500
+ {
1501
+ accessorKey: "status",
1502
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Status"),
1503
+ enableSorting: !1
1504
+ },
1505
+ {
1506
+ accessorKey: "title",
1507
+ header: "Title",
1508
+ enableSorting: !1
1509
+ },
1510
+ {
1511
+ accessorKey: "itemDescription",
1512
+ header: () => K("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
1513
+ enableSorting: !1
1514
+ },
1515
+ {
1516
+ accessorKey: "itemQuantity",
1517
+ header: "Item Quantity",
1518
+ enableSorting: !1
1519
+ },
1520
+ {
1521
+ accessorKey: "itemUnitPrice",
1522
+ header: "Item Unit Price",
1523
+ enableSorting: !1
1524
+ },
1525
+ {
1526
+ accessorKey: "itemAccount",
1527
+ header: () => K("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
1528
+ enableSorting: !1
1529
+ },
1530
+ {
1531
+ accessorKey: "itemTaxCode",
1532
+ header: "Item Tax Code",
1533
+ enableSorting: !1
1534
+ },
1535
+ {
1536
+ accessorKey: "itemDiscount",
1537
+ header: "Item Discount",
1538
+ enableSorting: !1
1539
+ },
1540
+ {
1541
+ accessorKey: "paymentNo",
1542
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment No"),
1543
+ enableSorting: !1
1544
+ },
1545
+ {
1546
+ accessorKey: "paymentMethod",
1547
+ header: "Payment Method",
1548
+ enableSorting: !1
1549
+ },
1550
+ {
1551
+ accessorKey: "paymentAccount",
1552
+ header: "Payment Account",
1553
+ enableSorting: !1
1554
+ },
1555
+ {
1556
+ accessorKey: "paymentDescription",
1557
+ header: "Payment Description",
1558
+ enableSorting: !1
1559
+ },
1560
+ {
1561
+ accessorKey: "paymentAmount",
1562
+ header: "Payment Amount",
1563
+ enableSorting: !1
1564
+ }
1565
+ ], k = W(f, "modelValue"), _ = E(!1), F = ge(), { dateRange: w } = Ke(ve());
1566
+ _e(
1567
+ () => w.value,
1568
+ async () => {
1569
+ if (k.value._id)
1570
+ try {
1571
+ _.value = !0, o.value = await Ne(k.value._id);
1572
+ } catch (u) {
1573
+ F.open({ message: u.message, type: "error" });
1574
+ } finally {
1575
+ _.value = !1;
1576
+ }
1577
+ },
1578
+ {
1579
+ immediate: !0
1580
+ }
1581
+ );
1582
+ async function h() {
1583
+ try {
1584
+ k.value._id ? (_.value = !0, await je(k.value._id), F.open({ message: s("report.integration.uploadSuccess"), type: "success" })) : F.open({ message: s("report.integration.error.invalid"), type: "error" });
1585
+ } catch (u) {
1586
+ F.open({ message: u.message, type: "error" });
1587
+ } finally {
1588
+ _.value = !1;
1589
+ }
1590
+ }
1591
+ return (u, b) => {
1592
+ const C = D("FmButton"), p = D("FmCircularProgress"), v = D("FmTable");
1593
+ return d(), S("div", Qo, [
1594
+ t("div", Jo, [
1595
+ n(Ie, {
1596
+ "date-range": m(w),
1597
+ "onUpdate:dateRange": b[0] || (b[0] = (r) => Ve(w) ? w.value = r : null),
1598
+ compare: !1
1599
+ }, null, 8, ["date-range"]),
1600
+ n(C, {
1601
+ loading: _.value,
1602
+ variant: "primary",
1603
+ label: m(s)("report.common.upload"),
1604
+ onClick: h
1605
+ }, null, 8, ["loading", "label"])
1606
+ ]),
1607
+ _.value ? (d(), S("div", Wo, [
1608
+ n(p, { size: "xl" }),
1609
+ t("span", Zo, V(m(s)("report.integration.table.loading")), 1)
1610
+ ])) : e.value.length > 0 ? (d(), M(v, {
1611
+ key: 1,
1612
+ class: "flex overflow-y-auto",
1613
+ "row-data": e.value,
1614
+ "column-defs": x
1615
+ }, null, 8, ["row-data"])) : P("", !0)
1616
+ ]);
1617
+ };
1618
+ }
1619
+ }), ta = { class: "h-full relative flex flex-col" }, oa = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, aa = /* @__PURE__ */ G({
1620
+ __name: "Bukku",
1621
+ props: {
1622
+ modelValue: {},
1623
+ modelModifiers: {}
1624
+ },
1625
+ emits: ["update:modelValue"],
1626
+ setup(f) {
1627
+ const { t: o } = Z(), e = W(f, "modelValue"), s = E("setting"), x = [
1628
+ {
1629
+ label: o("report.integration.setting"),
1630
+ value: "setting",
1631
+ icon: "settings"
1632
+ },
1633
+ {
1634
+ label: o("report.integration.preview"),
1635
+ value: "preview",
1636
+ icon: "table"
1637
+ }
1638
+ ], k = fe(), _ = H(() => {
1639
+ switch (s.value) {
1640
+ case "preview":
1641
+ return ea;
1642
+ case "setting":
1643
+ return Go;
1644
+ default:
1645
+ return null;
1646
+ }
1647
+ });
1648
+ return (F, w) => {
1649
+ var b;
1650
+ const h = D("FmPageHead"), u = D("FmTabs");
1651
+ return d(), S("div", ta, [
1652
+ n(h, {
1653
+ title: ((b = e.value) == null ? void 0 : b.name) || "Bukku",
1654
+ "back-button": !0,
1655
+ style: { paddingLeft: "0px", paddingRight: "0px" },
1656
+ "onClick:back": m(k).back
1657
+ }, {
1658
+ description: we(() => w[2] || (w[2] = [
1659
+ t("div", null, null, -1)
1660
+ ])),
1661
+ _: 1
1662
+ }, 8, ["title", "onClick:back"]),
1663
+ n(u, {
1664
+ "model-value": s.value,
1665
+ "onUpdate:modelValue": w[0] || (w[0] = (C) => s.value = C),
1666
+ items: x
1667
+ }, null, 8, ["model-value"]),
1668
+ t("div", oa, [
1669
+ (d(), M(ke(_.value), {
1670
+ modelValue: e.value,
1671
+ "onUpdate:modelValue": w[1] || (w[1] = (C) => e.value = C)
1672
+ }, null, 8, ["modelValue"]))
1673
+ ])
1674
+ ]);
1675
+ };
1676
+ }
1677
+ }), la = {
1678
+ key: 0,
1679
+ class: "flex flex-col h-full"
1680
+ }, na = { class: "flex flex-col gap-16 pb-[24px]" }, sa = { class: "flex flex-row justify-between items-center gap-2" }, ia = { class: "flex flex-row gap-2 items-center" }, ra = { class: "relative group cursor-pointer" }, ma = { 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" }, da = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, ca = { class: "flex flex-col gap-16" }, ua = { class: "fm-typo-en-title-sm-800" }, pa = { class: "flex flex-row items-center max-w-[100%]" }, fa = { class: "w-[25%]" }, va = { class: "flex-grow" }, ga = { class: "flex flex-row items-center max-w-[100%]" }, ya = { class: "w-[25%]" }, xa = { class: "flex flex-row items-center max-w-[100%]" }, _a = { class: "w-[25%]" }, ba = { class: "flex flex-col gap-16" }, wa = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, ha = { class: "flex flex-col gap-16 pt-3 pb-3" }, Va = { class: "flex flex-row items-center gap-5" }, ka = { class: "fm-typo-en-title-sm-800" }, $a = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Ca = { class: "flex flex-row items-center gap-x-16" }, Sa = { class: "fm-typo-en-title-sm-800" }, Da = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Fa = { class: "flex flex-row items-center gap-x-16" }, Ua = { class: "fm-typo-en-title-sm-800" }, Ta = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Na = { class: "flex flex-row items-center gap-x-16" }, Aa = { class: "fm-typo-en-title-sm-800" }, Ka = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, Ia = /* @__PURE__ */ G({
1681
+ __name: "Setting",
1682
+ props: {
1683
+ modelValue: { required: !0 },
1684
+ modelModifiers: {}
1685
+ },
1686
+ emits: ["update:modelValue"],
1687
+ setup(f) {
1688
+ const { t: o } = Z(), e = W(f, "modelValue"), s = ge(), x = $e(), k = fe(), { promptLoader: _ } = De(), { promptMessage: F } = Ae(), { restaurants: w } = ve(), h = H(
1689
+ () => w.map((l) => ({ label: l.name, value: l.id }))
1690
+ );
1691
+ async function u() {
1692
+ await F({
1693
+ message: o("report.messages.confirmDelete", { name: e.value.name }),
1694
+ title: o("report.common.delete")
1695
+ }) && await _(async () => {
1696
+ try {
1697
+ await Fe(e.value._id), await x.getSettings(), k.back();
1698
+ } catch (i) {
1699
+ s.open({ type: "error", message: i.message });
1700
+ }
1701
+ });
1702
+ }
1703
+ async function b() {
1704
+ await _(async () => {
1705
+ try {
1706
+ await Ue(e.value._id, e.value), await x.getSettings();
1707
+ } catch (l) {
1708
+ s.open({ type: "error", message: l.message });
1709
+ }
1710
+ });
1711
+ }
1712
+ function C(l, i) {
1713
+ var c, a;
1714
+ (a = (c = e.value.platform) == null ? void 0 : c.mappings) != null && a[l] && (e.value.platform.mappings[l] = e.value.platform.mappings[l].filter(
1715
+ (N, A) => A !== i
1716
+ ));
1717
+ }
1718
+ function p(l) {
1719
+ var i, c;
1720
+ (c = (i = e.value.platform) == null ? void 0 : i.mappings) != null && c[l] && (e.value.platform.mappings[l] = [
1721
+ ...e.value.platform.mappings[l],
1722
+ l === "items" ? {
1723
+ key: "",
1724
+ account: "",
1725
+ description: ""
1726
+ } : {
1727
+ key: "",
1728
+ account: ""
1729
+ }
1730
+ ]);
1731
+ }
1732
+ const v = [
1733
+ {
1734
+ label: "By day",
1735
+ value: be.BY_DAY
1736
+ },
1737
+ {
1738
+ label: "By invoice",
1739
+ value: be.BY_INVOICE
1740
+ },
1741
+ {
1742
+ label: "By day and category",
1743
+ value: be.BY_DAY_CATEGORY
1744
+ }
1745
+ ];
1746
+ function r({
1747
+ key: l,
1748
+ value: i
1749
+ }) {
1750
+ var c, a;
1751
+ (a = (c = e.value) == null ? void 0 : c.platform) != null && a.mappings && (e.value.platform.mappings[l] = i);
1752
+ }
1753
+ function y(l) {
1754
+ return {
1755
+ key: { placeholder: l, editable: !1 },
1756
+ account: { placeholder: l, editable: !0 }
1757
+ };
1758
+ }
1759
+ async function $() {
1760
+ await _(async () => {
1761
+ try {
1762
+ await Te(e.value._id), await x.getSettings();
1763
+ } catch (l) {
1764
+ s.open({ type: "error", message: l.message });
1765
+ }
1766
+ });
1767
+ }
1768
+ return Se(async () => {
1769
+ await x.getSettings();
1770
+ }), (l, i) => {
1771
+ var z, Q, B, q, X, te, oe, ae, le, ne, se, ie, re, me, de, ce, ue;
1772
+ const c = D("FmIcon"), a = D("FmButton"), N = D("FmMenuDivider"), A = D("FmTextField"), j = D("FmSelect");
1773
+ return (Q = (z = e.value) == null ? void 0 : z.platform) != null && Q.mappings ? (d(), S("div", la, [
1774
+ t("div", na, [
1775
+ t("div", sa, [
1776
+ i[14] || (i[14] = t("div", { class: "fm-typo-en-title-sm-800" }, null, -1)),
1777
+ t("div", ia, [
1778
+ t("div", ra, [
1779
+ n(c, {
1780
+ name: "refresh",
1781
+ class: "p-2 bg-gray-100 rounded-full",
1782
+ onClick: $
1783
+ }),
1784
+ t("span", ma, V(m(o)("report.integration.refreshSetting")), 1)
1785
+ ]),
1786
+ n(a, {
1787
+ variant: "tertiary",
1788
+ label: m(o)("report.common.remove"),
1789
+ onClick: u
1790
+ }, null, 8, ["label"]),
1791
+ n(a, {
1792
+ variant: "primary",
1793
+ label: m(o)("report.common.update"),
1794
+ onClick: b
1795
+ }, null, 8, ["label"])
1796
+ ])
1797
+ ])
1798
+ ]),
1799
+ n(N, { style: { margin: 0 } }),
1800
+ t("div", da, [
1801
+ t("div", ca, [
1802
+ t("div", ua, V(m(o)("report.integration.general")), 1),
1803
+ t("div", pa, [
1804
+ t("div", fa, V(m(o)("report.common.name")), 1),
1805
+ t("div", va, [
1806
+ n(A, {
1807
+ modelValue: e.value.name,
1808
+ "onUpdate:modelValue": i[0] || (i[0] = (T) => e.value.name = T)
1809
+ }, null, 8, ["modelValue"])
1810
+ ])
1811
+ ]),
1812
+ t("div", ga, [
1813
+ t("div", ya, V(m(o)("report.integration.location")), 1),
1814
+ n(j, {
1815
+ modelValue: e.value.platform.locationIds,
1816
+ "onUpdate:modelValue": i[1] || (i[1] = (T) => e.value.platform.locationIds = T),
1817
+ multiselect: !0,
1818
+ items: h.value,
1819
+ placeholder: "Select location",
1820
+ class: "flex-grow",
1821
+ rules: [(T) => T.length !== 0 || "Please select at least 1 location"]
1822
+ }, null, 8, ["modelValue", "items", "rules"])
1823
+ ]),
1824
+ t("div", xa, [
1825
+ t("div", _a, V(m(o)("report.integration.grouping.title")), 1),
1826
+ n(j, {
1827
+ modelValue: e.value.platform.grouping,
1828
+ "onUpdate:modelValue": i[2] || (i[2] = (T) => e.value.platform.grouping = T),
1829
+ multiselect: !1,
1830
+ items: v,
1831
+ placeholder: "Select grouping",
1832
+ class: "flex-grow"
1833
+ }, null, 8, ["modelValue"])
1834
+ ])
1835
+ ]),
1836
+ t("div", ba, [
1837
+ t("div", wa, [
1838
+ n(R, {
1839
+ "model-value": { key: "Project", account: e.value.platform.mappings.project },
1840
+ options: y("Project"),
1841
+ "onUpdate:modelValue": i[3] || (i[3] = (T) => r({ key: "project", value: T.account }))
1842
+ }, null, 8, ["model-value", "options"]),
1843
+ n(R, {
1844
+ "model-value": { key: "Debtor", account: e.value.platform.mappings.debtor },
1845
+ options: y("Debtor"),
1846
+ "onUpdate:modelValue": i[4] || (i[4] = (T) => r({ key: "debtor", value: T.account }))
1847
+ }, null, 8, ["model-value", "options"]),
1848
+ n(R, {
1849
+ "model-value": {
1850
+ key: "Rounding",
1851
+ account: e.value.platform.mappings.rounding.account
1852
+ },
1853
+ options: y("Rounding"),
1854
+ "onUpdate:modelValue": i[5] || (i[5] = (T) => {
1855
+ var g, U, L;
1856
+ (L = (U = (g = e.value) == null ? void 0 : g.platform) == null ? void 0 : U.mappings) != null && L.rounding && (e.value.platform.mappings.rounding.account = T.account);
1857
+ })
1858
+ }, null, 8, ["model-value", "options"]),
1859
+ (d(!0), S(O, null, Y((X = (q = (B = e.value) == null ? void 0 : B.platform) == null ? void 0 : q.mappings) == null ? void 0 : X.charges, (T, g) => (d(), M(R, {
1860
+ key: `charge-${g}`,
1861
+ modelValue: e.value.platform.mappings.charges[g],
1862
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.charges[g] = U,
1863
+ options: {
1864
+ key: { placeholder: "Key", editable: !1 },
1865
+ account: { placeholder: "Account code", editable: !0 }
1866
+ }
1867
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]))), 128))
1868
+ ])
1869
+ ]),
1870
+ t("div", ha, [
1871
+ t("div", Va, [
1872
+ t("div", ka, V(m(o)("report.integration.refNumFormat")), 1),
1873
+ n(Pe)
1874
+ ]),
1875
+ t("div", $a, [
1876
+ n(R, {
1877
+ "model-value": {
1878
+ key: "Invoice no",
1879
+ account: e.value.platform.mappings.invoiceDocNo
1880
+ },
1881
+ options: y("Invoice no"),
1882
+ "onUpdate:modelValue": i[6] || (i[6] = (T) => r({ key: "invoiceDocNo", value: T.account }))
1883
+ }, null, 8, ["model-value", "options"]),
1884
+ n(R, {
1885
+ "model-value": {
1886
+ key: "Credit note no",
1887
+ account: e.value.platform.mappings.creditNoteDocNo
1888
+ },
1889
+ options: y("Credit note no"),
1890
+ "onUpdate:modelValue": i[7] || (i[7] = (T) => r({ key: "creditNoteDocNo", value: T.account }))
1891
+ }, null, 8, ["model-value", "options"]),
1892
+ n(R, {
1893
+ "model-value": {
1894
+ key: "Payment no",
1895
+ account: e.value.platform.mappings.paymentDocNo
1896
+ },
1897
+ options: y("Payment no"),
1898
+ "onUpdate:modelValue": i[8] || (i[8] = (T) => r({ key: "paymentDocNo", value: T.account }))
1899
+ }, null, 8, ["model-value", "options"]),
1900
+ n(R, {
1901
+ "model-value": {
1902
+ key: "Refund no",
1903
+ account: e.value.platform.mappings.refundDocNo
1904
+ },
1905
+ options: y("Refund no"),
1906
+ "onUpdate:modelValue": i[9] || (i[9] = (T) => r({ key: "refundDocNo", value: T.account }))
1907
+ }, null, 8, ["model-value", "options"])
1908
+ ])
1909
+ ]),
1910
+ n(Re, {
1911
+ modelValue: e.value.platform,
1912
+ "onUpdate:modelValue": i[10] || (i[10] = (T) => e.value.platform = T),
1913
+ label: m(o)("report.input.email")
1914
+ }, null, 8, ["modelValue", "label"]),
1915
+ t("div", Ca, [
1916
+ t("div", Sa, V(m(o)("report.integration.items")), 1),
1917
+ n(a, {
1918
+ variant: "primary",
1919
+ icon: "add",
1920
+ onClick: i[11] || (i[11] = () => p("items"))
1921
+ })
1922
+ ]),
1923
+ t("div", Da, [
1924
+ (d(!0), S(O, null, Y((ae = (oe = (te = e.value) == null ? void 0 : te.platform) == null ? void 0 : oe.mappings) == null ? void 0 : ae.items, (T, g) => (d(), M(R, {
1925
+ key: `item-${g}`,
1926
+ modelValue: e.value.platform.mappings.items[g],
1927
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.items[g] = U,
1928
+ options: {
1929
+ key: { placeholder: "Key", editable: !0 },
1930
+ account: { placeholder: "Account code", editable: !0 }
1931
+ },
1932
+ removable: !0,
1933
+ onRemove: () => C("items", g)
1934
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1935
+ ]),
1936
+ t("div", Fa, [
1937
+ t("div", Ua, V(m(o)("report.integration.taxes")), 1),
1938
+ n(a, {
1939
+ variant: "primary",
1940
+ icon: "add",
1941
+ onClick: i[12] || (i[12] = () => p("taxes"))
1942
+ })
1943
+ ]),
1944
+ t("div", Ta, [
1945
+ (d(!0), S(O, null, Y((se = (ne = (le = e.value) == null ? void 0 : le.platform) == null ? void 0 : ne.mappings) == null ? void 0 : se.taxes, (T, g) => (d(), M(R, {
1946
+ key: `tax-${g}`,
1947
+ modelValue: e.value.platform.mappings.taxes[g],
1948
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.taxes[g] = U,
1949
+ options: {
1950
+ key: { placeholder: "Key", editable: !0 },
1951
+ account: { placeholder: "Account code", editable: !0 }
1952
+ },
1953
+ removable: !0,
1954
+ onRemove: () => C("taxes", g)
1955
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128)),
1956
+ (d(!0), S(O, null, Y((me = (re = (ie = e.value) == null ? void 0 : ie.platform) == null ? void 0 : re.mappings) == null ? void 0 : me.taxRoundingAdjustments, (T, g) => (d(), M(R, {
1957
+ key: `tax-rounding-adjustment-${g}`,
1958
+ modelValue: e.value.platform.mappings.taxRoundingAdjustments[g],
1959
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.taxRoundingAdjustments[g] = U,
1960
+ options: {
1961
+ key: { placeholder: "Key", editable: !0 },
1962
+ account: { placeholder: "Account code", editable: !0 }
1963
+ },
1964
+ removable: !0,
1965
+ onRemove: () => C("taxRoundingAdjustments", g)
1966
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1967
+ ]),
1968
+ t("div", Na, [
1969
+ t("div", Aa, V(m(o)("report.integration.payments")), 1),
1970
+ n(a, {
1971
+ variant: "primary",
1972
+ icon: "add",
1973
+ onClick: i[13] || (i[13] = () => p("payments"))
1974
+ })
1975
+ ]),
1976
+ t("div", Ka, [
1977
+ (d(!0), S(O, null, Y((ue = (ce = (de = e.value) == null ? void 0 : de.platform) == null ? void 0 : ce.mappings) == null ? void 0 : ue.payments, (T, g) => (d(), M(R, {
1978
+ key: `payment-${g}`,
1979
+ modelValue: e.value.platform.mappings.payments[g],
1980
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.payments[g] = U,
1981
+ options: {
1982
+ key: { placeholder: "Key", editable: !0 },
1983
+ account: { placeholder: "Payment name", editable: !0 }
1984
+ },
1985
+ removable: !0,
1986
+ onRemove: () => C("payments", g)
1987
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
1988
+ ])
1989
+ ])
1990
+ ])) : P("", !0);
1991
+ };
1992
+ }
1993
+ }), Ra = { class: "h-full flex flex-col gap-16" }, Ma = { class: "flex flex-row gap-2 justify-between items-center" }, Pa = {
1994
+ key: 0,
1995
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
1996
+ }, ja = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, La = /* @__PURE__ */ G({
1997
+ __name: "Preview",
1998
+ props: {
1999
+ modelValue: { required: !0 },
2000
+ modelModifiers: {}
2001
+ },
2002
+ emits: ["update:modelValue"],
2003
+ setup(f) {
2004
+ const { t: o } = Z(), e = E([]), s = H(
2005
+ () => e.value.reduce((u, b) => {
2006
+ const C = u.length, { invoice: p, payments: v } = b;
2007
+ u[C] = {
2008
+ date: p.DocDate,
2009
+ docNo: p.DocNo,
2010
+ projNo: p.ProjNo,
2011
+ debtor: p.DebtorCode,
2012
+ description: p.Description
2013
+ };
2014
+ for (let r = 0; r < Math.max(p._items.length, v.length); r++) {
2015
+ const y = C + r;
2016
+ u[y] || (u[y] = {}), p._items[r] && (u[y] = {
2017
+ ...u[y],
2018
+ itemDescription: p._items[r].DetailDescription,
2019
+ itemUnitPrice: p._items[r].Amount,
2020
+ itemAccount: p._items[r].AccNo,
2021
+ itemTaxCode: p._items[r].TaxType,
2022
+ itemTax: p._items[r].Tax
2023
+ }), v[r] && (u[y] = {
2024
+ ...u[y],
2025
+ paymentDocNo: v[r].DocNo,
2026
+ paymentMethod: v[r].paymentMethod,
2027
+ paymentDescription: v[r].Description,
2028
+ paymentAmount: v[r].PaymentAmt
2029
+ });
2030
+ }
2031
+ return u;
2032
+ }, [])
2033
+ ), x = [
2034
+ {
2035
+ accessorKey: "date",
2036
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
2037
+ enableSorting: !1
2038
+ },
2039
+ {
2040
+ accessorKey: "docNo",
2041
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Doc No"),
2042
+ enableSorting: !1
2043
+ },
2044
+ {
2045
+ accessorKey: "projNo",
2046
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Project"),
2047
+ enableSorting: !1
2048
+ },
2049
+ {
2050
+ accessorKey: "debtor",
2051
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Debtor"),
2052
+ enableSorting: !1
2053
+ },
2054
+ {
2055
+ accessorKey: "description",
2056
+ header: "Description",
2057
+ enableSorting: !1
2058
+ },
2059
+ {
2060
+ accessorKey: "itemAccount",
2061
+ header: () => K("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
2062
+ enableSorting: !1
2063
+ },
2064
+ {
2065
+ accessorKey: "itemTaxCode",
2066
+ header: "Item Tax Code",
2067
+ enableSorting: !1
2068
+ },
2069
+ {
2070
+ accessorKey: "itemDescription",
2071
+ header: () => K("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
2072
+ enableSorting: !1
2073
+ },
2074
+ {
2075
+ accessorKey: "itemUnitPrice",
2076
+ header: "Item Unit Price",
2077
+ enableSorting: !1
2078
+ },
2079
+ {
2080
+ accessorKey: "itemTax",
2081
+ header: "Item Tax",
2082
+ enableSorting: !1
2083
+ },
2084
+ {
2085
+ accessorKey: "paymentDocNo",
2086
+ header: "Payment Doc No",
2087
+ enableSorting: !1
2088
+ },
2089
+ {
2090
+ accessorKey: "paymentMethod",
2091
+ header: "Payment Method",
2092
+ enableSorting: !1
2093
+ },
2094
+ {
2095
+ accessorKey: "paymentDescription",
2096
+ header: "Payment Description",
2097
+ enableSorting: !1
2098
+ },
2099
+ {
2100
+ accessorKey: "paymentAmount",
2101
+ header: "Payment Amount",
2102
+ enableSorting: !1
2103
+ }
2104
+ ], k = W(f, "modelValue"), _ = E(!1), F = ge(), { dateRange: w } = Ke(ve());
2105
+ _e(
2106
+ () => w.value,
2107
+ async () => {
2108
+ if (k.value._id)
2109
+ try {
2110
+ _.value = !0, e.value = await Ne(k.value._id);
2111
+ } catch (u) {
2112
+ F.open({ message: u.message, type: "error" });
2113
+ } finally {
2114
+ _.value = !1;
2115
+ }
2116
+ },
2117
+ {
2118
+ immediate: !0
2119
+ }
2120
+ );
2121
+ async function h() {
2122
+ try {
2123
+ k.value._id ? (_.value = !0, await Le(k.value._id)) : F.open({ message: "Invalid accounting setting", type: "error" });
2124
+ } catch (u) {
2125
+ F.open({ message: u.message, type: "error" });
2126
+ } finally {
2127
+ _.value = !1;
2128
+ }
2129
+ }
2130
+ return (u, b) => {
2131
+ const C = D("FmButton"), p = D("FmCircularProgress"), v = D("FmTable");
2132
+ return d(), S("div", Ra, [
2133
+ t("div", Ma, [
2134
+ n(Ie, {
2135
+ "date-range": m(w),
2136
+ "onUpdate:dateRange": b[0] || (b[0] = (r) => Ve(w) ? w.value = r : null),
2137
+ compare: !1
2138
+ }, null, 8, ["date-range"]),
2139
+ n(C, {
2140
+ loading: _.value,
2141
+ variant: "primary",
2142
+ label: m(o)("report.common.download"),
2143
+ onClick: h
2144
+ }, null, 8, ["loading", "label"])
2145
+ ]),
2146
+ _.value ? (d(), S("div", Pa, [
2147
+ n(p, { size: "xl" }),
2148
+ t("span", ja, V(m(o)("report.common.isLoading")), 1)
2149
+ ])) : s.value.length > 0 ? (d(), M(v, {
2150
+ key: 1,
2151
+ class: "flex overflow-y-auto",
2152
+ "row-data": s.value,
2153
+ "column-defs": x
2154
+ }, null, 8, ["row-data"])) : P("", !0)
2155
+ ]);
2156
+ };
2157
+ }
2158
+ }), Ba = { class: "h-full relative flex flex-col" }, Oa = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, Ea = /* @__PURE__ */ G({
2159
+ __name: "AutoCount",
2160
+ props: {
2161
+ modelValue: {},
2162
+ modelModifiers: {}
2163
+ },
2164
+ emits: ["update:modelValue"],
2165
+ setup(f) {
2166
+ const { t: o } = Z(), e = W(f, "modelValue"), s = E("setting"), x = [
2167
+ {
2168
+ label: o("report.integration.setting"),
2169
+ value: "setting",
2170
+ icon: "settings"
2171
+ },
2172
+ {
2173
+ label: o("report.integration.preview"),
2174
+ value: "preview",
2175
+ icon: "table"
2176
+ }
2177
+ ], k = fe(), _ = H(() => {
2178
+ switch (s.value) {
2179
+ case "preview":
2180
+ return La;
2181
+ case "setting":
2182
+ return Ia;
2183
+ default:
2184
+ return null;
2185
+ }
2186
+ });
2187
+ return (F, w) => {
2188
+ var b;
2189
+ const h = D("FmPageHead"), u = D("FmTabs");
2190
+ return d(), S("div", Ba, [
2191
+ n(h, {
2192
+ title: ((b = e.value) == null ? void 0 : b.name) || "AutoCount",
2193
+ "back-button": !0,
2194
+ style: { paddingLeft: "0px", paddingRight: "0px" },
2195
+ "onClick:back": m(k).back
2196
+ }, {
2197
+ description: we(() => w[2] || (w[2] = [
2198
+ t("div", null, null, -1)
2199
+ ])),
2200
+ _: 1
2201
+ }, 8, ["title", "onClick:back"]),
2202
+ n(u, {
2203
+ "model-value": s.value,
2204
+ "onUpdate:modelValue": w[0] || (w[0] = (C) => s.value = C),
2205
+ items: x
2206
+ }, null, 8, ["model-value"]),
2207
+ t("div", Oa, [
2208
+ (d(), M(ke(_.value), {
2209
+ modelValue: e.value,
2210
+ "onUpdate:modelValue": w[1] || (w[1] = (C) => e.value = C)
2211
+ }, null, 8, ["modelValue"]))
2212
+ ])
2213
+ ]);
2214
+ };
2215
+ }
2216
+ }), za = {
2217
+ key: 0,
2218
+ class: "flex flex-col h-full"
2219
+ }, Ya = { class: "flex flex-col gap-16 pb-[24px]" }, qa = { class: "flex flex-row justify-between items-center gap-2" }, Ha = { class: "flex flex-row gap-2 items-center" }, Xa = { class: "relative group cursor-pointer" }, Ga = { 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" }, Qa = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, Ja = { class: "flex flex-col gap-16" }, Wa = { class: "fm-typo-en-title-sm-800" }, Za = { class: "flex flex-row items-center max-w-[100%]" }, el = { class: "w-[25%]" }, tl = { class: "flex-grow" }, ol = { class: "flex flex-row items-center max-w-[100%]" }, al = { class: "w-[25%]" }, ll = { class: "flex flex-row items-center max-w-[100%]" }, nl = { class: "w-[25%]" }, sl = { class: "flex flex-col gap-16" }, il = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, rl = { class: "grid-cols-1 grid gap-16" }, ml = { class: "flex flex-col gap-16 pt-3 pb-3" }, dl = { class: "flex flex-row items-center gap-5" }, cl = { class: "fm-typo-en-title-sm-800" }, ul = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, pl = { class: "flex flex-row items-center gap-x-16" }, fl = { class: "fm-typo-en-title-sm-800" }, vl = { class: "grid-cols-1 grid gap-16" }, gl = { class: "flex flex-row items-center gap-x-16" }, yl = { class: "fm-typo-en-title-sm-800" }, xl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, _l = { class: "flex flex-row items-center gap-x-16" }, bl = { class: "fm-typo-en-title-sm-800" }, wl = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, hl = /* @__PURE__ */ G({
2220
+ __name: "Setting",
2221
+ props: {
2222
+ modelValue: { required: !0 },
2223
+ modelModifiers: {}
2224
+ },
2225
+ emits: ["update:modelValue"],
2226
+ setup(f) {
2227
+ const { t: o } = Z(), e = W(f, "modelValue"), s = ge(), x = $e(), k = fe(), { promptLoader: _ } = De(), { promptMessage: F } = Ae(), { restaurants: w } = ve(), h = H(
2228
+ () => w.map((l) => ({ label: l.name, value: l.id }))
2229
+ );
2230
+ async function u() {
2231
+ await F({
2232
+ message: o("report.messages.confirmDelete", { name: e.value.name }),
2233
+ title: o("report.common.delete")
2234
+ }) && await _(async () => {
2235
+ try {
2236
+ await Fe(e.value._id), await x.getSettings(), k.back();
2237
+ } catch (i) {
2238
+ s.open({ type: "error", message: i.message });
2239
+ }
2240
+ });
2241
+ }
2242
+ async function b() {
2243
+ await _(async () => {
2244
+ try {
2245
+ await Ue(e.value._id, e.value), await x.getSettings();
2246
+ } catch (l) {
2247
+ s.open({ type: "error", message: l.message });
2248
+ }
2249
+ });
2250
+ }
2251
+ function C(l, i) {
2252
+ var c, a;
2253
+ (a = (c = e.value.platform) == null ? void 0 : c.mappings) != null && a[l] && (e.value.platform.mappings[l] = e.value.platform.mappings[l].filter(
2254
+ (N, A) => A !== i
2255
+ ));
2256
+ }
2257
+ function p(l) {
2258
+ var i, c;
2259
+ (c = (i = e.value.platform) == null ? void 0 : i.mappings) != null && c[l] && (e.value.platform.mappings[l] = [
2260
+ ...e.value.platform.mappings[l],
2261
+ l === "items" ? {
2262
+ key: "",
2263
+ account: "",
2264
+ description: ""
2265
+ } : {
2266
+ key: "",
2267
+ account: "",
2268
+ description: ""
2269
+ }
2270
+ ]);
2271
+ }
2272
+ const v = [
2273
+ {
2274
+ label: "By day",
2275
+ value: be.BY_DAY
2276
+ },
2277
+ {
2278
+ label: "By invoice",
2279
+ value: be.BY_INVOICE
2280
+ },
2281
+ {
2282
+ label: "By day and category",
2283
+ value: be.BY_DAY_CATEGORY
2284
+ }
2285
+ ];
2286
+ function r({
2287
+ key: l,
2288
+ value: i
2289
+ }) {
2290
+ var c, a;
2291
+ (a = (c = e.value) == null ? void 0 : c.platform) != null && a.mappings && (e.value.platform.mappings[l] = i);
2292
+ }
2293
+ function y(l) {
2294
+ return {
2295
+ key: { placeholder: l, editable: !1 },
2296
+ account: { placeholder: l, editable: !0 }
2297
+ };
2298
+ }
2299
+ async function $() {
2300
+ await _(async () => {
2301
+ try {
2302
+ await Te(e.value._id), await x.getSettings();
2303
+ } catch (l) {
2304
+ s.open({ type: "error", message: l.message });
2305
+ }
2306
+ });
2307
+ }
2308
+ return Se(async () => {
2309
+ await x.getSettings();
2310
+ }), (l, i) => {
2311
+ var z, Q, B, q, X, te, oe, ae, le, ne, se, ie, re, me, de, ce, ue;
2312
+ const c = D("FmIcon"), a = D("FmButton"), N = D("FmMenuDivider"), A = D("FmTextField"), j = D("FmSelect");
2313
+ return (Q = (z = e.value) == null ? void 0 : z.platform) != null && Q.mappings ? (d(), S("div", za, [
2314
+ t("div", Ya, [
2315
+ t("div", qa, [
2316
+ i[15] || (i[15] = t("div", { class: "fm-typo-en-title-sm-800" }, null, -1)),
2317
+ t("div", Ha, [
2318
+ t("div", Xa, [
2319
+ n(c, {
2320
+ name: "refresh",
2321
+ class: "p-2 bg-gray-100 rounded-full",
2322
+ onClick: $
2323
+ }),
2324
+ t("span", Ga, V(m(o)("report.integration.refreshSetting")), 1)
2325
+ ]),
2326
+ n(a, {
2327
+ variant: "tertiary",
2328
+ label: m(o)("report.common.delete"),
2329
+ onClick: u
2330
+ }, null, 8, ["label"]),
2331
+ n(a, {
2332
+ variant: "primary",
2333
+ label: m(o)("report.common.update"),
2334
+ onClick: b
2335
+ }, null, 8, ["label"])
2336
+ ])
2337
+ ])
2338
+ ]),
2339
+ n(N, { style: { margin: 0 } }),
2340
+ t("div", Qa, [
2341
+ t("div", Ja, [
2342
+ t("div", Wa, V(m(o)("report.integration.general")), 1),
2343
+ t("div", Za, [
2344
+ t("div", el, V(m(o)("report.common.name")), 1),
2345
+ t("div", tl, [
2346
+ n(A, {
2347
+ modelValue: e.value.name,
2348
+ "onUpdate:modelValue": i[0] || (i[0] = (T) => e.value.name = T)
2349
+ }, null, 8, ["modelValue"])
2350
+ ])
2351
+ ]),
2352
+ t("div", ol, [
2353
+ t("div", al, V(m(o)("report.integration.location")), 1),
2354
+ n(j, {
2355
+ modelValue: e.value.platform.locationIds,
2356
+ "onUpdate:modelValue": i[1] || (i[1] = (T) => e.value.platform.locationIds = T),
2357
+ multiselect: !0,
2358
+ items: h.value,
2359
+ placeholder: "Select location",
2360
+ class: "flex-grow",
2361
+ rules: [(T) => T.length !== 0 || "Please select at least 1 location"]
2362
+ }, null, 8, ["modelValue", "items", "rules"])
2363
+ ]),
2364
+ t("div", ll, [
2365
+ t("div", nl, V(m(o)("report.integration.grouping.title")), 1),
2366
+ n(j, {
2367
+ modelValue: e.value.platform.grouping,
2368
+ "onUpdate:modelValue": i[2] || (i[2] = (T) => e.value.platform.grouping = T),
2369
+ multiselect: !1,
2370
+ items: v,
2371
+ placeholder: "Select grouping",
2372
+ class: "flex-grow"
2373
+ }, null, 8, ["modelValue"])
2374
+ ])
2375
+ ]),
2376
+ t("div", sl, [
2377
+ t("div", il, [
2378
+ n(R, {
2379
+ "model-value": { key: "Debtor", account: e.value.platform.mappings.debtor },
2380
+ options: y("Debtor"),
2381
+ "onUpdate:modelValue": i[3] || (i[3] = (T) => r({ key: "debtor", value: T.account }))
2382
+ }, null, 8, ["model-value", "options"]),
2383
+ n(R, {
2384
+ "model-value": {
2385
+ key: "Project header",
2386
+ account: e.value.platform.mappings.projectHeader
2387
+ },
2388
+ options: y("Project header"),
2389
+ "onUpdate:modelValue": i[4] || (i[4] = (T) => r({ key: "projectHeader", value: T.account }))
2390
+ }, null, 8, ["model-value", "options"]),
2391
+ n(R, {
2392
+ "model-value": {
2393
+ key: "Project detail",
2394
+ account: e.value.platform.mappings.projectDetail
2395
+ },
2396
+ options: y("Project detail"),
2397
+ "onUpdate:modelValue": i[5] || (i[5] = (T) => r({ key: "projectDetail", value: T.account }))
2398
+ }, null, 8, ["model-value", "options"])
2399
+ ]),
2400
+ t("div", rl, [
2401
+ n(R, {
2402
+ "model-value": {
2403
+ key: "Rounding",
2404
+ account: e.value.platform.mappings.rounding.account,
2405
+ code: e.value.platform.mappings.rounding.code
2406
+ },
2407
+ options: {
2408
+ key: { placeholder: "Rounding", editable: !1 },
2409
+ account: { placeholder: "Account code", editable: !0 },
2410
+ code: { placeholder: "Item code", editable: !0 }
2411
+ },
2412
+ "onUpdate:modelValue": i[6] || (i[6] = (T) => {
2413
+ var g, U, L;
2414
+ (L = (U = (g = e.value) == null ? void 0 : g.platform) == null ? void 0 : U.mappings) != null && L.rounding && (e.value.platform.mappings.rounding.account = T.account, e.value.platform.mappings.rounding.code = T.code);
2415
+ })
2416
+ }, null, 8, ["model-value"]),
2417
+ (d(!0), S(O, null, Y((X = (q = (B = e.value) == null ? void 0 : B.platform) == null ? void 0 : q.mappings) == null ? void 0 : X.charges, (T, g) => (d(), M(R, {
2418
+ key: `charge-${g}`,
2419
+ modelValue: e.value.platform.mappings.charges[g],
2420
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.charges[g] = U,
2421
+ options: {
2422
+ key: { placeholder: "Key", editable: !1 },
2423
+ account: { placeholder: "Account code", editable: !0 },
2424
+ code: { placeholder: "Item code", editable: !0 }
2425
+ }
2426
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]))), 128))
2427
+ ])
2428
+ ]),
2429
+ t("div", ml, [
2430
+ t("div", dl, [
2431
+ t("div", cl, V(m(o)("report.integration.refNumFormat")), 1),
2432
+ n(Pe)
2433
+ ]),
2434
+ t("div", ul, [
2435
+ n(R, {
2436
+ "model-value": {
2437
+ key: "Invoice no",
2438
+ account: e.value.platform.mappings.invoiceDocNo
2439
+ },
2440
+ options: y("Invoice no"),
2441
+ "onUpdate:modelValue": i[7] || (i[7] = (T) => r({ key: "invoiceDocNo", value: T.account }))
2442
+ }, null, 8, ["model-value", "options"]),
2443
+ n(R, {
2444
+ "model-value": {
2445
+ key: "Credit note no",
2446
+ account: e.value.platform.mappings.creditNoteDocNo
2447
+ },
2448
+ options: y("Credit note no"),
2449
+ "onUpdate:modelValue": i[8] || (i[8] = (T) => r({ key: "creditNoteDocNo", value: T.account }))
2450
+ }, null, 8, ["model-value", "options"]),
2451
+ n(R, {
2452
+ "model-value": {
2453
+ key: "Payment no",
2454
+ account: e.value.platform.mappings.paymentDocNo
2455
+ },
2456
+ options: y("Payment no"),
2457
+ "onUpdate:modelValue": i[9] || (i[9] = (T) => r({ key: "paymentDocNo", value: T.account }))
2458
+ }, null, 8, ["model-value", "options"]),
2459
+ n(R, {
2460
+ "model-value": {
2461
+ key: "Refund no",
2462
+ account: e.value.platform.mappings.refundDocNo
2463
+ },
2464
+ options: y("Refund no"),
2465
+ "onUpdate:modelValue": i[10] || (i[10] = (T) => r({ key: "refundDocNo", value: T.account }))
2466
+ }, null, 8, ["model-value", "options"])
2467
+ ])
2468
+ ]),
2469
+ n(Re, {
2470
+ modelValue: e.value.platform,
2471
+ "onUpdate:modelValue": i[11] || (i[11] = (T) => e.value.platform = T),
2472
+ label: "email"
2473
+ }, null, 8, ["modelValue"]),
2474
+ t("div", pl, [
2475
+ t("div", fl, V(m(o)("report.integration.items")), 1),
2476
+ n(a, {
2477
+ variant: "primary",
2478
+ icon: "add",
2479
+ onClick: i[12] || (i[12] = () => p("items"))
2480
+ })
2481
+ ]),
2482
+ t("div", vl, [
2483
+ (d(!0), S(O, null, Y((ae = (oe = (te = e.value) == null ? void 0 : te.platform) == null ? void 0 : oe.mappings) == null ? void 0 : ae.items, (T, g) => (d(), M(R, {
2484
+ key: `item-${g}`,
2485
+ modelValue: e.value.platform.mappings.items[g],
2486
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.items[g] = U,
2487
+ options: {
2488
+ key: { placeholder: "Key", editable: !0 },
2489
+ account: { placeholder: "Account code", editable: !0 },
2490
+ code: { placeholder: "Item code", editable: !0 }
2491
+ },
2492
+ removable: !0,
2493
+ onRemove: () => C("items", g)
2494
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2495
+ ]),
2496
+ t("div", gl, [
2497
+ t("div", yl, V(m(o)("report.integration.taxes")), 1),
2498
+ n(a, {
2499
+ variant: "primary",
2500
+ icon: "add",
2501
+ onClick: i[13] || (i[13] = () => p("taxes"))
2502
+ })
2503
+ ]),
2504
+ t("div", xl, [
2505
+ (d(!0), S(O, null, Y((se = (ne = (le = e.value) == null ? void 0 : le.platform) == null ? void 0 : ne.mappings) == null ? void 0 : se.taxes, (T, g) => (d(), M(R, {
2506
+ key: `tax-${g}`,
2507
+ modelValue: e.value.platform.mappings.taxes[g],
2508
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.taxes[g] = U,
2509
+ options: {
2510
+ key: { placeholder: "Key", editable: !0 },
2511
+ account: { placeholder: "Account code", editable: !0 }
2512
+ },
2513
+ removable: !0,
2514
+ onRemove: () => C("taxes", g)
2515
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128)),
2516
+ (d(!0), S(O, null, Y((me = (re = (ie = e.value) == null ? void 0 : ie.platform) == null ? void 0 : re.mappings) == null ? void 0 : me.taxRoundingAdjustments, (T, g) => (d(), M(R, {
2517
+ key: `tax-rounding-adjustment-${g}`,
2518
+ modelValue: e.value.platform.mappings.taxRoundingAdjustments[g],
2519
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.taxRoundingAdjustments[g] = U,
2520
+ options: {
2521
+ key: { placeholder: "Key", editable: !0 },
2522
+ account: { placeholder: "Account code", editable: !0 }
2523
+ },
2524
+ removable: !0,
2525
+ onRemove: () => C("taxRoundingAdjustments", g)
2526
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2527
+ ]),
2528
+ t("div", _l, [
2529
+ t("div", bl, V(m(o)("report.integration.payments")), 1),
2530
+ n(a, {
2531
+ variant: "primary",
2532
+ icon: "add",
2533
+ onClick: i[14] || (i[14] = () => p("payments"))
2534
+ })
2535
+ ]),
2536
+ t("div", wl, [
2537
+ (d(!0), S(O, null, Y((ue = (ce = (de = e.value) == null ? void 0 : de.platform) == null ? void 0 : ce.mappings) == null ? void 0 : ue.payments, (T, g) => (d(), M(R, {
2538
+ key: `payment-${g}`,
2539
+ modelValue: e.value.platform.mappings.payments[g],
2540
+ "onUpdate:modelValue": (U) => e.value.platform.mappings.payments[g] = U,
2541
+ options: {
2542
+ key: { placeholder: "Key", editable: !0 },
2543
+ account: { placeholder: "Method", editable: !0 }
2544
+ },
2545
+ removable: !0,
2546
+ onRemove: () => C("payments", g)
2547
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
2548
+ ])
2549
+ ])
2550
+ ])) : P("", !0);
2551
+ };
2552
+ }
2553
+ }), Vl = { class: "h-full flex flex-col gap-16" }, kl = { class: "flex flex-row gap-2 justify-between items-center" }, $l = {
2554
+ key: 0,
2555
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
2556
+ }, Cl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Sl = /* @__PURE__ */ G({
2557
+ __name: "Preview",
2558
+ props: {
2559
+ modelValue: { required: !0 },
2560
+ modelModifiers: {}
2561
+ },
2562
+ emits: ["update:modelValue"],
2563
+ setup(f) {
2564
+ const { t: o } = Z(), e = E([]), s = H(
2565
+ () => e.value.reduce((u, b) => {
2566
+ const C = u.length, { invoice: p, payments: v } = b;
2567
+ u[C] = {
2568
+ date: p.DocDate,
2569
+ docNo: p.DocNo,
2570
+ debtor: p.Code,
2571
+ description: p.Description_HDR
2572
+ };
2573
+ for (let r = 0; r < Math.max(p._items.length, v.length); r++) {
2574
+ const y = C + r;
2575
+ u[y] || (u[y] = {}), p._items[r] && (u[y] = {
2576
+ ...u[y],
2577
+ itemDescription: p._items[r].Description_DTL,
2578
+ itemUnitPrice: p._items[r].UnitPrice,
2579
+ itemAccount: p._items[r].ACCOUNT,
2580
+ itemTaxCode: p._items[r].Tax,
2581
+ itemTax: p._items[r].TaxAmt
2582
+ }), v[r] && (u[y] = {
2583
+ ...u[y],
2584
+ paymentDocNo: v[r].DOCNO_Header,
2585
+ paymentMethod: v[r].PAYMENTMETHOD,
2586
+ paymentAccount: v[r].CODE,
2587
+ paymentDescription: v[r].DESCRIPTION,
2588
+ paymentAmount: v[r].KOAMT
2589
+ });
2590
+ }
2591
+ return u;
2592
+ }, [])
2593
+ ), x = [
2594
+ {
2595
+ accessorKey: "date",
2596
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
2597
+ enableSorting: !1
2598
+ },
2599
+ {
2600
+ accessorKey: "docNo",
2601
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Doc No"),
2602
+ enableSorting: !1
2603
+ },
2604
+ {
2605
+ accessorKey: "debtor",
2606
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Debtor"),
2607
+ enableSorting: !1
2608
+ },
2609
+ {
2610
+ accessorKey: "description",
2611
+ header: "Description",
2612
+ enableSorting: !1
2613
+ },
2614
+ {
2615
+ accessorKey: "itemAccount",
2616
+ header: () => K("p", { class: "min-w-[100px] text-nowrap text-ellipsis" }, "Item Account"),
2617
+ enableSorting: !1
2618
+ },
2619
+ {
2620
+ accessorKey: "itemTaxCode",
2621
+ header: "Item Tax Code",
2622
+ enableSorting: !1
2623
+ },
2624
+ {
2625
+ accessorKey: "itemDescription",
2626
+ header: () => K("p", { class: "min-w-[140px] text-nowrap text-ellipsis" }, "Item Description"),
2627
+ enableSorting: !1
2628
+ },
2629
+ {
2630
+ accessorKey: "itemUnitPrice",
2631
+ header: "Item Unit Price",
2632
+ enableSorting: !1
2633
+ },
2634
+ {
2635
+ accessorKey: "itemTax",
2636
+ header: "Item Tax",
2637
+ enableSorting: !1
2638
+ },
2639
+ {
2640
+ accessorKey: "paymentDocNo",
2641
+ header: "Payment Doc No",
2642
+ enableSorting: !1
2643
+ },
2644
+ {
2645
+ accessorKey: "paymentMethod",
2646
+ header: "Payment Method",
2647
+ enableSorting: !1
2648
+ },
2649
+ {
2650
+ accessorKey: "paymentDescription",
2651
+ header: "Payment Description",
2652
+ enableSorting: !1
2653
+ },
2654
+ {
2655
+ accessorKey: "paymentAmount",
2656
+ header: "Payment Amount",
2657
+ enableSorting: !1
2658
+ }
2659
+ ], k = W(f, "modelValue"), _ = E(!1), F = ge(), { dateRange: w } = Ke(ve());
2660
+ _e(
2661
+ () => w.value,
2662
+ async () => {
2663
+ if (k.value._id)
2664
+ try {
2665
+ _.value = !0, e.value = await Ne(k.value._id);
2666
+ } catch (u) {
2667
+ F.open({ message: u.message, type: "error" });
2668
+ } finally {
2669
+ _.value = !1;
2670
+ }
2671
+ },
2672
+ {
2673
+ immediate: !0
2674
+ }
2675
+ );
2676
+ async function h() {
2677
+ try {
2678
+ k.value._id ? (_.value = !0, await Le(k.value._id)) : F.open({ message: "Invalid accounting setting", type: "error" });
2679
+ } catch (u) {
2680
+ F.open({ message: u.message, type: "error" });
2681
+ } finally {
2682
+ _.value = !1;
2683
+ }
2684
+ }
2685
+ return (u, b) => {
2686
+ const C = D("FmButton"), p = D("FmCircularProgress"), v = D("FmTable");
2687
+ return d(), S("div", Vl, [
2688
+ t("div", kl, [
2689
+ n(Ie, {
2690
+ "date-range": m(w),
2691
+ "onUpdate:dateRange": b[0] || (b[0] = (r) => Ve(w) ? w.value = r : null),
2692
+ compare: !1
2693
+ }, null, 8, ["date-range"]),
2694
+ n(C, {
2695
+ loading: _.value,
2696
+ variant: "primary",
2697
+ label: m(o)("report.common.download"),
2698
+ onClick: h
2699
+ }, null, 8, ["loading", "label"])
2700
+ ]),
2701
+ _.value ? (d(), S("div", $l, [
2702
+ n(p, { size: "xl" }),
2703
+ t("span", Cl, V(m(o)("report.common.isLoading")), 1)
2704
+ ])) : s.value.length > 0 ? (d(), M(v, {
2705
+ key: 1,
2706
+ class: "flex overflow-y-auto",
2707
+ "row-data": s.value,
2708
+ "column-defs": x
2709
+ }, null, 8, ["row-data"])) : P("", !0)
2710
+ ]);
2711
+ };
2712
+ }
2713
+ }), Dl = { class: "h-full relative flex flex-col" }, Fl = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, Ul = /* @__PURE__ */ G({
2714
+ __name: "SQL",
2715
+ props: {
2716
+ modelValue: {},
2717
+ modelModifiers: {}
2718
+ },
2719
+ emits: ["update:modelValue"],
2720
+ setup(f) {
2721
+ const { t: o } = Z(), e = W(f, "modelValue"), s = E("setting"), x = [
2722
+ {
2723
+ label: o("report.integration.setting"),
2724
+ value: "setting",
2725
+ icon: "settings"
2726
+ },
2727
+ {
2728
+ label: o("report.integration.preview"),
2729
+ value: "preview",
2730
+ icon: "table"
2731
+ }
2732
+ ], k = fe(), _ = H(() => {
2733
+ switch (s.value) {
2734
+ case "preview":
2735
+ return Sl;
2736
+ case "setting":
2737
+ return hl;
2738
+ default:
2739
+ return null;
2740
+ }
2741
+ });
2742
+ return (F, w) => {
2743
+ var b;
2744
+ const h = D("FmPageHead"), u = D("FmTabs");
2745
+ return d(), S("div", Dl, [
2746
+ n(h, {
2747
+ title: ((b = e.value) == null ? void 0 : b.name) || "SQL",
2748
+ "back-button": !0,
2749
+ style: { paddingLeft: "0px", paddingRight: "0px" },
2750
+ "onClick:back": m(k).back
2751
+ }, {
2752
+ description: we(() => w[2] || (w[2] = [
2753
+ t("div", null, null, -1)
2754
+ ])),
2755
+ _: 1
2756
+ }, 8, ["title", "onClick:back"]),
2757
+ n(u, {
2758
+ "model-value": s.value,
2759
+ "onUpdate:modelValue": w[0] || (w[0] = (C) => s.value = C),
2760
+ items: x
2761
+ }, null, 8, ["model-value"]),
2762
+ t("div", Fl, [
2763
+ (d(), M(ke(_.value), {
2764
+ modelValue: e.value,
2765
+ "onUpdate:modelValue": w[1] || (w[1] = (C) => e.value = C)
2766
+ }, null, 8, ["modelValue"]))
2767
+ ])
2768
+ ]);
2769
+ };
2770
+ }
2771
+ }), Tl = {
2772
+ key: 0,
2773
+ class: "flex flex-col h-full"
2774
+ }, Nl = { class: "flex flex-col gap-16 pb-[24px]" }, Al = { class: "flex flex-row justify-between items-center gap-2" }, Kl = { class: "fm-typo-en-title-sm-800" }, Il = { class: "flex flex-row gap-2 items-center" }, Rl = { class: "flex flex-row gap-2 items-center" }, Ml = { class: "relative group cursor-pointer" }, Pl = { 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" }, jl = { class: "flex flex-col gap-24 pt-[24px] overflow-y-auto overflow-x-hidden" }, Ll = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bl = { class: "flex flex-row items-center max-w-[100%]" }, Ol = { class: "w-[25%]" }, El = { class: "flex-grow" }, zl = { class: "flex flex-col gap-24 pt-[24px] overflow-y-auto overflow-x-hidden" }, Yl = { class: "flex flex-row items-center justify-between" }, ql = { class: "w-[25%]" }, Hl = { class: "flex-grow" }, Xl = { class: "flex flex-row items-center justify-between" }, Gl = { class: "w-[25%]" }, Ql = { class: "flex-grow" }, Jl = { class: "flex flex-col gap-16" }, Wl = { class: "fm-typo-en-title-sm-800" }, Zl = { class: "flex flex-row items-center max-w-[100%]" }, en = { class: "w-[25%]" }, tn = { class: "flex-grow" }, on = { class: "flex flex-row items-center max-w-[100%]" }, an = { class: "w-[25%]" }, ln = { class: "flex flex-row items-center max-w-[100%]" }, nn = { class: "w-[25%]" }, sn = {
2775
+ key: 0,
2776
+ class: "flex flex-row items-center max-w-[100%]"
2777
+ }, rn = { class: "flex flex-col gap-16" }, mn = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, dn = { key: 1 }, cn = { class: "flex flex-col gap-16 pt-3 pb-3" }, un = { class: "flex flex-row items-center gap-5" }, pn = { class: "fm-typo-en-title-sm-800" }, fn = { class: "flex flex-row items-center max-w-[100%]" }, vn = { class: "flex-grow" }, gn = { class: "flex flex-row items-center max-w-[100%]" }, yn = { class: "flex-grow" }, xn = { class: "flex flex-row items-center gap-x-16" }, _n = { class: "fm-typo-en-title-sm-800" }, bn = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, wn = { class: "flex flex-row items-center gap-x-16" }, hn = { class: "fm-typo-en-title-sm-800" }, Vn = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, kn = { class: "flex flex-row items-center gap-x-16" }, $n = { class: "fm-typo-en-title-sm-800" }, Cn = { class: "flex flex-row items-center justify-between" }, Sn = { class: "flex-grow" }, Dn = {
2778
+ key: 0,
2779
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2780
+ }, Fn = {
2781
+ key: 1,
2782
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2783
+ }, Un = {
2784
+ key: 3,
2785
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2786
+ }, Tn = {
2787
+ key: 0,
2788
+ class: "flex flex-row items-center"
2789
+ }, Nn = /* @__PURE__ */ G({
2790
+ __name: "Setting",
2791
+ props: /* @__PURE__ */ he({
2792
+ retrievedMethods: {
2793
+ type: Object,
2794
+ required: !0
2795
+ },
2796
+ retrievedCustomers: {
2797
+ type: Object,
2798
+ required: !0
2799
+ }
2800
+ }, {
2801
+ modelValue: { required: !0 },
2802
+ modelModifiers: {}
2803
+ }),
2804
+ emits: ["update:modelValue"],
2805
+ setup(f) {
2806
+ const { t: o } = Z(), e = W(f, "modelValue"), s = ge(), x = $e(), k = fe(), { promptLoader: _ } = De(), { promptMessage: F } = Ae(), { restaurants: w } = ve(), h = H(
2807
+ () => w.map(($) => ({ label: $.name, value: $.id }))
2808
+ );
2809
+ function u($) {
2810
+ var l;
2811
+ !((l = f.retrievedMethods) != null && l.data) || !Array.isArray(f.retrievedMethods.data) || $.forEach((i) => {
2812
+ const c = f.retrievedMethods.data.find((a) => a.value == i.id);
2813
+ c && (i.cnId = c.cnId);
2814
+ });
2815
+ }
2816
+ async function b() {
2817
+ await F({
2818
+ message: o("report.messages.confirmDelete", { name: e.value.name }),
2819
+ title: o("report.common.delete")
2820
+ }) && await _(async () => {
2821
+ try {
2822
+ await Fe(e.value._id), await x.getSettings(), k.back();
2823
+ } catch (l) {
2824
+ s.open({ type: "error", message: l.message });
2825
+ }
2826
+ });
2827
+ }
2828
+ async function C() {
2829
+ await _(async () => {
2830
+ var $, l, i;
2831
+ try {
2832
+ (i = (l = ($ = e.value) == null ? void 0 : $.platform) == null ? void 0 : l.mappings) != null && i.paymentMethods && u(e.value.platform.mappings.paymentMethods), await Ue(e.value._id, e.value), await x.getSettings();
2833
+ } catch (c) {
2834
+ s.open({ type: "error", message: c.message });
2835
+ }
2836
+ });
2837
+ }
2838
+ function p($, l) {
2839
+ var i, c;
2840
+ (c = (i = e.value.platform) == null ? void 0 : i.mappings) != null && c[$] && (e.value.platform.mappings[$] = e.value.platform.mappings[$].filter(
2841
+ (a, N) => N !== l
2842
+ ));
2843
+ }
2844
+ function v($) {
2845
+ var l, i;
2846
+ (i = (l = e.value.platform) == null ? void 0 : l.mappings) != null && i[$] && (e.value.platform.mappings[$] = [
2847
+ ...e.value.platform.mappings[$],
2848
+ $ === "items" ? {
2849
+ key: "",
2850
+ account: "",
2851
+ description: ""
2852
+ } : $ === "taxes" ? {
2853
+ key: "",
2854
+ account: "SST-"
2855
+ } : {
2856
+ key: "",
2857
+ account: ""
2858
+ }
2859
+ ]);
2860
+ }
2861
+ const r = [
2862
+ {
2863
+ label: "By day",
2864
+ value: be.BY_DAY
2865
+ }
2866
+ ];
2867
+ _e(
2868
+ () => {
2869
+ var $, l, i;
2870
+ return (i = (l = ($ = e.value) == null ? void 0 : $.platform) == null ? void 0 : l.mappings) == null ? void 0 : i.taxes;
2871
+ },
2872
+ ($) => {
2873
+ $ && $.forEach((l, i) => {
2874
+ var N;
2875
+ const c = l.key || "";
2876
+ let a = l.account;
2877
+ if (!a && c) {
2878
+ switch (c) {
2879
+ case "SST_SV":
2880
+ a = "SST-6";
2881
+ break;
2882
+ case "SST_SV8":
2883
+ a = "SST-8";
2884
+ break;
2885
+ case "SST_EX":
2886
+ a = "SST-0";
2887
+ break;
2888
+ }
2889
+ (N = e.value.platform) != null && N.mappings && (e.value.platform.mappings.taxes[i] = {
2890
+ ...l,
2891
+ account: a
2892
+ });
2893
+ }
2894
+ });
2895
+ },
2896
+ { immediate: !0, deep: !0 }
2897
+ ), _e(
2898
+ () => {
2899
+ var $, l, i;
2900
+ return (i = (l = ($ = e.value) == null ? void 0 : $.platform) == null ? void 0 : l.mappings) == null ? void 0 : i.version;
2901
+ },
2902
+ ($) => {
2903
+ var l, i, c, a, N;
2904
+ $ === "v1" && !((c = (i = (l = e.value) == null ? void 0 : l.platform) == null ? void 0 : i.mappings) != null && c.payee) && (N = (a = e.value) == null ? void 0 : a.platform) != null && N.mappings && (e.value.platform.mappings.payee = {
2905
+ id: 1,
2906
+ name: ""
2907
+ });
2908
+ },
2909
+ { immediate: !0 }
2910
+ );
2911
+ async function y() {
2912
+ await _(async () => {
2913
+ try {
2914
+ await Te(e.value._id), await x.getSettings();
2915
+ } catch ($) {
2916
+ s.open({ type: "error", message: $.message });
2917
+ }
2918
+ });
2919
+ }
2920
+ return Se(async () => {
2921
+ await x.getSettings();
2922
+ }), ($, l) => {
2923
+ var Q, B, q, X, te, oe, ae, le, ne, se, ie, re, me, de, ce, ue, T;
2924
+ const i = D("FmIcon"), c = D("FmButton"), a = D("FmSelect"), N = D("FmMenuDivider"), A = D("FmTextField"), j = D("FmCircularProgress"), z = D("FmCheckbox");
2925
+ return (B = (Q = e.value) == null ? void 0 : Q.platform) != null && B.mappings ? (d(), S("div", Tl, [
2926
+ t("div", Nl, [
2927
+ t("div", Al, [
2928
+ t("div", Kl, V(m(o)("report.integration.connect")), 1),
2929
+ t("div", Il, [
2930
+ t("div", Rl, [
2931
+ t("div", Ml, [
2932
+ n(i, {
2933
+ name: "refresh",
2934
+ class: "p-2 bg-gray-100 rounded-full",
2935
+ onClick: y
2936
+ }),
2937
+ t("span", Pl, V(m(o)("report.integration.refreshSetting")), 1)
2938
+ ]),
2939
+ n(c, {
2940
+ variant: "tertiary",
2941
+ label: m(o)("report.common.delete"),
2942
+ onClick: b
2943
+ }, null, 8, ["label"]),
2944
+ n(c, {
2945
+ variant: "primary",
2946
+ label: m(o)("report.common.update"),
2947
+ onClick: C
2948
+ }, null, 8, ["label"])
2949
+ ])
2950
+ ])
2951
+ ])
2952
+ ]),
2953
+ t("div", jl, [
2954
+ t("div", Ll, V(m(o)("report.integration.biztory.authenticate")), 1),
2955
+ t("div", Bl, [
2956
+ t("div", Ol, "Biztory " + V(m(o)("report.integration.biztory.version")), 1),
2957
+ t("div", El, [
2958
+ n(a, {
2959
+ modelValue: e.value.platform.mappings.version,
2960
+ "onUpdate:modelValue": l[0] || (l[0] = (g) => e.value.platform.mappings.version = g),
2961
+ items: [
2962
+ { label: "v1", value: "v1" },
2963
+ { label: "v2", value: "v2" }
2964
+ ],
2965
+ placeholder: "Select Version"
2966
+ }, null, 8, ["modelValue"])
2967
+ ])
2968
+ ]),
2969
+ n(N, { style: { margin: 0 } }),
2970
+ t("div", zl, [
2971
+ t("div", Yl, [
2972
+ t("div", ql, V(m(o)("report.integration.biztory.subdomain")), 1),
2973
+ t("div", Hl, [
2974
+ n(A, {
2975
+ modelValue: e.value.platform.subdomain,
2976
+ "onUpdate:modelValue": l[1] || (l[1] = (g) => e.value.platform.subdomain = g),
2977
+ placeholder: "Subdomain"
2978
+ }, null, 8, ["modelValue"])
2979
+ ])
2980
+ ]),
2981
+ t("div", Xl, [
2982
+ t("div", Gl, V(m(o)("report.integration.biztory.apiKey")), 1),
2983
+ t("div", Ql, [
2984
+ n(A, {
2985
+ modelValue: e.value.platform.api_key,
2986
+ "onUpdate:modelValue": l[2] || (l[2] = (g) => e.value.platform.api_key = g),
2987
+ placeholder: "API Key"
2988
+ }, null, 8, ["modelValue"])
2989
+ ])
2990
+ ]),
2991
+ t("div", Jl, [
2992
+ t("div", Wl, V(m(o)("report.integration.general")), 1),
2993
+ t("div", Zl, [
2994
+ t("div", en, V(m(o)("report.common.name")), 1),
2995
+ t("div", tn, [
2996
+ n(A, {
2997
+ modelValue: e.value.name,
2998
+ "onUpdate:modelValue": l[3] || (l[3] = (g) => e.value.name = g)
2999
+ }, null, 8, ["modelValue"])
3000
+ ])
3001
+ ]),
3002
+ t("div", on, [
3003
+ t("div", an, V(m(o)("report.common.location")), 1),
3004
+ n(a, {
3005
+ modelValue: e.value.platform.locationIds,
3006
+ "onUpdate:modelValue": l[4] || (l[4] = (g) => e.value.platform.locationIds = g),
3007
+ multiselect: !0,
3008
+ items: h.value,
3009
+ placeholder: m(o)("report.common.location"),
3010
+ class: "flex-grow"
3011
+ }, null, 8, ["modelValue", "items", "placeholder"])
3012
+ ]),
3013
+ t("div", ln, [
3014
+ t("div", nn, V(m(o)("report.integration.grouping.title")), 1),
3015
+ n(a, {
3016
+ modelValue: e.value.platform.grouping,
3017
+ "onUpdate:modelValue": l[5] || (l[5] = (g) => e.value.platform.grouping = g),
3018
+ multiselect: !1,
3019
+ items: r,
3020
+ placeholder: m(o)("report.integration.grouping.title"),
3021
+ class: "flex-grow",
3022
+ disabled: ""
3023
+ }, null, 8, ["modelValue", "placeholder"])
3024
+ ]),
3025
+ e.value.platform.mappings.version == "v1" ? (d(), S("div", sn, [
3026
+ l[15] || (l[15] = t("div", { class: "w-[33%]" }, "Payee ID", -1)),
3027
+ e.value.platform.mappings.version == "v1" ? (d(), M(R, {
3028
+ key: 0,
3029
+ modelValue: e.value.platform.mappings.payee,
3030
+ "onUpdate:modelValue": l[6] || (l[6] = (g) => e.value.platform.mappings.payee = g),
3031
+ options: {
3032
+ id: { placeholder: "ID", editable: !0 }
3033
+ },
3034
+ removable: !1
3035
+ }, null, 8, ["modelValue"])) : P("", !0)
3036
+ ])) : P("", !0),
3037
+ t("div", rn, [
3038
+ t("div", mn, [
3039
+ !f.retrievedCustomers.isLoaded && e.value.platform.mappings.version == "v2" ? (d(), M(j, {
3040
+ key: 0,
3041
+ size: "xl"
3042
+ })) : P("", !0),
3043
+ f.retrievedCustomers.isLoaded && f.retrievedCustomers.data && ((q = f.retrievedCustomers.data) == null ? void 0 : q.length) != 0 ? (d(), S("div", dn, [
3044
+ e.value.platform.mappings.version == "v2" ? (d(), M(Me, {
3045
+ key: 0,
3046
+ modelValue: e.value.platform.mappings.payeeId,
3047
+ "onUpdate:modelValue": l[7] || (l[7] = (g) => e.value.platform.mappings.payeeId = g),
3048
+ options: {
3049
+ key: { placeholder: "Payee", editable: !1 },
3050
+ customer: {
3051
+ placeholder: "Select payee",
3052
+ editable: !0,
3053
+ dropdownOptions: ((X = f.retrievedCustomers) == null ? void 0 : X.data) ?? []
3054
+ }
3055
+ },
3056
+ removable: !1,
3057
+ "single-value-mode": ""
3058
+ }, null, 8, ["modelValue", "options"])) : P("", !0)
3059
+ ])) : P("", !0)
3060
+ ])
3061
+ ])
3062
+ ]),
3063
+ t("div", cn, [
3064
+ t("div", un, [
3065
+ t("div", pn, V(m(o)("report.integration.refNumFormat")), 1),
3066
+ n(Pe)
3067
+ ]),
3068
+ t("div", fn, [
3069
+ l[16] || (l[16] = t("div", { class: "w-[25%]" }, V("Invoice no"), -1)),
3070
+ t("div", vn, [
3071
+ n(A, {
3072
+ modelValue: e.value.platform.mappings.invoiceDocNo,
3073
+ "onUpdate:modelValue": l[8] || (l[8] = (g) => e.value.platform.mappings.invoiceDocNo = g)
3074
+ }, null, 8, ["modelValue"])
3075
+ ])
3076
+ ]),
3077
+ t("div", gn, [
3078
+ l[17] || (l[17] = t("div", { class: "w-[25%]" }, V("Credit no"), -1)),
3079
+ t("div", yn, [
3080
+ n(A, {
3081
+ modelValue: e.value.platform.mappings.creditNoteDocNo,
3082
+ "onUpdate:modelValue": l[9] || (l[9] = (g) => e.value.platform.mappings.creditNoteDocNo = g)
3083
+ }, null, 8, ["modelValue"])
3084
+ ])
3085
+ ])
3086
+ ]),
3087
+ n(Re, {
3088
+ modelValue: e.value.platform,
3089
+ "onUpdate:modelValue": l[10] || (l[10] = (g) => e.value.platform = g),
3090
+ label: "upload",
3091
+ "last-upload-date": (te = e.value.platform) == null ? void 0 : te.lastUploadDate
3092
+ }, null, 8, ["modelValue", "last-upload-date"]),
3093
+ t("div", xn, [
3094
+ t("div", _n, V(m(o)("report.integration.biztory.items")), 1),
3095
+ n(c, {
3096
+ variant: "primary",
3097
+ icon: "add",
3098
+ onClick: l[11] || (l[11] = () => v("items"))
3099
+ })
3100
+ ]),
3101
+ t("div", bn, [
3102
+ (d(!0), S(O, null, Y((le = (ae = (oe = e.value) == null ? void 0 : oe.platform) == null ? void 0 : ae.mappings) == null ? void 0 : le.items, (g, U) => (d(), M(R, {
3103
+ key: `item-${U}`,
3104
+ modelValue: e.value.platform.mappings.items[U],
3105
+ "onUpdate:modelValue": (L) => e.value.platform.mappings.items[U] = L,
3106
+ options: {
3107
+ key: { placeholder: "Key", editable: !0 },
3108
+ code: { placeholder: "Account code", editable: !0 }
3109
+ },
3110
+ removable: !0,
3111
+ onRemove: () => p("items", U)
3112
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
3113
+ ]),
3114
+ t("div", wn, [
3115
+ t("div", hn, V(m(o)("report.integration.biztory.taxes")), 1),
3116
+ n(c, {
3117
+ variant: "primary",
3118
+ icon: "add",
3119
+ onClick: l[12] || (l[12] = () => v("taxes"))
3120
+ })
3121
+ ]),
3122
+ t("div", Vn, [
3123
+ (d(!0), S(O, null, Y((ie = (se = (ne = e.value) == null ? void 0 : ne.platform) == null ? void 0 : se.mappings) == null ? void 0 : ie.taxes, (g, U) => (d(), M(R, {
3124
+ key: `tax-${U}`,
3125
+ modelValue: e.value.platform.mappings.taxes[U],
3126
+ "onUpdate:modelValue": (L) => e.value.platform.mappings.taxes[U] = L,
3127
+ options: {
3128
+ key: { placeholder: "Key", editable: !0 },
3129
+ account: { placeholder: "Account code", editable: !0 }
3130
+ },
3131
+ removable: !0,
3132
+ onRemove: () => p("taxes", U)
3133
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128)),
3134
+ (d(!0), S(O, null, Y((de = (me = (re = e.value) == null ? void 0 : re.platform) == null ? void 0 : me.mappings) == null ? void 0 : de.taxRoundingAdjustments, (g, U) => (d(), M(R, {
3135
+ key: `tax-rounding-adjustment-${U}`,
3136
+ modelValue: e.value.platform.mappings.taxRoundingAdjustments[U],
3137
+ "onUpdate:modelValue": (L) => e.value.platform.mappings.taxRoundingAdjustments[U] = L,
3138
+ options: {
3139
+ key: { placeholder: "Key", editable: !0 },
3140
+ account: { placeholder: "Account code", editable: !0 }
3141
+ },
3142
+ removable: !0,
3143
+ onRemove: () => p("taxRoundingAdjustments", U)
3144
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
3145
+ ]),
3146
+ t("div", kn, [
3147
+ t("div", $n, V(m(o)("report.integration.biztory.payments")), 1),
3148
+ n(c, {
3149
+ variant: "primary",
3150
+ icon: "add",
3151
+ onClick: l[13] || (l[13] = () => v("paymentMethods"))
3152
+ })
3153
+ ]),
3154
+ t("div", Cn, [
3155
+ l[18] || (l[18] = t("div", { class: "w-[25%]" }, "Payment Term", -1)),
3156
+ t("div", Sn, [
3157
+ n(R, {
3158
+ modelValue: e.value.platform.mappings.paymentTerm,
3159
+ "onUpdate:modelValue": l[14] || (l[14] = (g) => e.value.platform.mappings.paymentTerm = g),
3160
+ options: {
3161
+ id: { placeholder: "ID", editable: !0 },
3162
+ name: { placeholder: "Name", editable: !0 }
3163
+ },
3164
+ removable: !1
3165
+ }, null, 8, ["modelValue"])
3166
+ ])
3167
+ ]),
3168
+ f.retrievedMethods.isError ? P("", !0) : (d(), S("div", Dn, V(m(o)("report.integration.biztory.paymentTerm")), 1)),
3169
+ f.retrievedMethods.isLoaded && f.retrievedMethods.data && f.retrievedMethods.data.length == 0 && !f.retrievedMethods.isError ? (d(), S("span", Fn, V(m(o)("report.integration.biztory.noPaymentMethods")), 1)) : P("", !0),
3170
+ f.retrievedMethods.isLoaded ? P("", !0) : (d(), M(j, {
3171
+ key: 2,
3172
+ size: "xl"
3173
+ })),
3174
+ f.retrievedMethods.isError ? (d(), S("span", Un, V(m(o)("report.integration.biztory.error")), 1)) : P("", !0),
3175
+ (d(!0), S(O, null, Y((T = (ue = (ce = e.value) == null ? void 0 : ce.platform) == null ? void 0 : ue.mappings) == null ? void 0 : T.paymentMethods, (g, U) => {
3176
+ var L;
3177
+ return d(), S("div", {
3178
+ key: `payment-${U}`,
3179
+ class: "grid-cols-1 grid gap-x-16"
3180
+ }, [
3181
+ f.retrievedMethods.isLoaded && f.retrievedMethods.data && ((L = f.retrievedMethods.data) == null ? void 0 : L.length) != 0 ? (d(), S("div", Tn, [
3182
+ n(z, {
3183
+ "model-value": !e.value.platform.mappings.paymentMethods[U].skip,
3184
+ value: "",
3185
+ "onUpdate:modelValue": (I) => {
3186
+ var J, ye;
3187
+ (ye = (J = e.value.platform) == null ? void 0 : J.mappings) != null && ye.paymentMethods[U] && (e.value.platform.mappings.paymentMethods[U].skip = !I);
3188
+ }
3189
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
3190
+ n(Me, {
3191
+ modelValue: e.value.platform.mappings.paymentMethods[U],
3192
+ "onUpdate:modelValue": (I) => e.value.platform.mappings.paymentMethods[U] = I,
3193
+ options: {
3194
+ key: {
3195
+ placeholder: "Enter key",
3196
+ editable: !0
3197
+ },
3198
+ id: {
3199
+ placeholder: "Select mapping",
3200
+ editable: !0,
3201
+ dropdownOptions: f.retrievedMethods.data
3202
+ }
3203
+ },
3204
+ removable: !0,
3205
+ onRemove: () => p("paymentMethods", U)
3206
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"])
3207
+ ])) : P("", !0)
3208
+ ]);
3209
+ }), 128))
3210
+ ])
3211
+ ])
3212
+ ])) : P("", !0);
3213
+ };
3214
+ }
3215
+ });
3216
+ function An(f) {
3217
+ return f.reduce((o, e) => {
3218
+ var k, _, F, w, h, u, b, C, p, v, r, y, $, l, i, c, a, N, A, j, z, Q;
3219
+ const { invoice: s } = e, x = o.length;
3220
+ o[x] = {
3221
+ invoice_date: s.invoice_date,
3222
+ ref_num: s.ref_num,
3223
+ grandTotal: s.grandTotal,
3224
+ // tax_code: invoice.tax[0].tax_code,
3225
+ // tax: invoice.tax.reduce((sum, tax) => sum + tax.tax, 0),
3226
+ // service_charge: invoice.service_charge.total,
3227
+ item_code: (k = s.items[0]) == null ? void 0 : k.code,
3228
+ item_desc: (_ = s.items[0]) == null ? void 0 : _.description,
3229
+ item_price: (F = s.items[0]) == null ? void 0 : F.price,
3230
+ item_tax: (w = s.items[0]) == null ? void 0 : w.total_tax,
3231
+ item_tax_label: ((h = s.items[0]) == null ? void 0 : h.tax_label) || "-",
3232
+ payment_amount: ((b = (u = s.transactions) == null ? void 0 : u[0]) == null ? void 0 : b.amount) || void 0,
3233
+ payment_method: ((p = (C = s.transactions) == null ? void 0 : C[0]) == null ? void 0 : p.payment_method) || "-",
3234
+ payment_term: ((v = s == null ? void 0 : s.payment_term) == null ? void 0 : v.name) || ""
3235
+ };
3236
+ for (let B = 1; B < Math.max(((r = s.items) == null ? void 0 : r.length) || 0, ((y = s.transactions) == null ? void 0 : y.length) || 0); B++) {
3237
+ const q = x + B;
3238
+ o[q] || (o[q] = {});
3239
+ const X = s.items[B];
3240
+ X ? o[q] = {
3241
+ ...o[q],
3242
+ item_code: X.code,
3243
+ item_desc: X.description,
3244
+ item_price: X.price,
3245
+ item_tax: X.total_tax,
3246
+ item_tax_label: X.tax_label || "-",
3247
+ payment_amount: ((l = ($ = s.transactions) == null ? void 0 : $[B]) == null ? void 0 : l.amount) || void 0,
3248
+ payment_method: ((c = (i = s.transactions) == null ? void 0 : i[B]) == null ? void 0 : c.payment_method) || "-",
3249
+ payment_term: ((a = s == null ? void 0 : s.payment_term) == null ? void 0 : a.name) || ""
3250
+ } : o[q] = {
3251
+ payment_amount: ((A = (N = s.transactions) == null ? void 0 : N[B]) == null ? void 0 : A.amount) || void 0,
3252
+ payment_method: ((z = (j = s.transactions) == null ? void 0 : j[B]) == null ? void 0 : z.payment_method) || "-",
3253
+ payment_term: ((Q = s == null ? void 0 : s.payment_term) == null ? void 0 : Q.name) || ""
3254
+ };
3255
+ }
3256
+ return o;
3257
+ }, []);
3258
+ }
3259
+ const Kn = [
3260
+ {
3261
+ accessorKey: "invoice_date",
3262
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
3263
+ enableSorting: !1
3264
+ },
3265
+ {
3266
+ accessorKey: "ref_num",
3267
+ header: () => K("p", { class: "min-w-[130px] text-nowrap text-ellipsis" }, "Doc No"),
3268
+ enableSorting: !1
3269
+ },
3270
+ {
3271
+ accessorKey: "grandTotal",
3272
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Total"),
3273
+ enableSorting: !1
3274
+ },
3275
+ // {
3276
+ // accessorKey: "tax_code",
3277
+ // header: () => h("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Tax Code"),
3278
+ // enableSorting: false
3279
+ // },
3280
+ // {
3281
+ // accessorKey: "tax",
3282
+ // header: () => h("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Tax"),
3283
+ // enableSorting: false
3284
+ // },
3285
+ // {
3286
+ // accessorKey: "service_charge",
3287
+ // header: () => h("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Service Charge"),
3288
+ // enableSorting: false
3289
+ // },
3290
+ {
3291
+ accessorKey: "item_code",
3292
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Code"),
3293
+ enableSorting: !1
3294
+ },
3295
+ {
3296
+ accessorKey: "item_desc",
3297
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Description"),
3298
+ enableSorting: !1
3299
+ },
3300
+ {
3301
+ accessorKey: "item_price",
3302
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Price"),
3303
+ enableSorting: !1
3304
+ },
3305
+ {
3306
+ accessorKey: "item_tax",
3307
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Tax"),
3308
+ enableSorting: !1
3309
+ },
3310
+ {
3311
+ accessorKey: "item_tax_label",
3312
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Tax Label"),
3313
+ enableSorting: !1
3314
+ },
3315
+ {
3316
+ accessorKey: "payment_amount",
3317
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Amount"),
3318
+ enableSorting: !1
3319
+ },
3320
+ {
3321
+ accessorKey: "payment_term",
3322
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Term"),
3323
+ enableSorting: !1
3324
+ },
3325
+ {
3326
+ accessorKey: "payment_method",
3327
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Method"),
3328
+ enableSorting: !1
3329
+ }
3330
+ ];
3331
+ function In(f) {
3332
+ return f.reduce((o, e) => {
3333
+ var F, w, h, u, b, C, p, v, r, y, $, l, i, c;
3334
+ const { invoice: s, payments: x } = e, k = o.length;
3335
+ o[k] = {
3336
+ invoice_date: s.invoice_date,
3337
+ ref_num: e.isRefund && e.credit_notes && e.credit_notes.length > 0 ? ((F = e.credit_notes[0]) == null ? void 0 : F.ref_num) ?? s.ref_num : s.ref_num,
3338
+ total: s.total,
3339
+ item_code: (w = s.items[0]) == null ? void 0 : w.code,
3340
+ item_description: (h = s.items[0]) == null ? void 0 : h.description,
3341
+ item_price: (u = s.items[0]) == null ? void 0 : u.price,
3342
+ item_tax_label: ((b = s.items[0]) == null ? void 0 : b.tax_label) ?? "",
3343
+ item_tax_amount: ((C = s.items[0]) == null ? void 0 : C.total_tax) ?? "",
3344
+ service_charge_amount: ((p = s.service_charges[0]) == null ? void 0 : p.total) ?? "",
3345
+ rounding: s.rounding ?? 0,
3346
+ payment_term_id: s.payment_term.name ?? "",
3347
+ payment_term_amount: ((r = (v = x[0]) == null ? void 0 : v.ids[0]) == null ? void 0 : r.amount) ?? "",
3348
+ payment_method: ((y = x[0]) == null ? void 0 : y.payment_method_name) || ""
3349
+ };
3350
+ const _ = Math.max(
3351
+ (($ = s.items) == null ? void 0 : $.length) || 0,
3352
+ ((l = s.terms) == null ? void 0 : l.length) || 0,
3353
+ (x == null ? void 0 : x.length) || 0
3354
+ );
3355
+ for (let a = 1; a < _; a++) {
3356
+ const N = k + a;
3357
+ o[N] || (o[N] = {});
3358
+ const A = s.items[a], j = x[a];
3359
+ A ? o[N] = {
3360
+ ...o[N],
3361
+ item_code: A.code,
3362
+ item_description: A.description,
3363
+ item_price: A.total,
3364
+ item_tax_label: A.tax_label == "?" ? "" : A.tax_label ?? "",
3365
+ item_tax_amount: A.total_tax ?? "",
3366
+ payment_term_id: s.payment_term.name ?? "",
3367
+ payment_term_amount: ((i = j == null ? void 0 : j.ids[0]) == null ? void 0 : i.amount) ?? "",
3368
+ payment_method: (j == null ? void 0 : j.payment_method_name) || ""
3369
+ } : o[N] = {
3370
+ ...o[N],
3371
+ payment_term_id: s.payment_term.name ?? "",
3372
+ payment_term_amount: ((c = j == null ? void 0 : j.ids[0]) == null ? void 0 : c.amount) ?? "",
3373
+ payment_method: (j == null ? void 0 : j.payment_method_name) || ""
3374
+ };
3375
+ }
3376
+ return o;
3377
+ }, []);
3378
+ }
3379
+ const Rn = [
3380
+ {
3381
+ accessorKey: "invoice_date",
3382
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
3383
+ enableSorting: !1
3384
+ },
3385
+ {
3386
+ accessorKey: "ref_num",
3387
+ header: () => K("p", { class: "min-w-[160px] text-nowrap text-ellipsis" }, "Doc No"),
3388
+ enableSorting: !1
3389
+ },
3390
+ {
3391
+ accessorKey: "total",
3392
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Total"),
3393
+ enableSorting: !1
3394
+ },
3395
+ {
3396
+ accessorKey: "item_code",
3397
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Code"),
3398
+ enableSorting: !1
3399
+ },
3400
+ {
3401
+ accessorKey: "item_description",
3402
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Item Description"),
3403
+ enableSorting: !1
3404
+ },
3405
+ {
3406
+ accessorKey: "item_price",
3407
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Price"),
3408
+ enableSorting: !1
3409
+ },
3410
+ {
3411
+ accessorKey: "item_tax_label",
3412
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Tax Label"),
3413
+ enableSorting: !1
3414
+ },
3415
+ {
3416
+ accessorKey: "item_tax_amount",
3417
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Tax Amount"),
3418
+ enableSorting: !1
3419
+ },
3420
+ {
3421
+ accessorKey: "service_charge_amount",
3422
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Service Charge Amount"),
3423
+ enableSorting: !1
3424
+ },
3425
+ {
3426
+ accessorKey: "rounding",
3427
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Rounding"),
3428
+ enableSorting: !1
3429
+ },
3430
+ {
3431
+ accessorKey: "payment_term_id",
3432
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Term"),
3433
+ enableSorting: !1
3434
+ },
3435
+ {
3436
+ accessorKey: "payment_term_amount",
3437
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Term Amount"),
3438
+ enableSorting: !1
3439
+ },
3440
+ {
3441
+ accessorKey: "payment_method",
3442
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Method (ID)"),
3443
+ enableSorting: !1
3444
+ }
3445
+ ], Mn = { class: "h-full flex flex-col gap-16" }, Pn = { class: "flex flex-row gap-2 justify-between items-center" }, jn = {
3446
+ key: 0,
3447
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-y-auto"
3448
+ }, Ln = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bn = /* @__PURE__ */ G({
3449
+ __name: "Preview",
3450
+ props: {
3451
+ modelValue: { required: !0 },
3452
+ modelModifiers: {}
3453
+ },
3454
+ emits: ["update:modelValue"],
3455
+ setup(f) {
3456
+ const { t: o } = Z(), e = W(f, "modelValue"), s = E(!1), x = ge(), { dateRange: k } = Ke(ve()), _ = E([]);
3457
+ _e(
3458
+ () => k.value,
3459
+ async () => {
3460
+ if (e.value._id)
3461
+ try {
3462
+ s.value = !0, _.value = await Ne(e.value._id);
3463
+ } catch (u) {
3464
+ x.open({ message: u.message, type: "error" });
3465
+ } finally {
3466
+ s.value = !1;
3467
+ }
3468
+ },
3469
+ {
3470
+ immediate: !0
3471
+ }
3472
+ );
3473
+ const F = H(() => {
3474
+ switch (e.value.platform.mappings.version) {
3475
+ case "v1":
3476
+ return An(_.value);
3477
+ case "v2":
3478
+ return In(_.value);
3479
+ }
3480
+ return [];
3481
+ }), w = H(() => {
3482
+ switch (e.value.platform.mappings.version) {
3483
+ case "v1":
3484
+ return Kn;
3485
+ case "v2":
3486
+ return Rn;
3487
+ }
3488
+ return [];
3489
+ });
3490
+ async function h() {
3491
+ try {
3492
+ e.value._id && e.value.platform.subdomain && e.value.platform.api_key ? (s.value = !0, await je(e.value._id), x.open({ message: "Upload successful", type: "success" })) : x.open({ message: "Invalid accounting setting", type: "error" });
3493
+ } catch (u) {
3494
+ u.message && x.open({ message: u.message, type: "error" }), u.errors && u.errors.forEach((b) => x.open({ message: b, type: "error" }));
3495
+ } finally {
3496
+ s.value = !1;
3497
+ }
3498
+ }
3499
+ return (u, b) => {
3500
+ const C = D("FmButton"), p = D("FmCircularProgress"), v = D("FmTable");
3501
+ return d(), S("div", Mn, [
3502
+ t("div", Pn, [
3503
+ n(Ie, {
3504
+ "date-range": m(k),
3505
+ "onUpdate:dateRange": b[0] || (b[0] = (r) => Ve(k) ? k.value = r : null),
3506
+ compare: !1
3507
+ }, null, 8, ["date-range"]),
3508
+ n(C, {
3509
+ loading: s.value,
3510
+ variant: "primary",
3511
+ label: "Upload",
3512
+ onClick: h
3513
+ }, null, 8, ["loading"])
3514
+ ]),
3515
+ s.value ? (d(), S("div", jn, [
3516
+ n(p, { size: "xl" }),
3517
+ t("span", Ln, V(m(o)("report.common.isLoading")), 1)
3518
+ ])) : (d(), M(v, {
3519
+ key: 1,
3520
+ class: "flex overflow-y-auto",
3521
+ "row-data": F.value,
3522
+ "column-defs": w.value
3523
+ }, null, 8, ["row-data", "column-defs"]))
3524
+ ]);
3525
+ };
3526
+ }
3527
+ }), On = { class: "h-full relative flex flex-col" }, En = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, zn = /* @__PURE__ */ G({
3528
+ __name: "Biztory",
3529
+ props: {
3530
+ modelValue: { required: !0 },
3531
+ modelModifiers: {}
3532
+ },
3533
+ emits: ["update:modelValue"],
3534
+ setup(f) {
3535
+ const { t: o } = Z(), e = W(f, "modelValue"), s = E("setting"), x = [
3536
+ {
3537
+ label: o("report.integration.setting"),
3538
+ value: "setting",
3539
+ icon: "settings"
3540
+ },
3541
+ {
3542
+ label: o("report.integration.preview"),
3543
+ value: "preview",
3544
+ icon: "table"
3545
+ }
3546
+ ], k = fe(), _ = H(() => {
3547
+ switch (s.value) {
3548
+ case "preview":
3549
+ return {
3550
+ component: Bn
3551
+ };
3552
+ case "setting":
3553
+ return {
3554
+ component: Nn,
3555
+ props: {
3556
+ retrievedMethods: F.value,
3557
+ retrievedCustomers: w.value
3558
+ }
3559
+ };
3560
+ default:
3561
+ return null;
3562
+ }
3563
+ }), F = E({}), w = E({}), h = (v, r) => v.map((y) => ({
3564
+ label: r.length > 2 ? `ID:${y[r[2]]} [${y[r[0]]}] ${y[r[1]]}` : `[${y[r[0]]}] ${y[r[1]]}`,
3565
+ value: y.id,
3566
+ cnId: y.cnId ? y.cnId : null
3567
+ })), u = (v) => h(v, ["wallet", "name"]), b = (v) => h(v, ["id", "name"]), C = async (v, r, y, $) => {
3568
+ try {
3569
+ const l = await v(e.value._id);
3570
+ y.value.data = r(l);
3571
+ } catch (l) {
3572
+ console.error($, l), y.value.isError = !0;
3573
+ } finally {
3574
+ y.value.isLoaded = !0;
3575
+ }
3576
+ }, p = async () => {
3577
+ var v, r;
3578
+ (v = e.value.platform.mappings) != null && v.version && await C(
3579
+ tt,
3580
+ u,
3581
+ F,
3582
+ "Failed to fetch payment methods:"
3583
+ ), ((r = e.value.platform.mappings) == null ? void 0 : r.version) == "v2" && await C(
3584
+ ot,
3585
+ b,
3586
+ w,
3587
+ "Failed to fetch customers:"
3588
+ ), F.value.isLoaded = !0, w.value.isLoaded = !0;
3589
+ };
3590
+ return Ee(p), _e(() => {
3591
+ var v;
3592
+ return (v = e.value.platform.mappings) == null ? void 0 : v.version;
3593
+ }, p), (v, r) => {
3594
+ var l, i, c;
3595
+ const y = D("FmPageHead"), $ = D("FmTabs");
3596
+ return d(), S("div", On, [
3597
+ n(y, {
3598
+ title: ((l = e.value) == null ? void 0 : l.name) || "Biztory",
3599
+ "back-button": !0,
3600
+ style: { paddingLeft: "0px", paddingRight: "0px" },
3601
+ "onClick:back": m(k).back
3602
+ }, {
3603
+ description: we(() => r[2] || (r[2] = [
3604
+ t("div", null, null, -1)
3605
+ ])),
3606
+ _: 1
3607
+ }, 8, ["title", "onClick:back"]),
3608
+ n($, {
3609
+ "model-value": s.value,
3610
+ "onUpdate:modelValue": r[0] || (r[0] = (a) => s.value = a),
3611
+ items: x
3612
+ }, null, 8, ["model-value"]),
3613
+ t("div", En, [
3614
+ (d(), M(ke((i = _.value) == null ? void 0 : i.component), Oe({
3615
+ modelValue: e.value,
3616
+ "onUpdate:modelValue": r[1] || (r[1] = (a) => e.value = a)
3617
+ }, (c = _.value) == null ? void 0 : c.props), null, 16, ["modelValue"]))
3618
+ ])
3619
+ ]);
3620
+ };
3621
+ }
3622
+ }), Yn = {
3623
+ key: 0,
3624
+ class: "flex flex-col h-full"
3625
+ }, qn = { class: "flex flex-col gap-16 pb-[24px]" }, Hn = { class: "flex flex-row justify-between items-center gap-2" }, Xn = { class: "flex flex-row gap-2 items-center" }, Gn = { class: "relative group cursor-pointer" }, Qn = { 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" }, Jn = { class: "flex flex-col gap-24 pt-[24px] overflow-scroll" }, Wn = { class: "flex flex-col gap-16" }, Zn = { class: "fm-typo-en-title-sm-800" }, es = { class: "flex flex-row items-center max-w-[100%]" }, ts = { class: "w-[25%]" }, os = { class: "flex-grow" }, as = { class: "flex flex-row items-center max-w-[100%]" }, ls = { class: "w-[25%]" }, ns = { class: "flex flex-row items-center gap-x-16" }, ss = { class: "fm-typo-en-title-sm-800" }, is = { class: "grid-cols-1 grid gap-16" }, rs = /* @__PURE__ */ G({
3626
+ __name: "Setting",
3627
+ props: {
3628
+ modelValue: { required: !0 },
3629
+ modelModifiers: {}
3630
+ },
3631
+ emits: ["update:modelValue"],
3632
+ setup(f) {
3633
+ const { t: o } = Z(), e = W(f, "modelValue"), s = ge(), x = $e(), k = fe(), { promptLoader: _ } = De(), { promptMessage: F } = Ae(), { restaurants: w } = ve(), h = H(
3634
+ () => w.map((r) => ({ label: r.name, value: r.id }))
3635
+ );
3636
+ async function u() {
3637
+ await F({
3638
+ message: o("report.messages.confirmDelete", { name: e.value.name }),
3639
+ title: o("report.common.delete")
3640
+ }) && await _(async () => {
3641
+ try {
3642
+ await Fe(e.value._id), await x.getSettings(), k.back();
3643
+ } catch (y) {
3644
+ s.open({ type: "error", message: y.message });
3645
+ }
3646
+ });
3647
+ }
3648
+ async function b() {
3649
+ await _(async () => {
3650
+ try {
3651
+ await Ue(e.value._id, e.value), await x.getSettings();
3652
+ } catch (r) {
3653
+ s.open({ type: "error", message: r.message });
3654
+ }
3655
+ });
3656
+ }
3657
+ function C(r, y) {
3658
+ var $, l;
3659
+ (l = ($ = e.value.platform) == null ? void 0 : $.mappings) != null && l[r] && (e.value.platform.mappings[r] = e.value.platform.mappings[r].filter(
3660
+ (i, c) => c !== y
3661
+ ));
3662
+ }
3663
+ function p(r) {
3664
+ var y, $;
3665
+ ($ = (y = e.value.platform) == null ? void 0 : y.mappings) != null && $[r] && (e.value.platform.mappings[r] = [
3666
+ ...e.value.platform.mappings[r],
3667
+ {
3668
+ key: "",
3669
+ name: "",
3670
+ badgeNo: "",
3671
+ employeeNo: ""
3672
+ }
3673
+ ]);
3674
+ }
3675
+ async function v() {
3676
+ await _(async () => {
3677
+ try {
3678
+ await Te(e.value._id), await x.getSettings();
3679
+ } catch (r) {
3680
+ s.open({ type: "error", message: r.message });
3681
+ }
3682
+ });
3683
+ }
3684
+ return Se(async () => {
3685
+ await x.getSettings();
3686
+ }), (r, y) => {
3687
+ var N, A, j, z, Q;
3688
+ const $ = D("FmIcon"), l = D("FmButton"), i = D("FmMenuDivider"), c = D("FmTextField"), a = D("FmSelect");
3689
+ return (A = (N = e.value) == null ? void 0 : N.platform) != null && A.mappings ? (d(), S("div", Yn, [
3690
+ t("div", qn, [
3691
+ t("div", Hn, [
3692
+ y[4] || (y[4] = t("div", { class: "fm-typo-en-title-sm-800" }, null, -1)),
3693
+ t("div", Xn, [
3694
+ t("div", Gn, [
3695
+ n($, {
3696
+ name: "refresh",
3697
+ class: "p-2 bg-gray-100 rounded-full",
3698
+ onClick: v
3699
+ }),
3700
+ t("span", Qn, V(m(o)("report.integration.refreshSetting")), 1)
3701
+ ]),
3702
+ n(l, {
3703
+ variant: "tertiary",
3704
+ label: m(o)("report.common.delete"),
3705
+ onClick: u
3706
+ }, null, 8, ["label"]),
3707
+ n(l, {
3708
+ variant: "primary",
3709
+ label: m(o)("report.common.update"),
3710
+ onClick: b
3711
+ }, null, 8, ["label"])
3712
+ ])
3713
+ ])
3714
+ ]),
3715
+ n(i, { style: { margin: 0 } }),
3716
+ t("div", Jn, [
3717
+ t("div", Wn, [
3718
+ t("div", Zn, V(m(o)("report.integration.general")), 1),
3719
+ t("div", es, [
3720
+ t("div", ts, V(m(o)("report.common.name")), 1),
3721
+ t("div", os, [
3722
+ n(c, {
3723
+ modelValue: e.value.name,
3724
+ "onUpdate:modelValue": y[0] || (y[0] = (B) => e.value.name = B)
3725
+ }, null, 8, ["modelValue"])
3726
+ ])
3727
+ ]),
3728
+ t("div", as, [
3729
+ t("div", ls, V(m(o)("report.integration.location")), 1),
3730
+ n(a, {
3731
+ "model-value": e.value.platform.locationIds[0],
3732
+ multiselect: !1,
3733
+ items: h.value,
3734
+ placeholder: "Select location",
3735
+ class: "flex-grow",
3736
+ "onUpdate:modelValue": y[1] || (y[1] = (B) => e.value.platform.locationIds[0] = B)
3737
+ }, null, 8, ["model-value", "items"])
3738
+ ])
3739
+ ]),
3740
+ n(Re, {
3741
+ modelValue: e.value.platform,
3742
+ "onUpdate:modelValue": y[2] || (y[2] = (B) => e.value.platform = B),
3743
+ label: m(o)("report.input.email")
3744
+ }, null, 8, ["modelValue", "label"]),
3745
+ t("div", ns, [
3746
+ t("div", ss, V(m(o)("report.integration.iflexiHrms.employee")), 1),
3747
+ n(l, {
3748
+ variant: "primary",
3749
+ icon: "add",
3750
+ onClick: y[3] || (y[3] = () => p("employees"))
3751
+ })
3752
+ ]),
3753
+ t("div", is, [
3754
+ (d(!0), S(O, null, Y((Q = (z = (j = e.value) == null ? void 0 : j.platform) == null ? void 0 : z.mappings) == null ? void 0 : Q.employees, (B, q) => (d(), M(R, {
3755
+ key: `employee-${q}`,
3756
+ modelValue: e.value.platform.mappings.employees[q],
3757
+ "onUpdate:modelValue": (X) => e.value.platform.mappings.employees[q] = X,
3758
+ options: {
3759
+ key: { placeholder: "Name", editable: !0 },
3760
+ badgeNo: { placeholder: "Badge No", editable: !0 },
3761
+ employeeNo: { placeholder: "Employee No", editable: !0 }
3762
+ },
3763
+ removable: !0,
3764
+ onRemove: () => C("employees", q)
3765
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onRemove"]))), 128))
3766
+ ])
3767
+ ])
3768
+ ])) : P("", !0);
3769
+ };
3770
+ }
3771
+ }), ms = { class: "h-full flex flex-col gap-16" }, ds = { class: "flex flex-row gap-2 justify-between items-center" }, cs = {
3772
+ key: 0,
3773
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-scroll"
3774
+ }, us = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ps = /* @__PURE__ */ G({
3775
+ __name: "Preview",
3776
+ props: {
3777
+ modelValue: { required: !0 },
3778
+ modelModifiers: {}
3779
+ },
3780
+ emits: ["update:modelValue"],
3781
+ setup(f) {
3782
+ const { t: o } = Z(), e = E([]), s = [
3783
+ {
3784
+ accessorKey: "name",
3785
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Name"),
3786
+ enableSorting: !1
3787
+ },
3788
+ {
3789
+ accessorKey: "badgeNo",
3790
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Badge No"),
3791
+ enableSorting: !1
3792
+ },
3793
+ {
3794
+ accessorKey: "employeeNo",
3795
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Employee No"),
3796
+ enableSorting: !1
3797
+ },
3798
+ {
3799
+ accessorKey: "date",
3800
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Date"),
3801
+ enableSorting: !1
3802
+ },
3803
+ {
3804
+ accessorKey: "time",
3805
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Time"),
3806
+ enableSorting: !1
3807
+ }
3808
+ ], x = W(f, "modelValue"), k = E(!1), _ = ge(), { dateRange: F } = Ke(ve());
3809
+ _e(
3810
+ () => F.value,
3811
+ async () => {
3812
+ if (x.value._id)
3813
+ try {
3814
+ k.value = !0, e.value = await Ne(x.value._id);
3815
+ } catch (h) {
3816
+ _.open({ message: h.message, type: "error" });
3817
+ } finally {
3818
+ k.value = !1;
3819
+ }
3820
+ },
3821
+ {
3822
+ immediate: !0
3823
+ }
3824
+ );
3825
+ async function w() {
3826
+ try {
3827
+ x.value._id ? (k.value = !0, await Le(x.value._id)) : _.open({ message: "Invalid setting", type: "error" });
3828
+ } catch (h) {
3829
+ _.open({ message: h.message, type: "error" });
3830
+ } finally {
3831
+ k.value = !1;
3832
+ }
3833
+ }
3834
+ return (h, u) => {
3835
+ const b = D("FmButton"), C = D("FmCircularProgress"), p = D("FmTable");
3836
+ return d(), S("div", ms, [
3837
+ t("div", ds, [
3838
+ n(Ie, {
3839
+ "date-range": m(F),
3840
+ "onUpdate:dateRange": u[0] || (u[0] = (v) => Ve(F) ? F.value = v : null),
3841
+ compare: !1
3842
+ }, null, 8, ["date-range"]),
3843
+ n(b, {
3844
+ loading: k.value,
3845
+ variant: "primary",
3846
+ label: m(o)("report.common.download"),
3847
+ onClick: w
3848
+ }, null, 8, ["loading", "label"])
3849
+ ]),
3850
+ k.value ? (d(), S("div", cs, [
3851
+ n(C, { size: "xl" }),
3852
+ t("span", us, V(m(o)("report.common.isLoading")), 1)
3853
+ ])) : e.value.length > 0 ? (d(), M(p, {
3854
+ key: 1,
3855
+ class: "flex overflow-y-auto",
3856
+ "row-data": e.value,
3857
+ "column-defs": s
3858
+ }, null, 8, ["row-data"])) : P("", !0)
3859
+ ]);
3860
+ };
3861
+ }
3862
+ }), fs = { class: "h-full relative flex flex-col" }, vs = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, gs = /* @__PURE__ */ G({
3863
+ __name: "IFlexiHRMS",
3864
+ props: {
3865
+ modelValue: {},
3866
+ modelModifiers: {}
3867
+ },
3868
+ emits: ["update:modelValue"],
3869
+ setup(f) {
3870
+ const { t: o } = Z(), e = W(f, "modelValue"), s = E("setting"), x = [
3871
+ {
3872
+ label: o("report.integration.setting"),
3873
+ value: "setting",
3874
+ icon: "settings"
3875
+ },
3876
+ {
3877
+ label: o("report.integration.preview"),
3878
+ value: "preview",
3879
+ icon: "table"
3880
+ }
3881
+ ], k = fe(), _ = H(() => {
3882
+ switch (s.value) {
3883
+ case "preview":
3884
+ return ps;
3885
+ case "setting":
3886
+ return rs;
3887
+ default:
3888
+ return null;
3889
+ }
3890
+ });
3891
+ return (F, w) => {
3892
+ var b;
3893
+ const h = D("FmPageHead"), u = D("FmTabs");
3894
+ return d(), S("div", fs, [
3895
+ n(h, {
3896
+ title: ((b = e.value) == null ? void 0 : b.name) || "AutoCount",
3897
+ "back-button": !0,
3898
+ style: { paddingLeft: "0px", paddingRight: "0px" },
3899
+ "onClick:back": m(k).back
3900
+ }, {
3901
+ description: we(() => w[2] || (w[2] = [
3902
+ t("div", null, null, -1)
3903
+ ])),
3904
+ _: 1
3905
+ }, 8, ["title", "onClick:back"]),
3906
+ n(u, {
3907
+ "model-value": s.value,
3908
+ "onUpdate:modelValue": w[0] || (w[0] = (C) => s.value = C),
3909
+ items: x
3910
+ }, null, 8, ["model-value"]),
3911
+ t("div", vs, [
3912
+ (d(), M(ke(_.value), {
3913
+ modelValue: e.value,
3914
+ "onUpdate:modelValue": w[1] || (w[1] = (C) => e.value = C)
3915
+ }, null, 8, ["modelValue"]))
3916
+ ])
3917
+ ]);
3918
+ };
3919
+ }
3920
+ }), ys = {
3921
+ key: 0,
3922
+ class: "flex flex-col h-full"
3923
+ }, xs = { class: "flex flex-col gap-16 pb-[24px]" }, _s = { class: "flex flex-row justify-between items-center gap-2" }, bs = { class: "fm-typo-en-title-sm-800" }, ws = { class: "flex flex-row gap-2 items-center" }, hs = { class: "flex flex-row gap-2 items-center" }, Vs = { class: "relative group cursor-pointer" }, ks = { 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" }, $s = { class: "flex flex-col gap-24 pt-[24px] overflow-y-auto overflow-x-hidden" }, Cs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ss = { class: "flex flex-col gap-24 pt-[24px] overflow-y-auto overflow-x-hidden" }, Ds = { class: "flex flex-row items-center justify-between" }, Fs = { class: "w-[25%]" }, Us = { class: "flex-grow" }, Ts = { class: "flex flex-row items-center justify-between" }, Ns = { class: "w-[25%]" }, As = { class: "flex-grow" }, Ks = { class: "flex flex-row items-center justify-between" }, Is = { class: "w-[25%]" }, Rs = { class: "flex-grow" }, Ms = { class: "flex flex-col gap-16" }, Ps = { class: "fm-typo-en-title-sm-800" }, js = { class: "flex flex-row items-center max-w-[100%]" }, Ls = { class: "w-[25%]" }, Bs = { class: "flex-grow" }, Os = { class: "flex flex-row items-center max-w-[100%]" }, Es = { class: "w-[25%]" }, zs = { class: "flex flex-row items-center max-w-[100%]" }, Ys = { class: "w-[25%]" }, qs = { class: "flex flex-row items-center max-w-[100%]" }, Hs = { class: "w-[25%]" }, Xs = {
3924
+ key: 1,
3925
+ class: "w-[75%] flex flex-row items-center gap-2"
3926
+ }, Gs = {
3927
+ key: 2,
3928
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
3929
+ }, Qs = { class: "flex flex-row items-center max-w-[100%]" }, Js = { class: "w-[25%]" }, Ws = {
3930
+ key: 1,
3931
+ class: "w-[75%] flex flex-row items-center gap-2"
3932
+ }, Zs = {
3933
+ key: 2,
3934
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
3935
+ }, ei = { class: "flex flex-col gap-16" }, ti = { class: "fm-typo-en-title-sm-800" }, oi = { class: "flex flex-row items-center w-[100%] justify-start" }, ai = { class: "text-nowrap w-[calc(25%-4px)] overflow-hidden text-ellipsis" }, li = { class: "flex flex-row items-center w-[100%] justify-start" }, ni = { class: "text-nowrap w-[calc(25%-4px)] overflow-hidden text-ellipsis" }, si = { class: "flex flex-row items-center w-[100%] justify-start" }, ii = { class: "text-nowrap w-[calc(25%-4px)] overflow-hidden text-ellipsis" }, ri = { class: "flex flex-col gap-16 pt-3 pb-3" }, mi = { class: "flex flex-row items-center gap-5" }, di = { class: "fm-typo-en-title-sm-800" }, ci = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, ui = { class: "flex flex-row items-center gap-x-16" }, pi = { class: "fm-typo-en-title-sm-800" }, fi = { class: "flex flex-row items-center gap-x-16" }, vi = { class: "fm-typo-en-title-sm-800" }, gi = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, yi = { class: "flex flex-row items-center gap-x-16" }, xi = { class: "fm-typo-en-title-sm-800" }, _i = { class: "xs:grid-cols-1 grid-cols-2 grid gap-16" }, bi = /* @__PURE__ */ G({
3936
+ __name: "Setting",
3937
+ props: /* @__PURE__ */ he({
3938
+ retrievedDebtors: {
3939
+ type: Object,
3940
+ required: !0
3941
+ },
3942
+ retrievedLocations: {
3943
+ type: Object,
3944
+ required: !0
3945
+ }
3946
+ }, {
3947
+ modelValue: { required: !0 },
3948
+ modelModifiers: {}
3949
+ }),
3950
+ emits: ["update:modelValue"],
3951
+ setup(f) {
3952
+ const { t: o } = Z(), e = W(f, "modelValue"), s = ge(), x = $e(), k = fe(), { promptLoader: _ } = De(), { promptMessage: F } = Ae(), { restaurants: w } = ve(), h = H(
3953
+ () => w.map((c) => ({ label: c.name, value: c.id }))
3954
+ );
3955
+ let u = E("");
3956
+ async function b() {
3957
+ await F({
3958
+ message: o("report.messages.confirmDelete", { name: e.value.name }),
3959
+ title: o("report.common.delete")
3960
+ }) && await _(async () => {
3961
+ try {
3962
+ await Fe(e.value._id), await x.getSettings(), k.back();
3963
+ } catch (a) {
3964
+ s.open({ type: "error", message: a.message });
3965
+ }
3966
+ });
3967
+ }
3968
+ async function C() {
3969
+ await _(async () => {
3970
+ try {
3971
+ await Ue(e.value._id, e.value), await x.getSettings();
3972
+ } catch (c) {
3973
+ s.open({ type: "error", message: c.message });
3974
+ }
3975
+ });
3976
+ }
3977
+ function p(c, a) {
3978
+ var N, A;
3979
+ (A = (N = e.value.platform) == null ? void 0 : N.mappings) != null && A[c] && (e.value.platform.mappings[c] = e.value.platform.mappings[c].filter(
3980
+ (j, z) => z !== a
3981
+ ));
3982
+ }
3983
+ function v(c) {
3984
+ var a, N;
3985
+ (N = (a = e.value.platform) == null ? void 0 : a.mappings) != null && N[c] && (e.value.platform.mappings[c] = [
3986
+ ...e.value.platform.mappings[c],
3987
+ c === "items" ? {
3988
+ feedmeKey: "",
3989
+ accountCode: ""
3990
+ } : c === "taxes" ? {
3991
+ feedmeKey: "",
3992
+ accountCode: "SST-"
3993
+ } : {
3994
+ feedmeKey: "",
3995
+ accountCode: ""
3996
+ }
3997
+ ]);
3998
+ }
3999
+ const r = [
4000
+ {
4001
+ label: "By day",
4002
+ value: be.BY_DAY
4003
+ }
4004
+ ];
4005
+ async function y() {
4006
+ await _(async () => {
4007
+ try {
4008
+ await Te(e.value._id), await x.getSettings();
4009
+ } catch (c) {
4010
+ s.open({ type: "error", message: c.message });
4011
+ }
4012
+ });
4013
+ }
4014
+ function $({
4015
+ key: c,
4016
+ value: a
4017
+ }) {
4018
+ var N, A;
4019
+ (A = (N = e.value) == null ? void 0 : N.platform) != null && A.mappings && (e.value.platform.mappings[c] = a);
4020
+ }
4021
+ function l(c) {
4022
+ return {
4023
+ key: { placeholder: c, editable: !1 },
4024
+ account: { placeholder: c, editable: !0 }
4025
+ };
4026
+ }
4027
+ Se(async () => {
4028
+ await x.getSettings();
4029
+ });
4030
+ function i(c) {
4031
+ const a = f.retrievedDebtors.data.find(
4032
+ (N) => N.valueAccNo === c || N.value === c
4033
+ );
4034
+ a && (u.value = c, e.value.platform.mappings.debtorCode = a.valueAccNo, e.value.platform.mappings.debtorName = a.valueCompanyName);
4035
+ }
4036
+ return _e(
4037
+ () => f.retrievedDebtors.isLoaded,
4038
+ (c) => {
4039
+ var a;
4040
+ if (c && ((a = f.retrievedDebtors.data) == null ? void 0 : a.length) > 0) {
4041
+ const N = f.retrievedDebtors.data.find(
4042
+ (A) => A.valueAccNo === e.value.platform.mappings.debtorCode
4043
+ );
4044
+ N != null && (u.value = N.value);
4045
+ }
4046
+ },
4047
+ { immediate: !0 }
4048
+ ), (c, a) => {
4049
+ var X, te, oe, ae, le, ne, se, ie, re, me, de, ce, ue, T, g, U, L;
4050
+ const N = D("FmIcon"), A = D("FmButton"), j = D("FmMenuDivider"), z = D("FmTextField"), Q = D("FmSelect"), B = D("FmCircularProgress"), q = D("FmSwitch");
4051
+ return (te = (X = e.value) == null ? void 0 : X.platform) != null && te.mappings ? (d(), S("div", ys, [
4052
+ t("div", xs, [
4053
+ t("div", _s, [
4054
+ t("div", bs, V(m(o)("report.integration.connect")), 1),
4055
+ t("div", ws, [
4056
+ t("div", hs, [
4057
+ t("div", Vs, [
4058
+ n(N, {
4059
+ name: "refresh",
4060
+ class: "p-2 bg-gray-100 rounded-full",
4061
+ onClick: y
4062
+ }),
4063
+ t("span", ks, V(m(o)("report.integration.refreshSetting")), 1)
4064
+ ]),
4065
+ n(A, {
4066
+ variant: "tertiary",
4067
+ label: m(o)("report.common.delete"),
4068
+ onClick: b
4069
+ }, null, 8, ["label"]),
4070
+ n(A, {
4071
+ variant: "primary",
4072
+ label: m(o)("report.common.update"),
4073
+ onClick: C
4074
+ }, null, 8, ["label"])
4075
+ ])
4076
+ ])
4077
+ ])
4078
+ ]),
4079
+ t("div", $s, [
4080
+ t("div", Cs, V(m(o)("report.integration.authDescription")), 1),
4081
+ n(j, { style: { margin: 0 } }),
4082
+ t("div", Ss, [
4083
+ t("div", Ds, [
4084
+ t("div", Fs, V(m(o)("report.integration.autocount.keyId")), 1),
4085
+ t("div", Us, [
4086
+ n(z, {
4087
+ modelValue: e.value.platform.keyId,
4088
+ "onUpdate:modelValue": a[0] || (a[0] = (I) => e.value.platform.keyId = I),
4089
+ placeholder: m(o)("report.integration.autocount.keyId")
4090
+ }, null, 8, ["modelValue", "placeholder"])
4091
+ ])
4092
+ ]),
4093
+ t("div", Ts, [
4094
+ t("div", Ns, V(m(o)("report.integration.apiKey")), 1),
4095
+ t("div", As, [
4096
+ n(z, {
4097
+ modelValue: e.value.platform.apiKey,
4098
+ "onUpdate:modelValue": a[1] || (a[1] = (I) => e.value.platform.apiKey = I),
4099
+ placeholder: m(o)("report.integration.apiKey")
4100
+ }, null, 8, ["modelValue", "placeholder"])
4101
+ ])
4102
+ ]),
4103
+ t("div", Ks, [
4104
+ t("div", Is, V(m(o)("report.integration.autocount.accountBookId")), 1),
4105
+ t("div", Rs, [
4106
+ n(z, {
4107
+ modelValue: e.value.platform.accountBookId,
4108
+ "onUpdate:modelValue": a[2] || (a[2] = (I) => e.value.platform.accountBookId = I),
4109
+ placeholder: m(o)("report.integration.autocount.accountBookId")
4110
+ }, null, 8, ["modelValue", "placeholder"])
4111
+ ])
4112
+ ]),
4113
+ t("div", Ms, [
4114
+ t("div", Ps, V(m(o)("report.common.general")), 1),
4115
+ t("div", js, [
4116
+ t("div", Ls, V(m(o)("report.common.name")), 1),
4117
+ t("div", Bs, [
4118
+ n(z, {
4119
+ modelValue: e.value.name,
4120
+ "onUpdate:modelValue": a[3] || (a[3] = (I) => e.value.name = I)
4121
+ }, null, 8, ["modelValue"])
4122
+ ])
4123
+ ]),
4124
+ t("div", Os, [
4125
+ t("div", Es, V(m(o)("report.common.location")), 1),
4126
+ n(Q, {
4127
+ modelValue: e.value.platform.locationIds,
4128
+ "onUpdate:modelValue": a[4] || (a[4] = (I) => e.value.platform.locationIds = I),
4129
+ multiselect: !0,
4130
+ items: h.value,
4131
+ placeholder: m(o)("report.common.location"),
4132
+ class: "flex-grow"
4133
+ }, null, 8, ["modelValue", "items", "placeholder"])
4134
+ ]),
4135
+ t("div", zs, [
4136
+ t("div", Ys, V(m(o)("report.integration.grouping.title")), 1),
4137
+ n(Q, {
4138
+ modelValue: e.value.platform.grouping,
4139
+ "onUpdate:modelValue": a[5] || (a[5] = (I) => e.value.platform.grouping = I),
4140
+ multiselect: !1,
4141
+ items: r,
4142
+ placeholder: m(o)("report.integration.grouping.title"),
4143
+ class: "flex-grow",
4144
+ disabled: ""
4145
+ }, null, 8, ["modelValue", "placeholder"])
4146
+ ]),
4147
+ t("div", qs, [
4148
+ t("div", Hs, V(m(o)("report.integration.autocount.debtor")), 1),
4149
+ f.retrievedDebtors.isLoaded ? P("", !0) : (d(), M(B, {
4150
+ key: 0,
4151
+ size: "xl"
4152
+ })),
4153
+ f.retrievedDebtors.isLoaded && f.retrievedDebtors.data && ((oe = f.retrievedDebtors.data) == null ? void 0 : oe.length) != 0 && !f.retrievedDebtors.isError ? (d(), S("div", Xs, [
4154
+ n(Q, {
4155
+ modelValue: m(u),
4156
+ "onUpdate:modelValue": [
4157
+ a[6] || (a[6] = (I) => Ve(u) ? u.value = I : u = I),
4158
+ i
4159
+ ],
4160
+ items: f.retrievedDebtors.data,
4161
+ placeholder: m(o)("report.integration.autocount.selectDebtor"),
4162
+ class: "flex-grow",
4163
+ disabled: !f.retrievedDebtors.isLoaded
4164
+ }, null, 8, ["modelValue", "items", "placeholder", "disabled"])
4165
+ ])) : f.retrievedDebtors.isError ? (d(), S("div", Gs, V(m(o)("report.integration.errorFetchingDebtor")), 1)) : P("", !0)
4166
+ ]),
4167
+ t("div", Qs, [
4168
+ t("div", Js, V(m(o)("report.integration.autocount.location")), 1),
4169
+ f.retrievedLocations.isLoaded ? P("", !0) : (d(), M(B, {
4170
+ key: 0,
4171
+ size: "xl"
4172
+ })),
4173
+ f.retrievedLocations.isLoaded && f.retrievedLocations.data && ((ae = f.retrievedLocations.data) == null ? void 0 : ae.length) != 0 && !f.retrievedLocations.isError ? (d(), S("div", Ws, [
4174
+ n(Q, {
4175
+ modelValue: e.value.platform.mappings.salesLocation,
4176
+ "onUpdate:modelValue": a[7] || (a[7] = (I) => e.value.platform.mappings.salesLocation = I),
4177
+ items: f.retrievedLocations.data,
4178
+ placeholder: m(o)("report.integration.autocount.selectLocation"),
4179
+ class: "flex-grow",
4180
+ disabled: !f.retrievedLocations.isLoaded
4181
+ }, null, 8, ["modelValue", "items", "placeholder", "disabled"])
4182
+ ])) : f.retrievedLocations.isError ? (d(), S("div", Zs, V(m(o)("report.integration.errorFetchingLocation")), 1)) : P("", !0)
4183
+ ])
4184
+ ]),
4185
+ t("div", ei, [
4186
+ t("div", ti, V(m(o)("report.integration.autocount.saveAndApprove")), 1),
4187
+ t("div", oi, [
4188
+ t("div", ai, V(m(o)("report.integration.autocount.invoice")), 1),
4189
+ n(q, {
4190
+ modelValue: e.value.platform.mappings.saveApproveInvoice,
4191
+ "onUpdate:modelValue": a[8] || (a[8] = (I) => e.value.platform.mappings.saveApproveInvoice = I),
4192
+ style: { gap: "0px" }
4193
+ }, null, 8, ["modelValue"])
4194
+ ]),
4195
+ t("div", li, [
4196
+ t("div", ni, V(m(o)("report.integration.autocount.creditNote")), 1),
4197
+ n(q, {
4198
+ modelValue: e.value.platform.mappings.saveApproveCreditNote,
4199
+ "onUpdate:modelValue": a[9] || (a[9] = (I) => e.value.platform.mappings.saveApproveCreditNote = I),
4200
+ style: { gap: "0px" }
4201
+ }, null, 8, ["modelValue"])
4202
+ ]),
4203
+ t("div", si, [
4204
+ t("div", ii, V(m(o)("report.integration.autocount.payment")), 1),
4205
+ n(q, {
4206
+ modelValue: e.value.platform.mappings.saveApprovePayment,
4207
+ "onUpdate:modelValue": a[10] || (a[10] = (I) => e.value.platform.mappings.saveApprovePayment = I),
4208
+ style: { gap: "0px" }
4209
+ }, null, 8, ["modelValue"])
4210
+ ])
4211
+ ]),
4212
+ t("div", ri, [
4213
+ t("div", mi, [
4214
+ t("div", di, V(m(o)("report.integration.refNumFormat")), 1),
4215
+ n(Pe)
4216
+ ]),
4217
+ t("div", ci, [
4218
+ n(R, {
4219
+ "model-value": {
4220
+ key: "Invoice no",
4221
+ account: e.value.platform.mappings.invoiceDocNo
4222
+ },
4223
+ options: l("Invoice no"),
4224
+ "onUpdate:modelValue": a[11] || (a[11] = (I) => $({ key: "invoiceDocNo", value: I.account }))
4225
+ }, null, 8, ["model-value", "options"]),
4226
+ n(R, {
4227
+ "model-value": {
4228
+ key: "Credit note no",
4229
+ account: e.value.platform.mappings.creditNoteDocNo
4230
+ },
4231
+ options: l("Credit note no"),
4232
+ "onUpdate:modelValue": a[12] || (a[12] = (I) => $({ key: "creditNoteDocNo", value: I.account }))
4233
+ }, null, 8, ["model-value", "options"]),
4234
+ n(R, {
4235
+ "model-value": {
4236
+ key: "Payment no",
4237
+ account: e.value.platform.mappings.paymentDocNo
4238
+ },
4239
+ options: l("Payment no"),
4240
+ "onUpdate:modelValue": a[13] || (a[13] = (I) => $({ key: "paymentDocNo", value: I.account }))
4241
+ }, null, 8, ["model-value", "options"]),
4242
+ n(R, {
4243
+ "model-value": {
4244
+ key: "Refund no",
4245
+ account: e.value.platform.mappings.refundDocNo
4246
+ },
4247
+ options: l("Refund no"),
4248
+ "onUpdate:modelValue": a[14] || (a[14] = (I) => $({ key: "refundDocNo", value: I.account }))
4249
+ }, null, 8, ["model-value", "options"])
4250
+ ])
4251
+ ]),
4252
+ n(Re, {
4253
+ modelValue: e.value.platform,
4254
+ "onUpdate:modelValue": a[15] || (a[15] = (I) => e.value.platform = I),
4255
+ label: "upload",
4256
+ "last-upload-date": (le = e.value.platform) == null ? void 0 : le.lastUploadDate
4257
+ }, null, 8, ["modelValue", "last-upload-date"]),
4258
+ t("div", ui, [
4259
+ t("div", pi, V(m(o)("report.integration.biztory.items")), 1),
4260
+ n(A, {
4261
+ variant: "primary",
4262
+ icon: "add",
4263
+ onClick: a[16] || (a[16] = () => v("items"))
4264
+ })
4265
+ ]),
4266
+ (d(!0), S(O, null, Y((ie = (se = (ne = e.value) == null ? void 0 : ne.platform) == null ? void 0 : se.mappings) == null ? void 0 : ie.items, (I, J) => (d(), S("div", {
4267
+ key: `items-${J}`,
4268
+ class: "grid-cols-1 grid gap-x-16"
4269
+ }, [
4270
+ n(R, {
4271
+ modelValue: e.value.platform.mappings.items[J],
4272
+ "onUpdate:modelValue": (ye) => e.value.platform.mappings.items[J] = ye,
4273
+ options: {
4274
+ feedmeKey: {
4275
+ placeholder: m(o)("report.integration.autocount.feedmeKey"),
4276
+ editable: !0
4277
+ },
4278
+ productCode: {
4279
+ placeholder: m(o)("report.integration.autocount.productCode"),
4280
+ editable: !0
4281
+ },
4282
+ accountCode: {
4283
+ placeholder: m(o)("report.integration.autocount.accountCode"),
4284
+ editable: !0
4285
+ }
4286
+ },
4287
+ removable: !0,
4288
+ onRemove: () => p("items", J)
4289
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"])
4290
+ ]))), 128)),
4291
+ t("div", fi, [
4292
+ t("div", vi, V(m(o)("report.integration.biztory.taxes")), 1),
4293
+ n(A, {
4294
+ variant: "primary",
4295
+ icon: "add",
4296
+ onClick: a[17] || (a[17] = () => v("taxes"))
4297
+ })
4298
+ ]),
4299
+ t("div", gi, [
4300
+ (d(!0), S(O, null, Y((de = (me = (re = e.value) == null ? void 0 : re.platform) == null ? void 0 : me.mappings) == null ? void 0 : de.taxes, (I, J) => (d(), M(R, {
4301
+ key: `tax-${J}`,
4302
+ modelValue: e.value.platform.mappings.taxes[J],
4303
+ "onUpdate:modelValue": (ye) => e.value.platform.mappings.taxes[J] = ye,
4304
+ options: {
4305
+ feedmeKey: { placeholder: m(o)("report.integration.autocount.key"), editable: !0 },
4306
+ accountCode: {
4307
+ placeholder: m(o)("report.integration.autocount.accountCode"),
4308
+ editable: !0
4309
+ }
4310
+ },
4311
+ removable: !0,
4312
+ onRemove: () => p("taxes", J)
4313
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"]))), 128)),
4314
+ (d(!0), S(O, null, Y((T = (ue = (ce = e.value) == null ? void 0 : ce.platform) == null ? void 0 : ue.mappings) == null ? void 0 : T.taxRoundingAdjustments, (I, J) => (d(), M(R, {
4315
+ key: `tax-rounding-adjustment-${J}`,
4316
+ modelValue: e.value.platform.mappings.taxRoundingAdjustments[J],
4317
+ "onUpdate:modelValue": (ye) => e.value.platform.mappings.taxRoundingAdjustments[J] = ye,
4318
+ options: {
4319
+ feedmeKey: {
4320
+ placeholder: m(o)("report.integration.autocount.key"),
4321
+ editable: !0
4322
+ },
4323
+ accountCode: {
4324
+ placeholder: m(o)("report.integration.autocount.accountCode"),
4325
+ editable: !0
4326
+ }
4327
+ },
4328
+ removable: !0,
4329
+ onRemove: () => p("taxes", J)
4330
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"]))), 128))
4331
+ ]),
4332
+ t("div", yi, [
4333
+ t("div", xi, V(m(o)("report.integration.biztory.payments")), 1),
4334
+ n(A, {
4335
+ variant: "primary",
4336
+ icon: "add",
4337
+ onClick: a[18] || (a[18] = () => v("payments"))
4338
+ })
4339
+ ]),
4340
+ t("div", _i, [
4341
+ n(R, {
4342
+ "model-value": {
4343
+ key: "Credit Term",
4344
+ account: e.value.platform.mappings.creditTerm
4345
+ },
4346
+ options: l("creditTerm"),
4347
+ "onUpdate:modelValue": a[19] || (a[19] = (I) => $({ key: "creditTerm", value: I.account }))
4348
+ }, null, 8, ["model-value", "options"]),
4349
+ n(R, {
4350
+ "model-value": {
4351
+ key: "Currency Code",
4352
+ account: e.value.platform.mappings.currencyCode
4353
+ },
4354
+ options: l("currencyCode"),
4355
+ "onUpdate:modelValue": a[20] || (a[20] = (I) => $({ key: "currencyCode", value: I.account }))
4356
+ }, null, 8, ["model-value", "options"]),
4357
+ n(R, {
4358
+ "model-value": {
4359
+ key: "Journal Type",
4360
+ account: e.value.platform.mappings.journalType
4361
+ },
4362
+ options: l("journalType"),
4363
+ "onUpdate:modelValue": a[21] || (a[21] = (I) => $({ key: "journalType", value: I.account }))
4364
+ }, null, 8, ["model-value", "options"]),
4365
+ n(R, {
4366
+ "model-value": {
4367
+ key: "Currency Rate",
4368
+ account: e.value.platform.mappings.currencyRate
4369
+ },
4370
+ options: l("currencyRate"),
4371
+ "onUpdate:modelValue": a[22] || (a[22] = (I) => $({ key: "currencyRate", value: I.account }))
4372
+ }, null, 8, ["model-value", "options"])
4373
+ ]),
4374
+ (d(!0), S(O, null, Y((L = (U = (g = e.value) == null ? void 0 : g.platform) == null ? void 0 : U.mappings) == null ? void 0 : L.payments, (I, J) => (d(), S("div", {
4375
+ key: `payment-${J}`,
4376
+ class: "grid-cols-1 grid gap-x-16"
4377
+ }, [
4378
+ n(R, {
4379
+ modelValue: e.value.platform.mappings.payments[J],
4380
+ "onUpdate:modelValue": (ye) => e.value.platform.mappings.payments[J] = ye,
4381
+ options: {
4382
+ feedmeKey: {
4383
+ placeholder: m(o)("report.integration.autocount.feedmeKey"),
4384
+ editable: !0
4385
+ },
4386
+ accountCode: {
4387
+ placeholder: m(o)("report.integration.autocount.accountCode") + " (Use debtor code if need to knock-off payment)",
4388
+ editable: !0
4389
+ },
4390
+ paymentName: {
4391
+ placeholder: m(o)("report.integration.autocount.paymentMethod"),
4392
+ editable: !0
4393
+ }
4394
+ },
4395
+ removable: !0,
4396
+ onRemove: () => p("payments", J)
4397
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "onRemove"])
4398
+ ]))), 128))
4399
+ ])
4400
+ ])
4401
+ ])) : P("", !0);
4402
+ };
4403
+ }
4404
+ });
4405
+ function wi(f) {
4406
+ return f.reduce((o, e) => {
4407
+ var F, w, h, u, b, C, p, v, r, y, $, l, i;
4408
+ const { invoice: s, payments: x } = e, k = o.length;
4409
+ o[k] = {
4410
+ docNo: s.master.docNo,
4411
+ debtorCode: s.master.debtorCode,
4412
+ debtorName: s.master.debtorName,
4413
+ itemProductCode: (F = s.details[0]) == null ? void 0 : F.productCode,
4414
+ description: (w = s.details[0]) == null ? void 0 : w.description,
4415
+ unitPrice: (h = s.details[0]) == null ? void 0 : h.unitPrice,
4416
+ discount: (u = s.details[0]) == null ? void 0 : u.discount,
4417
+ taxCode: (b = s.details[0]) == null ? void 0 : b.taxCode,
4418
+ creditTerm: s.master.creditTerm,
4419
+ docType: (C = x[0]) == null ? void 0 : C.master.docType,
4420
+ paymentMethod: (v = (p = x[0]) == null ? void 0 : p.paymentDetails[0]) == null ? void 0 : v.paymentMethod,
4421
+ amount: ((r = x[0]) == null ? void 0 : r.details[0].amount) || 0,
4422
+ currencyCode: (y = x[0]) == null ? void 0 : y.master.currencyCode,
4423
+ journalType: ($ = x[0]) == null ? void 0 : $.master.journalType
4424
+ };
4425
+ const _ = Math.max(s.details.length, (x == null ? void 0 : x.length) || 0);
4426
+ for (let c = 1; c < _; c++) {
4427
+ const a = k + c;
4428
+ o[a] || (o[a] = {});
4429
+ const N = s.details[c], A = x[c];
4430
+ N && (o[a] = {
4431
+ ...o[a],
4432
+ debtorCode: s.master.debtorCode,
4433
+ debtorName: s.master.debtorName,
4434
+ creditTerm: s.master.creditTerm,
4435
+ itemProductCode: N.productCode,
4436
+ description: N.description,
4437
+ unitPrice: N.unitPrice,
4438
+ discount: N.discount,
4439
+ taxCode: N.taxCode
4440
+ }), A && (o[a] = {
4441
+ ...o[a],
4442
+ debtorCode: s.master.debtorCode,
4443
+ debtorName: s.master.debtorName,
4444
+ creditTerm: s.master.creditTerm,
4445
+ docType: A.master.docType,
4446
+ paymentMethod: (l = A.paymentDetails[0]) == null ? void 0 : l.paymentMethod,
4447
+ amount: ((i = A.details[0]) == null ? void 0 : i.amount) || 0,
4448
+ currencyCode: A.master.currencyCode,
4449
+ journalType: A.master.journalType
4450
+ });
4451
+ }
4452
+ return o;
4453
+ }, []);
4454
+ }
4455
+ const hi = [
4456
+ {
4457
+ accessorKey: "docNo",
4458
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Doc No"),
4459
+ enableSorting: !1
4460
+ },
4461
+ {
4462
+ accessorKey: "debtorCode",
4463
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Debtor Code"),
4464
+ enableSorting: !1
4465
+ },
4466
+ {
4467
+ accessorKey: "debtorName",
4468
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Debtor Name"),
4469
+ enableSorting: !1
4470
+ },
4471
+ {
4472
+ accessorKey: "creditTerm",
4473
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Credit Term"),
4474
+ enableSorting: !1
4475
+ },
4476
+ {
4477
+ accessorKey: "itemProductCode",
4478
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Product Code"),
4479
+ enableSorting: !1
4480
+ },
4481
+ {
4482
+ accessorKey: "description",
4483
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Description"),
4484
+ enableSorting: !1
4485
+ },
4486
+ {
4487
+ accessorKey: "taxCode",
4488
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Tax Code"),
4489
+ enableSorting: !1
4490
+ },
4491
+ {
4492
+ accessorKey: "unitPrice",
4493
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Price"),
4494
+ enableSorting: !1
4495
+ },
4496
+ {
4497
+ accessorKey: "discount",
4498
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Discount"),
4499
+ enableSorting: !1
4500
+ },
4501
+ {
4502
+ accessorKey: "docType",
4503
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Doc Type"),
4504
+ enableSorting: !1
4505
+ },
4506
+ {
4507
+ accessorKey: "paymentMethod",
4508
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Payment Method"),
4509
+ enableSorting: !1
4510
+ },
4511
+ {
4512
+ accessorKey: "amount",
4513
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Amount"),
4514
+ enableSorting: !1
4515
+ },
4516
+ {
4517
+ accessorKey: "currencyCode",
4518
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Currency Code"),
4519
+ enableSorting: !1
4520
+ },
4521
+ {
4522
+ accessorKey: "journalType",
4523
+ header: () => K("p", { class: "min-w-[90px] text-nowrap text-ellipsis" }, "Journal Type"),
4524
+ enableSorting: !1
4525
+ }
4526
+ ], Vi = { class: "h-full flex flex-col gap-16" }, ki = { class: "flex flex-row gap-2 justify-between items-center" }, $i = { class: "flex flex-row gap-5" }, Ci = {
4527
+ key: 0,
4528
+ class: "flex gap-24 w-full h-full justify-center items-center overflow-y-auto"
4529
+ }, Si = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Di = /* @__PURE__ */ G({
4530
+ __name: "Preview",
4531
+ props: {
4532
+ modelValue: { required: !0 },
4533
+ modelModifiers: {}
4534
+ },
4535
+ emits: ["update:modelValue"],
4536
+ setup(f) {
4537
+ const { t: o } = Z(), e = W(f, "modelValue"), s = E(!1), x = ge(), { dateRange: k } = Ke(ve()), _ = E([]);
4538
+ _e(
4539
+ () => k.value,
4540
+ async () => {
4541
+ if (e.value._id)
4542
+ try {
4543
+ s.value = !0, _.value = await Ne(e.value._id);
4544
+ } catch (b) {
4545
+ x.open({ message: b.message, type: "error" });
4546
+ } finally {
4547
+ s.value = !1;
4548
+ }
4549
+ },
4550
+ {
4551
+ immediate: !0
4552
+ }
4553
+ );
4554
+ const F = H(() => wi(_.value)), w = H(() => hi);
4555
+ async function h() {
4556
+ try {
4557
+ e.value._id && e.value.platform.apiKey ? (s.value = !0, await je(e.value._id), x.open({ message: o("report.integration.uploadSuccess"), type: "success" })) : x.open({ message: o("report.integration.invalidSetting"), type: "error" });
4558
+ } catch (b) {
4559
+ b.message && x.open({ message: b.message, type: "error" }), b.errors && b.errors.forEach((C) => x.open({ message: C, type: "error" }));
4560
+ } finally {
4561
+ s.value = !1;
4562
+ }
4563
+ }
4564
+ async function u() {
4565
+ try {
4566
+ e.value._id ? (s.value = !0, await Le(e.value._id)) : x.open({ message: o("report.integration.invalidSetting"), type: "error" });
4567
+ } catch (b) {
4568
+ x.open({ message: b.message, type: "error" });
4569
+ } finally {
4570
+ s.value = !1;
4571
+ }
4572
+ }
4573
+ return (b, C) => {
4574
+ const p = D("FmButton"), v = D("FmCircularProgress"), r = D("FmTable");
4575
+ return d(), S("div", Vi, [
4576
+ t("div", ki, [
4577
+ n(Ie, {
4578
+ "date-range": m(k),
4579
+ "onUpdate:dateRange": C[0] || (C[0] = (y) => Ve(k) ? k.value = y : null),
4580
+ compare: !1
4581
+ }, null, 8, ["date-range"]),
4582
+ t("div", $i, [
4583
+ n(p, {
4584
+ loading: s.value,
4585
+ variant: "primary",
4586
+ label: m(o)("report.common.upload"),
4587
+ onClick: h
4588
+ }, null, 8, ["loading", "label"]),
4589
+ n(p, {
4590
+ loading: s.value,
4591
+ variant: "primary",
4592
+ label: m(o)("report.common.download"),
4593
+ onClick: u
4594
+ }, null, 8, ["loading", "label"])
4595
+ ])
4596
+ ]),
4597
+ s.value ? (d(), S("div", Ci, [
4598
+ n(v, { size: "xl" }),
4599
+ t("span", Si, V(m(o)("report.common.isLoading")), 1)
4600
+ ])) : (d(), M(r, {
4601
+ key: 1,
4602
+ class: "flex overflow-y-auto",
4603
+ "row-data": F.value,
4604
+ "column-defs": w.value
4605
+ }, null, 8, ["row-data", "column-defs"]))
4606
+ ]);
4607
+ };
4608
+ }
4609
+ }), Fi = { class: "h-full relative flex flex-col" }, Ui = { class: "py-16 px-16 overflow-hidden flex-grow relative" }, Ti = /* @__PURE__ */ G({
4610
+ __name: "AutocountCloud",
4611
+ props: {
4612
+ modelValue: { required: !0 },
4613
+ modelModifiers: {}
4614
+ },
4615
+ emits: ["update:modelValue"],
4616
+ setup(f) {
4617
+ const { t: o } = Z(), e = W(f, "modelValue"), s = E("setting"), x = [
4618
+ {
4619
+ label: o("report.integration.setting"),
4620
+ value: "setting",
4621
+ icon: "settings"
4622
+ },
4623
+ {
4624
+ label: o("report.integration.preview"),
4625
+ value: "preview",
4626
+ icon: "table"
4627
+ }
4628
+ ], k = fe(), _ = H(() => {
4629
+ switch (s.value) {
4630
+ case "preview":
4631
+ return {
4632
+ component: Di
4633
+ };
4634
+ case "setting":
4635
+ return {
4636
+ component: bi,
4637
+ props: {
4638
+ retrievedLocations: F.value,
4639
+ retrievedDebtors: w.value
4640
+ }
4641
+ };
4642
+ default:
4643
+ return null;
4644
+ }
4645
+ }), F = E({}), w = E({}), h = (p) => p.data.map((v) => ({
4646
+ label: v.location + " - " + v.description,
4647
+ value: v.location
4648
+ })), u = (p) => p.data.map((v) => ({
4649
+ label: v.AccNo + " - " + v.CompanyName,
4650
+ value: v.AccNo + " - " + v.CompanyName,
4651
+ valueAccNo: v.AccNo,
4652
+ valueCompanyName: v.CompanyName
4653
+ })), b = async (p, v, r, y) => {
4654
+ try {
4655
+ const $ = await p(e.value._id);
4656
+ r.value.data = v($);
4657
+ } catch ($) {
4658
+ console.error(y, $), r.value.isError = !0;
4659
+ } finally {
4660
+ r.value.isLoaded = !0;
4661
+ }
4662
+ }, C = async () => {
4663
+ await b(
4664
+ at,
4665
+ u,
4666
+ w,
4667
+ "Failed to fetch debtors:"
4668
+ ), await b(
4669
+ lt,
4670
+ h,
4671
+ F,
4672
+ "Failed to fetch locations:"
4673
+ ), F.value.isLoaded = !0, w.value.isLoaded = !0;
4674
+ };
4675
+ return Ee(() => {
4676
+ e.value.platform.apiKey && e.value.platform.accountBookId && e.value.platform.keyId ? C() : (F.value.isLoaded = !0, w.value.isLoaded = !0, F.value.isError = !0, w.value.isError = !0);
4677
+ }), (p, v) => {
4678
+ var $, l, i;
4679
+ const r = D("FmPageHead"), y = D("FmTabs");
4680
+ return d(), S("div", Fi, [
4681
+ n(r, {
4682
+ title: (($ = e.value) == null ? void 0 : $.name) || "Autocount Cloud",
4683
+ "back-button": !0,
4684
+ style: { paddingLeft: "0px", paddingRight: "0px" },
4685
+ "onClick:back": m(k).back
4686
+ }, {
4687
+ description: we(() => v[2] || (v[2] = [
4688
+ t("div", null, null, -1)
4689
+ ])),
4690
+ _: 1
4691
+ }, 8, ["title", "onClick:back"]),
4692
+ n(y, {
4693
+ "model-value": s.value,
4694
+ "onUpdate:modelValue": v[0] || (v[0] = (c) => s.value = c),
4695
+ items: x
4696
+ }, null, 8, ["model-value"]),
4697
+ t("div", Ui, [
4698
+ (d(), M(ke((l = _.value) == null ? void 0 : l.component), Oe({
4699
+ modelValue: e.value,
4700
+ "onUpdate:modelValue": v[1] || (v[1] = (c) => e.value = c)
4701
+ }, (i = _.value) == null ? void 0 : i.props), null, 16, ["modelValue"]))
4702
+ ])
4703
+ ]);
4704
+ };
4705
+ }
4706
+ }), Ni = { class: "px-24 h-full relative" }, Bi = /* @__PURE__ */ G({
4707
+ __name: "Integration",
4708
+ setup(f) {
4709
+ const o = E(void 0), { params: e } = Ge(), s = $e(), x = E();
4710
+ Ee(async () => {
4711
+ s.settings.length === 0 && await s.getSettings();
4712
+ }), _e(
4713
+ () => s.settings,
4714
+ (_) => {
4715
+ var w;
4716
+ const F = _.find((h) => h._id === e.id);
4717
+ F && (x.value = F, o.value = (w = x.value.platform) == null ? void 0 : w.name);
4718
+ },
4719
+ { immediate: !0 }
4720
+ );
4721
+ const k = H(() => {
4722
+ switch (o.value) {
4723
+ case xe.Xero:
4724
+ return io;
4725
+ case xe.Bukku:
4726
+ return aa;
4727
+ case xe.AutoCount:
4728
+ return Ea;
4729
+ case xe.SQL:
4730
+ return Ul;
4731
+ case xe.iFlexi_HRMS:
4732
+ return gs;
4733
+ case xe.Biztory:
4734
+ return zn;
4735
+ case xe.AutoCountCloud:
4736
+ return Ti;
4737
+ default:
4738
+ return null;
4739
+ }
4740
+ });
4741
+ return (_, F) => (d(), S("div", Ni, [
4742
+ (d(), M(ke(k.value), {
4743
+ modelValue: x.value,
4744
+ "onUpdate:modelValue": F[0] || (F[0] = (w) => x.value = w)
4745
+ }, null, 8, ["modelValue"]))
4746
+ ]));
4747
+ }
4748
+ });
4749
+ export {
4750
+ Bi as default
4751
+ };