@feedmepos/mf-inventory-portal 1.1.1-dev.1 → 1.1.1-dev.2

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