@feedmepos/mf-inventory-portal 1.2.26 → 1.2.27

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