@feedmepos/mf-inventory-portal 0.0.19-dev.10 → 0.0.19-dev.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/{ApprovalView-BgTTFiOw.js → ApprovalView-BtgtZgDY.js} +5 -5
  2. package/dist/{BindingsDialog-BROnpXEI.js → BindingsDialog-DDqu7p2z.js} +1 -1
  3. package/dist/{BindingsPicker-aQHfS_vY.js → BindingsPicker-BDhn5Do7.js} +1 -1
  4. package/dist/{BindingsTable-DvtIQMFk.js → BindingsTable-C5R7orsB.js} +1 -1
  5. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DR9YAhaJ.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D0sbKAX9.js} +1 -1
  6. package/dist/{IngredientsView-BgAQCCD-.js → IngredientsView-Ac52Wd12.js} +5 -5
  7. package/dist/{IntegrationView-DEBb_X5K.js → IntegrationView-6mJtJK-d.js} +2 -2
  8. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-VF3PDSzP.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-C2BFaTg-.js} +1 -1
  9. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BIRzNfFN.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CL0RBLOF.js} +1 -1
  10. package/dist/{PurchaseOrderPrintPreview-D2zNGZhx.js → PurchaseOrderPrintPreview-UzrsJ0AN.js} +10 -10
  11. package/dist/{ReceiveRequestView-Dc5JlUMC.js → ReceiveRequestView-DW9u9TJZ.js} +7 -7
  12. package/dist/{RecipeView-C1DBn8pW.js → RecipeView-W15pCZKU.js} +5 -5
  13. package/dist/{StockView-6wi6BEOE.js → StockView-BqEe-OIX.js} +167 -167
  14. package/dist/{SupplierView-CS7YdL5Q.js → SupplierView-CGr2N-e7.js} +5 -5
  15. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DupNA58V.js +739 -0
  16. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-COVncBoC.js +1676 -0
  17. package/dist/TransferTemplateView-HgaSR8L8.js +1101 -0
  18. package/dist/{UnitView-BUdKTKch.js → UnitView-C07Yrynl.js} +6 -6
  19. package/dist/{WarehouseView-BbreEn79.js → WarehouseView-DL-8j9vX.js} +4 -4
  20. package/dist/{app-B3oV5Muh.js → app-B1MZZxUg.js} +97 -22
  21. package/dist/app.d.ts +74 -0
  22. package/dist/app.js +1 -1
  23. package/dist/components/row-action.enum.d.ts +3 -1
  24. package/dist/{decimal-DzjRPmPY.js → decimal-BXf_WdLk.js} +1 -1
  25. package/dist/{id-to-date-CG1QobkF.js → id-to-date-Dlovyec6.js} +1 -1
  26. package/dist/layout-BJjS48J5.js +151 -0
  27. package/dist/{purchase-order-transaction-type-D-GMrgDp.js → purchase-order-transaction-type-CMIu0jrP.js} +92 -87
  28. package/dist/row-action.enum-PMKMRrZR.js +50 -0
  29. package/dist/{supplier-BE_AQA4h.js → supplier-IDQmZ4VM.js} +1 -1
  30. package/dist/tsconfig.app.tsbuildinfo +1 -1
  31. package/dist/views/stock/helper/stock-row-action.d.ts +2 -2
  32. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetails.vue.d.ts +20 -0
  33. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetailsProps.d.ts +9 -0
  34. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -0
  35. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +445 -1
  36. package/dist/{xlsx-BGXLmGtO.js → xlsx-CfdXcS72.js} +1 -1
  37. package/dist/{xlsx.util-DxU-P-ww.js → xlsx.util-C5Wx4IUs.js} +2 -2
  38. package/package.json +2 -2
  39. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CBbbXOhl.js +0 -745
  40. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-CWEypKBc.js +0 -1662
  41. package/dist/TransferTemplateView-C1hmdeKM.js +0 -933
  42. package/dist/layout-qEWDq5Vs.js +0 -147
  43. package/dist/row-action.enum-7jVyol1k.js +0 -36
@@ -0,0 +1,1676 @@
1
+ import { reactive as je, onMounted as Ke, computed as F, h as U, getCurrentInstance as Le, watch as Ue, defineComponent as ne, openBlock as S, createElementBlock as A, Fragment as be, renderList as Ae, createElementVNode as p, toDisplayString as I, unref as e, resolveComponent as P, createVNode as k, withCtx as O, createCommentVNode as Z, ref as V, createBlock as N, normalizeClass as Ie, normalizeStyle as tt, isRef as ce } from "vue";
2
+ import { useBreakpoints as ot, components as oe, FmButtonVariant as Ve, useSnackbar as Se, useDialog as Ye, useProxiedModel as st } from "@feedmepos/ui-library";
3
+ import { F as ae, D as Ne, R as ve } from "./row-action.enum-PMKMRrZR.js";
4
+ import { P as $, u as at, f as nt, b as We } from "./purchase-order-transaction-type-CMIu0jrP.js";
5
+ import { a as Q, t as rt, a2 as Oe, D as lt, b as Ze, R as qe, $ as it, a0 as ut, r as ct, G as Qe, l as dt, A as Be, M as pt, a3 as Ge, c as Te, a6 as mt, O as Ee, P as Re, a7 as ft, j as G, a8 as yt, u as Me, n as vt, a9 as bt, aa as ht, ab as _t, E as gt, ac as Ct, y as kt } from "./app-B1MZZxUg.js";
6
+ import { _ as Je, u as wt } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-CL0RBLOF.js";
7
+ import { useI18n as pe } from "@feedmepos/mf-common";
8
+ import "vue-router";
9
+ import { u as xe } from "./supplier-IDQmZ4VM.js";
10
+ import { F as de, c as Tt, _ as St } from "./layout-BJjS48J5.js";
11
+ import { _ as xt } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
12
+ import { defineStore as Pt } from "pinia";
13
+ function se(t, m, a, i) {
14
+ var d, v, l;
15
+ if (i != null && i.manualTotalCost)
16
+ return i == null ? void 0 : i.manualTotalCost;
17
+ const f = (l = (v = (d = i == null ? void 0 : i.supplier) == null ? void 0 : d.supplyItems) == null ? void 0 : v.find(
18
+ (b) => b.skuId === t._id
19
+ )) == null ? void 0 : l.defaultCost, o = t.defaultCost, n = f ?? o, g = n == null ? void 0 : n.costPerUnit, c = g ? n != null && n.measurement ? +Q(g) / +Q(n == null ? void 0 : n.measurement.conversion) : +Q(g) : void 0, r = c ? a ? c * +Q(a.conversion) : c : void 0, u = r ? +Q(m) * r : void 0;
20
+ return u ? {
21
+ ...rt(u ?? 0, 2),
22
+ currency: Oe()
23
+ } : {
24
+ amount: 0,
25
+ precision: 0,
26
+ currency: Oe()
27
+ };
28
+ }
29
+ var B = /* @__PURE__ */ ((t) => (t.Code = "Code", t.Name = "Name", t.Amount = "Amount", t.Cost = "Cost", t.Delete = "Delete", t))(B || {});
30
+ const Ft = () => {
31
+ const { t } = pe();
32
+ return U(
33
+ Je,
34
+ {
35
+ zIndex: 50,
36
+ class: "whitespace-nowrap"
37
+ },
38
+ t("inventory.transfer.form.items.table.Cost", [Ge()])
39
+ );
40
+ };
41
+ function $t(t) {
42
+ const { t: m } = pe(), a = je({}), { breakpoints: i } = ot(), f = Ze();
43
+ Ke(() => {
44
+ for (const c of t.items) {
45
+ if (!c.totalCost)
46
+ continue;
47
+ const r = se(c.sku, c.quantity, c.measurement, {
48
+ supplier: t.supplier
49
+ }), u = c.totalCost ?? lt.reset();
50
+ r ? a[c.sku._id] = r.amount !== u.amount || r.precision !== u.precision : a[c.sku._id] = !0;
51
+ }
52
+ });
53
+ function o(c) {
54
+ var u, s, d, v, l, b, w;
55
+ return !!(((s = (u = c.defaultCost) == null ? void 0 : u.costPerUnit) == null ? void 0 : s.amount) ?? ((w = (b = (l = (v = (d = t.supplier) == null ? void 0 : d.supplyItems) == null ? void 0 : v.find((x) => x.skuId === c._id)) == null ? void 0 : l.defaultCost) == null ? void 0 : b.costPerUnit) == null ? void 0 : w.amount));
56
+ }
57
+ const n = [
58
+ {
59
+ id: "Code",
60
+ header: () => m("inventory.transfer.form.items.table.Code"),
61
+ accessorKey: "code",
62
+ size: 96,
63
+ cell(c) {
64
+ const r = c.row.original;
65
+ return U(oe.FmTextField, {
66
+ modelValue: r.code,
67
+ "onUpdate:modelValue": (u) => {
68
+ t.updateItem({
69
+ ...r,
70
+ code: u
71
+ });
72
+ },
73
+ key: r.sku._id,
74
+ rules: [qe()],
75
+ labelMark: "required"
76
+ });
77
+ },
78
+ enableSorting: !1
79
+ },
80
+ {
81
+ id: "Name",
82
+ header: () => m("inventory.transfer.form.items.table.Name"),
83
+ minSize: 300,
84
+ cell(c) {
85
+ const r = c.row.original;
86
+ return U(oe.FmTextField, {
87
+ modelValue: r.name,
88
+ "onUpdate:modelValue": (u) => {
89
+ t.updateItem({
90
+ ...r,
91
+ name: u
92
+ });
93
+ },
94
+ key: r.sku._id,
95
+ rules: [qe()],
96
+ labelMark: "required"
97
+ });
98
+ },
99
+ enableSorting: !1
100
+ },
101
+ {
102
+ id: "Amount",
103
+ header: () => m("inventory.transfer.form.items.table.Amount"),
104
+ minSize: 200,
105
+ cell(c) {
106
+ var s, d, v;
107
+ const r = c.row.original, u = !!((v = (d = (s = t.template) == null ? void 0 : s.purchaseOrder) == null ? void 0 : d.items) != null && v.find(
108
+ (l) => l.sku._id === r.sku._id
109
+ ));
110
+ return U(it, {
111
+ style: {
112
+ flex: "1 1 0%"
113
+ },
114
+ modelValue: {
115
+ amount: r.quantity ?? { amount: 1, precision: 0 },
116
+ measurement: r.measurement ?? null
117
+ },
118
+ key: r.sku._id,
119
+ unit: r.sku.unit,
120
+ "onUpdate:modelValue": (l) => {
121
+ const b = {
122
+ ...r,
123
+ quantity: l.amount,
124
+ measurement: l.measurement
125
+ };
126
+ f.enableTotalCost && (b.totalCost = se(r.sku, r.quantity, r.measurement, {
127
+ supplier: t.supplier,
128
+ // NOTE: set undefined here if `manualTotalCost[row.sku._id] = false`, so that the function
129
+ // will return the auto calculated default cost instead of the manual total cost
130
+ manualTotalCost: a[r.sku._id] ? b.totalCost : void 0
131
+ })), t.updateItem(b);
132
+ },
133
+ stepper: r.quantityStep,
134
+ disableUnit: u,
135
+ disabled: t.disabled,
136
+ rules: [
137
+ ut(
138
+ +Q(
139
+ r.minimumQuantity ?? {
140
+ amount: 1,
141
+ precision: ct(r.sku.unit, r.measurement)
142
+ }
143
+ )
144
+ )
145
+ ],
146
+ applyDefaultRules: !0
147
+ });
148
+ },
149
+ enableSorting: !1
150
+ },
151
+ {
152
+ id: "Cost",
153
+ header: Ft,
154
+ size: 180,
155
+ cell(c) {
156
+ const r = c.row.original, u = o(r.sku), s = i.value.xs || i.value.sm;
157
+ return !a[r.sku._id] && u ? U(
158
+ "div",
159
+ {
160
+ class: [
161
+ "flex gap-4 fm-typo-en-body-md-400 items-center",
162
+ t.disabled ? "text-fm-color-typo-disabled" : ""
163
+ ],
164
+ key: r.sku._id
165
+ },
166
+ [
167
+ U(oe.FmButton, {
168
+ prependIcon: "edit",
169
+ variant: Ve.Tertiary,
170
+ disabled: t.disabled,
171
+ onClick() {
172
+ t.updateItem({
173
+ ...r,
174
+ totalCost: se(r.sku, r.quantity, r.measurement, {
175
+ supplier: t.supplier
176
+ })
177
+ }), a[r.sku._id] = !0;
178
+ }
179
+ }),
180
+ U(
181
+ "div",
182
+ {
183
+ class: "flex flex-col"
184
+ },
185
+ [
186
+ U(
187
+ "span",
188
+ s ? Qe(
189
+ se(r.sku, r.quantity, r.measurement, {
190
+ supplier: t.supplier
191
+ })
192
+ ) : Q(
193
+ se(r.sku, r.quantity, r.measurement, {
194
+ supplier: t.supplier
195
+ })
196
+ )
197
+ ),
198
+ U(
199
+ "span",
200
+ {
201
+ class: [
202
+ "fm-typo-en-body-sm-400",
203
+ t.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
204
+ ]
205
+ },
206
+ m("inventory.transfer.form.items.autoCalculated")
207
+ )
208
+ ]
209
+ )
210
+ ]
211
+ ) : U(
212
+ oe.FmTextField,
213
+ {
214
+ modelValue: Q(r.totalCost ?? { amount: 0, precision: 0 }),
215
+ key: r.sku._id,
216
+ "onUpdate:modelValue": (d) => {
217
+ t.updateItem({
218
+ ...r,
219
+ totalCost: {
220
+ ...dt(+d),
221
+ currency: Oe()
222
+ }
223
+ });
224
+ },
225
+ rules: [Be(0), pt(2)]
226
+ },
227
+ {
228
+ prepend() {
229
+ return s ? U(
230
+ "div",
231
+ {
232
+ class: [
233
+ "text-fm-typo-en-body-lg-400",
234
+ t.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
235
+ ]
236
+ },
237
+ Ge()
238
+ ) : null;
239
+ },
240
+ append() {
241
+ return u ? U(oe.FmButton, {
242
+ prependIcon: "close",
243
+ variant: "tertiary",
244
+ disabled: t.disabled,
245
+ onClick() {
246
+ t.updateItem({
247
+ ...r,
248
+ // NOTE: different from PO template, if a default cost is reenabled,
249
+ // the total cost will automatically assigned
250
+ totalCost: se(r.sku, r.quantity, r.measurement, {
251
+ supplier: t.supplier
252
+ })
253
+ }), a[r.sku._id] = !1;
254
+ }
255
+ }) : null;
256
+ }
257
+ }
258
+ );
259
+ },
260
+ enableSorting: !1
261
+ },
262
+ {
263
+ id: "Delete",
264
+ header: "",
265
+ cell(c) {
266
+ const r = c.row.original;
267
+ return U(oe.FmButton, {
268
+ key: r.sku._id,
269
+ class: "delete-button",
270
+ type: "button",
271
+ icon: "delete",
272
+ variant: "tertiary",
273
+ size: "md",
274
+ disabled: t.disabled,
275
+ onClick: () => {
276
+ t.deleteItem(r);
277
+ }
278
+ });
279
+ },
280
+ enableSorting: !1,
281
+ size: 40,
282
+ meta: {
283
+ cellClass: "",
284
+ headerClass: ""
285
+ }
286
+ }
287
+ ];
288
+ return {
289
+ columnDefs: F(() => f.enableTotalCost && t.transferType === $.PURCHASE ? n : n.filter(
290
+ (c) => c.id !== "Cost"
291
+ /* Cost */
292
+ ))
293
+ };
294
+ }
295
+ function Dt(t = "modelValue") {
296
+ var o, n;
297
+ const m = ((o = Le()) == null ? void 0 : o.props) ?? {}, a = ((n = Le()) == null ? void 0 : n.emit) ?? (() => {
298
+ }), i = je(Te(m[t])), f = `update:${mt(t)}`;
299
+ return Ue(i, (g) => {
300
+ a(f, g);
301
+ }), i;
302
+ }
303
+ const At = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, It = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, Vt = { class: "w-[450px] xs:w-full flex" }, Ot = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Rt = /* @__PURE__ */ p("span", { class: "text-fm-color-typo-secondary" }, "/", -1), Ut = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Bt = /* @__PURE__ */ p("span", null, /* @__PURE__ */ I(" "), -1), Xe = /* @__PURE__ */ ne({
304
+ __name: "SupplierPriceHistory",
305
+ props: {
306
+ prices: {}
307
+ },
308
+ setup(t) {
309
+ const m = xe();
310
+ function a(i) {
311
+ return m.suppliers.find((f) => f._id === i);
312
+ }
313
+ return (i, f) => (S(), A("div", At, [
314
+ (S(!0), A(be, null, Ae(Object.keys(i.prices), (o) => {
315
+ var n;
316
+ return S(), A("div", {
317
+ key: o,
318
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
319
+ }, [
320
+ p("div", It, I((n = a(o)) == null ? void 0 : n.name), 1),
321
+ p("div", Vt, [
322
+ (S(!0), A(be, null, Ae(i.prices[o].slice(0, 3), (g) => {
323
+ var c;
324
+ return S(), A("div", {
325
+ key: g.date,
326
+ class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
327
+ }, [
328
+ p("div", Ot, [
329
+ p("span", null, I(g.totalCost ? e(Qe)(g.totalCost) : "No data"), 1),
330
+ Rt,
331
+ p("span", null, I(e(Q)(g.totalUnit, !1)), 1),
332
+ p("span", null, I(((c = g.measurement) == null ? void 0 : c.abbrev) ?? g.unit.abbrev), 1)
333
+ ]),
334
+ p("div", Ut, [
335
+ p("span", null, "(#" + I(g.seqNumber) + ")", 1),
336
+ Bt,
337
+ p("span", null, I(e(Ee)(new Date(g.date))), 1)
338
+ ])
339
+ ]);
340
+ }), 128))
341
+ ])
342
+ ]);
343
+ }), 128))
344
+ ]));
345
+ }
346
+ }), Et = { class: "flex flex-col gap-8 py-16" }, Mt = { class: "flex items-center" }, Lt = { class: "flex-1 flex gap-1 items-center" }, Nt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, qt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Ht = { class: "flex gap-8 w-full" }, zt = { class: "flex-1 flex flex-col gap-4" }, jt = /* @__PURE__ */ p("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), Kt = { class: "flex-1 flex flex-col gap-4" }, Yt = /* @__PURE__ */ p("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), Wt = { class: "flex gap-8 w-full" }, Zt = { class: "flex-1 flex flex-col gap-4" }, Qt = /* @__PURE__ */ p("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), Gt = { class: "flex-1 flex flex-col gap-4" }, Jt = /* @__PURE__ */ p("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), Xt = /* @__PURE__ */ ne({
347
+ __name: "TransferItem",
348
+ props: {
349
+ cellByColId: {},
350
+ comparePriceBySku: {},
351
+ showComparePrice: { type: Boolean },
352
+ row: {}
353
+ },
354
+ setup(t) {
355
+ const { t: m } = pe();
356
+ return (a, i) => {
357
+ var n, g, c, r, u, s, d, v, l, b, w, x, q, H, E, z, j, J, L, M, h, C, R, X, K, he, Pe;
358
+ const f = P("FmLabel"), o = P("FmSpacer");
359
+ return S(), A("div", Et, [
360
+ p("div", Mt, [
361
+ p("div", Lt, [
362
+ p("span", Nt, " (" + I(a.row.original.sku.code) + ") ", 1),
363
+ p("span", qt, I(a.row.original.sku.name), 1)
364
+ ]),
365
+ p("div", null, [
366
+ k(e(de), {
367
+ render: (c = (g = (n = a.cellByColId.Delete) == null ? void 0 : n.column) == null ? void 0 : g.columnDef) == null ? void 0 : c.cell,
368
+ props: (u = (r = a.cellByColId.Delete) == null ? void 0 : r.getContext) == null ? void 0 : u.call(r)
369
+ }, null, 8, ["render", "props"])
370
+ ])
371
+ ]),
372
+ p("div", Ht, [
373
+ p("div", zt, [
374
+ k(f, {
375
+ label: e(m)(`inventory.transfer.form.items.table.${e(B).Code}`)
376
+ }, null, 8, ["label"]),
377
+ k(e(de), {
378
+ render: (v = (d = (s = a.cellByColId[e(B).Code]) == null ? void 0 : s.column) == null ? void 0 : d.columnDef) == null ? void 0 : v.cell,
379
+ props: (b = (l = a.cellByColId[e(B).Code]) == null ? void 0 : l.getContext) == null ? void 0 : b.call(l)
380
+ }, null, 8, ["render", "props"]),
381
+ jt
382
+ ]),
383
+ p("div", Kt, [
384
+ k(f, {
385
+ label: e(m)(`inventory.transfer.form.items.table.${e(B).Name}`)
386
+ }, null, 8, ["label"]),
387
+ k(e(de), {
388
+ render: (q = (x = (w = a.cellByColId[e(B).Name]) == null ? void 0 : w.column) == null ? void 0 : x.columnDef) == null ? void 0 : q.cell,
389
+ props: (E = (H = a.cellByColId[e(B).Name]) == null ? void 0 : H.getContext) == null ? void 0 : E.call(H)
390
+ }, null, 8, ["render", "props"]),
391
+ Yt
392
+ ])
393
+ ]),
394
+ p("div", Wt, [
395
+ p("div", Zt, [
396
+ k(f, {
397
+ label: e(m)(`inventory.transfer.form.items.table.${e(B).Amount}`)
398
+ }, null, 8, ["label"]),
399
+ k(e(de), {
400
+ render: (J = (j = (z = a.cellByColId[e(B).Amount]) == null ? void 0 : z.column) == null ? void 0 : j.columnDef) == null ? void 0 : J.cell,
401
+ props: (M = (L = a.cellByColId[e(B).Amount]) == null ? void 0 : L.getContext) == null ? void 0 : M.call(L)
402
+ }, null, 8, ["render", "props"]),
403
+ Qt
404
+ ]),
405
+ p("div", Gt, [
406
+ k(Je, { "z-index": 50 }, {
407
+ default: O(() => [
408
+ k(f, {
409
+ label: e(m)(`inventory.transfer.form.items.table.${e(B).Cost}2`)
410
+ }, null, 8, ["label"])
411
+ ]),
412
+ _: 1
413
+ }),
414
+ k(e(de), {
415
+ render: (R = (C = (h = a.cellByColId[e(B).Cost]) == null ? void 0 : h.column) == null ? void 0 : C.columnDef) == null ? void 0 : R.cell,
416
+ props: (K = (X = a.cellByColId[e(B).Cost]) == null ? void 0 : X.getContext) == null ? void 0 : K.call(X)
417
+ }, null, 8, ["render", "props"]),
418
+ Jt
419
+ ])
420
+ ]),
421
+ a.showComparePrice && Object.keys(a.comparePriceBySku[(he = a.row.original.sku) == null ? void 0 : he._id] ?? {}).length > 0 ? (S(), A(be, { key: 0 }, [
422
+ k(o, { class: "h-8" }),
423
+ k(Xe, {
424
+ prices: a.comparePriceBySku[(Pe = a.row.original.sku) == null ? void 0 : Pe._id]
425
+ }, null, 8, ["prices"])
426
+ ], 64)) : Z("", !0)
427
+ ]);
428
+ };
429
+ }
430
+ });
431
+ function ke(t) {
432
+ return ft.parse(t);
433
+ }
434
+ function we(t) {
435
+ return {
436
+ _id: t.doc._id,
437
+ internal: t.type,
438
+ contactName: t.doc.profile.name,
439
+ name: t.doc.profile.name,
440
+ email: t.doc.profile.email,
441
+ phoneNumber: t.doc.profile.phoneNo,
442
+ registrationNumber: t.doc.profile.regNo,
443
+ address: t.doc.profile.address
444
+ };
445
+ }
446
+ function eo(t, m) {
447
+ const a = xe(), i = G();
448
+ i.watchLocation(async () => {
449
+ await a.readSuppliers();
450
+ const u = t();
451
+ if (u.supplier._id) return;
452
+ const s = a.suppliers[0], d = i.locations[0];
453
+ m({
454
+ ...u,
455
+ supplier: s ? ke(s) : d ? we(d) : u.supplier
456
+ });
457
+ });
458
+ const f = F(
459
+ () => {
460
+ var u, s;
461
+ return typeof ((s = (u = t()) == null ? void 0 : u.supplier) == null ? void 0 : s.internal) == "string" ? $.TRANSFER : $.PURCHASE;
462
+ }
463
+ ), o = F({
464
+ get() {
465
+ var u, s;
466
+ return (s = (u = t()) == null ? void 0 : u.supplier) == null ? void 0 : s._id;
467
+ },
468
+ set(u) {
469
+ const s = t() ?? {};
470
+ if (f.value === $.PURCHASE) {
471
+ const l = a.suppliers.find((b) => b._id === u);
472
+ m({
473
+ ...s,
474
+ supplier: l ? ke(l) : s.supplier
475
+ });
476
+ return;
477
+ }
478
+ const v = i.locations.find((l) => l.doc._id === u);
479
+ m({
480
+ ...s,
481
+ supplier: v ? we(v) : s.supplier
482
+ });
483
+ }
484
+ }), n = F(() => a.suppliers.map(ke)), g = F(() => {
485
+ var s;
486
+ const u = ((s = i._currentLocation) == null ? void 0 : s.type) === Re.warehouse;
487
+ return i.locations.filter((d) => {
488
+ var l;
489
+ return !(d.dbName === ((l = i._currentLocation) == null ? void 0 : l.dbName)) && (!u || d.type === Re.warehouse) && d.acceptRequest;
490
+ }).map(we);
491
+ }), c = F(() => f.value === $.PURCHASE ? n.value.map((s) => ({
492
+ label: s.name,
493
+ value: s._id
494
+ })) : g.value.map((s) => ({
495
+ label: s.name,
496
+ sublabel: s.internal ? `${s.internal}` : void 0,
497
+ value: s._id
498
+ }))), r = F(() => {
499
+ var v, l;
500
+ const u = (l = (v = t()) == null ? void 0 : v.supplier) == null ? void 0 : l._id;
501
+ if (f.value === $.PURCHASE) {
502
+ const b = a.suppliers.find((w) => w._id === u);
503
+ return b ? ke(b) : null;
504
+ }
505
+ const d = i.locations.find((b) => b.doc._id);
506
+ return d ? we(d) : null;
507
+ });
508
+ return {
509
+ transferLocationModel: o,
510
+ transferLocationOptions: c,
511
+ locationOptionsTypePurchase: n,
512
+ locationOptionsTypeTransfer: g,
513
+ selectedLocation: r
514
+ };
515
+ }
516
+ function to(t) {
517
+ const m = F({
518
+ get() {
519
+ const o = t.getEffectiveAt();
520
+ return o ? new Date(o) : null;
521
+ },
522
+ set(o) {
523
+ t.setEffectiveAt((o == null ? void 0 : o.toISOString()) ?? null);
524
+ }
525
+ }), a = F({
526
+ get() {
527
+ return !!m.value;
528
+ },
529
+ set(o) {
530
+ o ? m.value = /* @__PURE__ */ new Date() : m.value = null;
531
+ }
532
+ }), i = F({
533
+ get() {
534
+ return m.value === null ? "" : Ee(m.value);
535
+ },
536
+ set(o) {
537
+ o ? m.value = /* @__PURE__ */ new Date(`${o} ${f.value}`) : m.value = null;
538
+ }
539
+ }), f = F({
540
+ get() {
541
+ return m.value === null ? "" : yt(m.value);
542
+ },
543
+ set(o) {
544
+ o ? m.value = /* @__PURE__ */ new Date(`${i.value} ${o}`) : m.value = null;
545
+ }
546
+ });
547
+ return {
548
+ backdatePo: m,
549
+ backdateSwitch: a,
550
+ backdateModel: i,
551
+ backdateTimeModel: f
552
+ };
553
+ }
554
+ const oo = {
555
+ width: "24",
556
+ height: "24",
557
+ viewBox: "0 0 24 24",
558
+ fill: "none",
559
+ xmlns: "http://www.w3.org/2000/svg"
560
+ }, so = ["fill"], ao = ["fill"], no = ["stroke"], ro = ["stroke"], lo = /* @__PURE__ */ ne({
561
+ __name: "SparkIcon",
562
+ props: {
563
+ size: {
564
+ type: Number,
565
+ default: 24
566
+ },
567
+ color: {
568
+ type: String,
569
+ default: "#c7c7cc"
570
+ }
571
+ },
572
+ setup(t) {
573
+ return (m, a) => (S(), A("svg", oo, [
574
+ p("path", {
575
+ d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
576
+ fill: t.color
577
+ }, null, 8, so),
578
+ p("path", {
579
+ d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
580
+ fill: t.color
581
+ }, null, 8, ao),
582
+ p("path", {
583
+ d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
584
+ stroke: t.color,
585
+ "stroke-width": "1.5",
586
+ "stroke-linecap": "round",
587
+ "stroke-linejoin": "round"
588
+ }, null, 8, no),
589
+ p("path", {
590
+ d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
591
+ stroke: t.color,
592
+ "stroke-width": "1.5",
593
+ "stroke-linecap": "round",
594
+ "stroke-linejoin": "round"
595
+ }, null, 8, ro)
596
+ ]));
597
+ }
598
+ }), io = { class: "flex gap-8 items-center" }, uo = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, co = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, po = { class: "flex items-center w-full" }, mo = { class: "flex-1" }, fo = { class: "fm-typo-en-title-sm-800" }, yo = { class: "flex items-start gap-8" }, vo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, bo = { class: "flex gap-1" }, ho = /* @__PURE__ */ p("div", { class: "grow" }, null, -1), He = /* @__PURE__ */ ne({
599
+ __name: "ForecastStock",
600
+ props: {
601
+ disabled: { type: Boolean }
602
+ },
603
+ emits: ["update:poItems"],
604
+ setup(t, { emit: m }) {
605
+ const a = m, i = V(!1), f = V(7), o = wt(), n = Se(), g = Me(), { t: c } = pe();
606
+ async function r() {
607
+ if (f.value < 1)
608
+ return;
609
+ i.value = !1, await o.readPurchaseOrder(f.value);
610
+ const u = [];
611
+ if (o.purchaseOrderForecast.skus.length <= 0) {
612
+ n.open({
613
+ message: c("inventory.transfer.form.items.forecastStock.notAvailable"),
614
+ type: "info"
615
+ });
616
+ return;
617
+ }
618
+ const s = o.purchaseOrderForecast.skus.reduce((d, v) => {
619
+ const l = g.skus.find((x) => x._id === v.id);
620
+ if (d.find((x) => x.sku._id === v.id) || !l)
621
+ return d;
622
+ const w = {
623
+ sku: l,
624
+ code: l.code,
625
+ name: l.name,
626
+ quantity: {
627
+ amount: v.amount,
628
+ precision: 0
629
+ }
630
+ };
631
+ return d.push(w), d;
632
+ }, u);
633
+ a("update:poItems", s);
634
+ }
635
+ return (u, s) => {
636
+ const d = P("FmButton"), v = P("FmIcon"), l = P("FmStepperField"), b = P("FmPopover");
637
+ return S(), N(b, {
638
+ disabled: u.disabled,
639
+ class: "flex",
640
+ "show-popover": i.value,
641
+ onPopoverChanged: s[3] || (s[3] = (w) => i.value = w)
642
+ }, {
643
+ "popover-button": O(() => [
644
+ k(d, {
645
+ label: "unused",
646
+ variant: "secondary",
647
+ "text-color": u.disabled ? "disabled" : "primary",
648
+ "bg-color": "transparent",
649
+ "border-color": u.disabled ? "disabled" : "primary",
650
+ disabled: u.disabled
651
+ }, {
652
+ default: O(() => [
653
+ p("div", io, [
654
+ k(lo, {
655
+ size: 24,
656
+ color: u.disabled ? "#c7c7cc" : "#ff7823"
657
+ }, null, 8, ["color"]),
658
+ p("div", uo, I(e(c)("inventory.transfer.form.items.forecastStock.title")), 1)
659
+ ])
660
+ ]),
661
+ _: 1
662
+ }, 8, ["text-color", "border-color", "disabled"])
663
+ ]),
664
+ default: O(() => [
665
+ p("div", co, [
666
+ p("div", po, [
667
+ p("div", mo, [
668
+ k(xt, { "z-index": 99 }, {
669
+ default: O(() => [
670
+ p("p", fo, I(e(c)("inventory.transfer.form.items.forecastStock.title")), 1)
671
+ ]),
672
+ _: 1
673
+ })
674
+ ]),
675
+ k(d, {
676
+ icon: "close",
677
+ size: "md",
678
+ variant: "tertiary",
679
+ onClick: s[0] || (s[0] = (w) => i.value = !1)
680
+ })
681
+ ]),
682
+ k(l, {
683
+ modelValue: f.value,
684
+ "onUpdate:modelValue": s[1] || (s[1] = (w) => f.value = w),
685
+ label: e(c)("inventory.transfer.form.items.forecastStock.days"),
686
+ rules: [e(Be)(1)]
687
+ }, {
688
+ "helper-text": O(() => [
689
+ p("div", yo, [
690
+ k(v, {
691
+ name: "warning",
692
+ size: "sm",
693
+ class: "text-fm-color-system-warning-300"
694
+ }),
695
+ p("div", vo, I(e(c)("inventory.transfer.form.items.forecastStock.replace")), 1)
696
+ ])
697
+ ]),
698
+ _: 1
699
+ }, 8, ["modelValue", "label", "rules"]),
700
+ p("div", bo, [
701
+ ho,
702
+ k(d, {
703
+ label: e(c)("common.cancel"),
704
+ variant: "tertiary",
705
+ onClick: s[2] || (s[2] = (w) => i.value = !1)
706
+ }, null, 8, ["label"]),
707
+ k(d, {
708
+ label: e(c)("inventory.transfer.form.items.forecastStock.generate"),
709
+ onClick: r
710
+ }, null, 8, ["label"])
711
+ ])
712
+ ])
713
+ ]),
714
+ _: 1
715
+ }, 8, ["disabled", "show-popover"]);
716
+ };
717
+ }
718
+ }), et = vt((t, m) => ({
719
+ async getTemplate(a) {
720
+ const i = G(), f = `${t.inventoryBackendUrl}/${i.currentLocationDBName}/purchase-order-template/${a}`;
721
+ return m.get(f);
722
+ },
723
+ async readTemplates() {
724
+ const a = G(), i = `${t.inventoryBackendUrl}/${a.currentLocationDBName}/purchase-order-template`;
725
+ return m.get(i);
726
+ },
727
+ async createTemplate(a) {
728
+ const i = G(), f = `${t.inventoryBackendUrl}/${i.currentLocationDBName}/purchase-order-template`;
729
+ return m.post(f, a);
730
+ },
731
+ async updateTemplate(a) {
732
+ const i = G(), f = `${t.inventoryBackendUrl}/${i.currentLocationDBName}/purchase-order-template`;
733
+ return m.post(f, a);
734
+ },
735
+ async deleteTemplate(a) {
736
+ const i = G(), f = `${t.inventoryBackendUrl}/${i.currentLocationDBName}/purchase-order-template`;
737
+ return m.delete(f, { _id: a._id, _rev: a._rev });
738
+ }
739
+ })), _o = Pt("transferTemplateActions", () => {
740
+ const t = at("receive/request"), m = Ye(), a = Se(), i = et(), f = V({});
741
+ function o() {
742
+ f.value = {
743
+ mode: ae.CREATE,
744
+ show: !0,
745
+ "onUpdate:show"(s) {
746
+ f.value.show = s;
747
+ }
748
+ };
749
+ }
750
+ function n(s) {
751
+ f.value = {
752
+ mode: ae.UPDATE,
753
+ modelValue: s,
754
+ show: !0,
755
+ "onUpdate:show"(d) {
756
+ f.value.show = d;
757
+ }
758
+ };
759
+ }
760
+ function g(s, d, v) {
761
+ m.open({
762
+ title: `Confirm deleting template ${s.name}?`,
763
+ message: "Deleted template can no longer be retrieved",
764
+ primaryActions: {
765
+ text: "Delete",
766
+ variant: Ve.Destructive,
767
+ close: !0
768
+ },
769
+ secondaryActions: {
770
+ text: "Cancel",
771
+ variant: Ve.Plain,
772
+ close: !0
773
+ }
774
+ }).onPrimary(async () => {
775
+ a.open({
776
+ title: `Deleting ${s.name}`,
777
+ type: "info"
778
+ });
779
+ try {
780
+ d.value = !0;
781
+ const [l] = await Promise.allSettled([
782
+ i.deleteTemplate(s),
783
+ new Promise((b) => setTimeout(b, 1e3))
784
+ ]);
785
+ if (l.status === "rejected") throw l.reason;
786
+ a.open({
787
+ title: `Deleted ${s.name}`,
788
+ type: "success"
789
+ });
790
+ } catch (l) {
791
+ a.open({
792
+ title: `Unable to delete ${s.name}`,
793
+ message: `See error from server: ${l}`,
794
+ type: "error"
795
+ }), console.error("error on deleting purchase order template", l);
796
+ } finally {
797
+ d.value = !1, v();
798
+ }
799
+ });
800
+ }
801
+ const c = V({});
802
+ function r(s) {
803
+ c.value = {
804
+ template: s,
805
+ show: !0,
806
+ "onUpdate:show"(d) {
807
+ c.value.show = d;
808
+ },
809
+ "onAction:edit"() {
810
+ c.value.show = !1, n(Te(s));
811
+ },
812
+ "onAction:use"() {
813
+ c.value.show = !1, u(Te(s));
814
+ }
815
+ };
816
+ }
817
+ function u(s) {
818
+ t.promptCreateTransferDialog({
819
+ ...s.purchaseOrder,
820
+ template: s._id
821
+ });
822
+ }
823
+ return {
824
+ createTemplate: o,
825
+ viewTemplate: r,
826
+ updateTemplate: n,
827
+ deleteTemplate: g,
828
+ useTemplate: u,
829
+ templateDialogProps: f,
830
+ templateDetailsProps: c,
831
+ transferFormDialogProps: t.transferDialogProps
832
+ };
833
+ });
834
+ function De(t) {
835
+ var a;
836
+ return ((a = t == null ? void 0 : t.supplier) == null ? void 0 : a.internal) ? $.TRANSFER : $.PURCHASE;
837
+ }
838
+ const ze = "use";
839
+ function go() {
840
+ const { t } = pe(), { viewTemplate: m, updateTemplate: a, deleteTemplate: i, useTemplate: f } = _o(), o = V(new Array()), n = V(!1), g = G(), c = et();
841
+ async function r() {
842
+ if (o.value = [], !!g._currentLocation) {
843
+ n.value = !0;
844
+ try {
845
+ const [v] = await Promise.all([
846
+ c.readTemplates(),
847
+ new Promise((l) => setTimeout(l, 1e3))
848
+ ]);
849
+ o.value = v;
850
+ } catch (v) {
851
+ console.log("Something went wrong when fetching templates:", v);
852
+ } finally {
853
+ n.value = !1;
854
+ }
855
+ }
856
+ }
857
+ async function u(v) {
858
+ if (!o.value.find((l) => l._id) && g._currentLocation) {
859
+ n.value = !0;
860
+ try {
861
+ const [l] = await Promise.all([
862
+ c.getTemplate(v),
863
+ new Promise((b) => setTimeout(b, 1e3))
864
+ ]);
865
+ o.value = [l];
866
+ } catch (l) {
867
+ console.log("Something went wrong when fetching templates:", l);
868
+ } finally {
869
+ n.value = !1;
870
+ }
871
+ }
872
+ }
873
+ function s(v, l) {
874
+ switch (l = Te(l), v) {
875
+ case ze:
876
+ return f(l);
877
+ case ve.Details:
878
+ return m(l);
879
+ case ve.Edit:
880
+ return a(l);
881
+ case ve.Delete:
882
+ return i(l, n, r);
883
+ }
884
+ }
885
+ return { columnDefs: [
886
+ {
887
+ id: "_id",
888
+ accessorKey: "_id",
889
+ header: () => t("inventory.transfer.table.createdAt"),
890
+ cell(v) {
891
+ return nt(`${v.getValue()}`);
892
+ },
893
+ enableSorting: !0
894
+ },
895
+ {
896
+ id: "name",
897
+ accessorKey: "name",
898
+ header: () => t("inventory.transfer.table.name"),
899
+ enableSorting: !0,
900
+ size: 200
901
+ },
902
+ {
903
+ id: "supplier",
904
+ accessorKey: "purchaseOrder.supplier.name",
905
+ header: () => t("inventory.transfer.table.transferFrom"),
906
+ enableSorting: !0,
907
+ size: 200
908
+ },
909
+ {
910
+ id: "type",
911
+ header: () => t("inventory.transfer.receiveRequest.details.type.title"),
912
+ enableSorting: !0,
913
+ sortingFn(v, l) {
914
+ const b = De(v.original.purchaseOrder), w = De(l.original.purchaseOrder);
915
+ return b.localeCompare(w);
916
+ },
917
+ size: 200,
918
+ cell(v) {
919
+ const l = De(v.row.original.purchaseOrder), b = t(
920
+ `inventory.transfer.receiveRequest.details.type.${l.toLocaleLowerCase()}`
921
+ );
922
+ return U(oe.FmChip, {
923
+ label: b,
924
+ class: "fm-chip-transfer-info",
925
+ compact: !0
926
+ });
927
+ }
928
+ },
929
+ {
930
+ id: "noOfItems",
931
+ accessorKey: "purchaseOrder.items.length",
932
+ header: () => t("inventory.transfer.table.noOfItems"),
933
+ enableSorting: !1,
934
+ meta: {
935
+ width: "10rem",
936
+ textAlign: "right"
937
+ }
938
+ },
939
+ {
940
+ id: "ref",
941
+ accessorKey: "purchaseOrder.ref",
942
+ header: () => t("inventory.transfer.table.reference"),
943
+ enableSorting: !1,
944
+ size: "auto"
945
+ },
946
+ {
947
+ id: "action",
948
+ cell(v) {
949
+ const l = v.row.original, b = [
950
+ {
951
+ translationKey: "inventory.transfer.template.use",
952
+ value: ze,
953
+ color: "text-fm-color-typo-primary"
954
+ },
955
+ Ne[ve.Edit],
956
+ Ne[ve.Delete]
957
+ ];
958
+ return Tt(b, (w) => s(w, l));
959
+ },
960
+ enableSorting: !1,
961
+ size: 40,
962
+ meta: {
963
+ cellClass: "",
964
+ headerClass: ""
965
+ }
966
+ }
967
+ ], templates: o, loading: n, fetchTemplates: r, loadTemplate: u };
968
+ }
969
+ function Co() {
970
+ const t = Se(), m = We(), a = V(!1);
971
+ Ue(a, (n) => {
972
+ n && (f.value = !0, i().finally(() => {
973
+ f.value = !1;
974
+ }));
975
+ });
976
+ async function i() {
977
+ try {
978
+ const { startDate: n, endDate: g } = bt(6), u = (await m.getPurchaseOrders({ start: n, end: g })).filter(
979
+ (s) => {
980
+ var d, v;
981
+ return s.status === ht.enum.COMPLETE && ((d = s.supplier) == null ? void 0 : d.internal) !== "warehouse" && ((v = s.supplier) == null ? void 0 : v.internal) !== "restaurant";
982
+ }
983
+ ).reduce((s, d) => {
984
+ const v = new Date(_t(d._id)), l = d.supplier._id;
985
+ for (const b of d.items) {
986
+ if (!b.totalCost) continue;
987
+ const w = s[b.sku._id] ?? {}, x = w[l] ?? [];
988
+ x.push({
989
+ date: v.toISOString(),
990
+ totalUnit: b.quantity,
991
+ totalCost: b.totalCost,
992
+ unit: b.sku.unit,
993
+ measurement: b.measurement,
994
+ seqNumber: d.seqNumber
995
+ }), w[l] = x, s[b.sku._id] = w;
996
+ }
997
+ return s;
998
+ }, {});
999
+ o.value = u;
1000
+ } catch {
1001
+ t.open({
1002
+ title: "Something went wrong",
1003
+ message: "Cannot retrieve supplier purchase history. Please try again."
1004
+ }), a.value = !1;
1005
+ }
1006
+ }
1007
+ const f = V(!1), o = V({});
1008
+ return {
1009
+ comparePricesToggle: a,
1010
+ comparePriceFetching: f,
1011
+ comparePriceBySku: o
1012
+ };
1013
+ }
1014
+ const ko = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, wo = { key: 0 }, To = ["colspan"], So = /* @__PURE__ */ ne({
1015
+ __name: "TransferItemTable",
1016
+ props: {
1017
+ row: {},
1018
+ comparePriceBySku: {},
1019
+ showComparePrice: { type: Boolean }
1020
+ },
1021
+ setup(t) {
1022
+ function m(a) {
1023
+ return a.column.columnDef.meta;
1024
+ }
1025
+ return (a, i) => {
1026
+ var f, o;
1027
+ return S(), A(be, null, [
1028
+ p("tr", {
1029
+ class: Ie(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
1030
+ "bg-fm-color-neutral-gray-100": a.row.getIsSelected()
1031
+ }])
1032
+ }, [
1033
+ (S(!0), A(be, null, Ae(a.row.getVisibleCells(), (n) => {
1034
+ var g, c, r, u;
1035
+ return S(), A("td", {
1036
+ key: n.id,
1037
+ class: Ie([
1038
+ "h-[52px] px-16 text-fm-color-typo-primary",
1039
+ ((g = m(n)) == null ? void 0 : g.cellClass) ?? "px-16"
1040
+ ]),
1041
+ style: tt({
1042
+ width: (c = m(n)) == null ? void 0 : c.width,
1043
+ maxWidth: (r = m(n)) == null ? void 0 : r.maxWidth,
1044
+ textAlign: ((u = m(n)) == null ? void 0 : u.textAlign) ?? "left"
1045
+ })
1046
+ }, [
1047
+ p("span", ko, [
1048
+ k(e(de), {
1049
+ render: n.column.columnDef.cell,
1050
+ props: n.getContext()
1051
+ }, null, 8, ["render", "props"])
1052
+ ])
1053
+ ], 6);
1054
+ }), 128))
1055
+ ], 2),
1056
+ a.showComparePrice && Object.keys(a.comparePriceBySku[(f = a.row.original.sku) == null ? void 0 : f._id] ?? {}).length > 0 ? (S(), A("tr", wo, [
1057
+ p("td", {
1058
+ colspan: a.row.getVisibleCells().length
1059
+ }, [
1060
+ k(Xe, {
1061
+ prices: a.comparePriceBySku[(o = a.row.original.sku) == null ? void 0 : o._id]
1062
+ }, null, 8, ["prices"])
1063
+ ], 8, To)
1064
+ ])) : Z("", !0)
1065
+ ], 64);
1066
+ };
1067
+ }
1068
+ }), xo = { class: "flex flex-col gap-4" }, Po = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, Fo = { class: "flex flex-col gap-16" }, $o = { class: "flex flex-col gap-24" }, Do = {
1069
+ key: 0,
1070
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
1071
+ }, Ao = { class: "flex xs:flex-col sm:flex-col" }, Io = /* @__PURE__ */ p("div", { class: "xs:hidden sm:hidden h-48 lg:w-16 md:w-16" }, null, -1), Vo = {
1072
+ key: 0,
1073
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
1074
+ }, Oo = { class: "flex-1" }, Ro = { class: "flex-1" }, Uo = {
1075
+ key: 1,
1076
+ class: "flex items-center gap-4"
1077
+ }, Bo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Eo = { class: "flex flex-col gap-16" }, Mo = { class: "flex sm:flex-col xs:flex-col gap-16 items-center xs:items-start sm:items-start" }, Lo = { class: "flex-1 gap-8 fm-typo-en-title-sm-800" }, No = { class: "flex gap-8" }, qo = {
1078
+ key: 0,
1079
+ class: "xs:w-full"
1080
+ }, Ho = /* @__PURE__ */ ne({
1081
+ __name: "TransferForm2",
1082
+ props: {
1083
+ modelValue: {},
1084
+ disabled: { type: Boolean },
1085
+ suppliers: {},
1086
+ skus: {},
1087
+ lastClosingDate: {}
1088
+ },
1089
+ emits: ["validation-success", "form:ready"],
1090
+ setup(t, { expose: m, emit: a }) {
1091
+ const i = t, f = a, o = Dt(), { t: n } = pe(), g = G(), c = Me(), r = xe(), u = Ze(), s = go(), d = F(
1092
+ () => s.templates.value.find((y) => y._id === o.template)
1093
+ ), v = F(() => o.status === "DRAFT" || !o._rev);
1094
+ Ke(async () => {
1095
+ try {
1096
+ if (!o.template) return;
1097
+ await s.loadTemplate(o.template);
1098
+ } finally {
1099
+ f("form:ready");
1100
+ }
1101
+ });
1102
+ const l = F(
1103
+ () => g.currentLocation.type === Re.restaurant
1104
+ );
1105
+ g.watchLocation(async () => {
1106
+ location && (o.supplier || (o.supplier = r.suppliers.find((y) => y) ?? o.supplier));
1107
+ });
1108
+ const b = Ye(), w = eo(
1109
+ () => o,
1110
+ (y) => {
1111
+ Object.assign(o, y);
1112
+ }
1113
+ ), x = F({
1114
+ get() {
1115
+ var y;
1116
+ return typeof ((y = o == null ? void 0 : o.supplier) == null ? void 0 : y.internal) == "string" ? $.TRANSFER : $.PURCHASE;
1117
+ },
1118
+ set(y) {
1119
+ var Y;
1120
+ const _ = typeof ((Y = o == null ? void 0 : o.supplier) == null ? void 0 : Y.internal) == "string" ? $.TRANSFER : $.PURCHASE;
1121
+ y !== _ && (o.supplier = y === $.PURCHASE ? w.locationOptionsTypePurchase.value[0] : w.locationOptionsTypeTransfer.value[0]);
1122
+ }
1123
+ }), q = F(() => w.transferLocationOptions.value), H = F({
1124
+ get() {
1125
+ return o.supplier._id;
1126
+ },
1127
+ set(y) {
1128
+ w.transferLocationModel.value = y;
1129
+ }
1130
+ }), E = F({
1131
+ get() {
1132
+ return o.remark ?? void 0;
1133
+ },
1134
+ set(y) {
1135
+ o.remark = y;
1136
+ }
1137
+ }), { backdatePo: z, backdateSwitch: j, backdateModel: J, backdateTimeModel: L } = to({
1138
+ getEffectiveAt() {
1139
+ return o.effectiveAt;
1140
+ },
1141
+ setEffectiveAt(y) {
1142
+ o.effectiveAt = y;
1143
+ }
1144
+ }), { comparePricesToggle: M, comparePriceFetching: h, comparePriceBySku: C } = Co(), R = V();
1145
+ m({
1146
+ validateInputs: () => {
1147
+ var y, _;
1148
+ (_ = (y = R.value) == null ? void 0 : y.validateInputs) == null || _.call(y);
1149
+ },
1150
+ resetInputsValidation: () => {
1151
+ var y, _;
1152
+ (_ = (y = R.value) == null ? void 0 : y.resetInputsValidation) == null || _.call(y);
1153
+ },
1154
+ resetInputs: () => {
1155
+ var y, _;
1156
+ (_ = (y = R.value) == null ? void 0 : y.resetInputs) == null || _.call(y);
1157
+ }
1158
+ });
1159
+ const X = $t({
1160
+ updateItem: (y) => {
1161
+ o.items = o.items.map((_) => _.sku._id !== y.sku._id ? _ : y);
1162
+ },
1163
+ deleteItem: (y) => {
1164
+ o.items = o.items.filter((_) => _.sku._id !== y.sku._id);
1165
+ },
1166
+ get supplier() {
1167
+ return o.supplier;
1168
+ },
1169
+ get items() {
1170
+ return o.items;
1171
+ },
1172
+ get transferType() {
1173
+ return x.value;
1174
+ },
1175
+ get template() {
1176
+ return d.value;
1177
+ },
1178
+ get disabled() {
1179
+ return i.disabled;
1180
+ }
1181
+ }), K = F(() => X.columnDefs.value);
1182
+ function he() {
1183
+ var _e, fe, ge;
1184
+ let y;
1185
+ ((D) => {
1186
+ D.IsInTemplate = "IsInTemplate", D.IsOutsideTemplate = "IsOutsideTemplate";
1187
+ })(y || (y = {}));
1188
+ const _ = [
1189
+ {
1190
+ id: "IsInTemplate",
1191
+ label: "From template",
1192
+ sublabel: "These are defined in the template"
1193
+ },
1194
+ {
1195
+ id: "IsOutsideTemplate",
1196
+ label: "Other",
1197
+ collapse: !0
1198
+ }
1199
+ ], Y = new Set((ge = (fe = (_e = d.value) == null ? void 0 : _e.purchaseOrder) == null ? void 0 : fe.items) == null ? void 0 : ge.map((D) => D.sku._id)), me = c.skus.map(
1200
+ (D) => ({
1201
+ label: D.name,
1202
+ sublabel: D.code,
1203
+ value: D,
1204
+ groupId: Y.has(D._id) ? "IsInTemplate" : "IsOutsideTemplate"
1205
+ /* IsOutsideTemplate */
1206
+ })
1207
+ ), Fe = me.filter((D) => {
1208
+ var ee;
1209
+ return (ee = o.items) == null ? void 0 : ee.find((re) => re.sku._id === D.value._id);
1210
+ }).map((D) => D.value);
1211
+ b.open({
1212
+ title: n("inventory.transfer.form.selectItemTitle"),
1213
+ closeButton: !0,
1214
+ contentComponent: kt,
1215
+ contentComponentProps: {
1216
+ modelValue: Fe,
1217
+ items: me,
1218
+ groups: Y.size ? _ : void 0
1219
+ },
1220
+ primaryActions: {
1221
+ text: n("common.confirm"),
1222
+ close: !0
1223
+ },
1224
+ secondaryActions: {
1225
+ text: n("common.close"),
1226
+ close: !0,
1227
+ variant: "tertiary"
1228
+ }
1229
+ }).onPrimary((D) => {
1230
+ const ee = o.items ?? [], re = D.map((W) => {
1231
+ var Ce, ye;
1232
+ const le = ee.find((ie) => ie.sku._id === W._id);
1233
+ if (le)
1234
+ return le;
1235
+ const te = ((ye = (Ce = d.value) == null ? void 0 : Ce.purchaseOrder.items) == null ? void 0 : ye.find(
1236
+ (ie) => ie.sku._id === W._id
1237
+ )) ?? {
1238
+ sku: W,
1239
+ code: W.code,
1240
+ name: W.name,
1241
+ quantity: {
1242
+ amount: 1,
1243
+ precision: 0
1244
+ }
1245
+ };
1246
+ return x.value == $.PURCHASE && (te.totalCost = se(
1247
+ te.sku,
1248
+ te.quantity,
1249
+ te.measurement,
1250
+ {
1251
+ supplier: o.supplier
1252
+ }
1253
+ )), te;
1254
+ });
1255
+ re.sort((W, le) => W.sku.code.localeCompare(le.sku.code)), o.items = re;
1256
+ });
1257
+ }
1258
+ function Pe(y) {
1259
+ return y;
1260
+ }
1261
+ return (y, _) => {
1262
+ var ye, ie;
1263
+ const Y = P("FmChip"), me = P("FmSelect"), Fe = P("FmTextField"), _e = P("FmTextarea"), fe = P("FmSwitch"), ge = P("FmDatePicker"), D = P("FmTimePicker"), ee = P("FmFormGroup"), re = P("FmIcon"), W = P("FmButton"), le = P("FmTooltip"), te = P("FmTable"), Ce = P("FmForm");
1264
+ return S(), A("div", xo, [
1265
+ p("div", Po, [
1266
+ (ye = i.modelValue) != null && ye.template ? (S(), N(Y, {
1267
+ key: 0,
1268
+ variant: y.disabled ? "warning" : void 0,
1269
+ label: `${e(n)("inventory.transfer.template.title")}: ${((ie = d.value) == null ? void 0 : ie.name) ?? e(n)("inventory.transfer.form.loading")}`,
1270
+ icon: "summarize",
1271
+ compact: ""
1272
+ }, null, 8, ["variant", "label"])) : Z("", !0),
1273
+ k(Y, {
1274
+ label: e(g).currentLocation.name,
1275
+ icon: "storefront",
1276
+ compact: ""
1277
+ }, null, 8, ["label"]),
1278
+ y.lastClosingDate ? (S(), N(Y, {
1279
+ key: 1,
1280
+ label: `${e(n)("inventory.transfer.form.lastClosing")}: ${e(Ee)(y.lastClosingDate)} ${e(gt)(y.lastClosingDate)}`,
1281
+ icon: "calendar_month",
1282
+ compact: ""
1283
+ }, null, 8, ["label"])) : Z("", !0)
1284
+ ]),
1285
+ k(Ce, {
1286
+ ref_key: "formRef",
1287
+ ref: R,
1288
+ class: "flex flex-col gap-32",
1289
+ disabled: y.disabled,
1290
+ onValidationFailed: console.log,
1291
+ onValidationSuccess: _[12] || (_[12] = ($e) => f("validation-success"))
1292
+ }, {
1293
+ default: O(() => {
1294
+ var $e;
1295
+ return [
1296
+ p("div", Fo, [
1297
+ p("div", $o, [
1298
+ k(me, {
1299
+ label: e(n)("inventory.transfer.form.type.title"),
1300
+ "model-value": x.value,
1301
+ "onUpdate:modelValue": _[0] || (_[0] = (T) => x.value = T),
1302
+ items: [
1303
+ {
1304
+ label: e(n)("inventory.transfer.form.type.purchase"),
1305
+ value: e($).PURCHASE,
1306
+ disabled: !e(w).locationOptionsTypePurchase.value.length,
1307
+ sublabel: e(w).locationOptionsTypePurchase.value.length ? void 0 : e(n)("inventory.transfer.form.noSupplierAvailable")
1308
+ },
1309
+ {
1310
+ label: e(n)("inventory.transfer.form.type.transfer"),
1311
+ value: e($).TRANSFER,
1312
+ disabled: !e(w).locationOptionsTypeTransfer.value.length,
1313
+ sublabel: e(w).locationOptionsTypeTransfer.value.length ? void 0 : e(n)("inventory.transfer.form.noLocationAvailable")
1314
+ }
1315
+ ],
1316
+ rules: [e(Be)(1)(q.value)]
1317
+ }, null, 8, ["label", "model-value", "items", "rules"]),
1318
+ k(me, {
1319
+ label: x.value === e($).PURCHASE ? e(n)("inventory.transfer.form.purchaseFrom") : e(n)("inventory.transfer.form.transferFrom"),
1320
+ modelValue: H.value,
1321
+ "onUpdate:modelValue": _[1] || (_[1] = (T) => H.value = T),
1322
+ items: q.value
1323
+ }, null, 8, ["label", "modelValue", "items"]),
1324
+ k(Fe, {
1325
+ label: e(n)("inventory.transfer.form.reference"),
1326
+ "label-mark": "optional",
1327
+ modelValue: e(o).ref,
1328
+ "onUpdate:modelValue": _[2] || (_[2] = (T) => e(o).ref = T)
1329
+ }, null, 8, ["label", "modelValue"]),
1330
+ k(_e, {
1331
+ label: e(n)("inventory.transfer.form.remark"),
1332
+ "label-mark": "optional",
1333
+ "max-length": 240,
1334
+ modelValue: E.value,
1335
+ "onUpdate:modelValue": _[3] || (_[3] = (T) => E.value = T),
1336
+ class: Ie([y.disabled ? "text-fm-color-typo-disabled " : ""])
1337
+ }, null, 8, ["label", "modelValue", "class"]),
1338
+ e(u).enableBackdatePo ? (S(), A("div", Do, [
1339
+ p("div", Ao, [
1340
+ k(fe, {
1341
+ modelValue: e(j),
1342
+ "onUpdate:modelValue": _[4] || (_[4] = (T) => ce(j) ? j.value = T : null),
1343
+ label: e(n)("inventory.transfer.form.backdateTransfer"),
1344
+ sublabel: e(n)("inventory.transfer.form.applyTransferToOlderDate"),
1345
+ "label-placement": "right",
1346
+ disabled: l.value && !y.lastClosingDate || y.disabled
1347
+ }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1348
+ Io,
1349
+ e(j) ? (S(), A("div", Vo, [
1350
+ p("div", Oo, [
1351
+ k(ge, {
1352
+ modelValue: e(J),
1353
+ "onUpdate:modelValue": _[5] || (_[5] = (T) => ce(J) ? J.value = T : null)
1354
+ }, null, 8, ["modelValue"])
1355
+ ]),
1356
+ p("div", Ro, [
1357
+ k(D, {
1358
+ modelValue: e(L),
1359
+ "onUpdate:modelValue": _[6] || (_[6] = (T) => ce(L) ? L.value = T : null)
1360
+ }, null, 8, ["modelValue"])
1361
+ ])
1362
+ ])) : Z("", !0)
1363
+ ]),
1364
+ e(z) ? (S(), N(ee, {
1365
+ key: 0,
1366
+ modelValue: e(z),
1367
+ "onUpdate:modelValue": _[7] || (_[7] = (T) => ce(z) ? z.value = T : null),
1368
+ rules: [e(Ct)(new Date(y.lastClosingDate), /* @__PURE__ */ new Date())]
1369
+ }, null, 8, ["modelValue", "rules"])) : Z("", !0),
1370
+ l.value && !y.lastClosingDate ? (S(), A("div", Uo, [
1371
+ k(re, {
1372
+ name: "error",
1373
+ size: "sm",
1374
+ class: "text-fm-color-typo-warning"
1375
+ }),
1376
+ p("span", Bo, I(e(n)("inventory.transfer.form.cannotBackdateWithoutClosing")), 1)
1377
+ ])) : Z("", !0)
1378
+ ])) : Z("", !0)
1379
+ ])
1380
+ ]),
1381
+ p("div", Eo, [
1382
+ k(ee, {
1383
+ "model-value": e(o).items,
1384
+ rules: [
1385
+ function(ue) {
1386
+ return ue && ue.length > 0 || e(n)("inventory.transfer.form.mustHaveAtLeastOneItem");
1387
+ }
1388
+ ]
1389
+ }, null, 8, ["model-value", "rules"]),
1390
+ p("div", Mo, [
1391
+ p("div", Lo, I(e(n)("inventory.transfer.form.items.title")), 1),
1392
+ p("div", No, [
1393
+ k(W, {
1394
+ disabled: y.disabled,
1395
+ label: e(n)("inventory.transfer.form.items.addItem"),
1396
+ "prepend-icon": "add",
1397
+ variant: "secondary",
1398
+ "text-color": "primary",
1399
+ "bg-color": "transparent",
1400
+ "border-color": "primary",
1401
+ onClick: _[8] || (_[8] = (T) => he()),
1402
+ size: "md"
1403
+ }, null, 8, ["disabled", "label"]),
1404
+ e(o).template ? (S(), N(le, {
1405
+ key: 0,
1406
+ "z-index": 50
1407
+ }, {
1408
+ content: O(() => [
1409
+ p("div", null, I(e(n)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1410
+ ]),
1411
+ default: O(() => [
1412
+ k(He, {
1413
+ "onUpdate:poItems": _[9] || (_[9] = (T) => e(o).items = T),
1414
+ disabled: ""
1415
+ })
1416
+ ]),
1417
+ _: 1
1418
+ })) : (S(), N(He, {
1419
+ key: 1,
1420
+ "onUpdate:poItems": _[10] || (_[10] = (T) => e(o).items = T),
1421
+ disabled: y.disabled || !!e(o).template
1422
+ }, null, 8, ["disabled"]))
1423
+ ])
1424
+ ]),
1425
+ x.value === e($).PURCHASE && v.value && e(u).enableTotalCost && (($e = y.modelValue) != null && $e.items.length) ? (S(), A("div", qo, [
1426
+ k(fe, {
1427
+ label: e(h) ? e(n)("inventory.transfer.form.items.fetchingData") : e(n)("inventory.transfer.form.items.comparePriceHistory"),
1428
+ "prepend-icon": "compare_arrows",
1429
+ "label-placement": "right",
1430
+ "model-value": e(M),
1431
+ "onUpdate:modelValue": _[11] || (_[11] = (T) => ce(M) ? M.value = T : null),
1432
+ disabled: e(h) || y.disabled
1433
+ }, null, 8, ["label", "model-value", "disabled"])
1434
+ ])) : Z("", !0),
1435
+ (S(), N(te, {
1436
+ "column-defs": K.value,
1437
+ "row-data": e(o).items,
1438
+ key: e(o).items.map((T) => T.sku._id).join("."),
1439
+ "hide-footer": ""
1440
+ }, {
1441
+ "table-row": O((T) => [
1442
+ k(So, {
1443
+ "compare-price-by-sku": e(C),
1444
+ "show-compare-price": x.value === e($).PURCHASE && e(M),
1445
+ row: T
1446
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row"])
1447
+ ]),
1448
+ "list-row": O((T) => [
1449
+ (S(), N(St, {
1450
+ row: T,
1451
+ key: e(o).items.map((ue) => ue.sku._id).join(".")
1452
+ }, {
1453
+ default: O((ue) => [
1454
+ k(Xt, {
1455
+ "compare-price-by-sku": e(C),
1456
+ "show-compare-price": x.value === e($).PURCHASE && e(M),
1457
+ row: T,
1458
+ "cell-by-col-id": ue
1459
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1460
+ ]),
1461
+ _: 2
1462
+ }, 1032, ["row"]))
1463
+ ]),
1464
+ _: 1
1465
+ }, 8, ["column-defs", "row-data"]))
1466
+ ])
1467
+ ];
1468
+ }),
1469
+ _: 1
1470
+ }, 8, ["disabled", "onValidationFailed"])
1471
+ ]);
1472
+ };
1473
+ }
1474
+ }), zo = { class: "flex items-center" }, jo = { class: "fm-typo-en-title-md-800" }, Ko = { class: "flex gap-4" }, ns = /* @__PURE__ */ ne({
1475
+ __name: "TransferDialog",
1476
+ props: {
1477
+ mode: {},
1478
+ modelValue: {},
1479
+ template: {},
1480
+ show: { type: Boolean },
1481
+ lastClosingDate: {}
1482
+ },
1483
+ emits: ["update:show", "submitted"],
1484
+ setup(t, { expose: m, emit: a }) {
1485
+ var M;
1486
+ const i = t, f = a, o = We(), n = Se(), g = xe(), c = Me(), r = G(), u = V(!1), s = V(!1), d = V(!1);
1487
+ async function v(h) {
1488
+ if (h) {
1489
+ s.value = !1;
1490
+ try {
1491
+ await g.readSuppliers(), s.value = !0;
1492
+ } catch {
1493
+ n.open({
1494
+ title: "Unable to fetch list of suppliers",
1495
+ message: "Try to refresh page to retry operation",
1496
+ type: "error"
1497
+ });
1498
+ }
1499
+ }
1500
+ }
1501
+ r.watchLocation(v);
1502
+ function l() {
1503
+ return {
1504
+ remark: void 0,
1505
+ ref: void 0,
1506
+ stockSnapshotId: void 0,
1507
+ effectiveAt: void 0,
1508
+ items: [],
1509
+ supplier: {
1510
+ _rev: void 0,
1511
+ email: void 0,
1512
+ internal: void 0,
1513
+ contactName: void 0,
1514
+ phoneNumber: void 0,
1515
+ registrationNumber: void 0,
1516
+ supplyItems: void 0,
1517
+ _id: "",
1518
+ name: "",
1519
+ address: {
1520
+ line2: void 0,
1521
+ line1: "",
1522
+ state: "",
1523
+ city: "",
1524
+ postcode: "",
1525
+ country: ""
1526
+ }
1527
+ },
1528
+ status: "DRAFT",
1529
+ _id: "",
1530
+ seqNumber: 0,
1531
+ deliveryOrder: []
1532
+ };
1533
+ }
1534
+ const b = st(i, "show"), w = V(i.modelValue ?? l()), x = V(((M = i.modelValue) == null ? void 0 : M._id) ?? `${Math.random()}`);
1535
+ Ue(
1536
+ () => i.show,
1537
+ (h) => {
1538
+ var C;
1539
+ h && (d.value = !1, w.value = i.modelValue ?? l(), x.value = ((C = i.modelValue) == null ? void 0 : C._id) ?? `${Math.random()}`);
1540
+ }
1541
+ );
1542
+ const q = F(() => !s.value || !d.value), H = F(() => {
1543
+ switch (i.mode) {
1544
+ case ae.CREATE:
1545
+ return "Add transfer";
1546
+ case ae.READ:
1547
+ return "View transfer";
1548
+ case ae.UPDATE:
1549
+ return "Edit transfer";
1550
+ }
1551
+ return "";
1552
+ }), E = V();
1553
+ m({
1554
+ validateInputs: () => {
1555
+ var h, C;
1556
+ (C = (h = E.value) == null ? void 0 : h.validateInputs) == null || C.call(h);
1557
+ },
1558
+ resetInputsValidation: () => {
1559
+ var h, C;
1560
+ (C = (h = E.value) == null ? void 0 : h.resetInputsValidation) == null || C.call(h);
1561
+ },
1562
+ resetInputs: () => {
1563
+ var h, C;
1564
+ (C = (h = E.value) == null ? void 0 : h.resetInputs) == null || C.call(h);
1565
+ }
1566
+ });
1567
+ async function z() {
1568
+ const h = w.value;
1569
+ u.value = !0, (h.supplier.internal === "warehouse" || h.supplier.internal === "restaurant") && (h.items = h.items.map(({ totalCost: C, ...R }) => R));
1570
+ try {
1571
+ await o.createPurchaseOrder(h), await new Promise((C) => setTimeout(C, 1e3)), n.open({
1572
+ title: "Created",
1573
+ message: "Your transfer draft has been created!",
1574
+ type: "success"
1575
+ }), f("update:show", !1), f("submitted");
1576
+ } catch (C) {
1577
+ n.open({
1578
+ title: "Cannot create purchase order",
1579
+ message: "Report to system administrator for troubleshooting.",
1580
+ type: "error"
1581
+ }), console.error("Error in creating purchase order", C);
1582
+ } finally {
1583
+ u.value = !1;
1584
+ }
1585
+ }
1586
+ async function j() {
1587
+ const h = w.value;
1588
+ u.value = !0, (h.supplier.internal === "warehouse" || h.supplier.internal === "restaurant") && (h.items = h.items.map(({ totalCost: C, ...R }) => R));
1589
+ try {
1590
+ await o.updatePurchaseOrder(h), await new Promise((C) => setTimeout(C, 1e3)), n.open({
1591
+ title: "Updated",
1592
+ message: "Your transfer draft has been updated!",
1593
+ type: "success"
1594
+ }), f("update:show", !1), f("submitted");
1595
+ } catch (C) {
1596
+ n.open({
1597
+ title: "Cannot update purchase order",
1598
+ message: "Report to system administrator for troubleshooting.",
1599
+ type: "error"
1600
+ }), console.error("Error in updating purchase order", C);
1601
+ } finally {
1602
+ u.value = !1;
1603
+ }
1604
+ }
1605
+ function J() {
1606
+ switch (i.mode) {
1607
+ case ae.CREATE:
1608
+ return z();
1609
+ case ae.UPDATE:
1610
+ return j();
1611
+ }
1612
+ }
1613
+ function L() {
1614
+ var h, C;
1615
+ (C = (h = E.value) == null ? void 0 : h.validateInputs) == null || C.call(h);
1616
+ }
1617
+ return (h, C) => {
1618
+ const R = P("FmButton"), X = P("FmSideSheet");
1619
+ return S(), N(X, {
1620
+ modelValue: e(b),
1621
+ "onUpdate:modelValue": C[3] || (C[3] = (K) => ce(b) ? b.value = K : null),
1622
+ "dismiss-away": "",
1623
+ "close-button": "",
1624
+ "max-width": 900
1625
+ }, {
1626
+ "side-sheet-header": O(() => [
1627
+ p("div", zo, [
1628
+ p("div", jo, I(H.value), 1)
1629
+ ])
1630
+ ]),
1631
+ default: O(() => [
1632
+ (S(), N(Ho, {
1633
+ class: "w-full",
1634
+ ref_key: "formRef",
1635
+ ref: E,
1636
+ "onForm:ready": C[0] || (C[0] = () => d.value = !0),
1637
+ onValidationSuccess: J,
1638
+ modelValue: w.value,
1639
+ "onUpdate:modelValue": C[1] || (C[1] = (K) => w.value = K),
1640
+ disabled: u.value || q.value,
1641
+ suppliers: e(g).suppliers,
1642
+ skus: e(c).skus,
1643
+ key: x.value,
1644
+ "last-closing-date": h.lastClosingDate
1645
+ }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1646
+ ]),
1647
+ "side-sheet-footer": O(() => [
1648
+ p("div", Ko, [
1649
+ k(R, {
1650
+ loading: u.value,
1651
+ disabled: q.value,
1652
+ label: "Save",
1653
+ onClick: L
1654
+ }, null, 8, ["loading", "disabled"]),
1655
+ k(R, {
1656
+ disabled: q.value,
1657
+ variant: "tertiary",
1658
+ label: "Close",
1659
+ onClick: C[2] || (C[2] = (K) => f("update:show", !1))
1660
+ }, null, 8, ["disabled"])
1661
+ ])
1662
+ ]),
1663
+ _: 1
1664
+ }, 8, ["modelValue"]);
1665
+ };
1666
+ }
1667
+ });
1668
+ export {
1669
+ ns as _,
1670
+ et as a,
1671
+ _o as b,
1672
+ se as c,
1673
+ Dt as d,
1674
+ go as e,
1675
+ eo as u
1676
+ };