@feedmepos/mf-inventory-portal 0.0.24-dev.2 → 0.0.24-dev.49

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