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

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