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

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 (93) hide show
  1. package/dist/{App-Y3Ez8Rjf.js → App-DDxwfi6I.js} +36 -31
  2. package/dist/{ApprovalView-BUU1G4Q2.js → ApprovalView-7rpIigm0.js} +4 -4
  3. package/dist/{BindingsDialog-8wc4Q0JQ.js → BindingsDialog-DbyzX6mw.js} +2 -2
  4. package/dist/{BindingsPicker-DGWN1LQc.js → BindingsPicker-FZfhZr5O.js} +2 -2
  5. package/dist/{BindingsTable-7NJP2jT6.js → BindingsTable-Bk2770OV.js} +6 -6
  6. package/dist/ClosingDraftView-D9CnCwak.js +772 -0
  7. package/dist/{ClosingTemplateView-9s7vmwaT.js → ClosingTemplateView-DkpHmTtx.js} +32 -31
  8. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DjBiov5r.js +283 -0
  9. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-5DINn0ZB.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CBC214tP.js} +2 -2
  10. package/dist/{FmMultiselectDialog-7hok9sJP.js → FmMultiselectDialog-CK6xwOeG.js} +128 -124
  11. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-IFTMUhET.js +329 -0
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-FQ0HjuL3.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-D0otwOX8.js} +1 -1
  13. package/dist/{IngredientGroupView-C3maHTCg.js → IngredientGroupView-D5XtVfIQ.js} +12 -11
  14. package/dist/IngredientsView-c7WnQiTv.js +1666 -0
  15. package/dist/{IntegrationView-gO4h89Wj.js → IntegrationView-CHkhMxVM.js} +50 -50
  16. package/dist/{InventoryBindingForm-dh3GeyG-.js → InventoryBindingForm-BUZ9MS5V.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CJuo3i7W.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-YIRre_Km.js} +13 -13
  18. package/dist/{InventoryBindingSummary-BPoPcEoe.js → InventoryBindingSummary-BUi0mjeC.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-olm8sZKt.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CpYtHPFH.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BezTV43V.js → PremiumBadge.vue_vue_type_script_setup_true_lang-D8IH1X1o.js} +2 -2
  21. package/dist/{PurchaseOrderPrintPreview-Dix_fIoo.js → PurchaseOrderPrintPreview-BLuoVz5N.js} +1 -1
  22. package/dist/ReceiveRequestView-BNM5JdQO.js +4165 -0
  23. package/dist/{RecipeView-C4-a4IEW.js → RecipeView-DxRumcLY.js} +11 -10
  24. package/dist/{StockView-Du2txrIP.js → StockView-CZyeg3sX.js} +1356 -1457
  25. package/dist/{SupplierView-D_09FbQh.js → SupplierView-C2XLbf27.js} +2352 -783
  26. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BQG6UzUU.js +1229 -0
  27. package/dist/{TransferTemplateView-j3CRy6Lc.js → TransferTemplateView-BCxZCU0i.js} +307 -307
  28. package/dist/{UnitView-BXw2Vwq1.js → UnitView-uGpE4txg.js} +81 -80
  29. package/dist/{WarehouseView-CKamiETC.js → WarehouseView-DvQVmixr.js} +25 -24
  30. package/dist/api/bill.d.ts +2 -2
  31. package/dist/api/closing-draft.d.ts +6 -0
  32. package/dist/api/closing.d.ts +1 -0
  33. package/dist/api/netsuite.d.ts +70 -0
  34. package/dist/{app-GUbzqEtW.js → app-BaOENyRY.js} +3425 -3343
  35. package/dist/app.d.ts +3 -0
  36. package/dist/app.js +1 -1
  37. package/dist/components/FmMinMaxInputRules.d.ts +4 -1
  38. package/dist/components/row-action.enum.d.ts +1 -0
  39. package/dist/{date2-CLE9fB2R.js → date2-CfGU3sHq.js} +1 -1
  40. package/dist/{dayjs.min-CY1d38w7.js → dayjs.min-BMk-E1IO.js} +17 -17
  41. package/dist/{decimal-SIjO6Mjw.js → decimal-BkLhxOFS.js} +1 -1
  42. package/dist/{defineDeepModel-l40rX7kr.js → defineDeepModel-Cy-_HBnw.js} +1 -1
  43. package/dist/{feature-BXruKUhX.js → feature-GoxrdjJJ.js} +23 -9
  44. package/dist/form-mode.enum-BKiNVH6A.js +4 -0
  45. package/dist/{format-time-from-id-CcFsBXmk.js → format-time-from-id-96hwVl9P.js} +1 -1
  46. package/dist/format-unit-display-Cp0DBbM8.js +1217 -0
  47. package/dist/{fuzzy-CVOV9zJc.js → fuzzy-CBGiL1wK.js} +1 -1
  48. package/dist/index-0HEhOwKT.js +12087 -0
  49. package/dist/{index-BX5KZXhI.js → index-CoL8wxbn.js} +126 -122
  50. package/dist/{index-m9e9nYfl.js → index-S7yfliEo.js} +1 -1
  51. package/dist/netsuite-D3VPLW8O.js +225 -0
  52. package/dist/router/name.d.ts +1 -0
  53. package/dist/{row-action.enum-PMKMRrZR.js → row-action.enum-7rGLGZ5v.js} +10 -5
  54. package/dist/{rules-DlnN8IP3.js → rules-DxLLla7a.js} +40 -35
  55. package/dist/stock-BbFKtx1y.js +111 -0
  56. package/dist/stores/feature.d.ts +2 -0
  57. package/dist/stores/integration/netsuite.d.ts +81 -0
  58. package/dist/stores/inventory.d.ts +1 -4
  59. package/dist/style.css +1 -1
  60. package/dist/{supplier-B21WlSAM.js → supplier-gGovyyjr.js} +22 -22
  61. package/dist/tsconfig.app.tsbuildinfo +1 -1
  62. package/dist/{use-inventory-binding-dialog-D3x6xj2O.js → use-inventory-binding-dialog-DIBMf_9-.js} +2 -2
  63. package/dist/{use-template-enabled-locations-2-z-b-UXef.js → use-template-enabled-locations-2-Bof9JMYI.js} +2 -2
  64. package/dist/views/closing-draft/ClosingDraftView.vue.d.ts +2 -0
  65. package/dist/views/closing-draft/components/closing-draft-action/ClosingDraftAction.vue.d.ts +22 -0
  66. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +447 -0
  67. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +22 -0
  68. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +2601 -0
  69. package/dist/views/closing-draft/helpers/draft-status-to-class-name.helper.d.ts +1 -0
  70. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +24 -192
  71. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +24 -192
  72. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +2 -2
  73. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +40 -40
  74. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +1 -0
  75. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +63 -63
  76. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +63 -63
  77. package/dist/views/receive-request/helper/check-netsuite-subsidiary.helper.d.ts +1 -0
  78. package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -1
  79. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +8 -8
  80. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +96 -96
  81. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +96 -96
  82. package/dist/{xlsx-6mM1eNiL.js → xlsx-DOnDmayp.js} +1 -1
  83. package/dist/{xlsx.util-BLftcF4q.js → xlsx.util-BqsQd9YP.js} +1 -1
  84. package/package.json +3 -3
  85. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B4DDh9-a.js +0 -267
  86. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-CxR1FCft.js +0 -326
  87. package/dist/IngredientsView-DCR3IBkR.js +0 -1613
  88. package/dist/ReceiveRequestView-DdPiYb2P.js +0 -4082
  89. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-C9MOos--.js +0 -1144
  90. package/dist/format-unit-display-DEKg8cJm.js +0 -1198
  91. package/dist/index-CVsyOEb1.js +0 -10545
  92. package/dist/netsuite-DAKRv7zr.js +0 -146
  93. package/dist/normalizeArguments-DP7Hrren.js +0 -1552
@@ -0,0 +1,772 @@
1
+ import { defineComponent as te, ref as z, resolveComponent as T, openBlock as R, createBlock as H, withCtx as K, createElementVNode as s, createTextVNode as ie, toDisplayString as Y, unref as c, createVNode as D, h as ce, computed as F, onMounted as xe, watch as ke, isRef as pe, createCommentVNode as ue, normalizeClass as ge, createElementBlock as O, Fragment as ve, renderList as Se, normalizeStyle as ye, Teleport as Be, mergeProps as Fe } from "vue";
2
+ import { u as je, _ as $e, a as Re } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CBC214tP.js";
3
+ import { useI18n as be } from "@feedmepos/mf-common";
4
+ import { useSnackbar as De, useDialog as Te, useProxiedModel as Pe, useBreakpoints as Me } from "@feedmepos/ui-library";
5
+ import { k as ze, u as ae, p as M, s as he, q as J, c as Ue, r as Le, a as Ke } from "./app-BaOENyRY.js";
6
+ import { defineStore as _e, storeToRefs as Ne } from "pinia";
7
+ import { R as Ee, a as B, l as Ie, m as Ve, b as de, k as Oe, c as me, t as He } from "./rules-DxLLla7a.js";
8
+ import { D as ee, R as V } from "./row-action.enum-7rGLGZ5v.js";
9
+ import { c as Ye, _ as qe, F as Z } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
10
+ import { f as Ge } from "./format-time-from-id-96hwVl9P.js";
11
+ import { d as N } from "./date2-CfGU3sHq.js";
12
+ import { u as We } from "./stock-BbFKtx1y.js";
13
+ const Ae = ze((C, e) => {
14
+ function p() {
15
+ return ae().currentLocation.dbName;
16
+ }
17
+ return {
18
+ async getDraft(d) {
19
+ const i = p(), g = `${C.inventoryBackendUrl}/${i}/closing-draft/${d}`;
20
+ return e.get(g);
21
+ },
22
+ async readDrafts() {
23
+ const d = p(), i = `${C.inventoryBackendUrl}/${d}/closing-draft`;
24
+ return e.get(i);
25
+ },
26
+ async runOperation(d) {
27
+ const i = p(), g = `${C.inventoryBackendUrl}/${i}/closing-draft/run-operation`;
28
+ return e.post(g, d);
29
+ }
30
+ };
31
+ }), Ze = { class: "fm-typo-en-body-lg-400" }, Je = { class: "fm-typo-en-body-lg-600" }, Qe = { class: "flex gap-12 py-8 justify-end w-full" }, fe = /* @__PURE__ */ te({
32
+ __name: "ClosingDraftAction",
33
+ props: {
34
+ draft: {},
35
+ action: {},
36
+ onCancel: { type: Function },
37
+ onFinished: { type: Function }
38
+ },
39
+ setup(C) {
40
+ const e = C, p = z(), d = Ae(), i = De(), g = z(!1);
41
+ async function b() {
42
+ g.value = !0;
43
+ try {
44
+ await d.runOperation({
45
+ _id: e.draft._id,
46
+ _rev: e.draft._rev ?? "",
47
+ action: e.action,
48
+ data: {
49
+ remark: p.value
50
+ }
51
+ }).delayed(500), i.open({
52
+ title: "Success",
53
+ message: "Action submitted",
54
+ type: "success"
55
+ }), e.onFinished();
56
+ } catch (h) {
57
+ i.open({
58
+ title: "Something went wrong",
59
+ message: "Unable to submit actino. Please try again",
60
+ type: "error"
61
+ }), console.error("error on submit closing draft aciont", h);
62
+ } finally {
63
+ g.value = !1;
64
+ }
65
+ }
66
+ return (h, u) => {
67
+ const v = T("FmTextField"), j = T("FmButton"), n = T("FmForm");
68
+ return R(), H(n, {
69
+ onValidationSuccess: b,
70
+ class: "flex flex-col gap-32",
71
+ disabled: g.value
72
+ }, {
73
+ default: K(() => [
74
+ s("div", Ze, [
75
+ u[2] || (u[2] = ie(" You are about to ")),
76
+ s("span", Je, Y(h.action == c(M).enum.approveDraft ? "approve" : "reject"), 1),
77
+ u[3] || (u[3] = ie(" this draft. Please provider a remark to justify this action. "))
78
+ ]),
79
+ D(v, {
80
+ modelValue: p.value,
81
+ "onUpdate:modelValue": u[0] || (u[0] = (l) => p.value = l),
82
+ label: "Remark",
83
+ "label-mark": "required",
84
+ rules: [c(Ee)()]
85
+ }, null, 8, ["modelValue", "rules"]),
86
+ s("div", Qe, [
87
+ D(j, {
88
+ label: "Cancel",
89
+ variant: "tertiary",
90
+ onClick: u[1] || (u[1] = (l) => h.onCancel())
91
+ }),
92
+ D(j, {
93
+ label: h.action == c(M).enum.approveDraft ? "Approve" : "Reject",
94
+ type: "submit",
95
+ variant: h.action == c(M).enum.approveDraft ? "primary" : "destructive",
96
+ loading: g.value
97
+ }, null, 8, ["label", "variant", "loading"])
98
+ ])
99
+ ]),
100
+ _: 1
101
+ }, 8, ["disabled"]);
102
+ };
103
+ }
104
+ }), Q = _e(
105
+ "closingDraftActions",
106
+ function() {
107
+ const e = Te(), p = z(!1), d = z();
108
+ function i(u) {
109
+ const v = {
110
+ draft: u
111
+ };
112
+ d.value = v, p.value = !0;
113
+ }
114
+ function g(u) {
115
+ }
116
+ function b(u, v) {
117
+ e.open({
118
+ title: "Approve draft",
119
+ contentComponent: fe,
120
+ contentComponentProps: {
121
+ draft: u,
122
+ action: M.enum.approveDraft,
123
+ onFinished: () => {
124
+ e.close(), v == null || v();
125
+ },
126
+ onCancel: () => e.close()
127
+ }
128
+ });
129
+ }
130
+ function h(u, v) {
131
+ e.open({
132
+ title: "Reject draft",
133
+ contentComponent: fe,
134
+ contentComponentProps: {
135
+ draft: u,
136
+ action: M.enum.rejectDraft,
137
+ onFinished: () => {
138
+ e.close(), v == null || v();
139
+ },
140
+ onCancel: () => e.close()
141
+ }
142
+ });
143
+ }
144
+ return {
145
+ viewDraft: i,
146
+ approveDraft: b,
147
+ rejectDraft: h,
148
+ exportDraft: g,
149
+ viewClosingDraftShow: p,
150
+ viewClosingDraftProps: d
151
+ };
152
+ }
153
+ );
154
+ function Ce(C) {
155
+ switch (C) {
156
+ case "DRAFT":
157
+ return "fm-status-badge-draft";
158
+ case "PROCESSING":
159
+ return "fm-status-badge-processing";
160
+ case "FAILED":
161
+ return "fm-status-badge-cancel";
162
+ case "COMPLETED":
163
+ return "fm-status-badge-complete";
164
+ }
165
+ }
166
+ const Xe = _e("closingTable", function() {
167
+ const { t: e } = be(), p = Q(), d = z(new Array()), i = z(!1), g = ae(), b = Ae();
168
+ async function h() {
169
+ if (d.value = [], !!g._currentLocation) {
170
+ i.value = !0;
171
+ try {
172
+ const [n] = await Promise.all([b.readDrafts()]).delayed(1e3);
173
+ d.value = n.reverse();
174
+ } catch (n) {
175
+ console.log("Something went wrong when fetching drafts:", n);
176
+ } finally {
177
+ i.value = !1;
178
+ }
179
+ }
180
+ }
181
+ async function u(n) {
182
+ if (!d.value.find((l) => l._id) && g._currentLocation) {
183
+ i.value = !0;
184
+ try {
185
+ const [l] = await Promise.all([
186
+ b.getDraft(n),
187
+ new Promise((_) => setTimeout(_, 1e3))
188
+ ]);
189
+ d.value = [l];
190
+ } catch (l) {
191
+ console.log("Something went wrong when fetching drafts:", l);
192
+ } finally {
193
+ i.value = !1;
194
+ }
195
+ }
196
+ }
197
+ function v(n, l) {
198
+ switch (l = Ue(l), n) {
199
+ case V.Details:
200
+ return p.viewDraft(l);
201
+ case V.Export:
202
+ return p.exportDraft(l);
203
+ case M.enum.approveDraft:
204
+ return p.approveDraft(l);
205
+ case M.enum.rejectDraft:
206
+ return p.rejectDraft(l);
207
+ }
208
+ }
209
+ return {
210
+ columnDefs: [
211
+ {
212
+ id: "_id",
213
+ accessorKey: "_id",
214
+ header: () => e("inventory.closing.table.createdAt"),
215
+ cell(n) {
216
+ return Ge(`${n.getValue()}`);
217
+ },
218
+ enableSorting: !0
219
+ },
220
+ {
221
+ id: "updatedAt",
222
+ accessorFn: (n) => N(n.updatedAt),
223
+ header: () => "Updated at",
224
+ enableSorting: !0,
225
+ size: 200
226
+ },
227
+ {
228
+ id: "updatedBy",
229
+ accessorKey: "updatedBy.name",
230
+ header: () => "Last update by",
231
+ enableSorting: !0,
232
+ size: 200
233
+ },
234
+ {
235
+ id: "noOfItems",
236
+ accessorKey: "items.length",
237
+ header: () => e("inventory.closing.table.noOfItems"),
238
+ enableSorting: !1,
239
+ meta: {
240
+ width: "10rem",
241
+ textAlign: "right"
242
+ }
243
+ },
244
+ {
245
+ id: "recentRemark",
246
+ accessorFn: (n) => {
247
+ var l;
248
+ return (n == null ? void 0 : n.approveRemark) ?? ((l = n == null ? void 0 : n.rejectionHistory) == null ? void 0 : l.computeFirst((_) => _.rejectRemark));
249
+ },
250
+ header: () => "Recent remark"
251
+ },
252
+ {
253
+ id: "status",
254
+ accessorFn: (n) => n.status,
255
+ header: () => e("inventory.closing.table.status"),
256
+ enableSorting: !1,
257
+ cell(n) {
258
+ const _ = n.row.original.status;
259
+ return ce(
260
+ "div",
261
+ {
262
+ class: "flex"
263
+ },
264
+ ce(
265
+ "div",
266
+ {
267
+ class: ["fm-status-badge", Ce(_)]
268
+ },
269
+ he(_)
270
+ )
271
+ );
272
+ }
273
+ },
274
+ {
275
+ id: "action",
276
+ cell(n) {
277
+ const l = n.row.original, _ = [
278
+ ee[V.Edit],
279
+ ee[V.Delete],
280
+ ee[V.Export]
281
+ ], q = [
282
+ {
283
+ translationKey: "inventory.closing.draft.approveDraft",
284
+ color: "text-fm-color-typo-primary",
285
+ value: M.enum.approveDraft
286
+ },
287
+ {
288
+ translationKey: "inventory.closing.draft.rejectDraft",
289
+ color: "text-fm-color-typo-error",
290
+ value: M.enum.rejectDraft
291
+ }
292
+ ];
293
+ return Ye(
294
+ [..._, ...l.status === J.enum.DRAFT ? q : []],
295
+ (E) => v(E, l)
296
+ );
297
+ },
298
+ enableSorting: !1,
299
+ size: 40,
300
+ meta: {
301
+ cellClass: "",
302
+ headerClass: ""
303
+ }
304
+ }
305
+ ],
306
+ drafts: d,
307
+ loading: i,
308
+ fetchDrafts: h,
309
+ loadDraft: u
310
+ };
311
+ }), et = { class: "w-full flex flex-col gap-32" }, tt = { class: "flex justify-between" }, at = { 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" }, ot = { class: "flex gap-1" }, st = { class: "fm-typo-en-body-lg-600" }, rt = { class: "flex flex-col gap-16" }, lt = {
312
+ key: 0,
313
+ class: "w-full flex flex-col items-center"
314
+ }, it = { class: "flex items-center gap-8" }, ct = {
315
+ key: 1,
316
+ class: "overflow-x-auto"
317
+ }, ut = { class: "flex gap-8" }, dt = /* @__PURE__ */ te({
318
+ __name: "ClosingDraftDialog",
319
+ props: {
320
+ show: { type: Boolean },
321
+ draft: {}
322
+ },
323
+ setup(C) {
324
+ const e = C, p = We(), d = Q(), i = Pe(e, "show"), g = z(!1), b = z(new Array()), h = Le(), u = De(), v = Ke(), j = F(() => {
325
+ var a;
326
+ const t = ((a = e.draft) == null ? void 0 : a.items.map((r) => r.sku)) ?? [];
327
+ return t.sort((r, o) => r.code.localeCompare(o.code)), t;
328
+ });
329
+ xe(_), ke(
330
+ () => e.show,
331
+ (t) => {
332
+ t && _();
333
+ }
334
+ );
335
+ const n = me(0), l = me(100);
336
+ async function _() {
337
+ var a, r, o;
338
+ g.value = !0;
339
+ const t = ((a = e.draft) == null ? void 0 : a.status) === J.enum.COMPLETED;
340
+ try {
341
+ if (await v.init(), t) {
342
+ const m = e.draft.closingId;
343
+ if (!m) {
344
+ u.open({
345
+ title: "Something went wrong",
346
+ message: "Closing draft is completed but closing document cannot be found.",
347
+ type: "error"
348
+ }), console.error("Closing draft is completed but closing document cannot be found.", {
349
+ draftId: (r = e.draft) == null ? void 0 : r._id
350
+ });
351
+ return;
352
+ }
353
+ const f = await h.getClosingById(m);
354
+ b.value = (f == null ? void 0 : f.skus) ?? [];
355
+ } else {
356
+ await p.readStockBalance();
357
+ const m = (((o = p.stockBalance) == null ? void 0 : o.skus) ?? []).groupBy(
358
+ (f) => f.id,
359
+ (f) => f.balance
360
+ );
361
+ b.value = v.skus.map(
362
+ (f) => m[f._id] ?? n
363
+ );
364
+ }
365
+ } catch (m) {
366
+ u.open({
367
+ title: "Something went wrong",
368
+ message: "Something went wrong when fetching info. Please try again.",
369
+ type: "error"
370
+ }), console.error("error on fetch stock balances", m);
371
+ } finally {
372
+ g.value = !1;
373
+ }
374
+ }
375
+ const q = F(
376
+ () => b.value.groupBy(
377
+ (t) => t.id,
378
+ (t) => t.balance
379
+ )
380
+ ), E = F(() => {
381
+ var a;
382
+ return (((a = e.draft) == null ? void 0 : a.items) ?? []).groupBy((r) => r.sku._id);
383
+ }), L = F(() => {
384
+ const t = j.value.reduce((r, o) => Math.max(
385
+ r,
386
+ o.unit.measurements.filter((m) => !m.name.toLocaleLowerCase().includes("inactive")).length
387
+ ), 0);
388
+ return [
389
+ {
390
+ id: "code",
391
+ accessorKey: "code",
392
+ header: () => "Code",
393
+ size: 200
394
+ },
395
+ {
396
+ id: "name",
397
+ accessorKey: "name",
398
+ header: () => "Name",
399
+ size: 300
400
+ },
401
+ {
402
+ id: "baseUnit",
403
+ accessorKey: "baseUnit",
404
+ header: () => "Base unit",
405
+ size: 200
406
+ },
407
+ {
408
+ id: "baseUnitAmount",
409
+ accessorKey: "baseUnitAmount",
410
+ header: () => "Base unit amount",
411
+ size: 200
412
+ },
413
+ ...Array.from({ length: t }).flatMap((r, o) => {
414
+ const m = `measurementAbbrev${o}`, f = `measurementAmount${o}`;
415
+ return [
416
+ {
417
+ id: f,
418
+ accessorKey: f,
419
+ header: () => `Sub unit amount ${o + 1}`,
420
+ size: 200,
421
+ meta: {
422
+ textAlign: "right"
423
+ }
424
+ },
425
+ {
426
+ id: m,
427
+ accessorKey: m,
428
+ header: () => `Sub unit ${o + 1}`,
429
+ size: 200
430
+ }
431
+ ];
432
+ }),
433
+ {
434
+ id: "systemBalance",
435
+ accessorKey: "systemBalance",
436
+ header: () => "System balance",
437
+ size: 200,
438
+ meta: {
439
+ textAlign: "right"
440
+ }
441
+ },
442
+ {
443
+ id: "physicalBalance",
444
+ accessorKey: "physicalBalance",
445
+ header: () => "Physical balance",
446
+ size: 200,
447
+ meta: {
448
+ textAlign: "right"
449
+ }
450
+ },
451
+ {
452
+ id: "adjustedBalance",
453
+ accessorKey: "adjustedBalance",
454
+ header: () => "Adjusted balance",
455
+ size: 200,
456
+ meta: {
457
+ textAlign: "right"
458
+ }
459
+ },
460
+ {
461
+ id: "adjustedDiffPercentage",
462
+ accessorKey: "adjustedDiffPercentage",
463
+ header: () => "Diff (%)",
464
+ size: 200,
465
+ meta: {
466
+ textAlign: "right"
467
+ }
468
+ }
469
+ ];
470
+ }), $ = F(() => L.value.map((t) => t.size ?? 0).reduce((t, a) => t + a));
471
+ function X(t) {
472
+ const a = t.measurementsAmounts.groupBy((o) => o.measurement.id), r = t.sku.unit.measurements.reduce((o, m) => {
473
+ var U, y;
474
+ const f = ((y = (U = a.get(m.id)) == null ? void 0 : U[0]) == null ? void 0 : y.amount) ?? n, x = de(m.conversion, f);
475
+ return o + +B(x);
476
+ }, +B(t.baseAmount));
477
+ return He(r, t.baseAmount.precision);
478
+ }
479
+ const A = F(() => j.value.map((t) => {
480
+ var y, S;
481
+ const a = (y = E.value.get(t._id)) == null ? void 0 : y[0], r = ((S = q.value.get(t._id)) == null ? void 0 : S[0]) ?? n;
482
+ if (!a)
483
+ return {
484
+ code: t.code,
485
+ name: t.name,
486
+ baseUnit: t.unit.abbrev,
487
+ baseUnitAmount: 0,
488
+ systemBalance: +B(r),
489
+ physicalBalance: 0,
490
+ adjustedBalance: -+B(r),
491
+ adjustedDiffPercentage: -100
492
+ };
493
+ const o = X(a), m = Ie(o, r), f = r.amount === 0 ? null : Ve(m, r), x = f ? de(f, l) : null;
494
+ return {
495
+ code: t.code,
496
+ name: t.name,
497
+ baseUnit: t.unit.abbrev,
498
+ baseUnitAmount: +B(a.baseAmount),
499
+ ...a.measurementsAmounts.reduce((k, P, I) => (P.measurement.name.toLocaleLowerCase().includes("inactive") || (k[`measurementAbbrev${I}`] = `(${P.measurement.abbrev}) × ${B(P.measurement.conversion)}`, k[`measurementAmount${I}`] = +B(P.amount)), k), {}),
500
+ systemBalance: +B(r),
501
+ physicalBalance: +B(o),
502
+ adjustedBalance: +B(m),
503
+ adjustedDiffPercentage: x ? +B(Oe(x, 2)) : null
504
+ };
505
+ })), w = F(() => {
506
+ var a, r;
507
+ if (!e.draft) return [];
508
+ const t = e.draft.approvedAt ? {
509
+ action: `Approve at ${N(e.draft.approvedAt)}`,
510
+ // actionAt: props.draft.approvedAt,
511
+ actionBy: e.draft.approvedBy,
512
+ remark: e.draft.approveRemark
513
+ } : (a = e.draft.rejectionHistory) == null ? void 0 : a.computeFirst((o) => ({
514
+ action: `Reject at ${N(o.rejectedAt)}`,
515
+ // actionAt: e.rejectedAt,
516
+ actionBy: o.rejectedBy,
517
+ remark: o.rejectRemark
518
+ }));
519
+ return [
520
+ {
521
+ label: "Created at",
522
+ value: N(e.draft.createdAt)
523
+ },
524
+ {
525
+ label: "Created by",
526
+ value: e.draft.createdBy.name
527
+ },
528
+ {
529
+ label: "Updated at",
530
+ value: N(e.draft.updatedAt)
531
+ },
532
+ {
533
+ label: "Updated by",
534
+ value: e.draft.updatedBy.name
535
+ },
536
+ {
537
+ label: "Effective at",
538
+ value: N(e.draft.effectiveAt ?? e.draft.updatedAt)
539
+ },
540
+ t ? {
541
+ label: "Last action",
542
+ value: t.action
543
+ } : null,
544
+ t && t.actionBy ? {
545
+ label: "Last action by",
546
+ value: (r = t.actionBy) == null ? void 0 : r.name
547
+ } : null,
548
+ t && t.remark ? {
549
+ label: "Action remark",
550
+ value: t.remark
551
+ } : null
552
+ ].filter((o) => o).map((o) => o);
553
+ });
554
+ return (t, a) => {
555
+ const r = T("FmMenuDivider"), o = T("FmCard"), m = T("FmCircularProgress"), f = T("FmTable"), x = T("FmButton"), U = T("FmSideSheet");
556
+ return R(), H(U, {
557
+ "dismiss-away": "",
558
+ "max-width": 900,
559
+ "model-value": c(i),
560
+ "onUpdate:modelValue": a[3] || (a[3] = (y) => pe(i) ? i.value = y : null),
561
+ header: "Closing details"
562
+ }, {
563
+ "side-sheet-footer": K(() => {
564
+ var y, S;
565
+ return [
566
+ s("div", ut, [
567
+ ((y = e.draft) == null ? void 0 : y.status) === c(J).enum.DRAFT ? (R(), H(x, {
568
+ key: 0,
569
+ label: "Approve",
570
+ onClick: a[0] || (a[0] = () => e.draft && c(d).approveDraft(e.draft))
571
+ })) : ue("", !0),
572
+ ((S = e.draft) == null ? void 0 : S.status) === c(J).enum.DRAFT ? (R(), H(x, {
573
+ key: 1,
574
+ label: "Reject",
575
+ variant: "destructive",
576
+ onClick: a[1] || (a[1] = () => e.draft && c(d).rejectDraft(e.draft))
577
+ })) : ue("", !0),
578
+ D(x, {
579
+ label: "Close",
580
+ variant: "tertiary",
581
+ onClick: a[2] || (a[2] = (k) => i.value = !1)
582
+ })
583
+ ])
584
+ ];
585
+ }),
586
+ default: K(() => [
587
+ s("div", et, [
588
+ D(o, {
589
+ variant: "outlined",
590
+ class: "flex flex-col gap-8 px-12 py-16"
591
+ }, {
592
+ default: K(() => {
593
+ var y, S;
594
+ return [
595
+ s("div", tt, [
596
+ a[4] || (a[4] = s("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
597
+ s("div", null, [
598
+ s("div", at, [
599
+ s("div", {
600
+ class: ge(c(Ce)(((y = t.draft) == null ? void 0 : y.status) ?? "DRAFT"))
601
+ }, Y(c(he)(((S = t.draft) == null ? void 0 : S.status) ?? "")), 3)
602
+ ])
603
+ ])
604
+ ]),
605
+ D(r),
606
+ (R(!0), O(ve, null, Se(w.value, (k, P) => (R(), O("div", {
607
+ class: "flex flex-col gap-4",
608
+ key: P
609
+ }, [
610
+ s("div", nt, [
611
+ s("div", ot, Y(k.label), 1)
612
+ ]),
613
+ s("div", st, Y(k.value), 1)
614
+ ]))), 128))
615
+ ];
616
+ }),
617
+ _: 1
618
+ }),
619
+ s("div", rt, [
620
+ a[8] || (a[8] = s("div", { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, "Closing items", -1)),
621
+ g.value ? (R(), O("div", lt, [
622
+ a[6] || (a[6] = s("div", { class: "h-80" }, null, -1)),
623
+ s("div", it, [
624
+ s("div", null, [
625
+ D(m, { size: "md" })
626
+ ]),
627
+ a[5] || (a[5] = s("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
628
+ ]),
629
+ a[7] || (a[7] = s("div", { class: "h-80" }, null, -1))
630
+ ])) : (R(), O("div", ct, [
631
+ s("div", {
632
+ style: ye({ width: `${$.value}px` })
633
+ }, [
634
+ D(f, {
635
+ "column-defs": L.value,
636
+ "row-data": A.value
637
+ }, null, 8, ["column-defs", "row-data"])
638
+ ], 4)
639
+ ]))
640
+ ])
641
+ ])
642
+ ]),
643
+ _: 1
644
+ }, 8, ["model-value"]);
645
+ };
646
+ }
647
+ }), mt = { class: "flex-1 flex flex-col gap-8" }, ft = { class: "flex flex-col" }, pt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, gt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, vt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, yt = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, jt = /* @__PURE__ */ te({
648
+ __name: "ClosingDraftView",
649
+ setup(C) {
650
+ const { t: e } = be(), { viewDraft: p } = Q(), { viewClosingDraftProps: d, viewClosingDraftShow: i } = Ne(Q()), g = ae(), b = Xe(), h = je(), { breakpoints: u } = Me();
651
+ g.watchLocation(b.fetchDrafts);
652
+ const v = F(() => b.loading), j = z(""), n = F(() => u.value.xs || u.value.sm), l = F(() => n.value ? 10 : 20);
653
+ function _(L) {
654
+ switch (L) {
655
+ case "refresh":
656
+ return b.fetchDrafts();
657
+ }
658
+ }
659
+ function q(L) {
660
+ return L;
661
+ }
662
+ const E = F(() => n.value ? [
663
+ {
664
+ label: "Refresh",
665
+ value: "refresh",
666
+ isPrimary: !1
667
+ }
668
+ ] : [
669
+ {
670
+ label: "Refresh",
671
+ value: "refresh",
672
+ isPrimary: !1
673
+ }
674
+ ]);
675
+ return (L, $) => {
676
+ const X = T("FmTable");
677
+ return R(), O(ve, null, [
678
+ D($e, {
679
+ title: c(e)("inventory.closing.draft.title"),
680
+ actions: E.value,
681
+ "onClick:action": _
682
+ }, {
683
+ default: K(() => [
684
+ s("div", {
685
+ class: ge([
686
+ "flex flex-col gap-8 max-h-full",
687
+ {
688
+ "p-0": n.value,
689
+ "px-24 ": !n.value
690
+ }
691
+ ])
692
+ }, [
693
+ D(Re, {
694
+ "change-location": "",
695
+ searchable: "",
696
+ search: j.value,
697
+ "onUpdate:search": $[0] || ($[0] = (A) => j.value = A)
698
+ }, null, 8, ["search"]),
699
+ D(X, {
700
+ style: ye(c(h).tableHeight),
701
+ "column-defs": c(b).columnDefs,
702
+ "row-data": c(b).drafts,
703
+ "search-value": j.value,
704
+ loading: v.value,
705
+ onRowClick: $[1] || ($[1] = (A) => c(p)(A.original)),
706
+ "page-size": l.value
707
+ }, {
708
+ "list-row": K((A) => [
709
+ D(qe, {
710
+ row: A,
711
+ onRowClick: (w) => c(p)(w)
712
+ }, {
713
+ default: K((w) => {
714
+ var t, a, r, o, m, f, x, U, y, S, k, P, I, G, ne, oe, se, re, W, le;
715
+ return [
716
+ s("div", mt, [
717
+ s("div", ft, [
718
+ s("div", pt, [
719
+ D(c(Z), {
720
+ render: (r = (a = (t = w._id) == null ? void 0 : t.column) == null ? void 0 : a.columnDef) == null ? void 0 : r.cell,
721
+ props: (m = (o = w._id) == null ? void 0 : o.getContext) == null ? void 0 : m.call(o)
722
+ }, null, 8, ["render", "props"])
723
+ ]),
724
+ s("div", gt, [
725
+ D(c(Z), {
726
+ render: (U = (x = (f = w.name) == null ? void 0 : f.column) == null ? void 0 : x.columnDef) == null ? void 0 : U.cell,
727
+ props: (S = (y = w.name) == null ? void 0 : y.getContext) == null ? void 0 : S.call(y)
728
+ }, null, 8, ["render", "props"])
729
+ ]),
730
+ s("div", vt, Y([
731
+ ...A.original.items.slice(0, 3).map((we) => we.sku.name),
732
+ ...A.original.items.length >= 3 ? [`and ${A.original.items.length - 3} more items`] : []
733
+ ].join(", ")), 1),
734
+ s("div", yt, [
735
+ D(c(Z), {
736
+ render: (I = (P = (k = w.ref) == null ? void 0 : k.column) == null ? void 0 : P.columnDef) == null ? void 0 : I.cell,
737
+ props: (ne = (G = w.ref) == null ? void 0 : G.getContext) == null ? void 0 : ne.call(G)
738
+ }, null, 8, ["render", "props"])
739
+ ])
740
+ ]),
741
+ s("div", null, [
742
+ D(c(Z), {
743
+ render: (re = (se = (oe = w.status) == null ? void 0 : oe.column) == null ? void 0 : se.columnDef) == null ? void 0 : re.cell,
744
+ props: (le = (W = w.status) == null ? void 0 : W.getContext) == null ? void 0 : le.call(W)
745
+ }, null, 8, ["render", "props"])
746
+ ])
747
+ ])
748
+ ];
749
+ }),
750
+ _: 2
751
+ }, 1032, ["row", "onRowClick"])
752
+ ]),
753
+ _: 1
754
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
755
+ ], 2)
756
+ ]),
757
+ _: 1
758
+ }, 8, ["title", "actions"]),
759
+ (R(), H(Be, { to: "body" }, [
760
+ D(dt, Fe(c(d), {
761
+ show: c(i),
762
+ "onUpdate:show": $[2] || ($[2] = (A) => pe(i) ? i.value = A : null),
763
+ onSubmitted: $[3] || ($[3] = (A) => c(b).fetchDrafts())
764
+ }), null, 16, ["show"])
765
+ ]))
766
+ ], 64);
767
+ };
768
+ }
769
+ });
770
+ export {
771
+ jt as default
772
+ };