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