@feedmepos/mf-inventory-portal 0.0.19-dev.15 → 0.0.19-dev.17

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 (48) hide show
  1. package/dist/{ApprovalView-CRHU3Bv0.js → ApprovalView-YVJ8rI2M.js} +5 -5
  2. package/dist/{BindingsDialog-ChIRg0d3.js → BindingsDialog-C7ZO5bXe.js} +9 -9
  3. package/dist/{BindingsPicker-BJAbeiDf.js → BindingsPicker-BDsVbM3L.js} +1 -1
  4. package/dist/{BindingsTable-5MxWD_qa.js → BindingsTable-BiVQ4mvK.js} +1 -1
  5. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-vuSl8LVG.js +308 -0
  6. package/dist/{IngredientsView-qXrDtzSK.js → IngredientsView-CKDZsR2e.js} +5 -5
  7. package/dist/{IntegrationView-D6yFqod1.js → IntegrationView-DQZeJKul.js} +2 -2
  8. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DGurlvYg.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DDcFEUcz.js} +1 -1
  9. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-2Ady4pB4.js → PremiumBadge.vue_vue_type_script_setup_true_lang-6plo8rnV.js} +1 -1
  10. package/dist/{PurchaseOrderPrintPreview-BWwjMRqb.js → PurchaseOrderPrintPreview-Df-gYZFA.js} +1 -1
  11. package/dist/{ReceiveRequestView-C94SWDaj.js → ReceiveRequestView-CxW1ONAk.js} +8 -8
  12. package/dist/{RecipeView-CG9H_ZOo.js → RecipeView-B8eIaR2f.js} +4 -4
  13. package/dist/{StockView-BdXGfDNl.js → StockView-CqgqPyvI.js} +8 -8
  14. package/dist/SupplierView-CPHQT1Hn.js +817 -0
  15. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-DktBkwCx.js → TransferDetails.vue_vue_type_script_setup_true_lang-CBmoU3pN.js} +4 -4
  16. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DV6IxKMM.js +1435 -0
  17. package/dist/TransferTemplateView-BR2-tTiQ.js +1290 -0
  18. package/dist/{UnitView-Dx2vWJXi.js → UnitView-vUCf46QM.js} +5 -5
  19. package/dist/{WarehouseView-UkmUZnqH.js → WarehouseView-B3D5kkAU.js} +3 -3
  20. package/dist/api/purchase-order-template.d.ts +4 -0
  21. package/dist/api/supplier.d.ts +6 -4
  22. package/dist/{app-BLzTa0Ut.js → app-Ds9lsiAo.js} +5542 -5522
  23. package/dist/app.js +1 -1
  24. package/dist/{array-AvWd53LI.js → array-ClJzD_Lt.js} +3 -3
  25. package/dist/components/ChangeLocationComponent.vue.d.ts +14 -11
  26. package/dist/components/FmInventoryTableToolbar.vue.d.ts +0 -2
  27. package/dist/components/FmMultiselectDialogProps.d.ts +1 -0
  28. package/dist/{decimal-DLYVb_I_.js → decimal-BZJuYjv-.js} +1 -1
  29. package/dist/format-unit-display-Dw4iQUDG.js +707 -0
  30. package/dist/{id-to-date-CKplrnj_.js → id-to-date-CLG4t5Zp.js} +1 -1
  31. package/dist/layout/SingleColumnLayout.vue.d.ts +1 -0
  32. package/dist/{layout-B9sdKjL9.js → layout-b03Lvqhx.js} +1 -1
  33. package/dist/stores/feature.d.ts +1 -0
  34. package/dist/stores/location.d.ts +1 -0
  35. package/dist/stores/supplier.d.ts +9 -9
  36. package/dist/supplier-C9OQNEl0.js +69 -0
  37. package/dist/tsconfig.app.tsbuildinfo +1 -1
  38. package/dist/views/supplier/components/SupplierDialogProps.d.ts +0 -1
  39. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +583 -1
  40. package/dist/{xlsx-C3AV6UrJ.js → xlsx-B5RUBjKV.js} +1209 -1209
  41. package/dist/{xlsx.util-slrhXhsk.js → xlsx.util-H2UkpLte.js} +4 -4
  42. package/package.json +3 -3
  43. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D0j4VOis.js +0 -306
  44. package/dist/SupplierView-ClL2oc8K.js +0 -813
  45. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-BE95F9r1.js +0 -1437
  46. package/dist/TransferTemplateView-BXrNS8pg.js +0 -1279
  47. package/dist/format-unit-display-D_Z4TNZd.js +0 -668
  48. package/dist/supplier-BZ6HZcYB.js +0 -60
@@ -0,0 +1,1435 @@
1
+ import { reactive as He, onMounted as ze, computed as P, h as M, getCurrentInstance as Ee, watch as $e, defineComponent as se, openBlock as T, createElementBlock as V, Fragment as ve, renderList as Pe, createElementVNode as i, toDisplayString as A, unref as e, resolveComponent as I, createVNode as C, withCtx as D, createCommentVNode as K, ref as L, createBlock as z, normalizeClass as Ie, normalizeStyle as Je, isRef as ie } from "vue";
2
+ import { useBreakpoints as Xe, components as re, FmButtonVariant as et, useSnackbar as Ve, useDialog as tt, useProxiedModel as st } from "@feedmepos/ui-library";
3
+ import { F as fe } from "./row-action.enum-PMKMRrZR.js";
4
+ import { P as $, e as je, d as ot } from "./format-unit-display-Dw4iQUDG.js";
5
+ import { a as j, t as nt, a5 as Fe, D as at, b as We, R as Le, a2 as lt, a3 as rt, r as it, a4 as qe, G as Ye, l as ut, A as Ce, M as dt, a6 as Ze, c as ct, a9 as pt, O as Ae, P as Ke, aa as mt, j as De, ab as ft, u as Re, ac as yt, ad as vt, ae as bt, E as _t, af as gt, y as kt } from "./app-Ds9lsiAo.js";
6
+ import { _ as Qe, u as Ct } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-6plo8rnV.js";
7
+ import { useI18n as de } from "@feedmepos/mf-common";
8
+ import "vue-router";
9
+ import { u as he } from "./supplier-C9OQNEl0.js";
10
+ import { F as ue, _ as ht } from "./layout-b03Lvqhx.js";
11
+ import { _ as wt } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
12
+ function te(o, m, r, s) {
13
+ var u, c, k;
14
+ if (s != null && s.manualTotalCost)
15
+ return s == null ? void 0 : s.manualTotalCost;
16
+ const f = (k = (c = (u = s == null ? void 0 : s.supplier) == null ? void 0 : u.supplyItems) == null ? void 0 : c.find(
17
+ (b) => b.skuId === o._id
18
+ )) == null ? void 0 : k.defaultCost, t = o.defaultCost, a = f ?? t, x = a == null ? void 0 : a.costPerUnit, p = x ? a != null && a.measurement ? +j(x) / +j(a == null ? void 0 : a.measurement.conversion) : +j(x) : void 0, n = p ? r ? p * +j(r.conversion) : p : void 0, l = n ? +j(m) * n : void 0;
19
+ return l ? {
20
+ ...nt(l ?? 0, 2),
21
+ currency: Fe()
22
+ } : {
23
+ amount: 0,
24
+ precision: 0,
25
+ currency: Fe()
26
+ };
27
+ }
28
+ var E = /* @__PURE__ */ ((o) => (o.Code = "Code", o.Name = "Name", o.Amount = "Amount", o.Cost = "Cost", o.Delete = "Delete", o))(E || {});
29
+ const xt = () => {
30
+ const { t: o } = de();
31
+ return M(
32
+ Qe,
33
+ {
34
+ zIndex: 50,
35
+ class: "whitespace-nowrap"
36
+ },
37
+ o("inventory.transfer.form.items.table.Cost", [Ze()])
38
+ );
39
+ };
40
+ function St(o) {
41
+ const { t: m } = de(), r = He({}), { breakpoints: s } = Xe(), f = We();
42
+ ze(() => {
43
+ for (const p of o.items) {
44
+ if (!p.totalCost)
45
+ continue;
46
+ const n = te(p.sku, p.quantity, p.measurement, {
47
+ supplier: o.supplier
48
+ }), l = p.totalCost ?? at.reset();
49
+ n ? r[p.sku._id] = n.amount !== l.amount || n.precision !== l.precision : r[p.sku._id] = !0;
50
+ }
51
+ });
52
+ function t(p) {
53
+ var l, v, u, c, k, b, h;
54
+ return !!(((v = (l = p.defaultCost) == null ? void 0 : l.costPerUnit) == null ? void 0 : v.amount) ?? ((h = (b = (k = (c = (u = o.supplier) == null ? void 0 : u.supplyItems) == null ? void 0 : c.find((w) => w.skuId === p._id)) == null ? void 0 : k.defaultCost) == null ? void 0 : b.costPerUnit) == null ? void 0 : h.amount));
55
+ }
56
+ const a = [
57
+ {
58
+ id: "Code",
59
+ header: () => m("inventory.transfer.form.items.table.Code"),
60
+ accessorKey: "code",
61
+ size: 96,
62
+ cell(p) {
63
+ const n = p.row.original;
64
+ return M(re.FmTextField, {
65
+ modelValue: n.code,
66
+ "onUpdate:modelValue": (l) => {
67
+ o.updateItem({
68
+ ...n,
69
+ code: l
70
+ });
71
+ },
72
+ key: n.sku._id,
73
+ rules: [Le()],
74
+ labelMark: "required"
75
+ });
76
+ },
77
+ enableSorting: !1
78
+ },
79
+ {
80
+ id: "Name",
81
+ header: () => m("inventory.transfer.form.items.table.Name"),
82
+ minSize: 300,
83
+ cell(p) {
84
+ const n = p.row.original;
85
+ return M(re.FmTextField, {
86
+ modelValue: n.name,
87
+ "onUpdate:modelValue": (l) => {
88
+ o.updateItem({
89
+ ...n,
90
+ name: l
91
+ });
92
+ },
93
+ key: n.sku._id,
94
+ rules: [Le()],
95
+ labelMark: "required"
96
+ });
97
+ },
98
+ enableSorting: !1
99
+ },
100
+ {
101
+ id: "Amount",
102
+ header: () => m("inventory.transfer.form.items.table.Amount"),
103
+ minSize: 200,
104
+ cell(p) {
105
+ var v, u, c;
106
+ const n = p.row.original, l = (c = (u = (v = o.template) == null ? void 0 : v.purchaseOrder) == null ? void 0 : u.items) == null ? void 0 : c.find(
107
+ (k) => k.sku._id === n.sku._id
108
+ );
109
+ return M(lt, {
110
+ style: {
111
+ flex: "1 1 0%"
112
+ },
113
+ modelValue: {
114
+ amount: n.quantity ?? { amount: 1, precision: 0 },
115
+ measurement: n.measurement ?? null
116
+ },
117
+ key: n.sku._id,
118
+ unit: n.sku.unit,
119
+ "onUpdate:modelValue": (k) => {
120
+ const b = {
121
+ ...n,
122
+ quantity: k.amount,
123
+ measurement: k.measurement
124
+ };
125
+ f.enableTotalCost && (b.totalCost = te(n.sku, n.quantity, n.measurement, {
126
+ supplier: o.supplier,
127
+ // NOTE: set undefined here if `manualTotalCost[row.sku._id] = false`, so that the function
128
+ // will return the auto calculated default cost instead of the manual total cost
129
+ manualTotalCost: r[n.sku._id] ? b.totalCost : void 0
130
+ })), o.updateItem(b);
131
+ },
132
+ stepper: l == null ? void 0 : l.quantityStep,
133
+ disableUnit: !!l,
134
+ disabled: o.disabled,
135
+ rules: [
136
+ rt(
137
+ +j(
138
+ (l == null ? void 0 : l.minimumQuantity) ?? {
139
+ amount: 1,
140
+ precision: it(n.sku.unit, n.measurement)
141
+ }
142
+ )
143
+ ),
144
+ l != null && l.maximumQuantity ? qe(
145
+ +j(l == null ? void 0 : l.maximumQuantity)
146
+ ) : qe(1 / 0)
147
+ ],
148
+ applyDefaultRules: !0
149
+ });
150
+ },
151
+ enableSorting: !1
152
+ },
153
+ {
154
+ id: "Cost",
155
+ header: xt,
156
+ size: 180,
157
+ cell(p) {
158
+ const n = p.row.original, l = t(n.sku), v = s.value.xs || s.value.sm;
159
+ return !r[n.sku._id] && l ? M(
160
+ "div",
161
+ {
162
+ class: [
163
+ "flex gap-4 fm-typo-en-body-md-400 items-center",
164
+ o.disabled ? "text-fm-color-typo-disabled" : ""
165
+ ],
166
+ key: n.sku._id
167
+ },
168
+ [
169
+ M(re.FmButton, {
170
+ prependIcon: "edit",
171
+ variant: et.Tertiary,
172
+ disabled: o.disabled,
173
+ onClick() {
174
+ o.updateItem({
175
+ ...n,
176
+ totalCost: te(n.sku, n.quantity, n.measurement, {
177
+ supplier: o.supplier
178
+ })
179
+ }), r[n.sku._id] = !0;
180
+ }
181
+ }),
182
+ M(
183
+ "div",
184
+ {
185
+ class: "flex flex-col"
186
+ },
187
+ [
188
+ M(
189
+ "span",
190
+ v ? Ye(
191
+ te(n.sku, n.quantity, n.measurement, {
192
+ supplier: o.supplier
193
+ })
194
+ ) : j(
195
+ te(n.sku, n.quantity, n.measurement, {
196
+ supplier: o.supplier
197
+ })
198
+ )
199
+ ),
200
+ M(
201
+ "span",
202
+ {
203
+ class: [
204
+ "fm-typo-en-body-sm-400",
205
+ o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
206
+ ]
207
+ },
208
+ m("inventory.transfer.form.items.autoCalculated")
209
+ )
210
+ ]
211
+ )
212
+ ]
213
+ ) : M(
214
+ re.FmTextField,
215
+ {
216
+ modelValue: j(n.totalCost ?? { amount: 0, precision: 0 }),
217
+ key: n.sku._id,
218
+ "onUpdate:modelValue": (u) => {
219
+ o.updateItem({
220
+ ...n,
221
+ totalCost: {
222
+ ...ut(+u),
223
+ currency: Fe()
224
+ }
225
+ });
226
+ },
227
+ rules: [Ce(0), dt(2)]
228
+ },
229
+ {
230
+ prepend() {
231
+ return v ? M(
232
+ "div",
233
+ {
234
+ class: [
235
+ "text-fm-typo-en-body-lg-400",
236
+ o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
237
+ ]
238
+ },
239
+ Ze()
240
+ ) : null;
241
+ },
242
+ append() {
243
+ return l ? M(re.FmButton, {
244
+ prependIcon: "close",
245
+ variant: "tertiary",
246
+ disabled: o.disabled,
247
+ onClick() {
248
+ o.updateItem({
249
+ ...n,
250
+ // NOTE: different from PO template, if a default cost is reenabled,
251
+ // the total cost will automatically assigned
252
+ totalCost: te(n.sku, n.quantity, n.measurement, {
253
+ supplier: o.supplier
254
+ })
255
+ }), r[n.sku._id] = !1;
256
+ }
257
+ }) : null;
258
+ }
259
+ }
260
+ );
261
+ },
262
+ enableSorting: !1
263
+ },
264
+ {
265
+ id: "Delete",
266
+ header: "",
267
+ cell(p) {
268
+ const n = p.row.original;
269
+ return M(re.FmButton, {
270
+ key: n.sku._id,
271
+ class: "delete-button",
272
+ type: "button",
273
+ icon: "delete",
274
+ variant: "tertiary",
275
+ size: "md",
276
+ disabled: o.disabled,
277
+ onClick: () => {
278
+ o.deleteItem(n);
279
+ }
280
+ });
281
+ },
282
+ enableSorting: !1,
283
+ size: 40,
284
+ meta: {
285
+ cellClass: "",
286
+ headerClass: ""
287
+ }
288
+ }
289
+ ];
290
+ return {
291
+ columnDefs: P(() => f.enableTotalCost && o.transferType === $.PURCHASE ? a : a.filter(
292
+ (p) => p.id !== "Cost"
293
+ /* Cost */
294
+ ))
295
+ };
296
+ }
297
+ function Tt(o = "modelValue") {
298
+ var t, a;
299
+ const m = ((t = Ee()) == null ? void 0 : t.props) ?? {}, r = ((a = Ee()) == null ? void 0 : a.emit) ?? (() => {
300
+ }), s = He(ct(m[o] ?? {})), f = `update:${pt(o)}`;
301
+ return $e(s, (x) => {
302
+ r(f, x);
303
+ }), s;
304
+ }
305
+ const Pt = { 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" }, Ft = { class: "w-[450px] xs:w-full flex" }, $t = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Vt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ge = /* @__PURE__ */ se({
306
+ __name: "SupplierPriceHistory",
307
+ props: {
308
+ prices: {}
309
+ },
310
+ setup(o) {
311
+ const m = he();
312
+ function r(s) {
313
+ return m.suppliers.find((f) => f._id === s);
314
+ }
315
+ return (s, f) => (T(), V("div", Pt, [
316
+ (T(!0), V(ve, null, Pe(Object.keys(s.prices), (t) => {
317
+ var a;
318
+ return T(), V("div", {
319
+ key: t,
320
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
321
+ }, [
322
+ i("div", It, A((a = r(t)) == null ? void 0 : a.name), 1),
323
+ i("div", Ft, [
324
+ (T(!0), V(ve, null, Pe(s.prices[t].slice(0, 3), (x) => {
325
+ var p;
326
+ return T(), V("div", {
327
+ key: x.date,
328
+ class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
329
+ }, [
330
+ i("div", $t, [
331
+ i("span", null, A(x.totalCost ? e(Ye)(x.totalCost) : "No data"), 1),
332
+ f[0] || (f[0] = i("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
333
+ i("span", null, A(e(j)(x.totalUnit, !1)), 1),
334
+ i("span", null, A(((p = x.measurement) == null ? void 0 : p.abbrev) ?? x.unit.abbrev), 1)
335
+ ]),
336
+ i("div", Vt, [
337
+ i("span", null, "(#" + A(x.seqNumber) + ")", 1),
338
+ f[1] || (f[1] = i("span", null, A(" "), -1)),
339
+ i("span", null, A(e(Ae)(new Date(x.date))), 1)
340
+ ])
341
+ ]);
342
+ }), 128))
343
+ ])
344
+ ]);
345
+ }), 128))
346
+ ]));
347
+ }
348
+ }), At = { class: "flex flex-col gap-8 py-16" }, Dt = { class: "flex items-center" }, Rt = { class: "flex-1 flex gap-1 items-center" }, Ot = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Bt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Ut = { class: "flex gap-8 w-full" }, Mt = { class: "flex-1 flex flex-col gap-4" }, Et = { class: "flex-1 flex flex-col gap-4" }, Lt = { class: "flex gap-8 w-full" }, qt = { class: "flex-1 flex flex-col gap-4" }, Nt = { class: "flex-1 flex flex-col gap-4" }, Ht = /* @__PURE__ */ se({
349
+ __name: "TransferItem",
350
+ props: {
351
+ cellByColId: {},
352
+ comparePriceBySku: {},
353
+ showComparePrice: { type: Boolean },
354
+ row: {}
355
+ },
356
+ setup(o) {
357
+ const { t: m } = de();
358
+ return (r, s) => {
359
+ var a, x, p, n, l, v, u, c, k, b, h, w, R, O, J, B, W, Q, N, H, G, _, g, U, oe, Y, we;
360
+ const f = I("FmLabel"), t = I("FmSpacer");
361
+ return T(), V("div", At, [
362
+ i("div", Dt, [
363
+ i("div", Rt, [
364
+ i("span", Ot, " (" + A(r.row.original.sku.code) + ") ", 1),
365
+ i("span", Bt, A(r.row.original.sku.name), 1)
366
+ ]),
367
+ i("div", null, [
368
+ C(e(ue), {
369
+ render: (p = (x = (a = r.cellByColId.Delete) == null ? void 0 : a.column) == null ? void 0 : x.columnDef) == null ? void 0 : p.cell,
370
+ props: (l = (n = r.cellByColId.Delete) == null ? void 0 : n.getContext) == null ? void 0 : l.call(n)
371
+ }, null, 8, ["render", "props"])
372
+ ])
373
+ ]),
374
+ i("div", Ut, [
375
+ i("div", Mt, [
376
+ C(f, {
377
+ label: e(m)(`inventory.transfer.form.items.table.${e(E).Code}`)
378
+ }, null, 8, ["label"]),
379
+ C(e(ue), {
380
+ render: (c = (u = (v = r.cellByColId[e(E).Code]) == null ? void 0 : v.column) == null ? void 0 : u.columnDef) == null ? void 0 : c.cell,
381
+ props: (b = (k = r.cellByColId[e(E).Code]) == null ? void 0 : k.getContext) == null ? void 0 : b.call(k)
382
+ }, null, 8, ["render", "props"]),
383
+ s[0] || (s[0] = i("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
384
+ ]),
385
+ i("div", Et, [
386
+ C(f, {
387
+ label: e(m)(`inventory.transfer.form.items.table.${e(E).Name}`)
388
+ }, null, 8, ["label"]),
389
+ C(e(ue), {
390
+ render: (R = (w = (h = r.cellByColId[e(E).Name]) == null ? void 0 : h.column) == null ? void 0 : w.columnDef) == null ? void 0 : R.cell,
391
+ props: (J = (O = r.cellByColId[e(E).Name]) == null ? void 0 : O.getContext) == null ? void 0 : J.call(O)
392
+ }, null, 8, ["render", "props"]),
393
+ s[1] || (s[1] = i("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
394
+ ])
395
+ ]),
396
+ i("div", Lt, [
397
+ i("div", qt, [
398
+ C(f, {
399
+ label: e(m)(`inventory.transfer.form.items.table.${e(E).Amount}`)
400
+ }, null, 8, ["label"]),
401
+ C(e(ue), {
402
+ render: (Q = (W = (B = r.cellByColId[e(E).Amount]) == null ? void 0 : B.column) == null ? void 0 : W.columnDef) == null ? void 0 : Q.cell,
403
+ props: (H = (N = r.cellByColId[e(E).Amount]) == null ? void 0 : N.getContext) == null ? void 0 : H.call(N)
404
+ }, null, 8, ["render", "props"]),
405
+ s[2] || (s[2] = i("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
406
+ ]),
407
+ i("div", Nt, [
408
+ C(Qe, { "z-index": 50 }, {
409
+ default: D(() => [
410
+ C(f, {
411
+ label: e(m)(`inventory.transfer.form.items.table.${e(E).Cost}2`)
412
+ }, null, 8, ["label"])
413
+ ]),
414
+ _: 1
415
+ }),
416
+ C(e(ue), {
417
+ render: (g = (_ = (G = r.cellByColId[e(E).Cost]) == null ? void 0 : G.column) == null ? void 0 : _.columnDef) == null ? void 0 : g.cell,
418
+ props: (oe = (U = r.cellByColId[e(E).Cost]) == null ? void 0 : U.getContext) == null ? void 0 : oe.call(U)
419
+ }, null, 8, ["render", "props"]),
420
+ s[3] || (s[3] = i("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
421
+ ])
422
+ ]),
423
+ r.showComparePrice && Object.keys(r.comparePriceBySku[(Y = r.row.original.sku) == null ? void 0 : Y._id] ?? {}).length > 0 ? (T(), V(ve, { key: 0 }, [
424
+ C(t, { class: "h-8" }),
425
+ C(Ge, {
426
+ prices: r.comparePriceBySku[(we = r.row.original.sku) == null ? void 0 : we._id]
427
+ }, null, 8, ["prices"])
428
+ ], 64)) : K("", !0)
429
+ ]);
430
+ };
431
+ }
432
+ });
433
+ function ye(o) {
434
+ return mt.parse(o);
435
+ }
436
+ function ke(o) {
437
+ return {
438
+ _id: o.doc._id,
439
+ internal: o.type,
440
+ contactName: o.doc.profile.name,
441
+ name: o.doc.profile.name,
442
+ email: o.doc.profile.email,
443
+ phoneNumber: o.doc.profile.phoneNo,
444
+ registrationNumber: o.doc.profile.regNo,
445
+ address: o.doc.profile.address
446
+ };
447
+ }
448
+ function zt(o, m) {
449
+ const r = he(), s = De(), f = P(() => !s.businessLevel);
450
+ s.watchLocation(async () => {
451
+ await r.readSuppliers();
452
+ const u = o();
453
+ if (u.supplier._id) return;
454
+ const c = s.businessLevel ? r.businessSuppliers[0] : r.suppliers[0], b = (f.value ? s.locations.filter((h) => h.doc._id !== s.currentLocation.doc._id) : s.locations)[0];
455
+ m({
456
+ ...u,
457
+ supplier: c ? ye(c) : b ? ke(b) : u.supplier
458
+ });
459
+ });
460
+ const t = P(
461
+ () => {
462
+ var u, c;
463
+ return typeof ((c = (u = o()) == null ? void 0 : u.supplier) == null ? void 0 : c.internal) == "string" ? $.TRANSFER : $.PURCHASE;
464
+ }
465
+ ), a = P({
466
+ get() {
467
+ var u, c;
468
+ return (c = (u = o()) == null ? void 0 : u.supplier) == null ? void 0 : c._id;
469
+ },
470
+ set(u) {
471
+ const c = o() ?? {};
472
+ if (t.value === $.PURCHASE) {
473
+ const R = (s.businessLevel ? r.businessSuppliers : r.suppliers).find((O) => O._id === u);
474
+ m({
475
+ ...c,
476
+ supplier: R ? ye(R) : c.supplier
477
+ });
478
+ return;
479
+ }
480
+ const h = (f.value ? s.locations.filter((w) => w.doc._id !== s.currentLocation.doc._id) : s.locations).find((w) => w.doc._id === u);
481
+ m({
482
+ ...c,
483
+ supplier: h ? ke(h) : c.supplier
484
+ });
485
+ }
486
+ }), x = P(() => r.locationSuppliers.map(ye)), p = P(() => r.businessSuppliers.map(ye)), n = P(() => {
487
+ var k;
488
+ const u = ((k = s._currentLocation) == null ? void 0 : k.type) === Ke.warehouse;
489
+ return (f.value ? s.locations.filter((b) => b.doc._id !== s.currentLocation.doc._id) : s.locations).filter((b) => u || b.acceptRequest).map(ke);
490
+ }), l = P(() => {
491
+ if (t.value === $.PURCHASE) {
492
+ const c = x.value.map((b) => ({
493
+ label: b.name,
494
+ value: b._id
495
+ })), k = p.value.map((b) => ({
496
+ label: b.name,
497
+ sublabel: "Business supplier",
498
+ value: b._id
499
+ }));
500
+ return s.businessLevel ? k : [...c, ...k];
501
+ }
502
+ return n.value.map((c) => ({
503
+ label: c.name,
504
+ sublabel: c.internal ? `${c.internal}` : void 0,
505
+ value: c._id
506
+ }));
507
+ }), v = P(() => {
508
+ var b, h;
509
+ const u = (h = (b = o()) == null ? void 0 : b.supplier) == null ? void 0 : h._id;
510
+ if (t.value === $.PURCHASE) {
511
+ const w = r.suppliers.find((R) => R._id === u);
512
+ return w ? ye(w) : null;
513
+ }
514
+ const k = s.locations.find((w) => w.doc._id);
515
+ return k ? ke(k) : null;
516
+ });
517
+ return {
518
+ transferLocationModel: a,
519
+ transferLocationOptions: l,
520
+ locationOptionsTypePurchase: x,
521
+ locationOptionsTypeTransfer: n,
522
+ selectedLocation: v
523
+ };
524
+ }
525
+ function jt(o) {
526
+ const m = P({
527
+ get() {
528
+ const t = o.getEffectiveAt();
529
+ return t ? new Date(t) : null;
530
+ },
531
+ set(t) {
532
+ o.setEffectiveAt((t == null ? void 0 : t.toISOString()) ?? null);
533
+ }
534
+ }), r = P({
535
+ get() {
536
+ return !!m.value;
537
+ },
538
+ set(t) {
539
+ t ? m.value = /* @__PURE__ */ new Date() : m.value = null;
540
+ }
541
+ }), s = P({
542
+ get() {
543
+ return m.value === null ? "" : Ae(m.value);
544
+ },
545
+ set(t) {
546
+ t ? m.value = /* @__PURE__ */ new Date(`${t} ${f.value}`) : m.value = null;
547
+ }
548
+ }), f = P({
549
+ get() {
550
+ return m.value === null ? "" : ft(m.value);
551
+ },
552
+ set(t) {
553
+ t ? m.value = /* @__PURE__ */ new Date(`${s.value} ${t}`) : m.value = null;
554
+ }
555
+ });
556
+ return {
557
+ backdatePo: m,
558
+ backdateSwitch: r,
559
+ backdateModel: s,
560
+ backdateTimeModel: f
561
+ };
562
+ }
563
+ const Wt = {
564
+ width: "24",
565
+ height: "24",
566
+ viewBox: "0 0 24 24",
567
+ fill: "none",
568
+ xmlns: "http://www.w3.org/2000/svg"
569
+ }, Yt = ["fill"], Zt = ["fill"], Kt = ["stroke"], Qt = ["stroke"], Gt = /* @__PURE__ */ se({
570
+ __name: "SparkIcon",
571
+ props: {
572
+ size: {
573
+ type: Number,
574
+ default: 24
575
+ },
576
+ color: {
577
+ type: String,
578
+ default: "#c7c7cc"
579
+ }
580
+ },
581
+ setup(o) {
582
+ return (m, r) => (T(), V("svg", Wt, [
583
+ i("path", {
584
+ 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",
585
+ fill: o.color
586
+ }, null, 8, Yt),
587
+ i("path", {
588
+ 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",
589
+ fill: o.color
590
+ }, null, 8, Zt),
591
+ i("path", {
592
+ 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",
593
+ stroke: o.color,
594
+ "stroke-width": "1.5",
595
+ "stroke-linecap": "round",
596
+ "stroke-linejoin": "round"
597
+ }, null, 8, Kt),
598
+ i("path", {
599
+ 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",
600
+ stroke: o.color,
601
+ "stroke-width": "1.5",
602
+ "stroke-linecap": "round",
603
+ "stroke-linejoin": "round"
604
+ }, null, 8, Qt)
605
+ ]));
606
+ }
607
+ }), Jt = { class: "flex gap-8 items-center" }, Xt = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, es = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, ts = { class: "flex items-center w-full" }, ss = { class: "flex-1" }, os = { class: "fm-typo-en-title-sm-800" }, ns = { class: "flex items-start gap-8" }, as = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ls = { class: "flex gap-1" }, Ne = /* @__PURE__ */ se({
608
+ __name: "ForecastStock",
609
+ props: {
610
+ disabled: { type: Boolean }
611
+ },
612
+ emits: ["update:poItems"],
613
+ setup(o, { emit: m }) {
614
+ const r = m, s = L(!1), f = L(7), t = Ct(), a = Ve(), x = Re(), { t: p } = de();
615
+ async function n() {
616
+ if (f.value < 1)
617
+ return;
618
+ s.value = !1, await t.readPurchaseOrder(f.value);
619
+ const l = [];
620
+ if (t.purchaseOrderForecast.skus.length <= 0) {
621
+ a.open({
622
+ message: p("inventory.transfer.form.items.forecastStock.notAvailable"),
623
+ type: "info"
624
+ });
625
+ return;
626
+ }
627
+ const v = t.purchaseOrderForecast.skus.reduce((u, c) => {
628
+ const k = x.skus.find((w) => w._id === c.id);
629
+ if (u.find((w) => w.sku._id === c.id) || !k)
630
+ return u;
631
+ const h = {
632
+ sku: k,
633
+ code: k.code,
634
+ name: k.name,
635
+ quantity: {
636
+ amount: c.amount,
637
+ precision: 0
638
+ }
639
+ };
640
+ return u.push(h), u;
641
+ }, l);
642
+ r("update:poItems", v);
643
+ }
644
+ return (l, v) => {
645
+ const u = I("FmButton"), c = I("FmIcon"), k = I("FmStepperField"), b = I("FmPopover");
646
+ return T(), z(b, {
647
+ disabled: l.disabled,
648
+ class: "flex",
649
+ "show-popover": s.value,
650
+ onPopoverChanged: v[3] || (v[3] = (h) => s.value = h)
651
+ }, {
652
+ "popover-button": D(() => [
653
+ C(u, {
654
+ label: "unused",
655
+ variant: "secondary",
656
+ "text-color": l.disabled ? "disabled" : "primary",
657
+ "bg-color": "transparent",
658
+ "border-color": l.disabled ? "disabled" : "primary",
659
+ disabled: l.disabled
660
+ }, {
661
+ default: D(() => [
662
+ i("div", Jt, [
663
+ C(Gt, {
664
+ size: 24,
665
+ color: l.disabled ? "#c7c7cc" : "#ff7823"
666
+ }, null, 8, ["color"]),
667
+ i("div", Xt, A(e(p)("inventory.transfer.form.items.forecastStock.title")), 1)
668
+ ])
669
+ ]),
670
+ _: 1
671
+ }, 8, ["text-color", "border-color", "disabled"])
672
+ ]),
673
+ default: D(() => [
674
+ i("div", es, [
675
+ i("div", ts, [
676
+ i("div", ss, [
677
+ C(wt, { "z-index": 99 }, {
678
+ default: D(() => [
679
+ i("p", os, A(e(p)("inventory.transfer.form.items.forecastStock.title")), 1)
680
+ ]),
681
+ _: 1
682
+ })
683
+ ]),
684
+ C(u, {
685
+ icon: "close",
686
+ size: "md",
687
+ variant: "tertiary",
688
+ onClick: v[0] || (v[0] = (h) => s.value = !1)
689
+ })
690
+ ]),
691
+ C(k, {
692
+ modelValue: f.value,
693
+ "onUpdate:modelValue": v[1] || (v[1] = (h) => f.value = h),
694
+ label: e(p)("inventory.transfer.form.items.forecastStock.days"),
695
+ rules: [e(Ce)(1)]
696
+ }, {
697
+ "helper-text": D(() => [
698
+ i("div", ns, [
699
+ C(c, {
700
+ name: "warning",
701
+ size: "sm",
702
+ class: "text-fm-color-system-warning-300"
703
+ }),
704
+ i("div", as, A(e(p)("inventory.transfer.form.items.forecastStock.replace")), 1)
705
+ ])
706
+ ]),
707
+ _: 1
708
+ }, 8, ["modelValue", "label", "rules"]),
709
+ i("div", ls, [
710
+ v[4] || (v[4] = i("div", { class: "grow" }, null, -1)),
711
+ C(u, {
712
+ label: e(p)("common.cancel"),
713
+ variant: "tertiary",
714
+ onClick: v[2] || (v[2] = (h) => s.value = !1)
715
+ }, null, 8, ["label"]),
716
+ C(u, {
717
+ label: e(p)("inventory.transfer.form.items.forecastStock.generate"),
718
+ onClick: n
719
+ }, null, 8, ["label"])
720
+ ])
721
+ ])
722
+ ]),
723
+ _: 1
724
+ }, 8, ["disabled", "show-popover"]);
725
+ };
726
+ }
727
+ });
728
+ function rs() {
729
+ const o = Ve(), m = je(), r = L(!1);
730
+ $e(r, (a) => {
731
+ a && (f.value = !0, s().finally(() => {
732
+ f.value = !1;
733
+ }));
734
+ });
735
+ async function s() {
736
+ try {
737
+ const { startDate: a, endDate: x } = yt(6), l = (await m.getPurchaseOrders({ start: a, end: x })).filter(
738
+ (v) => {
739
+ var u, c;
740
+ return v.status === vt.enum.COMPLETE && ((u = v.supplier) == null ? void 0 : u.internal) !== "warehouse" && ((c = v.supplier) == null ? void 0 : c.internal) !== "restaurant";
741
+ }
742
+ ).reduce((v, u) => {
743
+ const c = new Date(bt(u._id)), k = u.supplier._id;
744
+ for (const b of u.items) {
745
+ if (!b.totalCost) continue;
746
+ const h = v[b.sku._id] ?? {}, w = h[k] ?? [];
747
+ w.push({
748
+ date: c.toISOString(),
749
+ totalUnit: b.quantity,
750
+ totalCost: b.totalCost,
751
+ unit: b.sku.unit,
752
+ measurement: b.measurement,
753
+ seqNumber: u.seqNumber
754
+ }), h[k] = w, v[b.sku._id] = h;
755
+ }
756
+ return v;
757
+ }, {});
758
+ t.value = l;
759
+ } catch {
760
+ o.open({
761
+ title: "Something went wrong",
762
+ message: "Cannot retrieve supplier purchase history. Please try again."
763
+ }), r.value = !1;
764
+ }
765
+ }
766
+ const f = L(!1), t = L({});
767
+ return {
768
+ comparePricesToggle: r,
769
+ comparePriceFetching: f,
770
+ comparePriceBySku: t
771
+ };
772
+ }
773
+ const is = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, us = { key: 0 }, ds = ["colspan"], cs = /* @__PURE__ */ se({
774
+ __name: "TransferItemTable",
775
+ props: {
776
+ row: {},
777
+ comparePriceBySku: {},
778
+ showComparePrice: { type: Boolean }
779
+ },
780
+ setup(o) {
781
+ function m(r) {
782
+ return r.column.columnDef.meta;
783
+ }
784
+ return (r, s) => {
785
+ var f, t;
786
+ return T(), V(ve, null, [
787
+ i("tr", {
788
+ class: Ie(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
789
+ "bg-fm-color-neutral-gray-100": r.row.getIsSelected()
790
+ }])
791
+ }, [
792
+ (T(!0), V(ve, null, Pe(r.row.getVisibleCells(), (a) => {
793
+ var x, p, n, l;
794
+ return T(), V("td", {
795
+ key: a.id,
796
+ class: Ie([
797
+ "h-[52px] px-16 text-fm-color-typo-primary",
798
+ ((x = m(a)) == null ? void 0 : x.cellClass) ?? "px-16"
799
+ ]),
800
+ style: Je({
801
+ width: (p = m(a)) == null ? void 0 : p.width,
802
+ maxWidth: (n = m(a)) == null ? void 0 : n.maxWidth,
803
+ textAlign: ((l = m(a)) == null ? void 0 : l.textAlign) ?? "left"
804
+ })
805
+ }, [
806
+ i("span", is, [
807
+ C(e(ue), {
808
+ render: a.column.columnDef.cell,
809
+ props: a.getContext()
810
+ }, null, 8, ["render", "props"])
811
+ ])
812
+ ], 6);
813
+ }), 128))
814
+ ], 2),
815
+ r.showComparePrice && Object.keys(r.comparePriceBySku[(f = r.row.original.sku) == null ? void 0 : f._id] ?? {}).length > 0 ? (T(), V("tr", us, [
816
+ i("td", {
817
+ colspan: r.row.getVisibleCells().length
818
+ }, [
819
+ C(Ge, {
820
+ prices: r.comparePriceBySku[(t = r.row.original.sku) == null ? void 0 : t._id]
821
+ }, null, 8, ["prices"])
822
+ ], 8, ds)
823
+ ])) : K("", !0)
824
+ ], 64);
825
+ };
826
+ }
827
+ }), ps = { class: "flex flex-col gap-4" }, ms = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, fs = { class: "flex flex-col gap-16" }, ys = { class: "flex flex-col gap-24" }, vs = {
828
+ key: 0,
829
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
830
+ }, bs = { class: "flex xs:flex-col sm:flex-col" }, _s = {
831
+ key: 0,
832
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
833
+ }, gs = { class: "flex-1" }, ks = { class: "flex-1" }, Cs = {
834
+ key: 1,
835
+ class: "flex items-center gap-4"
836
+ }, hs = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, ws = { class: "flex flex-col gap-16" }, xs = { class: "flex sm:flex-col xs:flex-col gap-16 items-center xs:items-start sm:items-start" }, Ss = { class: "flex-1 gap-8 fm-typo-en-title-sm-800" }, Ts = { class: "flex gap-8" }, Ps = {
837
+ key: 0,
838
+ class: "xs:w-full"
839
+ }, Is = /* @__PURE__ */ se({
840
+ __name: "TransferForm2",
841
+ props: {
842
+ modelValue: {},
843
+ disabled: { type: Boolean },
844
+ suppliers: {},
845
+ skus: {},
846
+ lastClosingDate: {}
847
+ },
848
+ emits: ["validation-success", "form:ready"],
849
+ setup(o, { expose: m, emit: r }) {
850
+ const s = o, f = r, t = Tt(), { t: a } = de(), x = De(), p = Re(), n = he(), l = We(), v = ot(), u = P(
851
+ () => v.templates.value.find((d) => d._id === t.template)
852
+ ), c = P(() => t.status === "DRAFT" || !t._rev);
853
+ ze(async () => {
854
+ try {
855
+ if (!t.template) return;
856
+ await v.loadTemplate(t.template);
857
+ } finally {
858
+ f("form:ready");
859
+ }
860
+ });
861
+ const k = P(
862
+ () => x.currentLocation.type === Ke.restaurant
863
+ );
864
+ x.watchLocation(async () => {
865
+ location && (t.supplier || (t.supplier = n.suppliers.find((d) => d) ?? t.supplier));
866
+ });
867
+ const b = tt(), h = zt(
868
+ () => t,
869
+ (d) => {
870
+ Object.assign(t, d);
871
+ }
872
+ ), w = P({
873
+ get() {
874
+ var d;
875
+ return typeof ((d = t == null ? void 0 : t.supplier) == null ? void 0 : d.internal) == "string" ? $.TRANSFER : $.PURCHASE;
876
+ },
877
+ set(d) {
878
+ var q;
879
+ const y = typeof ((q = t == null ? void 0 : t.supplier) == null ? void 0 : q.internal) == "string" ? $.TRANSFER : $.PURCHASE;
880
+ d !== y && (t.supplier = d === $.PURCHASE ? h.locationOptionsTypePurchase.value[0] : h.locationOptionsTypeTransfer.value[0]);
881
+ }
882
+ }), R = P(() => h.transferLocationOptions.value), O = P({
883
+ get() {
884
+ return t.supplier._id;
885
+ },
886
+ set(d) {
887
+ h.transferLocationModel.value = d;
888
+ }
889
+ }), J = P({
890
+ get() {
891
+ return t.remark ?? void 0;
892
+ },
893
+ set(d) {
894
+ t.remark = d;
895
+ }
896
+ }), { backdatePo: B, backdateSwitch: W, backdateModel: Q, backdateTimeModel: N } = jt({
897
+ getEffectiveAt() {
898
+ return t.effectiveAt;
899
+ },
900
+ setEffectiveAt(d) {
901
+ t.effectiveAt = d;
902
+ }
903
+ }), { comparePricesToggle: H, comparePriceFetching: G, comparePriceBySku: _ } = rs(), g = L();
904
+ m({
905
+ validateInputs: () => {
906
+ var d, y;
907
+ (y = (d = g.value) == null ? void 0 : d.validateInputs) == null || y.call(d);
908
+ },
909
+ resetInputsValidation: () => {
910
+ var d, y;
911
+ (y = (d = g.value) == null ? void 0 : d.resetInputsValidation) == null || y.call(d);
912
+ },
913
+ resetInputs: () => {
914
+ var d, y;
915
+ (y = (d = g.value) == null ? void 0 : d.resetInputs) == null || y.call(d);
916
+ }
917
+ });
918
+ const U = St({
919
+ updateItem: (d) => {
920
+ t.items = t.items.map((y) => y.sku._id !== d.sku._id ? y : d);
921
+ },
922
+ deleteItem: (d) => {
923
+ t.items = t.items.filter((y) => y.sku._id !== d.sku._id);
924
+ },
925
+ get supplier() {
926
+ return t.supplier;
927
+ },
928
+ get items() {
929
+ return t.items;
930
+ },
931
+ get transferType() {
932
+ return w.value;
933
+ },
934
+ get template() {
935
+ return u.value;
936
+ },
937
+ get disabled() {
938
+ return s.disabled;
939
+ }
940
+ }), oe = P(() => U.columnDefs.value);
941
+ function Y() {
942
+ var be, pe, _e;
943
+ let d;
944
+ ((F) => {
945
+ F.IsInTemplate = "IsInTemplate", F.IsOutsideTemplate = "IsOutsideTemplate";
946
+ })(d || (d = {}));
947
+ const y = [
948
+ {
949
+ id: "IsInTemplate",
950
+ label: a("inventory.transfer.form.items.fromTemplate.title")
951
+ },
952
+ {
953
+ id: "IsOutsideTemplate",
954
+ label: a("inventory.transfer.form.items.other.title"),
955
+ sublabel: "These options are not selectable, and the items are managed in template.",
956
+ collapse: !0,
957
+ disabled: !0
958
+ }
959
+ ], q = new Set((_e = (pe = (be = u.value) == null ? void 0 : be.purchaseOrder) == null ? void 0 : pe.items) == null ? void 0 : _e.map((F) => F.sku._id)), ce = p.skus.map(
960
+ (F) => ({
961
+ label: F.name,
962
+ sublabel: F.code,
963
+ value: F,
964
+ disabled: !!(q.size && !q.has(F._id)),
965
+ groupId: q.has(F._id) ? "IsInTemplate" : "IsOutsideTemplate"
966
+ /* IsOutsideTemplate */
967
+ })
968
+ ), xe = ce.filter((F) => {
969
+ var X;
970
+ return (X = t.items) == null ? void 0 : X.find((ne) => ne.sku._id === F.value._id);
971
+ }).map((F) => F.value);
972
+ b.open({
973
+ title: a("inventory.transfer.form.items.selectItem"),
974
+ closeButton: !0,
975
+ contentComponent: kt,
976
+ contentComponentProps: {
977
+ modelValue: xe,
978
+ items: ce,
979
+ groups: q.size ? y : void 0
980
+ },
981
+ primaryActions: {
982
+ text: a("common.confirm"),
983
+ close: !0
984
+ },
985
+ secondaryActions: {
986
+ text: a("common.close"),
987
+ close: !0,
988
+ variant: "tertiary"
989
+ }
990
+ }).onPrimary((F) => {
991
+ const X = t.items ?? [], ne = F.map((Z) => {
992
+ var ge, me;
993
+ const ae = X.find((le) => le.sku._id === Z._id);
994
+ if (ae)
995
+ return ae;
996
+ const ee = ((me = (ge = u.value) == null ? void 0 : ge.purchaseOrder.items) == null ? void 0 : me.find(
997
+ (le) => le.sku._id === Z._id
998
+ )) ?? {
999
+ sku: Z,
1000
+ code: Z.code,
1001
+ name: Z.name,
1002
+ quantity: {
1003
+ amount: 1,
1004
+ precision: 0
1005
+ }
1006
+ };
1007
+ return w.value == $.PURCHASE && (ee.totalCost = te(
1008
+ ee.sku,
1009
+ ee.quantity,
1010
+ ee.measurement,
1011
+ {
1012
+ supplier: t.supplier
1013
+ }
1014
+ )), ee;
1015
+ });
1016
+ ne.sort((Z, ae) => Z.sku.code.localeCompare(ae.sku.code)), t.items = ne;
1017
+ });
1018
+ }
1019
+ function we(d) {
1020
+ return d;
1021
+ }
1022
+ return (d, y) => {
1023
+ var me, le;
1024
+ const q = I("FmChip"), ce = I("FmSelect"), xe = I("FmTextField"), be = I("FmTextarea"), pe = I("FmSwitch"), _e = I("FmDatePicker"), F = I("FmTimePicker"), X = I("FmFormGroup"), ne = I("FmIcon"), Z = I("FmButton"), ae = I("FmTooltip"), ee = I("FmTable"), ge = I("FmForm");
1025
+ return T(), V("div", ps, [
1026
+ i("div", ms, [
1027
+ (me = s.modelValue) != null && me.template ? (T(), z(q, {
1028
+ key: 0,
1029
+ variant: d.disabled ? "warning" : void 0,
1030
+ label: `${e(a)("inventory.transfer.template.title")}: ${((le = u.value) == null ? void 0 : le.name) ?? e(a)("inventory.transfer.form.loading")}`,
1031
+ icon: "summarize",
1032
+ compact: ""
1033
+ }, null, 8, ["variant", "label"])) : K("", !0),
1034
+ C(q, {
1035
+ label: e(x).currentLocation.name,
1036
+ icon: "storefront",
1037
+ compact: ""
1038
+ }, null, 8, ["label"]),
1039
+ d.lastClosingDate ? (T(), z(q, {
1040
+ key: 1,
1041
+ label: `${e(a)("inventory.transfer.form.lastClosing")}: ${e(Ae)(d.lastClosingDate)} ${e(_t)(d.lastClosingDate)}`,
1042
+ icon: "calendar_month",
1043
+ compact: ""
1044
+ }, null, 8, ["label"])) : K("", !0)
1045
+ ]),
1046
+ C(ge, {
1047
+ ref_key: "formRef",
1048
+ ref: g,
1049
+ class: "flex flex-col gap-32",
1050
+ disabled: d.disabled,
1051
+ onValidationFailed: console.log,
1052
+ onValidationSuccess: y[12] || (y[12] = (Se) => f("validation-success"))
1053
+ }, {
1054
+ default: D(() => {
1055
+ var Se, Oe, Be, Ue, Me;
1056
+ return [
1057
+ i("div", fs, [
1058
+ i("div", ys, [
1059
+ C(ce, {
1060
+ disabled: !!((Se = s.modelValue) != null && Se.template),
1061
+ label: e(a)("inventory.transfer.form.type.title"),
1062
+ "model-value": w.value,
1063
+ "onUpdate:modelValue": y[0] || (y[0] = (S) => w.value = S),
1064
+ items: [
1065
+ {
1066
+ label: e(a)("inventory.transfer.form.type.purchase"),
1067
+ value: e($).PURCHASE,
1068
+ disabled: !e(h).locationOptionsTypePurchase.value.length,
1069
+ sublabel: e(h).locationOptionsTypePurchase.value.length ? void 0 : e(a)("inventory.transfer.form.noSupplierAvailable")
1070
+ },
1071
+ {
1072
+ label: e(a)("inventory.transfer.form.type.transfer"),
1073
+ value: e($).TRANSFER,
1074
+ disabled: !e(h).locationOptionsTypeTransfer.value.length,
1075
+ sublabel: e(h).locationOptionsTypeTransfer.value.length ? void 0 : e(a)("inventory.transfer.form.noLocationAvailable")
1076
+ }
1077
+ ],
1078
+ rules: [e(Ce)(1)(R.value)],
1079
+ "helper-text": (Oe = s.modelValue) != null && Oe.template ? "This field is locked and managed in template." : void 0
1080
+ }, null, 8, ["disabled", "label", "model-value", "items", "rules", "helper-text"]),
1081
+ C(ce, {
1082
+ disabled: !!((Be = s.modelValue) != null && Be.template),
1083
+ label: w.value === e($).PURCHASE ? e(a)("inventory.transfer.form.purchaseFrom") : e(a)("inventory.transfer.form.transferFrom"),
1084
+ modelValue: O.value,
1085
+ "onUpdate:modelValue": y[1] || (y[1] = (S) => O.value = S),
1086
+ items: R.value,
1087
+ "helper-text": (Ue = s.modelValue) != null && Ue.template ? "This field is locked and managed in template." : void 0
1088
+ }, null, 8, ["disabled", "label", "modelValue", "items", "helper-text"]),
1089
+ C(xe, {
1090
+ label: e(a)("inventory.transfer.form.reference"),
1091
+ "label-mark": "optional",
1092
+ modelValue: e(t).ref,
1093
+ "onUpdate:modelValue": y[2] || (y[2] = (S) => e(t).ref = S)
1094
+ }, null, 8, ["label", "modelValue"]),
1095
+ C(be, {
1096
+ label: e(a)("inventory.transfer.form.remark"),
1097
+ "label-mark": "optional",
1098
+ "max-length": 240,
1099
+ modelValue: J.value,
1100
+ "onUpdate:modelValue": y[3] || (y[3] = (S) => J.value = S),
1101
+ class: Ie([d.disabled ? "text-fm-color-typo-disabled " : ""])
1102
+ }, null, 8, ["label", "modelValue", "class"]),
1103
+ e(l).enableBackdatePo ? (T(), V("div", vs, [
1104
+ i("div", bs, [
1105
+ C(pe, {
1106
+ modelValue: e(W),
1107
+ "onUpdate:modelValue": y[4] || (y[4] = (S) => ie(W) ? W.value = S : null),
1108
+ label: e(a)("inventory.transfer.form.backdate.title"),
1109
+ sublabel: e(a)("inventory.transfer.form.backdate.subtitle"),
1110
+ "label-placement": "right",
1111
+ disabled: k.value && !d.lastClosingDate || d.disabled
1112
+ }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1113
+ y[13] || (y[13] = i("div", { class: "xs:hidden sm:hidden h-48 lg:w-16 md:w-16" }, null, -1)),
1114
+ e(W) ? (T(), V("div", _s, [
1115
+ i("div", gs, [
1116
+ C(_e, {
1117
+ modelValue: e(Q),
1118
+ "onUpdate:modelValue": y[5] || (y[5] = (S) => ie(Q) ? Q.value = S : null)
1119
+ }, null, 8, ["modelValue"])
1120
+ ]),
1121
+ i("div", ks, [
1122
+ C(F, {
1123
+ modelValue: e(N),
1124
+ "onUpdate:modelValue": y[6] || (y[6] = (S) => ie(N) ? N.value = S : null)
1125
+ }, null, 8, ["modelValue"])
1126
+ ])
1127
+ ])) : K("", !0)
1128
+ ]),
1129
+ e(B) ? (T(), z(X, {
1130
+ key: 0,
1131
+ modelValue: e(B),
1132
+ "onUpdate:modelValue": y[7] || (y[7] = (S) => ie(B) ? B.value = S : null),
1133
+ rules: [e(gt)(new Date(d.lastClosingDate), /* @__PURE__ */ new Date())]
1134
+ }, null, 8, ["modelValue", "rules"])) : K("", !0),
1135
+ k.value && !d.lastClosingDate ? (T(), V("div", Cs, [
1136
+ C(ne, {
1137
+ name: "error",
1138
+ size: "sm",
1139
+ class: "text-fm-color-typo-warning"
1140
+ }),
1141
+ i("span", hs, A(e(a)("inventory.transfer.form.backdate.error")), 1)
1142
+ ])) : K("", !0)
1143
+ ])) : K("", !0)
1144
+ ])
1145
+ ]),
1146
+ i("div", ws, [
1147
+ C(X, {
1148
+ "model-value": e(t).items,
1149
+ rules: [e(Ce)(1)]
1150
+ }, null, 8, ["model-value", "rules"]),
1151
+ i("div", xs, [
1152
+ i("div", Ss, A(e(a)("inventory.transfer.form.items.title")), 1),
1153
+ i("div", Ts, [
1154
+ C(Z, {
1155
+ disabled: d.disabled,
1156
+ label: e(a)("inventory.transfer.form.items.addItem"),
1157
+ "prepend-icon": "add",
1158
+ variant: "secondary",
1159
+ "text-color": "primary",
1160
+ "bg-color": "transparent",
1161
+ "border-color": "primary",
1162
+ onClick: y[8] || (y[8] = (S) => Y()),
1163
+ size: "md"
1164
+ }, null, 8, ["disabled", "label"]),
1165
+ e(t).template ? (T(), z(ae, {
1166
+ key: 0,
1167
+ "z-index": 50
1168
+ }, {
1169
+ content: D(() => [
1170
+ i("div", null, A(e(a)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1171
+ ]),
1172
+ default: D(() => [
1173
+ C(Ne, {
1174
+ "onUpdate:poItems": y[9] || (y[9] = (S) => e(t).items = S),
1175
+ disabled: ""
1176
+ })
1177
+ ]),
1178
+ _: 1
1179
+ })) : (T(), z(Ne, {
1180
+ key: 1,
1181
+ "onUpdate:poItems": y[10] || (y[10] = (S) => e(t).items = S),
1182
+ disabled: d.disabled || !!e(t).template
1183
+ }, null, 8, ["disabled"]))
1184
+ ])
1185
+ ]),
1186
+ w.value === e($).PURCHASE && c.value && e(l).enableTotalCost && ((Me = d.modelValue) != null && Me.items.length) ? (T(), V("div", Ps, [
1187
+ C(pe, {
1188
+ label: e(G) ? e(a)("inventory.transfer.form.items.fetchingData") : e(a)("inventory.transfer.form.items.comparePriceHistory"),
1189
+ "prepend-icon": "compare_arrows",
1190
+ "label-placement": "right",
1191
+ "model-value": e(H),
1192
+ "onUpdate:modelValue": y[11] || (y[11] = (S) => ie(H) ? H.value = S : null),
1193
+ disabled: e(G) || d.disabled
1194
+ }, null, 8, ["label", "model-value", "disabled"])
1195
+ ])) : K("", !0),
1196
+ (T(), z(ee, {
1197
+ "column-defs": oe.value,
1198
+ "row-data": e(t).items,
1199
+ key: e(t).items.map((S) => S.sku._id).join("."),
1200
+ "hide-footer": ""
1201
+ }, {
1202
+ "table-row": D((S) => [
1203
+ C(cs, {
1204
+ "compare-price-by-sku": e(_),
1205
+ "show-compare-price": w.value === e($).PURCHASE && e(H),
1206
+ row: S
1207
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row"])
1208
+ ]),
1209
+ "list-row": D((S) => [
1210
+ (T(), z(ht, {
1211
+ row: S,
1212
+ key: e(t).items.map((Te) => Te.sku._id).join(".")
1213
+ }, {
1214
+ default: D((Te) => [
1215
+ C(Ht, {
1216
+ "compare-price-by-sku": e(_),
1217
+ "show-compare-price": w.value === e($).PURCHASE && e(H),
1218
+ row: S,
1219
+ "cell-by-col-id": Te
1220
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1221
+ ]),
1222
+ _: 2
1223
+ }, 1032, ["row"]))
1224
+ ]),
1225
+ _: 1
1226
+ }, 8, ["column-defs", "row-data"]))
1227
+ ])
1228
+ ];
1229
+ }),
1230
+ _: 1
1231
+ }, 8, ["disabled", "onValidationFailed"])
1232
+ ]);
1233
+ };
1234
+ }
1235
+ }), Fs = { class: "flex items-center" }, $s = { class: "fm-typo-en-title-md-800" }, Vs = { class: "flex gap-4" }, Hs = /* @__PURE__ */ se({
1236
+ __name: "TransferDialog",
1237
+ props: {
1238
+ mode: {},
1239
+ modelValue: {},
1240
+ templateId: {},
1241
+ show: { type: Boolean },
1242
+ lastClosingDate: {}
1243
+ },
1244
+ emits: ["update:show", "submitted"],
1245
+ setup(o, { expose: m, emit: r }) {
1246
+ var G;
1247
+ const s = o, f = r, t = je(), a = Ve(), x = he(), p = Re(), n = De(), { t: l } = de(), v = L(!1), u = L(!1), c = L(!1);
1248
+ async function k(_) {
1249
+ if (_) {
1250
+ u.value = !1;
1251
+ try {
1252
+ await x.readSuppliers(), u.value = !0;
1253
+ } catch {
1254
+ a.open({
1255
+ title: l("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1256
+ message: l("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1257
+ type: "error"
1258
+ });
1259
+ }
1260
+ }
1261
+ }
1262
+ n.watchLocation(k);
1263
+ function b() {
1264
+ return {
1265
+ remark: void 0,
1266
+ ref: void 0,
1267
+ stockSnapshotId: void 0,
1268
+ effectiveAt: void 0,
1269
+ items: [],
1270
+ supplier: {
1271
+ _rev: void 0,
1272
+ email: void 0,
1273
+ internal: void 0,
1274
+ contactName: void 0,
1275
+ phoneNumber: void 0,
1276
+ registrationNumber: void 0,
1277
+ supplyItems: void 0,
1278
+ _id: "",
1279
+ name: "",
1280
+ address: {
1281
+ line2: void 0,
1282
+ line1: "",
1283
+ state: "",
1284
+ city: "",
1285
+ postcode: "",
1286
+ country: ""
1287
+ }
1288
+ },
1289
+ status: "DRAFT",
1290
+ _id: "",
1291
+ seqNumber: 0,
1292
+ deliveryOrder: [],
1293
+ template: s.templateId
1294
+ };
1295
+ }
1296
+ const h = st(s, "show"), w = L(s.modelValue ?? b()), R = L(((G = s.modelValue) == null ? void 0 : G._id) ?? `${Math.random()}`);
1297
+ $e(
1298
+ () => s.show,
1299
+ (_) => {
1300
+ var g;
1301
+ _ && (c.value = !1, w.value = s.modelValue ?? b(), R.value = ((g = s.modelValue) == null ? void 0 : g._id) ?? `${Math.random()}`);
1302
+ }
1303
+ );
1304
+ const O = P(() => !u.value || !c.value), J = P(() => {
1305
+ switch (s.mode) {
1306
+ case fe.READ:
1307
+ return "View transfer";
1308
+ case fe.CREATE:
1309
+ return l("inventory.transfer.receiveRequest.create.title");
1310
+ case fe.UPDATE:
1311
+ return l("inventory.transfer.receiveRequest.update.title");
1312
+ }
1313
+ return "";
1314
+ }), B = L();
1315
+ m({
1316
+ validateInputs: () => {
1317
+ var _, g;
1318
+ (g = (_ = B.value) == null ? void 0 : _.validateInputs) == null || g.call(_);
1319
+ },
1320
+ resetInputsValidation: () => {
1321
+ var _, g;
1322
+ (g = (_ = B.value) == null ? void 0 : _.resetInputsValidation) == null || g.call(_);
1323
+ },
1324
+ resetInputs: () => {
1325
+ var _, g;
1326
+ (g = (_ = B.value) == null ? void 0 : _.resetInputs) == null || g.call(_);
1327
+ }
1328
+ });
1329
+ async function W() {
1330
+ const _ = w.value;
1331
+ v.value = !0, (_.supplier.internal === "warehouse" || _.supplier.internal === "restaurant") && (_.items = _.items.map(({ totalCost: g, ...U }) => U));
1332
+ try {
1333
+ await t.createPurchaseOrder(_), await new Promise((g) => setTimeout(g, 1e3)), a.open({
1334
+ title: l("inventory.transfer.receiveRequest.create.success"),
1335
+ message: l("inventory.transfer.receiveRequest.create.successMessage"),
1336
+ type: "success"
1337
+ }), f("update:show", !1), f("submitted");
1338
+ } catch (g) {
1339
+ a.open({
1340
+ title: l("inventory.transfer.receiveRequest.create.error.title"),
1341
+ message: l("inventory.transfer.receiveRequest.create.error.message"),
1342
+ type: "error"
1343
+ }), console.error("Error in creating purchase order", g);
1344
+ } finally {
1345
+ v.value = !1;
1346
+ }
1347
+ }
1348
+ async function Q() {
1349
+ const _ = w.value;
1350
+ v.value = !0, (_.supplier.internal === "warehouse" || _.supplier.internal === "restaurant") && (_.items = _.items.map(({ totalCost: g, ...U }) => U));
1351
+ try {
1352
+ await t.updatePurchaseOrder(_), await new Promise((g) => setTimeout(g, 1e3)), a.open({
1353
+ title: l("inventory.transfer.receiveRequest.update.success"),
1354
+ message: l("inventory.transfer.receiveRequest.update.successMessage"),
1355
+ type: "success"
1356
+ }), f("update:show", !1), f("submitted");
1357
+ } catch (g) {
1358
+ a.open({
1359
+ title: l("inventory.transfer.receiveRequest.update.error.title"),
1360
+ message: l("inventory.transfer.receiveRequest.update.error.message"),
1361
+ type: "error"
1362
+ }), console.error("Error in updating purchase order", g);
1363
+ } finally {
1364
+ v.value = !1;
1365
+ }
1366
+ }
1367
+ function N() {
1368
+ switch (s.mode) {
1369
+ case fe.CREATE:
1370
+ return W();
1371
+ case fe.UPDATE:
1372
+ return Q();
1373
+ }
1374
+ }
1375
+ function H() {
1376
+ var _, g;
1377
+ (g = (_ = B.value) == null ? void 0 : _.validateInputs) == null || g.call(_);
1378
+ }
1379
+ return (_, g) => {
1380
+ const U = I("FmButton"), oe = I("FmSideSheet");
1381
+ return T(), z(oe, {
1382
+ modelValue: e(h),
1383
+ "onUpdate:modelValue": g[3] || (g[3] = (Y) => ie(h) ? h.value = Y : null),
1384
+ "dismiss-away": "",
1385
+ "close-button": "",
1386
+ "max-width": 900
1387
+ }, {
1388
+ "side-sheet-header": D(() => [
1389
+ i("div", Fs, [
1390
+ i("div", $s, A(J.value), 1)
1391
+ ])
1392
+ ]),
1393
+ default: D(() => [
1394
+ (T(), z(Is, {
1395
+ class: "w-full",
1396
+ ref_key: "formRef",
1397
+ ref: B,
1398
+ "onForm:ready": g[0] || (g[0] = () => c.value = !0),
1399
+ onValidationSuccess: N,
1400
+ modelValue: w.value,
1401
+ "onUpdate:modelValue": g[1] || (g[1] = (Y) => w.value = Y),
1402
+ disabled: v.value || O.value,
1403
+ suppliers: e(x).suppliers,
1404
+ skus: e(p).skus,
1405
+ key: R.value,
1406
+ "last-closing-date": _.lastClosingDate
1407
+ }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1408
+ ]),
1409
+ "side-sheet-footer": D(() => [
1410
+ i("div", Vs, [
1411
+ C(U, {
1412
+ loading: v.value,
1413
+ disabled: O.value,
1414
+ label: e(l)("common.save"),
1415
+ onClick: H
1416
+ }, null, 8, ["loading", "disabled", "label"]),
1417
+ C(U, {
1418
+ disabled: O.value,
1419
+ variant: "tertiary",
1420
+ label: e(l)("common.close"),
1421
+ onClick: g[2] || (g[2] = (Y) => f("update:show", !1))
1422
+ }, null, 8, ["disabled", "label"])
1423
+ ])
1424
+ ]),
1425
+ _: 1
1426
+ }, 8, ["modelValue"]);
1427
+ };
1428
+ }
1429
+ });
1430
+ export {
1431
+ Hs as _,
1432
+ te as c,
1433
+ Tt as d,
1434
+ zt as u
1435
+ };