@feedmepos/mf-inventory-portal 0.0.25-dev.14 → 0.0.25-dev.16

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 (49) hide show
  1. package/dist/{App-6g25LiMb.js → App-Crqni2j1.js} +2 -2
  2. package/dist/{ApprovalView-D1QD09Yc.js → ApprovalView-BRuPqlFf.js} +2 -2
  3. package/dist/{BindingsDialog-eUQ1_YJ6.js → BindingsDialog-CTnuKRLu.js} +2 -2
  4. package/dist/{BindingsPicker-CG9yJgeU.js → BindingsPicker-2Q_4Hswl.js} +5 -5
  5. package/dist/{BindingsTable-BVRcqAy9.js → BindingsTable-Ckg2d48O.js} +5 -5
  6. package/dist/ClosingDraftView-uMe2IeCv.js +1297 -0
  7. package/dist/{ClosingTemplateView-Bax4L6YF.js → ClosingTemplateView-byUMxqLf.js} +2 -2
  8. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CqU3Pubo.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-gU_anG_Q.js} +3 -3
  9. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BBaQYJia.js → FmUnitInput.vue_vue_type_script_setup_true_lang-xOyEnkhr.js} +1 -1
  10. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DrZCk-3P.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-6wK8UjSj.js} +1 -1
  11. package/dist/{IngredientGroupView-Cs5ZJb3h.js → IngredientGroupView-Dcg4XagR.js} +1 -1
  12. package/dist/{IngredientsView-DrRbwLdZ.js → IngredientsView--u4I1b25.js} +4 -4
  13. package/dist/{IntegrationView-CF-K0lEk.js → IntegrationView-C2A22fho.js} +1 -1
  14. package/dist/{InventoryBindingForm-Kq7F7Hxw.js → InventoryBindingForm-1UGFYiaO.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-djscF-a_.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-D66mpBo_.js} +3 -3
  16. package/dist/{InventoryBindingSummary-9iGC54ax.js → InventoryBindingSummary-BLx8Fn5W.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CSVc9YqP.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BB_aU2oG.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-C0liINI-.js → PremiumBadge.vue_vue_type_script_setup_true_lang-B11hYBMZ.js} +1 -1
  19. package/dist/PublishView-sXQx9Pgx.js +222 -0
  20. package/dist/{PurchaseOrderPrintPreview-BZjkqH8w.js → PurchaseOrderPrintPreview-BHL_I4iP.js} +1 -1
  21. package/dist/{ReceiveRequestView-DUmyosqT.js → ReceiveRequestView-DyLwzNZo.js} +9 -9
  22. package/dist/{RecipeView-B3mlZR2U.js → RecipeView-D3uBc5vl.js} +3 -3
  23. package/dist/{StockView-DS8W3pK-.js → StockView-BOeSTZHg.js} +7 -7
  24. package/dist/{SupplierView-Pm-PoUsN.js → SupplierView-BP2gogrQ.js} +4 -4
  25. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-DTKXMB4E.js → TransferDetails.vue_vue_type_script_setup_true_lang-B2FB-o52.js} +4 -4
  26. package/dist/{TransferTemplateView-CEJK7_3f.js → TransferTemplateView-DvwHL1c1.js} +7 -7
  27. package/dist/{UnitView-CaA3eoV3.js → UnitView-RePSry1v.js} +3 -3
  28. package/dist/{WarehouseView-uL4l-lXl.js → WarehouseView-Q1xF1sMN.js} +1 -1
  29. package/dist/api/closing-draft.d.ts +1 -0
  30. package/dist/api/inventory.d.ts +2 -0
  31. package/dist/{app-DLF5oQUX.js → app-Czi6WGIq.js} +2071 -2051
  32. package/dist/app.js +1 -1
  33. package/dist/components/FmMultiselectDialog.d.ts +6 -6
  34. package/dist/{decimal-BfL1Dfin.js → decimal-BIOPhE0t.js} +1 -1
  35. package/dist/{feature-D67-S0RZ.js → feature-Dd_JZy3Y.js} +1 -1
  36. package/dist/{format-unit-display-e9wEtPRW.js → format-unit-display-vj8ZBTdS.js} +2 -2
  37. package/dist/{index-mvz-S4fO.js → index-Bi93q5cv.js} +2 -2
  38. package/dist/{stock-Bh8xDSyj.js → stock-ksGPw_1H.js} +1 -1
  39. package/dist/stores/inventory.d.ts +127 -0
  40. package/dist/{supplier-BTSc7hfQ.js → supplier-Cb1acd5I.js} +1 -1
  41. package/dist/tsconfig.app.tsbuildinfo +1 -1
  42. package/dist/{use-ingredient-select-dialog-BBI1-Yt3.js → use-ingredient-select-dialog-NNTeFo0N.js} +1 -1
  43. package/dist/{use-inventory-binding-dialog-B06jZrl3.js → use-inventory-binding-dialog-D__Gm3Pv.js} +1 -1
  44. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +4 -1
  45. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +1 -1
  46. package/dist/{vue-i18n-Dy5gAXv-.js → vue-i18n-BoWWKkCm.js} +187 -187
  47. package/package.json +1 -1
  48. package/dist/ClosingDraftView-BBASz7i8.js +0 -1225
  49. package/dist/PublishView-DSkvsS-T.js +0 -192
@@ -0,0 +1,1297 @@
1
+ import { defineComponent as ke, ref as V, resolveComponent as I, openBlock as A, createBlock as W, withCtx as O, createElementVNode as n, createTextVNode as _e, toDisplayString as z, unref as h, createVNode as k, h as C, reactive as Oe, computed as M, onMounted as Ye, watch as Ke, isRef as Te, createElementBlock as B, Fragment as K, createCommentVNode as X, normalizeClass as ue, renderList as fe, normalizeStyle as Re, Teleport as Ge, mergeProps as qe } from "vue";
2
+ import { W as We, u as we, aj as G, l as Ze, J as Ce, i as T, t as Je, K as pe, p as Qe, q as Xe, r as et, ak as Pe, al as Ie, a6 as Me, am as Ue, an as oe, ac as tt, ai as ee, T as Ee, D as Be, h as he, f as at, e as nt, a as ot, y as st, _ as rt, z as lt, B as ct, E as xe } from "./app-Czi6WGIq.js";
3
+ import { useCoreStore as it, useI18n as He } from "@feedmepos/mf-common";
4
+ import { useSnackbar as je, useDialog as ut, useProxiedModel as dt, components as ie, useBreakpoints as mt } from "@feedmepos/ui-library";
5
+ import { defineStore as ze, storeToRefs as ft } from "pinia";
6
+ import { u as Le } from "./stock-ksGPw_1H.js";
7
+ import { E as pt } from "./empty-placeholder-wf6-BWE8.js";
8
+ const Se = We((o, p) => {
9
+ function e() {
10
+ return we().currentLocation.dbName;
11
+ }
12
+ return {
13
+ async getDraft(v) {
14
+ const u = e(), x = `${o.inventoryBackendUrl}/${u}/closing-draft/${v}`;
15
+ return p.get(x);
16
+ },
17
+ async readDrafts() {
18
+ const v = e(), u = `${o.inventoryBackendUrl}/${v}/closing-draft`;
19
+ return p.get(u);
20
+ },
21
+ async runOperation(v) {
22
+ const u = e(), x = `${o.inventoryBackendUrl}/${u}/closing-draft/run-operation`;
23
+ return p.post(x, v);
24
+ },
25
+ async sync(v) {
26
+ const u = e(), x = `${o.inventoryBackendUrl}/${u}/closing-draft/sync`;
27
+ return p.post(x, v);
28
+ }
29
+ };
30
+ }), vt = { class: "fm-typo-en-body-lg-400" }, yt = { class: "fm-typo-en-body-lg-600" }, gt = { class: "flex gap-12 py-8 justify-end w-full" }, $e = /* @__PURE__ */ ke({
31
+ __name: "ClosingDraftAction",
32
+ props: {
33
+ draft: {},
34
+ action: {},
35
+ onCancel: { type: Function },
36
+ onFinished: { type: Function }
37
+ },
38
+ setup(o) {
39
+ const p = o, e = V(), v = Se(), u = je(), x = V(!1);
40
+ async function m() {
41
+ x.value = !0;
42
+ try {
43
+ await v.runOperation({
44
+ _id: p.draft._id,
45
+ _rev: p.draft._rev ?? "",
46
+ action: p.action,
47
+ data: {
48
+ remark: e.value
49
+ }
50
+ }).delayed(500), u.open({
51
+ title: "Success",
52
+ message: "Action submitted",
53
+ type: "success"
54
+ }), p.onFinished();
55
+ } catch (y) {
56
+ u.open({
57
+ title: "Something went wrong",
58
+ message: "Unable to submit actino. Please try again",
59
+ type: "error"
60
+ }), console.error("error on submit closing draft aciont", y);
61
+ } finally {
62
+ x.value = !1;
63
+ }
64
+ }
65
+ return (y, D) => {
66
+ const U = I("FmTextField"), E = I("FmButton"), R = I("FmForm");
67
+ return A(), W(R, {
68
+ onValidationSuccess: m,
69
+ class: "flex flex-col gap-32",
70
+ disabled: x.value
71
+ }, {
72
+ default: O(() => [
73
+ n("div", vt, [
74
+ D[2] || (D[2] = _e(" You are about to ")),
75
+ n("span", yt, z(y.action == h(G).enum.approveDraft ? "approve" : "reject"), 1),
76
+ D[3] || (D[3] = _e(" this draft. Please provider a remark to justify this action. "))
77
+ ]),
78
+ k(U, {
79
+ modelValue: e.value,
80
+ "onUpdate:modelValue": D[0] || (D[0] = (s) => e.value = s),
81
+ label: "Remark",
82
+ "label-mark": "required",
83
+ rules: [h(Ze)()]
84
+ }, null, 8, ["modelValue", "rules"]),
85
+ n("div", gt, [
86
+ k(E, {
87
+ label: "Cancel",
88
+ variant: "tertiary",
89
+ onClick: D[1] || (D[1] = (s) => y.onCancel())
90
+ }),
91
+ k(E, {
92
+ label: y.action == h(G).enum.approveDraft ? "Approve" : "Reject",
93
+ type: "submit",
94
+ variant: y.action == h(G).enum.approveDraft ? "primary" : "destructive",
95
+ loading: x.value
96
+ }, null, 8, ["label", "variant", "loading"])
97
+ ])
98
+ ]),
99
+ _: 1
100
+ }, 8, ["disabled"]);
101
+ };
102
+ }
103
+ }), bt = pe(0);
104
+ function Ne(o) {
105
+ const p = o.measurementsAmounts.groupBy((v) => v.measurement.id), e = o.sku.unit.measurements.reduce((v, u) => {
106
+ var y, D;
107
+ const x = ((D = (y = p.get(u.id)) == null ? void 0 : y[0]) == null ? void 0 : D.amount) ?? bt, m = Ce(u.conversion, x);
108
+ return v + +T(m);
109
+ }, +T(o.baseAmount));
110
+ return Je(e, o.baseAmount.precision);
111
+ }
112
+ const ht = pe(0), xt = pe(100);
113
+ function Dt(o, p) {
114
+ const e = Ne(o), v = Pe(e, p), u = p.amount === 0 ? null : Ie(v, {
115
+ ...p,
116
+ amount: Math.abs(p.amount)
117
+ }), x = u ? Ce(u, xt) : null;
118
+ return {
119
+ code: o.sku.code,
120
+ name: o.sku.name,
121
+ baseUnit: o.sku.unit.abbrev,
122
+ baseUnitAmount: +T(o.baseAmount),
123
+ ...o.measurementsAmounts.filter((y) => At(y.measurement)).reduce(
124
+ (y, D, U) => (y[`measurementAbbrev${U}`] = `(${D.measurement.abbrev}) × ${T(D.measurement.conversion)}`, y[`measurementAmount${U}`] = +T(D.amount), y),
125
+ {}
126
+ ),
127
+ systemBalance: +T(p),
128
+ physicalBalance: +T(e),
129
+ adjustedAmount: +T(v),
130
+ adjustedDiffPercentage: x ? +T(Me(x, 2)) : null
131
+ };
132
+ }
133
+ function At(o) {
134
+ return !o.abbrev.toLocaleLowerCase().includes("inactive");
135
+ }
136
+ function _t() {
137
+ return [
138
+ {
139
+ id: "code",
140
+ name: "Code"
141
+ },
142
+ {
143
+ id: "name",
144
+ name: "Name"
145
+ },
146
+ {
147
+ id: "baseUnit",
148
+ name: "Base unit"
149
+ },
150
+ {
151
+ id: "physicalBalance",
152
+ name: "Actual balance"
153
+ },
154
+ {
155
+ id: "systemBalance",
156
+ name: "Balance"
157
+ },
158
+ {
159
+ id: "adjustedAmount",
160
+ name: "Adjusted balance"
161
+ },
162
+ {
163
+ id: "adjustedDiffPercentage",
164
+ name: "Diff (%)"
165
+ }
166
+ ];
167
+ }
168
+ function kt(o, p) {
169
+ var s, d, S, g, f, j, L;
170
+ const e = p.groupBy(
171
+ (b) => b.id,
172
+ (b) => b.balance
173
+ ), u = [...o.items, ...o.negativeStockItems ?? []].map((b) => {
174
+ var te;
175
+ const P = ((te = e.get(b.sku._id)) == null ? void 0 : te[0]) ?? ht;
176
+ return Dt(b, P);
177
+ }), m = it().currentBusiness.value, y = _t(), D = [
178
+ ["Business name:", m == null ? void 0 : m.name],
179
+ ["Business ID:", m == null ? void 0 : m._id],
180
+ ["Menu version", m == null ? void 0 : m.menuVersion],
181
+ ["Created at", new Date(o.createdAt)],
182
+ ["Created by", (s = o.createdBy) == null ? void 0 : s.name],
183
+ ["Updated at", new Date(o.updatedAt)],
184
+ ["Updated by", (d = o.updatedBy) == null ? void 0 : d.name],
185
+ ["Recent action", o.approvedAt ? "Approve" : o.rejectionHistory ? "Reject" : ""],
186
+ [
187
+ "Action by",
188
+ o.approvedAt ? (S = o.approvedBy) == null ? void 0 : S.name : o.rejectionHistory ? (f = (g = o.rejectionHistory[0]) == null ? void 0 : g.rejectedBy) == null ? void 0 : f.name : ""
189
+ ],
190
+ [
191
+ "Action at",
192
+ o.approvedAt ? new Date(o.approvedAt) : o.rejectionHistory ? new Date((j = o.rejectionHistory[0]) == null ? void 0 : j.rejectedAt) : ""
193
+ ],
194
+ [
195
+ "Action remark",
196
+ o.approvedAt ? o.approveRemark : o.rejectionHistory ? new Date((L = o.rejectionHistory[0]) == null ? void 0 : L.rejectRemark) : ""
197
+ ],
198
+ [],
199
+ y.map((b) => b.name),
200
+ ...u.map((b) => y.map((P) => b[P.id]))
201
+ ], U = y.map((b) => `system:${b.id}`), E = Qe(D, U), R = `[${m == null ? void 0 : m.name}] closing draft (${Xe(new Date(o.updatedAt))}).xlsx`;
202
+ return et(E, R), R;
203
+ }
204
+ const Ae = ze(
205
+ "closingDraftActions",
206
+ function() {
207
+ const p = ut(), e = je(), v = Ue(), u = Se(), x = Le(), m = V(!1), y = V();
208
+ function D(g) {
209
+ const f = {
210
+ draft: g
211
+ };
212
+ y.value = f, m.value = !0;
213
+ }
214
+ async function U(g) {
215
+ var j;
216
+ if (g.status === oe.enum.COMPLETED) {
217
+ const L = g.closingId;
218
+ if (!L)
219
+ return e.open({
220
+ title: "Something went wrong",
221
+ message: "Closing draft is completed but closing document cannot be found.",
222
+ type: "error"
223
+ }), console.error("Closing draft is completed but closing document cannot be found.", {
224
+ draftId: g == null ? void 0 : g._id
225
+ }), [];
226
+ const b = await v.getClosingById(L);
227
+ return (b == null ? void 0 : b.skus) ?? [];
228
+ } else
229
+ return await x.readStockBalance(), ((j = x.stockBalance) == null ? void 0 : j.skus) ?? [];
230
+ }
231
+ async function E(g, f) {
232
+ f || (e.open({
233
+ title: "Exporting",
234
+ message: "Fetching data..."
235
+ }), f = await U(g)), kt(g, f);
236
+ }
237
+ function R(g, f) {
238
+ p.open({
239
+ title: "Approve draft",
240
+ contentComponent: $e,
241
+ contentComponentProps: {
242
+ draft: g,
243
+ action: G.enum.approveDraft,
244
+ onFinished: () => {
245
+ p.close(), f == null || f();
246
+ },
247
+ onCancel: () => p.close()
248
+ }
249
+ });
250
+ }
251
+ function s(g, f) {
252
+ p.open({
253
+ title: "Reject draft",
254
+ contentComponent: $e,
255
+ contentComponentProps: {
256
+ draft: g,
257
+ action: G.enum.rejectDraft,
258
+ onFinished: () => {
259
+ p.close(), f == null || f();
260
+ },
261
+ onCancel: () => p.close()
262
+ }
263
+ });
264
+ }
265
+ async function d(g, f) {
266
+ await u.sync({
267
+ _id: g._id,
268
+ _rev: g._rev ?? "",
269
+ action: G.enum.approveDraft,
270
+ data: {
271
+ remark: g.remark ?? ""
272
+ }
273
+ }).delayed(500), e.open({
274
+ title: "Success",
275
+ message: "Sync requested",
276
+ type: "success"
277
+ }), f == null || f();
278
+ }
279
+ function S() {
280
+ m.value = !1;
281
+ }
282
+ return {
283
+ viewDraft: D,
284
+ closeDraftDialog: S,
285
+ approveDraft: R,
286
+ rejectDraft: s,
287
+ syncDraft: d,
288
+ exportDraft: E,
289
+ viewClosingDraftShow: m,
290
+ viewClosingDraftProps: y
291
+ };
292
+ }
293
+ );
294
+ function De(o) {
295
+ switch (o) {
296
+ case "DRAFT":
297
+ return "fm-status-badge-draft";
298
+ case "PROCESSING":
299
+ return "fm-status-badge-processing";
300
+ case "FAILED":
301
+ return "fm-status-badge-cancel";
302
+ case "COMPLETED":
303
+ return "fm-status-badge-complete";
304
+ }
305
+ }
306
+ const wt = ze(
307
+ "closingDraftTable",
308
+ function() {
309
+ const { t: p } = He(), e = Ae(), v = V(new Array()), u = V(!1), x = we(), m = Se();
310
+ async function y() {
311
+ if (v.value = [], !!x._currentLocation) {
312
+ u.value = !0;
313
+ try {
314
+ const [s] = await Promise.all([m.readDrafts()]).delayed(1e3);
315
+ v.value = s.reverse();
316
+ } catch (s) {
317
+ console.log("Something went wrong when fetching drafts:", s);
318
+ } finally {
319
+ u.value = !1;
320
+ }
321
+ }
322
+ }
323
+ async function D(s) {
324
+ if (!v.value.find((d) => d._id) && x._currentLocation) {
325
+ u.value = !0;
326
+ try {
327
+ const [d] = await Promise.all([
328
+ m.getDraft(s),
329
+ new Promise((S) => setTimeout(S, 1e3))
330
+ ]);
331
+ v.value = [d];
332
+ } catch (d) {
333
+ console.log("Something went wrong when fetching drafts:", d);
334
+ } finally {
335
+ u.value = !1;
336
+ }
337
+ }
338
+ }
339
+ function U() {
340
+ e.closeDraftDialog(), y();
341
+ }
342
+ function E(s, d) {
343
+ switch (d = nt(d), s) {
344
+ case he.Details:
345
+ return e.viewDraft(d);
346
+ case he.Export:
347
+ return e.exportDraft(d);
348
+ case G.enum.approveDraft:
349
+ return e.approveDraft(d, U);
350
+ case G.enum.rejectDraft:
351
+ return e.rejectDraft(d, U);
352
+ }
353
+ }
354
+ return {
355
+ columnDefs: [
356
+ {
357
+ id: "_id",
358
+ accessorKey: "_id",
359
+ header: () => p("inventory.closing.table.createdAt"),
360
+ cell(s) {
361
+ return tt(`${s.getValue()}`);
362
+ },
363
+ enableSorting: !0
364
+ },
365
+ {
366
+ id: "updatedAt",
367
+ accessorFn: (s) => ee(s.updatedAt),
368
+ header: () => "Updated at",
369
+ enableSorting: !0,
370
+ size: 200
371
+ },
372
+ {
373
+ id: "updatedBy",
374
+ accessorKey: "updatedBy.name",
375
+ header: () => "Last update by",
376
+ enableSorting: !0,
377
+ size: 200
378
+ },
379
+ {
380
+ id: "noOfItems",
381
+ accessorFn: (s) => {
382
+ var d;
383
+ return s.items.length + (((d = s.negativeStockItems) == null ? void 0 : d.length) ?? 0);
384
+ },
385
+ header: () => p("inventory.closing.table.noOfItems"),
386
+ enableSorting: !1,
387
+ meta: {
388
+ width: "10rem",
389
+ textAlign: "right"
390
+ }
391
+ },
392
+ {
393
+ id: "recentRemark",
394
+ accessorFn: (s) => {
395
+ var d;
396
+ return (s == null ? void 0 : s.approveRemark) ?? ((d = s == null ? void 0 : s.rejectionHistory) == null ? void 0 : d.computeFirst((S) => S.rejectRemark)) ?? s.remark;
397
+ },
398
+ header: () => "Recent remark"
399
+ },
400
+ {
401
+ id: "status",
402
+ accessorFn: (s) => s.status,
403
+ header: () => p("inventory.closing.table.status"),
404
+ enableSorting: !1,
405
+ cell(s) {
406
+ var L;
407
+ const d = s.row.original, S = d.status, g = new Date(d.updatedAt), f = (L = d == null ? void 0 : d.rejectionHistory) == null ? void 0 : L.computeFirst((b) => b.rejectedAt), j = f ? new Date(f) : null;
408
+ return S === "DRAFT" && j ? j.getTime() > g.getTime() ? C(
409
+ "div",
410
+ {
411
+ class: "flex"
412
+ },
413
+ C(
414
+ "div",
415
+ {
416
+ class: ["fm-status-badge", De("FAILED")]
417
+ },
418
+ "Rejected"
419
+ )
420
+ ) : C(
421
+ "div",
422
+ {
423
+ class: "flex"
424
+ },
425
+ C(
426
+ "div",
427
+ {
428
+ class: ["fm-status-badge", De("PROCESSING")]
429
+ },
430
+ "Updated"
431
+ )
432
+ ) : C(
433
+ "div",
434
+ {
435
+ class: "flex"
436
+ },
437
+ C(
438
+ "div",
439
+ {
440
+ class: ["fm-status-badge", De(S)]
441
+ },
442
+ Ee(S)
443
+ )
444
+ );
445
+ }
446
+ },
447
+ {
448
+ id: "action",
449
+ cell(s) {
450
+ const d = s.row.original, S = [
451
+ Be[he.Details],
452
+ Be[he.Export]
453
+ ], g = [
454
+ {
455
+ translationKey: "inventory.closing.draft.approveDraft",
456
+ color: "text-fm-color-typo-primary",
457
+ value: G.enum.approveDraft
458
+ },
459
+ {
460
+ translationKey: "inventory.closing.draft.rejectDraft",
461
+ color: "text-fm-color-typo-error",
462
+ value: G.enum.rejectDraft
463
+ }
464
+ ];
465
+ return at(
466
+ [
467
+ ...S,
468
+ ...d.status === oe.enum.DRAFT ? g : []
469
+ ],
470
+ (f) => E(f, d)
471
+ );
472
+ },
473
+ enableSorting: !1,
474
+ size: 40,
475
+ meta: {
476
+ cellClass: "",
477
+ headerClass: ""
478
+ }
479
+ }
480
+ ],
481
+ drafts: v,
482
+ loading: u,
483
+ fetchDrafts: y,
484
+ loadDraft: D
485
+ };
486
+ }
487
+ ), Ct = { class: "w-full flex flex-col gap-32" }, jt = { class: "flex justify-between" }, St = { class: "flex" }, Ft = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bt = { class: "flex gap-1" }, $t = { class: "fm-typo-en-body-lg-600" }, Tt = { class: "flex flex-col gap-16" }, Rt = { class: "flex items-center" }, Pt = { key: 0 }, It = {
488
+ key: 0,
489
+ class: "w-full flex flex-col items-center"
490
+ }, Mt = { class: "flex items-center gap-8" }, Ut = {
491
+ key: 0,
492
+ class: "flex gap-8"
493
+ }, Et = { class: "overflow-x-auto" }, Ht = {
494
+ key: 1,
495
+ class: "flex-1 xs:w-screen xs:max-w-full"
496
+ }, zt = {
497
+ key: 0,
498
+ class: "flex flex-col items-center gap-8 h-full"
499
+ }, Lt = ["src"], Nt = {
500
+ key: 1,
501
+ class: "px-4 flex flex-col"
502
+ }, Vt = { class: "flex gap-12 content-stretch" }, Ot = {
503
+ class: "flex flex-col w-24",
504
+ name: "circles"
505
+ }, Yt = { class: "flex-1 flex flex-col items-center" }, Kt = { class: "flex-1 flex flex-col items-center" }, Gt = {
506
+ class: "py-12 flex flex-col gap-4",
507
+ name: "received-at header"
508
+ }, qt = { class: "fm-typo-en-body-lg-400" }, Wt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Zt = { class: "flex gap-12 content-stretch" }, Jt = {
509
+ class: "flex flex-col w-24",
510
+ name: "circles"
511
+ }, Qt = { class: "flex-1 flex flex-col items-center" }, Xt = {
512
+ class: "py-12 flex flex-col gap-4 flex-1",
513
+ name: "delivery details"
514
+ }, ea = { class: "flex flex-col gap-8" }, ta = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, aa = { class: "flex flex-col gap-4" }, na = { class: "flex gap-8" }, oa = /* @__PURE__ */ ke({
515
+ __name: "ClosingDraftDialog",
516
+ props: {
517
+ show: { type: Boolean },
518
+ draft: {}
519
+ },
520
+ emits: ["submitted"],
521
+ setup(o, { emit: p }) {
522
+ const e = o, v = Le(), u = Ae(), x = dt(e, "show"), m = V(!1), y = V(!1), D = V(new Array()), U = Ue(), E = je(), R = ot(), s = Oe({}), d = M(() => new Set(
523
+ R.skus.filter((a) => {
524
+ var t;
525
+ return s[(t = a.customAttributes) == null ? void 0 : t.tag];
526
+ }).map((a) => a._id)
527
+ )), S = p, g = M(() => {
528
+ var t, r;
529
+ const a = [...((t = e.draft) == null ? void 0 : t.items) ?? [], ...((r = e.draft) == null ? void 0 : r.negativeStockItems) ?? []];
530
+ return d.value.size ? a.filter((l) => d.value.has(l.sku._id)) : a;
531
+ }), f = M(() => {
532
+ const a = g.value.map((t) => t.sku);
533
+ return a.sort((t, r) => t.code.localeCompare(r.code)), a;
534
+ }), j = M(() => g.value.groupBy(
535
+ (t) => t.sku._id,
536
+ (t) => t.measurementsAmounts.filter((r) => !r.measurement.abbrev.toLocaleLowerCase().includes("inactive")).map((r) => r.measurement.id)
537
+ ));
538
+ Ye(P), Ke(
539
+ () => e.show,
540
+ (a) => {
541
+ a && (J.value = Z[0], P());
542
+ }
543
+ );
544
+ const L = pe(0), b = pe(100);
545
+ async function P() {
546
+ var t, r, l;
547
+ m.value = !0;
548
+ const a = ((t = e.draft) == null ? void 0 : t.status) === oe.enum.COMPLETED;
549
+ try {
550
+ if (await R.init(), a) {
551
+ const c = e.draft.closingId;
552
+ if (!c) {
553
+ E.open({
554
+ title: "Something went wrong",
555
+ message: "Closing draft is completed but closing document cannot be found.",
556
+ type: "error"
557
+ }), console.error("Closing draft is completed but closing document cannot be found.", {
558
+ draftId: (r = e.draft) == null ? void 0 : r._id
559
+ });
560
+ return;
561
+ }
562
+ const i = await U.getClosingById(c);
563
+ D.value = (i == null ? void 0 : i.skus) ?? [];
564
+ } else
565
+ await v.readStockBalance(), D.value = ((l = v.stockBalance) == null ? void 0 : l.skus) ?? [];
566
+ } catch (c) {
567
+ E.open({
568
+ title: "Something went wrong",
569
+ message: "Something went wrong when fetching info. Please try again.",
570
+ type: "error"
571
+ }), console.error("error on fetch stock balances", c);
572
+ } finally {
573
+ m.value = !1;
574
+ }
575
+ }
576
+ const te = M(
577
+ () => D.value.groupBy(
578
+ (a) => a.id,
579
+ (a) => a.balance
580
+ )
581
+ ), ve = M(() => g.value.groupBy((a) => a.sku._id));
582
+ function se(a) {
583
+ return C(
584
+ ie.FmTooltip,
585
+ { zIndex: 51, placement: "left", class: "w-full flex justify-end" },
586
+ {
587
+ default() {
588
+ return a;
589
+ },
590
+ content() {
591
+ return "Differences are calculated using this formula: (Adjusted / System) × 100%";
592
+ }
593
+ }
594
+ );
595
+ }
596
+ const ae = M(() => {
597
+ const a = f.value.reduce((r, l) => {
598
+ var c, i, w, $;
599
+ return console.log(
600
+ "Measurement counts",
601
+ l.unit.name,
602
+ l.unit.abbrev,
603
+ (i = (c = j.value) == null ? void 0 : c.get(l._id)) == null ? void 0 : i[0].length
604
+ ), Math.max(r, (($ = (w = j.value) == null ? void 0 : w.get(l._id)) == null ? void 0 : $[0].length) ?? 0);
605
+ }, 0);
606
+ return [
607
+ {
608
+ id: "sku",
609
+ accessorFn: (r) => `${r.code} ${r.name}`,
610
+ header: () => "Name",
611
+ size: 350,
612
+ cell(r) {
613
+ const l = r.row.original, c = l.adjustedDiffPercentage, i = typeof c == "number" && Math.abs(c) > 10, w = C("div", { class: "flex flex-col gap-4" }, [
614
+ C(
615
+ "div",
616
+ {
617
+ class: [
618
+ "line-clamp-1 fm-typo-en-body-lg-400",
619
+ i ? " text-fm-color-system-error-300" : "text-fm-color-typo-primary"
620
+ ]
621
+ },
622
+ l.name
623
+ ),
624
+ C(
625
+ "div",
626
+ {
627
+ class: [
628
+ "line-clamp-1 fm-typo-en-body-md-400",
629
+ i ? " text-fm-color-system-error-300" : "text-fm-color-typo-secondary"
630
+ ]
631
+ },
632
+ l.code
633
+ )
634
+ ]);
635
+ return C(
636
+ ie.FmTooltip,
637
+ {
638
+ zIndex: 51
639
+ },
640
+ {
641
+ content() {
642
+ return i ? "Adjustment difference is more than 10%." : `${l.code} - ${l.name}`;
643
+ },
644
+ default() {
645
+ return C("div", { class: "flex items-center gap-4 justify-start w-full" }, [
646
+ w
647
+ ]);
648
+ }
649
+ }
650
+ );
651
+ }
652
+ },
653
+ {
654
+ id: "physicalBalances",
655
+ header: () => "Amounts",
656
+ enableSorting: !1,
657
+ cell(r) {
658
+ const l = r.row.original, c = (w, $) => C(
659
+ ie.FmTooltip,
660
+ { zIndex: 50 },
661
+ {
662
+ default() {
663
+ return C(
664
+ "div",
665
+ {
666
+ 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"
667
+ },
668
+ [
669
+ C("span", { class: "text-fm-color-typo-primary" }, `${w} `),
670
+ C(
671
+ "span",
672
+ {
673
+ class: "text-fm-color-typo-secondary",
674
+ style: { maxWidth: "80px" }
675
+ },
676
+ $
677
+ )
678
+ ]
679
+ );
680
+ },
681
+ content() {
682
+ return `${w} ${$}`;
683
+ }
684
+ }
685
+ );
686
+ let i = Array.from({ length: a }).map((w, $) => {
687
+ if (!l[`measurementAmount${$}`])
688
+ return null;
689
+ const F = l[`measurementAmount${$}`], le = l[`measurementAbbrev${$}`];
690
+ return c(F, le);
691
+ }).filter((w) => w);
692
+ return (l.baseUnitAmount || !i.length) && (i = [c(l.baseUnitAmount, l.baseUnit), ...i]), C("div", { class: "flex gap-8 flex-nowrap" }, i);
693
+ }
694
+ },
695
+ {
696
+ id: "physicalBalance",
697
+ accessorKey: "physicalBalance",
698
+ header: () => se("Actual Balance"),
699
+ size: 200,
700
+ meta: {
701
+ textAlign: "right"
702
+ }
703
+ },
704
+ {
705
+ id: "systemBalance",
706
+ accessorKey: "systemBalance",
707
+ header: () => se("Balance"),
708
+ size: 200,
709
+ meta: {
710
+ textAlign: "right"
711
+ }
712
+ },
713
+ {
714
+ id: "adjustedAmount",
715
+ accessorKey: "adjustedAmount",
716
+ header: () => se("Adjusted balance"),
717
+ size: 200,
718
+ meta: {
719
+ textAlign: "right"
720
+ }
721
+ },
722
+ {
723
+ id: "adjustedDiffPercentage",
724
+ accessorKey: "adjustedDiffPercentage",
725
+ header: () => C(
726
+ ie.FmTooltip,
727
+ { zIndex: 51, placement: "left", class: "w-full flex justify-end" },
728
+ {
729
+ default() {
730
+ return C("div", { class: "flex items-center gap-4" }, [
731
+ "Diff (%)",
732
+ C(ie.FmIcon, { name: "info", color: "neutral-gray-400", size: "sm" })
733
+ ]);
734
+ },
735
+ content() {
736
+ return "Differences are calculated using this formula: (Adjusted / System) × 100%";
737
+ }
738
+ }
739
+ ),
740
+ size: 200,
741
+ cell(r) {
742
+ const l = r.row.original.adjustedDiffPercentage;
743
+ if (!l) return "N/A";
744
+ const c = l.toFixed(2);
745
+ if (c === "0.00")
746
+ return C("div", { class: "flex items-center gap-4 justify-end" }, ["0.00"]);
747
+ const i = l > 0;
748
+ return C("div", { class: "flex items-center gap-4 justify-end" }, [
749
+ C(ie.FmIcon, {
750
+ name: i ? "arrow_drop_up" : "arrow_drop_down",
751
+ color: i ? "system-success-300" : "system-error-300",
752
+ size: "md"
753
+ }),
754
+ c
755
+ ]);
756
+ },
757
+ meta: {
758
+ textAlign: "right"
759
+ }
760
+ }
761
+ ];
762
+ }), ye = M(() => ae.value.map((a) => a.size ?? 0).reduce((a, t) => a + t)), re = V(""), de = M(() => f.value.map((a) => {
763
+ var F, le;
764
+ const t = (F = ve.value.get(a._id)) == null ? void 0 : F[0], r = ((le = te.value.get(a._id)) == null ? void 0 : le[0]) ?? L;
765
+ if (!t)
766
+ return {
767
+ code: a.code,
768
+ name: a.name,
769
+ baseUnit: a.unit.abbrev,
770
+ baseUnitAmount: 0,
771
+ systemBalance: +T(r),
772
+ physicalBalance: 0,
773
+ adjustedAmount: -+T(r),
774
+ adjustedDiffPercentage: -100
775
+ };
776
+ const l = Ne(t), c = Pe(l, r), i = r.amount === 0 ? null : Ie(c, {
777
+ ...r,
778
+ amount: Math.abs(r.amount)
779
+ }), w = i ? Ce(i, b) : null;
780
+ return {
781
+ code: a.code,
782
+ name: a.name,
783
+ baseUnit: a.unit.abbrev,
784
+ baseUnitAmount: +T(t.baseAmount),
785
+ ...t.measurementsAmounts.filter((Q) => {
786
+ var Y, ne, be;
787
+ return (be = (ne = (Y = j.value) == null ? void 0 : Y.get(a._id)) == null ? void 0 : ne[0]) == null ? void 0 : be.includes(Q.measurement.id);
788
+ }).reduce((Q, Y, ne) => (Q[`measurementAbbrev${ne}`] = `(${Y.measurement.abbrev}) × ${T(Y.measurement.conversion)}`, Q[`measurementAmount${ne}`] = +T(Y.amount), Q), {}),
789
+ systemBalance: +T(r),
790
+ physicalBalance: +T(l),
791
+ adjustedAmount: +T(c),
792
+ adjustedDiffPercentage: w ? +T(Me(w, 2)) : null
793
+ };
794
+ })), ge = M(() => {
795
+ var t, r, l;
796
+ if (!e.draft) return [];
797
+ const a = e.draft.approvedAt ? {
798
+ action: `Approve at ${ee(e.draft.approvedAt)}`,
799
+ // actionAt: props.draft.approvedAt,
800
+ actionBy: e.draft.approvedBy,
801
+ remark: e.draft.approveRemark
802
+ } : (t = e.draft.rejectionHistory) == null ? void 0 : t.computeFirst((c) => ({
803
+ action: `Reject at ${ee(c.rejectedAt)}`,
804
+ // actionAt: e.rejectedAt,
805
+ actionBy: c.rejectedBy,
806
+ remark: c.rejectRemark
807
+ }));
808
+ return [
809
+ {
810
+ label: "Using template",
811
+ value: ((r = e.draft.usingTemplates.find((c) => c)) == null ? void 0 : r.name) ?? "None"
812
+ },
813
+ {
814
+ label: "Created at",
815
+ value: ee(e.draft.createdAt)
816
+ },
817
+ {
818
+ label: "Created by",
819
+ value: e.draft.createdBy.name
820
+ },
821
+ {
822
+ label: "Updated at",
823
+ value: ee(e.draft.updatedAt)
824
+ },
825
+ {
826
+ label: "Updated by",
827
+ value: e.draft.updatedBy.name
828
+ },
829
+ {
830
+ label: "Effective at",
831
+ value: ee(e.draft.effectiveAt ?? e.draft.updatedAt)
832
+ },
833
+ e.draft.remark ? {
834
+ label: "Remark",
835
+ value: e.draft.remark
836
+ } : null,
837
+ a ? {
838
+ label: "Last action",
839
+ value: a.action
840
+ } : null,
841
+ a && a.actionBy ? {
842
+ label: "Last action by",
843
+ value: (l = a.actionBy) == null ? void 0 : l.name
844
+ } : null,
845
+ a && a.remark ? {
846
+ label: "Action remark",
847
+ value: a.remark
848
+ } : null
849
+ ].filter((c) => c).map((c) => c);
850
+ }), Z = [
851
+ {
852
+ label: "Overview",
853
+ value: "overview"
854
+ },
855
+ {
856
+ label: "Action history",
857
+ value: "history"
858
+ }
859
+ ], J = V(Z[0]), q = M(() => {
860
+ var t, r, l, c;
861
+ return [
862
+ ...(((t = e.draft) == null ? void 0 : t.rejectionHistory) ?? []).map(
863
+ (i) => ({
864
+ header: "Reject",
865
+ date: ee(i.rejectedAt),
866
+ info: [
867
+ {
868
+ label: "Rejected by",
869
+ values: [i.rejectedBy.name]
870
+ },
871
+ {
872
+ label: "Rejection remark",
873
+ values: [i.rejectRemark]
874
+ }
875
+ ]
876
+ })
877
+ ),
878
+ ...(r = e.draft) != null && r.approvedBy ? [
879
+ {
880
+ header: "Approve",
881
+ date: e.draft.approvedAt ? ee(e.draft.approvedAt) : "",
882
+ info: [
883
+ {
884
+ label: "Approved by",
885
+ values: [(l = e.draft) == null ? void 0 : l.approvedBy.name]
886
+ },
887
+ {
888
+ label: "Approval remark",
889
+ values: [((c = e.draft) == null ? void 0 : c.approveRemark) ?? ""]
890
+ }
891
+ ]
892
+ }
893
+ ] : []
894
+ ];
895
+ }), me = M(() => {
896
+ var c, i, w, $;
897
+ if ((c = e == null ? void 0 : e.draft) != null && c.approvedAt) return "Draft is already approved.";
898
+ if (((i = e.draft) == null ? void 0 : i.status) !== oe.enum.DRAFT) return "Status is not draft.";
899
+ const a = de.value.some((F) => F.physicalBalance < 0), t = (($ = (w = v.stockBalance.skus) == null ? void 0 : w.filter((F) => F.balance.amount < 0)) == null ? void 0 : $.map((F) => F.id)) ?? [], r = new Set(f.value.map((F) => F._id)), l = t.filter((F) => !r.has(F)).length;
900
+ return [
901
+ a ? "Negative total exist." : null,
902
+ l ? "Negative stock is not included in this draft. Reopen draft in POS and apply changes." : null
903
+ ].filter((F) => F).join(" ");
904
+ });
905
+ return (a, t) => {
906
+ const r = I("FmButtonGroup"), l = I("FmMenuDivider"), c = I("FmCard"), i = I("FmButton"), w = I("FmCircularProgress"), $ = I("FmTextField"), F = I("FmIcon"), le = I("FmChip"), Q = I("FmTable"), Y = I("FmSpacer"), ne = I("FmTooltip"), be = I("FmSideSheet");
907
+ return A(), W(be, {
908
+ "dismiss-away": "",
909
+ "max-width": 900,
910
+ "model-value": h(x),
911
+ "onUpdate:modelValue": t[8] || (t[8] = (_) => Te(x) ? x.value = _ : null),
912
+ header: "Closing details"
913
+ }, {
914
+ "side-sheet-footer": O(() => {
915
+ var _, H, N, ce;
916
+ return [
917
+ n("div", na, [
918
+ ((_ = e.draft) == null ? void 0 : _.status) === h(oe).enum.DRAFT ? (A(), B(K, { key: 0 }, [
919
+ me.value ? (A(), W(ne, {
920
+ key: 0,
921
+ "z-index": 51
922
+ }, {
923
+ content: O(() => [
924
+ _e(z(me.value), 1)
925
+ ]),
926
+ default: O(() => [
927
+ k(i, {
928
+ disabled: "",
929
+ key: "approve key",
930
+ label: "Approve",
931
+ onClick: t[3] || (t[3] = () => e.draft && h(u).approveDraft(e.draft, () => S("submitted")))
932
+ })
933
+ ]),
934
+ _: 1
935
+ })) : (A(), W(i, {
936
+ key: "approve key",
937
+ label: "Approve",
938
+ onClick: t[4] || (t[4] = () => e.draft && h(u).approveDraft(e.draft, () => S("submitted")))
939
+ }))
940
+ ], 64)) : X("", !0),
941
+ ((H = e.draft) == null ? void 0 : H.status) === h(oe).enum.DRAFT ? (A(), W(i, {
942
+ key: 1,
943
+ label: "Reject",
944
+ variant: "destructive",
945
+ onClick: t[5] || (t[5] = () => e.draft && h(u).rejectDraft(e.draft, () => S("submitted")))
946
+ })) : X("", !0),
947
+ (N = e.draft) != null && N.approvedAt && ((ce = e.draft) == null ? void 0 : ce.status) !== h(oe).enum.COMPLETED ? (A(), W(i, {
948
+ key: 2,
949
+ label: "Sync",
950
+ loading: y.value,
951
+ onClick: t[6] || (t[6] = () => {
952
+ e.draft && (y.value = !0, h(u).syncDraft(e.draft, () => {
953
+ y.value = !1, S("submitted");
954
+ }));
955
+ })
956
+ }, null, 8, ["loading"])) : X("", !0),
957
+ k(i, {
958
+ label: "Close",
959
+ variant: "tertiary",
960
+ onClick: t[7] || (t[7] = (Fe) => x.value = !1)
961
+ })
962
+ ])
963
+ ];
964
+ }),
965
+ default: O(() => [
966
+ n("div", Ct, [
967
+ n("div", null, [
968
+ k(r, {
969
+ items: Z,
970
+ modelValue: J.value,
971
+ "onUpdate:modelValue": t[0] || (t[0] = (_) => J.value = _)
972
+ }, null, 8, ["modelValue"])
973
+ ]),
974
+ J.value.value === "overview" ? (A(), B(K, { key: 0 }, [
975
+ k(c, {
976
+ variant: "outlined",
977
+ class: "flex flex-col gap-8 px-12 py-16"
978
+ }, {
979
+ default: O(() => {
980
+ var _, H;
981
+ return [
982
+ n("div", jt, [
983
+ t[9] || (t[9] = n("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
984
+ n("div", St, [
985
+ n("div", {
986
+ class: ue(["fm-status-badge", h(De)(((_ = a.draft) == null ? void 0 : _.status) ?? "DRAFT")])
987
+ }, z(h(Ee)(((H = a.draft) == null ? void 0 : H.status) ?? "")), 3)
988
+ ])
989
+ ]),
990
+ k(l),
991
+ (A(!0), B(K, null, fe(ge.value, (N, ce) => (A(), B("div", {
992
+ class: "flex flex-col gap-4",
993
+ key: ce
994
+ }, [
995
+ n("div", Ft, [
996
+ n("div", Bt, z(N.label), 1)
997
+ ]),
998
+ n("div", $t, z(N.value), 1)
999
+ ]))), 128))
1000
+ ];
1001
+ }),
1002
+ _: 1
1003
+ }),
1004
+ n("div", Tt, [
1005
+ n("div", Rt, [
1006
+ t[10] || (t[10] = n("div", { class: "flex-1 fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, " Closing items ", -1)),
1007
+ m.value ? X("", !0) : (A(), B("div", Pt, [
1008
+ k(i, {
1009
+ label: "Export data",
1010
+ "prepend-icon": "download",
1011
+ variant: "secondary",
1012
+ "text-color": "primary",
1013
+ "bg-color": "transparent",
1014
+ "border-color": "primary",
1015
+ onClick: t[1] || (t[1] = (_) => a.draft ? h(u).exportDraft(a.draft, D.value) : null)
1016
+ })
1017
+ ]))
1018
+ ]),
1019
+ m.value ? (A(), B("div", It, [
1020
+ t[12] || (t[12] = n("div", { class: "h-80" }, null, -1)),
1021
+ n("div", Mt, [
1022
+ n("div", null, [
1023
+ k(w, { size: "md" })
1024
+ ]),
1025
+ t[11] || (t[11] = n("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
1026
+ ]),
1027
+ t[13] || (t[13] = n("div", { class: "h-80" }, null, -1))
1028
+ ])) : (A(), B(K, { key: 1 }, [
1029
+ n("div", null, [
1030
+ k($, {
1031
+ modelValue: re.value,
1032
+ "onUpdate:modelValue": t[2] || (t[2] = (_) => re.value = _),
1033
+ placeholder: "Filter items"
1034
+ }, null, 8, ["modelValue"])
1035
+ ]),
1036
+ h(R).skuTags.size ? (A(), B("div", Ut, [
1037
+ (A(!0), B(K, null, fe(h(R).skuTags.keys(), (_) => (A(), W(le, {
1038
+ key: `${_}`,
1039
+ label: `${_}`,
1040
+ selectable: "",
1041
+ selected: s[`${_}`],
1042
+ onClick: (H) => s[`${_}`] = !s[`${_}`]
1043
+ }, {
1044
+ default: O(() => [
1045
+ s[`${_}`] ? (A(), W(F, {
1046
+ key: 0,
1047
+ name: "check",
1048
+ class: "text-white",
1049
+ size: "sm"
1050
+ })) : X("", !0),
1051
+ n("span", {
1052
+ class: ue([
1053
+ "",
1054
+ {
1055
+ "text-white fm-typo-en-body-md-600": s[`${_}`],
1056
+ "text-fm-color-typo-primary fm-typo-en-body-md-400": !s[`${_}`]
1057
+ }
1058
+ ])
1059
+ }, z(_), 3)
1060
+ ]),
1061
+ _: 2
1062
+ }, 1032, ["label", "selected", "onClick"]))), 128))
1063
+ ])) : X("", !0),
1064
+ n("div", Et, [
1065
+ n("div", {
1066
+ style: Re({ width: `${ye.value}px` })
1067
+ }, [
1068
+ k(Q, {
1069
+ "column-defs": ae.value,
1070
+ "row-data": de.value,
1071
+ "search-value": re.value
1072
+ }, null, 8, ["column-defs", "row-data", "search-value"])
1073
+ ], 4)
1074
+ ])
1075
+ ], 64))
1076
+ ])
1077
+ ], 64)) : X("", !0),
1078
+ J.value.value === "history" ? (A(), B("div", Ht, [
1079
+ q.value.length ? (A(), B("div", Nt, [
1080
+ (A(!0), B(K, null, fe(q.value, (_, H) => (A(), B(K, { key: H }, [
1081
+ n("div", Vt, [
1082
+ n("div", Ot, [
1083
+ n("div", Yt, [
1084
+ n("div", {
1085
+ class: ue([
1086
+ {
1087
+ "bg-fm-color-primary": H !== 0,
1088
+ "bg-white": H === 0
1089
+ },
1090
+ "w-[2px] h-full"
1091
+ ])
1092
+ }, null, 2)
1093
+ ]),
1094
+ t[16] || (t[16] = n("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1095
+ n("div", Kt, [
1096
+ n("div", {
1097
+ class: ue([
1098
+ {
1099
+ "bg-fm-color-primary": H < q.value.length - 1,
1100
+ "bg-white": H >= q.value.length - 1
1101
+ },
1102
+ "w-[2px] h-full"
1103
+ ])
1104
+ }, null, 2)
1105
+ ])
1106
+ ]),
1107
+ n("div", Gt, [
1108
+ n("div", qt, z(_.header), 1),
1109
+ n("div", Wt, z(_.date), 1)
1110
+ ])
1111
+ ]),
1112
+ n("div", Zt, [
1113
+ n("div", Jt, [
1114
+ n("div", Qt, [
1115
+ n("div", {
1116
+ class: ue([
1117
+ {
1118
+ "bg-fm-color-primary": H < q.value.length - 1,
1119
+ "bg-white": H >= q.value.length - 1
1120
+ },
1121
+ "w-[2px] h-full"
1122
+ ])
1123
+ }, null, 2)
1124
+ ])
1125
+ ]),
1126
+ n("div", Xt, [
1127
+ k(c, {
1128
+ variant: "outlined",
1129
+ class: "py-12 px-16"
1130
+ }, {
1131
+ default: O(() => [
1132
+ n("div", ea, [
1133
+ (A(!0), B(K, null, fe(_.info, (N, ce) => (A(), B("div", {
1134
+ key: ce,
1135
+ class: "flex flex-col gap-4"
1136
+ }, [
1137
+ n("div", ta, z(N == null ? void 0 : N.label), 1),
1138
+ n("div", aa, [
1139
+ (A(!0), B(K, null, fe(N == null ? void 0 : N.values, (Fe, Ve) => (A(), B("div", {
1140
+ key: Ve,
1141
+ class: "fm-typo-en-body-lg-600"
1142
+ }, z(Fe), 1))), 128))
1143
+ ])
1144
+ ]))), 128))
1145
+ ])
1146
+ ]),
1147
+ _: 2
1148
+ }, 1024)
1149
+ ])
1150
+ ])
1151
+ ], 64))), 128))
1152
+ ])) : (A(), B("div", zt, [
1153
+ k(Y),
1154
+ n("div", null, [
1155
+ n("img", {
1156
+ src: h(pt),
1157
+ alt: "List is empty"
1158
+ }, null, 8, Lt)
1159
+ ]),
1160
+ t[14] || (t[14] = n("div", { class: "fm-typo-en-body-lg-600" }, z("No records found"), -1)),
1161
+ t[15] || (t[15] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, z("You can track approval and rejection history here"), -1)),
1162
+ k(Y),
1163
+ k(Y)
1164
+ ]))
1165
+ ])) : X("", !0)
1166
+ ])
1167
+ ]),
1168
+ _: 1
1169
+ }, 8, ["model-value"]);
1170
+ };
1171
+ }
1172
+ }), sa = { class: "flex-1 flex flex-col gap-8" }, ra = { class: "flex flex-col" }, la = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ca = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, ia = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, ua = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, ba = /* @__PURE__ */ ke({
1173
+ __name: "ClosingDraftView",
1174
+ setup(o) {
1175
+ const { t: p } = He(), { viewDraft: e } = Ae(), { viewClosingDraftProps: v, viewClosingDraftShow: u } = ft(Ae()), x = we(), m = wt(), y = st(), { breakpoints: D } = mt();
1176
+ x.watchLocation(m.fetchDrafts);
1177
+ const U = M(() => m.loading), E = V(""), R = M(() => D.value.xs || D.value.sm), s = M(() => R.value ? 10 : 20);
1178
+ function d(f) {
1179
+ switch (f) {
1180
+ case "refresh":
1181
+ return m.fetchDrafts();
1182
+ }
1183
+ }
1184
+ function S(f) {
1185
+ return f;
1186
+ }
1187
+ const g = M(() => R.value ? [
1188
+ {
1189
+ label: "Refresh",
1190
+ value: "refresh",
1191
+ isPrimary: !1
1192
+ }
1193
+ ] : [
1194
+ {
1195
+ label: "Refresh",
1196
+ value: "refresh",
1197
+ isPrimary: !1
1198
+ }
1199
+ ]);
1200
+ return (f, j) => {
1201
+ const L = I("FmTable");
1202
+ return A(), B(K, null, [
1203
+ k(rt, {
1204
+ title: h(p)("inventory.closing.draft.title"),
1205
+ actions: g.value,
1206
+ "onClick:action": d
1207
+ }, {
1208
+ default: O(() => [
1209
+ n("div", {
1210
+ class: ue([
1211
+ "flex flex-col gap-8 max-h-full",
1212
+ {
1213
+ "p-0": R.value,
1214
+ "px-24 ": !R.value
1215
+ }
1216
+ ])
1217
+ }, [
1218
+ k(lt, {
1219
+ "change-location": "",
1220
+ searchable: "",
1221
+ search: E.value,
1222
+ "onUpdate:search": j[0] || (j[0] = (b) => E.value = b)
1223
+ }, null, 8, ["search"]),
1224
+ k(L, {
1225
+ style: Re(h(y).tableHeight),
1226
+ "column-defs": h(m).columnDefs,
1227
+ "row-data": h(m).drafts,
1228
+ "search-value": E.value,
1229
+ loading: U.value,
1230
+ onRowClick: j[1] || (j[1] = (b) => h(e)(b.original)),
1231
+ "page-size": s.value
1232
+ }, {
1233
+ "list-row": O((b) => [
1234
+ k(ct, {
1235
+ row: b,
1236
+ onRowClick: (P) => h(e)(P)
1237
+ }, {
1238
+ default: O((P) => {
1239
+ var te, ve, se, ae, ye, re, de, ge, Z, J, q, me, a, t, r, l, c, i, w, $;
1240
+ return [
1241
+ n("div", sa, [
1242
+ n("div", ra, [
1243
+ n("div", la, [
1244
+ k(h(xe), {
1245
+ render: (se = (ve = (te = P._id) == null ? void 0 : te.column) == null ? void 0 : ve.columnDef) == null ? void 0 : se.cell,
1246
+ props: (ye = (ae = P._id) == null ? void 0 : ae.getContext) == null ? void 0 : ye.call(ae)
1247
+ }, null, 8, ["render", "props"])
1248
+ ]),
1249
+ n("div", ca, [
1250
+ k(h(xe), {
1251
+ render: (ge = (de = (re = P.name) == null ? void 0 : re.column) == null ? void 0 : de.columnDef) == null ? void 0 : ge.cell,
1252
+ props: (J = (Z = P.name) == null ? void 0 : Z.getContext) == null ? void 0 : J.call(Z)
1253
+ }, null, 8, ["render", "props"])
1254
+ ]),
1255
+ n("div", ia, z([
1256
+ ...b.original.items.slice(0, 3).map((F) => F.sku.name),
1257
+ ...b.original.items.length >= 3 ? [`and ${b.original.items.length - 3} more items`] : []
1258
+ ].join(", ")), 1),
1259
+ n("div", ua, [
1260
+ k(h(xe), {
1261
+ render: (a = (me = (q = P.ref) == null ? void 0 : q.column) == null ? void 0 : me.columnDef) == null ? void 0 : a.cell,
1262
+ props: (r = (t = P.ref) == null ? void 0 : t.getContext) == null ? void 0 : r.call(t)
1263
+ }, null, 8, ["render", "props"])
1264
+ ])
1265
+ ]),
1266
+ n("div", null, [
1267
+ k(h(xe), {
1268
+ render: (i = (c = (l = P.status) == null ? void 0 : l.column) == null ? void 0 : c.columnDef) == null ? void 0 : i.cell,
1269
+ props: ($ = (w = P.status) == null ? void 0 : w.getContext) == null ? void 0 : $.call(w)
1270
+ }, null, 8, ["render", "props"])
1271
+ ])
1272
+ ])
1273
+ ];
1274
+ }),
1275
+ _: 2
1276
+ }, 1032, ["row", "onRowClick"])
1277
+ ]),
1278
+ _: 1
1279
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1280
+ ], 2)
1281
+ ]),
1282
+ _: 1
1283
+ }, 8, ["title", "actions"]),
1284
+ (A(), W(Ge, { to: "body" }, [
1285
+ k(oa, qe(h(v), {
1286
+ show: h(u),
1287
+ "onUpdate:show": j[2] || (j[2] = (b) => Te(u) ? u.value = b : null),
1288
+ onSubmitted: j[3] || (j[3] = () => (u.value = !1, h(m).fetchDrafts()))
1289
+ }), null, 16, ["show"])
1290
+ ]))
1291
+ ], 64);
1292
+ };
1293
+ }
1294
+ });
1295
+ export {
1296
+ ba as default
1297
+ };