@feedmepos/mf-inventory-portal 1.2.42-dev.2 → 1.2.42

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