@feedmepos/mf-inventory-portal 0.0.14-dev.4 → 0.0.15-dev.1

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 (52) hide show
  1. package/dist/{ApprovalView-RDKSFUZo.js → ApprovalView-BY-O670N.js} +6 -6
  2. package/dist/{BindingsDialog-B4ewRMkz.js → BindingsDialog-XmH2SMob.js} +2 -2
  3. package/dist/{BindingsPicker-DDqtV-Dt.js → BindingsPicker-Cjl2Th_Q.js} +2 -2
  4. package/dist/{BindingsTable-C7pNcdJS.js → BindingsTable-BeNptqZW.js} +3 -3
  5. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-TUaVrXZt.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-h-hFgCLF.js} +1 -1
  6. package/dist/{FmMultiselectDialog.vue_vue_type_script_setup_true_lang-CFVarJY6.js → FmMultiselectDialog.vue_vue_type_script_setup_true_lang-DMJFuKOx.js} +2 -2
  7. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-B46dL3GK.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D5MDXCdF.js} +3 -3
  8. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-eHB-EELx.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BWHoRZgx.js} +1 -1
  9. package/dist/IngredientsView-D2koDDCa.js +961 -0
  10. package/dist/{IntegrationView-DoNIpOlf.js → IntegrationView-GCoPVdgX.js} +3 -3
  11. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BOD3sRaO.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-lu1Pn7Gk.js} +6 -6
  12. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Bo5r3L9C.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CrPXWCp-.js} +1 -1
  13. package/dist/{PurchaseOrderPrintPreview-BPvebP_9.js → PurchaseOrderPrintPreview-Cn-mprBN.js} +1 -1
  14. package/dist/{ReceiveRequestView-BmGfyccP.js → ReceiveRequestView-GL432SId.js} +12 -12
  15. package/dist/{RecipeView-CMTLMhqx.js → RecipeView-BFmR7xPn.js} +7 -7
  16. package/dist/StockForecast.vue_vue_type_style_index_0_lang-B5EK101t.js +58 -0
  17. package/dist/StockView-DcP0TgA3.js +1960 -0
  18. package/dist/{SupplierView-CvU7KAhV.js → SupplierView-Bm-s_LxZ.js} +7 -7
  19. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-WB33qI-T.js → TransferDetails.vue_vue_type_script_setup_true_lang-DYoCba5O.js} +5 -5
  20. package/dist/{UnitView-BVvw9e8T.js → UnitView-D18PDC4n.js} +6 -6
  21. package/dist/{WarehouseView-CmV0UW0K.js → WarehouseView-eLPv8hGj.js} +3 -3
  22. package/dist/api/inventory.d.ts +8 -0
  23. package/dist/{app-O1zDxmv0.js → app-CoibawJ0.js} +2618 -2613
  24. package/dist/app.js +1 -1
  25. package/dist/components/StockForecast.vue.d.ts +1 -1
  26. package/dist/components/StockForecastProps.d.ts +7 -0
  27. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +4 -0
  28. package/dist/components/shell/inventory/binding-ui.vue.d.ts +4 -0
  29. package/dist/{date2-BD5YjQ2-.js → date2-dqysRKe3.js} +1 -1
  30. package/dist/{dayjs.min-D2krsD1m.js → dayjs.min-BzpFqAbZ.js} +171 -136
  31. package/dist/{decimal-kgi8j2WD.js → decimal-DWauQ6xh.js} +1 -1
  32. package/dist/{fuzzy-DgzXRD3R.js → fuzzy-DugNfdQg.js} +1 -1
  33. package/dist/{init-date-range-AqEW4Dkk.js → init-date-range-C7UhcSkp.js} +1 -1
  34. package/dist/{layout-DrCGFTq4.js → layout-h_bwk4FG.js} +1 -1
  35. package/dist/{rules-xXkrVUNf.js → rules-DFRHLux_.js} +1 -1
  36. package/dist/{stock-estimate-5EznMVbX.js → stock-estimate-vp_4DTD4.js} +2 -2
  37. package/dist/stores/inventory.d.ts +16 -0
  38. package/dist/{supplier-BxDnb8U3.js → supplier-WzY65qOo.js} +1 -1
  39. package/dist/tsconfig.app.tsbuildinfo +1 -1
  40. package/dist/{use-inventory-binding-dialog-Ci8xOw7J.js → use-inventory-binding-dialog-D5FIe7hV.js} +2 -2
  41. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +8 -0
  42. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +4 -0
  43. package/dist/views/ingredients/helper/sku-days-threshold.helper.d.ts +1 -0
  44. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +20 -0
  45. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +16 -0
  46. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +48 -0
  47. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +8 -0
  48. package/dist/{xlsx-BTr72y9q.js → xlsx-tNyBIBTV.js} +1 -1
  49. package/package.json +1 -1
  50. package/dist/IngredientsView-DfCkjxFn.js +0 -832
  51. package/dist/StockView-DnjkFPPa.js +0 -1987
  52. package/dist/util-CEVKTbZD.js +0 -18
@@ -0,0 +1,961 @@
1
+ import { ref as z, defineComponent as se, computed as c, resolveComponent as b, openBlock as S, createBlock as B, withCtx as v, createVNode as r, createElementBlock as Q, Fragment as ae, createElementVNode as a, createCommentVNode as Y, onMounted as Re, watch as Ee, unref as m, normalizeClass as ye, createTextVNode as De, toDisplayString as X, renderList as $e, isRef as be, normalizeStyle as Te, Teleport as Pe, normalizeProps as Be, guardReactiveProps as Le } from "vue";
2
+ import { u as ue, c as Se, S as Oe, g as Ve, F as G, d as he, a as Ne, C as re, b as xe, e as ze } from "./app-CoibawJ0.js";
3
+ import { useDialog as Ge, useSnackbar as ke, useProxiedModel as Fe, useBreakpoints as We } from "@feedmepos/ui-library";
4
+ import { i as Ye, _ as qe } from "./is-linked-ingredient-error-C6AghEwR.js";
5
+ import { F as M, D as we, R as ne } from "./row-action.enum-BwQbURNh.js";
6
+ import { c as He, _ as je, F as Ce, u as Ke } from "./layout-h_bwk4FG.js";
7
+ import { _ as Je } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CFjO4TPG.js";
8
+ import { R as de, U as Qe, A as ie, M as Xe } from "./rules-DFRHLux_.js";
9
+ import { g as Ze, _ as me, S as ce } from "./StockForecast.vue_vue_type_style_index_0_lang-B5EK101t.js";
10
+ import { _ as et } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-lu1Pn7Gk.js";
11
+ import { _ as pe } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-BWHoRZgx.js";
12
+ import { a as tt, t as lt } from "./date2-dqysRKe3.js";
13
+ import { useCoreStore as nt } from "@feedmepos/mf-common";
14
+ import { _ as fe } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-BvadeWUz.js";
15
+ function ot() {
16
+ const A = Ge(), F = ke(), V = ue(), l = z(!1), o = z();
17
+ function s() {
18
+ const d = {
19
+ unit: {},
20
+ mode: M.CREATE,
21
+ show: !0,
22
+ "onUpdate:show"(h) {
23
+ o.value.show = h;
24
+ }
25
+ };
26
+ o.value = d;
27
+ }
28
+ async function f(d) {
29
+ const h = {
30
+ unit: Se(d),
31
+ mode: M.UPDATE,
32
+ show: !0,
33
+ "onUpdate:show"(i) {
34
+ o.value.show = i;
35
+ }
36
+ };
37
+ o.value = h;
38
+ }
39
+ async function C(d) {
40
+ l.value = !0;
41
+ try {
42
+ await V.deleteSku(d), F.open({
43
+ title: "Success",
44
+ message: `Deleted ${d.name}`,
45
+ type: "success"
46
+ });
47
+ } catch (h) {
48
+ h instanceof Oe && Ye(h) ? A.open({
49
+ title: "Cannot delete ingredient",
50
+ contentComponent: qe,
51
+ contentComponentProps: {
52
+ subject: (d == null ? void 0 : d.name) ?? "",
53
+ items: h.errorResponse.message
54
+ },
55
+ secondaryActions: {
56
+ text: "Close",
57
+ close: !0
58
+ }
59
+ }) : console.log("unable to delete ingredient", h), F.open({
60
+ title: `Cannot delete ${d.name}`,
61
+ message: "Please try again.",
62
+ type: "error"
63
+ }), console.error("failed to delete ingredient", h);
64
+ } finally {
65
+ l.value = !1;
66
+ }
67
+ }
68
+ function U(d) {
69
+ A.open({
70
+ title: `Delete ${(d == null ? void 0 : d.name) ?? "ingredient"}?`,
71
+ closeButton: !1,
72
+ message: "You may not be able to delete this ingredient if it is linked in any of the inventory modules.",
73
+ primaryActions: {
74
+ text: "Delete",
75
+ close: !0,
76
+ variant: "destructive"
77
+ },
78
+ secondaryActions: {
79
+ text: "Cancel",
80
+ close: !0
81
+ }
82
+ }).onPrimary(() => C(d));
83
+ }
84
+ return {
85
+ createIngredient: s,
86
+ updateIngredient: f,
87
+ deleteIngredient: U,
88
+ ingredientDialogProps: o,
89
+ ingredientViewLoading: l
90
+ };
91
+ }
92
+ function at({
93
+ updateIngredient: A,
94
+ deleteIngredient: F
95
+ }) {
96
+ async function V(o, s) {
97
+ const f = Se(s);
98
+ if (o === ne.Edit) {
99
+ await A(f);
100
+ return;
101
+ }
102
+ if (o === ne.Delete) {
103
+ await F(f);
104
+ return;
105
+ }
106
+ }
107
+ return { columnDefs: [
108
+ {
109
+ accessorKey: "code",
110
+ header: "Code",
111
+ enableSorting: !0,
112
+ size: 300
113
+ },
114
+ {
115
+ accessorKey: "name",
116
+ header: "Name",
117
+ enableSorting: !0,
118
+ size: 300
119
+ },
120
+ {
121
+ accessorFn: (o) => {
122
+ var s;
123
+ if (o.trackingMeasurement) {
124
+ const f = (s = o.unit.measurements) == null ? void 0 : s.find(
125
+ (C) => C.id === o.trackingMeasurement
126
+ );
127
+ if (f)
128
+ return `${f.name} (${f.abbrev})`;
129
+ }
130
+ return `${o.unit.name} (${o.unit.abbrev})`;
131
+ },
132
+ header: "Unit",
133
+ enableSorting: !1,
134
+ size: "auto"
135
+ },
136
+ {
137
+ id: "action",
138
+ header: "",
139
+ cell(o) {
140
+ return He(
141
+ [we[ne.Edit], we[ne.Delete]],
142
+ (s) => {
143
+ V(s, o.row.original);
144
+ }
145
+ );
146
+ },
147
+ enableSorting: !1,
148
+ size: 40,
149
+ meta: {
150
+ cellClass: "",
151
+ headerClass: ""
152
+ }
153
+ }
154
+ ] };
155
+ }
156
+ const st = /* @__PURE__ */ se({
157
+ __name: "ConvertForm",
158
+ props: {
159
+ modelValue: {},
160
+ rootValue: {},
161
+ disabled: { type: Boolean }
162
+ },
163
+ emits: ["update:modelValue"],
164
+ setup(A, { emit: F }) {
165
+ const V = A, l = c(() => {
166
+ var i;
167
+ return (i = V.rootValue) == null ? void 0 : i.unit;
168
+ }), o = c(() => {
169
+ var i;
170
+ return (i = V.rootValue) == null ? void 0 : i._id;
171
+ }), s = F, f = c({
172
+ get() {
173
+ return !!V.modelValue;
174
+ },
175
+ set(i) {
176
+ i ? s("update:modelValue", {
177
+ measurement: null,
178
+ inventoryBindings: []
179
+ }) : s("update:modelValue", null);
180
+ }
181
+ }), C = c(() => Ze(l.value));
182
+ function U(i) {
183
+ const y = V.modelValue ?? {};
184
+ y.measurement = i ? `${i}` : null, s("update:modelValue", y);
185
+ }
186
+ function d(i) {
187
+ const y = V.modelValue ?? {};
188
+ y.inventoryBindings = i, s("update:modelValue", y);
189
+ }
190
+ const h = c(() => {
191
+ if (!V.modelValue) return null;
192
+ const i = V.modelValue;
193
+ return i.measurement ? C.value.find((y) => y.value === i.measurement) ?? null : C.value.find((y) => y.value === null) ?? null;
194
+ });
195
+ return (i, y) => {
196
+ const L = b("FmSwitch"), w = b("FmSelect"), x = b("FmCard");
197
+ return S(), B(x, {
198
+ variant: "outlined",
199
+ class: "p-16 flex flex-col gap-16"
200
+ }, {
201
+ default: v(() => {
202
+ var E, I;
203
+ return [
204
+ r(L, {
205
+ value: "",
206
+ "model-value": f.value,
207
+ "onUpdate:modelValue": y[0] || (y[0] = (R) => f.value = R),
208
+ label: "Convertible",
209
+ sublabel: "Convertible from other recipe or ingredients",
210
+ labelPlacement: "right"
211
+ }, null, 8, ["model-value"]),
212
+ f.value ? (S(), Q(ae, { key: 0 }, [
213
+ a("div", null, [
214
+ r(w, {
215
+ label: "Recipes and ingredients convert to",
216
+ modelValue: (E = h.value) == null ? void 0 : E.value,
217
+ "onUpdate:modelValue": U,
218
+ items: C.value
219
+ }, null, 8, ["modelValue", "items"])
220
+ ]),
221
+ r(et, {
222
+ id: o.value,
223
+ "model-value": ((I = i.modelValue) == null ? void 0 : I.inventoryBindings) ?? [],
224
+ "onUpdate:modelValue": d,
225
+ "exclude-binding-id": o.value
226
+ }, null, 8, ["id", "model-value", "exclude-binding-id"])
227
+ ], 64)) : Y("", !0)
228
+ ];
229
+ }),
230
+ _: 1
231
+ });
232
+ };
233
+ }
234
+ });
235
+ function oe() {
236
+ return {
237
+ low: 7,
238
+ mid: 14
239
+ };
240
+ }
241
+ const ut = { class: "text-fm-color-typo-secondary" }, rt = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, dt = { class: "col-span-2 mt-16" }, it = {
242
+ key: 1,
243
+ class: "col-span-2 mt-16 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
244
+ }, mt = { class: "col-span-2 flex flex-col gap-12" }, ct = { class: "flex flex-col gap-4" }, pt = /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800" }, "Alert threshold", -1), ft = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Configure threshold for days remaining indicator in the stock balance page. ", -1), vt = { class: "col-span-2 flex flex-col gap-4" }, _t = { class: "flex fm-corner-radius-md border-[1px] border-fm-color-neutral-gray-200" }, gt = { class: "flex-1 p-12 flex flex-col gap-8" }, yt = { class: "mx-auto" }, bt = { class: "flex flex-col" }, Vt = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "When less than", -1), ht = /* @__PURE__ */ a("div", { class: "text-fm-color-typo-secondary pr-32" }, "days", -1), xt = /* @__PURE__ */ a("div", { class: "h-full w-[1px] bg-fm-color-neutral-gray-200 relative" }, [
245
+ /* @__PURE__ */ a("div", {
246
+ class: "absolute bg-white",
247
+ style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
248
+ }, /* @__PURE__ */ X("<"))
249
+ ], -1), Ft = { class: "flex-1 p-12 flex flex-col gap-8" }, wt = { class: "mx-auto" }, Ct = { class: "flex flex-col" }, St = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "When less than", -1), kt = /* @__PURE__ */ a("div", { class: "text-fm-color-typo-secondary pr-32" }, "days", -1), Mt = /* @__PURE__ */ a("div", { class: "h-full w-[1px] bg-fm-color-neutral-gray-200 relative" }, [
250
+ /* @__PURE__ */ a("div", {
251
+ class: "absolute bg-white",
252
+ style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
253
+ }, /* @__PURE__ */ X("<"))
254
+ ], -1), It = { class: "flex-1 p-12 flex flex-col gap-8" }, At = { class: "mx-auto" }, Ut = /* @__PURE__ */ a("div", { class: "flex flex-col" }, [
255
+ /* @__PURE__ */ a("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "Stock is staple")
256
+ ], -1), Rt = /* @__PURE__ */ se({
257
+ __name: "IngredientForm",
258
+ props: {
259
+ mode: {},
260
+ modelValue: {},
261
+ disabled: { type: Boolean }
262
+ },
263
+ emits: ["update:modelValue", "click:submit"],
264
+ setup(A, { expose: F, emit: V }) {
265
+ var ve;
266
+ const l = A, o = V, s = ue(), f = nt(), C = Ne();
267
+ function U(e) {
268
+ if (e.length === 0) return;
269
+ const t = e[0], n = l.modelValue ?? {
270
+ unit: s.units.find((u) => u)
271
+ };
272
+ n.unit || (n.unit = t, o("update:modelValue", n));
273
+ }
274
+ Re(() => {
275
+ U(s.units);
276
+ }), Ee([() => s.units], ([e]) => {
277
+ U(e);
278
+ });
279
+ function d() {
280
+ o("click:submit");
281
+ }
282
+ const h = c({
283
+ get() {
284
+ var e;
285
+ return ((e = l.modelValue) == null ? void 0 : e.code) ?? "";
286
+ },
287
+ set(e) {
288
+ const t = l.modelValue ? {
289
+ ...l.modelValue
290
+ } : {};
291
+ t.code = e, o("update:modelValue", t);
292
+ }
293
+ }), i = c({
294
+ get() {
295
+ var e;
296
+ return ((e = l.modelValue) == null ? void 0 : e.name) ?? "";
297
+ },
298
+ set(e) {
299
+ const t = l.modelValue ? {
300
+ ...l.modelValue
301
+ } : {};
302
+ t.name = e, o("update:modelValue", t);
303
+ }
304
+ }), y = c({
305
+ get() {
306
+ var t, n;
307
+ const e = (n = (t = l.modelValue) == null ? void 0 : t.defaultCost) == null ? void 0 : n.costPerUnit;
308
+ return e ? +tt(e) : 0;
309
+ },
310
+ set(e) {
311
+ var n, u, _, p;
312
+ const t = l.modelValue ? {
313
+ ...l.modelValue
314
+ } : {};
315
+ t.defaultCost ?? (t.defaultCost = {
316
+ costPerUnit: {
317
+ amount: 0,
318
+ precision: 2,
319
+ currency: ((n = Ve(f.currentCountry.value)) == null ? void 0 : n.currency) ?? "MYR"
320
+ },
321
+ measurement: (p = (_ = (u = l.modelValue) == null ? void 0 : u.unit) == null ? void 0 : _.measurements) == null ? void 0 : p.find(
322
+ (T) => {
323
+ var P;
324
+ return T.id === ((P = l.modelValue) == null ? void 0 : P.trackingMeasurement);
325
+ }
326
+ )
327
+ }), t.defaultCost.costPerUnit = {
328
+ ...t.defaultCost.costPerUnit,
329
+ ...lt(+e, 4)
330
+ }, o("update:modelValue", t);
331
+ }
332
+ }), L = c(() => {
333
+ var t, n, u;
334
+ const e = ((t = l.modelValue) == null ? void 0 : t.unit) ?? s.units.find((_) => _);
335
+ return e ? {
336
+ _id: e._id,
337
+ measurement: (n = l.modelValue) == null ? void 0 : n.trackingMeasurement,
338
+ name: ((u = e.measurements.find((_) => {
339
+ var p;
340
+ return _.id === ((p = l.modelValue) == null ? void 0 : p.trackingMeasurement);
341
+ })) == null ? void 0 : u.name) ?? e.name
342
+ } : null;
343
+ }), w = c(
344
+ () => s.units.flatMap(({ name: e, _id: t, abbrev: n, measurements: u }) => [
345
+ {
346
+ label: `${e}`,
347
+ value: null,
348
+ displayAsSection: !0
349
+ },
350
+ {
351
+ label: `${e} (${n})`,
352
+ value: { _id: t },
353
+ displayAsSection: !1
354
+ },
355
+ ...u.map(({ id: _, name: p, abbrev: T }) => ({
356
+ label: `${p} (${T})`,
357
+ value: { _id: t, measurement: _ },
358
+ displayAsSection: !1
359
+ }))
360
+ ])
361
+ );
362
+ function x(e) {
363
+ var t, n, u, _, p;
364
+ return ((n = (t = l.modelValue) == null ? void 0 : t.unit) == null ? void 0 : n._id) === ((u = e.value) == null ? void 0 : u._id) && ((_ = l.modelValue) == null ? void 0 : _.trackingMeasurement) === ((p = e.value) == null ? void 0 : p.measurement);
365
+ }
366
+ function E(e) {
367
+ var T, P;
368
+ if (!e) return;
369
+ const { _id: t, measurement: n } = e, u = n || void 0, _ = s.units.find((J) => J._id === t);
370
+ if (!_)
371
+ return;
372
+ const p = l.modelValue ?? {};
373
+ p.unit = _, p.trackingMeasurement = u, p.convert && (p.convert.measurement = u || null), C.enableTotalCost && (p.defaultCost = {
374
+ measurement: _.measurements.find((J) => J.id === u),
375
+ costPerUnit: {
376
+ ...((T = p.defaultCost) == null ? void 0 : T.costPerUnit) ?? {
377
+ amount: 0,
378
+ precision: 2,
379
+ currency: ((P = Ve(f.currentCountry.value)) == null ? void 0 : P.currency) ?? "MYR"
380
+ }
381
+ }
382
+ }), o("update:modelValue", p);
383
+ }
384
+ const I = c({
385
+ get() {
386
+ var e;
387
+ return ((e = l.modelValue) == null ? void 0 : e.convert) ?? null;
388
+ },
389
+ set(e) {
390
+ const t = l.modelValue ? {
391
+ ...l.modelValue
392
+ } : {};
393
+ e ? t.convert = e : t.convert = null, o("update:modelValue", t);
394
+ }
395
+ }), R = c(() => G.options.filter(
396
+ (e) => e === G.enum.FIFO || e === G.enum.WAVG
397
+ ).map((e) => {
398
+ function t(n) {
399
+ switch (n) {
400
+ case G.enum.WAVG:
401
+ return "Weighted Average (WAVG)";
402
+ case G.enum.FIFO:
403
+ return "First In First Out (FIFO)";
404
+ case G.enum.LIFO:
405
+ return "Last In First Out (LIFO)";
406
+ case G.enum.FEFO:
407
+ return "First Expired First Out (FEFO)";
408
+ }
409
+ return "";
410
+ }
411
+ return {
412
+ label: t(e),
413
+ value: e
414
+ };
415
+ })), Z = c({
416
+ get() {
417
+ var e;
418
+ return ((e = l.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
419
+ },
420
+ set(e) {
421
+ const t = l.modelValue ? {
422
+ ...l.modelValue
423
+ } : {};
424
+ t.valuation = e, o("update:modelValue", t);
425
+ }
426
+ }), D = z();
427
+ F({
428
+ validateInputs: () => {
429
+ var e, t;
430
+ (t = (e = D.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
431
+ },
432
+ resetInputsValidation: () => {
433
+ var e, t;
434
+ (t = (e = D.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
435
+ },
436
+ resetInputs: () => {
437
+ var e, t;
438
+ (t = (e = D.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
439
+ }
440
+ });
441
+ const $ = z(!1), q = c(
442
+ () => {
443
+ var e, t, n;
444
+ return (e = l.modelValue) != null && e._id ? ((n = s.menu.bindedBySkuId[(t = l.modelValue) == null ? void 0 : t._id]) == null ? void 0 : n.filter(
445
+ (u) => u.from === "INGREDIENT"
446
+ )) ?? [] : [];
447
+ }
448
+ ), H = c(
449
+ () => {
450
+ var e, t, n;
451
+ return (e = l.modelValue) != null && e._id ? ((n = s.menu.bindedBySkuId[(t = l.modelValue) == null ? void 0 : t._id]) == null ? void 0 : n.filter(
452
+ (u) => u.from === "RECIPE"
453
+ )) ?? [] : [];
454
+ }
455
+ ), j = c(
456
+ () => {
457
+ var e, t, n;
458
+ return (e = l.modelValue) != null && e._id ? ((n = s.menu.bindedBySkuId[(t = l.modelValue) == null ? void 0 : t._id]) == null ? void 0 : n.filter((u) => u.from === "MENU")) ?? [] : [];
459
+ }
460
+ ), W = c(
461
+ () => s.skus.map((e) => ({ label: e.name, value: e.code }))
462
+ ), ee = z((ve = l.modelValue) == null ? void 0 : ve.code);
463
+ function te(e) {
464
+ var n;
465
+ const t = e.el;
466
+ t && ((n = t.querySelector("[x-should-scroll-into=true]")) == null || n.scrollIntoView());
467
+ }
468
+ function K(e) {
469
+ switch (e) {
470
+ case re.MY:
471
+ return "MYR";
472
+ case re.SG:
473
+ return "SGD";
474
+ case re.ID:
475
+ return "IDR";
476
+ default:
477
+ return "MYR";
478
+ }
479
+ }
480
+ const le = c(
481
+ () => {
482
+ var e, t, n, u, _, p;
483
+ return ((u = (n = (t = (e = l.modelValue) == null ? void 0 : e.unit) == null ? void 0 : t.measurements) == null ? void 0 : n.find(
484
+ (T) => {
485
+ var P;
486
+ return T.id === ((P = l.modelValue) == null ? void 0 : P.trackingMeasurement);
487
+ }
488
+ )) == null ? void 0 : u.abbrev) ?? ((p = (_ = l.modelValue) == null ? void 0 : _.unit) == null ? void 0 : p.abbrev);
489
+ }
490
+ ), O = c({
491
+ get() {
492
+ var e, t;
493
+ return ((t = (e = l.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.low) ?? oe().low;
494
+ },
495
+ set(e) {
496
+ var u;
497
+ const t = ((u = l.modelValue) == null ? void 0 : u.thresholds) ?? oe();
498
+ t.low = e;
499
+ const n = l.modelValue ? {
500
+ ...l.modelValue
501
+ } : {};
502
+ n.thresholds = t, o("update:modelValue", n);
503
+ }
504
+ }), N = c({
505
+ get() {
506
+ var e, t;
507
+ return ((t = (e = l.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.mid) ?? oe().mid;
508
+ },
509
+ set(e) {
510
+ var u;
511
+ const t = ((u = l.modelValue) == null ? void 0 : u.thresholds) ?? oe();
512
+ t.mid = e;
513
+ const n = l.modelValue ? {
514
+ ...l.modelValue
515
+ } : {};
516
+ n.thresholds = t, o("update:modelValue", n);
517
+ }
518
+ });
519
+ function Me() {
520
+ return function(t) {
521
+ return typeof (t == null ? void 0 : t.low) != "number" || typeof (t == null ? void 0 : t.mid) != "number" ? "Required" : t.low >= t.mid ? "Days for red indicator should be less than yellow indicator." : !0;
522
+ };
523
+ }
524
+ return (e, t) => {
525
+ const n = b("FmTextField"), u = b("FmLabel"), _ = b("FmSelect"), p = b("FmField"), T = b("FmMenuHeader"), P = b("FmMenuDivider"), J = b("FmMenuItem"), Ie = b("FmMenu"), _e = b("FmFormGroup"), Ae = b("FmSwitch"), ge = b("FmStepperField"), Ue = b("FmForm");
526
+ return S(), B(Ue, {
527
+ disabled: e.disabled,
528
+ ref_key: "formRef",
529
+ ref: D,
530
+ class: "grid grid-cols-2 gap-24",
531
+ onValidationSuccess: d
532
+ }, {
533
+ default: v(() => [
534
+ r(n, {
535
+ label: "Code",
536
+ "model-value": h.value,
537
+ "onUpdate:modelValue": t[0] || (t[0] = (g) => h.value = g),
538
+ rules: [m(de)(), m(Qe)(W.value, ee.value)],
539
+ "label-mark": "required"
540
+ }, null, 8, ["model-value", "rules"]),
541
+ r(n, {
542
+ label: "Name",
543
+ "model-value": i.value,
544
+ "onUpdate:modelValue": t[1] || (t[1] = (g) => i.value = g),
545
+ rules: [m(de)()],
546
+ "label-mark": "required"
547
+ }, null, 8, ["model-value", "rules"]),
548
+ r(_, {
549
+ class: "col-span-2",
550
+ "model-value": Z.value,
551
+ "onUpdate:modelValue": t[2] || (t[2] = (g) => Z.value = g),
552
+ items: R.value
553
+ }, {
554
+ label: v(() => [
555
+ r(fe, { "z-index": 50 }, {
556
+ default: v(() => [
557
+ r(u, { label: "Valuation Method" })
558
+ ]),
559
+ _: 1
560
+ })
561
+ ]),
562
+ _: 1
563
+ }, 8, ["model-value", "items"]),
564
+ r(_e, {
565
+ class: ye([m(C).enableTotalCost ? "col-span-1" : "col-span-2"]),
566
+ "model-value": L.value,
567
+ rules: [m(de)()],
568
+ "label-mark": "required"
569
+ }, {
570
+ label: v(() => [
571
+ r(u, { label: "Unit" })
572
+ ]),
573
+ default: v(({ invalid: g }) => [
574
+ r(Ie, null, {
575
+ "menu-button": v(() => [
576
+ r(p, {
577
+ class: ye([
578
+ "fm-typo-en-body-lg-400",
579
+ {
580
+ "text-fm-color-typo-primary": !e.disabled,
581
+ "text-fm-color-typo-disabled": e.disabled
582
+ }
583
+ ]),
584
+ invalid: g,
585
+ "append-icon": "expand_more"
586
+ }, {
587
+ default: v(() => {
588
+ var k;
589
+ return [
590
+ De(X((k = L.value) == null ? void 0 : k.name), 1)
591
+ ];
592
+ }),
593
+ _: 2
594
+ }, 1032, ["class", "invalid"])
595
+ ]),
596
+ default: v(() => [
597
+ a("div", {
598
+ class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
599
+ onVnodeMounted: te
600
+ }, [
601
+ (S(!0), Q(ae, null, $e(w.value, (k) => (S(), Q(ae, {
602
+ key: k.label
603
+ }, [
604
+ k.displayAsSection ? (S(), Q(ae, { key: 0 }, [
605
+ r(T, {
606
+ label: k.label
607
+ }, null, 8, ["label"]),
608
+ r(P)
609
+ ], 64)) : (S(), B(J, {
610
+ key: 1,
611
+ label: k.label,
612
+ "model-value": x(k),
613
+ onClick: (Nt) => E(k.value),
614
+ "x-should-scroll-into": `${x(k)}`
615
+ }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
616
+ ], 64))), 128))
617
+ ], 512)
618
+ ]),
619
+ _: 2
620
+ }, 1024)
621
+ ]),
622
+ _: 1
623
+ }, 8, ["class", "model-value", "rules"]),
624
+ m(C).enableTotalCost ? (S(), B(n, {
625
+ key: 0,
626
+ "model-value": y.value,
627
+ "onUpdate:modelValue": t[3] || (t[3] = (g) => y.value = g),
628
+ rules: [m(ie)(0), m(Xe)(2)]
629
+ }, {
630
+ label: v(() => [
631
+ r(fe, { "z-index": 50 }, {
632
+ default: v(() => [
633
+ r(u, { label: "Price per unit" })
634
+ ]),
635
+ _: 1
636
+ })
637
+ ]),
638
+ prepend: v(() => {
639
+ var g, k;
640
+ return [
641
+ a("div", ut, X(K(((g = m(f).currentCountry) == null ? void 0 : g.value) ?? m(he)) === "MYR" ? "RM" : K(((k = m(f).currentCountry) == null ? void 0 : k.value) ?? m(he))), 1)
642
+ ];
643
+ }),
644
+ append: v(() => [
645
+ a("div", rt, " / " + X(le.value), 1)
646
+ ]),
647
+ _: 1
648
+ }, 8, ["model-value", "rules"])) : Y("", !0),
649
+ a("div", dt, [
650
+ r(st, {
651
+ "model-value": I.value,
652
+ "onUpdate:modelValue": t[4] || (t[4] = (g) => I.value = g),
653
+ "root-value": e.modelValue
654
+ }, null, 8, ["model-value", "root-value"])
655
+ ]),
656
+ e.mode !== m(M).CREATE ? (S(), Q("div", it, [
657
+ a("div", null, [
658
+ r(Ae, {
659
+ label: "Show binded items",
660
+ modelValue: $.value,
661
+ "onUpdate:modelValue": t[5] || (t[5] = (g) => $.value = g),
662
+ "label-placement": "right"
663
+ }, null, 8, ["modelValue"])
664
+ ]),
665
+ $.value && q.value.length ? (S(), B(pe, {
666
+ key: 0,
667
+ name: "Ingredient",
668
+ bindings: q.value
669
+ }, null, 8, ["bindings"])) : Y("", !0),
670
+ $.value && H.value.length ? (S(), B(pe, {
671
+ key: 1,
672
+ name: "Recipe",
673
+ bindings: H.value
674
+ }, null, 8, ["bindings"])) : Y("", !0),
675
+ $.value && j.value.length ? (S(), B(pe, {
676
+ key: 2,
677
+ name: "Menu",
678
+ bindings: j.value
679
+ }, null, 8, ["bindings"])) : Y("", !0)
680
+ ])) : Y("", !0),
681
+ a("div", mt, [
682
+ a("div", ct, [
683
+ r(fe, null, {
684
+ default: v(() => [
685
+ pt
686
+ ]),
687
+ _: 1
688
+ }),
689
+ ft
690
+ ]),
691
+ a("div", vt, [
692
+ r(_e, {
693
+ "model-value": { low: O.value, mid: N.value },
694
+ rules: [Me()]
695
+ }, null, 8, ["model-value", "rules"]),
696
+ a("div", _t, [
697
+ a("div", gt, [
698
+ a("div", yt, [
699
+ r(me, {
700
+ days: O.value,
701
+ level: m(ce).low
702
+ }, null, 8, ["days", "level"])
703
+ ]),
704
+ a("div", bt, [
705
+ Vt,
706
+ r(ge, {
707
+ modelValue: O.value,
708
+ "onUpdate:modelValue": t[6] || (t[6] = (g) => O.value = g),
709
+ rules: [m(ie)(0)]
710
+ }, {
711
+ append: v(() => [
712
+ ht
713
+ ]),
714
+ _: 1
715
+ }, 8, ["modelValue", "rules"])
716
+ ])
717
+ ]),
718
+ xt,
719
+ a("div", Ft, [
720
+ a("div", wt, [
721
+ r(me, {
722
+ days: N.value,
723
+ level: m(ce).mid
724
+ }, null, 8, ["days", "level"])
725
+ ]),
726
+ a("div", Ct, [
727
+ St,
728
+ r(ge, {
729
+ modelValue: N.value,
730
+ "onUpdate:modelValue": t[7] || (t[7] = (g) => N.value = g),
731
+ rules: [m(ie)(0)]
732
+ }, {
733
+ append: v(() => [
734
+ kt
735
+ ]),
736
+ _: 1
737
+ }, 8, ["modelValue", "rules"])
738
+ ])
739
+ ]),
740
+ Mt,
741
+ a("div", It, [
742
+ a("div", At, [
743
+ r(me, {
744
+ days: N.value + 1,
745
+ level: m(ce).high
746
+ }, null, 8, ["days", "level"])
747
+ ]),
748
+ Ut
749
+ ])
750
+ ])
751
+ ])
752
+ ])
753
+ ]),
754
+ _: 1
755
+ }, 8, ["disabled"]);
756
+ };
757
+ }
758
+ }), Et = { class: "flex gap-4" }, Dt = /* @__PURE__ */ se({
759
+ __name: "IngredientDialog",
760
+ props: {
761
+ show: { type: Boolean },
762
+ unit: {},
763
+ mode: { default: M.READ }
764
+ },
765
+ emits: ["update:show"],
766
+ setup(A) {
767
+ const F = A, V = ue(), l = ke(), o = Fe(F, "show"), s = Fe(F, "unit"), f = c(() => {
768
+ switch (F.mode) {
769
+ case M.READ:
770
+ return "View ingredient";
771
+ case M.UPDATE:
772
+ return "Edit ingredient";
773
+ case M.CREATE:
774
+ return "Add ingredient";
775
+ }
776
+ return "";
777
+ }), C = c(() => {
778
+ switch (F.mode) {
779
+ case M.READ:
780
+ return "";
781
+ case M.UPDATE:
782
+ return "Save";
783
+ case M.CREATE:
784
+ return "Add";
785
+ }
786
+ return "";
787
+ }), U = z(), d = z(!1);
788
+ async function h() {
789
+ d.value = !0;
790
+ try {
791
+ await V.createSku(s.value), o.value = !1, l.open({
792
+ title: "Success",
793
+ message: "Created " + s.value.name,
794
+ type: "success"
795
+ });
796
+ } catch (w) {
797
+ w instanceof xe || l.open({
798
+ title: "Failed to create ingredient",
799
+ message: "Please try again",
800
+ type: "error"
801
+ });
802
+ } finally {
803
+ d.value = !1;
804
+ }
805
+ }
806
+ async function i() {
807
+ d.value = !0;
808
+ try {
809
+ await V.updateSku(s.value), d.value = !1, o.value = !1, l.open({
810
+ title: "Success",
811
+ message: "Updated " + s.value.name,
812
+ type: "success"
813
+ });
814
+ } catch (w) {
815
+ w instanceof xe || l.open({
816
+ title: "Failed to update ingredient",
817
+ message: "Please try again",
818
+ type: "error"
819
+ });
820
+ } finally {
821
+ d.value = !1;
822
+ }
823
+ }
824
+ function y() {
825
+ var w, x;
826
+ (x = (w = U.value) == null ? void 0 : w.validateInputs) == null || x.call(w);
827
+ }
828
+ function L() {
829
+ switch (F.mode) {
830
+ case M.READ:
831
+ return;
832
+ case M.UPDATE:
833
+ return i();
834
+ case M.CREATE:
835
+ return h();
836
+ }
837
+ }
838
+ return (w, x) => {
839
+ const E = b("FmButton"), I = b("FmSideSheet");
840
+ return S(), B(I, {
841
+ "model-value": m(o),
842
+ "onUpdate:modelValue": x[3] || (x[3] = (R) => be(o) ? o.value = R : null),
843
+ header: f.value,
844
+ "close-button": "",
845
+ "dismiss-away": "",
846
+ "max-width": 500
847
+ }, {
848
+ "side-sheet-footer": v(() => [
849
+ a("div", Et, [
850
+ r(E, {
851
+ loading: d.value,
852
+ label: C.value,
853
+ onClick: y
854
+ }, null, 8, ["loading", "label"]),
855
+ r(E, {
856
+ disabled: d.value,
857
+ label: "Close",
858
+ variant: "tertiary",
859
+ onClick: x[2] || (x[2] = (R) => o.value = !1)
860
+ }, null, 8, ["disabled"])
861
+ ])
862
+ ]),
863
+ default: v(() => [
864
+ r(Rt, {
865
+ class: "w-full",
866
+ ref_key: "hasValidationExpose",
867
+ ref: U,
868
+ modelValue: m(s),
869
+ "onUpdate:modelValue": x[0] || (x[0] = (R) => be(s) ? s.value = R : null),
870
+ mode: w.mode,
871
+ disabled: d.value,
872
+ "onClick:submit": x[1] || (x[1] = (R) => L())
873
+ }, null, 8, ["modelValue", "mode", "disabled"])
874
+ ]),
875
+ _: 1
876
+ }, 8, ["model-value", "header"]);
877
+ };
878
+ }
879
+ }), $t = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, Tt = { class: "px-8 flex items-center xs:gap-0 xs:flex-col-reverse sm:gap-0 sm:flex-col-reverse" }, Pt = { class: "flex-1 w-full" }, Bt = { class: "flex flex-col py-8" }, Lt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ot = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, ll = /* @__PURE__ */ se({
880
+ __name: "IngredientsView",
881
+ setup(A) {
882
+ const F = ue(), V = c(() => F.skus), l = ze(), {
883
+ createIngredient: o,
884
+ updateIngredient: s,
885
+ deleteIngredient: f,
886
+ ingredientDialogProps: C,
887
+ ingredientViewLoading: U
888
+ } = ot(), { columnDefs: d } = at({ updateIngredient: s, deleteIngredient: f });
889
+ function h(E) {
890
+ E === "add" && o();
891
+ }
892
+ const i = z(""), y = c(() => U.value), { breakpoints: L } = We(), w = c(() => L.value.xs || L.value.sm ? 10 : 20), x = Ke();
893
+ return (E, I) => {
894
+ const R = b("FmTableToolbar"), Z = b("FmTable");
895
+ return S(), B(Je, {
896
+ title: "Ingredient",
897
+ actions: [{ label: "Add ingredient", value: "add", isPrimary: !0, prependIcon: "add" }],
898
+ "onClick:action": h
899
+ }, {
900
+ default: v(() => [
901
+ a("div", $t, [
902
+ a("div", Tt, [
903
+ a("div", Pt, [
904
+ r(R, {
905
+ searchable: "",
906
+ "search-model": i.value,
907
+ "onUpdate:searchModel": I[0] || (I[0] = (D) => i.value = D)
908
+ }, null, 8, ["search-model"])
909
+ ])
910
+ ]),
911
+ r(Z, {
912
+ style: Te(m(x).tableHeight),
913
+ "column-defs": m(d),
914
+ "row-data": V.value,
915
+ "search-value": i.value,
916
+ loading: !m(l)._currentLocation || y.value,
917
+ onRowClick: I[1] || (I[1] = (D) => m(s)(D.original)),
918
+ "page-size": w.value
919
+ }, {
920
+ "list-row": v((D) => [
921
+ r(je, {
922
+ row: D,
923
+ onRowClick: m(s)
924
+ }, {
925
+ default: v(($) => {
926
+ var q, H, j, W, ee, te, K, le, O, N;
927
+ return [
928
+ a("div", Bt, [
929
+ a("div", Lt, [
930
+ r(m(Ce), {
931
+ render: (j = (H = (q = $.code) == null ? void 0 : q.column) == null ? void 0 : H.columnDef) == null ? void 0 : j.cell,
932
+ props: (ee = (W = $.code) == null ? void 0 : W.getContext) == null ? void 0 : ee.call(W)
933
+ }, null, 8, ["render", "props"])
934
+ ]),
935
+ a("div", Ot, [
936
+ r(m(Ce), {
937
+ render: (le = (K = (te = $.name) == null ? void 0 : te.column) == null ? void 0 : K.columnDef) == null ? void 0 : le.cell,
938
+ props: (N = (O = $.name) == null ? void 0 : O.getContext) == null ? void 0 : N.call(O)
939
+ }, null, 8, ["render", "props"])
940
+ ])
941
+ ])
942
+ ];
943
+ }),
944
+ _: 2
945
+ }, 1032, ["row", "onRowClick"])
946
+ ]),
947
+ _: 1
948
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
949
+ ]),
950
+ (S(), B(Pe, { to: "body" }, [
951
+ r(Dt, Be(Le(m(C))), null, 16)
952
+ ]))
953
+ ]),
954
+ _: 1
955
+ });
956
+ };
957
+ }
958
+ });
959
+ export {
960
+ ll as default
961
+ };