@feedmepos/mf-inventory-portal 0.0.23-dev.9 → 0.0.24-dev.1

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 (140) hide show
  1. package/dist/App-D3sNH2MR.js +276 -0
  2. package/dist/{ApprovalView-e85YmdZN.js → ApprovalView-DHnRx0hJ.js} +17 -20
  3. package/dist/{BindingsDialog-giBUD0IH.js → BindingsDialog-oTeg2Dai.js} +6 -6
  4. package/dist/{BindingsPicker-CC4MmPbF.js → BindingsPicker-CWdjmMJ3.js} +8 -9
  5. package/dist/{BindingsTable-WphZdzrA.js → BindingsTable-bKLR1OKX.js} +18 -22
  6. package/dist/ClosingDraftView-CIQVz7lY.js +1225 -0
  7. package/dist/{ClosingTemplateView-1lzoDyet.js → ClosingTemplateView-D5pLzQwU.js} +259 -274
  8. package/dist/FmCustomAttribute.vue_vue_type_script_setup_true_lang-ClLDcchC.js +142 -0
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Cv-vvzr5.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B_c6Vn6P.js} +23 -24
  10. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DIFQcrc0.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DhpHOaRH.js} +50 -51
  11. package/dist/{IngredientGroupView-UegBM_JK.js → IngredientGroupView-4C437mso.js} +63 -70
  12. package/dist/IngredientsView-DoiGgjre.js +1706 -0
  13. package/dist/{IntegrationView-FYNNzKia.js → IntegrationView-8ZKE7MAM.js} +123 -126
  14. package/dist/{InventoryBindingForm-DsHv_IHG.js → InventoryBindingForm-CcnfliYQ.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BURSXafS.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-B_J-6C9x.js} +116 -108
  16. package/dist/{InventoryBindingSummary-BLb4MRPZ.js → InventoryBindingSummary-CRdHCzNE.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BG78-DHs.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-B2-TypU0.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CqID5_7v.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BuQde75S.js} +20 -21
  19. package/dist/PublishView-t5gjGmK_.js +192 -0
  20. package/dist/{PurchaseOrderPrintPreview-BBMU3teq.js → PurchaseOrderPrintPreview-6i53Y-v1.js} +13 -14
  21. package/dist/ReceiveRequestView-uOeSh0Mr.js +1866 -0
  22. package/dist/RecipeView-BTWywckD.js +609 -0
  23. package/dist/StockView-DN2xk8ei.js +1817 -0
  24. package/dist/{SupplierView-B2aObtwK.js → SupplierView-l0XUg3J4.js} +185 -196
  25. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CWMn6fFf.js +1327 -0
  26. package/dist/TransferTemplateView-wDKXpCWZ.js +1263 -0
  27. package/dist/UnitView-CUI-k-tS.js +648 -0
  28. package/dist/{WarehouseView-G8pej6Y2.js → WarehouseView-WsI_eG5r.js} +190 -197
  29. package/dist/api/adjustment-template.d.ts +25 -0
  30. package/dist/api/bill.d.ts +240 -84
  31. package/dist/api/inventory.d.ts +19 -6
  32. package/dist/api/netsuite.d.ts +3 -3
  33. package/dist/app-DntcWR3_.js +85558 -0
  34. package/dist/app.d.ts +85 -0
  35. package/dist/app.js +2 -2
  36. package/dist/components/FmCustomAttribute.vue.d.ts +23 -0
  37. package/dist/components/FmLockableField.vue.d.ts +37 -0
  38. package/dist/components/FmMultiselectDialogProps.d.ts +1 -0
  39. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +3 -1
  40. package/dist/components/shell/inventory/binding-ui.vue.d.ts +3 -1
  41. package/dist/composable/defineDeepModel.d.ts +1 -1
  42. package/dist/{decimal-DC07xoJW.js → decimal-DTCTnMwO.js} +1 -1
  43. package/dist/format-unit-display-Hy48Iw5j.js +1215 -0
  44. package/dist/index-Bv9RYyTZ.js +29202 -0
  45. package/dist/{StockView-C5btudss.js → index-D4yJP9I2.js} +2220 -3863
  46. package/dist/layout/SingleColumnLayout.vue.d.ts +1 -0
  47. package/dist/router/name.d.ts +2 -0
  48. package/dist/stock-BsdmfT-b.js +125 -0
  49. package/dist/stores/feature.d.ts +41 -1
  50. package/dist/stores/integration/netsuite.d.ts +3 -2
  51. package/dist/stores/inventory.d.ts +20 -8
  52. package/dist/stores/location.d.ts +29 -1
  53. package/dist/stores/supplier.d.ts +1 -1
  54. package/dist/style.css +1 -1
  55. package/dist/supplier-CXhkgC4M.js +77 -0
  56. package/dist/tsconfig.app.tsbuildinfo +1 -1
  57. package/dist/{use-inventory-binding-dialog-B0G2XYSw.js → use-inventory-binding-dialog-DPMJmBCr.js} +10 -11
  58. package/dist/views/adjustment-template/import/AdjustmentTemplateImport.vue.d.ts +2 -0
  59. package/dist/views/adjustment-template/import/AdjustmentTemplateImportItem.vue.d.ts +18 -0
  60. package/dist/views/adjustment-template/import/export.d.ts +60 -0
  61. package/dist/views/adjustment-template/wastage-template/WastageTemplateDetails.vue.d.ts +2 -0
  62. package/dist/views/adjustment-template/wastage-template/WastageTemplateDialog.vue.d.ts +22 -0
  63. package/dist/views/adjustment-template/wastage-template/WastageTemplatePublish.vue.d.ts +6 -0
  64. package/dist/views/adjustment-template/wastage-template/WastageTemplateReason.vue.d.ts +18 -0
  65. package/dist/views/adjustment-template/wastage-template/WastageTemplateView.vue.d.ts +2 -0
  66. package/dist/views/adjustment-template/wastage-template/actions.d.ts +1377 -0
  67. package/dist/views/adjustment-template/wastage-template/form/WastageTemplateForm.vue.d.ts +16 -0
  68. package/dist/views/adjustment-template/wastage-template/form/WastageTemplateItemTable.vue.d.ts +35 -0
  69. package/dist/views/adjustment-template/wastage-template/form/useAdjustmentTemplateItems.d.ts +20 -0
  70. package/dist/views/adjustment-template/wastage-template/props.d.ts +36 -0
  71. package/dist/views/adjustment-template/wastage-template/table.d.ts +1351 -0
  72. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +198 -12
  73. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +7 -4
  74. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +1559 -467
  75. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +19 -0
  76. package/dist/views/closing-draft/helpers/get-calculated-total.helper.d.ts +4 -0
  77. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +2 -1
  78. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +72 -12
  79. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +73 -13
  80. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +6 -3
  81. package/dist/views/ingredients/components/convert/ConvertFormProps.d.ts +1 -0
  82. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +4 -2
  83. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +1 -0
  84. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +2 -1
  85. package/dist/views/publish/PublishView.vue.d.ts +2 -0
  86. package/dist/views/receive-request/components/netsuite/NetSuiteInfo.vue.d.ts +12 -0
  87. package/dist/views/receive-request/components/netsuite/NetSuiteProps.d.ts +13 -0
  88. package/dist/views/receive-request/components/netsuite/NetSuiteSync.vue.d.ts +12 -0
  89. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +13 -0
  90. package/dist/views/receive-request/components/transfer-form/SparkIcon.vue.d.ts +1 -1
  91. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +86 -17
  92. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +4 -2
  93. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +2 -1
  94. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +126 -24
  95. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +126 -24
  96. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +2 -0
  97. package/dist/views/stock/components/StockRecordCard.vue.d.ts +120 -42
  98. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +6 -4
  99. package/dist/views/stock/helper/compute-summary-total.d.ts +2 -2
  100. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +4 -0
  101. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +2 -1
  102. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +72 -12
  103. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +72 -12
  104. package/dist/views/transfer-template/helpers/import-export.helper.d.ts +2 -1
  105. package/dist/vue-i18n-ByVzHsI7.js +2365 -0
  106. package/package.json +5 -4
  107. package/dist/App-ByLgARNp.js +0 -259
  108. package/dist/ClosingDraftView-CQM1Sx45.js +0 -755
  109. package/dist/FmDroppableField-8RzKjEdL.js +0 -154
  110. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BvkN-71q.js +0 -436
  111. package/dist/FmMultiselectDialog-DScMA6iG.js +0 -415
  112. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-t4pim_k9.js +0 -51
  113. package/dist/IngredientsView-BfW-jZLM.js +0 -1666
  114. package/dist/ReceiveRequestView-vbANEzne.js +0 -4165
  115. package/dist/RecipeView-DW4DY0C0.js +0 -598
  116. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js +0 -135
  117. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-B2LOvVef.js +0 -1229
  118. package/dist/TransferTemplateView-BKumN_p6.js +0 -1262
  119. package/dist/UnitView-CHLucv9s.js +0 -648
  120. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +0 -9
  121. package/dist/app-BXjk74IB.js +0 -33538
  122. package/dist/date2-CWAt9bRf.js +0 -117
  123. package/dist/dayjs.min-D3jPOnu6.js +0 -282
  124. package/dist/defineDeepModel-CiD4GtOw.js +0 -13
  125. package/dist/feature-6tcLMotY.js +0 -92
  126. package/dist/form-mode.enum-BKiNVH6A.js +0 -4
  127. package/dist/format-time-from-id-CYU5Z9Mt.js +0 -15
  128. package/dist/format-unit-display-CY-0bznr.js +0 -1217
  129. package/dist/fuzzy-BMkhNYLR.js +0 -41
  130. package/dist/index-BXwQa14X.js +0 -45
  131. package/dist/index-CRLd5xyg.js +0 -22283
  132. package/dist/index-DqwAtOgI.js +0 -12087
  133. package/dist/netsuite-fYUUk_ss.js +0 -225
  134. package/dist/row-action.enum-7rGLGZ5v.js +0 -55
  135. package/dist/rules-BmRGm3yv.js +0 -203
  136. package/dist/stock-CEX0DP2B.js +0 -111
  137. package/dist/supplier-CdJmZr7w.js +0 -77
  138. package/dist/use-template-enabled-locations-2-xbPJWHCs.js +0 -86
  139. package/dist/xlsx-CTOKp7SQ.js +0 -24004
  140. package/dist/xlsx.util-D5NFSfDg.js +0 -78
@@ -0,0 +1,1225 @@
1
+ import { defineComponent as ye, ref as O, resolveComponent as E, openBlock as _, createBlock as ne, withCtx as N, createElementVNode as o, createTextVNode as ge, toDisplayString as L, unref as h, createVNode as D, h as $, computed as M, onMounted as He, watch as ze, isRef as _e, createElementBlock as F, Fragment as W, createCommentVNode as le, normalizeClass as ie, renderList as ue, normalizeStyle as we, Teleport as Ee, mergeProps as Le } from "vue";
2
+ import { X as Ne, u as be, af as q, m as Oe, K as he, j as C, t as Ve, L as ce, q as Ke, r as Ye, s as Ge, ag as ke, ah as je, a3 as Ce, ai as Se, aj as oe, a9 as qe, ae as X, V as Be, D as De, i as de, h as Ze, f as We, a as Xe, z as Je, _ as Qe, B as et, E as tt, G as me } from "./app-DntcWR3_.js";
3
+ import { useCoreStore as at, useI18n as Fe } from "@feedmepos/mf-common";
4
+ import { useSnackbar as Ae, useDialog as nt, useProxiedModel as ot, components as ae, useBreakpoints as st } from "@feedmepos/ui-library";
5
+ import { defineStore as Re, storeToRefs as rt } from "pinia";
6
+ import { u as $e } from "./stock-BsdmfT-b.js";
7
+ import { E as lt } from "./empty-placeholder-wf6-BWE8.js";
8
+ const Te = Ne((n, d) => {
9
+ function e() {
10
+ return be().currentLocation.dbName;
11
+ }
12
+ return {
13
+ async getDraft(u) {
14
+ const m = e(), g = `${n.inventoryBackendUrl}/${m}/closing-draft/${u}`;
15
+ return d.get(g);
16
+ },
17
+ async readDrafts() {
18
+ const u = e(), m = `${n.inventoryBackendUrl}/${u}/closing-draft`;
19
+ return d.get(m);
20
+ },
21
+ async runOperation(u) {
22
+ const m = e(), g = `${n.inventoryBackendUrl}/${m}/closing-draft/run-operation`;
23
+ return d.post(g, u);
24
+ }
25
+ };
26
+ }), it = { class: "fm-typo-en-body-lg-400" }, ct = { class: "fm-typo-en-body-lg-600" }, ut = { class: "flex gap-12 py-8 justify-end w-full" }, xe = /* @__PURE__ */ ye({
27
+ __name: "ClosingDraftAction",
28
+ props: {
29
+ draft: {},
30
+ action: {},
31
+ onCancel: { type: Function },
32
+ onFinished: { type: Function }
33
+ },
34
+ setup(n) {
35
+ const d = n, e = O(), u = Te(), m = Ae(), g = O(!1);
36
+ async function x() {
37
+ g.value = !0;
38
+ try {
39
+ await u.runOperation({
40
+ _id: d.draft._id,
41
+ _rev: d.draft._rev ?? "",
42
+ action: d.action,
43
+ data: {
44
+ remark: e.value
45
+ }
46
+ }).delayed(500), m.open({
47
+ title: "Success",
48
+ message: "Action submitted",
49
+ type: "success"
50
+ }), d.onFinished();
51
+ } catch (l) {
52
+ m.open({
53
+ title: "Something went wrong",
54
+ message: "Unable to submit actino. Please try again",
55
+ type: "error"
56
+ }), console.error("error on submit closing draft aciont", l);
57
+ } finally {
58
+ g.value = !1;
59
+ }
60
+ }
61
+ return (l, b) => {
62
+ const R = E("FmTextField"), P = E("FmButton"), T = E("FmForm");
63
+ return _(), ne(T, {
64
+ onValidationSuccess: x,
65
+ class: "flex flex-col gap-32",
66
+ disabled: g.value
67
+ }, {
68
+ default: N(() => [
69
+ o("div", it, [
70
+ b[2] || (b[2] = ge(" You are about to ")),
71
+ o("span", ct, L(l.action == h(q).enum.approveDraft ? "approve" : "reject"), 1),
72
+ b[3] || (b[3] = ge(" this draft. Please provider a remark to justify this action. "))
73
+ ]),
74
+ D(R, {
75
+ modelValue: e.value,
76
+ "onUpdate:modelValue": b[0] || (b[0] = (r) => e.value = r),
77
+ label: "Remark",
78
+ "label-mark": "required",
79
+ rules: [h(Oe)()]
80
+ }, null, 8, ["modelValue", "rules"]),
81
+ o("div", ut, [
82
+ D(P, {
83
+ label: "Cancel",
84
+ variant: "tertiary",
85
+ onClick: b[1] || (b[1] = (r) => l.onCancel())
86
+ }),
87
+ D(P, {
88
+ label: l.action == h(q).enum.approveDraft ? "Approve" : "Reject",
89
+ type: "submit",
90
+ variant: l.action == h(q).enum.approveDraft ? "primary" : "destructive",
91
+ loading: g.value
92
+ }, null, 8, ["label", "variant", "loading"])
93
+ ])
94
+ ]),
95
+ _: 1
96
+ }, 8, ["disabled"]);
97
+ };
98
+ }
99
+ }), dt = ce(0);
100
+ function Me(n) {
101
+ const d = n.measurementsAmounts.groupBy((u) => u.measurement.id), e = n.sku.unit.measurements.reduce((u, m) => {
102
+ var l, b;
103
+ const g = ((b = (l = d.get(m.id)) == null ? void 0 : l[0]) == null ? void 0 : b.amount) ?? dt, x = he(m.conversion, g);
104
+ return u + +C(x);
105
+ }, +C(n.baseAmount));
106
+ return Ve(e, n.baseAmount.precision);
107
+ }
108
+ const mt = ce(0), ft = ce(100);
109
+ function pt(n, d) {
110
+ const e = Me(n), u = ke(e, d), m = d.amount === 0 ? null : je(u, {
111
+ ...d,
112
+ amount: Math.abs(d.amount)
113
+ }), g = m ? he(m, ft) : null;
114
+ return {
115
+ code: n.sku.code,
116
+ name: n.sku.name,
117
+ baseUnit: n.sku.unit.abbrev,
118
+ baseUnitAmount: +C(n.baseAmount),
119
+ ...n.measurementsAmounts.filter((l) => Pe(l.measurement)).reduce(
120
+ (l, b, R) => (l[`measurementAbbrev${R}`] = `(${b.measurement.abbrev}) × ${C(b.measurement.conversion)}`, l[`measurementAmount${R}`] = +C(b.amount), l),
121
+ {}
122
+ ),
123
+ systemBalance: +C(d),
124
+ physicalBalance: +C(e),
125
+ adjustedAmount: +C(u),
126
+ adjustedDiffPercentage: g ? +C(Ce(g, 2)) : null
127
+ };
128
+ }
129
+ function Pe(n) {
130
+ return !n.abbrev.toLocaleLowerCase().includes("inactive");
131
+ }
132
+ function vt(n) {
133
+ return n.reduce(
134
+ (d, e) => Math.max(d, e.sku.unit.measurements.filter(Pe).length),
135
+ 0
136
+ );
137
+ }
138
+ function gt(n) {
139
+ return [
140
+ {
141
+ id: "code",
142
+ name: "Code"
143
+ },
144
+ {
145
+ id: "name",
146
+ name: "Name"
147
+ },
148
+ {
149
+ id: "unit",
150
+ name: "Base unit amount"
151
+ },
152
+ {
153
+ id: "baseUnit",
154
+ name: "Base unit"
155
+ },
156
+ ...Array.from({ length: n }).flatMap((e, u) => [
157
+ {
158
+ id: `measurementAmount${u}`,
159
+ name: `UOM amount ${u + 1}`
160
+ },
161
+ {
162
+ id: `measurementAbbrev${u}`,
163
+ name: `UOM ${u + 1}`
164
+ }
165
+ ]),
166
+ {
167
+ id: "physicalBalance",
168
+ name: "Total balance"
169
+ },
170
+ {
171
+ id: "systemBalance",
172
+ name: "System balance"
173
+ },
174
+ {
175
+ id: "adjustedAmount",
176
+ name: "Adjusted amount"
177
+ },
178
+ {
179
+ id: "adjustedDiffPercentage",
180
+ name: "Diff (%)"
181
+ }
182
+ ];
183
+ }
184
+ function yt(n, d) {
185
+ var s, v, U, S, w, V, B;
186
+ const e = d.groupBy(
187
+ (y) => y.id,
188
+ (y) => y.balance
189
+ ), u = [...n.items, ...n.negativeStockItems ?? []], m = u.map((y) => {
190
+ var J;
191
+ const K = ((J = e.get(y.sku._id)) == null ? void 0 : J[0]) ?? mt;
192
+ return pt(y, K);
193
+ }), g = vt(u), l = at().currentBusiness.value, b = gt(g), R = [
194
+ ["Business name:", l == null ? void 0 : l.name],
195
+ ["Business ID:", l == null ? void 0 : l._id],
196
+ ["Menu version", l == null ? void 0 : l.menuVersion],
197
+ ["Created at", new Date(n.createdAt)],
198
+ ["Created by", (s = n.createdBy) == null ? void 0 : s.name],
199
+ ["Updated at", new Date(n.updatedAt)],
200
+ ["Updated by", (v = n.updatedBy) == null ? void 0 : v.name],
201
+ ["Recent action", n.approvedAt ? "Approve" : n.rejectionHistory ? "Reject" : ""],
202
+ [
203
+ "Action by",
204
+ n.approvedAt ? (U = n.approvedBy) == null ? void 0 : U.name : n.rejectionHistory ? (w = (S = n.rejectionHistory[0]) == null ? void 0 : S.rejectedBy) == null ? void 0 : w.name : ""
205
+ ],
206
+ [
207
+ "Action at",
208
+ n.approvedAt ? new Date(n.approvedAt) : n.rejectionHistory ? new Date((V = n.rejectionHistory[0]) == null ? void 0 : V.rejectedAt) : ""
209
+ ],
210
+ [
211
+ "Action remark",
212
+ n.approvedAt ? n.approveRemark : n.rejectionHistory ? new Date((B = n.rejectionHistory[0]) == null ? void 0 : B.rejectRemark) : ""
213
+ ],
214
+ [],
215
+ b.map((y) => y.name),
216
+ ...m.map((y) => b.map((K) => y[K.id]))
217
+ ], P = b.map((y) => `system:${y.id}`), T = Ke(R, P), r = `[${l == null ? void 0 : l.name}] closing draft (${Ye(new Date(n.updatedAt))}).xlsx`;
218
+ return Ge(T, r), r;
219
+ }
220
+ const pe = Re(
221
+ "closingDraftActions",
222
+ function() {
223
+ const d = nt(), e = Ae(), u = Se(), m = $e(), g = O(!1), x = O();
224
+ function l(s) {
225
+ const v = {
226
+ draft: s
227
+ };
228
+ x.value = v, g.value = !0;
229
+ }
230
+ async function b(s) {
231
+ var U;
232
+ if (s.status === oe.enum.COMPLETED) {
233
+ const S = s.closingId;
234
+ if (!S)
235
+ return e.open({
236
+ title: "Something went wrong",
237
+ message: "Closing draft is completed but closing document cannot be found.",
238
+ type: "error"
239
+ }), console.error("Closing draft is completed but closing document cannot be found.", {
240
+ draftId: s == null ? void 0 : s._id
241
+ }), [];
242
+ const w = await u.getClosingById(S);
243
+ return (w == null ? void 0 : w.skus) ?? [];
244
+ } else
245
+ return await m.readStockBalance(), ((U = m.stockBalance) == null ? void 0 : U.skus) ?? [];
246
+ }
247
+ async function R(s, v) {
248
+ v || (e.open({
249
+ title: "Exporting",
250
+ message: "Fetching data..."
251
+ }), v = await b(s)), yt(s, v);
252
+ }
253
+ function P(s, v) {
254
+ d.open({
255
+ title: "Approve draft",
256
+ contentComponent: xe,
257
+ contentComponentProps: {
258
+ draft: s,
259
+ action: q.enum.approveDraft,
260
+ onFinished: () => {
261
+ d.close(), v == null || v();
262
+ },
263
+ onCancel: () => d.close()
264
+ }
265
+ });
266
+ }
267
+ function T(s, v) {
268
+ d.open({
269
+ title: "Reject draft",
270
+ contentComponent: xe,
271
+ contentComponentProps: {
272
+ draft: s,
273
+ action: q.enum.rejectDraft,
274
+ onFinished: () => {
275
+ d.close(), v == null || v();
276
+ },
277
+ onCancel: () => d.close()
278
+ }
279
+ });
280
+ }
281
+ function r() {
282
+ g.value = !1;
283
+ }
284
+ return {
285
+ viewDraft: l,
286
+ closeDraftDialog: r,
287
+ approveDraft: P,
288
+ rejectDraft: T,
289
+ exportDraft: R,
290
+ viewClosingDraftShow: g,
291
+ viewClosingDraftProps: x
292
+ };
293
+ }
294
+ );
295
+ function fe(n) {
296
+ switch (n) {
297
+ case "DRAFT":
298
+ return "fm-status-badge-draft";
299
+ case "PROCESSING":
300
+ return "fm-status-badge-processing";
301
+ case "FAILED":
302
+ return "fm-status-badge-cancel";
303
+ case "COMPLETED":
304
+ return "fm-status-badge-complete";
305
+ }
306
+ }
307
+ const bt = Re(
308
+ "closingDraftTable",
309
+ function() {
310
+ const { t: d } = Fe(), e = pe(), u = O(new Array()), m = O(!1), g = be(), x = Te();
311
+ async function l() {
312
+ if (u.value = [], !!g._currentLocation) {
313
+ m.value = !0;
314
+ try {
315
+ const [r] = await Promise.all([x.readDrafts()]).delayed(1e3);
316
+ u.value = r.reverse();
317
+ } catch (r) {
318
+ console.log("Something went wrong when fetching drafts:", r);
319
+ } finally {
320
+ m.value = !1;
321
+ }
322
+ }
323
+ }
324
+ async function b(r) {
325
+ if (!u.value.find((s) => s._id) && g._currentLocation) {
326
+ m.value = !0;
327
+ try {
328
+ const [s] = await Promise.all([
329
+ x.getDraft(r),
330
+ new Promise((v) => setTimeout(v, 1e3))
331
+ ]);
332
+ u.value = [s];
333
+ } catch (s) {
334
+ console.log("Something went wrong when fetching drafts:", s);
335
+ } finally {
336
+ m.value = !1;
337
+ }
338
+ }
339
+ }
340
+ function R() {
341
+ e.closeDraftDialog(), l();
342
+ }
343
+ function P(r, s) {
344
+ switch (s = We(s), r) {
345
+ case de.Details:
346
+ return e.viewDraft(s);
347
+ case de.Export:
348
+ return e.exportDraft(s);
349
+ case q.enum.approveDraft:
350
+ return e.approveDraft(s, R);
351
+ case q.enum.rejectDraft:
352
+ return e.rejectDraft(s, R);
353
+ }
354
+ }
355
+ return {
356
+ columnDefs: [
357
+ {
358
+ id: "_id",
359
+ accessorKey: "_id",
360
+ header: () => d("inventory.closing.table.createdAt"),
361
+ cell(r) {
362
+ return qe(`${r.getValue()}`);
363
+ },
364
+ enableSorting: !0
365
+ },
366
+ {
367
+ id: "updatedAt",
368
+ accessorFn: (r) => X(r.updatedAt),
369
+ header: () => "Updated at",
370
+ enableSorting: !0,
371
+ size: 200
372
+ },
373
+ {
374
+ id: "updatedBy",
375
+ accessorKey: "updatedBy.name",
376
+ header: () => "Last update by",
377
+ enableSorting: !0,
378
+ size: 200
379
+ },
380
+ {
381
+ id: "noOfItems",
382
+ accessorFn: (r) => {
383
+ var s;
384
+ return r.items.length + (((s = r.negativeStockItems) == null ? void 0 : s.length) ?? 0);
385
+ },
386
+ header: () => d("inventory.closing.table.noOfItems"),
387
+ enableSorting: !1,
388
+ meta: {
389
+ width: "10rem",
390
+ textAlign: "right"
391
+ }
392
+ },
393
+ {
394
+ id: "recentRemark",
395
+ accessorFn: (r) => {
396
+ var s;
397
+ return (r == null ? void 0 : r.approveRemark) ?? ((s = r == null ? void 0 : r.rejectionHistory) == null ? void 0 : s.computeFirst((v) => v.rejectRemark)) ?? r.remark;
398
+ },
399
+ header: () => "Recent remark"
400
+ },
401
+ {
402
+ id: "status",
403
+ accessorFn: (r) => r.status,
404
+ header: () => d("inventory.closing.table.status"),
405
+ enableSorting: !1,
406
+ cell(r) {
407
+ var V;
408
+ const s = r.row.original, v = s.status, U = new Date(s.updatedAt), S = (V = s == null ? void 0 : s.rejectionHistory) == null ? void 0 : V.computeFirst((B) => B.rejectedAt), w = S ? new Date(S) : null;
409
+ return v === "DRAFT" && w ? w.getTime() > U.getTime() ? $(
410
+ "div",
411
+ {
412
+ class: "flex"
413
+ },
414
+ $(
415
+ "div",
416
+ {
417
+ class: ["fm-status-badge", fe("FAILED")]
418
+ },
419
+ "Rejected"
420
+ )
421
+ ) : $(
422
+ "div",
423
+ {
424
+ class: "flex"
425
+ },
426
+ $(
427
+ "div",
428
+ {
429
+ class: ["fm-status-badge", fe("PROCESSING")]
430
+ },
431
+ "Updated"
432
+ )
433
+ ) : $(
434
+ "div",
435
+ {
436
+ class: "flex"
437
+ },
438
+ $(
439
+ "div",
440
+ {
441
+ class: ["fm-status-badge", fe(v)]
442
+ },
443
+ Be(v)
444
+ )
445
+ );
446
+ }
447
+ },
448
+ {
449
+ id: "action",
450
+ cell(r) {
451
+ const s = r.row.original, v = [
452
+ De[de.Details],
453
+ De[de.Export]
454
+ ], U = [
455
+ {
456
+ translationKey: "inventory.closing.draft.approveDraft",
457
+ color: "text-fm-color-typo-primary",
458
+ value: q.enum.approveDraft
459
+ },
460
+ {
461
+ translationKey: "inventory.closing.draft.rejectDraft",
462
+ color: "text-fm-color-typo-error",
463
+ value: q.enum.rejectDraft
464
+ }
465
+ ];
466
+ return Ze(
467
+ [
468
+ ...v,
469
+ ...s.status === oe.enum.DRAFT ? U : []
470
+ ],
471
+ (S) => P(S, s)
472
+ );
473
+ },
474
+ enableSorting: !1,
475
+ size: 40,
476
+ meta: {
477
+ cellClass: "",
478
+ headerClass: ""
479
+ }
480
+ }
481
+ ],
482
+ drafts: u,
483
+ loading: m,
484
+ fetchDrafts: l,
485
+ loadDraft: b
486
+ };
487
+ }
488
+ ), ht = { class: "w-full flex flex-col gap-32" }, At = { class: "flex justify-between" }, Dt = { class: "flex" }, xt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _t = { class: "flex gap-1" }, wt = { class: "fm-typo-en-body-lg-600" }, kt = { class: "flex flex-col gap-16" }, jt = { class: "flex" }, Ct = { key: 0 }, St = {
489
+ key: 0,
490
+ class: "w-full flex flex-col items-center"
491
+ }, Bt = { class: "flex items-center gap-8" }, Ft = {
492
+ key: 1,
493
+ class: "overflow-x-auto"
494
+ }, Rt = {
495
+ key: 1,
496
+ class: "flex-1 xs:w-screen xs:max-w-full"
497
+ }, $t = {
498
+ key: 0,
499
+ class: "flex flex-col items-center gap-8 h-full"
500
+ }, Tt = ["src"], Mt = {
501
+ key: 1,
502
+ class: "px-4 flex flex-col"
503
+ }, Pt = { class: "flex gap-12 content-stretch" }, It = {
504
+ class: "flex flex-col w-24",
505
+ name: "circles"
506
+ }, Ut = { class: "flex-1 flex flex-col items-center" }, Ht = { class: "flex-1 flex flex-col items-center" }, zt = {
507
+ class: "py-12 flex flex-col gap-4",
508
+ name: "received-at header"
509
+ }, Et = { class: "fm-typo-en-body-lg-400" }, Lt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Nt = { class: "flex gap-12 content-stretch" }, Ot = {
510
+ class: "flex flex-col w-24",
511
+ name: "circles"
512
+ }, Vt = { class: "flex-1 flex flex-col items-center" }, Kt = {
513
+ class: "py-12 flex flex-col gap-4 flex-1",
514
+ name: "delivery details"
515
+ }, Yt = { class: "flex flex-col gap-8" }, Gt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, qt = { class: "flex flex-col gap-4" }, Zt = { class: "flex gap-8" }, Wt = /* @__PURE__ */ ye({
516
+ __name: "ClosingDraftDialog",
517
+ props: {
518
+ show: { type: Boolean },
519
+ draft: {}
520
+ },
521
+ emits: ["submitted"],
522
+ setup(n, { emit: d }) {
523
+ const e = n, u = $e(), m = pe(), g = ot(e, "show"), x = O(!1), l = O(new Array()), b = Se(), R = Ae(), P = Xe(), T = d, r = M(() => {
524
+ var a, t;
525
+ return [
526
+ ...((a = e.draft) == null ? void 0 : a.items) ?? [],
527
+ ...((t = e.draft) == null ? void 0 : t.negativeStockItems) ?? []
528
+ ];
529
+ }), s = M(() => {
530
+ const a = r.value.map((t) => t.sku);
531
+ return a.sort((t, i) => t.code.localeCompare(i.code)), a;
532
+ }), v = M(() => r.value.groupBy(
533
+ (t) => t.sku._id,
534
+ (t) => t.measurementsAmounts.filter((i) => !i.measurement.abbrev.toLocaleLowerCase().includes("inactive")).map((i) => i.measurement.id)
535
+ ));
536
+ He(w), ze(
537
+ () => e.show,
538
+ (a) => {
539
+ a && (Z.value = te[0], w());
540
+ }
541
+ );
542
+ const U = ce(0), S = ce(100);
543
+ async function w() {
544
+ var t, i, f;
545
+ x.value = !0;
546
+ const a = ((t = e.draft) == null ? void 0 : t.status) === oe.enum.COMPLETED;
547
+ try {
548
+ if (await P.init(), a) {
549
+ const c = e.draft.closingId;
550
+ if (!c) {
551
+ R.open({
552
+ title: "Something went wrong",
553
+ message: "Closing draft is completed but closing document cannot be found.",
554
+ type: "error"
555
+ }), console.error("Closing draft is completed but closing document cannot be found.", {
556
+ draftId: (i = e.draft) == null ? void 0 : i._id
557
+ });
558
+ return;
559
+ }
560
+ const p = await b.getClosingById(c);
561
+ l.value = (p == null ? void 0 : p.skus) ?? [];
562
+ } else
563
+ await u.readStockBalance(), l.value = ((f = u.stockBalance) == null ? void 0 : f.skus) ?? [];
564
+ } catch (c) {
565
+ R.open({
566
+ title: "Something went wrong",
567
+ message: "Something went wrong when fetching info. Please try again.",
568
+ type: "error"
569
+ }), console.error("error on fetch stock balances", c);
570
+ } finally {
571
+ x.value = !1;
572
+ }
573
+ }
574
+ const V = M(
575
+ () => l.value.groupBy(
576
+ (a) => a.id,
577
+ (a) => a.balance
578
+ )
579
+ ), B = M(() => r.value.groupBy((a) => a.sku._id));
580
+ function y(a) {
581
+ return $(
582
+ ae.FmTooltip,
583
+ { zIndex: 51, placement: "left", class: "w-full flex justify-end" },
584
+ {
585
+ default() {
586
+ return a;
587
+ },
588
+ content() {
589
+ return "Differences are calculated using this formula: (Adjusted / System) × 100%";
590
+ }
591
+ }
592
+ );
593
+ }
594
+ const K = M(() => {
595
+ const a = s.value.reduce((i, f) => {
596
+ var c, p, I, j;
597
+ return console.log(
598
+ "Measurement counts",
599
+ f.unit.name,
600
+ f.unit.abbrev,
601
+ (p = (c = v.value) == null ? void 0 : c.get(f._id)) == null ? void 0 : p[0].length
602
+ ), Math.max(i, ((j = (I = v.value) == null ? void 0 : I.get(f._id)) == null ? void 0 : j[0].length) ?? 0);
603
+ }, 0);
604
+ return [
605
+ {
606
+ id: "code",
607
+ accessorKey: "code",
608
+ header: () => "Code",
609
+ size: 200,
610
+ cell(i) {
611
+ const f = i.row.original.adjustedDiffPercentage;
612
+ return typeof f == "number" && Math.abs(f) > 10 ? $(
613
+ ae.FmTooltip,
614
+ {
615
+ zIndex: 51
616
+ },
617
+ {
618
+ content() {
619
+ return "Adjustment difference is more than 10%.";
620
+ },
621
+ default() {
622
+ return $("div", { class: "flex items-center gap-4 justify-start w-full" }, [
623
+ $(ae.FmIcon, { size: "sm", color: "system-error-300", name: "error" }),
624
+ `${i.getValue()}`
625
+ ]);
626
+ }
627
+ }
628
+ ) : i.getValue();
629
+ }
630
+ },
631
+ {
632
+ id: "name",
633
+ accessorKey: "name",
634
+ header: () => "Name",
635
+ size: 300
636
+ },
637
+ {
638
+ id: "baseUnitAmount",
639
+ accessorKey: "baseUnitAmount",
640
+ header: () => y("Base unit amount"),
641
+ size: 200,
642
+ meta: {
643
+ textAlign: "right"
644
+ }
645
+ },
646
+ {
647
+ id: "baseUnit",
648
+ accessorKey: "baseUnit",
649
+ header: () => "Base unit",
650
+ size: 200
651
+ },
652
+ ...Array.from({ length: a }).flatMap((i, f) => {
653
+ const c = `measurementAbbrev${f}`, p = `measurementAmount${f}`;
654
+ return [
655
+ {
656
+ id: p,
657
+ accessorKey: p,
658
+ header: () => y(`UOM amount ${f + 1}`),
659
+ size: 200,
660
+ meta: {
661
+ textAlign: "right"
662
+ }
663
+ },
664
+ {
665
+ id: c,
666
+ accessorKey: c,
667
+ header: () => `UOM ${f + 1}`,
668
+ size: 200
669
+ }
670
+ ];
671
+ }),
672
+ {
673
+ id: "physicalBalance",
674
+ accessorKey: "physicalBalance",
675
+ header: () => y("Total balance"),
676
+ size: 200,
677
+ meta: {
678
+ textAlign: "right"
679
+ }
680
+ },
681
+ {
682
+ id: "systemBalance",
683
+ accessorKey: "systemBalance",
684
+ header: () => y("System balance"),
685
+ size: 200,
686
+ meta: {
687
+ textAlign: "right"
688
+ }
689
+ },
690
+ {
691
+ id: "adjustedAmount",
692
+ accessorKey: "adjustedAmount",
693
+ header: () => y("Adjusted amount"),
694
+ size: 200,
695
+ meta: {
696
+ textAlign: "right"
697
+ }
698
+ },
699
+ {
700
+ id: "adjustedDiffPercentage",
701
+ accessorKey: "adjustedDiffPercentage",
702
+ header: () => $(
703
+ ae.FmTooltip,
704
+ { zIndex: 51, placement: "left", class: "w-full flex justify-end" },
705
+ {
706
+ default() {
707
+ return $("div", { class: "flex items-center gap-4" }, [
708
+ "Diff (%)",
709
+ $(ae.FmIcon, { name: "info", color: "neutral-gray-400", size: "sm" })
710
+ ]);
711
+ },
712
+ content() {
713
+ return "Differences are calculated using this formula: (Adjusted / System) × 100%";
714
+ }
715
+ }
716
+ ),
717
+ size: 200,
718
+ cell(i) {
719
+ const f = i.row.original.adjustedDiffPercentage;
720
+ if (!f) return "N/A";
721
+ const c = f.toFixed(2);
722
+ if (c === "0.00")
723
+ return $("div", { class: "flex items-center gap-4 justify-end" }, ["0.00"]);
724
+ const p = f > 0;
725
+ return $("div", { class: "flex items-center gap-4 justify-end" }, [
726
+ $(ae.FmIcon, {
727
+ name: p ? "arrow_drop_up" : "arrow_drop_down",
728
+ color: p ? "system-success-300" : "system-error-300",
729
+ size: "md"
730
+ }),
731
+ c
732
+ ]);
733
+ },
734
+ meta: {
735
+ textAlign: "right"
736
+ }
737
+ }
738
+ ];
739
+ }), J = M(() => K.value.map((a) => a.size ?? 0).reduce((a, t) => a + t)), se = M(() => s.value.map((a) => {
740
+ var G, Q;
741
+ const t = (G = B.value.get(a._id)) == null ? void 0 : G[0], i = ((Q = V.value.get(a._id)) == null ? void 0 : Q[0]) ?? U;
742
+ if (!t)
743
+ return {
744
+ code: a.code,
745
+ name: a.name,
746
+ baseUnit: a.unit.abbrev,
747
+ baseUnitAmount: 0,
748
+ systemBalance: +C(i),
749
+ physicalBalance: 0,
750
+ adjustedAmount: -+C(i),
751
+ adjustedDiffPercentage: -100
752
+ };
753
+ const f = Me(t), c = ke(f, i), p = i.amount === 0 ? null : je(c, {
754
+ ...i,
755
+ amount: Math.abs(i.amount)
756
+ }), I = p ? he(p, S) : null;
757
+ return {
758
+ code: a.code,
759
+ name: a.name,
760
+ baseUnit: a.unit.abbrev,
761
+ baseUnitAmount: +C(t.baseAmount),
762
+ ...t.measurementsAmounts.filter((H) => {
763
+ var A, k, z;
764
+ return (z = (k = (A = v.value) == null ? void 0 : A.get(a._id)) == null ? void 0 : k[0]) == null ? void 0 : z.includes(H.measurement.id);
765
+ }).reduce((H, A, k) => (H[`measurementAbbrev${k}`] = `(${A.measurement.abbrev}) × ${C(A.measurement.conversion)}`, H[`measurementAmount${k}`] = +C(A.amount), H), {}),
766
+ systemBalance: +C(i),
767
+ physicalBalance: +C(f),
768
+ adjustedAmount: +C(c),
769
+ adjustedDiffPercentage: I ? +C(Ce(I, 2)) : null
770
+ };
771
+ })), ee = M(() => {
772
+ var t, i, f;
773
+ if (!e.draft) return [];
774
+ const a = e.draft.approvedAt ? {
775
+ action: `Approve at ${X(e.draft.approvedAt)}`,
776
+ // actionAt: props.draft.approvedAt,
777
+ actionBy: e.draft.approvedBy,
778
+ remark: e.draft.approveRemark
779
+ } : (t = e.draft.rejectionHistory) == null ? void 0 : t.computeFirst((c) => ({
780
+ action: `Reject at ${X(c.rejectedAt)}`,
781
+ // actionAt: e.rejectedAt,
782
+ actionBy: c.rejectedBy,
783
+ remark: c.rejectRemark
784
+ }));
785
+ return [
786
+ {
787
+ label: "Using template",
788
+ value: ((i = e.draft.usingTemplates.find((c) => c)) == null ? void 0 : i.name) ?? "None"
789
+ },
790
+ {
791
+ label: "Created at",
792
+ value: X(e.draft.createdAt)
793
+ },
794
+ {
795
+ label: "Created by",
796
+ value: e.draft.createdBy.name
797
+ },
798
+ {
799
+ label: "Updated at",
800
+ value: X(e.draft.updatedAt)
801
+ },
802
+ {
803
+ label: "Updated by",
804
+ value: e.draft.updatedBy.name
805
+ },
806
+ {
807
+ label: "Effective at",
808
+ value: X(e.draft.effectiveAt ?? e.draft.updatedAt)
809
+ },
810
+ e.draft.remark ? {
811
+ label: "Remark",
812
+ value: e.draft.remark
813
+ } : null,
814
+ a ? {
815
+ label: "Last action",
816
+ value: a.action
817
+ } : null,
818
+ a && a.actionBy ? {
819
+ label: "Last action by",
820
+ value: (f = a.actionBy) == null ? void 0 : f.name
821
+ } : null,
822
+ a && a.remark ? {
823
+ label: "Action remark",
824
+ value: a.remark
825
+ } : null
826
+ ].filter((c) => c).map((c) => c);
827
+ }), te = [
828
+ {
829
+ label: "Overview",
830
+ value: "overview"
831
+ },
832
+ {
833
+ label: "Action history",
834
+ value: "history"
835
+ }
836
+ ], Z = O(te[0]), Y = M(() => {
837
+ var t, i, f, c;
838
+ return [
839
+ ...(((t = e.draft) == null ? void 0 : t.rejectionHistory) ?? []).map(
840
+ (p) => ({
841
+ header: "Reject",
842
+ date: X(p.rejectedAt),
843
+ info: [
844
+ {
845
+ label: "Rejected by",
846
+ values: [p.rejectedBy.name]
847
+ },
848
+ {
849
+ label: "Rejection remark",
850
+ values: [p.rejectRemark]
851
+ }
852
+ ]
853
+ })
854
+ ),
855
+ ...(i = e.draft) != null && i.approvedBy ? [
856
+ {
857
+ header: "Approve",
858
+ date: e.draft.approvedAt ? X(e.draft.approvedAt) : "",
859
+ info: [
860
+ {
861
+ label: "Approved by",
862
+ values: [(f = e.draft) == null ? void 0 : f.approvedBy.name]
863
+ },
864
+ {
865
+ label: "Approval remark",
866
+ values: [((c = e.draft) == null ? void 0 : c.approveRemark) ?? ""]
867
+ }
868
+ ]
869
+ }
870
+ ] : []
871
+ ];
872
+ }), re = M(() => {
873
+ var c, p, I;
874
+ if (((c = e.draft) == null ? void 0 : c.status) !== oe.enum.DRAFT) return "Status is not draft.";
875
+ const a = se.value.some((j) => j.physicalBalance < 0), t = ((I = (p = u.stockBalance.skus) == null ? void 0 : p.filter((j) => j.balance.amount < 0)) == null ? void 0 : I.map((j) => j.id)) ?? [], i = new Set(s.value.map((j) => j._id)), f = t.filter((j) => !i.has(j)).length;
876
+ return [
877
+ a ? "Negative total exist." : null,
878
+ f ? "Negative stock is not included in this draft. Reopen draft in POS and apply changes." : null
879
+ ].filter((j) => j).join(" ");
880
+ });
881
+ return (a, t) => {
882
+ const i = E("FmButtonGroup"), f = E("FmMenuDivider"), c = E("FmCard"), p = E("FmButton"), I = E("FmCircularProgress"), j = E("FmTable"), G = E("FmSpacer"), Q = E("FmTooltip"), H = E("FmSideSheet");
883
+ return _(), ne(H, {
884
+ "dismiss-away": "",
885
+ "max-width": 900,
886
+ "model-value": h(g),
887
+ "onUpdate:modelValue": t[6] || (t[6] = (A) => _e(g) ? g.value = A : null),
888
+ header: "Closing details"
889
+ }, {
890
+ "side-sheet-footer": N(() => {
891
+ var A, k;
892
+ return [
893
+ o("div", Zt, [
894
+ ((A = e.draft) == null ? void 0 : A.status) === h(oe).enum.DRAFT ? (_(), F(W, { key: 0 }, [
895
+ re.value ? (_(), ne(Q, {
896
+ key: 0,
897
+ "z-index": 51
898
+ }, {
899
+ content: N(() => [
900
+ ge(L(re.value), 1)
901
+ ]),
902
+ default: N(() => [
903
+ D(p, {
904
+ disabled: "",
905
+ key: "approve key",
906
+ label: "Approve",
907
+ onClick: t[2] || (t[2] = () => e.draft && h(m).approveDraft(e.draft, () => T("submitted")))
908
+ })
909
+ ]),
910
+ _: 1
911
+ })) : (_(), ne(p, {
912
+ key: "approve key",
913
+ label: "Approve",
914
+ onClick: t[3] || (t[3] = () => e.draft && h(m).approveDraft(e.draft, () => T("submitted")))
915
+ }))
916
+ ], 64)) : le("", !0),
917
+ ((k = e.draft) == null ? void 0 : k.status) === h(oe).enum.DRAFT ? (_(), ne(p, {
918
+ key: 1,
919
+ label: "Reject",
920
+ variant: "destructive",
921
+ onClick: t[4] || (t[4] = () => e.draft && h(m).rejectDraft(e.draft, () => T("submitted")))
922
+ })) : le("", !0),
923
+ D(p, {
924
+ label: "Close",
925
+ variant: "tertiary",
926
+ onClick: t[5] || (t[5] = (z) => g.value = !1)
927
+ })
928
+ ])
929
+ ];
930
+ }),
931
+ default: N(() => [
932
+ o("div", ht, [
933
+ o("div", null, [
934
+ D(i, {
935
+ items: te,
936
+ modelValue: Z.value,
937
+ "onUpdate:modelValue": t[0] || (t[0] = (A) => Z.value = A)
938
+ }, null, 8, ["modelValue"])
939
+ ]),
940
+ Z.value.value === "overview" ? (_(), F(W, { key: 0 }, [
941
+ D(c, {
942
+ variant: "outlined",
943
+ class: "flex flex-col gap-8 px-12 py-16"
944
+ }, {
945
+ default: N(() => {
946
+ var A, k;
947
+ return [
948
+ o("div", At, [
949
+ t[7] || (t[7] = o("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
950
+ o("div", Dt, [
951
+ o("div", {
952
+ class: ie(["fm-status-badge", h(fe)(((A = a.draft) == null ? void 0 : A.status) ?? "DRAFT")])
953
+ }, L(h(Be)(((k = a.draft) == null ? void 0 : k.status) ?? "")), 3)
954
+ ])
955
+ ]),
956
+ D(f),
957
+ (_(!0), F(W, null, ue(ee.value, (z, ve) => (_(), F("div", {
958
+ class: "flex flex-col gap-4",
959
+ key: ve
960
+ }, [
961
+ o("div", xt, [
962
+ o("div", _t, L(z.label), 1)
963
+ ]),
964
+ o("div", wt, L(z.value), 1)
965
+ ]))), 128))
966
+ ];
967
+ }),
968
+ _: 1
969
+ }),
970
+ o("div", kt, [
971
+ o("div", jt, [
972
+ t[8] || (t[8] = o("div", { class: "flex-1 fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, " Closing items ", -1)),
973
+ x.value ? le("", !0) : (_(), F("div", Ct, [
974
+ D(p, {
975
+ label: "Export data",
976
+ "prepend-icon": "download",
977
+ variant: "secondary",
978
+ "text-color": "primary",
979
+ "bg-color": "transparent",
980
+ "border-color": "primary",
981
+ onClick: t[1] || (t[1] = (A) => a.draft ? h(m).exportDraft(a.draft, l.value) : null)
982
+ })
983
+ ]))
984
+ ]),
985
+ x.value ? (_(), F("div", St, [
986
+ t[10] || (t[10] = o("div", { class: "h-80" }, null, -1)),
987
+ o("div", Bt, [
988
+ o("div", null, [
989
+ D(I, { size: "md" })
990
+ ]),
991
+ t[9] || (t[9] = o("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
992
+ ]),
993
+ t[11] || (t[11] = o("div", { class: "h-80" }, null, -1))
994
+ ])) : (_(), F("div", Ft, [
995
+ o("div", {
996
+ style: we({ width: `${J.value}px` })
997
+ }, [
998
+ D(j, {
999
+ "column-defs": K.value,
1000
+ "row-data": se.value
1001
+ }, null, 8, ["column-defs", "row-data"])
1002
+ ], 4)
1003
+ ]))
1004
+ ])
1005
+ ], 64)) : le("", !0),
1006
+ Z.value.value === "history" ? (_(), F("div", Rt, [
1007
+ Y.value.length ? (_(), F("div", Mt, [
1008
+ (_(!0), F(W, null, ue(Y.value, (A, k) => (_(), F(W, { key: k }, [
1009
+ o("div", Pt, [
1010
+ o("div", It, [
1011
+ o("div", Ut, [
1012
+ o("div", {
1013
+ class: ie([
1014
+ {
1015
+ "bg-fm-color-primary": k !== 0,
1016
+ "bg-white": k === 0
1017
+ },
1018
+ "w-[2px] h-full"
1019
+ ])
1020
+ }, null, 2)
1021
+ ]),
1022
+ t[14] || (t[14] = o("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1023
+ o("div", Ht, [
1024
+ o("div", {
1025
+ class: ie([
1026
+ {
1027
+ "bg-fm-color-primary": k < Y.value.length - 1,
1028
+ "bg-white": k >= Y.value.length - 1
1029
+ },
1030
+ "w-[2px] h-full"
1031
+ ])
1032
+ }, null, 2)
1033
+ ])
1034
+ ]),
1035
+ o("div", zt, [
1036
+ o("div", Et, L(A.header), 1),
1037
+ o("div", Lt, L(A.date), 1)
1038
+ ])
1039
+ ]),
1040
+ o("div", Nt, [
1041
+ o("div", Ot, [
1042
+ o("div", Vt, [
1043
+ o("div", {
1044
+ class: ie([
1045
+ {
1046
+ "bg-fm-color-primary": k < Y.value.length - 1,
1047
+ "bg-white": k >= Y.value.length - 1
1048
+ },
1049
+ "w-[2px] h-full"
1050
+ ])
1051
+ }, null, 2)
1052
+ ])
1053
+ ]),
1054
+ o("div", Kt, [
1055
+ D(c, {
1056
+ variant: "outlined",
1057
+ class: "py-12 px-16"
1058
+ }, {
1059
+ default: N(() => [
1060
+ o("div", Yt, [
1061
+ (_(!0), F(W, null, ue(A.info, (z, ve) => (_(), F("div", {
1062
+ key: ve,
1063
+ class: "flex flex-col gap-4"
1064
+ }, [
1065
+ o("div", Gt, L(z == null ? void 0 : z.label), 1),
1066
+ o("div", qt, [
1067
+ (_(!0), F(W, null, ue(z == null ? void 0 : z.values, (Ie, Ue) => (_(), F("div", {
1068
+ key: Ue,
1069
+ class: "fm-typo-en-body-lg-600"
1070
+ }, L(Ie), 1))), 128))
1071
+ ])
1072
+ ]))), 128))
1073
+ ])
1074
+ ]),
1075
+ _: 2
1076
+ }, 1024)
1077
+ ])
1078
+ ])
1079
+ ], 64))), 128))
1080
+ ])) : (_(), F("div", $t, [
1081
+ D(G),
1082
+ o("div", null, [
1083
+ o("img", {
1084
+ src: h(lt),
1085
+ alt: "List is empty"
1086
+ }, null, 8, Tt)
1087
+ ]),
1088
+ t[12] || (t[12] = o("div", { class: "fm-typo-en-body-lg-600" }, L("No records found"), -1)),
1089
+ t[13] || (t[13] = o("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, L("You can track approval and rejection history here"), -1)),
1090
+ D(G),
1091
+ D(G)
1092
+ ]))
1093
+ ])) : le("", !0)
1094
+ ])
1095
+ ]),
1096
+ _: 1
1097
+ }, 8, ["model-value"]);
1098
+ };
1099
+ }
1100
+ }), Xt = { class: "flex-1 flex flex-col gap-8" }, Jt = { class: "flex flex-col" }, Qt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ea = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, ta = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, aa = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, ua = /* @__PURE__ */ ye({
1101
+ __name: "ClosingDraftView",
1102
+ setup(n) {
1103
+ const { t: d } = Fe(), { viewDraft: e } = pe(), { viewClosingDraftProps: u, viewClosingDraftShow: m } = rt(pe()), g = be(), x = bt(), l = Je(), { breakpoints: b } = st();
1104
+ g.watchLocation(x.fetchDrafts);
1105
+ const R = M(() => x.loading), P = O(""), T = M(() => b.value.xs || b.value.sm), r = M(() => T.value ? 10 : 20);
1106
+ function s(S) {
1107
+ switch (S) {
1108
+ case "refresh":
1109
+ return x.fetchDrafts();
1110
+ }
1111
+ }
1112
+ function v(S) {
1113
+ return S;
1114
+ }
1115
+ const U = M(() => T.value ? [
1116
+ {
1117
+ label: "Refresh",
1118
+ value: "refresh",
1119
+ isPrimary: !1
1120
+ }
1121
+ ] : [
1122
+ {
1123
+ label: "Refresh",
1124
+ value: "refresh",
1125
+ isPrimary: !1
1126
+ }
1127
+ ]);
1128
+ return (S, w) => {
1129
+ const V = E("FmTable");
1130
+ return _(), F(W, null, [
1131
+ D(Qe, {
1132
+ title: h(d)("inventory.closing.draft.title"),
1133
+ actions: U.value,
1134
+ "onClick:action": s
1135
+ }, {
1136
+ default: N(() => [
1137
+ o("div", {
1138
+ class: ie([
1139
+ "flex flex-col gap-8 max-h-full",
1140
+ {
1141
+ "p-0": T.value,
1142
+ "px-24 ": !T.value
1143
+ }
1144
+ ])
1145
+ }, [
1146
+ D(et, {
1147
+ "change-location": "",
1148
+ searchable: "",
1149
+ search: P.value,
1150
+ "onUpdate:search": w[0] || (w[0] = (B) => P.value = B)
1151
+ }, null, 8, ["search"]),
1152
+ D(V, {
1153
+ style: we(h(l).tableHeight),
1154
+ "column-defs": h(x).columnDefs,
1155
+ "row-data": h(x).drafts,
1156
+ "search-value": P.value,
1157
+ loading: R.value,
1158
+ onRowClick: w[1] || (w[1] = (B) => h(e)(B.original)),
1159
+ "page-size": r.value
1160
+ }, {
1161
+ "list-row": N((B) => [
1162
+ D(tt, {
1163
+ row: B,
1164
+ onRowClick: (y) => h(e)(y)
1165
+ }, {
1166
+ default: N((y) => {
1167
+ var K, J, se, ee, te, Z, Y, re, a, t, i, f, c, p, I, j, G, Q, H, A;
1168
+ return [
1169
+ o("div", Xt, [
1170
+ o("div", Jt, [
1171
+ o("div", Qt, [
1172
+ D(h(me), {
1173
+ render: (se = (J = (K = y._id) == null ? void 0 : K.column) == null ? void 0 : J.columnDef) == null ? void 0 : se.cell,
1174
+ props: (te = (ee = y._id) == null ? void 0 : ee.getContext) == null ? void 0 : te.call(ee)
1175
+ }, null, 8, ["render", "props"])
1176
+ ]),
1177
+ o("div", ea, [
1178
+ D(h(me), {
1179
+ render: (re = (Y = (Z = y.name) == null ? void 0 : Z.column) == null ? void 0 : Y.columnDef) == null ? void 0 : re.cell,
1180
+ props: (t = (a = y.name) == null ? void 0 : a.getContext) == null ? void 0 : t.call(a)
1181
+ }, null, 8, ["render", "props"])
1182
+ ]),
1183
+ o("div", ta, L([
1184
+ ...B.original.items.slice(0, 3).map((k) => k.sku.name),
1185
+ ...B.original.items.length >= 3 ? [`and ${B.original.items.length - 3} more items`] : []
1186
+ ].join(", ")), 1),
1187
+ o("div", aa, [
1188
+ D(h(me), {
1189
+ render: (c = (f = (i = y.ref) == null ? void 0 : i.column) == null ? void 0 : f.columnDef) == null ? void 0 : c.cell,
1190
+ props: (I = (p = y.ref) == null ? void 0 : p.getContext) == null ? void 0 : I.call(p)
1191
+ }, null, 8, ["render", "props"])
1192
+ ])
1193
+ ]),
1194
+ o("div", null, [
1195
+ D(h(me), {
1196
+ render: (Q = (G = (j = y.status) == null ? void 0 : j.column) == null ? void 0 : G.columnDef) == null ? void 0 : Q.cell,
1197
+ props: (A = (H = y.status) == null ? void 0 : H.getContext) == null ? void 0 : A.call(H)
1198
+ }, null, 8, ["render", "props"])
1199
+ ])
1200
+ ])
1201
+ ];
1202
+ }),
1203
+ _: 2
1204
+ }, 1032, ["row", "onRowClick"])
1205
+ ]),
1206
+ _: 1
1207
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1208
+ ], 2)
1209
+ ]),
1210
+ _: 1
1211
+ }, 8, ["title", "actions"]),
1212
+ (_(), ne(Ee, { to: "body" }, [
1213
+ D(Wt, Le(h(u), {
1214
+ show: h(m),
1215
+ "onUpdate:show": w[2] || (w[2] = (B) => _e(m) ? m.value = B : null),
1216
+ onSubmitted: w[3] || (w[3] = () => (m.value = !1, h(x).fetchDrafts()))
1217
+ }), null, 16, ["show"])
1218
+ ]))
1219
+ ], 64);
1220
+ };
1221
+ }
1222
+ });
1223
+ export {
1224
+ ua as default
1225
+ };