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