@feedmepos/mf-inventory-portal 1.3.9-dev.2 → 1.3.10

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