@feedmepos/mf-inventory-portal 1.7.0-dev.6 → 1.7.0-dev.8

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 (118) hide show
  1. package/README.md +8 -8
  2. package/dist/{App-NlIy4RUv.js → App-DGt1TKAe.js} +4 -4
  3. package/dist/{ApprovalView-E7y0ueFH.js → ApprovalView-DA6vPFB8.js} +8 -8
  4. package/dist/{BindingsDialog-BNApImJz.js → BindingsDialog-CdcKh6UZ.js} +2 -2
  5. package/dist/{BindingsPicker-DRWs430b.js → BindingsPicker-C0q1FNa6.js} +2 -2
  6. package/dist/{BindingsTable-BC1TgKaN.js → BindingsTable-BnBAlW1t.js} +3 -3
  7. package/dist/{BulkReceiveRequestView-3XmccTDH.js → BulkReceiveRequestView-BiiwvM-O.js} +19 -19
  8. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DW71yYOY.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DsY0X4Er.js} +1 -1
  9. package/dist/ClosingDraftView-CNEvYNfz.js +4398 -0
  10. package/dist/ClosingHistoryView-BvaVrfjv.js +1112 -0
  11. package/dist/ClosingTemplateView-DxPGJz0K.js +2270 -0
  12. package/dist/CursorPaginatedTable.vue_vue_type_script_setup_true_lang-4KT9rH9e.js +152 -0
  13. package/dist/{DefaultView-vIumMOKt.js → DefaultView-Mqtuxaq1.js} +2 -2
  14. package/dist/{DeliveryOrderPrintPreview-DhLgl3uz.js → DeliveryOrderPrintPreview--IKofxUf.js} +2 -2
  15. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-Cn2ub5XB.js → EmailDialog.vue_vue_type_script_setup_true_lang-CZLIa7_0.js} +23 -23
  16. package/dist/FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-cu92NvT7.js +69 -0
  17. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CNkXEMRd.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DJSDKAcv.js} +2 -2
  18. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DC21Ybcs.js +120 -0
  19. package/dist/{FmMultiselectDialog-Ckl1Yv9A.js → FmMultiselectDialog-BRN_fVWG.js} +1 -1
  20. package/dist/{FmMultiselectDialog-BKUDjNe8.js → FmMultiselectDialog-DNMu6Pyo.js} +2 -2
  21. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-D-dqtdHm.js → FmUnitInput.vue_vue_type_script_setup_true_lang-JjqnjgF6.js} +5 -5
  22. package/dist/{ImportView-B2dZLlIQ.js → ImportView-CzhINr8x.js} +6 -6
  23. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CZN7bMba.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-UX70sCkO.js} +1 -1
  24. package/dist/{IngredientGroupView-B8uTaewu.js → IngredientGroupView-D34lU0nT.js} +5 -5
  25. package/dist/{IngredientsView-0pIpqaYP.js → IngredientsView-C5APBsVv.js} +16 -16
  26. package/dist/{IntegrationExplorerView-m340FRkF.js → IntegrationExplorerView-B9CMZOyM.js} +4 -4
  27. package/dist/{IntegrationView-CR63stDu.js → IntegrationView-C2QFD6iK.js} +13 -13
  28. package/dist/{InventoryBindingForm-DxwGujF1.js → InventoryBindingForm-B6KPHHXM.js} +1 -1
  29. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CuXUsDzD.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DqTs4tkd.js} +5 -5
  30. package/dist/{InventoryBindingSummary-BZC8PmSy.js → InventoryBindingSummary-C3pSlQIV.js} +1 -1
  31. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DUQxKXKO.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BBj2fp9p.js} +1 -1
  32. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DhabkmeS.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BQcze770.js} +1 -1
  33. package/dist/{ProductionView-DGK7ari8.js → ProductionView-D3hxR4Al.js} +7 -7
  34. package/dist/{PublishView-C2WdbS4L.js → PublishView-dyIbB5oY.js} +3 -3
  35. package/dist/{PurchaseOrderPrintPreview-DbB68sX0.js → PurchaseOrderPrintPreview-BtecmMvJ.js} +2 -2
  36. package/dist/{ReceiveRequestView-zAUq0Ssz.js → ReceiveRequestView-CsyLhbWO.js} +13 -13
  37. package/dist/{RecipeView-C5w_pUXR.js → RecipeView-C0GFeSDy.js} +17 -17
  38. package/dist/{SettingsView-DLRcCvk4.js → SettingsView-CLjyeHBv.js} +4 -4
  39. package/dist/{StockView-BaH1vKcT.js → StockView-CGiQO7JM.js} +21 -21
  40. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-weKIvp8F.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Bpa_-7Xw.js} +1 -1
  41. package/dist/{SupplierView-DrviX9XY.js → SupplierView-BxGah90N.js} +12 -12
  42. package/dist/{SurchargeView-PeKEls1Z.js → SurchargeView-_K_rxa1E.js} +6 -6
  43. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-Czkd0qqw.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-C5iFkaac.js} +2 -2
  44. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-B01wr4F8.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CJHiozGf.js} +1 -1
  45. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Dqz1eFSJ.js → TransferDetails.vue_vue_type_script_setup_true_lang-XTJW-ITd.js} +20 -20
  46. package/dist/{TransferTemplateView-wN2nr_0X.js → TransferTemplateView-BEVHHa3g.js} +20 -20
  47. package/dist/{UnitCostHistoryView-DGTYxbvj.js → UnitCostHistoryView-BHYOJdh7.js} +4 -4
  48. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-B6krURPH.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-DbqnEmeM.js} +4 -4
  49. package/dist/{UnitView-C8SM9fQP.js → UnitView-BtwxautF.js} +7 -7
  50. package/dist/{WarehouseView-DhOlmE3U.js → WarehouseView-iCaNZRIz.js} +5 -5
  51. package/dist/{WastageTemplateView-CM4eTx0N.js → WastageTemplateView-Bc6GJd4d.js} +14 -14
  52. package/dist/api/closing-draft.d.ts +11 -0
  53. package/dist/api/closing-template.d.ts +11 -2
  54. package/dist/api/closing.d.ts +12 -1
  55. package/dist/{app-pfHbU1WT.js → app-BP2iMkXf.js} +4521 -4308
  56. package/dist/app.d.ts +8 -0
  57. package/dist/app.js +1 -1
  58. package/dist/{closing-template-C6Vx5eWA.js → closing-template-5y8eotCC.js} +31 -11
  59. package/dist/components/CursorPaginatedTable.vue.d.ts +136 -0
  60. package/dist/components/FmInventoryTableToolbar.vue.d.ts +26 -0
  61. package/dist/components/ui-library/FmDateRangePickerChip.vue.d.ts +5 -0
  62. package/dist/composable/defineApi.d.ts +1 -1
  63. package/dist/{date2-C-n9LpKa.js → date2-Bfw67PjS.js} +1 -1
  64. package/dist/{dayjs.min-Bu4_8gM9.js → dayjs.min-B3qfrpYu.js} +1 -1
  65. package/dist/{decimal-C2_Vh-I3.js → decimal-SalS1cxI.js} +2 -2
  66. package/dist/{defineDeepModel-CXP9xlO9.js → defineDeepModel-CCBhCBwm.js} +1 -1
  67. package/dist/{duplicate-template-XPmYbOJ9.js → duplicate-template-C0FI8Pt9.js} +1 -1
  68. package/dist/{feature-CLk0uPEH.js → feature-Cp_nrPL6.js} +2 -2
  69. package/dist/{format-time-from-id-G5QRBa84.js → format-time-from-id-BCn8GnjQ.js} +1 -1
  70. package/dist/{format-unit-display-IIqavf90.js → format-unit-display-CXbG9MgA.js} +12 -12
  71. package/dist/{import-export.helper-BO_uqwp4.js → import-export.helper-D4GvjZUO.js} +6 -6
  72. package/dist/{index-Ce3fiDvd.js → index-CzkezMbA.js} +3344 -3066
  73. package/dist/{index-Dcm54ldM.js → index-DvTfqbiM.js} +1 -1
  74. package/dist/{index-DnpSJzwo.js → index-xDQmlVeP.js} +3 -3
  75. package/dist/{inventory-core-dart.default-INsUG73Y.js → inventory-core-dart.default-CVpYUeBn.js} +1 -1
  76. package/dist/{jszip.min-D3KgBOLH.js → jszip.min-CfuFlbgP.js} +2 -2
  77. package/dist/{lz-string-BWhXP-Xc.js → lz-string-D9ANZJke.js} +1 -1
  78. package/dist/{netsuite-DzOrZBvA.js → netsuite-Dijt7bYw.js} +2 -2
  79. package/dist/{number-VpMHWJsJ.js → number-DI4WG85J.js} +3 -3
  80. package/dist/{predefined-templates-BvnvUI_F.js → predefined-templates-1-zDE0Iu.js} +1 -1
  81. package/dist/{purchase-order-template-CJh4_Q3H.js → purchase-order-template-CbI-13Ym.js} +1 -1
  82. package/dist/{recalculationUtils-BTvAwC7J.js → recalculationUtils-B2r9j-19.js} +1 -1
  83. package/dist/{rules-LPO_v5Zr.js → rules-DxJtL6OC.js} +2 -2
  84. package/dist/{stock-DCHhwIaC.js → stock-6C0d5Fe8.js} +1 -1
  85. package/dist/{stock-CqpYPWHj.js → stock-BDGgOFuW.js} +3 -3
  86. package/dist/stores/inventory.import-errors.spec.d.ts +1 -0
  87. package/dist/{supplier-CZEJx5mC.js → supplier-BVmJ5p3z.js} +2 -2
  88. package/dist/{surcharge-BbTuG_a2.js → surcharge-BRNgbJmg.js} +1 -1
  89. package/dist/tsconfig.app.tsbuildinfo +1 -1
  90. package/dist/{uom-rules-Cu4fXhZ2.js → uom-rules-Czbq4YOl.js} +1 -1
  91. package/dist/{use-ingredient-select-dialog-D6ETW66d.js → use-ingredient-select-dialog-F4E4y-uM.js} +2 -2
  92. package/dist/{use-inventory-binding-dialog-D_b729Po.js → use-inventory-binding-dialog-CETXyyXW.js} +2 -2
  93. package/dist/{use-template-enabled-locations-DeR8DY64.js → use-template-enabled-locations-BXD1IoQM.js} +2 -2
  94. package/dist/{use-transfer-locations-DysOG_1c.js → use-transfer-locations-DSHSzGPR.js} +2 -2
  95. package/dist/{useHrmPermission-BDMnFbDK.js → useHrmPermission-tg3v6qrq.js} +1 -1
  96. package/dist/{useNavigationMenu-CjoofsrC.js → useNavigationMenu-tbjt_qJ2.js} +2 -2
  97. package/dist/{useSseClient-B7hHgXIn.js → useSseClient-BvEOOnEx.js} +1 -1
  98. package/dist/views/adjustment-template/wastage-template/table.d.ts +1 -1
  99. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.vue.d.ts +4 -2
  100. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +8 -4
  101. package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupDetailSideSheet.vue.d.ts +4 -2
  102. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +1290 -15
  103. package/dist/views/closing-draft/composables/use-closing-draft-import.d.ts +2 -1
  104. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +234 -3090
  105. package/dist/views/closing-draft/helpers/closing-group-status.helper.d.ts +5 -3
  106. package/dist/views/closing-draft/helpers/closing-groups.helper.d.ts +19 -8
  107. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +577 -15
  108. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +51 -1025
  109. package/dist/views/closing-template/helpers/import-export.helper.d.ts +1 -1
  110. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +1 -1
  111. package/dist/{vue-i18n-kLRqcyG8.js → vue-i18n-D1uxFCER.js} +1 -1
  112. package/dist/{xlsx.util-1F6O_wmm.js → xlsx.util-CRhZzioa.js} +2 -2
  113. package/package.json +2 -2
  114. package/dist/ClosingDraftView-DUv-k-RN.js +0 -4320
  115. package/dist/ClosingHistoryView-CGb32hip.js +0 -1115
  116. package/dist/ClosingTemplateView-DtxeqHgX.js +0 -2237
  117. package/dist/FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-OReBYvpY.js +0 -61
  118. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DiyqG-gq.js +0 -118
@@ -1,4320 +0,0 @@
1
- import { defineComponent as De, ref as Q, computed as S, onMounted as tn, resolveComponent as J, createElementBlock as C, createBlock as ne, openBlock as p, Fragment as re, createTextVNode as fe, withCtx as te, createElementVNode as a, createCommentVNode as H, createVNode as D, toDisplayString as N, unref as f, h as _, watch as Be, renderList as ge, onUnmounted as Un, withModifiers as Nn, normalizeStyle as mt, normalizeClass as he, isRef as vt, reactive as Zt, createSlots as Vn, Teleport as En, mergeProps as Ln } from "vue";
2
- import { u as zn, _ as On } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DwrLsWX_.js";
3
- import { useCoreStore as nn, useI18n as Je } from "@feedmepos/mf-common";
4
- import { useSnackbar as ze, useDialog as on, components as ye, useProxiedModel as St, useBreakpoints as Gn } from "@feedmepos/ui-library";
5
- import { m as Hn, u as Oe, M as de, w as oe, q as an, s as Ae, O as _e, B as Re, c as Yn, a as Ft, j as Kn } from "./app-pfHbU1WT.js";
6
- import { defineStore as sn, storeToRefs as Wn } from "pinia";
7
- import { b as ft, e as rn, f as qn, a as $e } from "./date2-C-n9LpKa.js";
8
- import { R as ln } from "./rules-LPO_v5Zr.js";
9
- import { e as yt, c as qe, j as Qe, l as cn, m as un, a as Qn, k as dn, o as ie, t as Jn } from "./number-VpMHWJsJ.js";
10
- import { b as Zn, d as Xn, u as dt, w as eo, c as to } from "./xlsx.util-1F6O_wmm.js";
11
- import { i as It, u as Bt } from "./uom-rules-Cu4fXhZ2.js";
12
- import { u as no } from "./stock-CqpYPWHj.js";
13
- import { u as gt } from "./stock-DCHhwIaC.js";
14
- import { D as Xt, R as Ve } from "./row-action.enum-DQ9bJ_uv.js";
15
- import { c as oo } from "./component-kqxARxvM.js";
16
- import { f as ao } from "./format-time-from-id-G5QRBa84.js";
17
- import { f as so } from "./recalculationUtils-BTvAwC7J.js";
18
- import { _ as ro } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DiyqG-gq.js";
19
- import { _ as mn } from "./empty-placeholder-B0QU467o.js";
20
- import { F as $t } from "./FmAdminBadge-DlplQOHb.js";
21
- import { u as lo } from "./vue-i18n-kLRqcyG8.js";
22
- import { F as io } from "./decimal-C2_Vh-I3.js";
23
- import { u as co } from "./useSseClient-B7hHgXIn.js";
24
- import { d as uo } from "./dayjs.min-Bu4_8gM9.js";
25
- import { F as mo } from "./FmDroppableField-J0tG_U3w.js";
26
- import { _ as fo } from "./FmConfirmationButton.vue_vue_type_script_setup_true_lang-Vg8U7WMZ.js";
27
- import { _ as po, F as Ye } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DAMpuZ1X.js";
28
- const Me = Hn((t, n) => {
29
- function e() {
30
- return Oe().currentLocation.dbName;
31
- }
32
- return {
33
- getDbName: e,
34
- async getDraft(o) {
35
- const i = e(), s = `${t.inventoryBackendUrl}/${i}/closing-draft/${o}`;
36
- return n.get(s);
37
- },
38
- async readDrafts() {
39
- const o = e(), i = `${t.inventoryBackendUrl}/${o}/closing-draft`;
40
- return n.get(i);
41
- },
42
- async runOperation(o) {
43
- const i = e(), s = `${t.inventoryBackendUrl}/${i}/closing-draft/run-operation`;
44
- return n.post(s, o);
45
- },
46
- async runOperationV1(o) {
47
- const i = e(), s = `${t.inventoryBackendUrl}/${i}/closing-draft/v1/run-operation`;
48
- return n.post(s, o);
49
- },
50
- async sync(o) {
51
- const i = e(), s = `${t.inventoryBackendUrl}/${i}/closing-draft/sync`;
52
- return n.post(s, o);
53
- },
54
- async cloneDraft(o) {
55
- const i = e(), s = `${t.inventoryBackendUrl}/${i}/closing-draft/${o}/clone`;
56
- return n.post(s, {});
57
- },
58
- /** Closing groups belonging to a parent closing draft. */
59
- async getClosingGroups(o) {
60
- const i = e(), s = `${t.inventoryBackendUrl}/${i}/closing-draft/${o}/groups`;
61
- return n.get(s);
62
- },
63
- /** Approve a closing group (sub-closing): status -> COMPLETED, no recalculation. */
64
- async approveClosingGroup(o, i) {
65
- const s = e(), r = `${t.inventoryBackendUrl}/${s}/closing-draft/${o}/group/approve`;
66
- return n.post(r, { remark: i });
67
- },
68
- /** Reject a closing group (sub-closing): records a rejection note, stays DRAFT. */
69
- async rejectClosingGroup(o, i) {
70
- const s = e(), r = `${t.inventoryBackendUrl}/${s}/closing-draft/${o}/group/reject`;
71
- return n.post(r, { remark: i });
72
- },
73
- async createQuickModeDraftWithItems(o) {
74
- const i = e(), s = `${t.inventoryBackendUrl}/${i}/closing-draft/quick-mode/new-with-items`;
75
- return n.post(s, o);
76
- },
77
- initializeStockSnapshot(o, i) {
78
- const s = e(), r = `${t.inventoryBackendUrl}/${s}/closing-draft/${encodeURIComponent(o)}/initialize-stock-snapshot`;
79
- return n.post(r, { effectiveAt: i });
80
- },
81
- async getRefreshBalanceStatus(o, i) {
82
- const s = e(), r = `${t.inventoryBackendUrl}/${s}/closing-draft/${o}/refresh-balance/status?closingDraftRevision=${encodeURIComponent(i)}`;
83
- return n.get(r);
84
- }
85
- };
86
- }), vo = { class: "fm-typo-en-body-lg-400" }, yo = { class: "fm-typo-en-body-lg-600" }, go = {
87
- key: 0,
88
- class: "flex flex-col"
89
- }, bo = {
90
- key: 0,
91
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-error mt-4"
92
- }, ho = { class: "flex gap-12 py-8 justify-end w-full" }, Ct = /* @__PURE__ */ De({
93
- __name: "ClosingDraftAction",
94
- props: {
95
- draft: {},
96
- action: {},
97
- onCancel: { type: Function },
98
- onFinished: { type: Function }
99
- },
100
- setup(t) {
101
- const n = t, e = Q(), o = Me(), i = ze(), s = Q(!1), r = Q(null), u = Q(!1), c = S(() => {
102
- switch (n.action) {
103
- case de.enum.approveDraft:
104
- return "Approve";
105
- case de.enum.rejectDraft:
106
- return "Reject";
107
- case de.enum.markAsFailed:
108
- return "Mark as Failed";
109
- }
110
- throw new Error(`Unknown action: ${n.action}`);
111
- }), b = S(() => {
112
- switch (n.action) {
113
- case de.enum.approveDraft:
114
- return "primary";
115
- case de.enum.rejectDraft:
116
- return "destructive";
117
- case de.enum.markAsFailed:
118
- return "destructive";
119
- }
120
- throw new Error(`Unknown action: ${n.action}`);
121
- });
122
- tn(() => {
123
- if (n.draft.effectiveAt)
124
- r.value = new Date(n.draft.effectiveAt);
125
- else {
126
- const R = new Date(n.draft.createdAt);
127
- R.setHours(23, 59, 59, 999), r.value = R;
128
- }
129
- u.value = !0;
130
- });
131
- const y = S({
132
- get() {
133
- return r.value === null ? "" : ft(r.value);
134
- },
135
- set(R) {
136
- if (R) {
137
- const F = /* @__PURE__ */ new Date(`${R} ${I.value}`);
138
- F.setSeconds(59, 999), r.value = F;
139
- } else
140
- r.value = null;
141
- }
142
- }), I = S({
143
- get() {
144
- return r.value === null ? "" : rn(r.value);
145
- },
146
- set(R) {
147
- if (R) {
148
- const F = /* @__PURE__ */ new Date(`${y.value} ${R}`);
149
- F.setSeconds(59, 999), r.value = F;
150
- } else
151
- r.value = null;
152
- }
153
- }), E = S(() => r.value ? r.value.getTime() > (/* @__PURE__ */ new Date()).getTime() : !1);
154
- async function U(R) {
155
- s.value = !0;
156
- try {
157
- R ? await o.runOperationV1({
158
- _id: n.draft._id,
159
- _rev: n.draft._rev ?? "",
160
- action: n.action,
161
- data: {
162
- effectiveAt: r.value ? r.value.toISOString() : null,
163
- remark: e.value
164
- }
165
- }).delayed(500) : await o.runOperation({
166
- _id: n.draft._id,
167
- _rev: n.draft._rev ?? "",
168
- action: n.action,
169
- data: {
170
- effectiveAt: r.value ? r.value.toISOString() : null,
171
- remark: e.value
172
- }
173
- }).delayed(500), i.open({
174
- title: "Success",
175
- message: "Action submitted",
176
- type: "success"
177
- }), n.onFinished();
178
- } catch (F) {
179
- i.open({
180
- title: "Something went wrong",
181
- message: (F == null ? void 0 : F.message) ?? "Unable to submit action. Please try again",
182
- type: "error"
183
- }), console.error("error on submit closing draft action", F);
184
- } finally {
185
- s.value = !1;
186
- }
187
- }
188
- return (R, F) => {
189
- const L = J("FmLabel"), K = J("FmDatePicker"), j = J("FmTimePicker"), z = J("FmTextField"), A = J("FmButton"), w = J("FmForm");
190
- return u.value ? (p(), ne(w, {
191
- key: 1,
192
- onValidationSuccess: U,
193
- class: "flex flex-col gap-32",
194
- disabled: s.value
195
- }, {
196
- default: te(() => [
197
- a("div", vo, [
198
- F[4] || (F[4] = fe(" You are about to ")),
199
- a("span", yo, N(c.value), 1),
200
- F[5] || (F[5] = fe(" this draft. Please provide a remark to justify this action. "))
201
- ]),
202
- R.action === f(de).enum.approveDraft ? (p(), C("div", go, [
203
- D(L, { class: "fm-typo-en-body-lg-600" }, {
204
- default: te(() => F[6] || (F[6] = [
205
- fe("Closing Date")
206
- ])),
207
- _: 1
208
- }),
209
- D(K, {
210
- modelValue: y.value,
211
- "onUpdate:modelValue": F[0] || (F[0] = (d) => y.value = d),
212
- max: f(ft)(/* @__PURE__ */ new Date())
213
- }, null, 8, ["modelValue", "max"]),
214
- D(L, { class: "fm-typo-en-body-lg-600" }, {
215
- default: te(() => F[7] || (F[7] = [
216
- fe("Closing Time")
217
- ])),
218
- _: 1
219
- }),
220
- D(j, {
221
- modelValue: I.value,
222
- "onUpdate:modelValue": F[1] || (F[1] = (d) => I.value = d)
223
- }, null, 8, ["modelValue"]),
224
- E.value ? (p(), C("div", bo, " Cannot select future date ")) : H("", !0)
225
- ])) : H("", !0),
226
- D(z, {
227
- modelValue: e.value,
228
- "onUpdate:modelValue": F[2] || (F[2] = (d) => e.value = d),
229
- label: "Remark",
230
- "label-mark": "required",
231
- rules: [f(ln)()]
232
- }, null, 8, ["modelValue", "rules"]),
233
- a("div", ho, [
234
- D(A, {
235
- label: "Cancel",
236
- variant: "tertiary",
237
- onClick: F[3] || (F[3] = (d) => R.onCancel())
238
- }),
239
- D(A, {
240
- label: c.value,
241
- type: "submit",
242
- variant: b.value,
243
- loading: s.value
244
- }, null, 8, ["label", "variant", "loading"])
245
- ])
246
- ]),
247
- _: 1
248
- }, 8, ["disabled"])) : (p(), C(re, { key: 0 }, [
249
- fe("Loading")
250
- ], 64));
251
- };
252
- }
253
- }), _o = qe(0);
254
- function bt(t) {
255
- const n = t.measurementsAmounts.groupBy((e) => e.measurement.id);
256
- return t.sku.unit.measurements.reduce((e, o) => {
257
- var r, u;
258
- const i = ((u = (r = n.get(o.id)) == null ? void 0 : r[0]) == null ? void 0 : u.amount) ?? _o, s = yt(o.conversion, i);
259
- return Qe(e, s);
260
- }, t.baseAmount);
261
- }
262
- const ko = qe(0), xo = qe(100);
263
- function wo(t, n, e, o, i, s, r, u) {
264
- var O, g, k, x, ee;
265
- const c = bt(t), b = o ?? c, y = cn(b, n), I = n.amount === 0 ? null : un(y, {
266
- ...n,
267
- amount: Math.abs(n.amount)
268
- }), E = I ? yt(I, xo) : null, U = ((O = t.sku.defaultCost) == null ? void 0 : O.costPerUnit) ?? { amount: 0, precision: 0 }, R = Number(oe.toFormatString({ value: U })), F = ((k = (g = t.sku.defaultCost) == null ? void 0 : g.measurement) == null ? void 0 : k.conversion) ?? {
269
- amount: 1,
270
- precision: 0
271
- }, L = Number(
272
- oe.toFormatString({ value: F })
273
- ), K = i ? Number(oe.toFormatString({ value: i })) : 0, j = Number(oe.toFormatString({ value: n })), z = Number(oe.toFormatString({ value: b })), A = z - j, w = A * R / L, d = z * R / L, h = j * R / L, B = {};
274
- return r && s && r.forEach((X) => {
275
- const T = { amount: 0, precision: 0 }, G = s[X];
276
- if (G) {
277
- const $ = Qe(T, G);
278
- B[`adjustment_${X}`] = Qn($);
279
- } else
280
- B[`adjustment_${X}`] = "0";
281
- }), {
282
- code: t.sku.code,
283
- name: t.sku.name,
284
- baseUnit: t.sku.unit.abbrev,
285
- costUnit: ((ee = (x = t.sku.defaultCost) == null ? void 0 : x.measurement) == null ? void 0 : ee.abbrev) ?? null,
286
- baseUnitAmount: Number(oe.toFormatString({ value: t.baseAmount })),
287
- ...e.reduce(
288
- (X, T, G) => {
289
- const $ = oe.toFormatString({ value: T.conversion }), Y = T.orphan ? " [invalid UOM]" : T.inactive ? " [NetSuite-inactive]" : "";
290
- return X[`measurementAbbrev${G}`] = `(${T.abbrev}) × ${$}${Y}`, X[`measurementAmount${G}`] = Number(oe.toFormatString({ value: T.amount })), X;
291
- },
292
- {}
293
- ),
294
- systemBalance: j,
295
- physicalBalance: z,
296
- adjustedAmount: Number(oe.toFormatString({ value: y })),
297
- adjustedDiffPercentage: E ? Number(
298
- oe.toFormatString({
299
- value: dn(E, 2)
300
- })
301
- ) : null,
302
- costPerUnit: R,
303
- opening: K,
304
- ...B,
305
- varianceQty: A,
306
- varianceInCost: w,
307
- stockTakeValue: d,
308
- systemValue: h,
309
- // Include custom attribute values
310
- ...(u ?? []).reduce(
311
- (X, T) => {
312
- var $;
313
- const G = ($ = t.sku.customAttributes) == null ? void 0 : $[T];
314
- return X[`customAttr_${T}`] = G != null ? String(G) : null, X;
315
- },
316
- {}
317
- )
318
- };
319
- }
320
- function Do(t) {
321
- let n = 0;
322
- for (const e of t.values())
323
- e.length > n && (n = e.length);
324
- return n;
325
- }
326
- function $o(t, n) {
327
- const e = /* @__PURE__ */ new Map();
328
- for (const o of t) {
329
- if (e.has(o.sku._id)) continue;
330
- const i = new Map(o.sku.unit.measurements.map((u) => [u.id, u])), s = new Map(
331
- o.measurementsAmounts.map((u) => [u.measurement.id, u.amount])
332
- ), r = [];
333
- for (const u of o.sku.unit.measurements) {
334
- const c = s.get(u.id);
335
- c && r.push({
336
- id: u.id,
337
- abbrev: u.abbrev,
338
- conversion: u.conversion,
339
- amount: c,
340
- inactive: It(u, n),
341
- orphan: !1
342
- });
343
- }
344
- for (const u of o.measurementsAmounts)
345
- i.has(u.measurement.id) || r.push({
346
- id: u.measurement.id,
347
- abbrev: u.measurement.abbrev,
348
- conversion: u.measurement.conversion,
349
- amount: u.amount,
350
- inactive: !1,
351
- orphan: !0
352
- });
353
- e.set(o.sku._id, r);
354
- }
355
- return e;
356
- }
357
- function Co(t, n = [], e = []) {
358
- const o = an(), i = o === "MYR" ? "RM" : o;
359
- return [
360
- {
361
- id: "code",
362
- name: "Code"
363
- },
364
- {
365
- id: "name",
366
- name: "Name"
367
- },
368
- {
369
- id: "baseUnit",
370
- name: "Base unit"
371
- },
372
- {
373
- id: "costPerUnit",
374
- name: "Cost per unit"
375
- },
376
- {
377
- id: "costUnit",
378
- name: "UOM"
379
- },
380
- {
381
- id: "opening",
382
- name: "Opening (B/F)"
383
- },
384
- // Dynamic adjustment type columns
385
- ...n.map((r) => ({
386
- id: `adjustment_${r}`,
387
- name: Ae(r)
388
- })),
389
- {
390
- id: "systemBalance",
391
- name: "System balance (Qty)"
392
- },
393
- {
394
- id: "physicalBalance",
395
- name: "Stock take (Qty)"
396
- },
397
- {
398
- id: "adjustedAmount",
399
- name: "Variance"
400
- },
401
- {
402
- id: "varianceInCost",
403
- name: `Variance (${i})`
404
- },
405
- {
406
- id: "adjustedDiffPercentage",
407
- name: "Variance (%)"
408
- },
409
- {
410
- id: "stockTakeValue",
411
- name: `Stock take value (${i})`
412
- },
413
- {
414
- id: "systemValue",
415
- name: `System value (${i})`
416
- },
417
- {
418
- id: "baseUnitAmount",
419
- name: "Base unit amount"
420
- },
421
- ...Array.from({ length: t }).flatMap((r, u) => [
422
- {
423
- id: `measurementAmount${u}`,
424
- name: `UOM amount ${u + 1}`
425
- },
426
- {
427
- id: `measurementAbbrev${u}`,
428
- name: `UOM ${u + 1}`
429
- }
430
- ]),
431
- // Dynamic custom attribute columns
432
- ...e.map((r) => ({
433
- id: `customAttr_${r}`,
434
- name: Ae(r)
435
- }))
436
- ];
437
- }
438
- function Ao(t, n, e, o = [], i) {
439
- var M, O, g, k, x, ee, X;
440
- const s = n.groupBy(
441
- (T) => T.id,
442
- (T) => T.balance
443
- ), r = e.groupBy(
444
- (T) => T.id,
445
- (T) => T.balance
446
- ), u = /* @__PURE__ */ new Map();
447
- if (t.opening)
448
- for (const T of t.opening)
449
- u.set(T.skuId, T.balance);
450
- const c = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Map();
451
- if (t.adjustmentSnapshot)
452
- for (const T of t.adjustmentSnapshot)
453
- T.adjustmentsByType && (Object.keys(T.adjustmentsByType).forEach((G) => c.add(G)), b.set(T.skuId, T.adjustmentsByType));
454
- const y = ["receive", "sales", "wastage"], I = [];
455
- y.forEach((T) => {
456
- c.has(T) && (I.push(T), c.delete(T));
457
- });
458
- const E = Array.from(c).sort(), U = [...I, ...E], R = [...t.items, ...t.negativeStockItems ?? []], L = nn().currentBusiness.value, K = $o(R, i), j = R.map((T) => {
459
- var ae, ce;
460
- const G = ((ae = s.get(T.sku._id)) == null ? void 0 : ae[0]) ?? ko, $ = K.get(T.sku._id) ?? [], Y = u.get(T.sku._id), me = b.get(T.sku._id);
461
- return wo(
462
- T,
463
- G,
464
- $,
465
- (ce = r.get(T.sku._id)) == null ? void 0 : ce[0],
466
- Y,
467
- me,
468
- U,
469
- o
470
- );
471
- }), z = Do(K), A = Co(z, U, o), w = [
472
- ["Business name:", L == null ? void 0 : L.name],
473
- ["Business ID:", L == null ? void 0 : L._id],
474
- ["Menu version", L == null ? void 0 : L.menuVersion],
475
- ["Created at", new Date(t.createdAt)],
476
- ["Created by", (M = t.createdBy) == null ? void 0 : M.name],
477
- ["Updated at", new Date(t.updatedAt)],
478
- ["Updated by", (O = t.updatedBy) == null ? void 0 : O.name],
479
- ["Recent action", t.approvedAt ? "Approve" : t.rejectionHistory ? "Reject" : ""],
480
- [
481
- "Action by",
482
- t.approvedAt ? (g = t.approvedBy) == null ? void 0 : g.name : t.rejectionHistory ? (x = (k = t.rejectionHistory[0]) == null ? void 0 : k.rejectedBy) == null ? void 0 : x.name : ""
483
- ],
484
- [
485
- "Action at",
486
- t.approvedAt ? new Date(t.approvedAt) : t.rejectionHistory ? new Date((ee = t.rejectionHistory[0]) == null ? void 0 : ee.rejectedAt) : ""
487
- ],
488
- [
489
- "Action remark",
490
- t.approvedAt ? t.approveRemark : t.rejectionHistory ? new Date((X = t.rejectionHistory[0]) == null ? void 0 : X.rejectRemark) : ""
491
- ],
492
- [],
493
- A.map((T) => T.name),
494
- ...j.map((T) => A.map((G) => T[G.id]))
495
- ], d = A.map((T) => `system:${T.id}`), h = Zn(w, d), B = `[${L == null ? void 0 : L.name}] closing draft (${qn(new Date(t.updatedAt))}).xlsx`;
496
- return Xn(h, B), B;
497
- }
498
- const So = { class: "flex flex-col" }, Fo = {
499
- key: 0,
500
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-error mt-4"
501
- }, Io = { class: "flex gap-12 py-8 justify-end w-full" }, Bo = /* @__PURE__ */ De({
502
- __name: "RefreshBalanceAction",
503
- props: {
504
- draft: {},
505
- onCancel: { type: Function },
506
- onFinished: { type: Function }
507
- },
508
- setup(t) {
509
- const n = t;
510
- gt();
511
- const e = Q(!1), o = Q(null), i = Q(!1);
512
- tn(() => {
513
- if (n.draft.effectiveAt)
514
- o.value = new Date(n.draft.effectiveAt);
515
- else {
516
- const b = new Date(n.draft.createdAt);
517
- b.setHours(23, 59, 59, 999), o.value = b;
518
- }
519
- i.value = !0;
520
- });
521
- const s = S({
522
- get() {
523
- return o.value === null ? "" : ft(o.value);
524
- },
525
- set(b) {
526
- if (b) {
527
- const y = /* @__PURE__ */ new Date(`${b} ${r.value}`);
528
- y.setSeconds(59, 999), o.value = y;
529
- } else
530
- o.value = null;
531
- }
532
- }), r = S({
533
- get() {
534
- return o.value === null ? "" : rn(o.value);
535
- },
536
- set(b) {
537
- if (b) {
538
- const y = /* @__PURE__ */ new Date(`${s.value} ${b}`);
539
- y.setSeconds(59, 999), o.value = y;
540
- } else
541
- o.value = null;
542
- }
543
- }), u = S(() => o.value ? o.value.getTime() > (/* @__PURE__ */ new Date()).getTime() : !1);
544
- async function c() {
545
- e.value = !0, n.onFinished(o.value.toISOString());
546
- }
547
- return (b, y) => {
548
- const I = J("FmLabel"), E = J("FmDatePicker"), U = J("FmTimePicker"), R = J("FmButton"), F = J("FmForm");
549
- return i.value ? (p(), ne(F, {
550
- key: 1,
551
- onValidationSuccess: c,
552
- class: "flex flex-col gap-32",
553
- disabled: e.value
554
- }, {
555
- default: te(() => [
556
- y[5] || (y[5] = a("div", { class: "fm-typo-en-body-lg-400" }, [
557
- a("p", null, [
558
- fe(" Performing "),
559
- a("span", { class: "fm-typo-en-body-lg-600" }, '"Refresh Balance"'),
560
- fe(" until closing effective date and time. ")
561
- ]),
562
- a("p", { class: "mt-2" }, [
563
- fe(" Please note that this action will "),
564
- a("b", null, "update"),
565
- fe(" the effective date and time. ")
566
- ])
567
- ], -1)),
568
- a("div", So, [
569
- D(I, { class: "fm-typo-en-body-lg-600" }, {
570
- default: te(() => y[3] || (y[3] = [
571
- fe("Closing Date")
572
- ])),
573
- _: 1
574
- }),
575
- D(E, {
576
- modelValue: s.value,
577
- "onUpdate:modelValue": y[0] || (y[0] = (L) => s.value = L),
578
- max: f(ft)(/* @__PURE__ */ new Date())
579
- }, null, 8, ["modelValue", "max"]),
580
- D(I, { class: "fm-typo-en-body-lg-600" }, {
581
- default: te(() => y[4] || (y[4] = [
582
- fe("Closing Time")
583
- ])),
584
- _: 1
585
- }),
586
- D(U, {
587
- modelValue: r.value,
588
- "onUpdate:modelValue": y[1] || (y[1] = (L) => r.value = L)
589
- }, null, 8, ["modelValue"]),
590
- u.value ? (p(), C("div", Fo, " Cannot select future date ")) : H("", !0)
591
- ]),
592
- a("div", Io, [
593
- D(R, {
594
- label: "Cancel",
595
- variant: "tertiary",
596
- onClick: y[2] || (y[2] = (L) => b.onCancel())
597
- }),
598
- D(R, {
599
- label: "Refresh balance",
600
- type: "submit",
601
- variant: "primary",
602
- loading: e.value,
603
- disabled: u.value
604
- }, null, 8, ["loading", "disabled"])
605
- ])
606
- ]),
607
- _: 1
608
- }, 8, ["disabled"])) : (p(), C(re, { key: 0 }, [
609
- fe("Loading")
610
- ], 64));
611
- };
612
- }
613
- }), pt = sn(
614
- "closingDraftActions",
615
- function() {
616
- const n = on(), e = ze(), o = gt(), i = Me(), s = no(), r = Bt(), u = Q(!1), c = Q();
617
- function b(A) {
618
- const w = {
619
- draft: A
620
- };
621
- c.value = w, u.value = !0;
622
- }
623
- async function y(A) {
624
- var d;
625
- if (A.status === _e.enum.COMPLETED) {
626
- const h = A.closingAdjustmentId;
627
- if (!h)
628
- return e.open({
629
- title: "Something went wrong",
630
- message: "Closing draft is completed but closing document cannot be found.",
631
- type: "error"
632
- }), console.error("Closing draft is completed but closing document cannot be found.", {
633
- draftId: A._id
634
- }), [];
635
- const B = await o.readAdjustmentById(h);
636
- return ((B == null ? void 0 : B.skus) ?? []).map((O) => ({
637
- id: O.sku._id,
638
- balance: O.fromBalance,
639
- costs: O.fromCostBalances
640
- }));
641
- } else
642
- return await s.readStockBalance(), ((d = s.stockBalance) == null ? void 0 : d.skus) ?? [];
643
- }
644
- async function I(A, w, d, h) {
645
- w || (e.open({
646
- title: "Exporting",
647
- message: "Fetching data..."
648
- }), w = await y(A)), Ao(
649
- A,
650
- w,
651
- d ?? [],
652
- h ?? [],
653
- r.value
654
- );
655
- }
656
- function E(A, w, d) {
657
- n.open({
658
- title: "Approve draft",
659
- contentComponent: Ct,
660
- contentComponentProps: {
661
- draft: A,
662
- action: de.enum.approveDraft,
663
- onFinished: () => {
664
- n.close(), w == null || w();
665
- },
666
- onCancel: () => {
667
- n.close();
668
- }
669
- }
670
- }).onClose(() => {
671
- d == null || d();
672
- });
673
- }
674
- function U(A, w) {
675
- n.open({
676
- title: "Reject draft",
677
- contentComponent: Ct,
678
- contentComponentProps: {
679
- draft: A,
680
- action: de.enum.rejectDraft,
681
- onFinished: () => {
682
- n.close(), w == null || w();
683
- },
684
- onCancel: () => n.close()
685
- }
686
- });
687
- }
688
- function R(A, w) {
689
- n.open({
690
- title: "Mark draft as failed",
691
- contentComponent: Ct,
692
- contentComponentProps: {
693
- draft: A,
694
- action: de.enum.markAsFailed,
695
- onFinished: () => {
696
- n.close(), w == null || w();
697
- },
698
- onCancel: () => n.close()
699
- }
700
- });
701
- }
702
- async function F(A, w) {
703
- await i.sync({
704
- _id: A._id,
705
- _rev: A._rev ?? "",
706
- action: de.enum.approveDraft,
707
- data: {
708
- remark: A.remark ?? ""
709
- }
710
- }).delayed(500), e.open({
711
- title: "Success",
712
- message: "Sync requested",
713
- type: "success"
714
- }), w == null || w();
715
- }
716
- function L() {
717
- u.value = !1;
718
- }
719
- async function K(A, w, d) {
720
- await n.open({
721
- title: "Refresh balance",
722
- contentComponent: Bo,
723
- contentComponentProps: {
724
- draft: A,
725
- onFinished: (h) => {
726
- n.close(), d == null || d(h);
727
- },
728
- onCancel: async () => {
729
- n.close(), w == null || w();
730
- }
731
- }
732
- });
733
- }
734
- async function j(A) {
735
- await n.open({
736
- title: "Invalidate closing draft cache",
737
- message: "It will invalidate opening and stock movement cache for this draft.",
738
- primaryActions: { text: "Proceed", close: !0 },
739
- secondaryActions: { text: "Cancel", close: !0 }
740
- }).onPrimary(async () => {
741
- await o.recalculation.scheduleInvalidateClosingDraftCache([A._id]), e.open({
742
- title: "Success",
743
- message: "Invalidate cache requested",
744
- type: "success"
745
- });
746
- });
747
- }
748
- async function z(A, w) {
749
- try {
750
- e.open({
751
- title: "Cloning",
752
- message: "Creating a copy of the draft..."
753
- }), await i.cloneDraft(A._id), e.open({
754
- title: "Success",
755
- message: "Draft cloned successfully",
756
- type: "success"
757
- }), w == null || w();
758
- } catch (d) {
759
- e.open({
760
- title: "Error",
761
- message: (d == null ? void 0 : d.message) || "Failed to clone draft",
762
- type: "error"
763
- });
764
- }
765
- }
766
- return {
767
- viewDraft: b,
768
- closeDraftDialog: L,
769
- approveDraft: E,
770
- rejectDraft: U,
771
- markAsFailed: R,
772
- syncDraft: F,
773
- exportDraft: I,
774
- refreshBalance: K,
775
- cloneDraft: z,
776
- viewClosingDraftShow: u,
777
- viewClosingDraftProps: c,
778
- invalidateDraftCache: j
779
- };
780
- }
781
- );
782
- function We(t) {
783
- switch (t) {
784
- case "DRAFT":
785
- return "fm-status-badge-draft";
786
- case "PROCESSING":
787
- return "fm-status-badge-processing";
788
- case "FAILED":
789
- return "fm-status-badge-cancel";
790
- case "COMPLETED":
791
- return "fm-status-badge-complete";
792
- }
793
- }
794
- function To(t) {
795
- return t.baseAmount.amount > 0 ? !0 : t.measurementsAmounts.some((n) => n.amount.amount !== 0);
796
- }
797
- function jo(t) {
798
- var i, s, r;
799
- const n = Number(oe.toFormatString({ value: bt(t) })), e = Number(
800
- oe.toFormatString({
801
- value: ((i = t.sku.defaultCost) == null ? void 0 : i.costPerUnit) ?? { amount: 0, precision: 0 }
802
- })
803
- ), o = Number(
804
- oe.toFormatString({
805
- value: ((r = (s = t.sku.defaultCost) == null ? void 0 : s.measurement) == null ? void 0 : r.conversion) ?? { amount: 1, precision: 0 }
806
- })
807
- );
808
- return n * e / o;
809
- }
810
- function Po(t, n) {
811
- return t.status === _e.enum.COMPLETED ? "COMPLETED" : (t.rejectionHistory ?? []).length > 0 ? "REJECTED" : n > 0 ? "IN_PROGRESS" : "PENDING";
812
- }
813
- function ht(t) {
814
- var n, e;
815
- return ((e = (n = t.usingTemplates) == null ? void 0 : n[0]) == null ? void 0 : e.name) || "Group";
816
- }
817
- function Ro(t) {
818
- var e;
819
- const n = (e = t.usingTemplates) == null ? void 0 : e[0];
820
- return n != null && n.ref ? n.ref : ht(t).replace(/[^a-z0-9]/gi, "").slice(0, 6).toUpperCase() || "GROUP";
821
- }
822
- function At(t) {
823
- var r, u, c;
824
- const n = [...t.items, ...t.negativeStockItems ?? []], e = n.filter(To).length, o = Po(t, e), i = n.reduce((b, y) => b + jo(y), 0), s = ((r = t.updatedBy) == null ? void 0 : r.name) || ((u = t.createdBy) == null ? void 0 : u.name) || void 0;
825
- return {
826
- id: t._id,
827
- name: ht(t),
828
- code: Ro(t),
829
- status: o,
830
- itemCount: n.length,
831
- totalAmount: i,
832
- countedCount: e,
833
- countedBy: e > 0 ? s : void 0,
834
- verifiedBy: (c = t.approvedBy) == null ? void 0 : c.name,
835
- updatedBy: s,
836
- updatedAt: t.updatedAt || t.createdAt
837
- };
838
- }
839
- function Mo(t) {
840
- return t.reduce(
841
- (n, e) => (n.totalItems += e.itemCount, n.totalAmount += e.totalAmount, e.status === "COMPLETED" ? n.completed++ : e.status === "IN_PROGRESS" ? n.inProgress++ : e.status === "REJECTED" ? n.rejected++ : n.pending++, n),
842
- {
843
- groupCount: t.length,
844
- totalItems: 0,
845
- totalAmount: 0,
846
- completed: 0,
847
- inProgress: 0,
848
- pending: 0,
849
- rejected: 0
850
- }
851
- );
852
- }
853
- const fn = sn(
854
- "closingDraftTable",
855
- function() {
856
- const { t: n } = Je(), e = nn(), o = pt(), i = Q(new Array()), s = Q(0), r = Q(!1), u = Oe(), c = Me(), b = Q({}), y = Q({});
857
- async function I() {
858
- if (i.value = [], !!u._currentLocation) {
859
- r.value = !0;
860
- try {
861
- const [g] = await Promise.all([c.readDrafts()]).delayed(1e3);
862
- i.value = U(g.reverse()), s.value++, L(i.value);
863
- } catch (g) {
864
- console.log("Something went wrong when fetching drafts:", g);
865
- } finally {
866
- r.value = !1;
867
- }
868
- }
869
- }
870
- async function E(g) {
871
- if (!i.value.find((k) => k._id) && u._currentLocation) {
872
- r.value = !0;
873
- try {
874
- const [k] = await Promise.all([
875
- c.getDraft(g),
876
- new Promise((x) => setTimeout(x, 1e3))
877
- ]);
878
- i.value = U([k]), s.value++, L(i.value);
879
- } catch (k) {
880
- console.log("Something went wrong when fetching drafts:", k);
881
- } finally {
882
- r.value = !1;
883
- }
884
- }
885
- }
886
- function U(g) {
887
- const k = so(
888
- g.filter((x) => !!x.closingId).map((x) => ({ closingId: x.closingId, draftCreatedAt: new Date(Re(x._id)) }))
889
- );
890
- return g.map((x) => ({
891
- ...x,
892
- closingIdDisplay: x.closingId ? k.get(x.closingId) ?? null : null
893
- }));
894
- }
895
- async function R(g) {
896
- const k = await Promise.all(
897
- g.map(async (x) => {
898
- try {
899
- const ee = await c.getClosingGroups(x._id);
900
- return [x._id, ee];
901
- } catch (ee) {
902
- return console.log(`Something went wrong when fetching groups for ${x._id}:`, ee), [x._id, []];
903
- }
904
- })
905
- );
906
- return Object.fromEntries(k);
907
- }
908
- function F(g, k) {
909
- y.value = { ...y.value, [g]: k }, b.value = { ...b.value, [g]: k.map(At) };
910
- }
911
- async function L(g) {
912
- const k = await R(g);
913
- y.value = k, b.value = Object.fromEntries(
914
- Object.entries(k).map(([x, ee]) => [x, ee.map(At)])
915
- ), s.value++;
916
- }
917
- async function K(g) {
918
- try {
919
- const k = await c.getClosingGroups(g);
920
- F(g, k), s.value++;
921
- } catch (k) {
922
- console.log(`Something went wrong when refreshing groups for ${g}:`, k);
923
- }
924
- }
925
- function j(g, k) {
926
- var x;
927
- return (x = y.value[g]) == null ? void 0 : x.find((ee) => ee._id === k);
928
- }
929
- function z(g) {
930
- i.value = i.value.map((k) => k._id === g._id ? {
931
- ...g,
932
- _rev: g._rev,
933
- closingIdDisplay: k.closingIdDisplay
934
- } : k), K(g._id), s.value++;
935
- }
936
- function A(g) {
937
- var ee, X;
938
- const k = g.items.length + (((ee = g.negativeStockItems) == null ? void 0 : ee.length) ?? 0), x = (g == null ? void 0 : g.approveRemark) ?? ((X = g == null ? void 0 : g.rejectionHistory) == null ? void 0 : X.computeFirst((T) => T.rejectRemark)) ?? g.remark ?? "";
939
- return { count: k, remark: x };
940
- }
941
- function w(g) {
942
- return b.value[g] ?? [];
943
- }
944
- function d(g, k = "") {
945
- return _(
946
- "span",
947
- {
948
- class: [
949
- "inline-flex items-center rounded-sm bg-fm-color-neutral-gray-100 px-8 py-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
950
- k
951
- ]
952
- },
953
- g
954
- );
955
- }
956
- function h(g) {
957
- if (!g.length) return null;
958
- const k = g.reduce(
959
- (x, ee) => (ee.status === "COMPLETED" ? x.completed++ : ee.status === "IN_PROGRESS" ? x.inProgress++ : ee.status === "REJECTED" ? x.rejected++ : x.pending++, x),
960
- { completed: 0, inProgress: 0, pending: 0, rejected: 0 }
961
- );
962
- return _("div", { class: "mt-8 flex flex-wrap gap-6" }, [
963
- d(`${g.length} groups`),
964
- k.completed ? d(`${k.completed} completed`, "text-fm-color-typo-success") : null,
965
- k.inProgress ? d(`${k.inProgress} in progress`, "text-fm-color-typo-warning") : null,
966
- k.pending ? d(`${k.pending} pending`) : null,
967
- k.rejected ? d(`${k.rejected} rejected`, "text-fm-color-typo-error") : null
968
- ]);
969
- }
970
- function B() {
971
- o.closeDraftDialog(), I();
972
- }
973
- function M(g, k) {
974
- switch (k = Yn(k), g) {
975
- case Ve.Details:
976
- return o.viewDraft(k);
977
- case Ve.Export:
978
- return o.exportDraft(k);
979
- case de.enum.approveDraft:
980
- return o.approveDraft(k, B);
981
- case de.enum.rejectDraft:
982
- return o.rejectDraft(k, B);
983
- case de.enum.markAsFailed:
984
- return o.markAsFailed(k, B);
985
- case Ve.Duplicate:
986
- return o.cloneDraft(k, B);
987
- }
988
- }
989
- return {
990
- columnDefs: [
991
- {
992
- id: "_id",
993
- accessorKey: "_id",
994
- header: () => n("inventory.closing.table.createdAt"),
995
- cell(g) {
996
- return ao(`${g.getValue()}`);
997
- },
998
- sortingFn: (g, k) => new Date(Re(g.original._id)).getTime() - new Date(Re(k.original._id)).getTime(),
999
- enableSorting: !0
1000
- },
1001
- {
1002
- id: "closingId",
1003
- accessorFn: (g) => g.closingIdDisplay,
1004
- size: 160,
1005
- header: () => n("inventory.closing.draft.table.id"),
1006
- cell(g) {
1007
- return g.getValue();
1008
- },
1009
- enableSorting: !0
1010
- },
1011
- {
1012
- accessorKey: "effectiveAt",
1013
- header: () => n("inventory.closing.draft.table.effectiveAt"),
1014
- cell(g) {
1015
- const k = g.row.original;
1016
- let x = g.getValue();
1017
- return x || (x = Re(k._id)), $e(x);
1018
- },
1019
- enableSorting: !0,
1020
- size: 230
1021
- },
1022
- {
1023
- id: "description",
1024
- accessorFn: (g) => {
1025
- const { count: k, remark: x } = A(g);
1026
- return `${k} ${x}`;
1027
- },
1028
- header: () => n("inventory.closing.draft.table.description"),
1029
- enableSorting: !0,
1030
- size: 350,
1031
- cell(g) {
1032
- const { count: k, remark: x } = A(g.row.original), ee = w(g.row.original._id), X = (T, G) => _("div", { class: "flex gap-4" }, [
1033
- _(
1034
- "span",
1035
- { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" },
1036
- `${T}:`
1037
- ),
1038
- _(
1039
- "span",
1040
- {
1041
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
1042
- style: "white-space: pre-wrap; word-break: break-word;"
1043
- },
1044
- `${G}`
1045
- )
1046
- ]);
1047
- return _("div", { class: "flex flex-col gap-2", style: "width: 300px;" }, [
1048
- X(n("inventory.closing.draft.table.items"), k),
1049
- x ? X(n("inventory.closing.draft.table.remark"), x) : null,
1050
- h(ee)
1051
- ]);
1052
- }
1053
- },
1054
- {
1055
- id: "status",
1056
- accessorFn: (g) => g.status,
1057
- header: () => n("inventory.closing.table.status"),
1058
- enableSorting: !1,
1059
- cell(g) {
1060
- var G;
1061
- const k = g.row.original, x = k.status, ee = new Date(k.updatedAt), X = (G = k == null ? void 0 : k.rejectionHistory) == null ? void 0 : G.computeFirst(($) => $.rejectedAt), T = X ? new Date(X) : null;
1062
- return x === "DRAFT" && T ? T.getTime() > ee.getTime() ? _(
1063
- "div",
1064
- {
1065
- class: "flex"
1066
- },
1067
- _(
1068
- "div",
1069
- {
1070
- class: ["fm-status-badge", We("FAILED")]
1071
- },
1072
- "Rejected"
1073
- )
1074
- ) : _(
1075
- "div",
1076
- {
1077
- class: "flex"
1078
- },
1079
- _(
1080
- "div",
1081
- {
1082
- class: ["fm-status-badge", We("PROCESSING")]
1083
- },
1084
- "Updated"
1085
- )
1086
- ) : _(
1087
- "div",
1088
- {
1089
- class: "flex"
1090
- },
1091
- _(
1092
- "div",
1093
- {
1094
- class: ["fm-status-badge", We(x)]
1095
- },
1096
- Ae(x)
1097
- )
1098
- );
1099
- }
1100
- },
1101
- {
1102
- id: "updatedAt",
1103
- accessorFn: (g) => g.updatedAt,
1104
- header: () => n("inventory.closing.draft.table.lastUpdate"),
1105
- enableSorting: !0,
1106
- size: 200,
1107
- cell(g) {
1108
- var x;
1109
- const k = g.row.original;
1110
- return _("div", { class: "flex flex-col" }, [
1111
- _(
1112
- "div",
1113
- { class: "fm-typo-en-body-md-600 text-fm-color-typo-primary" },
1114
- ((x = k.updatedBy) == null ? void 0 : x.name) ?? ""
1115
- ),
1116
- _(
1117
- "div",
1118
- { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
1119
- $e(k.updatedAt)
1120
- )
1121
- ]);
1122
- }
1123
- },
1124
- {
1125
- id: "action",
1126
- cell(g) {
1127
- var G;
1128
- const k = g.row.original, x = ((G = e.sessionUser.value) == null ? void 0 : G.role.isAdmin) ?? !1, ee = [
1129
- Xt[Ve.Details],
1130
- Xt[Ve.Export]
1131
- ], X = [
1132
- {
1133
- translationKey: "inventory.closing.draft.approveDraft",
1134
- color: "text-fm-color-typo-primary",
1135
- value: de.enum.approveDraft
1136
- },
1137
- {
1138
- translationKey: "inventory.closing.draft.rejectDraft",
1139
- color: "text-fm-color-typo-error",
1140
- value: de.enum.rejectDraft
1141
- },
1142
- {
1143
- translationKey: "inventory.closing.draft.markAsFailed",
1144
- color: "text-fm-color-typo-error",
1145
- value: de.enum.markAsFailed
1146
- }
1147
- ], T = x && k.status !== _e.enum.DRAFT ? [
1148
- {
1149
- translationKey: "inventory.closing.draft.cloneDraft",
1150
- color: "text-fm-color-typo-primary",
1151
- value: Ve.Duplicate
1152
- }
1153
- ] : [];
1154
- return oo(
1155
- [
1156
- ...ee,
1157
- ...k.status === _e.enum.DRAFT ? X : []
1158
- ],
1159
- ($) => M($, k),
1160
- T
1161
- );
1162
- },
1163
- enableSorting: !1,
1164
- size: 40,
1165
- meta: {
1166
- cellClass: "",
1167
- headerClass: ""
1168
- }
1169
- }
1170
- ],
1171
- drafts: i,
1172
- loading: r,
1173
- tableKey: s,
1174
- groupsByDraftId: b,
1175
- getRawGroup: j,
1176
- refreshDraftGroups: K,
1177
- fetchDrafts: I,
1178
- loadDraft: E,
1179
- updateDraftRef: z
1180
- };
1181
- }
1182
- );
1183
- function Uo(t) {
1184
- const n = /* @__PURE__ */ new Map();
1185
- for (const e of t)
1186
- for (const o of e) {
1187
- const i = n.get(o.sku._id);
1188
- if (!i) {
1189
- n.set(o.sku._id, {
1190
- ...o,
1191
- baseAmount: { ...o.baseAmount },
1192
- measurementsAmounts: o.measurementsAmounts.map((s) => ({
1193
- ...s,
1194
- amount: { ...s.amount }
1195
- }))
1196
- });
1197
- continue;
1198
- }
1199
- i.baseAmount = Qe(i.baseAmount, o.baseAmount);
1200
- for (const s of o.measurementsAmounts) {
1201
- const r = i.measurementsAmounts.findIndex(
1202
- (u) => u.measurement.id === s.measurement.id
1203
- );
1204
- r > -1 ? i.measurementsAmounts[r].amount = Qe(
1205
- i.measurementsAmounts[r].amount,
1206
- s.amount
1207
- ) : i.measurementsAmounts.push({ ...s, amount: { ...s.amount } });
1208
- }
1209
- }
1210
- return [...n.values()];
1211
- }
1212
- const No = { class: "fm-typo-en-heading-lg-600" }, Vo = { class: "py-4" }, Eo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, Lo = { key: 0 }, zo = { class: "flex flex-col gap-1 max-h-200 overflow-auto w-full mb-4" }, Oo = {
1213
- key: 0,
1214
- class: "text-fm-color-system-success-300"
1215
- }, Go = {
1216
- key: 1,
1217
- class: "text-fm-color-system-error-300"
1218
- }, Ho = { class: "fm-typo-en-body-md-400" }, Yo = { class: "mt-4 flex gap-4" }, Ko = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, Wo = { key: 0 }, qo = { class: "mt-4 flex gap-4" }, Qo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, Jo = { key: 0 }, Zo = {
1219
- key: 0,
1220
- class: "mb-4"
1221
- }, Xo = { class: "flex flex-col gap-1 max-h-200 overflow-auto w-full" }, ea = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ta = {
1222
- key: 0,
1223
- class: "text-fm-color-system-success-300 mr-1"
1224
- }, na = {
1225
- key: 1,
1226
- class: "text-fm-color-system-error-300 mr-1"
1227
- }, oa = { class: "fm-typo-en-body-md-400" }, aa = { class: "mt-4 flex gap-4" }, sa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, ra = {
1228
- key: 0,
1229
- class: "flex gap-4"
1230
- }, Ke = 1, Ee = 2, Le = 3, Pe = 4, la = /* @__PURE__ */ De({
1231
- __name: "ClosingDraftApprovalDialog",
1232
- props: {
1233
- show: { type: Boolean },
1234
- refreshing: { type: Boolean },
1235
- approving: { type: Boolean },
1236
- draft: {},
1237
- groups: {}
1238
- },
1239
- emits: ["update:show", "refresh", "approve"],
1240
- setup(t, { emit: n }) {
1241
- const { FmStepper: e, FmStep: o, FmDialog: i, FmButton: s } = ye, { t: r } = lo(), u = Ft(), c = t, b = n, y = S(
1242
- () => {
1243
- var $, Y;
1244
- return (($ = c.draft) == null ? void 0 : $.stockSnapshot) && ((Y = c.draft) == null ? void 0 : Y.stockSnapshot) !== void 0;
1245
- }
1246
- ), I = S(() => {
1247
- var me, ae, ce;
1248
- const $ = ((me = c.draft) == null ? void 0 : me.items.map((pe) => ({
1249
- id: pe.sku._id,
1250
- code: pe.sku.code,
1251
- name: pe.sku.name
1252
- }))) ?? [], Y = ((ce = (ae = c.draft) == null ? void 0 : ae.negativeStockItems) == null ? void 0 : ce.map((pe) => ({
1253
- id: pe.sku._id,
1254
- code: pe.sku.code,
1255
- name: pe.sku.name
1256
- }))) ?? [];
1257
- return [...$, ...Y].reduce(
1258
- (pe, Te) => (pe[Te.id] = Te, pe),
1259
- {}
1260
- );
1261
- }), E = S(
1262
- () => {
1263
- var $, Y, me;
1264
- return (((me = (Y = ($ = c.draft) == null ? void 0 : $.stockSnapshot) == null ? void 0 : Y.filter((ae) => ae.balance.amount < 0)) == null ? void 0 : me.map((ae) => {
1265
- const ce = u.skuById[ae.id];
1266
- return ce ? {
1267
- id: ce._id,
1268
- code: ce.code,
1269
- name: ce.name
1270
- } : null;
1271
- })) ?? []).filter((ae) => ae !== null);
1272
- }
1273
- ), U = S(() => {
1274
- var $;
1275
- return y.value ? (($ = E.value) == null ? void 0 : $.filter((Y) => !I.value[Y.id]).map((Y) => Y.id)) ?? [] : [];
1276
- }), R = S({
1277
- get: () => c.show,
1278
- set: ($) => b("update:show", $)
1279
- }), F = S(() => {
1280
- var $;
1281
- return ((($ = c.groups) == null ? void 0 : $.length) ?? 0) > 0;
1282
- }), L = S(
1283
- () => {
1284
- var $;
1285
- return (($ = c.groups) == null ? void 0 : $.filter((Y) => Y.status !== _e.enum.COMPLETED)) ?? [];
1286
- }
1287
- ), K = S(() => L.value.length === 0), j = Q(Ke), z = () => j.value > Ke, A = () => j.value > Ee, w = () => j.value > Le, d = () => !1;
1288
- function h($) {
1289
- return $ === Ke ? !F.value : $ === Ee ? y.value : $ === Le ? U.value.length == 0 : !1;
1290
- }
1291
- const B = S(() => !y.value || U.value.length > 0 || F.value && !K.value);
1292
- function M() {
1293
- let $ = 1;
1294
- for (; $ < Pe && h($); ) $++;
1295
- return $;
1296
- }
1297
- const O = S(() => j.value > M());
1298
- function g($) {
1299
- let Y = $ + 1;
1300
- for (; Y <= Pe && h(Y); ) Y++;
1301
- return Y > Pe ? Pe : Y;
1302
- }
1303
- function k($) {
1304
- let Y = $ - 1;
1305
- for (; Y >= 1 && h(Y); ) Y--;
1306
- const me = M();
1307
- return Y < me ? me : Y;
1308
- }
1309
- function x() {
1310
- return M();
1311
- }
1312
- Be(
1313
- () => c.show,
1314
- ($) => {
1315
- $ && (j.value = x());
1316
- }
1317
- ), Be(
1318
- () => y.value,
1319
- ($) => {
1320
- $ && j.value === Ee && (j.value = g(Ee));
1321
- }
1322
- ), Be(
1323
- () => U.value.length,
1324
- ($) => {
1325
- $ === 0 && j.value === Le && (j.value = g(Le));
1326
- }
1327
- );
1328
- function ee() {
1329
- b("refresh");
1330
- }
1331
- function X() {
1332
- j.value < Pe && (j.value = g(j.value));
1333
- }
1334
- function T() {
1335
- j.value > 1 && (j.value = k(j.value));
1336
- }
1337
- function G() {
1338
- b("approve");
1339
- }
1340
- return ($, Y) => {
1341
- const me = J("FmIcon");
1342
- return p(), ne(f(i), {
1343
- modelValue: R.value,
1344
- "onUpdate:modelValue": Y[1] || (Y[1] = (ae) => R.value = ae),
1345
- "max-width": 600
1346
- }, {
1347
- "dialog-header": te(() => [
1348
- a("div", No, N(f(r)("inventory.closing.approval.title")), 1)
1349
- ]),
1350
- default: te(() => [
1351
- a("div", Vo, [
1352
- D(f(e), {
1353
- modelValue: j.value,
1354
- "onUpdate:modelValue": Y[0] || (Y[0] = (ae) => j.value = ae),
1355
- orientation: "vertical"
1356
- }, {
1357
- default: te(() => [
1358
- F.value ? (p(), ne(f(o), {
1359
- key: 0,
1360
- value: Ke,
1361
- title: f(r)("inventory.closing.approval.step.groups.title"),
1362
- complete: z
1363
- }, {
1364
- default: te(() => [
1365
- a("div", Eo, N(K.value ? f(r)("inventory.closing.approval.step.groups.completedMessage") : f(r)("inventory.closing.approval.step.groups.pendingMessage")), 1),
1366
- j.value === Ke ? (p(), C("div", Lo, [
1367
- a("div", zo, [
1368
- (p(!0), C(re, null, ge($.groups ?? [], (ae) => (p(), C("div", {
1369
- key: ae._id,
1370
- class: "flex gap-8 items-center"
1371
- }, [
1372
- ae.status === f(_e).enum.COMPLETED ? (p(), C("span", Oo, [
1373
- D(me, {
1374
- name: "check_circle",
1375
- size: "sm"
1376
- })
1377
- ])) : (p(), C("span", Go, [
1378
- D(me, {
1379
- name: "error",
1380
- size: "sm"
1381
- })
1382
- ])),
1383
- a("div", Ho, N(f(ht)(ae)), 1)
1384
- ]))), 128))
1385
- ]),
1386
- a("div", Yo, [
1387
- D(f(s), {
1388
- label: f(r)("inventory.common.continue"),
1389
- disabled: !K.value,
1390
- onClick: X
1391
- }, null, 8, ["label", "disabled"])
1392
- ])
1393
- ])) : H("", !0)
1394
- ]),
1395
- _: 1
1396
- }, 8, ["title"])) : H("", !0),
1397
- D(f(o), {
1398
- value: Ee,
1399
- title: f(r)("inventory.closing.approval.step.generateReport.title"),
1400
- disabled: () => F.value && !K.value,
1401
- complete: A
1402
- }, {
1403
- default: te(() => [
1404
- a("div", Ko, N(f(r)("inventory.closing.approval.step.generateReport.description")), 1),
1405
- j.value === Ee ? (p(), C("div", Wo, [
1406
- D(f(s), {
1407
- label: f(r)("inventory.stock.stock_balance.refreshBalance"),
1408
- "prepend-icon": "refresh",
1409
- variant: "secondary",
1410
- loading: $.refreshing,
1411
- disabled: $.refreshing,
1412
- onClick: ee
1413
- }, null, 8, ["label", "loading", "disabled"]),
1414
- a("div", qo, [
1415
- O.value ? (p(), ne(f(s), {
1416
- key: 0,
1417
- label: f(r)("inventory.common.back"),
1418
- variant: "secondary",
1419
- onClick: T
1420
- }, null, 8, ["label"])) : H("", !0),
1421
- D(f(s), {
1422
- label: f(r)("inventory.common.continue"),
1423
- disabled: !y.value,
1424
- onClick: X
1425
- }, null, 8, ["label", "disabled"])
1426
- ])
1427
- ])) : H("", !0)
1428
- ]),
1429
- _: 1
1430
- }, 8, ["title", "disabled"]),
1431
- D(f(o), {
1432
- value: Le,
1433
- title: f(r)("inventory.closing.approval.step.negativeItems.title"),
1434
- disabled: () => !y.value,
1435
- complete: w
1436
- }, {
1437
- default: te(() => [
1438
- a("div", Qo, N(E.value.length > 0 ? `${f(r)("inventory.closing.approval.step.negativeItems.resolveMessage")} [${f(r)("inventory.closing.approval.step.negativeItems.itemsHeader")} (${U.value.length})]` : f(r)("inventory.closing.approval.step.negativeItems.noItemsMessage")), 1),
1439
- j.value === Le ? (p(), C("div", Jo, [
1440
- E.value.length > 0 ? (p(), C("div", Zo, [
1441
- Y[2] || (Y[2] = a("div", { class: "fm-typo-en-body-md-600 mb-2" }, null, -1)),
1442
- a("div", Xo, [
1443
- (p(!0), C(re, null, ge(E.value, (ae) => (p(), C("div", {
1444
- key: ae.id,
1445
- class: "flex gap-8"
1446
- }, [
1447
- a("div", ea, [
1448
- I.value[ae.id] ? (p(), C("span", ta, [
1449
- D(me, {
1450
- name: "check_circle",
1451
- size: "sm"
1452
- })
1453
- ])) : (p(), C("span", na, [
1454
- D(me, {
1455
- name: "error",
1456
- size: "sm"
1457
- })
1458
- ])),
1459
- fe(" " + N(ae.code), 1)
1460
- ]),
1461
- a("div", oa, N(ae.name), 1)
1462
- ]))), 128))
1463
- ])
1464
- ])) : H("", !0),
1465
- a("div", aa, [
1466
- O.value ? (p(), ne(f(s), {
1467
- key: 0,
1468
- label: f(r)("inventory.common.back"),
1469
- variant: "secondary",
1470
- onClick: T
1471
- }, null, 8, ["label"])) : H("", !0),
1472
- D(f(s), {
1473
- label: f(r)("inventory.common.continue"),
1474
- disabled: B.value,
1475
- onClick: X
1476
- }, null, 8, ["label", "disabled"])
1477
- ])
1478
- ])) : H("", !0)
1479
- ]),
1480
- _: 1
1481
- }, 8, ["title", "disabled"]),
1482
- D(f(o), {
1483
- value: Pe,
1484
- title: f(r)("inventory.closing.approval.step.approval.title"),
1485
- disabled: () => B.value,
1486
- complete: d
1487
- }, {
1488
- default: te(() => [
1489
- a("div", sa, N(f(r)("inventory.closing.approval.step.approval.warning")), 1),
1490
- j.value === Pe ? (p(), C("div", ra, [
1491
- O.value ? (p(), ne(f(s), {
1492
- key: 0,
1493
- label: f(r)("inventory.common.back"),
1494
- variant: "secondary",
1495
- onClick: T
1496
- }, null, 8, ["label"])) : H("", !0),
1497
- D(f(s), {
1498
- label: f(r)("inventory.common.approve"),
1499
- variant: "destructive",
1500
- disabled: B.value,
1501
- loading: $.approving,
1502
- onClick: G
1503
- }, null, 8, ["label", "disabled", "loading"])
1504
- ])) : H("", !0)
1505
- ]),
1506
- _: 1
1507
- }, 8, ["title", "disabled"])
1508
- ]),
1509
- _: 1
1510
- }, 8, ["modelValue"])
1511
- ])
1512
- ]),
1513
- _: 1
1514
- }, 8, ["modelValue"]);
1515
- };
1516
- }
1517
- });
1518
- function ia(t) {
1519
- const n = Me(), e = co(), o = ze(), { t: i } = Je(), s = Q(!1), r = Q(null);
1520
- let u = !1, c = null, b = !1, y = !1;
1521
- function I() {
1522
- L();
1523
- const z = t.closingDraftId.value, A = t.currentRev.value;
1524
- if (!z || !A)
1525
- return;
1526
- u = !1;
1527
- const w = {
1528
- type: "closing-draft",
1529
- params: {
1530
- draftId: z,
1531
- locationId: n.getDbName(),
1532
- closingDraftRevision: A
1533
- }
1534
- }, { unsubscribe: d, initialState: h } = e.subscribe(w, U);
1535
- c = d, h.then((B) => {
1536
- B != null && B.initialState && U(B.initialState);
1537
- }).catch((B) => {
1538
- console.error("Failed to fetch initial state", B);
1539
- });
1540
- }
1541
- function E() {
1542
- y = !0, I();
1543
- }
1544
- async function U(z) {
1545
- var w;
1546
- if (u || !z) {
1547
- r.value = z, s.value = !1;
1548
- return;
1549
- }
1550
- if (z.closingDraftId && z.closingDraftId !== t.closingDraftId.value)
1551
- return;
1552
- if (r.value = z, z.message === "processing" || !z.completedAt && !z.message) {
1553
- b = !0, s.value = !0;
1554
- return;
1555
- }
1556
- if (z.message === "completed" || z.completedAt) {
1557
- if (!b) {
1558
- s.value = !1;
1559
- return;
1560
- }
1561
- b = !1, await R();
1562
- return;
1563
- }
1564
- const A = b;
1565
- b = !1, s.value = !1, A && (console.log("Closing draft balance refresh error:", z), o.open({
1566
- title: i("inventory.common.refreshFailed"),
1567
- message: i("inventory.stock.stock_balance.refreshBalanceError"),
1568
- type: "error"
1569
- }), (w = t.onError) == null || w.call(t, z.message ?? "Unknown error"));
1570
- }
1571
- async function R() {
1572
- const z = t.closingDraftId.value;
1573
- if (!z) {
1574
- s.value = !1;
1575
- return;
1576
- }
1577
- try {
1578
- const A = await n.getDraft(z);
1579
- s.value = !1, t.onCompleted(A), o.open({
1580
- title: "Balance refreshed",
1581
- message: "Stock balance has been recalculated.",
1582
- type: "success"
1583
- });
1584
- } catch {
1585
- s.value = !1, o.open({
1586
- title: "Refresh completed",
1587
- message: "Balance was refreshed but failed to load updated data. Please reload.",
1588
- type: "warning"
1589
- });
1590
- }
1591
- }
1592
- async function F(z) {
1593
- if (!(!t.closingDraftId.value || s.value || b)) {
1594
- s.value = !0, b = !0, r.value = {
1595
- requestId: "",
1596
- closingDraftId: t.closingDraftId.value,
1597
- closingDraftRevision: t.currentRev.value ?? "",
1598
- message: "processing",
1599
- startedAt: (/* @__PURE__ */ new Date()).toISOString()
1600
- };
1601
- try {
1602
- await n.initializeStockSnapshot(t.closingDraftId.value, z);
1603
- } catch (A) {
1604
- b = !1, s.value = !1, o.open({
1605
- title: i("inventory.common.refreshFailed"),
1606
- message: i("inventory.stock.stock_balance.refreshBalanceError"),
1607
- type: "error"
1608
- }), console.error("error starting refresh", A);
1609
- }
1610
- }
1611
- }
1612
- function L() {
1613
- u = !1, c && (c(), c = null);
1614
- }
1615
- function K() {
1616
- L(), u = !0, s.value = !1, b = !1, r.value = null;
1617
- }
1618
- function j() {
1619
- y = !1, K();
1620
- }
1621
- return Be(
1622
- [t.closingDraftId, t.currentRev],
1623
- ([z, A], [w, d]) => {
1624
- y && (z === w && A === d || I());
1625
- }
1626
- ), Un(() => {
1627
- j();
1628
- }), {
1629
- refreshing: s,
1630
- refreshStatus: r,
1631
- startListening: E,
1632
- startRefresh: F,
1633
- cleanup: j
1634
- };
1635
- }
1636
- function ca(t) {
1637
- switch (t) {
1638
- case "COMPLETED":
1639
- return { label: "Completed", className: "fm-status-badge-complete" };
1640
- case "IN_PROGRESS":
1641
- return { label: "In Progress", className: "fm-status-badge-processing" };
1642
- case "REJECTED":
1643
- return { label: "Rejected", className: "fm-status-badge-error" };
1644
- case "PENDING":
1645
- return { label: "Pending", className: "fm-status-badge-draft" };
1646
- }
1647
- }
1648
- const ua = { class: "flex items-start justify-between gap-8" }, da = { class: "flex items-center gap-8 min-w-0" }, ma = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary truncate" }, fa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary" }, pa = { class: "fm-typo-en-body-md-600" }, va = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-tertiary" }, ya = /* @__PURE__ */ De({
1649
- __name: "ClosingGroupCard",
1650
- props: {
1651
- group: {}
1652
- },
1653
- emits: ["select"],
1654
- setup(t, { emit: n }) {
1655
- const e = t, o = n, i = S(() => ca(e.group.status)), s = S(
1656
- () => `RM ${e.group.totalAmount.toLocaleString("en-MY", {
1657
- minimumFractionDigits: 2,
1658
- maximumFractionDigits: 2
1659
- })}`
1660
- ), r = S(() => {
1661
- const u = e.group.updatedBy ?? "—", c = e.group.updatedAt ? $e(e.group.updatedAt) : "—";
1662
- return `Last updated by ${u} · ${c}`;
1663
- });
1664
- return (u, c) => (p(), C("div", {
1665
- class: "flex flex-col gap-8 rounded-lg border border-fm-color-neutral-gray-200 bg-white p-16 cursor-pointer hover:border-fm-color-primary",
1666
- onClick: c[0] || (c[0] = Nn((b) => o("select", u.group.id), ["stop"]))
1667
- }, [
1668
- a("div", ua, [
1669
- a("div", da, [
1670
- u.group.color ? (p(), C("span", {
1671
- key: 0,
1672
- class: "w-8 h-8 rounded-full shrink-0",
1673
- style: mt({ backgroundColor: u.group.color })
1674
- }, null, 4)) : H("", !0),
1675
- a("span", ma, N(u.group.name), 1)
1676
- ]),
1677
- a("div", {
1678
- class: he(["fm-status-badge shrink-0", i.value.className])
1679
- }, N(i.value.label), 3)
1680
- ]),
1681
- a("div", fa, [
1682
- a("span", pa, N(u.group.itemCount), 1),
1683
- fe(" items · " + N(s.value), 1)
1684
- ]),
1685
- c[1] || (c[1] = a("div", { class: "border-t border-dashed border-fm-color-neutral-gray-200" }, null, -1)),
1686
- a("div", va, N(r.value), 1)
1687
- ]));
1688
- }
1689
- }), ga = {
1690
- key: 0,
1691
- class: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-16"
1692
- }, ba = {
1693
- key: 1,
1694
- class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1695
- }, ha = /* @__PURE__ */ De({
1696
- __name: "ClosingGroupGrid",
1697
- props: {
1698
- groups: {}
1699
- },
1700
- emits: ["select"],
1701
- setup(t, { emit: n }) {
1702
- const e = n;
1703
- return (o, i) => o.groups.length ? (p(), C("div", ga, [
1704
- (p(!0), C(re, null, ge(o.groups, (s) => (p(), ne(ya, {
1705
- key: s.id,
1706
- group: s,
1707
- onSelect: i[0] || (i[0] = (r) => e("select", r))
1708
- }, null, 8, ["group"]))), 128))
1709
- ])) : (p(), C("div", ba, "No closing groups"));
1710
- }
1711
- });
1712
- function pn(t, n) {
1713
- const e = t.sku, o = [], i = Number(oe.toFormatString({ value: t.baseAmount }));
1714
- i && o.push({
1715
- label: "Base",
1716
- amount: i,
1717
- abbrev: e.unit.abbrev,
1718
- subtotal: i,
1719
- inactive: !1,
1720
- orphan: !1,
1721
- counted: !0
1722
- });
1723
- const s = new Map(
1724
- t.measurementsAmounts.map((c) => [c.measurement.id, c.amount])
1725
- ), r = new Set(e.unit.measurements.map((c) => c.id)), u = (c, b, y, I, E) => {
1726
- const U = Number(oe.toFormatString({ value: y }));
1727
- if (!U) return;
1728
- const R = oe.toFormatString({ value: b }), F = Number(
1729
- oe.toFormatString({
1730
- value: yt(y, b)
1731
- })
1732
- );
1733
- o.push({
1734
- label: E ? `${U} ${c}` : `${U} ${c} × ${R} ${e.unit.abbrev}`,
1735
- amount: U,
1736
- abbrev: c,
1737
- subtotal: F,
1738
- inactive: I,
1739
- orphan: E,
1740
- counted: !E
1741
- });
1742
- };
1743
- for (const c of e.unit.measurements) {
1744
- const b = s.get(c.id);
1745
- b && u(c.abbrev, c.conversion, b, It(c, n), !1);
1746
- }
1747
- for (const c of t.measurementsAmounts)
1748
- r.has(c.measurement.id) || u(c.measurement.abbrev, c.measurement.conversion, c.amount, !1, !0);
1749
- return o;
1750
- }
1751
- const ut = (t) => ie(t, { minPrecision: 0, maxPrecision: 3 });
1752
- function _a(t, n) {
1753
- return n ? "text-fm-color-system-error-300" : t ? "text-purple-500" : "";
1754
- }
1755
- function ka(t, n) {
1756
- return n ? _(ye.FmIcon, { name: "warning", size: "sm", color: "system-error-300" }) : t ? _(ye.FmIcon, { name: "rule", size: "sm" }) : null;
1757
- }
1758
- function vn(t, n, e) {
1759
- return _(
1760
- "div",
1761
- {
1762
- class: "p-12 flex flex-col gap-4 fm-typo-en-body-md-400 min-w-[280px] max-w-[420px]"
1763
- },
1764
- [
1765
- _("div", { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary mb-4" }, "Breakdown"),
1766
- ...t.map(
1767
- (o) => _("div", { class: "flex justify-between gap-12" }, [
1768
- _(
1769
- "div",
1770
- { class: ["flex items-center gap-4", _a(o.inactive, o.orphan)] },
1771
- [ka(o.inactive, o.orphan), _("span", o.label)]
1772
- ),
1773
- _(
1774
- "div",
1775
- { class: o.counted ? "" : "line-through text-fm-color-typo-tertiary" },
1776
- o.orphan ? `${ut(o.amount)} ${o.abbrev} (no valid conversion)` : o.counted ? `${ut(o.subtotal)} ${e}` : `${ut(o.subtotal)} ${e} (ignored)`
1777
- )
1778
- ])
1779
- ),
1780
- _("hr", { class: "border-fm-color-typo-secondary my-4" }),
1781
- _("div", { class: "flex justify-between fm-typo-en-body-lg-600" }, [
1782
- _("span", "Total"),
1783
- _("span", `${ut(n)} ${e}`)
1784
- ])
1785
- ]
1786
- );
1787
- }
1788
- function Tt(t, n) {
1789
- const e = t.sku, o = Number(oe.toFormatString({ value: t.baseAmount })), i = new Map(
1790
- t.measurementsAmounts.map((c) => [c.measurement.id, c.amount])
1791
- ), s = new Set(e.unit.measurements.map((c) => c.id)), r = [], u = (c, b, y, I, E) => {
1792
- const U = Number(oe.toFormatString({ value: y })), R = oe.toFormatString({ value: b });
1793
- r.push({
1794
- abbrev: `(${c}) × ${R}`,
1795
- amount: U,
1796
- variant: E ? "orphan" : I ? "inactive" : "normal"
1797
- });
1798
- };
1799
- for (const c of e.unit.measurements) {
1800
- const b = i.get(c.id);
1801
- b && u(c.abbrev, c.conversion, b, It(c, n), !1);
1802
- }
1803
- for (const c of t.measurementsAmounts)
1804
- s.has(c.measurement.id) || u(c.measurement.abbrev, c.measurement.conversion, c.amount, !1, !0);
1805
- return { baseUnitAmount: o, measurements: r };
1806
- }
1807
- function en(t, n, e) {
1808
- const o = t.sku, { baseUnitAmount: i, measurements: s } = Tt(t, e);
1809
- return {
1810
- id: o._id,
1811
- code: o.code,
1812
- name: o.name,
1813
- baseUnit: o.unit.abbrev,
1814
- baseUnitAmount: i,
1815
- isTemplateItem: n,
1816
- measurements: s,
1817
- physicalBalance: Number(oe.toFormatString({ value: bt(t) })),
1818
- breakdown: pn(t, e)
1819
- };
1820
- }
1821
- function xa(t, n) {
1822
- const e = [
1823
- ...t.items.map((o) => en(o, !0, n)),
1824
- ...(t.negativeStockItems ?? []).map((o) => en(o, !1, n))
1825
- ];
1826
- return e.sort((o, i) => o.code.localeCompare(i.code)), e;
1827
- }
1828
- function jt(t, n, e) {
1829
- const o = (r, u, c = "normal") => _(
1830
- ye.FmTooltip,
1831
- { zIndex: 50 },
1832
- {
1833
- default() {
1834
- return _(
1835
- "div",
1836
- {
1837
- class: [
1838
- "fm-typo-en-body-lg-400 py-4 px-8 fm-corner-radius-md line-clamp-1 border-1",
1839
- c === "orphan" ? "border-fm-color-system-error-300" : c === "inactive" ? "border-purple-500" : "border-fm-color-typo-secondary"
1840
- ]
1841
- },
1842
- [
1843
- _("span", { class: "text-fm-color-typo-primary" }, `${r} `),
1844
- _(
1845
- "span",
1846
- { class: "text-fm-color-typo-secondary", style: { maxWidth: "80px" } },
1847
- u
1848
- )
1849
- ]
1850
- );
1851
- },
1852
- content() {
1853
- return c === "orphan" ? `${r} ${u} (invalid UOM — not on SKU)` : c === "inactive" ? `${r} ${u} (NetSuite-inactive UOM)` : `${r} ${u}`;
1854
- }
1855
- }
1856
- ), i = e.filter((r) => !!r.amount).map((r) => o(r.amount, r.abbrev, r.variant)), s = t || !i.length ? [o(t, n), ...i] : i;
1857
- return _(
1858
- "div",
1859
- { class: "flex gap-8 flex-nowrap", style: { minWidth: `${120 * s.length}px` } },
1860
- s
1861
- );
1862
- }
1863
- function wa(t, n, e) {
1864
- const o = [];
1865
- for (const i of n) {
1866
- const s = i.items.find((b) => b.sku._id === t);
1867
- if (!s) continue;
1868
- const { baseUnitAmount: r, measurements: u } = Tt(s, e);
1869
- (r !== 0 || u.some((b) => b.amount !== 0)) && o.push({ label: i.label, isSub: i.isSub, baseUnitAmount: r, measurements: u });
1870
- }
1871
- return o;
1872
- }
1873
- function Da(t, n) {
1874
- return _(
1875
- "div",
1876
- { class: "flex flex-col gap-8" },
1877
- t.map(
1878
- (e) => _("div", { class: "flex flex-col gap-4" }, [
1879
- _(
1880
- "div",
1881
- { class: "fm-typo-en-body-sm-600 text-fm-color-typo-tertiary uppercase" },
1882
- e.label
1883
- ),
1884
- jt(e.baseUnitAmount, n, e.measurements)
1885
- ])
1886
- )
1887
- );
1888
- }
1889
- const $a = "N/A";
1890
- function yn(t, n) {
1891
- var o, i;
1892
- const e = t.approvedAt ? {
1893
- action: `Approve at ${$e(t.approvedAt)}`,
1894
- actionBy: t.approvedBy,
1895
- remark: t.approveRemark
1896
- } : (o = t.rejectionHistory) == null ? void 0 : o.computeFirst((s) => ({
1897
- action: `Reject at ${$e(s.rejectedAt)}`,
1898
- actionBy: s.rejectedBy,
1899
- remark: s.rejectRemark
1900
- }));
1901
- return [
1902
- n.idDisplay ? { label: "ID", value: n.idDisplay } : null,
1903
- {
1904
- label: "Location",
1905
- value: n.locationName ?? $a
1906
- },
1907
- {
1908
- label: "Created at",
1909
- value: $e(t.createdAt)
1910
- },
1911
- {
1912
- label: "Created by",
1913
- value: t.createdBy.name
1914
- },
1915
- {
1916
- label: "Updated at",
1917
- value: $e(t.updatedAt)
1918
- },
1919
- {
1920
- label: "Updated by",
1921
- value: t.updatedBy.name
1922
- },
1923
- {
1924
- label: "Effective at",
1925
- value: $e(t.effectiveAt ?? Re(t._id))
1926
- },
1927
- {
1928
- label: "Using template",
1929
- value: ((i = t.usingTemplates.find((s) => s)) == null ? void 0 : i.name) ?? "None"
1930
- },
1931
- t.remark ? { label: "Remark", value: t.remark } : null,
1932
- e ? { label: "Last action", value: e.action } : null,
1933
- e && e.actionBy ? { label: "Last action by", value: e.actionBy.name } : null,
1934
- e && e.remark ? { label: "Action remark", value: e.remark } : null
1935
- ].filter((s) => !!s);
1936
- }
1937
- const Ca = { class: "fm-typo-en-body-lg-400" }, Aa = { class: "fm-typo-en-body-lg-600" }, Sa = { class: "flex gap-12 py-8 justify-end w-full" }, Fa = /* @__PURE__ */ De({
1938
- __name: "ClosingGroupAction",
1939
- props: {
1940
- group: {},
1941
- action: {},
1942
- onCancel: { type: Function },
1943
- onFinished: { type: Function }
1944
- },
1945
- setup(t) {
1946
- const n = t, e = Me(), o = ze(), i = Q(), s = Q(!1), r = S(() => n.action === "approve"), u = S(() => r.value ? "Approve" : "Reject"), c = S(() => r.value ? "primary" : "destructive");
1947
- async function b() {
1948
- s.value = !0;
1949
- try {
1950
- r.value ? await e.approveClosingGroup(n.group._id, i.value).delayed(500) : await e.rejectClosingGroup(n.group._id, i.value).delayed(500), o.open({ title: "Success", message: "Action submitted", type: "success" }), n.onFinished();
1951
- } catch (y) {
1952
- o.open({
1953
- title: "Something went wrong",
1954
- message: (y == null ? void 0 : y.message) ?? "Unable to submit action. Please try again",
1955
- type: "error"
1956
- }), console.error("error on submit closing group action", y);
1957
- } finally {
1958
- s.value = !1;
1959
- }
1960
- }
1961
- return (y, I) => {
1962
- const E = J("FmTextField"), U = J("FmButton"), R = J("FmForm");
1963
- return p(), ne(R, {
1964
- onValidationSuccess: b,
1965
- class: "flex flex-col gap-32",
1966
- disabled: s.value
1967
- }, {
1968
- default: te(() => [
1969
- a("div", Ca, [
1970
- I[2] || (I[2] = fe(" You are about to ")),
1971
- a("span", Aa, N(u.value), 1),
1972
- I[3] || (I[3] = fe(" this group. Please provide a remark to justify this action. "))
1973
- ]),
1974
- D(E, {
1975
- modelValue: i.value,
1976
- "onUpdate:modelValue": I[0] || (I[0] = (F) => i.value = F),
1977
- label: "Remark",
1978
- "label-mark": "required",
1979
- rules: [f(ln)()]
1980
- }, null, 8, ["modelValue", "rules"]),
1981
- a("div", Sa, [
1982
- D(U, {
1983
- label: "Cancel",
1984
- variant: "tertiary",
1985
- onClick: I[1] || (I[1] = (F) => y.onCancel())
1986
- }),
1987
- D(U, {
1988
- label: u.value,
1989
- type: "submit",
1990
- variant: c.value,
1991
- loading: s.value
1992
- }, null, 8, ["label", "variant", "loading"])
1993
- ])
1994
- ]),
1995
- _: 1
1996
- }, 8, ["disabled"]);
1997
- };
1998
- }
1999
- }), Ia = { class: "w-full flex flex-col gap-32" }, Ba = { class: "fm-typo-en-title-md-600" }, Ta = { class: "text-fm-color-typo-secondary" }, ja = { class: "text-fm-color-primary" }, Pa = { class: "flex justify-between" }, Ra = { class: "flex" }, Ma = { class: "grid grid-cols-[repeat(4,1fr)] xs:flex xs:flex-col sm:flex sm:flex-col gap-8" }, Ua = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Na = { class: "flex gap-1" }, Va = {
2000
- class: "fm-typo-en-body-lg-600",
2001
- style: { "white-space": "pre-wrap", "word-break": "break-word" }
2002
- }, Ea = { class: "fm-typo-en-body-lg-600" }, La = { class: "flex gap-8" }, za = { class: "overflow-x-auto" }, Oa = {
2003
- key: 1,
2004
- class: "flex-1 xs:w-screen xs:max-w-full"
2005
- }, Ga = {
2006
- key: 0,
2007
- class: "flex flex-col items-center gap-8 h-full"
2008
- }, Ha = ["src"], Ya = {
2009
- key: 1,
2010
- class: "px-4 flex flex-col"
2011
- }, Ka = { class: "flex gap-12 content-stretch" }, Wa = {
2012
- class: "flex flex-col w-24",
2013
- name: "circles"
2014
- }, qa = { class: "flex-1 flex flex-col items-center" }, Qa = { class: "flex-1 flex flex-col items-center" }, Ja = {
2015
- class: "py-12 flex flex-col gap-4",
2016
- name: "received-at header"
2017
- }, Za = { class: "fm-typo-en-body-lg-400" }, Xa = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, es = { class: "flex gap-12 content-stretch" }, ts = {
2018
- class: "flex flex-col w-24",
2019
- name: "circles"
2020
- }, ns = { class: "flex-1 flex flex-col items-center" }, os = {
2021
- class: "py-12 flex flex-col gap-4 flex-1",
2022
- name: "delivery details"
2023
- }, as = { class: "flex flex-col gap-8" }, ss = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, rs = { class: "flex flex-col gap-4" }, ls = { class: "flex items-center gap-8 w-full" }, is = /* @__PURE__ */ De({
2024
- __name: "ClosingGroupDetailSideSheet",
2025
- props: {
2026
- show: { type: Boolean },
2027
- group: {},
2028
- parentName: {}
2029
- },
2030
- emits: ["update:show", "updated"],
2031
- setup(t, { emit: n }) {
2032
- const e = t, o = n, i = St(e, "show"), s = Bt(), r = Oe(), u = on(), c = S(() => {
2033
- var d, h, B;
2034
- return ((B = (h = (d = e.group) == null ? void 0 : d.usingTemplates) == null ? void 0 : h.find((M) => M)) == null ? void 0 : B.name) ?? "Group";
2035
- }), b = S(() => {
2036
- var d;
2037
- return ((d = e.group) == null ? void 0 : d.status) === _e.enum.DRAFT;
2038
- });
2039
- function y(d) {
2040
- e.group && u.open({
2041
- title: d === "approve" ? "Approve group" : "Reject group",
2042
- contentComponent: Fa,
2043
- contentComponentProps: {
2044
- group: e.group,
2045
- action: d,
2046
- onFinished: () => {
2047
- u.close(), o("updated"), i.value = !1;
2048
- },
2049
- onCancel: () => u.close()
2050
- }
2051
- });
2052
- }
2053
- const I = S(() => {
2054
- var d;
2055
- return e.group ? yn(e.group, {
2056
- locationName: (d = r._currentLocation) == null ? void 0 : d.name
2057
- }) : [];
2058
- }), E = [
2059
- { label: "Overview", value: "overview" },
2060
- { label: "Action history", value: "history" }
2061
- ], U = Q(E[0]), R = Q(""), F = Q({ templateItem: !0, nonTemplateItem: !0 }), L = Q(null);
2062
- function K(d, h) {
2063
- L.value = h ? d : L.value === d ? null : L.value;
2064
- }
2065
- Be(
2066
- () => e.show,
2067
- (d) => {
2068
- d && (U.value = E[0], R.value = "", F.value = { templateItem: !0, nonTemplateItem: !0 }, L.value = null);
2069
- }
2070
- );
2071
- const j = S(
2072
- () => e.group ? xa(e.group, s.value) : []
2073
- ), z = S(
2074
- () => j.value.filter((d) => !!(d.isTemplateItem && F.value.templateItem || !d.isTemplateItem && F.value.nonTemplateItem))
2075
- ), A = S(() => [
2076
- {
2077
- id: "sku",
2078
- accessorFn: (d) => `${d.code} ${d.name}`,
2079
- header: () => "Name",
2080
- size: 350,
2081
- cell(d) {
2082
- const h = d.row.original;
2083
- return _("div", { class: "flex flex-col gap-4" }, [
2084
- _(
2085
- "div",
2086
- { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
2087
- h.name
2088
- ),
2089
- _(
2090
- "div",
2091
- { class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
2092
- h.code
2093
- )
2094
- ]);
2095
- }
2096
- },
2097
- {
2098
- id: "uom",
2099
- accessorFn: (d) => d.baseUnit,
2100
- header: () => "UOM (base)",
2101
- size: 120
2102
- },
2103
- {
2104
- id: "physicalBalance",
2105
- accessorKey: "physicalBalance",
2106
- header: () => _(
2107
- ye.FmTooltip,
2108
- { zIndex: 51, placement: "left", class: "w-full flex justify-end" },
2109
- {
2110
- default: () => "Stock Take balance",
2111
- content: () => "The physical balance recorded during stock take."
2112
- }
2113
- ),
2114
- size: 180,
2115
- cell(d) {
2116
- const h = d.row.original, B = _(
2117
- "div",
2118
- { class: "text-right fm-typo-en-body-lg-400" },
2119
- ie(h.physicalBalance)
2120
- );
2121
- return h.breakdown.length ? _(
2122
- ye.FmPopover,
2123
- {
2124
- showPopover: L.value === h.id,
2125
- placement: "bottom-end",
2126
- zIndex: 9999,
2127
- "onPopover-changed": (M) => K(h.id, M)
2128
- },
2129
- {
2130
- "popover-button": () => _(
2131
- "button",
2132
- {
2133
- type: "button",
2134
- class: "flex items-center gap-4 ml-auto text-fm-color-typo-secondary hover:text-fm-color-typo-primary"
2135
- },
2136
- [B, _(ye.FmIcon, { name: "info", size: "sm", outline: !0 })]
2137
- ),
2138
- default: () => vn(h.breakdown, h.physicalBalance, h.baseUnit)
2139
- }
2140
- ) : B;
2141
- },
2142
- meta: { textAlign: "right" }
2143
- },
2144
- {
2145
- id: "amounts",
2146
- header: () => "Amounts",
2147
- enableSorting: !1,
2148
- cell(d) {
2149
- const h = d.row.original;
2150
- return jt(h.baseUnitAmount, h.baseUnit, h.measurements);
2151
- }
2152
- }
2153
- ]), w = S(() => {
2154
- const d = e.group;
2155
- if (!d) return [];
2156
- const h = [...d.activityLogs ?? []], B = d.rejectionHistory ?? [];
2157
- for (const M of B)
2158
- h.find(
2159
- (g) => `${g.action}_${g.performedAt}` == `${de.enum.rejectDraft}_${M.rejectedAt}`
2160
- ) || h.push({
2161
- action: de.enum.rejectDraft,
2162
- performedAt: M.rejectedAt,
2163
- performedBy: M.rejectedBy,
2164
- remark: M.rejectRemark
2165
- });
2166
- return d.approvedAt && (h.find(
2167
- (O) => `${O.action}_${O.performedAt}` == `${de.enum.approveDraft}_${d.approvedAt}`
2168
- ) || h.push({
2169
- action: de.enum.approveDraft,
2170
- performedAt: d.approvedAt,
2171
- performedBy: d.approvedBy ?? { name: "Unknown", id: "unknown" },
2172
- remark: d.approveRemark
2173
- })), h.sort((M, O) => new Date(O.performedAt).getTime() - new Date(M.performedAt).getTime()).map((M) => ({
2174
- header: Ae(M.action),
2175
- date: $e(M.performedAt),
2176
- info: [
2177
- { label: "Performed by", values: [M.performedBy.name] },
2178
- { label: "Remark", values: [M.remark ?? ""] }
2179
- ]
2180
- }));
2181
- });
2182
- return (d, h) => {
2183
- const B = J("FmButtonGroup"), M = J("FmMenuDivider"), O = J("FmCard"), g = J("FmChip"), k = J("FmTextField"), x = J("FmTable"), ee = J("FmSpacer"), X = J("FmButton"), T = J("FmSideSheet");
2184
- return p(), ne(T, {
2185
- "dismiss-away": "",
2186
- "max-width": 9999,
2187
- "model-value": f(i),
2188
- "onUpdate:modelValue": h[7] || (h[7] = (G) => vt(i) ? i.value = G : null),
2189
- header: "Group details"
2190
- }, {
2191
- "side-sheet-footer": te(() => [
2192
- a("div", ls, [
2193
- b.value ? (p(), ne(X, {
2194
- key: 0,
2195
- label: "Approve",
2196
- onClick: h[4] || (h[4] = (G) => y("approve"))
2197
- })) : H("", !0),
2198
- b.value ? (p(), ne(X, {
2199
- key: 1,
2200
- label: "Reject",
2201
- variant: "destructive",
2202
- onClick: h[5] || (h[5] = (G) => y("reject"))
2203
- })) : H("", !0),
2204
- D(X, {
2205
- label: "Close",
2206
- variant: "tertiary",
2207
- onClick: h[6] || (h[6] = (G) => i.value = !1)
2208
- })
2209
- ])
2210
- ]),
2211
- default: te(() => [
2212
- a("div", Ia, [
2213
- a("div", Ba, [
2214
- d.parentName ? (p(), C(re, { key: 0 }, [
2215
- a("span", Ta, N(d.parentName), 1),
2216
- h[8] || (h[8] = fe(" · "))
2217
- ], 64)) : H("", !0),
2218
- h[9] || (h[9] = fe(" Group · ")),
2219
- a("span", ja, N(c.value), 1)
2220
- ]),
2221
- a("div", null, [
2222
- D(B, {
2223
- items: E,
2224
- modelValue: U.value,
2225
- "onUpdate:modelValue": h[0] || (h[0] = (G) => U.value = G)
2226
- }, null, 8, ["modelValue"])
2227
- ]),
2228
- U.value.value === "overview" ? (p(), C(re, { key: 0 }, [
2229
- D(O, {
2230
- variant: "outlined",
2231
- class: "flex flex-col gap-8 px-12 py-16"
2232
- }, {
2233
- default: te(() => {
2234
- var G, $;
2235
- return [
2236
- a("div", Pa, [
2237
- h[10] || (h[10] = a("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
2238
- a("div", Ra, [
2239
- a("div", {
2240
- class: he(["fm-status-badge", f(We)(((G = d.group) == null ? void 0 : G.status) ?? "DRAFT")])
2241
- }, N(f(Ae)((($ = d.group) == null ? void 0 : $.status) ?? "")), 3)
2242
- ])
2243
- ]),
2244
- D(M),
2245
- a("div", Ma, [
2246
- (p(!0), C(re, null, ge(I.value, (Y, me) => (p(), C("div", {
2247
- class: "flex flex-col gap-4",
2248
- key: me
2249
- }, [
2250
- a("div", Ua, [
2251
- a("div", Na, N(Y.label), 1)
2252
- ]),
2253
- a("div", Va, N(Y.value), 1)
2254
- ]))), 128))
2255
- ])
2256
- ];
2257
- }),
2258
- _: 1
2259
- }),
2260
- D(O, {
2261
- variant: "outlined",
2262
- class: "flex flex-col gap-16 px-12 py-16"
2263
- }, {
2264
- default: te(() => [
2265
- a("div", Ea, N(c.value) + " items", 1),
2266
- a("div", La, [
2267
- D(g, {
2268
- label: "Template Item(s)",
2269
- selected: F.value.templateItem,
2270
- onClick: h[1] || (h[1] = (G) => F.value.templateItem = !F.value.templateItem)
2271
- }, null, 8, ["selected"]),
2272
- D(g, {
2273
- label: "Non-template Item(s)",
2274
- selected: F.value.nonTemplateItem,
2275
- onClick: h[2] || (h[2] = (G) => F.value.nonTemplateItem = !F.value.nonTemplateItem)
2276
- }, null, 8, ["selected"])
2277
- ]),
2278
- D(k, {
2279
- modelValue: R.value,
2280
- "onUpdate:modelValue": h[3] || (h[3] = (G) => R.value = G),
2281
- placeholder: "Filter items"
2282
- }, null, 8, ["modelValue"]),
2283
- a("div", za, [
2284
- D(x, {
2285
- "column-defs": A.value,
2286
- "row-data": z.value,
2287
- "search-value": R.value,
2288
- "page-size": 10
2289
- }, null, 8, ["column-defs", "row-data", "search-value"])
2290
- ])
2291
- ]),
2292
- _: 1
2293
- })
2294
- ], 64)) : H("", !0),
2295
- U.value.value === "history" ? (p(), C("div", Oa, [
2296
- w.value.length ? (p(), C("div", Ya, [
2297
- (p(!0), C(re, null, ge(w.value, (G, $) => (p(), C(re, { key: $ }, [
2298
- a("div", Ka, [
2299
- a("div", Wa, [
2300
- a("div", qa, [
2301
- a("div", {
2302
- class: he([
2303
- { "bg-fm-color-primary": $ !== 0, "bg-white": $ === 0 },
2304
- "w-[2px] h-full"
2305
- ])
2306
- }, null, 2)
2307
- ]),
2308
- h[13] || (h[13] = a("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
2309
- a("div", Qa, [
2310
- a("div", {
2311
- class: he([
2312
- {
2313
- "bg-fm-color-primary": $ < w.value.length - 1,
2314
- "bg-white": $ >= w.value.length - 1
2315
- },
2316
- "w-[2px] h-full"
2317
- ])
2318
- }, null, 2)
2319
- ])
2320
- ]),
2321
- a("div", Ja, [
2322
- a("div", Za, N(G.header), 1),
2323
- a("div", Xa, N(G.date), 1)
2324
- ])
2325
- ]),
2326
- a("div", es, [
2327
- a("div", ts, [
2328
- a("div", ns, [
2329
- a("div", {
2330
- class: he([
2331
- {
2332
- "bg-fm-color-primary": $ < w.value.length - 1,
2333
- "bg-white": $ >= w.value.length - 1
2334
- },
2335
- "w-[2px] h-full"
2336
- ])
2337
- }, null, 2)
2338
- ])
2339
- ]),
2340
- a("div", os, [
2341
- D(O, {
2342
- variant: "outlined",
2343
- class: "py-12 px-16"
2344
- }, {
2345
- default: te(() => [
2346
- a("div", as, [
2347
- (p(!0), C(re, null, ge(G.info, (Y, me) => (p(), C("div", {
2348
- key: me,
2349
- class: "flex flex-col gap-4"
2350
- }, [
2351
- a("div", ss, N(Y.label), 1),
2352
- a("div", rs, [
2353
- (p(!0), C(re, null, ge(Y.values, (ae, ce) => (p(), C("div", {
2354
- key: ce,
2355
- class: "fm-typo-en-body-lg-600"
2356
- }, N(ae), 1))), 128))
2357
- ])
2358
- ]))), 128))
2359
- ])
2360
- ]),
2361
- _: 2
2362
- }, 1024)
2363
- ])
2364
- ])
2365
- ], 64))), 128))
2366
- ])) : (p(), C("div", Ga, [
2367
- D(ee),
2368
- a("div", null, [
2369
- a("img", {
2370
- src: f(mn),
2371
- alt: "List is empty"
2372
- }, null, 8, Ha)
2373
- ]),
2374
- h[11] || (h[11] = a("div", { class: "fm-typo-en-body-lg-600" }, "No records found", -1)),
2375
- h[12] || (h[12] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, " You can track approval and rejection history here ", -1)),
2376
- D(ee),
2377
- D(ee)
2378
- ]))
2379
- ])) : H("", !0)
2380
- ])
2381
- ]),
2382
- _: 1
2383
- }, 8, ["model-value"]);
2384
- };
2385
- }
2386
- }), cs = { class: "w-full flex flex-col gap-32" }, us = { class: "flex flex-col gap-4" }, ds = { class: "flex justify-between" }, ms = { class: "flex" }, fs = { class: "grid grid-cols-[repeat(4,1fr)] xs:flex xs:flex-col sm:flex sm:flex-col gap-8" }, ps = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, vs = { class: "flex gap-1" }, ys = {
2387
- class: "fm-typo-en-body-lg-600",
2388
- style: { "white-space": "pre-wrap", "word-break": "break-word" }
2389
- }, gs = { class: "flex items-center justify-between" }, bs = { class: "fm-typo-en-body-lg-600" }, hs = {
2390
- key: 1,
2391
- class: "flex items-start gap-8 p-12 fm-corner-radius-md border-1 border-yellow-500 bg-yellow-50 text-yellow-700"
2392
- }, _s = { class: "flex flex-col gap-2" }, ks = { class: "fm-typo-en-body-sm-400 list-disc pl-16" }, xs = { key: 0 }, ws = { key: 1 }, Ds = { class: "flex flex-col gap-16" }, $s = { class: "flex items-center" }, Cs = {
2393
- key: 0,
2394
- class: "flex gap-8"
2395
- }, As = {
2396
- key: 0,
2397
- class: "w-full flex flex-col items-center"
2398
- }, Ss = { class: "flex items-center gap-8" }, Fs = { class: "flex flex-col gap-8" }, Is = { class: "flex gap-8" }, Bs = {
2399
- key: 0,
2400
- class: "flex gap-8"
2401
- }, Ts = {
2402
- key: 1,
2403
- class: "flex gap-8 flex-wrap"
2404
- }, js = { class: "overflow-x-auto" }, Ps = {
2405
- key: 1,
2406
- class: "flex-1 xs:w-screen xs:max-w-full"
2407
- }, Rs = {
2408
- key: 0,
2409
- class: "flex flex-col items-center gap-8 h-full"
2410
- }, Ms = ["src"], Us = {
2411
- key: 1,
2412
- class: "px-4 flex flex-col"
2413
- }, Ns = { class: "flex gap-12 content-stretch" }, Vs = {
2414
- class: "flex flex-col w-24",
2415
- name: "circles"
2416
- }, Es = { class: "flex-1 flex flex-col items-center" }, Ls = { class: "flex-1 flex flex-col items-center" }, zs = {
2417
- class: "py-12 flex flex-col gap-4",
2418
- name: "received-at header"
2419
- }, Os = { class: "fm-typo-en-body-lg-400" }, Gs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Hs = { class: "flex gap-12 content-stretch" }, Ys = {
2420
- class: "flex flex-col w-24",
2421
- name: "circles"
2422
- }, Ks = { class: "flex-1 flex flex-col items-center" }, Ws = {
2423
- class: "py-12 flex flex-col gap-4 flex-1",
2424
- name: "delivery details"
2425
- }, qs = { class: "flex flex-col gap-8" }, Qs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Js = { class: "flex flex-col gap-4" }, Zs = { class: "flex items-center justify-between gap-8 w-full" }, Xs = { class: "flex items-center gap-8" }, er = { class: "flex flex-col items-end" }, tr = { class: "text-2xl font-semibold" }, nr = "N/A", or = /* @__PURE__ */ De({
2426
- __name: "ClosingDraftDialog",
2427
- props: {
2428
- show: { type: Boolean },
2429
- draft: {}
2430
- },
2431
- emits: ["submitted", "refresh"],
2432
- setup(t, { emit: n }) {
2433
- const e = t, o = S(() => {
2434
- const m = an();
2435
- return m === "MYR" ? "RM" : m;
2436
- }), i = fn(), s = S(() => {
2437
- var m, l;
2438
- return (m = e.draft) != null && m.closingId ? ((l = i.drafts.find((v) => v._id === e.draft._id)) == null ? void 0 : l.closingIdDisplay) ?? null : null;
2439
- }), r = pt(), u = Me(), c = St(e, "show"), b = Q(!1), y = Q(!1), I = Q([]);
2440
- let E = 0;
2441
- async function U() {
2442
- var v;
2443
- const m = (v = e.draft) == null ? void 0 : v._id;
2444
- if (I.value = [], !m) return;
2445
- const l = ++E;
2446
- try {
2447
- const V = await u.getClosingGroups(m);
2448
- if (l !== E) return;
2449
- I.value = V;
2450
- } catch (V) {
2451
- if (l !== E) return;
2452
- console.error("Failed to fetch closing groups", V);
2453
- }
2454
- }
2455
- const R = S(() => I.value.map(At)), F = S(() => {
2456
- var m, l, v;
2457
- return (v = (l = (m = e.draft) == null ? void 0 : m.usingTemplates) == null ? void 0 : l.find((V) => V)) == null ? void 0 : v.name;
2458
- }), L = Q(null), K = Q(!1);
2459
- function j(m) {
2460
- const l = I.value.find((v) => v._id === m);
2461
- l && (L.value = l, K.value = !0);
2462
- }
2463
- const z = Q(new Array()), A = Q(new Array()), w = S(
2464
- () => {
2465
- var m;
2466
- return ((m = e.draft) == null ? void 0 : m.status) === _e.enum.COMPLETED;
2467
- }
2468
- ), d = S(
2469
- () => {
2470
- var m;
2471
- return w.value ? z.value : ((m = e.draft) == null ? void 0 : m.stockSnapshot) ?? [];
2472
- }
2473
- ), h = S(
2474
- () => w.value ? A.value : []
2475
- ), B = S(() => {
2476
- var V;
2477
- const m = /* @__PURE__ */ new Set();
2478
- for (const W of ((V = e.draft) == null ? void 0 : V.adjustmentSnapshot) ?? [])
2479
- W.adjustmentsByType && Object.keys(W.adjustmentsByType).forEach((P) => m.add(P));
2480
- const v = ["receive", "sales", "wastage"].filter((W) => m.has(W));
2481
- return v.forEach((W) => m.delete(W)), [...v, ...Array.from(m).sort()];
2482
- }), M = gt(), O = ze(), g = Ft(), k = Oe(), x = Zt({}), ee = S(() => new Set(
2483
- g.skus.filter((m) => {
2484
- var l;
2485
- return x[(l = m.customAttributes) == null ? void 0 : l.tag];
2486
- }).map((m) => m._id)
2487
- )), X = n, T = S(() => {
2488
- var m;
2489
- return (m = e.draft) == null ? void 0 : m._id;
2490
- }), G = S(() => {
2491
- var m;
2492
- return (m = e.draft) == null ? void 0 : m._rev;
2493
- }), {
2494
- refreshing: $,
2495
- startListening: Y,
2496
- startRefresh: me,
2497
- cleanup: ae
2498
- } = ia({
2499
- closingDraftId: T,
2500
- currentRev: G,
2501
- onCompleted: (m) => {
2502
- X("refresh", m), c.value = !1;
2503
- }
2504
- }), ce = Q({
2505
- templateItem: !0,
2506
- nonTemplateItem: !0
2507
- }), pe = Q(null);
2508
- function Te(m, l) {
2509
- pe.value = l ? m : pe.value === m ? null : pe.value;
2510
- }
2511
- const Ze = S(() => {
2512
- var m, l;
2513
- return [
2514
- {
2515
- label: "Main",
2516
- isSub: !1,
2517
- items: [...((m = e.draft) == null ? void 0 : m.items) ?? [], ...((l = e.draft) == null ? void 0 : l.negativeStockItems) ?? []]
2518
- },
2519
- ...I.value.map((v) => ({
2520
- label: ht(v),
2521
- isSub: !0,
2522
- items: [...v.items ?? [], ...v.negativeStockItems ?? []]
2523
- }))
2524
- ];
2525
- }), Ge = S(() => {
2526
- var V, W;
2527
- const m = [
2528
- ...((V = e.draft) == null ? void 0 : V.items) ?? [],
2529
- ...((W = e.draft) == null ? void 0 : W.negativeStockItems) ?? []
2530
- ], l = I.value.map((P) => [
2531
- ...P.items ?? [],
2532
- ...P.negativeStockItems ?? []
2533
- ]), v = Uo([m, ...l]);
2534
- return ee.value.size ? v.filter((P) => ee.value.has(P.sku._id)) : v;
2535
- }), Se = S(() => {
2536
- const m = Ge.value.map((l) => l.sku);
2537
- return m.sort((l, v) => l.code.localeCompare(v.code)), m;
2538
- }), Fe = Bt();
2539
- Be(
2540
- () => e.show,
2541
- async (m) => {
2542
- if (!m) {
2543
- ae();
2544
- return;
2545
- }
2546
- He.value = xt[0], ce.value = {
2547
- templateItem: !0,
2548
- nonTemplateItem: !0
2549
- }, pe.value = null, Y();
2550
- },
2551
- { immediate: !0 }
2552
- ), Be(
2553
- [() => e.show, T],
2554
- ([m]) => {
2555
- m && (U(), bn());
2556
- },
2557
- { immediate: !0 }
2558
- );
2559
- const Xe = S(() => tt.value.reduce((m, l) => m + Number(l.stockTakeValue), 0)), et = qe(0), gn = qe(100);
2560
- async function bn() {
2561
- var m, l;
2562
- if (k._currentLocation) {
2563
- b.value = !0, z.value = [], A.value = [];
2564
- try {
2565
- if (await g.init(), !w.value) return;
2566
- const v = (m = e.draft) == null ? void 0 : m.closingAdjustmentId;
2567
- if (!v) {
2568
- O.open({
2569
- title: "Something went wrong",
2570
- message: "Closing draft is completed but closing document cannot be found.",
2571
- type: "error"
2572
- }), console.error("Closing draft is completed but closing document cannot be found.", {
2573
- draftId: (l = e.draft) == null ? void 0 : l._id
2574
- });
2575
- return;
2576
- }
2577
- const V = await M.readAdjustmentById(v), W = (V == null ? void 0 : V.skus) ?? [];
2578
- for (const P of W)
2579
- z.value.push({
2580
- id: P.sku._id,
2581
- balance: P.fromBalance,
2582
- costs: P.fromCostBalances
2583
- }), A.value.push({
2584
- id: P.sku._id,
2585
- balance: P.toBalance,
2586
- costs: P.toCostBalances
2587
- });
2588
- } catch (v) {
2589
- O.open({
2590
- title: "Something went wrong",
2591
- message: "Something went wrong when fetching info. Please try again.",
2592
- type: "error"
2593
- }), console.error("error on fetch stock balances", v);
2594
- } finally {
2595
- b.value = !1;
2596
- }
2597
- }
2598
- }
2599
- async function Pt() {
2600
- var l, v;
2601
- if ($.value)
2602
- return;
2603
- if (!(((l = e.draft) == null ? void 0 : l.effectiveAt) ?? (e.draft ? Re((v = e.draft) == null ? void 0 : v._id) : null))) {
2604
- O.open({
2605
- title: "Cannot refresh",
2606
- message: "Effective date is not available for this draft.",
2607
- type: "error"
2608
- });
2609
- return;
2610
- }
2611
- await r.refreshBalance(
2612
- e.draft,
2613
- () => {
2614
- },
2615
- async (V) => {
2616
- await me(V);
2617
- }
2618
- );
2619
- }
2620
- async function hn() {
2621
- var l, v;
2622
- if (!(((l = e.draft) == null ? void 0 : l.effectiveAt) ?? (e.draft ? Re((v = e.draft) == null ? void 0 : v._id) : null))) {
2623
- O.open({
2624
- title: "Cannot refresh",
2625
- message: "Effective date is not available for this draft.",
2626
- type: "error"
2627
- });
2628
- return;
2629
- }
2630
- await r.invalidateDraftCache(e.draft);
2631
- }
2632
- const _n = S(
2633
- () => d.value.groupBy(
2634
- (m) => m.id,
2635
- (m) => m.balance
2636
- )
2637
- ), kn = S(() => Ge.value.groupBy((m) => m.sku._id)), xn = S(() => {
2638
- var m;
2639
- return (m = e.draft) != null && m.adjustmentSnapshot ? new Map(e.draft.adjustmentSnapshot.map((l) => [l.skuId, l.adjustmentsByType])) : /* @__PURE__ */ new Map();
2640
- }), wn = S(() => {
2641
- var m;
2642
- return (m = e.draft) != null && m.opening ? new Map(e.draft.opening.map((l) => [l.skuId, l.balance])) : /* @__PURE__ */ new Map();
2643
- });
2644
- function we(m, l) {
2645
- return _(
2646
- ye.FmTooltip,
2647
- { zIndex: 51, placement: "left", class: "w-full flex justify-end" },
2648
- {
2649
- default() {
2650
- return m;
2651
- },
2652
- content() {
2653
- return l || m;
2654
- }
2655
- }
2656
- );
2657
- }
2658
- const Rt = S(() => [
2659
- {
2660
- id: "sku",
2661
- accessorFn: (l) => `${l.code} ${l.name}`,
2662
- header: () => "Name",
2663
- size: 350,
2664
- cell(l) {
2665
- const v = l.row.original, V = v.adjustedDiffPercentage, W = typeof V == "number" && Math.abs(V) > 10, P = _("div", { class: "flex flex-col gap-4" }, [
2666
- _(
2667
- "div",
2668
- {
2669
- class: [
2670
- "line-clamp-1 fm-typo-en-body-lg-400",
2671
- W ? " text-fm-color-system-error-300" : "text-fm-color-typo-primary"
2672
- ]
2673
- },
2674
- v.name
2675
- ),
2676
- _(
2677
- "div",
2678
- {
2679
- class: [
2680
- "line-clamp-1 fm-typo-en-body-md-400",
2681
- W ? " text-fm-color-system-error-300" : "text-fm-color-typo-secondary"
2682
- ]
2683
- },
2684
- v.code
2685
- ),
2686
- // Flags items whose counts come from more than one sub — a heads-up
2687
- // that the displayed total is summed across subs.
2688
- v.subSources.length >= 2 ? _(
2689
- "div",
2690
- {
2691
- class: "flex items-center gap-4 w-fit px-8 py-2 fm-corner-radius-md bg-orange-50 text-fm-color-primary fm-typo-en-body-md-600"
2692
- },
2693
- [
2694
- _(ye.FmIcon, { name: "refresh", size: "sm" }),
2695
- _("span", `Counted in ${v.subSources.length} subs: ${v.subSources.join(", ")}`)
2696
- ]
2697
- ) : null
2698
- ]);
2699
- return _(
2700
- ye.FmTooltip,
2701
- {
2702
- zIndex: 51
2703
- },
2704
- {
2705
- content() {
2706
- return W ? "Adjustment difference is more than 10%." : `${v.code} - ${v.name}`;
2707
- },
2708
- default() {
2709
- return _("div", { class: "flex items-center gap-4 justify-start w-full" }, [
2710
- P
2711
- ]);
2712
- }
2713
- }
2714
- );
2715
- }
2716
- },
2717
- // Dynamic custom attribute columns (toggled by user)
2718
- ...Nt.value.map(
2719
- (l) => ({
2720
- id: `customAttr_${l}`,
2721
- accessorFn: (v) => v.customAttributeValues[l],
2722
- header: () => we(Ae(l)),
2723
- size: 160,
2724
- cell(v) {
2725
- const V = v.row.original.customAttributeValues[l];
2726
- return V == null ? "N/A" : typeof V == "number" ? _("div", { class: "text-right fm-typo-en-body-lg-400" }, ie(V)) : _("div", { class: "text-right fm-typo-en-body-lg-400" }, String(V));
2727
- },
2728
- meta: {
2729
- textAlign: "right"
2730
- }
2731
- })
2732
- ),
2733
- {
2734
- id: "costPerUnit",
2735
- accessorKey: "costPerUnit",
2736
- header: () => we("Cost per unit"),
2737
- size: 160,
2738
- cell(l) {
2739
- const v = l.row.original.costPerUnit;
2740
- return _("div", { class: "text-right fm-typo-en-body-lg-400" }, ie(v));
2741
- },
2742
- meta: {
2743
- textAlign: "right"
2744
- }
2745
- },
2746
- {
2747
- id: "costUnit",
2748
- header: () => "UOM",
2749
- size: 120,
2750
- cell(l) {
2751
- var Z;
2752
- const v = l.row.original, V = v.costUnit, W = v.baseUnit, P = V ?? W;
2753
- if (V && V !== W) {
2754
- const le = Se.value.find((se) => se._id === v.id), ue = (Z = le == null ? void 0 : le.defaultCost) == null ? void 0 : Z.measurement;
2755
- if (ue) {
2756
- const se = ue.conversion.amount / Math.pow(10, ue.conversion.precision);
2757
- return _("div", { class: "flex flex-col" }, [
2758
- _(
2759
- "span",
2760
- { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
2761
- P
2762
- ),
2763
- _("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, [
2764
- "1 ",
2765
- _("span", { class: "fm-typo-en-body-sm-600" }, V),
2766
- ` = ${se} `,
2767
- _("span", { class: "fm-typo-en-body-sm-600" }, W)
2768
- ])
2769
- ]);
2770
- }
2771
- }
2772
- return P;
2773
- }
2774
- },
2775
- {
2776
- id: "opening",
2777
- accessorKey: "opening",
2778
- header: () => we("Opening (B/F)", "The opening balance brought forward from previous period."),
2779
- size: 150,
2780
- cell(l) {
2781
- const v = l.row.original.opening;
2782
- return _("div", { class: "text-right fm-typo-en-body-lg-400" }, ie(v));
2783
- },
2784
- meta: {
2785
- textAlign: "right"
2786
- }
2787
- },
2788
- // Dynamic adjustment type columns
2789
- ...B.value.map(
2790
- (l) => ({
2791
- id: `adjustment_${l}`,
2792
- accessorFn: (v) => v.adjustmentAmounts[l] ?? { amount: 0, precision: 0 },
2793
- header: () => we(Ae(l)),
2794
- size: 150,
2795
- cell(v) {
2796
- const V = v.row.original.adjustmentAmounts[l] ?? { amount: 0, precision: 0 };
2797
- return _("div", { class: "text-right fm-typo-en-body-lg-400" }, ie(V));
2798
- },
2799
- meta: {
2800
- textAlign: "right"
2801
- }
2802
- })
2803
- ),
2804
- {
2805
- id: "systemBalance",
2806
- accessorKey: "systemBalance",
2807
- header: () => we("System Balance", "The system calculated balance before stock take."),
2808
- size: 200,
2809
- cell(l) {
2810
- const v = l.row.original.systemBalance;
2811
- return _("div", { class: "text-right fm-typo-en-body-lg-400" }, ie(v));
2812
- },
2813
- meta: {
2814
- textAlign: "right"
2815
- }
2816
- },
2817
- {
2818
- id: "physicalBalance",
2819
- accessorFn: (l) => {
2820
- var V;
2821
- const v = (V = h.value.find((W) => W.id === l.id)) == null ? void 0 : V.balance;
2822
- return v ? io.toDouble(v) : l.physicalBalance;
2823
- },
2824
- header: () => we("Stock Take balance", "The physical balance recorded during stock take."),
2825
- cell(l) {
2826
- var ue;
2827
- const v = l.row.original, V = oe.fromNumber(v.physicalBalance);
2828
- let W = !0;
2829
- const P = (ue = h.value.find((se) => se.id === v.id)) == null ? void 0 : ue.balance;
2830
- let Z;
2831
- P && !oe.equals({ a: V, b: P }) ? (W = !1, Z = ie(P)) : Z = ie(v.physicalBalance);
2832
- const le = _("div", { class: "flex flex-col items-end" }, [
2833
- _(
2834
- "span",
2835
- { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
2836
- Z
2837
- ),
2838
- W ? null : _(
2839
- "span",
2840
- { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
2841
- `Draft: ${ie(v.physicalBalance)}`
2842
- )
2843
- ]);
2844
- return v.breakdown.length ? _(
2845
- ye.FmPopover,
2846
- {
2847
- showPopover: pe.value === v.id,
2848
- placement: "bottom-end",
2849
- zIndex: 9999,
2850
- "onPopover-changed": (se) => Te(v.id, se)
2851
- },
2852
- {
2853
- "popover-button": () => _(
2854
- "button",
2855
- {
2856
- type: "button",
2857
- class: "flex items-center gap-4 ml-auto text-fm-color-typo-secondary hover:text-fm-color-typo-primary"
2858
- },
2859
- [
2860
- le,
2861
- _(ye.FmIcon, { name: "info", size: "sm", outline: !0 })
2862
- ]
2863
- ),
2864
- default: () => vn(v.breakdown, v.physicalBalance, v.baseUnit)
2865
- }
2866
- ) : le;
2867
- },
2868
- size: 200,
2869
- meta: {
2870
- textAlign: "right"
2871
- }
2872
- },
2873
- {
2874
- id: "adjustedAmount",
2875
- accessorKey: "adjustedAmount",
2876
- header: () => we("Variance", "The difference between Stock Take balance and System Balance."),
2877
- size: 200,
2878
- cell(l) {
2879
- const v = l.row.original.adjustedAmount;
2880
- return _("div", { class: "text-right fm-typo-en-body-lg-400" }, ie(v));
2881
- },
2882
- meta: {
2883
- textAlign: "right"
2884
- }
2885
- },
2886
- {
2887
- id: "varianceInCost",
2888
- accessorKey: "varianceInCost",
2889
- header: () => we(`Variance (${o.value})`),
2890
- size: 150,
2891
- cell(l) {
2892
- const v = l.row.original.varianceInCost;
2893
- return _("div", { class: "text-right fm-typo-en-body-lg-400" }, ie(v));
2894
- },
2895
- meta: {
2896
- textAlign: "right"
2897
- }
2898
- },
2899
- {
2900
- id: "adjustedDiffPercentage",
2901
- accessorKey: "adjustedDiffPercentage",
2902
- header: () => we(
2903
- "Variance (%)",
2904
- "Difference between Stock Take balance and System Balance in percentage."
2905
- ),
2906
- size: 200,
2907
- cell(l) {
2908
- const v = l.row.original.adjustedDiffPercentage;
2909
- if (v == null)
2910
- return _(
2911
- "div",
2912
- { class: "flex items-center gap-4 justify-end fm-typo-en-body-lg-400" },
2913
- nr
2914
- );
2915
- const V = ie(v);
2916
- if (v === 0)
2917
- return _("div", { class: "flex items-center gap-4 justify-end fm-typo-en-body-lg-400" }, [
2918
- ie(0)
2919
- ]);
2920
- const W = v > 0;
2921
- return _("div", { class: "flex items-center gap-4 justify-end fm-typo-en-body-lg-400" }, [
2922
- _(ye.FmIcon, {
2923
- name: W ? "arrow_drop_up" : "arrow_drop_down",
2924
- color: W ? "system-success-300" : "system-error-300",
2925
- size: "md"
2926
- }),
2927
- V
2928
- ]);
2929
- },
2930
- meta: {
2931
- textAlign: "right"
2932
- }
2933
- },
2934
- {
2935
- id: "stockTakeValue",
2936
- accessorKey: "stockTakeValue",
2937
- header: () => we(`Stock take value (${o.value})`),
2938
- size: 180,
2939
- cell(l) {
2940
- var ue;
2941
- const v = l.row.original, V = v.stockTakeValue, W = Se.value.find((se) => se._id === v.id), P = (ue = W == null ? void 0 : W.defaultCost) == null ? void 0 : ue.measurement, Z = v.physicalBalance, le = v.costPerUnit;
2942
- if (P) {
2943
- const se = oe.toFormatString({ value: P.conversion }), je = `${ie(Z, { minPrecision: 2, maxPrecision: 4 })} ${v.baseUnit} ÷ ${se} × ${le} ${o.value}`;
2944
- return _(
2945
- ye.FmTooltip,
2946
- { zIndex: 51 },
2947
- {
2948
- content() {
2949
- return je;
2950
- },
2951
- default() {
2952
- return _(
2953
- "div",
2954
- { class: "text-right w-full fm-typo-en-body-lg-400" },
2955
- ie(V)
2956
- );
2957
- }
2958
- }
2959
- );
2960
- } else {
2961
- const se = `${ie(Z, { minPrecision: 2, maxPrecision: 4 })} ${v.baseUnit} × ${le} ${o.value}`;
2962
- return _(
2963
- ye.FmTooltip,
2964
- { zIndex: 51 },
2965
- {
2966
- content() {
2967
- return se;
2968
- },
2969
- default() {
2970
- return _(
2971
- "div",
2972
- { class: "text-right w-full fm-typo-en-body-lg-400" },
2973
- ie(V)
2974
- );
2975
- }
2976
- }
2977
- );
2978
- }
2979
- },
2980
- meta: {
2981
- textAlign: "right"
2982
- }
2983
- },
2984
- {
2985
- id: "systemValue",
2986
- accessorKey: "systemValue",
2987
- header: () => we(`System value (${o.value})`),
2988
- size: 180,
2989
- cell(l) {
2990
- var ue;
2991
- const v = l.row.original, V = v.systemValue, W = Se.value.find((se) => se._id === v.id), P = (ue = W == null ? void 0 : W.defaultCost) == null ? void 0 : ue.measurement, Z = v.systemBalance, le = v.costPerUnit;
2992
- if (P) {
2993
- const se = oe.toFormatString({ value: P.conversion }), je = `${ie(Z, { minPrecision: 2, maxPrecision: 4 })} ${v.baseUnit} ÷ ${se} × ${le} ${o.value}`;
2994
- return _(
2995
- ye.FmTooltip,
2996
- { zIndex: 51 },
2997
- {
2998
- content() {
2999
- return je;
3000
- },
3001
- default() {
3002
- return _(
3003
- "div",
3004
- { class: "text-right fm-typo-en-body-lg-400" },
3005
- ie(V)
3006
- );
3007
- }
3008
- }
3009
- );
3010
- } else {
3011
- const se = `${ie(Z, { minPrecision: 2, maxPrecision: 4 })} ${v.baseUnit} × ${le} ${o.value}`;
3012
- return _(
3013
- ye.FmTooltip,
3014
- { zIndex: 51 },
3015
- {
3016
- content() {
3017
- return se;
3018
- },
3019
- default() {
3020
- return _(
3021
- "div",
3022
- { class: "text-right fm-typo-en-body-lg-400" },
3023
- ie(V)
3024
- );
3025
- }
3026
- }
3027
- );
3028
- }
3029
- },
3030
- meta: {
3031
- textAlign: "right"
3032
- }
3033
- },
3034
- {
3035
- id: "physicalBalances",
3036
- header: () => "Amounts",
3037
- enableSorting: !1,
3038
- cell(l) {
3039
- const v = l.row.original;
3040
- return I.value.length && v.sourceBuckets.length ? Da(v.sourceBuckets, v.baseUnit) : jt(v.baseUnitAmount, v.baseUnit, v.measurements);
3041
- }
3042
- }
3043
- ]), Dn = S(() => Rt.value.map((m) => m.size ?? 0).reduce((m, l) => m + l)), _t = Q(""), $n = S(() => {
3044
- var V, W;
3045
- const m = ((W = (V = e.draft) == null ? void 0 : V.negativeStockItems) == null ? void 0 : W.reduce(
3046
- (P, Z) => (P[Z.sku._id] = Z, P),
3047
- {}
3048
- )) ?? {}, l = new Map(
3049
- h.value.map((P) => [P.id, P.balance])
3050
- );
3051
- return Se.value.map((P) => {
3052
- var Ot, Gt, Ht, Yt, Kt, Wt, qt, Qt, Jt;
3053
- const Z = (Ot = kn.value.get(P._id)) == null ? void 0 : Ot[0], le = ((Gt = _n.value.get(P._id)) == null ? void 0 : Gt[0]) ?? et, ue = ((Ht = P.defaultCost) == null ? void 0 : Ht.costPerUnit) ?? et, se = Number(oe.toFormatString({ value: ue })), je = ((Kt = (Yt = P.defaultCost) == null ? void 0 : Yt.measurement) == null ? void 0 : Kt.conversion) ?? {
3054
- amount: 1,
3055
- precision: 0
3056
- }, Ce = Number(
3057
- oe.toFormatString({ value: je })
3058
- ), st = wn.value.get(P._id), rt = st ? Number(oe.toFormatString({ value: st })) : 0, q = xn.value.get(P._id), ve = {};
3059
- if (B.value.forEach((ke) => {
3060
- const it = ve[ke] ?? { amount: 0, precision: 0 }, ct = q == null ? void 0 : q[ke];
3061
- ct && (ve[ke] = Qe(it, ct));
3062
- }), !Z) {
3063
- const ke = Number(oe.toFormatString({ value: le })), it = 0 - ke, ct = it * se / Ce, Rn = 0, Mn = ke * se / Ce;
3064
- return {
3065
- id: P._id,
3066
- code: P.code,
3067
- name: P.name,
3068
- costUnit: ((qt = (Wt = P.defaultCost) == null ? void 0 : Wt.measurement) == null ? void 0 : qt.abbrev) ?? null,
3069
- baseUnit: P.unit.abbrev,
3070
- baseUnitAmount: 0,
3071
- systemBalance: ke,
3072
- physicalBalance: 0,
3073
- adjustedAmount: -ke,
3074
- adjustedDiffPercentage: -100,
3075
- isTemplateItem: !m[P._id],
3076
- costPerUnit: se,
3077
- opening: rt,
3078
- varianceQty: it,
3079
- varianceInCost: ct,
3080
- stockTakeValue: Rn,
3081
- systemValue: Mn,
3082
- adjustmentAmounts: ve,
3083
- customAttributeValues: P.customAttributes ?? {},
3084
- measurements: [],
3085
- breakdown: [],
3086
- sourceBuckets: [],
3087
- subSources: []
3088
- };
3089
- }
3090
- const be = bt(Z), Ie = l.get(P._id), Ne = cn(
3091
- Ie ?? be,
3092
- le
3093
- ), lt = le.amount === 0 ? null : un(Ne, {
3094
- ...le,
3095
- amount: Math.abs(le.amount)
3096
- }), Et = lt ? yt(lt, gn) : null, wt = Number(oe.toFormatString({ value: le })), Dt = Number(oe.toFormatString({ value: be })), Lt = Dt - wt, Fn = Lt * se / Ce, In = Dt * se / Ce, Bn = wt * se / Ce, { baseUnitAmount: Tn, measurements: jn } = Tt(Z, Fe.value), Pn = pn(Z, Fe.value), zt = wa(P._id, Ze.value, Fe.value);
3097
- return {
3098
- id: P._id,
3099
- code: P.code,
3100
- name: P.name,
3101
- costUnit: ((Jt = (Qt = P.defaultCost) == null ? void 0 : Qt.measurement) == null ? void 0 : Jt.abbrev) ?? null,
3102
- baseUnit: P.unit.abbrev,
3103
- baseUnitAmount: Tn,
3104
- measurements: jn,
3105
- breakdown: Pn,
3106
- systemBalance: wt,
3107
- physicalBalance: Dt,
3108
- adjustedAmount: Number(oe.toFormatString({ value: Ne })),
3109
- adjustedDiffPercentage: Et ? Number(
3110
- oe.toFormatString({
3111
- value: dn(Et, 2)
3112
- })
3113
- ) : null,
3114
- isTemplateItem: !m[P._id],
3115
- costPerUnit: se,
3116
- opening: rt,
3117
- varianceQty: Lt,
3118
- varianceInCost: Fn,
3119
- stockTakeValue: In,
3120
- systemValue: Bn,
3121
- adjustmentAmounts: ve,
3122
- customAttributeValues: P.customAttributes ?? {},
3123
- sourceBuckets: zt,
3124
- subSources: zt.filter((ke) => ke.isSub).map((ke) => ke.label)
3125
- };
3126
- });
3127
- }), tt = S(() => $n.value.filter((m) => !!(m.isTemplateItem && ce.value.templateItem || !m.isTemplateItem && ce.value.nonTemplateItem))), Mt = S(
3128
- () => tt.value.some((m) => m.measurements.some((l) => l.variant === "inactive"))
3129
- ), Ut = S(
3130
- () => tt.value.some((m) => m.measurements.some((l) => l.variant === "orphan"))
3131
- ), Cn = S(
3132
- () => Mt.value || Ut.value
3133
- ), kt = S(() => {
3134
- const m = /* @__PURE__ */ new Set();
3135
- for (const l of Se.value)
3136
- if (l.customAttributes)
3137
- for (const v of Object.keys(l.customAttributes))
3138
- v !== "tag" && m.add(v);
3139
- return Array.from(m).sort();
3140
- }), nt = Zt({}), Nt = S(
3141
- () => kt.value.filter((m) => nt[m])
3142
- ), An = S(() => {
3143
- var m;
3144
- return e.draft ? yn(e.draft, {
3145
- idDisplay: s.value,
3146
- locationName: (m = k._currentLocation) == null ? void 0 : m.name
3147
- }) : [];
3148
- }), xt = [
3149
- {
3150
- label: "Overview",
3151
- value: "overview"
3152
- },
3153
- {
3154
- label: "Action history",
3155
- value: "history"
3156
- }
3157
- ], He = Q(xt[0]), Ue = S(() => {
3158
- var V, W, P;
3159
- const m = ((V = e.draft) == null ? void 0 : V.activityLogs) ?? [], l = ((W = e.draft) == null ? void 0 : W.rejectionHistory) ?? [];
3160
- for (const Z of l)
3161
- m.find(
3162
- (ue) => `${ue.action}_${ue.performedAt}` == `${de.enum.rejectDraft}_${Z.rejectedAt}`
3163
- ) || m.push({
3164
- action: de.enum.rejectDraft,
3165
- performedAt: Z.rejectedAt,
3166
- performedBy: Z.rejectedBy,
3167
- remark: Z.rejectRemark
3168
- });
3169
- return (P = e.draft) != null && P.approvedAt && (m.find(
3170
- (le) => {
3171
- var ue;
3172
- return `${le.action}_${le.performedAt}` == `${de.enum.approveDraft}_${(ue = e.draft) == null ? void 0 : ue.approvedAt}`;
3173
- }
3174
- ) || m.push({
3175
- action: de.enum.approveDraft,
3176
- performedAt: e.draft.approvedAt,
3177
- performedBy: e.draft.approvedBy ?? { name: "Unknown", id: "unknown" },
3178
- remark: e.draft.approveRemark
3179
- })), m.sort((Z, le) => new Date(le.performedAt).getTime() - new Date(Z.performedAt).getTime()).map(
3180
- (Z) => ({
3181
- header: Ae(Z.action),
3182
- date: $e(Z.performedAt),
3183
- info: [
3184
- {
3185
- label: "Performed by",
3186
- values: [Z.performedBy.name]
3187
- },
3188
- {
3189
- label: "Remark",
3190
- values: [Z.remark ?? ""]
3191
- }
3192
- ]
3193
- })
3194
- );
3195
- }), ot = Q(!1), at = Q(!1), Vt = S(() => {
3196
- var m;
3197
- return ((m = e.draft) == null ? void 0 : m.status) !== _e.enum.DRAFT ? "Status is not draft." : null;
3198
- });
3199
- function Sn() {
3200
- e.draft && (at.value = !0, r.approveDraft(
3201
- e.draft,
3202
- () => {
3203
- at.value = !1, ot.value = !1, X("submitted");
3204
- },
3205
- () => {
3206
- at.value = !1;
3207
- }
3208
- ));
3209
- }
3210
- return (m, l) => {
3211
- const v = J("FmButtonGroup"), V = J("FmMenuDivider"), W = J("FmCard"), P = J("FmIcon"), Z = J("FmButton"), le = J("FmCircularProgress"), ue = J("FmChip"), se = J("FmTextField"), je = J("FmTable"), Ce = J("FmSpacer"), st = J("FmTooltip"), rt = J("FmSideSheet");
3212
- return p(), C(re, null, [
3213
- D(rt, {
3214
- "dismiss-away": "",
3215
- "max-width": 9999,
3216
- "model-value": f(c),
3217
- "onUpdate:modelValue": l[9] || (l[9] = (q) => vt(c) ? c.value = q : null),
3218
- header: "Closing details"
3219
- }, {
3220
- "side-sheet-footer": te(() => {
3221
- var q, ve, be, Ie;
3222
- return [
3223
- a("div", Zs, [
3224
- a("div", Xs, [
3225
- ((q = e.draft) == null ? void 0 : q.status) === f(_e).enum.DRAFT ? (p(), C(re, { key: 0 }, [
3226
- Vt.value ? (p(), ne(st, {
3227
- key: 0,
3228
- "z-index": 51,
3229
- placement: "right"
3230
- }, {
3231
- content: te(() => [
3232
- fe(N(Vt.value), 1)
3233
- ]),
3234
- default: te(() => [
3235
- D(Z, {
3236
- disabled: "",
3237
- key: "approve key",
3238
- label: "Approve"
3239
- })
3240
- ]),
3241
- _: 1
3242
- })) : (p(), ne(Z, {
3243
- key: "approve key",
3244
- label: "Approve",
3245
- onClick: l[5] || (l[5] = (Ne) => ot.value = !0)
3246
- }))
3247
- ], 64)) : H("", !0),
3248
- ((ve = e.draft) == null ? void 0 : ve.status) === f(_e).enum.DRAFT ? (p(), ne(Z, {
3249
- key: 1,
3250
- label: "Reject",
3251
- variant: "destructive",
3252
- onClick: l[6] || (l[6] = () => e.draft && f(r).rejectDraft(e.draft, () => X("submitted")))
3253
- })) : H("", !0),
3254
- D(Z, {
3255
- label: "Close",
3256
- variant: "tertiary",
3257
- onClick: l[7] || (l[7] = (Ne) => c.value = !1)
3258
- }),
3259
- (be = e.draft) != null && be.approvedAt && ((Ie = e.draft) == null ? void 0 : Ie.status) !== f(_e).enum.COMPLETED ? (p(), ne($t, { key: 2 }, {
3260
- default: te(() => [
3261
- D(Z, {
3262
- label: "Sync",
3263
- loading: y.value,
3264
- onClick: l[8] || (l[8] = () => {
3265
- e.draft && (y.value = !0, f(r).syncDraft(e.draft, () => {
3266
- y.value = !1, X("submitted");
3267
- }));
3268
- })
3269
- }, null, 8, ["loading"])
3270
- ]),
3271
- _: 1
3272
- })) : H("", !0)
3273
- ]),
3274
- a("div", er, [
3275
- l[25] || (l[25] = a("div", { class: "text-xs text-gray-500 uppercase tracking-wide" }, "Total stock take value", -1)),
3276
- a("div", tr, N(o.value) + " " + N(Xe.value.toFixed(2)), 1)
3277
- ])
3278
- ])
3279
- ];
3280
- }),
3281
- default: te(() => [
3282
- a("div", cs, [
3283
- a("div", null, [
3284
- D(v, {
3285
- items: xt,
3286
- modelValue: He.value,
3287
- "onUpdate:modelValue": l[0] || (l[0] = (q) => He.value = q)
3288
- }, null, 8, ["modelValue"])
3289
- ]),
3290
- He.value.value === "overview" ? (p(), C(re, { key: 0 }, [
3291
- D($t, { selectable: "" }, {
3292
- default: te(() => {
3293
- var q;
3294
- return [
3295
- a("div", us, [
3296
- l[12] || (l[12] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, [
3297
- a("div", { class: "flex gap-1" }, "Draft ID")
3298
- ], -1)),
3299
- fe(" " + N((q = m.draft) == null ? void 0 : q._id), 1)
3300
- ])
3301
- ];
3302
- }),
3303
- _: 1
3304
- }),
3305
- D(W, {
3306
- variant: "outlined",
3307
- class: "flex flex-col gap-8 px-12 py-16"
3308
- }, {
3309
- default: te(() => {
3310
- var q, ve;
3311
- return [
3312
- a("div", ds, [
3313
- l[13] || (l[13] = a("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
3314
- a("div", ms, [
3315
- a("div", {
3316
- class: he(["fm-status-badge", f(We)(((q = m.draft) == null ? void 0 : q.status) ?? "DRAFT")])
3317
- }, N(f(Ae)(((ve = m.draft) == null ? void 0 : ve.status) ?? "")), 3)
3318
- ])
3319
- ]),
3320
- D(V),
3321
- a("div", fs, [
3322
- (p(!0), C(re, null, ge(An.value, (be, Ie) => (p(), C("div", {
3323
- class: "flex flex-col gap-4",
3324
- key: Ie
3325
- }, [
3326
- a("div", ps, [
3327
- a("div", vs, N(be.label), 1)
3328
- ]),
3329
- a("div", ys, N(be.value), 1)
3330
- ]))), 128))
3331
- ])
3332
- ];
3333
- }),
3334
- _: 1
3335
- }),
3336
- R.value.length ? (p(), ne(W, {
3337
- key: 0,
3338
- variant: "outlined",
3339
- class: "flex flex-col gap-8 px-12 py-16"
3340
- }, {
3341
- default: te(() => [
3342
- a("div", gs, [
3343
- a("div", bs, "Groups " + N(R.value.length), 1),
3344
- l[14] || (l[14] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Parent totals = sum of all groups ", -1))
3345
- ]),
3346
- D(V),
3347
- D(ha, {
3348
- groups: R.value,
3349
- onSelect: j
3350
- }, null, 8, ["groups"])
3351
- ]),
3352
- _: 1
3353
- })) : H("", !0),
3354
- Cn.value ? (p(), C("div", hs, [
3355
- D(P, {
3356
- name: "rule",
3357
- size: "sm"
3358
- }),
3359
- a("div", _s, [
3360
- l[16] || (l[16] = a("div", { class: "fm-typo-en-body-md-600" }, "UOM notes", -1)),
3361
- a("ul", ks, [
3362
- Mt.value ? (p(), C("li", xs, l[15] || (l[15] = [
3363
- fe(" Measurements highlighted in "),
3364
- a("span", { class: "font-bold" }, "purple", -1),
3365
- fe(" are NetSuite-inactive UOMs (surfaced for audit; their amounts are part of the base total). ")
3366
- ]))) : H("", !0),
3367
- Ut.value ? (p(), C("li", ws, " Red highlights are UOMs not on the SKU (ignored). ")) : H("", !0)
3368
- ])
3369
- ])
3370
- ])) : H("", !0),
3371
- a("div", Ds, [
3372
- a("div", $s, [
3373
- l[17] || (l[17] = a("div", { class: "flex-1 fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, " Closing items ", -1)),
3374
- b.value ? H("", !0) : (p(), C("div", Cs, [
3375
- m.draft && m.draft.status !== f(_e).enum.COMPLETED ? (p(), ne(Z, {
3376
- key: 0,
3377
- label: "Refresh balance",
3378
- "prepend-icon": "refresh",
3379
- variant: "secondary",
3380
- "text-color": "primary",
3381
- "bg-color": "transparent",
3382
- "border-color": "primary",
3383
- loading: f($),
3384
- disabled: f($),
3385
- onClick: Pt
3386
- }, null, 8, ["loading", "disabled"])) : H("", !0),
3387
- D($t, null, {
3388
- default: te(() => [
3389
- D(Z, {
3390
- label: "Invalidate Draft Cache",
3391
- "prepend-icon": "refresh",
3392
- variant: "secondary",
3393
- "text-color": "primary",
3394
- "bg-color": "transparent",
3395
- "border-color": "primary",
3396
- loading: f($),
3397
- onClick: hn
3398
- }, null, 8, ["loading"])
3399
- ]),
3400
- _: 1
3401
- }),
3402
- D(Z, {
3403
- label: "Export data",
3404
- "prepend-icon": "download",
3405
- variant: "secondary",
3406
- "text-color": "primary",
3407
- "bg-color": "transparent",
3408
- "border-color": "primary",
3409
- onClick: l[1] || (l[1] = (q) => m.draft ? f(r).exportDraft(
3410
- m.draft,
3411
- d.value,
3412
- h.value,
3413
- Nt.value
3414
- ) : null)
3415
- })
3416
- ]))
3417
- ]),
3418
- b.value ? (p(), C("div", As, [
3419
- l[19] || (l[19] = a("div", { class: "h-80" }, null, -1)),
3420
- a("div", Ss, [
3421
- a("div", null, [
3422
- D(le, { size: "md" })
3423
- ]),
3424
- l[18] || (l[18] = a("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
3425
- ]),
3426
- l[20] || (l[20] = a("div", { class: "h-80" }, null, -1))
3427
- ])) : (p(), C(re, { key: 1 }, [
3428
- a("div", Fs, [
3429
- a("div", Is, [
3430
- D(ue, {
3431
- label: "Template Item(s)",
3432
- selected: ce.value.templateItem,
3433
- onClick: l[2] || (l[2] = (q) => ce.value.templateItem = !ce.value.templateItem)
3434
- }, null, 8, ["selected"]),
3435
- D(ue, {
3436
- label: "Non-template Item(s)",
3437
- selected: ce.value.nonTemplateItem,
3438
- onClick: l[3] || (l[3] = (q) => ce.value.nonTemplateItem = !ce.value.nonTemplateItem)
3439
- }, null, 8, ["selected"])
3440
- ]),
3441
- D(se, {
3442
- modelValue: _t.value,
3443
- "onUpdate:modelValue": l[4] || (l[4] = (q) => _t.value = q),
3444
- placeholder: "Filter items"
3445
- }, null, 8, ["modelValue"])
3446
- ]),
3447
- f(g).skuTags.size ? (p(), C("div", Bs, [
3448
- (p(!0), C(re, null, ge(f(g).skuTags.keys(), (q) => (p(), ne(ue, {
3449
- key: `${q}`,
3450
- label: `${q}`,
3451
- selectable: "",
3452
- selected: x[`${q}`],
3453
- onClick: (ve) => x[`${q}`] = !x[`${q}`]
3454
- }, {
3455
- default: te(() => [
3456
- x[`${q}`] ? (p(), ne(P, {
3457
- key: 0,
3458
- name: "check",
3459
- class: "text-white",
3460
- size: "sm"
3461
- })) : H("", !0),
3462
- a("span", {
3463
- class: he([
3464
- "",
3465
- {
3466
- "text-white fm-typo-en-body-md-600": x[`${q}`],
3467
- "text-fm-color-typo-primary fm-typo-en-body-md-400": !x[`${q}`]
3468
- }
3469
- ])
3470
- }, N(q), 3)
3471
- ]),
3472
- _: 2
3473
- }, 1032, ["label", "selected", "onClick"]))), 128))
3474
- ])) : H("", !0),
3475
- kt.value.length ? (p(), C("div", Ts, [
3476
- l[21] || (l[21] = a("span", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary self-center" }, "Extra columns:", -1)),
3477
- (p(!0), C(re, null, ge(kt.value, (q) => (p(), ne(ue, {
3478
- key: q,
3479
- label: q,
3480
- selectable: "",
3481
- selected: nt[q],
3482
- onClick: (ve) => nt[q] = !nt[q]
3483
- }, null, 8, ["label", "selected", "onClick"]))), 128))
3484
- ])) : H("", !0),
3485
- a("div", js, [
3486
- a("div", {
3487
- style: mt({ height: "600px", minWidth: `${Dn.value}px` })
3488
- }, [
3489
- D(je, {
3490
- "column-defs": Rt.value,
3491
- "row-data": tt.value,
3492
- "search-value": _t.value
3493
- }, null, 8, ["column-defs", "row-data", "search-value"])
3494
- ], 4)
3495
- ])
3496
- ], 64))
3497
- ])
3498
- ], 64)) : H("", !0),
3499
- He.value.value === "history" ? (p(), C("div", Ps, [
3500
- Ue.value.length ? (p(), C("div", Us, [
3501
- (p(!0), C(re, null, ge(Ue.value, (q, ve) => (p(), C(re, { key: ve }, [
3502
- a("div", Ns, [
3503
- a("div", Vs, [
3504
- a("div", Es, [
3505
- a("div", {
3506
- class: he([
3507
- {
3508
- "bg-fm-color-primary": ve !== 0,
3509
- "bg-white": ve === 0
3510
- },
3511
- "w-[2px] h-full"
3512
- ])
3513
- }, null, 2)
3514
- ]),
3515
- l[24] || (l[24] = a("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
3516
- a("div", Ls, [
3517
- a("div", {
3518
- class: he([
3519
- {
3520
- "bg-fm-color-primary": ve < Ue.value.length - 1,
3521
- "bg-white": ve >= Ue.value.length - 1
3522
- },
3523
- "w-[2px] h-full"
3524
- ])
3525
- }, null, 2)
3526
- ])
3527
- ]),
3528
- a("div", zs, [
3529
- a("div", Os, N(q.header), 1),
3530
- a("div", Gs, N(q.date), 1)
3531
- ])
3532
- ]),
3533
- a("div", Hs, [
3534
- a("div", Ys, [
3535
- a("div", Ks, [
3536
- a("div", {
3537
- class: he([
3538
- {
3539
- "bg-fm-color-primary": ve < Ue.value.length - 1,
3540
- "bg-white": ve >= Ue.value.length - 1
3541
- },
3542
- "w-[2px] h-full"
3543
- ])
3544
- }, null, 2)
3545
- ])
3546
- ]),
3547
- a("div", Ws, [
3548
- D(W, {
3549
- variant: "outlined",
3550
- class: "py-12 px-16"
3551
- }, {
3552
- default: te(() => [
3553
- a("div", qs, [
3554
- (p(!0), C(re, null, ge(q.info, (be, Ie) => (p(), C("div", {
3555
- key: Ie,
3556
- class: "flex flex-col gap-4"
3557
- }, [
3558
- a("div", Qs, N(be == null ? void 0 : be.label), 1),
3559
- a("div", Js, [
3560
- (p(!0), C(re, null, ge(be == null ? void 0 : be.values, (Ne, lt) => (p(), C("div", {
3561
- key: lt,
3562
- class: "fm-typo-en-body-lg-600"
3563
- }, N(Ne), 1))), 128))
3564
- ])
3565
- ]))), 128))
3566
- ])
3567
- ]),
3568
- _: 2
3569
- }, 1024)
3570
- ])
3571
- ])
3572
- ], 64))), 128))
3573
- ])) : (p(), C("div", Rs, [
3574
- D(Ce),
3575
- a("div", null, [
3576
- a("img", {
3577
- src: f(mn),
3578
- alt: "List is empty"
3579
- }, null, 8, Ms)
3580
- ]),
3581
- l[22] || (l[22] = a("div", { class: "fm-typo-en-body-lg-600" }, N("No records found"), -1)),
3582
- l[23] || (l[23] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, N("You can track approval and rejection history here"), -1)),
3583
- D(Ce),
3584
- D(Ce)
3585
- ]))
3586
- ])) : H("", !0)
3587
- ])
3588
- ]),
3589
- _: 1
3590
- }, 8, ["model-value"]),
3591
- f(c) && e.draft ? (p(), ne(la, {
3592
- key: 0,
3593
- show: ot.value,
3594
- "onUpdate:show": l[10] || (l[10] = (q) => ot.value = q),
3595
- refreshing: f($),
3596
- approving: at.value,
3597
- draft: e.draft,
3598
- groups: I.value,
3599
- onRefresh: Pt,
3600
- onApprove: Sn
3601
- }, null, 8, ["show", "refreshing", "approving", "draft", "groups"])) : H("", !0),
3602
- D(is, {
3603
- show: K.value,
3604
- "onUpdate:show": l[11] || (l[11] = (q) => K.value = q),
3605
- group: L.value ?? void 0,
3606
- "parent-name": F.value,
3607
- onUpdated: U
3608
- }, null, 8, ["show", "group", "parent-name"])
3609
- ], 64);
3610
- };
3611
- }
3612
- });
3613
- var xe = /* @__PURE__ */ ((t) => (t.ready = "ready", t.negative = "negative", t.systemNegative = "systemNegative", t))(xe || {});
3614
- async function ar(t) {
3615
- return new Promise((n, e) => {
3616
- const o = new FileReader();
3617
- o.onload = (i) => {
3618
- var s;
3619
- try {
3620
- const r = (s = i.target) == null ? void 0 : s.result, u = to(r, { type: "array" }), c = u.SheetNames[0], b = u.Sheets[c], y = dt.sheet_to_json(b, {
3621
- header: 1,
3622
- defval: ""
3623
- }), I = (j) => String(j).trim().toLowerCase().replace(/^\uFEFF/, ""), E = y.findIndex(
3624
- (j) => j.some((z) => I(z) === "code")
3625
- );
3626
- if (E === -1) {
3627
- n([]);
3628
- return;
3629
- }
3630
- const U = y[E], R = U.findIndex((j) => I(j) === "code"), F = U.findIndex((j) => I(j) === "balance");
3631
- if (R === -1 || F === -1) {
3632
- e(
3633
- new Error(
3634
- `Missing required columns: ${R === -1 ? '"Code" ' : ""}${F === -1 ? '"Balance"' : ""}.`.trim()
3635
- )
3636
- );
3637
- return;
3638
- }
3639
- const K = y.slice(E + 1).filter((j) => String(j[R]).trim()).map((j) => ({
3640
- itemCode: String(j[R]).trim(),
3641
- quantity: Number(j[F]) || 0
3642
- }));
3643
- n(K);
3644
- } catch (r) {
3645
- e(r);
3646
- }
3647
- }, o.onerror = e, o.readAsArrayBuffer(t);
3648
- });
3649
- }
3650
- function sr(t) {
3651
- const n = /* @__PURE__ */ new Map();
3652
- return t.forEach((e) => {
3653
- const o = n.get(e.itemCode) || 0;
3654
- n.set(e.itemCode, o + e.quantity);
3655
- }), n;
3656
- }
3657
- function rr(t, n) {
3658
- const e = [], o = [];
3659
- for (const [i, s] of n.entries()) {
3660
- const r = t[i];
3661
- if (!r) {
3662
- o.push(i);
3663
- continue;
3664
- }
3665
- const u = s < 0 ? "negative" : "ready";
3666
- e.push({
3667
- sku: r,
3668
- physicalCount: s,
3669
- // Note: filled by composable after readStockBalance()
3670
- systemBalance: { amount: 0, precision: 0 },
3671
- variance: s - 0,
3672
- status: u
3673
- });
3674
- }
3675
- return { mergedItems: e, unrecognisedItemCodes: o };
3676
- }
3677
- function lr(t, n) {
3678
- const e = t.filter((c) => !c.isInactive), o = uo().format("YYYY-MM-DD"), i = `${n} - ${o}.csv`, s = [
3679
- ["Code", "Name", "Balance"],
3680
- ...e.map((c) => [c.code, c.name, ""])
3681
- ], r = dt.aoa_to_sheet(s), u = dt.book_new();
3682
- dt.book_append_sheet(u, r, "Template"), eo(u, i, { bookType: "csv" });
3683
- }
3684
- function ir() {
3685
- const t = Q([]), n = Q([]), e = Q(!1), o = Ft(), i = Oe(), s = gt(), r = S(
3686
- () => t.value.some((y) => y.status === xe.negative)
3687
- );
3688
- async function u(y) {
3689
- t.value = [], n.value = [], e.value = !0;
3690
- try {
3691
- const I = await ar(y), E = sr(I), U = o.skuByCode, { mergedItems: R, unrecognisedItemCodes: F } = rr(
3692
- U,
3693
- E
3694
- ), L = await s.readStockBalance(), K = L.skus ?? [];
3695
- K.length === 0 && console.warn(
3696
- "No SKU balances found when importing closing draft. All system balances will be set to 0.",
3697
- {
3698
- stockBalance: L
3699
- }
3700
- );
3701
- const j = new Map(
3702
- K.map((A) => [A.id, A.balance])
3703
- ), z = new Set(R.map((A) => A.sku._id));
3704
- t.value = R.map((A) => {
3705
- const w = j.get(A.sku._id) ?? { amount: 0, precision: 0 }, d = w.amount / Math.pow(10, w.precision);
3706
- return { ...A, systemBalance: w, variance: A.physicalCount - d };
3707
- });
3708
- for (const A of Object.values(o.skuByCode)) {
3709
- if (z.has(A._id)) continue;
3710
- const w = j.get(A._id);
3711
- if (!w) continue;
3712
- const d = w.amount / Math.pow(10, w.precision);
3713
- d >= 0 || t.value.push({
3714
- sku: A,
3715
- physicalCount: 0,
3716
- systemBalance: w,
3717
- variance: 0 - d,
3718
- status: xe.systemNegative
3719
- });
3720
- }
3721
- n.value = F;
3722
- } catch (I) {
3723
- t.value = [], n.value = [], console.error("Error processing uploaded file", { error: I });
3724
- } finally {
3725
- e.value = !1;
3726
- }
3727
- }
3728
- async function c() {
3729
- const y = Me(), I = t.value.filter((K) => K.status === xe.ready), E = t.value.filter(
3730
- (K) => K.status === xe.systemNegative
3731
- ), U = (K) => ({
3732
- sku: {
3733
- _id: K.sku._id,
3734
- code: K.sku.code,
3735
- name: K.sku.name,
3736
- unit: K.sku.unit
3737
- },
3738
- baseAmount: Jn(K.physicalCount, K.sku.unit.precision),
3739
- measurementsAmounts: []
3740
- }), R = I.map(U), F = E.map(U), L = {
3741
- effectiveAt: (/* @__PURE__ */ new Date()).toISOString(),
3742
- items: R,
3743
- negativeStockItems: F
3744
- };
3745
- return await y.createQuickModeDraftWithItems(L);
3746
- }
3747
- function b() {
3748
- var I;
3749
- const y = ((I = i.currentLocation) == null ? void 0 : I.name) ?? "template";
3750
- lr(o.skus, y);
3751
- }
3752
- return { mergedItems: t, unrecognisedItemCodes: n, hasBlockingErrors: r, isLoading: e, onFileUpload: u, submit: c, downloadTemplate: b };
3753
- }
3754
- const cr = { class: "flex flex-col gap-16" }, ur = {
3755
- key: 0,
3756
- class: "px-16 py-12 rounded-8 bg-fm-color-danger-weak text-fm-color-danger-default"
3757
- }, dr = { key: 1 }, mr = { class: "fm-typo-en-label-md-400 cursor-pointer" }, fr = { class: "mt-8 flex flex-col gap-4" }, pr = { key: 2 }, vr = { class: "fm-typo-en-label-md-400 cursor-pointer" }, yr = { class: "mt-8 flex flex-col gap-4" }, gr = /* @__PURE__ */ De({
3758
- __name: "ClosingDraftCreatePreviewTable",
3759
- props: {
3760
- items: {},
3761
- unrecognisedItemCodes: {}
3762
- },
3763
- setup(t) {
3764
- const n = t, { t: e } = Je(), o = S(
3765
- () => n.items.filter((u) => u.status === xe.negative)
3766
- ), i = S(
3767
- () => n.items.filter((u) => u.status === xe.systemNegative)
3768
- ), s = S(() => ({
3769
- [xe.negative]: {
3770
- bgColor: "bg-fm-color-danger-weak",
3771
- textColor: "text-fm-color-danger-default",
3772
- icon: "🚫",
3773
- label: e("inventory.closing.draft.createDraft.previewTable.status.negative")
3774
- },
3775
- [xe.systemNegative]: {
3776
- bgColor: "bg-fm-color-warning-weak",
3777
- textColor: "text-fm-color-warning-default",
3778
- icon: "⚠️",
3779
- label: e("inventory.closing.draft.createDraft.previewTable.status.systemNegative")
3780
- }
3781
- })), r = [
3782
- {
3783
- id: "name",
3784
- header: () => e("inventory.ingredient.name"),
3785
- cell: (u) => u.row.original.sku.name
3786
- },
3787
- {
3788
- id: "uom",
3789
- header: () => e("inventory.closing.draft.createDraft.previewTable.uom"),
3790
- size: 80,
3791
- cell: (u) => u.row.original.sku.unit.abbrev
3792
- },
3793
- {
3794
- id: "systemBalance",
3795
- header: () => e("inventory.closing.draft.createDraft.previewTable.systemBalance"),
3796
- size: 180,
3797
- cell: (u) => {
3798
- const c = u.row.original;
3799
- return _("div", ie(c.systemBalance));
3800
- }
3801
- },
3802
- {
3803
- id: "physicalCount",
3804
- header: () => e("inventory.closing.draft.createDraft.previewTable.stockTakeBalance"),
3805
- cell: (u) => {
3806
- const c = u.row.original;
3807
- return _("div", ie(c.physicalCount));
3808
- }
3809
- },
3810
- {
3811
- id: "variance",
3812
- header: () => e("inventory.closing.draft.createDraft.previewTable.variance"),
3813
- cell: (u) => {
3814
- const b = u.row.original.variance, y = b < 0 ? "text-fm-color-danger-default" : b > 0 ? "text-fm-color-success-default" : "";
3815
- return _("span", { class: y }, ie(b));
3816
- }
3817
- },
3818
- {
3819
- id: "variancePercentage",
3820
- header: () => e("inventory.closing.draft.createDraft.previewTable.variancePercentage"),
3821
- size: 130,
3822
- cell: (u) => {
3823
- const c = u.row.original, b = c.systemBalance.amount / Math.pow(10, c.systemBalance.precision), y = b === 0 ? null : Math.max(
3824
- -100,
3825
- Math.min(100, Math.round(c.variance / Math.abs(b) * 1e4) / 100)
3826
- );
3827
- if (y === null)
3828
- return _(
3829
- "div",
3830
- { class: "flex items-center gap-4 justify-end fm-typo-en-body-md-400" },
3831
- e("inventory.closing.draft.createDraft.previewTable.notApplicable")
3832
- );
3833
- const I = `${ie(y)}`;
3834
- if (y === 0)
3835
- return _(
3836
- "div",
3837
- { class: "flex items-center gap-4 justify-end fm-typo-en-body-md-400" },
3838
- I
3839
- );
3840
- const E = y > 0;
3841
- return _("div", { class: "flex items-center gap-4 justify-end fm-typo-en-body-md-400" }, [
3842
- _(ye.FmIcon, {
3843
- name: E ? "arrow_drop_up" : "arrow_drop_down",
3844
- color: E ? "system-success-300" : "system-error-300",
3845
- size: "md"
3846
- }),
3847
- I
3848
- ]);
3849
- }
3850
- },
3851
- {
3852
- id: "status",
3853
- header: () => e("inventory.common.status"),
3854
- cell: (u) => {
3855
- const c = u.row.original.status, b = s.value[c];
3856
- return b ? _(
3857
- "span",
3858
- {
3859
- class: `px-8 py-2 rounded-4 ${b.bgColor} ${b.textColor} fm-typo-en-label-sm-400`
3860
- },
3861
- `${b.icon} ${b.label}`
3862
- ) : null;
3863
- }
3864
- }
3865
- ];
3866
- return (u, c) => {
3867
- const b = J("FmTable");
3868
- return p(), C("div", cr, [
3869
- o.value.length > 0 ? (p(), C("div", ur, [
3870
- fe(N(f(e)("inventory.closing.draft.createDraft.previewTable.cannotSubmitNegative")) + " ", 1),
3871
- a("strong", null, N(o.value.map((y) => y.sku.code).join(", ")), 1)
3872
- ])) : H("", !0),
3873
- i.value.length > 0 ? (p(), C("details", dr, [
3874
- a("summary", mr, N(f(e)("inventory.closing.draft.createDraft.previewTable.systemNegativeNote", [i.value.length])), 1),
3875
- a("ul", fr, [
3876
- (p(!0), C(re, null, ge(i.value, (y) => (p(), C("li", {
3877
- key: y.sku._id,
3878
- class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
3879
- }, N(y.sku.code), 1))), 128))
3880
- ])
3881
- ])) : H("", !0),
3882
- u.unrecognisedItemCodes.length > 0 ? (p(), C("details", pr, [
3883
- a("summary", vr, N(f(e)("inventory.closing.draft.createDraft.previewTable.unrecognisedNote", [u.unrecognisedItemCodes.length])), 1),
3884
- a("ul", yr, [
3885
- (p(!0), C(re, null, ge(u.unrecognisedItemCodes, (y) => (p(), C("li", {
3886
- key: y,
3887
- class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
3888
- }, N(y), 1))), 128))
3889
- ])
3890
- ])) : H("", !0),
3891
- D(b, {
3892
- "row-data": n.items,
3893
- "column-defs": r,
3894
- pagination: { pageSize: 20 }
3895
- }, null, 8, ["row-data"])
3896
- ]);
3897
- };
3898
- }
3899
- }), br = { class: "flex flex-col gap-16" }, hr = { class: "flex flex-col gap-8" }, _r = { class: "fm-typo-en-body-lg-600" }, kr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, xr = { class: "fm-corner-radius-md p-16 flex items-center gap-16 border border-fm-color-border-default" }, wr = { class: "flex flex-col flex-1 gap-4" }, Dr = { class: "fm-typo-en-body-md-600" }, $r = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Cr = {
3900
- key: 0,
3901
- class: "flex flex-col gap-8"
3902
- }, Ar = { class: "fm-typo-en-body-lg-600" }, Sr = {
3903
- key: 0,
3904
- class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 flex items-center gap-8"
3905
- }, Fr = { class: "grid grid-cols-[repeat(3,1fr)] gap-12" }, Ir = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary flex items-center gap-4" }, Br = { class: "flex items-center gap-8 w-full" }, Tr = /* @__PURE__ */ De({
3906
- __name: "ClosingDraftCreateSideSheet",
3907
- props: {
3908
- show: { type: Boolean }
3909
- },
3910
- emits: ["update:show", "submitted"],
3911
- setup(t, { emit: n }) {
3912
- const e = t, o = n, i = St(e, "show"), { t: s } = Je(), r = ze(), u = Q("upload"), c = Q(null), b = Q(!1), { mergedItems: y, unrecognisedItemCodes: I, hasBlockingErrors: E, isLoading: U, onFileUpload: R, submit: F, downloadTemplate: L } = ir(), K = S(
3913
- () => c.value && !U.value && y.value.length > 0
3914
- ), j = S(() => {
3915
- const d = y.value.filter(
3916
- (O) => O.status === xe.ready
3917
- ).length, h = y.value.filter(
3918
- (O) => O.status === xe.negative
3919
- ).length, B = y.value.filter(
3920
- (O) => O.status === xe.systemNegative
3921
- ).length, M = y.value.filter((O) => O.variance !== 0).length;
3922
- return [
3923
- { label: s("inventory.closing.draft.createDraft.summary.totalItems"), value: y.value.length },
3924
- { label: s("inventory.closing.draft.createDraft.summary.itemsWithCount"), value: d },
3925
- {
3926
- label: s("inventory.closing.draft.createDraft.summary.unrecognisedItems"),
3927
- value: I.value.length,
3928
- isWarning: I.value.length > 0
3929
- },
3930
- { label: s("inventory.closing.draft.createDraft.summary.itemsWithVariance"), value: M },
3931
- { label: s("inventory.closing.draft.createDraft.summary.negativeCounts"), value: h, isError: h > 0 },
3932
- {
3933
- label: s("inventory.closing.draft.createDraft.summary.systemNegative"),
3934
- value: B,
3935
- isWarning: B > 0
3936
- }
3937
- ];
3938
- });
3939
- async function z(d) {
3940
- c.value = d, await R(d);
3941
- }
3942
- async function A() {
3943
- b.value = !0;
3944
- try {
3945
- await F(), w(), o("submitted"), r.open({
3946
- title: "Success",
3947
- message: "Closing draft created successfully",
3948
- type: "success"
3949
- });
3950
- } catch (d) {
3951
- console.error("Failed to create closing draft", { error: d }), r.open({
3952
- title: "Something went wrong",
3953
- message: "Failed to create closing draft. Please try again",
3954
- type: "error"
3955
- });
3956
- } finally {
3957
- b.value = !1;
3958
- }
3959
- }
3960
- Be(i, (d) => {
3961
- d || (u.value = "upload", c.value = null);
3962
- });
3963
- function w() {
3964
- i.value = !1;
3965
- }
3966
- return (d, h) => {
3967
- const B = J("FmCircularProgress"), M = J("FmIcon"), O = J("FmButton"), g = J("FmCard"), k = J("FmSideSheet");
3968
- return p(), ne(k, {
3969
- "dismiss-away": "",
3970
- "max-width": 9999,
3971
- "model-value": f(i),
3972
- "onUpdate:modelValue": h[2] || (h[2] = (x) => vt(i) ? i.value = x : null),
3973
- header: f(s)("inventory.closing.draft.createDraft.title")
3974
- }, {
3975
- default: te(() => [
3976
- a("div", br, [
3977
- u.value === "upload" ? (p(), C(re, { key: 0 }, [
3978
- a("div", hr, [
3979
- a("div", _r, N(f(s)("inventory.closing.draft.createDraft.importCsv")), 1),
3980
- a("div", kr, N(f(s)("inventory.closing.draft.createDraft.uploadDescription")), 1),
3981
- D(mo, {
3982
- class: he({ "h-[200px]": !c.value }),
3983
- accept: ".csv",
3984
- disabled: f(U),
3985
- onFileUpload: z
3986
- }, Vn({ _: 2 }, [
3987
- c.value ? {
3988
- name: "default",
3989
- fn: te(({ openFileDialog: x }) => [
3990
- a("div", xr, [
3991
- f(U) ? (p(), ne(B, {
3992
- key: 0,
3993
- size: "md",
3994
- color: "neutral-gray-200"
3995
- })) : (p(), ne(M, {
3996
- key: 1,
3997
- name: "check_circle",
3998
- color: "system-success-400",
3999
- size: "lg"
4000
- })),
4001
- a("div", wr, [
4002
- a("div", Dr, N(c.value.name), 1),
4003
- a("div", $r, N(f(U) ? f(s)("inventory.closing.draft.createDraft.processing") : f(s)("inventory.closing.draft.createDraft.itemsLoaded", [f(y).length])), 1)
4004
- ]),
4005
- f(U) ? H("", !0) : (p(), ne(O, {
4006
- key: 2,
4007
- label: f(s)("inventory.closing.draft.createDraft.replaceFile"),
4008
- variant: "secondary",
4009
- "prepend-icon": "autorenew",
4010
- onClick: x
4011
- }, null, 8, ["label", "onClick"]))
4012
- ])
4013
- ]),
4014
- key: "0"
4015
- } : void 0
4016
- ]), 1032, ["class", "disabled"])
4017
- ]),
4018
- K.value ? (p(), C("div", Cr, [
4019
- a("div", Ar, N(f(s)("inventory.closing.draft.createDraft.importSummary")), 1),
4020
- f(E) ? (p(), C("div", Sr, [
4021
- D(M, {
4022
- name: "error",
4023
- size: "sm",
4024
- color: "system-error-300"
4025
- }),
4026
- a("span", null, N(f(s)("inventory.closing.draft.createDraft.reviewIssues")), 1)
4027
- ])) : H("", !0),
4028
- D(g, {
4029
- variant: "outlined",
4030
- class: "flex flex-col gap-12 px-16 py-12"
4031
- }, {
4032
- default: te(() => [
4033
- a("div", Fr, [
4034
- (p(!0), C(re, null, ge(j.value, (x) => (p(), C("div", {
4035
- key: x.label,
4036
- class: "flex flex-col gap-4"
4037
- }, [
4038
- a("div", Ir, [
4039
- x.isError ? (p(), ne(M, {
4040
- key: 0,
4041
- name: "error",
4042
- size: "sm",
4043
- color: "system-error-300"
4044
- })) : H("", !0),
4045
- x.isWarning && !x.isError ? (p(), ne(M, {
4046
- key: 1,
4047
- name: "warning",
4048
- size: "sm",
4049
- color: "system-warning-300"
4050
- })) : H("", !0),
4051
- a("span", null, N(x.label), 1)
4052
- ]),
4053
- a("div", {
4054
- class: he([
4055
- "fm-typo-en-body-lg-600",
4056
- {
4057
- "text-fm-color-system-error-300": x.isError,
4058
- "text-fm-color-system-warning-300": x.isWarning && !x.isError
4059
- }
4060
- ])
4061
- }, N(x.value), 3)
4062
- ]))), 128))
4063
- ])
4064
- ]),
4065
- _: 1
4066
- })
4067
- ])) : H("", !0)
4068
- ], 64)) : H("", !0),
4069
- u.value === "preview" ? (p(), ne(gr, {
4070
- key: 1,
4071
- items: f(y),
4072
- "unrecognised-item-codes": f(I)
4073
- }, null, 8, ["items", "unrecognised-item-codes"])) : H("", !0)
4074
- ])
4075
- ]),
4076
- "side-sheet-footer": te(() => [
4077
- a("div", Br, [
4078
- u.value === "preview" ? (p(), ne(O, {
4079
- key: 0,
4080
- variant: "secondary",
4081
- label: f(s)("inventory.common.back"),
4082
- "prepend-icon": "arrow_back",
4083
- onClick: h[0] || (h[0] = (x) => u.value = "upload")
4084
- }, null, 8, ["label"])) : H("", !0),
4085
- u.value === "upload" ? (p(), ne(O, {
4086
- key: 1,
4087
- variant: "primary",
4088
- label: f(s)("inventory.common.next"),
4089
- disabled: !c.value || f(U),
4090
- onClick: h[1] || (h[1] = (x) => u.value = "preview")
4091
- }, null, 8, ["label", "disabled"])) : H("", !0),
4092
- u.value === "preview" ? (p(), ne(fo, {
4093
- key: 2,
4094
- label: f(s)("inventory.closing.draft.createDraft.submit"),
4095
- disabled: f(E) || f(y).length === 0 || b.value,
4096
- loading: b.value,
4097
- "confirm-title": f(s)("inventory.closing.draft.createDraft.confirmTitle"),
4098
- "confirm-message": f(s)("inventory.closing.draft.createDraft.confirmMessage"),
4099
- onConfirm: A
4100
- }, null, 8, ["label", "disabled", "loading", "confirm-title", "confirm-message"])) : H("", !0),
4101
- D(O, {
4102
- variant: "tertiary",
4103
- label: f(s)("inventory.common.close"),
4104
- onClick: w
4105
- }, null, 8, ["label"]),
4106
- u.value === "upload" ? (p(), ne(O, {
4107
- key: 3,
4108
- class: "ml-auto",
4109
- variant: "secondary",
4110
- label: f(s)("inventory.closing.draft.createDraft.downloadTemplate"),
4111
- "prepend-icon": "download",
4112
- onClick: f(L)
4113
- }, null, 8, ["label", "onClick"])) : H("", !0)
4114
- ])
4115
- ]),
4116
- _: 1
4117
- }, 8, ["model-value", "header"]);
4118
- };
4119
- }
4120
- }), jr = ["onClick"], Pr = { class: "flex items-start gap-8" }, Rr = { class: "fm-typo-body-md-400 line-clamp-3 w-full" }, Mr = { class: "flex flex-col gap-8" }, Ur = { class: "flex items-start gap-4" }, Nr = { class: "flex-1 flex flex-col gap-8" }, Vr = { class: "flex flex-col" }, Er = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Lr = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, zr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Or = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Gr = {
4121
- key: 0,
4122
- class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
4123
- }, _l = /* @__PURE__ */ De({
4124
- __name: "ClosingDraftView",
4125
- setup(t) {
4126
- const { t: n } = Je(), { viewDraft: e } = pt(), { viewClosingDraftProps: o, viewClosingDraftShow: i } = Wn(pt()), s = Oe(), r = fn(), u = zn(), { breakpoints: c } = Gn();
4127
- s.watchLocation(r.fetchDrafts);
4128
- const b = S(() => r.loading), y = Q(""), I = Q(!1), E = S(() => c.value.xs || c.value.sm), U = S(() => E.value ? 10 : 20), R = S(
4129
- () => {
4130
- var w;
4131
- return ((w = s._currentLocation) == null ? void 0 : w.type) === Kn.enum.warehouse;
4132
- }
4133
- );
4134
- function F(w) {
4135
- switch (w) {
4136
- case "add":
4137
- return I.value = !0;
4138
- case "refresh":
4139
- return r.fetchDrafts();
4140
- }
4141
- }
4142
- function L(w) {
4143
- return w;
4144
- }
4145
- function K(w) {
4146
- return r.groupsByDraftId[w.original._id] ?? [];
4147
- }
4148
- function j(w) {
4149
- return w.column.columnDef.meta;
4150
- }
4151
- function z(w) {
4152
- const d = Mo(K(w)), h = d.totalAmount.toLocaleString("en-MY", {
4153
- minimumFractionDigits: 2,
4154
- maximumFractionDigits: 2
4155
- });
4156
- return [
4157
- `${d.totalItems} items`,
4158
- `RM ${h}`,
4159
- `${d.groupCount} groups`,
4160
- `${d.completed} completed`,
4161
- `${d.inProgress} in progress`,
4162
- `${d.pending} pending`,
4163
- d.rejected ? `${d.rejected} rejected` : null
4164
- ].filter(Boolean).join(" · ");
4165
- }
4166
- const A = S(() => {
4167
- const w = {
4168
- label: n("inventory.closing.draft.createDraft.title"),
4169
- value: "add",
4170
- isPrimary: !0,
4171
- prependIcon: "add"
4172
- }, d = {
4173
- label: n("inventory.common.refresh"),
4174
- value: "refresh",
4175
- isPrimary: !1
4176
- };
4177
- return [...R.value ? [w] : [], d];
4178
- });
4179
- return (w, d) => {
4180
- const h = J("FmTable");
4181
- return p(), C(re, null, [
4182
- D(On, {
4183
- title: f(n)("inventory.closing.draft.title"),
4184
- actions: A.value,
4185
- "onClick:action": F
4186
- }, {
4187
- default: te(() => [
4188
- a("div", {
4189
- class: he([
4190
- "flex flex-col gap-8 max-h-full",
4191
- {
4192
- "p-0": E.value,
4193
- "px-24 ": !E.value
4194
- }
4195
- ])
4196
- }, [
4197
- D(ro, {
4198
- "change-location": "",
4199
- searchable: "",
4200
- search: y.value,
4201
- "onUpdate:search": d[0] || (d[0] = (B) => y.value = B)
4202
- }, null, 8, ["search"]),
4203
- (p(), ne(h, {
4204
- key: f(r).tableKey,
4205
- style: mt(f(u).tableHeight),
4206
- "column-defs": f(r).columnDefs,
4207
- "row-data": f(r).drafts,
4208
- "search-value": y.value,
4209
- loading: b.value,
4210
- onRowClick: d[1] || (d[1] = (B) => f(e)(B.original)),
4211
- "page-size": U.value
4212
- }, {
4213
- "table-row": te((B) => [
4214
- a("tr", {
4215
- class: "border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm cursor-pointer",
4216
- onClick: (M) => f(e)(B.original)
4217
- }, [
4218
- (p(!0), C(re, null, ge(B.getVisibleCells(), (M) => {
4219
- var O, g, k, x;
4220
- return p(), C("td", {
4221
- key: M.id,
4222
- class: he([
4223
- "h-[56px] text-fm-color-typo-primary align-top",
4224
- ((O = j(M)) == null ? void 0 : O.cellClass) ?? "px-16 py-12"
4225
- ]),
4226
- style: mt({
4227
- width: (g = j(M)) == null ? void 0 : g.width,
4228
- maxWidth: (k = j(M)) == null ? void 0 : k.maxWidth,
4229
- textAlign: ((x = j(M)) == null ? void 0 : x.textAlign) ?? "left"
4230
- })
4231
- }, [
4232
- a("div", Pr, [
4233
- a("span", Rr, [
4234
- D(f(Ye), {
4235
- render: M.column.columnDef.cell,
4236
- props: M.getContext()
4237
- }, null, 8, ["render", "props"])
4238
- ])
4239
- ])
4240
- ], 6);
4241
- }), 128))
4242
- ], 8, jr)
4243
- ]),
4244
- "list-row": te((B) => [
4245
- a("div", Mr, [
4246
- a("div", Ur, [
4247
- D(po, {
4248
- class: "flex-1",
4249
- row: B,
4250
- onRowClick: (M) => f(e)(M)
4251
- }, {
4252
- default: te((M) => {
4253
- var O, g, k, x, ee, X, T, G, $, Y, me, ae, ce, pe, Te, Ze, Ge, Se, Fe, Xe;
4254
- return [
4255
- a("div", Nr, [
4256
- a("div", Vr, [
4257
- a("div", Er, [
4258
- D(f(Ye), {
4259
- render: (k = (g = (O = M._id) == null ? void 0 : O.column) == null ? void 0 : g.columnDef) == null ? void 0 : k.cell,
4260
- props: (ee = (x = M._id) == null ? void 0 : x.getContext) == null ? void 0 : ee.call(x)
4261
- }, null, 8, ["render", "props"])
4262
- ]),
4263
- a("div", Lr, [
4264
- D(f(Ye), {
4265
- render: (G = (T = (X = M.name) == null ? void 0 : X.column) == null ? void 0 : T.columnDef) == null ? void 0 : G.cell,
4266
- props: (Y = ($ = M.name) == null ? void 0 : $.getContext) == null ? void 0 : Y.call($)
4267
- }, null, 8, ["render", "props"])
4268
- ]),
4269
- a("div", zr, N([
4270
- ...B.original.items.slice(0, 3).map((et) => et.sku.name),
4271
- ...B.original.items.length >= 3 ? [`and ${B.original.items.length - 3} more items`] : []
4272
- ].join(", ")), 1),
4273
- a("div", Or, [
4274
- D(f(Ye), {
4275
- render: (ce = (ae = (me = M.ref) == null ? void 0 : me.column) == null ? void 0 : ae.columnDef) == null ? void 0 : ce.cell,
4276
- props: (Te = (pe = M.ref) == null ? void 0 : pe.getContext) == null ? void 0 : Te.call(pe)
4277
- }, null, 8, ["render", "props"])
4278
- ])
4279
- ]),
4280
- K(B).length ? (p(), C("div", Gr, N(z(B)), 1)) : H("", !0),
4281
- a("div", null, [
4282
- D(f(Ye), {
4283
- render: (Se = (Ge = (Ze = M.status) == null ? void 0 : Ze.column) == null ? void 0 : Ge.columnDef) == null ? void 0 : Se.cell,
4284
- props: (Xe = (Fe = M.status) == null ? void 0 : Fe.getContext) == null ? void 0 : Xe.call(Fe)
4285
- }, null, 8, ["render", "props"])
4286
- ])
4287
- ])
4288
- ];
4289
- }),
4290
- _: 2
4291
- }, 1032, ["row", "onRowClick"])
4292
- ])
4293
- ])
4294
- ]),
4295
- _: 1
4296
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
4297
- ], 2)
4298
- ]),
4299
- _: 1
4300
- }, 8, ["title", "actions"]),
4301
- D(Tr, {
4302
- show: I.value,
4303
- "onUpdate:show": d[2] || (d[2] = (B) => I.value = B),
4304
- onSubmitted: f(r).fetchDrafts
4305
- }, null, 8, ["show", "onSubmitted"]),
4306
- (p(), ne(En, { to: "body" }, [
4307
- D(or, Ln(f(o), {
4308
- show: f(i),
4309
- "onUpdate:show": d[3] || (d[3] = (B) => vt(i) ? i.value = B : null),
4310
- onSubmitted: d[4] || (d[4] = () => (i.value = !1, f(r).fetchDrafts())),
4311
- onRefresh: d[5] || (d[5] = (B) => f(r).updateDraftRef(B))
4312
- }), null, 16, ["show"])
4313
- ]))
4314
- ], 64);
4315
- };
4316
- }
4317
- });
4318
- export {
4319
- _l as default
4320
- };