@feedmepos/mf-inventory-portal 1.2.25-dev.4 → 1.2.25-dev.5

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