@feedmepos/mf-inventory-portal 0.0.25-dev.15 → 0.0.25-dev.16

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