@feedmepos/mf-inventory-portal 0.0.25-dev.26 → 0.0.25-dev.28

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