@feedmepos/mf-inventory-portal 0.0.23-dev.12 → 0.0.23-dev.13

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 (55) hide show
  1. package/dist/{App-DASBZyvh.js → App-BzS1z3F-.js} +3 -3
  2. package/dist/{ApprovalView-DHF6ZNbm.js → ApprovalView-C1uZVtww.js} +4 -4
  3. package/dist/{BindingsDialog-D9qKxyAg.js → BindingsDialog-QLaA7j56.js} +2 -2
  4. package/dist/{BindingsPicker-CeBoqXz8.js → BindingsPicker-LhnFNdmi.js} +2 -2
  5. package/dist/{BindingsTable-Dd5xRj10.js → BindingsTable-DZYGkB07.js} +4 -4
  6. package/dist/ClosingDraftView-BhZA5Sbd.js +939 -0
  7. package/dist/{ClosingTemplateView-CSXAdVxc.js → ClosingTemplateView-bqpJqC4X.js} +10 -10
  8. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BST01iWL.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DENPdwTN.js} +4 -4
  9. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BH2P7EWu.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CJHdEwqX.js} +2 -2
  10. package/dist/{FmMultiselectDialog-CS4NySsZ.js → FmMultiselectDialog-GfKj0mFG.js} +3 -3
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-C7jj8lh2.js → FmUnitInput.vue_vue_type_script_setup_true_lang-BmFOF0rI.js} +2 -2
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-B_bOROW1.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BtjEZwIg.js} +1 -1
  13. package/dist/{IngredientGroupView-D8YdtFuI.js → IngredientGroupView-CsHd5M6s.js} +5 -5
  14. package/dist/{IngredientsView-Dwi7AdEC.js → IngredientsView-0QxND7rq.js} +9 -9
  15. package/dist/{IntegrationView-cRXTwH66.js → IntegrationView-T9C336FQ.js} +4 -4
  16. package/dist/{InventoryBindingForm-Bn8LLL7Z.js → InventoryBindingForm-DQPAOp0s.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-jXdc2zeS.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CX-BTgs0.js} +5 -5
  18. package/dist/{InventoryBindingSummary-eUAU5Z7o.js → InventoryBindingSummary-hqD7qMHb.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DP9gkO9u.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-rz50s3rd.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DjdvK5YG.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CrP9Bqh7.js} +2 -2
  21. package/dist/{PurchaseOrderPrintPreview-RsvtuTgm.js → PurchaseOrderPrintPreview-EMxizu88.js} +1 -1
  22. package/dist/{ReceiveRequestView-BVYXX41L.js → ReceiveRequestView-NocAGf9K.js} +18 -18
  23. package/dist/{RecipeView-BFj61pLR.js → RecipeView-Bxn8kv23.js} +7 -7
  24. package/dist/{StockView-B8DHNq-I.js → StockView-D928wvmo.js} +13 -13
  25. package/dist/{SupplierView-DE5glObY.js → SupplierView-BY8qT5mF.js} +10 -10
  26. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-CAR2rHAz.js → TransferDetails.vue_vue_type_script_setup_true_lang-DD5EfCNJ.js} +9 -9
  27. package/dist/{TransferTemplateView-DaY-24XT.js → TransferTemplateView-nQyS9duy.js} +14 -14
  28. package/dist/{UnitView-Bqh-DD8a.js → UnitView-Cj2EnX9R.js} +5 -5
  29. package/dist/{WarehouseView-KOZF8E0j.js → WarehouseView-CxgmS_A5.js} +4 -4
  30. package/dist/{app-CCmjyIGj.js → app-DTA5BMBZ.js} +8 -8
  31. package/dist/app.js +1 -1
  32. package/dist/{date2-Bts8EH96.js → date2-D7C6TRwa.js} +1 -1
  33. package/dist/{dayjs.min-Bwx_xAqf.js → dayjs.min-DLvJ9ZGq.js} +1 -1
  34. package/dist/{decimal-Cw3aj2HA.js → decimal-BOrWVGhm.js} +1 -1
  35. package/dist/{defineDeepModel-DF4IooaB.js → defineDeepModel-BNQXg1XY.js} +1 -1
  36. package/dist/{feature-DUVlpk0T.js → feature-Bv4WEepg.js} +1 -1
  37. package/dist/{format-time-from-id-DRL6XFTy.js → format-time-from-id-DYzFo1_S.js} +1 -1
  38. package/dist/{format-unit-display-h-7i16En.js → format-unit-display-C1J2TVsY.js} +8 -8
  39. package/dist/{fuzzy-Csk59ocn.js → fuzzy-BSqPLIIT.js} +1 -1
  40. package/dist/{index-BUdfAMv8.js → index-C5TiwgAO.js} +1 -1
  41. package/dist/{index-rrLxN15a.js → index-DWkXyapw.js} +1 -1
  42. package/dist/{index-C49C9tXF.js → index-xBRaZCEF.js} +1 -1
  43. package/dist/{netsuite-Cgj-Fs7U.js → netsuite-DIsy8hge.js} +1 -1
  44. package/dist/{rules-CSQd5FJv.js → rules-B0Wi_v-Q.js} +2 -2
  45. package/dist/{stock-DOndmj1b.js → stock-ChLGopyy.js} +2 -2
  46. package/dist/{supplier-Bv3Jvn8o.js → supplier-DxsqLKhq.js} +1 -1
  47. package/dist/tsconfig.app.tsbuildinfo +1 -1
  48. package/dist/{use-inventory-binding-dialog-C7br2QA4.js → use-inventory-binding-dialog-Cqjn4mUN.js} +2 -2
  49. package/dist/{use-template-enabled-locations-2-eX5uS542.js → use-template-enabled-locations-2-DY4I0HDI.js} +2 -2
  50. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +6 -2
  51. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +4 -1
  52. package/dist/{xlsx-wOJHnWy6.js → xlsx-Cjwxkhy4.js} +1 -1
  53. package/dist/{xlsx.util-C4ZYbcNA.js → xlsx.util-p-iKS8gR.js} +1 -1
  54. package/package.json +1 -1
  55. package/dist/ClosingDraftView-TbFoEdiB.js +0 -767
@@ -0,0 +1,939 @@
1
+ import { defineComponent as ue, ref as N, resolveComponent as F, openBlock as h, createBlock as Q, withCtx as Y, createElementVNode as a, createTextVNode as me, toDisplayString as T, unref as l, createVNode as p, h as fe, computed as R, onMounted as ke, watch as Se, isRef as be, createCommentVNode as oe, createElementBlock as C, Fragment as q, normalizeClass as J, renderList as ne, normalizeStyle as he, Teleport as je, mergeProps as Be } from "vue";
2
+ import { u as Fe, _ as Re, a as $e } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CJHdEwqX.js";
3
+ import { useI18n as _e } from "@feedmepos/mf-common";
4
+ import { useSnackbar as xe, useDialog as Pe, useProxiedModel as Te, useBreakpoints as Me } from "@feedmepos/ui-library";
5
+ import { k as Le, u as de, p as V, s as De, q as le, c as Ue, r as ze, a as Ee } from "./app-DTA5BMBZ.js";
6
+ import { defineStore as Ae, storeToRefs as Ne } from "pinia";
7
+ import { R as Ke, a as P, l as Ve, m as He, b as pe, k as Ie, c as ve, t as Oe } from "./rules-B0Wi_v-Q.js";
8
+ import { D as ge, R as se } from "./row-action.enum-7rGLGZ5v.js";
9
+ import { c as Ye, _ as Ge, F as re } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
10
+ import { f as qe } from "./format-time-from-id-DYzFo1_S.js";
11
+ import { d as O } from "./date2-D7C6TRwa.js";
12
+ import { u as We } from "./stock-ChLGopyy.js";
13
+ import { E as Ze } from "./empty-placeholder-wf6-BWE8.js";
14
+ const we = Le((S, d) => {
15
+ function t() {
16
+ return de().currentLocation.dbName;
17
+ }
18
+ return {
19
+ async getDraft(m) {
20
+ const i = t(), g = `${S.inventoryBackendUrl}/${i}/closing-draft/${m}`;
21
+ return d.get(g);
22
+ },
23
+ async readDrafts() {
24
+ const m = t(), i = `${S.inventoryBackendUrl}/${m}/closing-draft`;
25
+ return d.get(i);
26
+ },
27
+ async runOperation(m) {
28
+ const i = t(), g = `${S.inventoryBackendUrl}/${i}/closing-draft/run-operation`;
29
+ return d.post(g, m);
30
+ }
31
+ };
32
+ }), Je = { class: "fm-typo-en-body-lg-400" }, Qe = { class: "fm-typo-en-body-lg-600" }, Xe = { class: "flex gap-12 py-8 justify-end w-full" }, ye = /* @__PURE__ */ ue({
33
+ __name: "ClosingDraftAction",
34
+ props: {
35
+ draft: {},
36
+ action: {},
37
+ onCancel: { type: Function },
38
+ onFinished: { type: Function }
39
+ },
40
+ setup(S) {
41
+ const d = S, t = N(), m = we(), i = xe(), g = N(!1);
42
+ async function _() {
43
+ g.value = !0;
44
+ try {
45
+ await m.runOperation({
46
+ _id: d.draft._id,
47
+ _rev: d.draft._rev ?? "",
48
+ action: d.action,
49
+ data: {
50
+ remark: t.value
51
+ }
52
+ }).delayed(500), i.open({
53
+ title: "Success",
54
+ message: "Action submitted",
55
+ type: "success"
56
+ }), d.onFinished();
57
+ } catch (x) {
58
+ i.open({
59
+ title: "Something went wrong",
60
+ message: "Unable to submit actino. Please try again",
61
+ type: "error"
62
+ }), console.error("error on submit closing draft aciont", x);
63
+ } finally {
64
+ g.value = !1;
65
+ }
66
+ }
67
+ return (x, D) => {
68
+ const A = F("FmTextField"), y = F("FmButton"), M = F("FmForm");
69
+ return h(), Q(M, {
70
+ onValidationSuccess: _,
71
+ class: "flex flex-col gap-32",
72
+ disabled: g.value
73
+ }, {
74
+ default: Y(() => [
75
+ a("div", Je, [
76
+ D[2] || (D[2] = me(" You are about to ")),
77
+ a("span", Qe, T(x.action == l(V).enum.approveDraft ? "approve" : "reject"), 1),
78
+ D[3] || (D[3] = me(" this draft. Please provider a remark to justify this action. "))
79
+ ]),
80
+ p(A, {
81
+ modelValue: t.value,
82
+ "onUpdate:modelValue": D[0] || (D[0] = (r) => t.value = r),
83
+ label: "Remark",
84
+ "label-mark": "required",
85
+ rules: [l(Ke)()]
86
+ }, null, 8, ["modelValue", "rules"]),
87
+ a("div", Xe, [
88
+ p(y, {
89
+ label: "Cancel",
90
+ variant: "tertiary",
91
+ onClick: D[1] || (D[1] = (r) => x.onCancel())
92
+ }),
93
+ p(y, {
94
+ label: x.action == l(V).enum.approveDraft ? "Approve" : "Reject",
95
+ type: "submit",
96
+ variant: x.action == l(V).enum.approveDraft ? "primary" : "destructive",
97
+ loading: g.value
98
+ }, null, 8, ["label", "variant", "loading"])
99
+ ])
100
+ ]),
101
+ _: 1
102
+ }, 8, ["disabled"]);
103
+ };
104
+ }
105
+ }), ie = Ae(
106
+ "closingDraftActions",
107
+ function() {
108
+ const d = Pe(), t = N(!1), m = N();
109
+ function i(A) {
110
+ const y = {
111
+ draft: A
112
+ };
113
+ m.value = y, t.value = !0;
114
+ }
115
+ function g(A) {
116
+ }
117
+ function _(A, y) {
118
+ d.open({
119
+ title: "Approve draft",
120
+ contentComponent: ye,
121
+ contentComponentProps: {
122
+ draft: A,
123
+ action: V.enum.approveDraft,
124
+ onFinished: () => {
125
+ d.close(), y == null || y();
126
+ },
127
+ onCancel: () => d.close()
128
+ }
129
+ });
130
+ }
131
+ function x(A, y) {
132
+ d.open({
133
+ title: "Reject draft",
134
+ contentComponent: ye,
135
+ contentComponentProps: {
136
+ draft: A,
137
+ action: V.enum.rejectDraft,
138
+ onFinished: () => {
139
+ d.close(), y == null || y();
140
+ },
141
+ onCancel: () => d.close()
142
+ }
143
+ });
144
+ }
145
+ function D() {
146
+ t.value = !1;
147
+ }
148
+ return {
149
+ viewDraft: i,
150
+ closeDraftDialog: D,
151
+ approveDraft: _,
152
+ rejectDraft: x,
153
+ exportDraft: g,
154
+ viewClosingDraftShow: t,
155
+ viewClosingDraftProps: m
156
+ };
157
+ }
158
+ );
159
+ function Ce(S) {
160
+ switch (S) {
161
+ case "DRAFT":
162
+ return "fm-status-badge-draft";
163
+ case "PROCESSING":
164
+ return "fm-status-badge-processing";
165
+ case "FAILED":
166
+ return "fm-status-badge-cancel";
167
+ case "COMPLETED":
168
+ return "fm-status-badge-complete";
169
+ }
170
+ }
171
+ const et = Ae("closingTable", function() {
172
+ const { t: d } = _e(), t = ie(), m = N(new Array()), i = N(!1), g = de(), _ = we();
173
+ async function x() {
174
+ if (m.value = [], !!g._currentLocation) {
175
+ i.value = !0;
176
+ try {
177
+ const [r] = await Promise.all([_.readDrafts()]).delayed(1e3);
178
+ m.value = r.reverse();
179
+ } catch (r) {
180
+ console.log("Something went wrong when fetching drafts:", r);
181
+ } finally {
182
+ i.value = !1;
183
+ }
184
+ }
185
+ }
186
+ async function D(r) {
187
+ if (!m.value.find((c) => c._id) && g._currentLocation) {
188
+ i.value = !0;
189
+ try {
190
+ const [c] = await Promise.all([
191
+ _.getDraft(r),
192
+ new Promise(($) => setTimeout($, 1e3))
193
+ ]);
194
+ m.value = [c];
195
+ } catch (c) {
196
+ console.log("Something went wrong when fetching drafts:", c);
197
+ } finally {
198
+ i.value = !1;
199
+ }
200
+ }
201
+ }
202
+ function A() {
203
+ t.closeDraftDialog(), x();
204
+ }
205
+ function y(r, c) {
206
+ switch (c = Ue(c), r) {
207
+ case se.Details:
208
+ return t.viewDraft(c);
209
+ case se.Export:
210
+ return t.exportDraft(c);
211
+ case V.enum.approveDraft:
212
+ return t.approveDraft(c, A);
213
+ case V.enum.rejectDraft:
214
+ return t.rejectDraft(c, A);
215
+ }
216
+ }
217
+ return {
218
+ columnDefs: [
219
+ {
220
+ id: "_id",
221
+ accessorKey: "_id",
222
+ header: () => d("inventory.closing.table.createdAt"),
223
+ cell(r) {
224
+ return qe(`${r.getValue()}`);
225
+ },
226
+ enableSorting: !0
227
+ },
228
+ {
229
+ id: "updatedAt",
230
+ accessorFn: (r) => O(r.updatedAt),
231
+ header: () => "Updated at",
232
+ enableSorting: !0,
233
+ size: 200
234
+ },
235
+ {
236
+ id: "updatedBy",
237
+ accessorKey: "updatedBy.name",
238
+ header: () => "Last update by",
239
+ enableSorting: !0,
240
+ size: 200
241
+ },
242
+ {
243
+ id: "noOfItems",
244
+ accessorKey: "items.length",
245
+ header: () => d("inventory.closing.table.noOfItems"),
246
+ enableSorting: !1,
247
+ meta: {
248
+ width: "10rem",
249
+ textAlign: "right"
250
+ }
251
+ },
252
+ {
253
+ id: "recentRemark",
254
+ accessorFn: (r) => {
255
+ var c;
256
+ return (r == null ? void 0 : r.approveRemark) ?? ((c = r == null ? void 0 : r.rejectionHistory) == null ? void 0 : c.computeFirst(($) => $.rejectRemark));
257
+ },
258
+ header: () => "Recent remark"
259
+ },
260
+ {
261
+ id: "status",
262
+ accessorFn: (r) => r.status,
263
+ header: () => d("inventory.closing.table.status"),
264
+ enableSorting: !1,
265
+ cell(r) {
266
+ const $ = r.row.original.status;
267
+ return fe(
268
+ "div",
269
+ {
270
+ class: "flex"
271
+ },
272
+ fe(
273
+ "div",
274
+ {
275
+ class: ["fm-status-badge", Ce($)]
276
+ },
277
+ De($)
278
+ )
279
+ );
280
+ }
281
+ },
282
+ {
283
+ id: "action",
284
+ cell(r) {
285
+ const c = r.row.original, $ = [
286
+ ge[se.Details],
287
+ ge[se.Export]
288
+ ], W = [
289
+ {
290
+ translationKey: "inventory.closing.draft.approveDraft",
291
+ color: "text-fm-color-typo-primary",
292
+ value: V.enum.approveDraft
293
+ },
294
+ {
295
+ translationKey: "inventory.closing.draft.rejectDraft",
296
+ color: "text-fm-color-typo-error",
297
+ value: V.enum.rejectDraft
298
+ }
299
+ ];
300
+ return Ye(
301
+ [...$, ...c.status === le.enum.DRAFT ? W : []],
302
+ (H) => y(H, c)
303
+ );
304
+ },
305
+ enableSorting: !1,
306
+ size: 40,
307
+ meta: {
308
+ cellClass: "",
309
+ headerClass: ""
310
+ }
311
+ }
312
+ ],
313
+ drafts: m,
314
+ loading: i,
315
+ fetchDrafts: x,
316
+ loadDraft: D
317
+ };
318
+ }), tt = { class: "w-full flex flex-col gap-32" }, at = { class: "flex justify-between" }, ot = { class: "inline-flex rounded-md items-center gap-4 justify-center h-[22px] px-8 bg-fm-color-neutral-gray-100 fm-status-badge fm-status-badge-receiving" }, nt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, st = { class: "flex gap-1" }, rt = { class: "fm-typo-en-body-lg-600" }, lt = { class: "flex flex-col gap-16" }, it = {
319
+ key: 0,
320
+ class: "w-full flex flex-col items-center"
321
+ }, ct = { class: "flex items-center gap-8" }, ut = {
322
+ key: 1,
323
+ class: "overflow-x-auto"
324
+ }, dt = {
325
+ key: 1,
326
+ class: "flex-1 xs:w-screen xs:max-w-full"
327
+ }, mt = {
328
+ key: 0,
329
+ class: "flex flex-col items-center gap-8 h-full"
330
+ }, ft = ["src"], pt = {
331
+ key: 1,
332
+ class: "px-4 flex flex-col"
333
+ }, vt = { class: "flex gap-12 content-stretch" }, gt = {
334
+ class: "flex flex-col w-24",
335
+ name: "circles"
336
+ }, yt = { class: "flex-1 flex flex-col items-center" }, bt = { class: "flex-1 flex flex-col items-center" }, ht = {
337
+ class: "py-12 flex flex-col gap-4",
338
+ name: "received-at header"
339
+ }, _t = { class: "fm-typo-en-body-lg-400" }, xt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Dt = { class: "flex gap-12 content-stretch" }, At = {
340
+ class: "flex flex-col w-24",
341
+ name: "circles"
342
+ }, wt = { class: "flex-1 flex flex-col items-center" }, Ct = {
343
+ class: "py-12 flex flex-col gap-4 flex-1",
344
+ name: "delivery details"
345
+ }, kt = { class: "flex flex-col gap-8" }, St = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, jt = { class: "flex flex-col gap-4" }, Bt = { class: "flex gap-8" }, Ft = /* @__PURE__ */ ue({
346
+ __name: "ClosingDraftDialog",
347
+ props: {
348
+ show: { type: Boolean },
349
+ draft: {}
350
+ },
351
+ emits: ["submitted"],
352
+ setup(S, { emit: d }) {
353
+ const t = S, m = We(), i = ie(), g = Te(t, "show"), _ = N(!1), x = N(new Array()), D = ze(), A = xe(), y = Ee(), M = d, r = R(() => {
354
+ var e;
355
+ const o = ((e = t.draft) == null ? void 0 : e.items.map((s) => s.sku)) ?? [];
356
+ return o.sort((s, n) => s.code.localeCompare(n.code)), o;
357
+ });
358
+ ke(W), Se(
359
+ () => t.show,
360
+ (o) => {
361
+ o && (U.value = Z[0], W());
362
+ }
363
+ );
364
+ const c = ve(0), $ = ve(100);
365
+ async function W() {
366
+ var e, s, n;
367
+ _.value = !0;
368
+ const o = ((e = t.draft) == null ? void 0 : e.status) === le.enum.COMPLETED;
369
+ try {
370
+ if (await y.init(), o) {
371
+ const u = t.draft.closingId;
372
+ if (!u) {
373
+ A.open({
374
+ title: "Something went wrong",
375
+ message: "Closing draft is completed but closing document cannot be found.",
376
+ type: "error"
377
+ }), console.error("Closing draft is completed but closing document cannot be found.", {
378
+ draftId: (s = t.draft) == null ? void 0 : s._id
379
+ });
380
+ return;
381
+ }
382
+ const b = await D.getClosingById(u);
383
+ x.value = (b == null ? void 0 : b.skus) ?? [];
384
+ } else
385
+ await m.readStockBalance(), x.value = ((n = m.stockBalance) == null ? void 0 : n.skus) ?? [];
386
+ } catch (u) {
387
+ A.open({
388
+ title: "Something went wrong",
389
+ message: "Something went wrong when fetching info. Please try again.",
390
+ type: "error"
391
+ }), console.error("error on fetch stock balances", u);
392
+ } finally {
393
+ _.value = !1;
394
+ }
395
+ }
396
+ const H = R(
397
+ () => x.value.groupBy(
398
+ (o) => o.id,
399
+ (o) => o.balance
400
+ )
401
+ ), L = R(() => {
402
+ var e;
403
+ return (((e = t.draft) == null ? void 0 : e.items) ?? []).groupBy((s) => s.sku._id);
404
+ }), X = R(() => {
405
+ const o = r.value.reduce((s, n) => Math.max(
406
+ s,
407
+ n.unit.measurements.filter((u) => !u.name.toLocaleLowerCase().includes("inactive")).length
408
+ ), 0);
409
+ return [
410
+ {
411
+ id: "code",
412
+ accessorKey: "code",
413
+ header: () => "Code",
414
+ size: 200
415
+ },
416
+ {
417
+ id: "name",
418
+ accessorKey: "name",
419
+ header: () => "Name",
420
+ size: 300
421
+ },
422
+ {
423
+ id: "baseUnit",
424
+ accessorKey: "baseUnit",
425
+ header: () => "Base unit",
426
+ size: 200
427
+ },
428
+ {
429
+ id: "baseUnitAmount",
430
+ accessorKey: "baseUnitAmount",
431
+ header: () => "Base unit amount",
432
+ size: 200
433
+ },
434
+ ...Array.from({ length: o }).flatMap((s, n) => {
435
+ const u = `measurementAbbrev${n}`, b = `measurementAmount${n}`;
436
+ return [
437
+ {
438
+ id: b,
439
+ accessorKey: b,
440
+ header: () => `Sub unit amount ${n + 1}`,
441
+ size: 200,
442
+ meta: {
443
+ textAlign: "right"
444
+ }
445
+ },
446
+ {
447
+ id: u,
448
+ accessorKey: u,
449
+ header: () => `Sub unit ${n + 1}`,
450
+ size: 200
451
+ }
452
+ ];
453
+ }),
454
+ {
455
+ id: "systemBalance",
456
+ accessorKey: "systemBalance",
457
+ header: () => "System balance",
458
+ size: 200,
459
+ meta: {
460
+ textAlign: "right"
461
+ }
462
+ },
463
+ {
464
+ id: "physicalBalance",
465
+ accessorKey: "physicalBalance",
466
+ header: () => "Physical balance",
467
+ size: 200,
468
+ meta: {
469
+ textAlign: "right"
470
+ }
471
+ },
472
+ {
473
+ id: "adjustedBalance",
474
+ accessorKey: "adjustedBalance",
475
+ header: () => "Adjusted balance",
476
+ size: 200,
477
+ meta: {
478
+ textAlign: "right"
479
+ }
480
+ },
481
+ {
482
+ id: "adjustedDiffPercentage",
483
+ accessorKey: "adjustedDiffPercentage",
484
+ header: () => "Diff (%)",
485
+ size: 200,
486
+ cell(s) {
487
+ var n;
488
+ return (n = s.row.original.adjustedDiffPercentage) == null ? void 0 : n.toFixed(2);
489
+ },
490
+ meta: {
491
+ textAlign: "right"
492
+ }
493
+ }
494
+ ];
495
+ }), j = R(() => X.value.map((o) => o.size ?? 0).reduce((o, e) => o + e));
496
+ function B(o) {
497
+ const e = o.measurementsAmounts.groupBy((n) => n.measurement.id), s = o.sku.unit.measurements.reduce((n, u) => {
498
+ var E, k;
499
+ const b = ((k = (E = e.get(u.id)) == null ? void 0 : E[0]) == null ? void 0 : k.amount) ?? c, z = pe(u.conversion, b);
500
+ return n + +P(z);
501
+ }, +P(o.baseAmount));
502
+ return Oe(s, o.baseAmount.precision);
503
+ }
504
+ const ee = R(() => r.value.map((o) => {
505
+ var k, G;
506
+ const e = (k = L.value.get(o._id)) == null ? void 0 : k[0], s = ((G = H.value.get(o._id)) == null ? void 0 : G[0]) ?? c;
507
+ if (!e)
508
+ return {
509
+ code: o.code,
510
+ name: o.name,
511
+ baseUnit: o.unit.abbrev,
512
+ baseUnitAmount: 0,
513
+ systemBalance: +P(s),
514
+ physicalBalance: 0,
515
+ adjustedBalance: -+P(s),
516
+ adjustedDiffPercentage: -100
517
+ };
518
+ const n = B(e), u = Ve(n, s), b = s.amount === 0 ? null : He(u, s), z = b ? pe(b, $) : null;
519
+ return {
520
+ code: o.code,
521
+ name: o.name,
522
+ baseUnit: o.unit.abbrev,
523
+ baseUnitAmount: +P(e.baseAmount),
524
+ ...e.measurementsAmounts.reduce((f, v, w) => (v.measurement.name.toLocaleLowerCase().includes("inactive") || (f[`measurementAbbrev${w}`] = `(${v.measurement.abbrev}) × ${P(v.measurement.conversion)}`, f[`measurementAmount${w}`] = +P(v.amount)), f), {}),
525
+ systemBalance: +P(s),
526
+ physicalBalance: +P(n),
527
+ adjustedBalance: +P(u),
528
+ adjustedDiffPercentage: z ? +P(Ie(z, 2)) : null
529
+ };
530
+ })), te = R(() => {
531
+ var e, s;
532
+ if (!t.draft) return [];
533
+ const o = t.draft.approvedAt ? {
534
+ action: `Approve at ${O(t.draft.approvedAt)}`,
535
+ // actionAt: props.draft.approvedAt,
536
+ actionBy: t.draft.approvedBy,
537
+ remark: t.draft.approveRemark
538
+ } : (e = t.draft.rejectionHistory) == null ? void 0 : e.computeFirst((n) => ({
539
+ action: `Reject at ${O(n.rejectedAt)}`,
540
+ // actionAt: e.rejectedAt,
541
+ actionBy: n.rejectedBy,
542
+ remark: n.rejectRemark
543
+ }));
544
+ return [
545
+ {
546
+ label: "Created at",
547
+ value: O(t.draft.createdAt)
548
+ },
549
+ {
550
+ label: "Created by",
551
+ value: t.draft.createdBy.name
552
+ },
553
+ {
554
+ label: "Updated at",
555
+ value: O(t.draft.updatedAt)
556
+ },
557
+ {
558
+ label: "Updated by",
559
+ value: t.draft.updatedBy.name
560
+ },
561
+ {
562
+ label: "Effective at",
563
+ value: O(t.draft.effectiveAt ?? t.draft.updatedAt)
564
+ },
565
+ o ? {
566
+ label: "Last action",
567
+ value: o.action
568
+ } : null,
569
+ o && o.actionBy ? {
570
+ label: "Last action by",
571
+ value: (s = o.actionBy) == null ? void 0 : s.name
572
+ } : null,
573
+ o && o.remark ? {
574
+ label: "Action remark",
575
+ value: o.remark
576
+ } : null
577
+ ].filter((n) => n).map((n) => n);
578
+ }), Z = [
579
+ {
580
+ label: "Overview",
581
+ value: "overview"
582
+ },
583
+ {
584
+ label: "Action history",
585
+ value: "history"
586
+ }
587
+ ], U = N(Z[0]), K = R(() => {
588
+ var e, s, n, u;
589
+ return [
590
+ ...(((e = t.draft) == null ? void 0 : e.rejectionHistory) ?? []).map(
591
+ (b) => ({
592
+ header: "Reject",
593
+ date: O(b.rejectedAt),
594
+ info: [
595
+ {
596
+ label: "Rejected by",
597
+ values: [b.rejectedBy.name]
598
+ },
599
+ {
600
+ label: "Rejection remark",
601
+ values: [b.rejectRemark]
602
+ }
603
+ ]
604
+ })
605
+ ),
606
+ ...(s = t.draft) != null && s.approvedBy ? [
607
+ {
608
+ header: "Approve",
609
+ date: t.draft.approvedAt ? O(t.draft.approvedAt) : "",
610
+ info: [
611
+ {
612
+ label: "Approved by",
613
+ values: [(n = t.draft) == null ? void 0 : n.approvedBy.name]
614
+ },
615
+ {
616
+ label: "Approval remark",
617
+ values: [((u = t.draft) == null ? void 0 : u.approveRemark) ?? ""]
618
+ }
619
+ ]
620
+ }
621
+ ] : []
622
+ ];
623
+ });
624
+ return (o, e) => {
625
+ const s = F("FmButtonGroup"), n = F("FmMenuDivider"), u = F("FmCard"), b = F("FmCircularProgress"), z = F("FmTable"), E = F("FmSpacer"), k = F("FmButton"), G = F("FmSideSheet");
626
+ return h(), Q(G, {
627
+ "dismiss-away": "",
628
+ "max-width": 900,
629
+ "model-value": l(g),
630
+ "onUpdate:modelValue": e[4] || (e[4] = (f) => be(g) ? g.value = f : null),
631
+ header: "Closing details"
632
+ }, {
633
+ "side-sheet-footer": Y(() => {
634
+ var f, v;
635
+ return [
636
+ a("div", Bt, [
637
+ ((f = t.draft) == null ? void 0 : f.status) === l(le).enum.DRAFT ? (h(), Q(k, {
638
+ key: 0,
639
+ label: "Approve",
640
+ onClick: e[1] || (e[1] = () => t.draft && l(i).approveDraft(t.draft, () => M("submitted")))
641
+ })) : oe("", !0),
642
+ ((v = t.draft) == null ? void 0 : v.status) === l(le).enum.DRAFT ? (h(), Q(k, {
643
+ key: 1,
644
+ label: "Reject",
645
+ variant: "destructive",
646
+ onClick: e[2] || (e[2] = () => t.draft && l(i).rejectDraft(t.draft, () => M("submitted")))
647
+ })) : oe("", !0),
648
+ p(k, {
649
+ label: "Close",
650
+ variant: "tertiary",
651
+ onClick: e[3] || (e[3] = (w) => g.value = !1)
652
+ })
653
+ ])
654
+ ];
655
+ }),
656
+ default: Y(() => [
657
+ a("div", tt, [
658
+ a("div", null, [
659
+ p(s, {
660
+ items: Z,
661
+ modelValue: U.value,
662
+ "onUpdate:modelValue": e[0] || (e[0] = (f) => U.value = f)
663
+ }, null, 8, ["modelValue"])
664
+ ]),
665
+ U.value.value === "overview" ? (h(), C(q, { key: 0 }, [
666
+ p(u, {
667
+ variant: "outlined",
668
+ class: "flex flex-col gap-8 px-12 py-16"
669
+ }, {
670
+ default: Y(() => {
671
+ var f, v;
672
+ return [
673
+ a("div", at, [
674
+ e[5] || (e[5] = a("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
675
+ a("div", null, [
676
+ a("div", ot, [
677
+ a("div", {
678
+ class: J(l(Ce)(((f = o.draft) == null ? void 0 : f.status) ?? "DRAFT"))
679
+ }, T(l(De)(((v = o.draft) == null ? void 0 : v.status) ?? "")), 3)
680
+ ])
681
+ ])
682
+ ]),
683
+ p(n),
684
+ (h(!0), C(q, null, ne(te.value, (w, I) => (h(), C("div", {
685
+ class: "flex flex-col gap-4",
686
+ key: I
687
+ }, [
688
+ a("div", nt, [
689
+ a("div", st, T(w.label), 1)
690
+ ]),
691
+ a("div", rt, T(w.value), 1)
692
+ ]))), 128))
693
+ ];
694
+ }),
695
+ _: 1
696
+ }),
697
+ a("div", lt, [
698
+ e[9] || (e[9] = a("div", { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, "Closing items", -1)),
699
+ _.value ? (h(), C("div", it, [
700
+ e[7] || (e[7] = a("div", { class: "h-80" }, null, -1)),
701
+ a("div", ct, [
702
+ a("div", null, [
703
+ p(b, { size: "md" })
704
+ ]),
705
+ e[6] || (e[6] = a("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
706
+ ]),
707
+ e[8] || (e[8] = a("div", { class: "h-80" }, null, -1))
708
+ ])) : (h(), C("div", ut, [
709
+ a("div", {
710
+ style: he({ width: `${j.value}px` })
711
+ }, [
712
+ p(z, {
713
+ "column-defs": X.value,
714
+ "row-data": ee.value
715
+ }, null, 8, ["column-defs", "row-data"])
716
+ ], 4)
717
+ ]))
718
+ ])
719
+ ], 64)) : oe("", !0),
720
+ U.value.value === "history" ? (h(), C("div", dt, [
721
+ K.value.length ? (h(), C("div", pt, [
722
+ (h(!0), C(q, null, ne(K.value, (f, v) => (h(), C(q, { key: v }, [
723
+ a("div", vt, [
724
+ a("div", gt, [
725
+ a("div", yt, [
726
+ a("div", {
727
+ class: J([
728
+ {
729
+ "bg-fm-color-primary": v !== 0,
730
+ "bg-white": v === 0
731
+ },
732
+ "w-[2px] h-full"
733
+ ])
734
+ }, null, 2)
735
+ ]),
736
+ e[12] || (e[12] = a("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
737
+ a("div", bt, [
738
+ a("div", {
739
+ class: J([
740
+ {
741
+ "bg-fm-color-primary": v < K.value.length - 1,
742
+ "bg-white": v >= K.value.length - 1
743
+ },
744
+ "w-[2px] h-full"
745
+ ])
746
+ }, null, 2)
747
+ ])
748
+ ]),
749
+ a("div", ht, [
750
+ a("div", _t, T(f.header), 1),
751
+ a("div", xt, T(f.date), 1)
752
+ ])
753
+ ]),
754
+ a("div", Dt, [
755
+ a("div", At, [
756
+ a("div", wt, [
757
+ a("div", {
758
+ class: J([
759
+ {
760
+ "bg-fm-color-primary": v < K.value.length - 1,
761
+ "bg-white": v >= K.value.length - 1
762
+ },
763
+ "w-[2px] h-full"
764
+ ])
765
+ }, null, 2)
766
+ ])
767
+ ]),
768
+ a("div", Ct, [
769
+ p(u, {
770
+ variant: "outlined",
771
+ class: "py-12 px-16"
772
+ }, {
773
+ default: Y(() => [
774
+ a("div", kt, [
775
+ (h(!0), C(q, null, ne(f.info, (w, I) => (h(), C("div", {
776
+ key: I,
777
+ class: "flex flex-col gap-4"
778
+ }, [
779
+ a("div", St, T(w == null ? void 0 : w.label), 1),
780
+ a("div", jt, [
781
+ (h(!0), C(q, null, ne(w == null ? void 0 : w.values, (ae, ce) => (h(), C("div", {
782
+ key: ce,
783
+ class: "fm-typo-en-body-lg-600"
784
+ }, T(ae), 1))), 128))
785
+ ])
786
+ ]))), 128))
787
+ ])
788
+ ]),
789
+ _: 2
790
+ }, 1024)
791
+ ])
792
+ ])
793
+ ], 64))), 128))
794
+ ])) : (h(), C("div", mt, [
795
+ p(E),
796
+ a("div", null, [
797
+ a("img", {
798
+ src: l(Ze),
799
+ alt: "List is empty"
800
+ }, null, 8, ft)
801
+ ]),
802
+ e[10] || (e[10] = a("div", { class: "fm-typo-en-body-lg-600" }, T("No records found"), -1)),
803
+ e[11] || (e[11] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, T("You can track approval and rejection history here"), -1)),
804
+ p(E),
805
+ p(E)
806
+ ]))
807
+ ])) : oe("", !0)
808
+ ])
809
+ ]),
810
+ _: 1
811
+ }, 8, ["model-value"]);
812
+ };
813
+ }
814
+ }), Rt = { class: "flex-1 flex flex-col gap-8" }, $t = { class: "flex flex-col" }, Pt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Tt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Mt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Lt = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Zt = /* @__PURE__ */ ue({
815
+ __name: "ClosingDraftView",
816
+ setup(S) {
817
+ const { t: d } = _e(), { viewDraft: t } = ie(), { viewClosingDraftProps: m, viewClosingDraftShow: i } = Ne(ie()), g = de(), _ = et(), x = Fe(), { breakpoints: D } = Me();
818
+ g.watchLocation(_.fetchDrafts);
819
+ const A = R(() => _.loading), y = N(""), M = R(() => D.value.xs || D.value.sm), r = R(() => M.value ? 10 : 20);
820
+ function c(H) {
821
+ switch (H) {
822
+ case "refresh":
823
+ return _.fetchDrafts();
824
+ }
825
+ }
826
+ function $(H) {
827
+ return H;
828
+ }
829
+ const W = R(() => M.value ? [
830
+ {
831
+ label: "Refresh",
832
+ value: "refresh",
833
+ isPrimary: !1
834
+ }
835
+ ] : [
836
+ {
837
+ label: "Refresh",
838
+ value: "refresh",
839
+ isPrimary: !1
840
+ }
841
+ ]);
842
+ return (H, L) => {
843
+ const X = F("FmTable");
844
+ return h(), C(q, null, [
845
+ p(Re, {
846
+ title: l(d)("inventory.closing.draft.title"),
847
+ actions: W.value,
848
+ "onClick:action": c
849
+ }, {
850
+ default: Y(() => [
851
+ a("div", {
852
+ class: J([
853
+ "flex flex-col gap-8 max-h-full",
854
+ {
855
+ "p-0": M.value,
856
+ "px-24 ": !M.value
857
+ }
858
+ ])
859
+ }, [
860
+ p($e, {
861
+ "change-location": "",
862
+ searchable: "",
863
+ search: y.value,
864
+ "onUpdate:search": L[0] || (L[0] = (j) => y.value = j)
865
+ }, null, 8, ["search"]),
866
+ p(X, {
867
+ style: he(l(x).tableHeight),
868
+ "column-defs": l(_).columnDefs,
869
+ "row-data": l(_).drafts,
870
+ "search-value": y.value,
871
+ loading: A.value,
872
+ onRowClick: L[1] || (L[1] = (j) => l(t)(j.original)),
873
+ "page-size": r.value
874
+ }, {
875
+ "list-row": Y((j) => [
876
+ p(Ge, {
877
+ row: j,
878
+ onRowClick: (B) => l(t)(B)
879
+ }, {
880
+ default: Y((B) => {
881
+ var ee, te, Z, U, K, o, e, s, n, u, b, z, E, k, G, f, v, w, I, ae;
882
+ return [
883
+ a("div", Rt, [
884
+ a("div", $t, [
885
+ a("div", Pt, [
886
+ p(l(re), {
887
+ render: (Z = (te = (ee = B._id) == null ? void 0 : ee.column) == null ? void 0 : te.columnDef) == null ? void 0 : Z.cell,
888
+ props: (K = (U = B._id) == null ? void 0 : U.getContext) == null ? void 0 : K.call(U)
889
+ }, null, 8, ["render", "props"])
890
+ ]),
891
+ a("div", Tt, [
892
+ p(l(re), {
893
+ render: (s = (e = (o = B.name) == null ? void 0 : o.column) == null ? void 0 : e.columnDef) == null ? void 0 : s.cell,
894
+ props: (u = (n = B.name) == null ? void 0 : n.getContext) == null ? void 0 : u.call(n)
895
+ }, null, 8, ["render", "props"])
896
+ ]),
897
+ a("div", Mt, T([
898
+ ...j.original.items.slice(0, 3).map((ce) => ce.sku.name),
899
+ ...j.original.items.length >= 3 ? [`and ${j.original.items.length - 3} more items`] : []
900
+ ].join(", ")), 1),
901
+ a("div", Lt, [
902
+ p(l(re), {
903
+ render: (E = (z = (b = B.ref) == null ? void 0 : b.column) == null ? void 0 : z.columnDef) == null ? void 0 : E.cell,
904
+ props: (G = (k = B.ref) == null ? void 0 : k.getContext) == null ? void 0 : G.call(k)
905
+ }, null, 8, ["render", "props"])
906
+ ])
907
+ ]),
908
+ a("div", null, [
909
+ p(l(re), {
910
+ render: (w = (v = (f = B.status) == null ? void 0 : f.column) == null ? void 0 : v.columnDef) == null ? void 0 : w.cell,
911
+ props: (ae = (I = B.status) == null ? void 0 : I.getContext) == null ? void 0 : ae.call(I)
912
+ }, null, 8, ["render", "props"])
913
+ ])
914
+ ])
915
+ ];
916
+ }),
917
+ _: 2
918
+ }, 1032, ["row", "onRowClick"])
919
+ ]),
920
+ _: 1
921
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
922
+ ], 2)
923
+ ]),
924
+ _: 1
925
+ }, 8, ["title", "actions"]),
926
+ (h(), Q(je, { to: "body" }, [
927
+ p(Ft, Be(l(m), {
928
+ show: l(i),
929
+ "onUpdate:show": L[2] || (L[2] = (j) => be(i) ? i.value = j : null),
930
+ onSubmitted: L[3] || (L[3] = () => (i.value = !1, l(_).fetchDrafts()))
931
+ }), null, 16, ["show"])
932
+ ]))
933
+ ], 64);
934
+ };
935
+ }
936
+ });
937
+ export {
938
+ Zt as default
939
+ };