@feedmepos/mf-report 5.4.11-beta.0 → 5.4.11-beta.1

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