@feedmepos/mf-inventory-portal 0.0.25-dev.2 → 0.0.25-dev.21

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