@feedmepos/mf-inventory-portal 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/{App-BU_WSlx-.js → App-BkpSG-20.js} +1 -1
  2. package/dist/{ApprovalView-l2DdsNXH.js → ApprovalView-B7GuyNL8.js} +2 -2
  3. package/dist/{BindingsDialog-B4tQ9oQ2.js → BindingsDialog-DU7WwMQQ.js} +2 -2
  4. package/dist/{BindingsPicker-mVGeJMi2.js → BindingsPicker-DoikTRt9.js} +1 -1
  5. package/dist/{BindingsTable-CQfPvj8g.js → BindingsTable-CR_HLrBt.js} +1 -1
  6. package/dist/ClosingDraftView-B-zuhr0m.js +1739 -0
  7. package/dist/{ClosingTemplateView-DaYjDBPc.js → ClosingTemplateView-BXnzvooK.js} +2 -2
  8. package/dist/{DeliveryOrderPrintPreview-vHQa4Pma.js → DeliveryOrderPrintPreview-BGii4E5k.js} +1 -1
  9. package/dist/{FmAdminBadge-DUYqoh_b.js → FmAdminBadge-C7SFFAsw.js} +1 -1
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-SmAbact2.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CLSMS6lS.js} +3 -3
  11. package/dist/{FmMultiselectDialog-CKfAAKn7.js → FmMultiselectDialog-DxrZDApl.js} +1 -1
  12. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-a967Y4eW.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CG8hJ9BY.js} +1 -1
  13. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CBI-U1s2.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CaW3WMvN.js} +1 -1
  14. package/dist/{IngredientGroupView-CeQ7PRmJ.js → IngredientGroupView-CZXIEHF9.js} +2 -2
  15. package/dist/{IngredientsView-BmN-1mUc.js → IngredientsView-BsD9bz4s.js} +4 -4
  16. package/dist/{IntegrationView-Cm4jdNzA.js → IntegrationView-BwZLCHKQ.js} +4 -4
  17. package/dist/{InventoryBindingForm-CbDjrC3O.js → InventoryBindingForm-D1DjZ8GU.js} +1 -1
  18. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BLuD-xKb.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-977ZTGqB.js} +3 -3
  19. package/dist/{InventoryBindingSummary-nBwMH1KR.js → InventoryBindingSummary-DzTHC4EA.js} +1 -1
  20. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-EAczeEql.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CVjIweiD.js} +1 -1
  21. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-xF4w1bLo.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BOynbtg3.js} +1 -1
  22. package/dist/{PublishView-CJbpgj4t.js → PublishView-Qpnsfl9u.js} +1 -1
  23. package/dist/{PurchaseOrderPrintPreview-CKL-ESMG.js → PurchaseOrderPrintPreview-Cu0Huq0q.js} +1 -1
  24. package/dist/{ReceiveRequestView-BXup2Y5i.js → ReceiveRequestView-4-0jJ5tI.js} +8 -8
  25. package/dist/{RecipeView-CYiaWfO2.js → RecipeView-CkzCMbst.js} +3 -3
  26. package/dist/{StockView-B5ZGzrsN.js → StockView-C2GZw_2q.js} +7 -7
  27. package/dist/{SupplierView-DpJB7y5J.js → SupplierView-BMBCSjIF.js} +3 -3
  28. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Bnw-GVII.js → TransferDetails.vue_vue_type_script_setup_true_lang-CNfrMUvj.js} +6 -6
  29. package/dist/{TransferTemplateView-2x7CoPG6.js → TransferTemplateView-BpGi9pYo.js} +6 -6
  30. package/dist/{UnitView-D7gJR81B.js → UnitView-CyelRDgW.js} +3 -3
  31. package/dist/{WarehouseView-Cdmvo8AX.js → WarehouseView-CB1LmtPm.js} +1 -1
  32. package/dist/{app-7RQRfUWP.js → app-DLJ3tarV.js} +8196 -8174
  33. package/dist/app.js +1 -1
  34. package/dist/{decimal-BG61A172.js → decimal-Y-vsqUV6.js} +1 -1
  35. package/dist/{format-unit-display-BcCVYu07.js → format-unit-display-52tZYV50.js} +2 -2
  36. package/dist/{index-B9eaFsQz.js → index-PtOchBO2.js} +1 -1
  37. package/dist/{index-BP5fDtDw.js → index-Z9YSq95U.js} +1 -1
  38. package/dist/{stock-B59nAkMB.js → stock-CN530yZJ.js} +1 -1
  39. package/dist/{supplier-T0SjVZcK.js → supplier-B5VFlEyS.js} +1 -1
  40. package/dist/{use-ingredient-select-dialog-Rvaune-D.js → use-ingredient-select-dialog-CrLCvhtp.js} +1 -1
  41. package/dist/{use-inventory-binding-dialog-DNSWmOzX.js → use-inventory-binding-dialog-zoNELf20.js} +1 -1
  42. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +3 -3
  43. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +2 -2
  44. package/package.json +3 -3
  45. package/dist/ClosingDraftView-BJOcWcjt.js +0 -1687
@@ -0,0 +1,1739 @@
1
+ import { defineComponent as Te, ref as H, computed as L, onMounted as Le, resolveComponent as P, openBlock as x, createElementBlock as U, Fragment as J, createTextVNode as Z, createBlock as X, withCtx as O, createElementVNode as o, toDisplayString as W, unref as F, createVNode as D, createCommentVNode as ee, h as T, reactive as nt, watch as ot, isRef as Ye, normalizeClass as Ae, renderList as he, normalizeStyle as Ke, Teleport as st, mergeProps as rt } from "vue";
2
+ import { a4 as lt, u as Ie, aq as E, ai as Ge, ar as qe, n as ct, Q as Ee, j as N, t as it, V as xe, s as ut, v as dt, w as mt, as as We, at as Ze, ad as Je, au as re, aj as ft, a6 as Me, a5 as le, a1 as Ue, D as Oe, i as Se, h as pt, f as vt, a as yt, T as Fe, C as gt, _ as bt, E as At, G as kt, J as je } from "./app-DLJ3tarV.js";
3
+ import { useCoreStore as Dt, useI18n as Qe } from "@feedmepos/mf-common";
4
+ import { useSnackbar as Ve, useDialog as _t, useProxiedModel as ht, components as be, useBreakpoints as xt } from "@feedmepos/ui-library";
5
+ import { defineStore as Xe, storeToRefs as wt } from "pinia";
6
+ import { a as He, u as et } from "./stock-CN530yZJ.js";
7
+ import { E as Ct } from "./empty-placeholder-wf6-BWE8.js";
8
+ const Re = lt((l, s) => {
9
+ function e() {
10
+ return Ie().currentLocation.dbName;
11
+ }
12
+ return {
13
+ async getDraft(u) {
14
+ const p = e(), _ = `${l.inventoryBackendUrl}/${p}/closing-draft/${u}`;
15
+ return s.get(_);
16
+ },
17
+ async readDrafts() {
18
+ const u = e(), p = `${l.inventoryBackendUrl}/${u}/closing-draft`;
19
+ return s.get(p);
20
+ },
21
+ async runOperation(u) {
22
+ const p = e(), _ = `${l.inventoryBackendUrl}/${p}/closing-draft/run-operation`;
23
+ return s.post(_, u);
24
+ },
25
+ async sync(u) {
26
+ const p = e(), _ = `${l.inventoryBackendUrl}/${p}/closing-draft/sync`;
27
+ return s.post(_, u);
28
+ }
29
+ };
30
+ }), St = { class: "fm-typo-en-body-lg-400" }, Ft = { class: "fm-typo-en-body-lg-600" }, jt = {
31
+ key: 0,
32
+ class: "flex flex-col"
33
+ }, Bt = { class: "flex gap-12 py-8 justify-end w-full" }, Pe = /* @__PURE__ */ Te({
34
+ __name: "ClosingDraftAction",
35
+ props: {
36
+ draft: {},
37
+ action: {},
38
+ onCancel: { type: Function },
39
+ onFinished: { type: Function }
40
+ },
41
+ setup(l) {
42
+ const s = l, e = H(), u = Re(), p = Ve(), _ = H(!1), m = H(null), R = H(!1), w = L(() => {
43
+ switch (s.action) {
44
+ case E.enum.approveDraft:
45
+ return "Approve";
46
+ case E.enum.rejectDraft:
47
+ return "Reject";
48
+ case E.enum.markAsFailed:
49
+ return "Mark as Failed";
50
+ }
51
+ throw new Error(`Unknown action: ${s.action}`);
52
+ }), h = L(() => {
53
+ switch (s.action) {
54
+ case E.enum.approveDraft:
55
+ return "primary";
56
+ case E.enum.rejectDraft:
57
+ return "destructive";
58
+ case E.enum.markAsFailed:
59
+ return "destructive";
60
+ }
61
+ throw new Error(`Unknown action: ${s.action}`);
62
+ });
63
+ Le(() => {
64
+ if (s.draft.effectiveAt)
65
+ m.value = new Date(s.draft.effectiveAt);
66
+ else {
67
+ const n = new Date(s.draft.createdAt);
68
+ n.setHours(23, 59, 59, 999), m.value = n;
69
+ }
70
+ R.value = !0;
71
+ });
72
+ const v = L({
73
+ get() {
74
+ return m.value === null ? "" : Ge(m.value);
75
+ },
76
+ set(n) {
77
+ if (n) {
78
+ const a = /* @__PURE__ */ new Date(`${n} ${I.value}`);
79
+ a.setSeconds(59, 999), m.value = a;
80
+ } else
81
+ m.value = null;
82
+ }
83
+ }), I = L({
84
+ get() {
85
+ return m.value === null ? "" : qe(m.value);
86
+ },
87
+ set(n) {
88
+ if (n) {
89
+ const a = /* @__PURE__ */ new Date(`${v.value} ${n}`);
90
+ a.setSeconds(59, 999), m.value = a;
91
+ } else
92
+ m.value = null;
93
+ }
94
+ });
95
+ async function Y() {
96
+ _.value = !0;
97
+ try {
98
+ await u.runOperation({
99
+ _id: s.draft._id,
100
+ _rev: s.draft._rev ?? "",
101
+ action: s.action,
102
+ data: {
103
+ effectiveAt: m.value ? m.value.toISOString() : null,
104
+ remark: e.value
105
+ }
106
+ }).delayed(500), p.open({
107
+ title: "Success",
108
+ message: "Action submitted",
109
+ type: "success"
110
+ }), s.onFinished();
111
+ } catch (n) {
112
+ p.open({
113
+ title: "Something went wrong",
114
+ message: "Unable to submit action. Please try again",
115
+ type: "error"
116
+ }), console.error("error on submit closing draft action", n);
117
+ } finally {
118
+ _.value = !1;
119
+ }
120
+ }
121
+ return (n, a) => {
122
+ const j = P("FmLabel"), M = P("FmDatePicker"), f = P("FmTimePicker"), g = P("FmTextField"), k = P("FmButton"), $ = P("FmForm");
123
+ return R.value ? (x(), X($, {
124
+ key: 1,
125
+ onValidationSuccess: Y,
126
+ class: "flex flex-col gap-32",
127
+ disabled: _.value
128
+ }, {
129
+ default: O(() => [
130
+ o("div", St, [
131
+ a[4] || (a[4] = Z(" You are about to ")),
132
+ o("span", Ft, W(w.value), 1),
133
+ a[5] || (a[5] = Z(" this draft. Please provide a remark to justify this action. "))
134
+ ]),
135
+ n.action === F(E).enum.approveDraft ? (x(), U("div", jt, [
136
+ D(j, { class: "fm-typo-en-body-lg-600" }, {
137
+ default: O(() => a[6] || (a[6] = [
138
+ Z("Closing Date")
139
+ ])),
140
+ _: 1
141
+ }),
142
+ D(M, {
143
+ modelValue: v.value,
144
+ "onUpdate:modelValue": a[0] || (a[0] = (V) => v.value = V)
145
+ }, null, 8, ["modelValue"]),
146
+ D(j, { class: "fm-typo-en-body-lg-600" }, {
147
+ default: O(() => a[7] || (a[7] = [
148
+ Z("Closing Time")
149
+ ])),
150
+ _: 1
151
+ }),
152
+ D(f, {
153
+ modelValue: I.value,
154
+ "onUpdate:modelValue": a[1] || (a[1] = (V) => I.value = V)
155
+ }, null, 8, ["modelValue"])
156
+ ])) : ee("", !0),
157
+ D(g, {
158
+ modelValue: e.value,
159
+ "onUpdate:modelValue": a[2] || (a[2] = (V) => e.value = V),
160
+ label: "Remark",
161
+ "label-mark": "required",
162
+ rules: [F(ct)()]
163
+ }, null, 8, ["modelValue", "rules"]),
164
+ o("div", Bt, [
165
+ D(k, {
166
+ label: "Cancel",
167
+ variant: "tertiary",
168
+ onClick: a[3] || (a[3] = (V) => n.onCancel())
169
+ }),
170
+ D(k, {
171
+ label: w.value,
172
+ type: "submit",
173
+ variant: h.value,
174
+ loading: _.value
175
+ }, null, 8, ["label", "variant", "loading"])
176
+ ])
177
+ ]),
178
+ _: 1
179
+ }, 8, ["disabled"])) : (x(), U(J, { key: 0 }, [
180
+ Z("Loading")
181
+ ], 64));
182
+ };
183
+ }
184
+ }), $t = xe(0);
185
+ function tt(l) {
186
+ const s = l.measurementsAmounts.groupBy((u) => u.measurement.id), e = l.sku.unit.measurements.reduce((u, p) => {
187
+ var R, w;
188
+ const _ = ((w = (R = s.get(p.id)) == null ? void 0 : R[0]) == null ? void 0 : w.amount) ?? $t, m = Ee(p.conversion, _);
189
+ return u + +N(m);
190
+ }, +N(l.baseAmount));
191
+ return it(e, l.baseAmount.precision);
192
+ }
193
+ const Tt = xe(0), It = xe(100);
194
+ function Rt(l, s, e, u) {
195
+ const p = tt(l), _ = u ?? p, m = We(_, s), R = s.amount === 0 ? null : Ze(m, {
196
+ ...s,
197
+ amount: Math.abs(s.amount)
198
+ }), w = R ? Ee(R, It) : null;
199
+ return {
200
+ code: l.sku.code,
201
+ name: l.sku.name,
202
+ baseUnit: l.sku.unit.abbrev,
203
+ baseUnitAmount: +N(l.baseAmount),
204
+ ...l.measurementsAmounts.filter(
205
+ (v) => Pt(v.measurement) && e.includes(v.measurement.id)
206
+ ).reduce(
207
+ (v, I, Y) => (v[`measurementAbbrev${Y}`] = `(${I.measurement.abbrev}) × ${N(I.measurement.conversion)}`, v[`measurementAmount${Y}`] = +N(I.amount), v),
208
+ {}
209
+ ),
210
+ systemBalance: +N(s),
211
+ physicalBalance: +N(_),
212
+ adjustedAmount: +N(m),
213
+ adjustedDiffPercentage: w ? +N(Je(w, 2)) : null
214
+ };
215
+ }
216
+ function Pt(l) {
217
+ return !l.abbrev.toLocaleLowerCase().includes("inactive");
218
+ }
219
+ function Mt(l) {
220
+ const s = at(l);
221
+ return l.reduce(
222
+ (e, u) => {
223
+ var p;
224
+ return Math.max(e, ((p = s == null ? void 0 : s.get(u.sku._id)) == null ? void 0 : p[0].length) ?? 0);
225
+ },
226
+ 0
227
+ );
228
+ }
229
+ function at(l) {
230
+ return l.groupBy(
231
+ (s) => s.sku._id,
232
+ (s) => s.measurementsAmounts.filter((e) => !e.measurement.abbrev.toLocaleLowerCase().includes("inactive")).map((e) => e.measurement.id)
233
+ );
234
+ }
235
+ function Ut(l) {
236
+ return [
237
+ {
238
+ id: "code",
239
+ name: "Code"
240
+ },
241
+ {
242
+ id: "name",
243
+ name: "Name"
244
+ },
245
+ {
246
+ id: "systemBalance",
247
+ name: "Balance"
248
+ },
249
+ {
250
+ id: "physicalBalance",
251
+ name: "Actual balance"
252
+ },
253
+ {
254
+ id: "adjustedAmount",
255
+ name: "Adjusted balance"
256
+ },
257
+ {
258
+ id: "adjustedDiffPercentage",
259
+ name: "Diff (%)"
260
+ },
261
+ {
262
+ id: "baseUnitAmount",
263
+ name: "Base unit amount"
264
+ },
265
+ {
266
+ id: "baseUnit",
267
+ name: "Base unit"
268
+ },
269
+ ...Array.from({ length: l }).flatMap((e, u) => [
270
+ {
271
+ id: `measurementAmount${u}`,
272
+ name: `UOM amount ${u + 1}`
273
+ },
274
+ {
275
+ id: `measurementAbbrev${u}`,
276
+ name: `UOM ${u + 1}`
277
+ }
278
+ ])
279
+ ];
280
+ }
281
+ function Lt(l, s, e) {
282
+ var M, f, g, k, $, V, te;
283
+ const u = s.groupBy(
284
+ (B) => B.id,
285
+ (B) => B.balance
286
+ ), p = e.groupBy(
287
+ (B) => B.id,
288
+ (B) => B.balance
289
+ ), _ = [...l.items, ...l.negativeStockItems ?? []], m = at(_), R = _.map((B) => {
290
+ var ie, ue, de;
291
+ const Q = ((ie = u.get(B.sku._id)) == null ? void 0 : ie[0]) ?? Tt, ce = ((ue = m == null ? void 0 : m.get(B.sku._id)) == null ? void 0 : ue[0]) ?? [];
292
+ return Rt(
293
+ B,
294
+ Q,
295
+ ce,
296
+ (de = p.get(B.sku._id)) == null ? void 0 : de[0]
297
+ );
298
+ }), w = Mt(_), v = Dt().currentBusiness.value, I = Ut(w), Y = [
299
+ ["Business name:", v == null ? void 0 : v.name],
300
+ ["Business ID:", v == null ? void 0 : v._id],
301
+ ["Menu version", v == null ? void 0 : v.menuVersion],
302
+ ["Created at", new Date(l.createdAt)],
303
+ ["Created by", (M = l.createdBy) == null ? void 0 : M.name],
304
+ ["Updated at", new Date(l.updatedAt)],
305
+ ["Updated by", (f = l.updatedBy) == null ? void 0 : f.name],
306
+ ["Recent action", l.approvedAt ? "Approve" : l.rejectionHistory ? "Reject" : ""],
307
+ [
308
+ "Action by",
309
+ l.approvedAt ? (g = l.approvedBy) == null ? void 0 : g.name : l.rejectionHistory ? ($ = (k = l.rejectionHistory[0]) == null ? void 0 : k.rejectedBy) == null ? void 0 : $.name : ""
310
+ ],
311
+ [
312
+ "Action at",
313
+ l.approvedAt ? new Date(l.approvedAt) : l.rejectionHistory ? new Date((V = l.rejectionHistory[0]) == null ? void 0 : V.rejectedAt) : ""
314
+ ],
315
+ [
316
+ "Action remark",
317
+ l.approvedAt ? l.approveRemark : l.rejectionHistory ? new Date((te = l.rejectionHistory[0]) == null ? void 0 : te.rejectRemark) : ""
318
+ ],
319
+ [],
320
+ I.map((B) => B.name),
321
+ ...R.map((B) => I.map((Q) => B[Q.id]))
322
+ ], n = I.map((B) => `system:${B.id}`), a = ut(Y, n), j = `[${v == null ? void 0 : v.name}] closing draft (${dt(new Date(l.updatedAt))}).xlsx`;
323
+ return mt(a, j), j;
324
+ }
325
+ const Et = { class: "flex flex-col" }, Vt = { class: "flex gap-12 py-8 justify-end w-full" }, Ht = /* @__PURE__ */ Te({
326
+ __name: "RefreshBalanceAction",
327
+ props: {
328
+ draft: {},
329
+ onCancel: { type: Function },
330
+ onFinished: { type: Function }
331
+ },
332
+ setup(l) {
333
+ const s = l;
334
+ He();
335
+ const e = H(!1), u = H(null), p = H(!1);
336
+ Le(() => {
337
+ if (s.draft.effectiveAt)
338
+ u.value = new Date(s.draft.effectiveAt);
339
+ else {
340
+ const w = new Date(s.draft.createdAt);
341
+ w.setHours(23, 59, 59, 999), u.value = w;
342
+ }
343
+ p.value = !0;
344
+ });
345
+ const _ = L({
346
+ get() {
347
+ return u.value === null ? "" : Ge(u.value);
348
+ },
349
+ set(w) {
350
+ if (w) {
351
+ const h = /* @__PURE__ */ new Date(`${w} ${m.value}`);
352
+ h.setSeconds(59, 999), u.value = h;
353
+ } else
354
+ u.value = null;
355
+ }
356
+ }), m = L({
357
+ get() {
358
+ return u.value === null ? "" : qe(u.value);
359
+ },
360
+ set(w) {
361
+ if (w) {
362
+ const h = /* @__PURE__ */ new Date(`${_.value} ${w}`);
363
+ h.setSeconds(59, 999), u.value = h;
364
+ } else
365
+ u.value = null;
366
+ }
367
+ });
368
+ async function R() {
369
+ e.value = !0, s.onFinished(u.value.toISOString());
370
+ }
371
+ return (w, h) => {
372
+ const v = P("FmLabel"), I = P("FmDatePicker"), Y = P("FmTimePicker"), n = P("FmButton"), a = P("FmForm");
373
+ return p.value ? (x(), X(a, {
374
+ key: 1,
375
+ onValidationSuccess: R,
376
+ class: "flex flex-col gap-32",
377
+ disabled: e.value
378
+ }, {
379
+ default: O(() => [
380
+ h[5] || (h[5] = o("div", { class: "fm-typo-en-body-lg-400" }, [
381
+ o("p", null, [
382
+ Z(" Performing "),
383
+ o("span", { class: "fm-typo-en-body-lg-600" }, '"Refresh Balance"'),
384
+ Z(" until closing effective date and time. ")
385
+ ]),
386
+ o("p", { class: "mt-2" }, [
387
+ Z(" Please note that this action will "),
388
+ o("b", null, "update"),
389
+ Z(" the effective date and time. ")
390
+ ])
391
+ ], -1)),
392
+ o("div", Et, [
393
+ D(v, { class: "fm-typo-en-body-lg-600" }, {
394
+ default: O(() => h[3] || (h[3] = [
395
+ Z("Closing Date")
396
+ ])),
397
+ _: 1
398
+ }),
399
+ D(I, {
400
+ modelValue: _.value,
401
+ "onUpdate:modelValue": h[0] || (h[0] = (j) => _.value = j)
402
+ }, null, 8, ["modelValue"]),
403
+ D(v, { class: "fm-typo-en-body-lg-600" }, {
404
+ default: O(() => h[4] || (h[4] = [
405
+ Z("Closing Time")
406
+ ])),
407
+ _: 1
408
+ }),
409
+ D(Y, {
410
+ modelValue: m.value,
411
+ "onUpdate:modelValue": h[1] || (h[1] = (j) => m.value = j)
412
+ }, null, 8, ["modelValue"])
413
+ ]),
414
+ o("div", Vt, [
415
+ D(n, {
416
+ label: "Cancel",
417
+ variant: "tertiary",
418
+ onClick: h[2] || (h[2] = (j) => w.onCancel())
419
+ }),
420
+ D(n, {
421
+ label: "Refresh balance",
422
+ type: "submit",
423
+ variant: "primary",
424
+ loading: e.value
425
+ }, null, 8, ["loading"])
426
+ ])
427
+ ]),
428
+ _: 1
429
+ }, 8, ["disabled"])) : (x(), U(J, { key: 0 }, [
430
+ Z("Loading")
431
+ ], 64));
432
+ };
433
+ }
434
+ }), $e = Xe(
435
+ "closingDraftActions",
436
+ function() {
437
+ const s = _t(), e = Ve(), u = He(), p = Re(), _ = et(), m = H(!1), R = H();
438
+ function w(f) {
439
+ const g = {
440
+ draft: f
441
+ };
442
+ R.value = g, m.value = !0;
443
+ }
444
+ async function h(f) {
445
+ var k;
446
+ if (f.status === re.enum.COMPLETED) {
447
+ const $ = f.closingAdjustmentId;
448
+ if (!$)
449
+ return e.open({
450
+ title: "Something went wrong",
451
+ message: "Closing draft is completed but closing document cannot be found.",
452
+ type: "error"
453
+ }), console.error("Closing draft is completed but closing document cannot be found.", {
454
+ draftId: f._id
455
+ }), [];
456
+ const V = await u.readAdjustmentById($);
457
+ return ((V == null ? void 0 : V.skus) ?? []).map((B) => ({
458
+ id: B.sku._id,
459
+ balance: B.fromBalance,
460
+ costs: B.fromCostBalances
461
+ }));
462
+ } else
463
+ return await _.readStockBalance(), ((k = _.stockBalance) == null ? void 0 : k.skus) ?? [];
464
+ }
465
+ async function v(f, g, k) {
466
+ g || (e.open({
467
+ title: "Exporting",
468
+ message: "Fetching data..."
469
+ }), g = await h(f)), Lt(f, g, k ?? []);
470
+ }
471
+ function I(f, g) {
472
+ s.open({
473
+ title: "Approve draft",
474
+ contentComponent: Pe,
475
+ contentComponentProps: {
476
+ draft: f,
477
+ action: E.enum.approveDraft,
478
+ onFinished: () => {
479
+ s.close(), g == null || g();
480
+ },
481
+ onCancel: () => s.close()
482
+ }
483
+ });
484
+ }
485
+ function Y(f, g) {
486
+ s.open({
487
+ title: "Reject draft",
488
+ contentComponent: Pe,
489
+ contentComponentProps: {
490
+ draft: f,
491
+ action: E.enum.rejectDraft,
492
+ onFinished: () => {
493
+ s.close(), g == null || g();
494
+ },
495
+ onCancel: () => s.close()
496
+ }
497
+ });
498
+ }
499
+ function n(f, g) {
500
+ s.open({
501
+ title: "Mark draft as failed",
502
+ contentComponent: Pe,
503
+ contentComponentProps: {
504
+ draft: f,
505
+ action: E.enum.markAsFailed,
506
+ onFinished: () => {
507
+ s.close(), g == null || g();
508
+ },
509
+ onCancel: () => s.close()
510
+ }
511
+ });
512
+ }
513
+ async function a(f, g) {
514
+ await p.sync({
515
+ _id: f._id,
516
+ _rev: f._rev ?? "",
517
+ action: E.enum.approveDraft,
518
+ data: {
519
+ remark: f.remark ?? ""
520
+ }
521
+ }).delayed(500), e.open({
522
+ title: "Success",
523
+ message: "Sync requested",
524
+ type: "success"
525
+ }), g == null || g();
526
+ }
527
+ function j() {
528
+ m.value = !1;
529
+ }
530
+ async function M(f, g, k) {
531
+ await s.open({
532
+ title: "Refresh balance",
533
+ contentComponent: Ht,
534
+ contentComponentProps: {
535
+ draft: f,
536
+ onFinished: ($) => {
537
+ s.close(), k == null || k($);
538
+ },
539
+ onCancel: async () => {
540
+ s.close(), g == null || g();
541
+ }
542
+ }
543
+ });
544
+ }
545
+ return {
546
+ viewDraft: w,
547
+ closeDraftDialog: j,
548
+ approveDraft: I,
549
+ rejectDraft: Y,
550
+ markAsFailed: n,
551
+ syncDraft: a,
552
+ exportDraft: v,
553
+ refreshBalance: M,
554
+ viewClosingDraftShow: m,
555
+ viewClosingDraftProps: R
556
+ };
557
+ }
558
+ );
559
+ function Be(l) {
560
+ switch (l) {
561
+ case "DRAFT":
562
+ return "fm-status-badge-draft";
563
+ case "PROCESSING":
564
+ return "fm-status-badge-processing";
565
+ case "FAILED":
566
+ return "fm-status-badge-cancel";
567
+ case "COMPLETED":
568
+ return "fm-status-badge-complete";
569
+ }
570
+ }
571
+ const Nt = Xe(
572
+ "closingDraftTable",
573
+ function() {
574
+ const { t: s } = Qe(), e = $e(), u = H(new Array()), p = H(!1), _ = Ie(), m = Re();
575
+ async function R() {
576
+ if (u.value = [], !!_._currentLocation) {
577
+ p.value = !0;
578
+ try {
579
+ const [n] = await Promise.all([m.readDrafts()]).delayed(1e3);
580
+ u.value = n.reverse();
581
+ } catch (n) {
582
+ console.log("Something went wrong when fetching drafts:", n);
583
+ } finally {
584
+ p.value = !1;
585
+ }
586
+ }
587
+ }
588
+ async function w(n) {
589
+ if (!u.value.find((a) => a._id) && _._currentLocation) {
590
+ p.value = !0;
591
+ try {
592
+ const [a] = await Promise.all([
593
+ m.getDraft(n),
594
+ new Promise((j) => setTimeout(j, 1e3))
595
+ ]);
596
+ u.value = [a];
597
+ } catch (a) {
598
+ console.log("Something went wrong when fetching drafts:", a);
599
+ } finally {
600
+ p.value = !1;
601
+ }
602
+ }
603
+ }
604
+ function h(n) {
605
+ u.value = u.value.map((a) => a._id === n._id ? {
606
+ ...n,
607
+ _rev: a._rev
608
+ } : a);
609
+ }
610
+ function v() {
611
+ e.closeDraftDialog(), R();
612
+ }
613
+ function I(n, a) {
614
+ switch (a = vt(a), n) {
615
+ case Se.Details:
616
+ return e.viewDraft(a);
617
+ case Se.Export:
618
+ return e.exportDraft(a);
619
+ case E.enum.approveDraft:
620
+ return e.approveDraft(a, v);
621
+ case E.enum.rejectDraft:
622
+ return e.rejectDraft(a, v);
623
+ case E.enum.markAsFailed:
624
+ return e.markAsFailed(a, v);
625
+ }
626
+ }
627
+ return {
628
+ columnDefs: [
629
+ {
630
+ id: "_id",
631
+ accessorKey: "_id",
632
+ header: () => s("inventory.closing.table.createdAt"),
633
+ cell(n) {
634
+ return ft(`${n.getValue()}`);
635
+ },
636
+ enableSorting: !0
637
+ },
638
+ {
639
+ accessorKey: "effectiveAt",
640
+ header: () => "Effective at",
641
+ cell(n) {
642
+ const a = n.row.original;
643
+ let j = n.getValue();
644
+ return j || (j = Me(a._id)), le(j);
645
+ },
646
+ enableSorting: !0,
647
+ size: 200
648
+ },
649
+ {
650
+ id: "updatedAt",
651
+ accessorFn: (n) => le(n.updatedAt),
652
+ header: () => "Updated at",
653
+ enableSorting: !0,
654
+ size: 200
655
+ },
656
+ {
657
+ id: "updatedBy",
658
+ accessorKey: "updatedBy.name",
659
+ header: () => "Last update by",
660
+ enableSorting: !0,
661
+ size: 200
662
+ },
663
+ {
664
+ id: "noOfItems",
665
+ accessorFn: (n) => {
666
+ var a;
667
+ return n.items.length + (((a = n.negativeStockItems) == null ? void 0 : a.length) ?? 0);
668
+ },
669
+ header: () => s("inventory.closing.table.noOfItems"),
670
+ enableSorting: !1,
671
+ meta: {
672
+ width: "10rem",
673
+ textAlign: "right"
674
+ }
675
+ },
676
+ {
677
+ id: "recentRemark",
678
+ accessorFn: (n) => {
679
+ var a;
680
+ return (n == null ? void 0 : n.approveRemark) ?? ((a = n == null ? void 0 : n.rejectionHistory) == null ? void 0 : a.computeFirst((j) => j.rejectRemark)) ?? n.remark;
681
+ },
682
+ header: () => "Recent remark"
683
+ },
684
+ {
685
+ id: "status",
686
+ accessorFn: (n) => n.status,
687
+ header: () => s("inventory.closing.table.status"),
688
+ enableSorting: !1,
689
+ cell(n) {
690
+ var k;
691
+ const a = n.row.original, j = a.status, M = new Date(a.updatedAt), f = (k = a == null ? void 0 : a.rejectionHistory) == null ? void 0 : k.computeFirst(($) => $.rejectedAt), g = f ? new Date(f) : null;
692
+ return j === "DRAFT" && g ? g.getTime() > M.getTime() ? T(
693
+ "div",
694
+ {
695
+ class: "flex"
696
+ },
697
+ T(
698
+ "div",
699
+ {
700
+ class: ["fm-status-badge", Be("FAILED")]
701
+ },
702
+ "Rejected"
703
+ )
704
+ ) : T(
705
+ "div",
706
+ {
707
+ class: "flex"
708
+ },
709
+ T(
710
+ "div",
711
+ {
712
+ class: ["fm-status-badge", Be("PROCESSING")]
713
+ },
714
+ "Updated"
715
+ )
716
+ ) : T(
717
+ "div",
718
+ {
719
+ class: "flex"
720
+ },
721
+ T(
722
+ "div",
723
+ {
724
+ class: ["fm-status-badge", Be(j)]
725
+ },
726
+ Ue(j)
727
+ )
728
+ );
729
+ }
730
+ },
731
+ {
732
+ id: "action",
733
+ cell(n) {
734
+ const a = n.row.original, j = [
735
+ Oe[Se.Details],
736
+ Oe[Se.Export]
737
+ ], M = [
738
+ {
739
+ translationKey: "inventory.closing.draft.approveDraft",
740
+ color: "text-fm-color-typo-primary",
741
+ value: E.enum.approveDraft
742
+ },
743
+ {
744
+ translationKey: "inventory.closing.draft.rejectDraft",
745
+ color: "text-fm-color-typo-error",
746
+ value: E.enum.rejectDraft
747
+ },
748
+ {
749
+ translationKey: "inventory.closing.draft.markAsFailed",
750
+ color: "text-fm-color-typo-error",
751
+ value: E.enum.markAsFailed
752
+ }
753
+ ];
754
+ return pt(
755
+ [
756
+ ...j,
757
+ ...a.status === re.enum.DRAFT ? M : []
758
+ ],
759
+ (f) => I(f, a)
760
+ );
761
+ },
762
+ enableSorting: !1,
763
+ size: 40,
764
+ meta: {
765
+ cellClass: "",
766
+ headerClass: ""
767
+ }
768
+ }
769
+ ],
770
+ drafts: u,
771
+ loading: p,
772
+ fetchDrafts: R,
773
+ loadDraft: w,
774
+ updateDraftRef: h
775
+ };
776
+ }
777
+ ), zt = { class: "w-full flex flex-col gap-32" }, Ot = { class: "flex justify-between" }, Yt = { class: "flex" }, Kt = { class: "grid grid-cols-[repeat(4,1fr)] xs:flex xs:flex-col sm:flex sm:flex-col gap-8" }, Gt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, qt = { class: "flex gap-1" }, Wt = { class: "fm-typo-en-body-lg-600" }, Zt = { class: "flex flex-col gap-16" }, Jt = { class: "flex items-center" }, Qt = {
778
+ key: 0,
779
+ class: "flex gap-8"
780
+ }, Xt = {
781
+ key: 0,
782
+ class: "w-full flex flex-col items-center"
783
+ }, ea = { class: "flex items-center gap-8" }, ta = { class: "flex flex-col gap-8" }, aa = { class: "flex gap-8" }, na = {
784
+ key: 0,
785
+ class: "flex gap-8"
786
+ }, oa = { class: "overflow-x-auto" }, sa = {
787
+ key: 1,
788
+ class: "flex-1 xs:w-screen xs:max-w-full"
789
+ }, ra = {
790
+ key: 0,
791
+ class: "flex flex-col items-center gap-8 h-full"
792
+ }, la = ["src"], ca = {
793
+ key: 1,
794
+ class: "px-4 flex flex-col"
795
+ }, ia = { class: "flex gap-12 content-stretch" }, ua = {
796
+ class: "flex flex-col w-24",
797
+ name: "circles"
798
+ }, da = { class: "flex-1 flex flex-col items-center" }, ma = { class: "flex-1 flex flex-col items-center" }, fa = {
799
+ class: "py-12 flex flex-col gap-4",
800
+ name: "received-at header"
801
+ }, pa = { class: "fm-typo-en-body-lg-400" }, va = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ya = { class: "flex gap-12 content-stretch" }, ga = {
802
+ class: "flex flex-col w-24",
803
+ name: "circles"
804
+ }, ba = { class: "flex-1 flex flex-col items-center" }, Aa = {
805
+ class: "py-12 flex flex-col gap-4 flex-1",
806
+ name: "delivery details"
807
+ }, ka = { class: "flex flex-col gap-8" }, Da = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _a = { class: "flex flex-col gap-4" }, ha = { class: "flex gap-8" }, xa = /* @__PURE__ */ Te({
808
+ __name: "ClosingDraftDialog",
809
+ props: {
810
+ show: { type: Boolean },
811
+ draft: {}
812
+ },
813
+ emits: ["submitted", "refresh"],
814
+ setup(l, { emit: s }) {
815
+ const e = l, u = et(), p = $e(), _ = ht(e, "show"), m = H(!1), R = H(!1), w = H(!1), h = H(new Array()), v = H(new Array()), I = He(), Y = Re(), n = Ve(), a = yt(), j = Ie(), M = nt({}), f = L(() => new Set(
816
+ a.skus.filter((r) => {
817
+ var t;
818
+ return M[(t = r.customAttributes) == null ? void 0 : t.tag];
819
+ }).map((r) => r._id)
820
+ )), g = s, k = H({
821
+ templateItem: !0,
822
+ nonTemplateItem: !0
823
+ }), $ = L(() => {
824
+ var t, y;
825
+ const r = [...((t = e.draft) == null ? void 0 : t.items) ?? [], ...((y = e.draft) == null ? void 0 : y.negativeStockItems) ?? []];
826
+ return f.value.size ? r.filter((d) => f.value.has(d.sku._id)) : r;
827
+ }), V = L(() => {
828
+ const r = $.value.map((t) => t.sku);
829
+ return r.sort((t, y) => t.code.localeCompare(y.code)), r;
830
+ }), te = L(() => $.value.groupBy(
831
+ (t) => t.sku._id,
832
+ (t) => t.measurementsAmounts.filter((y) => !y.measurement.abbrev.toLocaleLowerCase().includes("inactive")).map((y) => y.measurement.id)
833
+ ));
834
+ Le(ce), ot(
835
+ () => e.show,
836
+ (r) => {
837
+ r && (se.value = ve[0], ce(), k.value = {
838
+ templateItem: !0,
839
+ nonTemplateItem: !0
840
+ });
841
+ }
842
+ );
843
+ const B = xe(0), Q = xe(100);
844
+ async function ce() {
845
+ var t, y, d;
846
+ if (!j._currentLocation) return;
847
+ m.value = !0;
848
+ const r = ((t = e.draft) == null ? void 0 : t.status) === re.enum.COMPLETED;
849
+ v.value = [];
850
+ try {
851
+ if (await a.init(), r) {
852
+ const i = e.draft.closingAdjustmentId;
853
+ if (!i) {
854
+ n.open({
855
+ title: "Something went wrong",
856
+ message: "Closing draft is completed but closing document cannot be found.",
857
+ type: "error"
858
+ }), console.error("Closing draft is completed but closing document cannot be found.", {
859
+ draftId: (y = e.draft) == null ? void 0 : y._id
860
+ });
861
+ return;
862
+ }
863
+ const c = await I.readAdjustmentById(i), A = (c == null ? void 0 : c.skus) ?? [];
864
+ for (const C in A) {
865
+ const b = A[C], q = {
866
+ id: b.sku._id,
867
+ balance: b.fromBalance,
868
+ costs: b.fromCostBalances
869
+ }, ye = {
870
+ id: b.sku._id,
871
+ balance: b.toBalance,
872
+ costs: b.toCostBalances
873
+ };
874
+ h.value.push(q), v.value.push(ye);
875
+ }
876
+ } else
877
+ h.value = ((d = e.draft) == null ? void 0 : d.stockSnapshot) ?? [];
878
+ } catch (i) {
879
+ n.open({
880
+ title: "Something went wrong",
881
+ message: "Something went wrong when fetching info. Please try again.",
882
+ type: "error"
883
+ }), console.error("error on fetch stock balances", i);
884
+ } finally {
885
+ m.value = !1;
886
+ }
887
+ }
888
+ async function ie() {
889
+ var t, y;
890
+ if (!(((t = e.draft) == null ? void 0 : t.effectiveAt) ?? (e.draft ? Me((y = e.draft) == null ? void 0 : y._id) : null))) {
891
+ n.open({
892
+ title: "Cannot refresh",
893
+ message: "Effective date is not available for this draft.",
894
+ type: "error"
895
+ });
896
+ return;
897
+ }
898
+ await p.refreshBalance(
899
+ e.draft,
900
+ () => {
901
+ },
902
+ async (d) => {
903
+ var C;
904
+ R.value = !0;
905
+ const i = (C = e.draft) == null ? void 0 : C._rev, c = 30, A = 2e3;
906
+ try {
907
+ await I.recalculation.scheduleCalculateStockSnapshotAtDate(d, e.draft._id);
908
+ let b = null;
909
+ for (let q = 0; q < c && (b = await Y.getDraft(e.draft._id).delayed(A), b._rev === i); q++)
910
+ ;
911
+ if (!b || b._rev === i) {
912
+ n.open({
913
+ title: "Refresh failed",
914
+ message: "Failed to refresh stock balance. Please try again.",
915
+ type: "error"
916
+ }), console.error("error refreshing stock balances: there is no change in _rev");
917
+ return;
918
+ }
919
+ g("refresh", b), h.value = b.stockSnapshot ?? [], n.open({
920
+ title: "Balance refreshed",
921
+ message: "Stock balance has been recalculated.",
922
+ type: "success"
923
+ });
924
+ } catch (b) {
925
+ n.open({
926
+ title: "Refresh failed",
927
+ message: "Failed to refresh stock balance. Please try again.",
928
+ type: "error"
929
+ }), console.error("error refreshing stock balances", b);
930
+ } finally {
931
+ R.value = !1;
932
+ }
933
+ }
934
+ );
935
+ }
936
+ const ue = L(
937
+ () => h.value.groupBy(
938
+ (r) => r.id,
939
+ (r) => r.balance
940
+ )
941
+ ), de = L(() => $.value.groupBy((r) => r.sku._id));
942
+ function oe(r) {
943
+ return T(
944
+ be.FmTooltip,
945
+ { zIndex: 51, placement: "left", class: "w-full flex justify-end" },
946
+ {
947
+ default() {
948
+ return r;
949
+ },
950
+ content() {
951
+ return "Differences are calculated using this formula: (Adjusted / System) × 100%";
952
+ }
953
+ }
954
+ );
955
+ }
956
+ const ke = L(() => {
957
+ const r = V.value.reduce((y, d) => {
958
+ var i, c;
959
+ return Math.max(y, ((c = (i = te.value) == null ? void 0 : i.get(d._id)) == null ? void 0 : c[0].length) ?? 0);
960
+ }, 0);
961
+ return [
962
+ {
963
+ id: "sku",
964
+ accessorFn: (y) => `${y.code} ${y.name}`,
965
+ header: () => "Name",
966
+ size: 350,
967
+ cell(y) {
968
+ const d = y.row.original, i = d.adjustedDiffPercentage, c = typeof i == "number" && Math.abs(i) > 10, A = T("div", { class: "flex flex-col gap-4" }, [
969
+ T(
970
+ "div",
971
+ {
972
+ class: [
973
+ "line-clamp-1 fm-typo-en-body-lg-400",
974
+ c ? " text-fm-color-system-error-300" : "text-fm-color-typo-primary"
975
+ ]
976
+ },
977
+ d.name
978
+ ),
979
+ T(
980
+ "div",
981
+ {
982
+ class: [
983
+ "line-clamp-1 fm-typo-en-body-md-400",
984
+ c ? " text-fm-color-system-error-300" : "text-fm-color-typo-secondary"
985
+ ]
986
+ },
987
+ d.code
988
+ )
989
+ ]);
990
+ return T(
991
+ be.FmTooltip,
992
+ {
993
+ zIndex: 51
994
+ },
995
+ {
996
+ content() {
997
+ return c ? "Adjustment difference is more than 10%." : `${d.code} - ${d.name}`;
998
+ },
999
+ default() {
1000
+ return T("div", { class: "flex items-center gap-4 justify-start w-full" }, [
1001
+ A
1002
+ ]);
1003
+ }
1004
+ }
1005
+ );
1006
+ }
1007
+ },
1008
+ {
1009
+ id: "baseUnit",
1010
+ header: () => "Base unit",
1011
+ accessorKey: "baseUnit"
1012
+ },
1013
+ {
1014
+ id: "physicalBalance",
1015
+ accessorFn: (y) => {
1016
+ var i;
1017
+ const d = (i = v.value.find((c) => c.id === y.id)) == null ? void 0 : i.balance;
1018
+ return d ? Fe.toFormatString({ value: d }) : y.physicalBalance;
1019
+ },
1020
+ header: () => oe("Actual balance"),
1021
+ cell(y) {
1022
+ var b;
1023
+ const d = y.row.original, i = Fe.fromNumber(d.physicalBalance);
1024
+ let c = !0, A = d.physicalBalance;
1025
+ const C = (b = v.value.find((q) => q.id === d.id)) == null ? void 0 : b.balance;
1026
+ return C && (Fe.equals({
1027
+ a: i,
1028
+ b: C
1029
+ }) || (c = !1, A = Number(Fe.toFormatString({ value: C })))), T("div", { class: "flex flex-col" }, [
1030
+ T(
1031
+ "span",
1032
+ { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
1033
+ A
1034
+ ),
1035
+ c ? null : T(
1036
+ "span",
1037
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1038
+ `Draft: ${d.physicalBalance.toString()}`
1039
+ )
1040
+ ]);
1041
+ },
1042
+ size: 200,
1043
+ meta: {
1044
+ textAlign: "right"
1045
+ }
1046
+ },
1047
+ {
1048
+ id: "systemBalance",
1049
+ accessorKey: "systemBalance",
1050
+ header: () => oe("Balance"),
1051
+ size: 200,
1052
+ meta: {
1053
+ textAlign: "right"
1054
+ }
1055
+ },
1056
+ {
1057
+ id: "adjustedAmount",
1058
+ accessorKey: "adjustedAmount",
1059
+ header: () => oe("Adjusted balance"),
1060
+ size: 200,
1061
+ meta: {
1062
+ textAlign: "right"
1063
+ }
1064
+ },
1065
+ {
1066
+ id: "adjustedDiffPercentage",
1067
+ accessorKey: "adjustedDiffPercentage",
1068
+ header: () => T(
1069
+ be.FmTooltip,
1070
+ { zIndex: 51, placement: "left", class: "w-full flex justify-end" },
1071
+ {
1072
+ default() {
1073
+ return T("div", { class: "flex items-center gap-4" }, [
1074
+ "Diff (%)",
1075
+ T(be.FmIcon, { name: "info", color: "neutral-gray-400", size: "sm" })
1076
+ ]);
1077
+ },
1078
+ content() {
1079
+ return "Differences are calculated using this formula: (Adjusted / System) × 100%";
1080
+ }
1081
+ }
1082
+ ),
1083
+ size: 200,
1084
+ cell(y) {
1085
+ const d = y.row.original.adjustedDiffPercentage;
1086
+ if (!d) return "N/A";
1087
+ const i = d.toFixed(2);
1088
+ if (i === "0.00")
1089
+ return T("div", { class: "flex items-center gap-4 justify-end" }, ["0.00"]);
1090
+ const c = d > 0;
1091
+ return T("div", { class: "flex items-center gap-4 justify-end" }, [
1092
+ T(be.FmIcon, {
1093
+ name: c ? "arrow_drop_up" : "arrow_drop_down",
1094
+ color: c ? "system-success-300" : "system-error-300",
1095
+ size: "md"
1096
+ }),
1097
+ i
1098
+ ]);
1099
+ },
1100
+ meta: {
1101
+ textAlign: "right"
1102
+ }
1103
+ },
1104
+ {
1105
+ id: "physicalBalances",
1106
+ header: () => "Amounts",
1107
+ enableSorting: !1,
1108
+ cell(y) {
1109
+ const d = y.row.original, i = (A, C) => T(
1110
+ be.FmTooltip,
1111
+ { zIndex: 50 },
1112
+ {
1113
+ default() {
1114
+ return T(
1115
+ "div",
1116
+ {
1117
+ class: "fm-typo-en-body-md-400 py-4 px-8 border-1 border-fm-color-typo-secondary fm-corner-radius-md line-clamp-1"
1118
+ },
1119
+ [
1120
+ T("span", { class: "text-fm-color-typo-primary" }, `${A} `),
1121
+ T(
1122
+ "span",
1123
+ {
1124
+ class: "text-fm-color-typo-secondary",
1125
+ style: { maxWidth: "80px" }
1126
+ },
1127
+ C
1128
+ )
1129
+ ]
1130
+ );
1131
+ },
1132
+ content() {
1133
+ return `${A} ${C}`;
1134
+ }
1135
+ }
1136
+ );
1137
+ let c = Array.from({ length: r }).map((A, C) => {
1138
+ if (!d[`measurementAmount${C}`])
1139
+ return null;
1140
+ const b = d[`measurementAmount${C}`], q = d[`measurementAbbrev${C}`];
1141
+ return i(b, q);
1142
+ }).filter((A) => A);
1143
+ return (d.baseUnitAmount || !c.length) && (c = [i(d.baseUnitAmount, d.baseUnit), ...c]), T(
1144
+ "div",
1145
+ {
1146
+ class: "flex gap-8 flex-nowrap",
1147
+ style: {
1148
+ minWidth: `${120 * c.length}px`
1149
+ }
1150
+ },
1151
+ c
1152
+ );
1153
+ }
1154
+ }
1155
+ ];
1156
+ }), we = L(() => ke.value.map((r) => r.size ?? 0).reduce((r, t) => r + t)), fe = H(""), De = L(() => {
1157
+ var y, d;
1158
+ const r = ((d = (y = e.draft) == null ? void 0 : y.negativeStockItems) == null ? void 0 : d.reduce(
1159
+ (i, c) => (i[c.sku._id] = c, i),
1160
+ {}
1161
+ )) ?? {};
1162
+ return V.value.map((i) => {
1163
+ var Ce, S, z, K;
1164
+ const c = (Ce = de.value.get(i._id)) == null ? void 0 : Ce[0], A = ((S = ue.value.get(i._id)) == null ? void 0 : S[0]) ?? B;
1165
+ if (!c)
1166
+ return {
1167
+ id: i._id,
1168
+ code: i.code,
1169
+ name: i.name,
1170
+ baseUnit: i.unit.abbrev,
1171
+ baseUnitAmount: 0,
1172
+ systemBalance: +N(A),
1173
+ physicalBalance: 0,
1174
+ adjustedAmount: -+N(A),
1175
+ adjustedDiffPercentage: -100,
1176
+ isTemplateItem: !r[i._id]
1177
+ };
1178
+ const C = tt(c), b = (K = (z = v.value) == null ? void 0 : z.find(
1179
+ (G) => G.id === i._id
1180
+ )) == null ? void 0 : K.balance, q = We(
1181
+ b ?? C,
1182
+ A
1183
+ ), ye = A.amount === 0 ? null : Ze(q, {
1184
+ ...A,
1185
+ amount: Math.abs(A.amount)
1186
+ }), ge = ye ? Ee(ye, Q) : null;
1187
+ return {
1188
+ id: i._id,
1189
+ code: i.code,
1190
+ name: i.name,
1191
+ baseUnit: i.unit.abbrev,
1192
+ baseUnitAmount: +N(c.baseAmount),
1193
+ ...c.measurementsAmounts.filter((G) => {
1194
+ var ne, me, ze;
1195
+ return (ze = (me = (ne = te.value) == null ? void 0 : ne.get(i._id)) == null ? void 0 : me[0]) == null ? void 0 : ze.includes(G.measurement.id);
1196
+ }).reduce((G, ne, me) => (G[`measurementAbbrev${me}`] = `(${ne.measurement.abbrev}) × ${N(ne.measurement.conversion)}`, G[`measurementAmount${me}`] = +N(ne.amount), G), {}),
1197
+ systemBalance: +N(A),
1198
+ physicalBalance: +N(C),
1199
+ adjustedAmount: +N(q),
1200
+ adjustedDiffPercentage: ge ? +N(Je(ge, 2)) : null,
1201
+ isTemplateItem: !r[i._id]
1202
+ };
1203
+ }).filter((i) => !!(i.isTemplateItem && k.value.templateItem || !i.isTemplateItem && k.value.nonTemplateItem));
1204
+ }), pe = L(() => {
1205
+ var t, y, d, i;
1206
+ if (!e.draft) return [];
1207
+ const r = e.draft.approvedAt ? {
1208
+ action: `Approve at ${le(e.draft.approvedAt)}`,
1209
+ // actionAt: props.draft.approvedAt,
1210
+ actionBy: e.draft.approvedBy,
1211
+ remark: e.draft.approveRemark
1212
+ } : (t = e.draft.rejectionHistory) == null ? void 0 : t.computeFirst((c) => ({
1213
+ action: `Reject at ${le(c.rejectedAt)}`,
1214
+ // actionAt: e.rejectedAt,
1215
+ actionBy: c.rejectedBy,
1216
+ remark: c.rejectRemark
1217
+ }));
1218
+ return [
1219
+ {
1220
+ label: "Created at",
1221
+ value: le(e.draft.createdAt)
1222
+ },
1223
+ {
1224
+ label: "Created by",
1225
+ value: e.draft.createdBy.name
1226
+ },
1227
+ {
1228
+ label: "Updated at",
1229
+ value: le(e.draft.updatedAt)
1230
+ },
1231
+ {
1232
+ label: "Updated by",
1233
+ value: e.draft.updatedBy.name
1234
+ },
1235
+ {
1236
+ label: "Effective at",
1237
+ value: le(e.draft.effectiveAt ?? Me((y = e.draft) == null ? void 0 : y._id))
1238
+ },
1239
+ {
1240
+ label: "Using template",
1241
+ value: ((d = e.draft.usingTemplates.find((c) => c)) == null ? void 0 : d.name) ?? "None"
1242
+ },
1243
+ e.draft.remark ? {
1244
+ label: "Remark",
1245
+ value: e.draft.remark
1246
+ } : null,
1247
+ r ? {
1248
+ label: "Last action",
1249
+ value: r.action
1250
+ } : null,
1251
+ r && r.actionBy ? {
1252
+ label: "Last action by",
1253
+ value: (i = r.actionBy) == null ? void 0 : i.name
1254
+ } : null,
1255
+ r && r.remark ? {
1256
+ label: "Action remark",
1257
+ value: r.remark
1258
+ } : null
1259
+ ].filter((c) => c).map((c) => c);
1260
+ }), ve = [
1261
+ {
1262
+ label: "Overview",
1263
+ value: "overview"
1264
+ },
1265
+ {
1266
+ label: "Action history",
1267
+ value: "history"
1268
+ }
1269
+ ], se = H(ve[0]), ae = L(() => {
1270
+ var d, i, c;
1271
+ const r = ((d = e.draft) == null ? void 0 : d.activityLogs) ?? [], t = ((i = e.draft) == null ? void 0 : i.rejectionHistory) ?? [];
1272
+ for (const A of t)
1273
+ r.find(
1274
+ (b) => `${b.action}_${b.performedAt}` == `${E.enum.rejectDraft}_${A.rejectedAt}`
1275
+ ) || r.push({
1276
+ action: E.enum.rejectDraft,
1277
+ performedAt: A.rejectedAt,
1278
+ performedBy: A.rejectedBy,
1279
+ remark: A.rejectRemark
1280
+ });
1281
+ return (c = e.draft) != null && c.approvedAt && (r.find(
1282
+ (C) => {
1283
+ var b;
1284
+ return `${C.action}_${C.performedAt}` == `${E.enum.approveDraft}_${(b = e.draft) == null ? void 0 : b.approvedAt}`;
1285
+ }
1286
+ ) || r.push({
1287
+ action: E.enum.approveDraft,
1288
+ performedAt: e.draft.approvedAt,
1289
+ performedBy: e.draft.approvedBy ?? { name: "Unknown", id: "unknown" },
1290
+ remark: e.draft.approveRemark
1291
+ })), r.sort((A, C) => new Date(C.performedAt).getTime() - new Date(A.performedAt).getTime()).map(
1292
+ (A) => ({
1293
+ header: Ue(A.action),
1294
+ date: le(A.performedAt),
1295
+ info: [
1296
+ {
1297
+ label: "Performed by",
1298
+ values: [A.performedBy.name]
1299
+ },
1300
+ {
1301
+ label: "Remark",
1302
+ values: [A.remark ?? ""]
1303
+ }
1304
+ ]
1305
+ })
1306
+ );
1307
+ }), _e = L(() => {
1308
+ var i, c, A, C;
1309
+ if ((i = e == null ? void 0 : e.draft) != null && i.approvedAt) return "Draft is already approved.";
1310
+ if (((c = e.draft) == null ? void 0 : c.status) !== re.enum.DRAFT) return "Status is not draft.";
1311
+ const r = De.value.some((b) => b.physicalBalance < 0), t = ((C = (A = u.stockBalance.skus) == null ? void 0 : A.filter((b) => b.balance.amount < 0)) == null ? void 0 : C.map((b) => b.id)) ?? [], y = new Set(V.value.map((b) => b._id)), d = t.filter((b) => !y.has(b)).length;
1312
+ return [
1313
+ r ? "Negative total exist." : null,
1314
+ d ? "Negative stock is not included in this draft. Reopen draft in POS and apply changes." : null
1315
+ ].filter((b) => b).join(" ");
1316
+ });
1317
+ return (r, t) => {
1318
+ const y = P("FmButtonGroup"), d = P("FmMenuDivider"), i = P("FmCard"), c = P("FmButton"), A = P("FmCircularProgress"), C = P("FmChip"), b = P("FmTextField"), q = P("FmIcon"), ye = P("FmTable"), ge = P("FmSpacer"), Ne = P("FmTooltip"), Ce = P("FmSideSheet");
1319
+ return x(), X(Ce, {
1320
+ "dismiss-away": "",
1321
+ "max-width": 9999,
1322
+ "model-value": F(_),
1323
+ "onUpdate:modelValue": t[10] || (t[10] = (S) => Ye(_) ? _.value = S : null),
1324
+ header: "Closing details"
1325
+ }, {
1326
+ "side-sheet-footer": O(() => {
1327
+ var S, z, K, G;
1328
+ return [
1329
+ o("div", ha, [
1330
+ ((S = e.draft) == null ? void 0 : S.status) === F(re).enum.DRAFT ? (x(), U(J, { key: 0 }, [
1331
+ _e.value ? (x(), X(Ne, {
1332
+ key: 0,
1333
+ "z-index": 51
1334
+ }, {
1335
+ content: O(() => [
1336
+ Z(W(_e.value), 1)
1337
+ ]),
1338
+ default: O(() => [
1339
+ D(c, {
1340
+ disabled: "",
1341
+ key: "approve key",
1342
+ label: "Approve",
1343
+ onClick: t[5] || (t[5] = () => e.draft && F(p).approveDraft(e.draft, () => g("submitted")))
1344
+ })
1345
+ ]),
1346
+ _: 1
1347
+ })) : (x(), X(c, {
1348
+ key: "approve key",
1349
+ label: "Approve",
1350
+ onClick: t[6] || (t[6] = () => e.draft && F(p).approveDraft(e.draft, () => g("submitted")))
1351
+ }))
1352
+ ], 64)) : ee("", !0),
1353
+ ((z = e.draft) == null ? void 0 : z.status) === F(re).enum.DRAFT ? (x(), X(c, {
1354
+ key: 1,
1355
+ label: "Reject",
1356
+ variant: "destructive",
1357
+ onClick: t[7] || (t[7] = () => e.draft && F(p).rejectDraft(e.draft, () => g("submitted")))
1358
+ })) : ee("", !0),
1359
+ (K = e.draft) != null && K.approvedAt && ((G = e.draft) == null ? void 0 : G.status) !== F(re).enum.COMPLETED ? (x(), X(c, {
1360
+ key: 2,
1361
+ label: "Sync",
1362
+ loading: w.value,
1363
+ onClick: t[8] || (t[8] = () => {
1364
+ e.draft && (w.value = !0, F(p).syncDraft(e.draft, () => {
1365
+ w.value = !1, g("submitted");
1366
+ }));
1367
+ })
1368
+ }, null, 8, ["loading"])) : ee("", !0),
1369
+ D(c, {
1370
+ label: "Close",
1371
+ variant: "tertiary",
1372
+ onClick: t[9] || (t[9] = (ne) => _.value = !1)
1373
+ })
1374
+ ])
1375
+ ];
1376
+ }),
1377
+ default: O(() => [
1378
+ o("div", zt, [
1379
+ o("div", null, [
1380
+ D(y, {
1381
+ items: ve,
1382
+ modelValue: se.value,
1383
+ "onUpdate:modelValue": t[0] || (t[0] = (S) => se.value = S)
1384
+ }, null, 8, ["modelValue"])
1385
+ ]),
1386
+ se.value.value === "overview" ? (x(), U(J, { key: 0 }, [
1387
+ D(i, {
1388
+ variant: "outlined",
1389
+ class: "flex flex-col gap-8 px-12 py-16"
1390
+ }, {
1391
+ default: O(() => {
1392
+ var S, z;
1393
+ return [
1394
+ o("div", Ot, [
1395
+ t[11] || (t[11] = o("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
1396
+ o("div", Yt, [
1397
+ o("div", {
1398
+ class: Ae(["fm-status-badge", F(Be)(((S = r.draft) == null ? void 0 : S.status) ?? "DRAFT")])
1399
+ }, W(F(Ue)(((z = r.draft) == null ? void 0 : z.status) ?? "")), 3)
1400
+ ])
1401
+ ]),
1402
+ D(d),
1403
+ o("div", Kt, [
1404
+ (x(!0), U(J, null, he(pe.value, (K, G) => (x(), U("div", {
1405
+ class: "flex flex-col gap-4",
1406
+ key: G
1407
+ }, [
1408
+ o("div", Gt, [
1409
+ o("div", qt, W(K.label), 1)
1410
+ ]),
1411
+ o("div", Wt, W(K.value), 1)
1412
+ ]))), 128))
1413
+ ])
1414
+ ];
1415
+ }),
1416
+ _: 1
1417
+ }),
1418
+ o("div", Zt, [
1419
+ o("div", Jt, [
1420
+ t[12] || (t[12] = o("div", { class: "flex-1 fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, " Closing items ", -1)),
1421
+ m.value ? ee("", !0) : (x(), U("div", Qt, [
1422
+ r.draft && r.draft.status !== F(re).enum.COMPLETED ? (x(), X(c, {
1423
+ key: 0,
1424
+ label: "Refresh balance",
1425
+ "prepend-icon": "refresh",
1426
+ variant: "secondary",
1427
+ "text-color": "primary",
1428
+ "bg-color": "transparent",
1429
+ "border-color": "primary",
1430
+ loading: R.value,
1431
+ onClick: ie
1432
+ }, null, 8, ["loading"])) : ee("", !0),
1433
+ D(c, {
1434
+ label: "Export data",
1435
+ "prepend-icon": "download",
1436
+ variant: "secondary",
1437
+ "text-color": "primary",
1438
+ "bg-color": "transparent",
1439
+ "border-color": "primary",
1440
+ onClick: t[1] || (t[1] = (S) => r.draft ? F(p).exportDraft(
1441
+ r.draft,
1442
+ h.value,
1443
+ v.value
1444
+ ) : null)
1445
+ })
1446
+ ]))
1447
+ ]),
1448
+ m.value ? (x(), U("div", Xt, [
1449
+ t[14] || (t[14] = o("div", { class: "h-80" }, null, -1)),
1450
+ o("div", ea, [
1451
+ o("div", null, [
1452
+ D(A, { size: "md" })
1453
+ ]),
1454
+ t[13] || (t[13] = o("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
1455
+ ]),
1456
+ t[15] || (t[15] = o("div", { class: "h-80" }, null, -1))
1457
+ ])) : (x(), U(J, { key: 1 }, [
1458
+ o("div", ta, [
1459
+ o("div", aa, [
1460
+ D(C, {
1461
+ label: "Template Item(s)",
1462
+ selected: k.value.templateItem,
1463
+ onClick: t[2] || (t[2] = (S) => k.value.templateItem = !k.value.templateItem)
1464
+ }, null, 8, ["selected"]),
1465
+ D(C, {
1466
+ label: "Non-template Item(s)",
1467
+ selected: k.value.nonTemplateItem,
1468
+ onClick: t[3] || (t[3] = (S) => k.value.nonTemplateItem = !k.value.nonTemplateItem)
1469
+ }, null, 8, ["selected"])
1470
+ ]),
1471
+ D(b, {
1472
+ modelValue: fe.value,
1473
+ "onUpdate:modelValue": t[4] || (t[4] = (S) => fe.value = S),
1474
+ placeholder: "Filter items"
1475
+ }, null, 8, ["modelValue"])
1476
+ ]),
1477
+ F(a).skuTags.size ? (x(), U("div", na, [
1478
+ (x(!0), U(J, null, he(F(a).skuTags.keys(), (S) => (x(), X(C, {
1479
+ key: `${S}`,
1480
+ label: `${S}`,
1481
+ selectable: "",
1482
+ selected: M[`${S}`],
1483
+ onClick: (z) => M[`${S}`] = !M[`${S}`]
1484
+ }, {
1485
+ default: O(() => [
1486
+ M[`${S}`] ? (x(), X(q, {
1487
+ key: 0,
1488
+ name: "check",
1489
+ class: "text-white",
1490
+ size: "sm"
1491
+ })) : ee("", !0),
1492
+ o("span", {
1493
+ class: Ae([
1494
+ "",
1495
+ {
1496
+ "text-white fm-typo-en-body-md-600": M[`${S}`],
1497
+ "text-fm-color-typo-primary fm-typo-en-body-md-400": !M[`${S}`]
1498
+ }
1499
+ ])
1500
+ }, W(S), 3)
1501
+ ]),
1502
+ _: 2
1503
+ }, 1032, ["label", "selected", "onClick"]))), 128))
1504
+ ])) : ee("", !0),
1505
+ o("div", oa, [
1506
+ o("div", {
1507
+ style: Ke({ minWidth: `${we.value}px` })
1508
+ }, [
1509
+ D(ye, {
1510
+ "column-defs": ke.value,
1511
+ "row-data": De.value,
1512
+ "search-value": fe.value
1513
+ }, null, 8, ["column-defs", "row-data", "search-value"])
1514
+ ], 4)
1515
+ ])
1516
+ ], 64))
1517
+ ])
1518
+ ], 64)) : ee("", !0),
1519
+ se.value.value === "history" ? (x(), U("div", sa, [
1520
+ ae.value.length ? (x(), U("div", ca, [
1521
+ (x(!0), U(J, null, he(ae.value, (S, z) => (x(), U(J, { key: z }, [
1522
+ o("div", ia, [
1523
+ o("div", ua, [
1524
+ o("div", da, [
1525
+ o("div", {
1526
+ class: Ae([
1527
+ {
1528
+ "bg-fm-color-primary": z !== 0,
1529
+ "bg-white": z === 0
1530
+ },
1531
+ "w-[2px] h-full"
1532
+ ])
1533
+ }, null, 2)
1534
+ ]),
1535
+ t[18] || (t[18] = o("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1536
+ o("div", ma, [
1537
+ o("div", {
1538
+ class: Ae([
1539
+ {
1540
+ "bg-fm-color-primary": z < ae.value.length - 1,
1541
+ "bg-white": z >= ae.value.length - 1
1542
+ },
1543
+ "w-[2px] h-full"
1544
+ ])
1545
+ }, null, 2)
1546
+ ])
1547
+ ]),
1548
+ o("div", fa, [
1549
+ o("div", pa, W(S.header), 1),
1550
+ o("div", va, W(S.date), 1)
1551
+ ])
1552
+ ]),
1553
+ o("div", ya, [
1554
+ o("div", ga, [
1555
+ o("div", ba, [
1556
+ o("div", {
1557
+ class: Ae([
1558
+ {
1559
+ "bg-fm-color-primary": z < ae.value.length - 1,
1560
+ "bg-white": z >= ae.value.length - 1
1561
+ },
1562
+ "w-[2px] h-full"
1563
+ ])
1564
+ }, null, 2)
1565
+ ])
1566
+ ]),
1567
+ o("div", Aa, [
1568
+ D(i, {
1569
+ variant: "outlined",
1570
+ class: "py-12 px-16"
1571
+ }, {
1572
+ default: O(() => [
1573
+ o("div", ka, [
1574
+ (x(!0), U(J, null, he(S.info, (K, G) => (x(), U("div", {
1575
+ key: G,
1576
+ class: "flex flex-col gap-4"
1577
+ }, [
1578
+ o("div", Da, W(K == null ? void 0 : K.label), 1),
1579
+ o("div", _a, [
1580
+ (x(!0), U(J, null, he(K == null ? void 0 : K.values, (ne, me) => (x(), U("div", {
1581
+ key: me,
1582
+ class: "fm-typo-en-body-lg-600"
1583
+ }, W(ne), 1))), 128))
1584
+ ])
1585
+ ]))), 128))
1586
+ ])
1587
+ ]),
1588
+ _: 2
1589
+ }, 1024)
1590
+ ])
1591
+ ])
1592
+ ], 64))), 128))
1593
+ ])) : (x(), U("div", ra, [
1594
+ D(ge),
1595
+ o("div", null, [
1596
+ o("img", {
1597
+ src: F(Ct),
1598
+ alt: "List is empty"
1599
+ }, null, 8, la)
1600
+ ]),
1601
+ t[16] || (t[16] = o("div", { class: "fm-typo-en-body-lg-600" }, W("No records found"), -1)),
1602
+ t[17] || (t[17] = o("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, W("You can track approval and rejection history here"), -1)),
1603
+ D(ge),
1604
+ D(ge)
1605
+ ]))
1606
+ ])) : ee("", !0)
1607
+ ])
1608
+ ]),
1609
+ _: 1
1610
+ }, 8, ["model-value"]);
1611
+ };
1612
+ }
1613
+ }), wa = { class: "flex-1 flex flex-col gap-8" }, Ca = { class: "flex flex-col" }, Sa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fa = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, ja = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Ba = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, La = /* @__PURE__ */ Te({
1614
+ __name: "ClosingDraftView",
1615
+ setup(l) {
1616
+ const { t: s } = Qe(), { viewDraft: e } = $e(), { viewClosingDraftProps: u, viewClosingDraftShow: p } = wt($e()), _ = Ie(), m = Nt(), R = gt(), { breakpoints: w } = xt();
1617
+ _.watchLocation(m.fetchDrafts);
1618
+ const h = L(() => m.loading), v = H(""), I = L(() => w.value.xs || w.value.sm), Y = L(() => I.value ? 10 : 20);
1619
+ function n(M) {
1620
+ switch (M) {
1621
+ case "refresh":
1622
+ return m.fetchDrafts();
1623
+ }
1624
+ }
1625
+ function a(M) {
1626
+ return M;
1627
+ }
1628
+ const j = L(() => I.value ? [
1629
+ {
1630
+ label: s("inventory.common.refresh"),
1631
+ value: "refresh",
1632
+ isPrimary: !1
1633
+ }
1634
+ ] : [
1635
+ {
1636
+ label: s("inventory.common.refresh"),
1637
+ value: "refresh",
1638
+ isPrimary: !1
1639
+ }
1640
+ ]);
1641
+ return (M, f) => {
1642
+ const g = P("FmTable");
1643
+ return x(), U(J, null, [
1644
+ D(bt, {
1645
+ title: F(s)("inventory.closing.draft.title"),
1646
+ actions: j.value,
1647
+ "onClick:action": n
1648
+ }, {
1649
+ default: O(() => [
1650
+ o("div", {
1651
+ class: Ae([
1652
+ "flex flex-col gap-8 max-h-full",
1653
+ {
1654
+ "p-0": I.value,
1655
+ "px-24 ": !I.value
1656
+ }
1657
+ ])
1658
+ }, [
1659
+ D(At, {
1660
+ "change-location": "",
1661
+ searchable: "",
1662
+ search: v.value,
1663
+ "onUpdate:search": f[0] || (f[0] = (k) => v.value = k)
1664
+ }, null, 8, ["search"]),
1665
+ D(g, {
1666
+ style: Ke(F(R).tableHeight),
1667
+ "column-defs": F(m).columnDefs,
1668
+ "row-data": F(m).drafts,
1669
+ "search-value": v.value,
1670
+ loading: h.value,
1671
+ onRowClick: f[1] || (f[1] = (k) => F(e)(k.original)),
1672
+ "page-size": Y.value
1673
+ }, {
1674
+ "list-row": O((k) => [
1675
+ D(kt, {
1676
+ row: k,
1677
+ onRowClick: ($) => F(e)($)
1678
+ }, {
1679
+ default: O(($) => {
1680
+ var V, te, B, Q, ce, ie, ue, de, oe, ke, we, fe, De, pe, ve, se, ae, _e, r, t;
1681
+ return [
1682
+ o("div", wa, [
1683
+ o("div", Ca, [
1684
+ o("div", Sa, [
1685
+ D(F(je), {
1686
+ render: (B = (te = (V = $._id) == null ? void 0 : V.column) == null ? void 0 : te.columnDef) == null ? void 0 : B.cell,
1687
+ props: (ce = (Q = $._id) == null ? void 0 : Q.getContext) == null ? void 0 : ce.call(Q)
1688
+ }, null, 8, ["render", "props"])
1689
+ ]),
1690
+ o("div", Fa, [
1691
+ D(F(je), {
1692
+ render: (de = (ue = (ie = $.name) == null ? void 0 : ie.column) == null ? void 0 : ue.columnDef) == null ? void 0 : de.cell,
1693
+ props: (ke = (oe = $.name) == null ? void 0 : oe.getContext) == null ? void 0 : ke.call(oe)
1694
+ }, null, 8, ["render", "props"])
1695
+ ]),
1696
+ o("div", ja, W([
1697
+ ...k.original.items.slice(0, 3).map((y) => y.sku.name),
1698
+ ...k.original.items.length >= 3 ? [`and ${k.original.items.length - 3} more items`] : []
1699
+ ].join(", ")), 1),
1700
+ o("div", Ba, [
1701
+ D(F(je), {
1702
+ render: (De = (fe = (we = $.ref) == null ? void 0 : we.column) == null ? void 0 : fe.columnDef) == null ? void 0 : De.cell,
1703
+ props: (ve = (pe = $.ref) == null ? void 0 : pe.getContext) == null ? void 0 : ve.call(pe)
1704
+ }, null, 8, ["render", "props"])
1705
+ ])
1706
+ ]),
1707
+ o("div", null, [
1708
+ D(F(je), {
1709
+ render: (_e = (ae = (se = $.status) == null ? void 0 : se.column) == null ? void 0 : ae.columnDef) == null ? void 0 : _e.cell,
1710
+ props: (t = (r = $.status) == null ? void 0 : r.getContext) == null ? void 0 : t.call(r)
1711
+ }, null, 8, ["render", "props"])
1712
+ ])
1713
+ ])
1714
+ ];
1715
+ }),
1716
+ _: 2
1717
+ }, 1032, ["row", "onRowClick"])
1718
+ ]),
1719
+ _: 1
1720
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1721
+ ], 2)
1722
+ ]),
1723
+ _: 1
1724
+ }, 8, ["title", "actions"]),
1725
+ (x(), X(st, { to: "body" }, [
1726
+ D(xa, rt(F(u), {
1727
+ show: F(p),
1728
+ "onUpdate:show": f[2] || (f[2] = (k) => Ye(p) ? p.value = k : null),
1729
+ onSubmitted: f[3] || (f[3] = () => (p.value = !1, F(m).fetchDrafts())),
1730
+ onRefresh: f[4] || (f[4] = (k) => F(m).updateDraftRef(k))
1731
+ }), null, 16, ["show"])
1732
+ ]))
1733
+ ], 64);
1734
+ };
1735
+ }
1736
+ });
1737
+ export {
1738
+ La as default
1739
+ };