@feedmepos/mf-inventory-portal 1.2.7 → 1.2.8-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 (88) hide show
  1. package/dist/{App-BtLCesbn.js → App-BL2MW6zc.js} +1 -1
  2. package/dist/{ApprovalView-Ba4XBhGf.js → ApprovalView-C18JNyKG.js} +69 -68
  3. package/dist/{BindingsDialog-BbBUniCu.js → BindingsDialog-DxXGq2TK.js} +2 -2
  4. package/dist/{BindingsPicker-C3q3ROku.js → BindingsPicker-BsuXkTQv.js} +1 -1
  5. package/dist/{BindingsTable-BTxWMif_.js → BindingsTable-BeGm5MK6.js} +1 -1
  6. package/dist/{ClosingDraftView-DGITBnaY.js → ClosingDraftView-yzzV-yhQ.js} +203 -203
  7. package/dist/ClosingTemplateView-DgI8ANjn.js +1862 -0
  8. package/dist/{DeliveryOrderPrintPreview-CUaHpblV.js → DeliveryOrderPrintPreview-B3xmuRAQ.js} +8 -8
  9. package/dist/{FmAdminBadge-BdwGZY-f.js → FmAdminBadge-9bTzCMaP.js} +6 -6
  10. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B1pioWnC.js +230 -0
  11. package/dist/{FmMultiselectDialog-BETfHs3j.js → FmMultiselectDialog-D4QIUWaf.js} +1 -1
  12. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BNdbeRQp.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CwuM-hJU.js} +23 -23
  13. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-VYMMcwLl.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BFeK6K0l.js} +1 -1
  14. package/dist/{IngredientGroupView-C4d9b3Td.js → IngredientGroupView-Ku7t3MgL.js} +12 -12
  15. package/dist/IngredientsView-CAn1-40w.js +2306 -0
  16. package/dist/{IntegrationView-CWFzRDWO.js → IntegrationView-DEtbdogx.js} +4 -4
  17. package/dist/{InventoryBindingForm-Cx0Prlq8.js → InventoryBindingForm-BqBGbblS.js} +1 -1
  18. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-cpR3Sf2Y.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CpVc2nGE.js} +41 -41
  19. package/dist/{InventoryBindingSummary-l8XvpxVU.js → InventoryBindingSummary-dEM8P354.js} +1 -1
  20. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BjRvIX-v.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-0AaD13Wg.js} +1 -1
  21. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-gjuZveKy.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BqVwcG4Z.js} +11 -11
  22. package/dist/{PublishView-D2iUnDan.js → PublishView-CE2Ul9NM.js} +14 -14
  23. package/dist/{PurchaseOrderPrintPreview-DdLvM-wt.js → PurchaseOrderPrintPreview-C6Lg4V4I.js} +11 -11
  24. package/dist/{ReceiveRequestView-DpF5ZzvH.js → ReceiveRequestView-CDTT3m48.js} +148 -145
  25. package/dist/{RecipeView-Dvtm8o1Y.js → RecipeView-CROKnpq9.js} +49 -49
  26. package/dist/StockView-Wv700Rt6.js +2104 -0
  27. package/dist/SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BdtRkUS6.js +158 -0
  28. package/dist/{SupplierView-7GtIJ3Fz.js → SupplierView-BNWtlH7a.js} +1133 -1015
  29. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BvzSua6d.js +3058 -0
  30. package/dist/{TransferTemplateView-Cmvg-yvW.js → TransferTemplateView-DlxBMSPW.js} +131 -130
  31. package/dist/{UnitView-DjVm1iVX.js → UnitView-B56YIwiR.js} +59 -59
  32. package/dist/WarehouseView-C0d-uE4n.js +1066 -0
  33. package/dist/api/inventory.d.ts +8 -0
  34. package/dist/api/netsuite.d.ts +3 -0
  35. package/dist/api/purchase-order-template.d.ts +1 -0
  36. package/dist/api/purchase-order.d.ts +2 -0
  37. package/dist/api/shipment.d.ts +11 -0
  38. package/dist/api/warehouse.d.ts +3 -1
  39. package/dist/{app-Z-ylwRmy.js → app-Bo3plhvb.js} +17877 -17113
  40. package/dist/app.d.ts +96 -9
  41. package/dist/app.js +3 -3
  42. package/dist/closing-template-ByR3kWir.js +53 -0
  43. package/dist/components/FmInventoryTableToolbar.vue.d.ts +9 -2
  44. package/dist/components/netsuite/SubsidiaryTreeDialog.vue.d.ts +2 -0
  45. package/dist/{decimal-D1pJ2776.js → decimal-YpqAHWnk.js} +1 -1
  46. package/dist/{format-unit-display-9BMm-8A4.js → format-unit-display-CpusApo9.js} +372 -404
  47. package/dist/{index-rEIM0AVC.js → index-BHD7bEuA.js} +1 -1
  48. package/dist/{index-BOl10vcm.js → index-CJTjmcUN.js} +1 -1
  49. package/dist/purchase-order-template-CNhjKd6p.js +41 -0
  50. package/dist/{stock-B8ewk80v.js → stock-BhgeS5mL.js} +1 -1
  51. package/dist/stores/feature.d.ts +10 -0
  52. package/dist/stores/integration/netsuite.d.ts +19 -0
  53. package/dist/stores/inventory.d.ts +1 -0
  54. package/dist/stores/location.d.ts +57 -1
  55. package/dist/stores/supplier.d.ts +96 -0
  56. package/dist/stores/warehouse.d.ts +4 -0
  57. package/dist/{supplier-DLSXYY1o.js → supplier-DG8JyhMj.js} +1 -1
  58. package/dist/tsconfig.app.tsbuildinfo +1 -1
  59. package/dist/{use-ingredient-select-dialog-CTjwdY3T.js → use-ingredient-select-dialog-LIEBAng-.js} +5 -5
  60. package/dist/{use-inventory-binding-dialog-zXJB7MQY.js → use-inventory-binding-dialog-Df7DfQ1b.js} +8 -8
  61. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +24 -0
  62. package/dist/views/ingredients/components/ingredient-form/IngredientFormProps.d.ts +6 -0
  63. package/dist/views/integration/components/netsuite/business/BusinessNetSuiteSideSheet.vue.d.ts +2 -0
  64. package/dist/views/receive-request/components/delivery-order-form/CreateForm.vue.d.ts +16 -0
  65. package/dist/views/receive-request/components/delivery-order-form/CreateFormProps.d.ts +4 -0
  66. package/dist/views/receive-request/components/delivery-order-form/EditForm.vue.d.ts +16 -0
  67. package/dist/views/receive-request/components/delivery-order-form/EditFormProps.d.ts +4 -0
  68. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
  69. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +60 -0
  70. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +10 -0
  71. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +94 -0
  72. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +72 -1
  73. package/dist/views/supplier/components/SupplierForm.vue.d.ts +8 -0
  74. package/dist/views/supplier/components/SupplierSupplyItemField.vue.d.ts +3 -0
  75. package/dist/views/supplier/composables/use-supplier-table.d.ts +4 -0
  76. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +8 -0
  77. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +16 -0
  78. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +48 -0
  79. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +48 -0
  80. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -0
  81. package/package.json +3 -3
  82. package/dist/ClosingTemplateView-eRvwxXBq.js +0 -1908
  83. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-lDkElrkF.js +0 -227
  84. package/dist/IngredientsView-BvqWuIVT.js +0 -1876
  85. package/dist/StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js +0 -59
  86. package/dist/StockView-CRDu_GQ_.js +0 -2086
  87. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DbmLtbZt.js +0 -2494
  88. package/dist/WarehouseView-CBso3SXT.js +0 -1034
@@ -1,1876 +0,0 @@
1
- import { ref as H, h as Q, defineComponent as se, computed as S, resolveComponent as w, openBlock as h, createBlock as T, withCtx as V, createVNode as p, unref as d, createElementBlock as B, Fragment as X, createElementVNode as c, createCommentVNode as j, renderSlot as ve, createTextVNode as Re, toDisplayString as D, normalizeClass as J, mergeModels as Oe, onMounted as ft, watch as et, useModel as yt, renderList as ye, isRef as He, createSlots as tt, normalizeStyle as gt, Teleport as je, normalizeProps as bt, guardReactiveProps as ht } from "vue";
2
- import { a as ee, e as q, f as nt, S as _t, h as xt, D as Ye, i as xe, A as Ve, b as Ae, j as ot, k as Se, t as lt, l as kt, m as ge, n as Me, U as Vt, o as St, M as Ft, p as qe, q as Ge, c as at, r as We, s as st, v as wt, w as rt, x as Ct, y as Mt, I as It, z as $t, B as Et, N as Ut, H as Rt, u as At, C as Tt, _ as Dt, E as Bt, G as Pt, J as Ke, K as Nt } from "./app-Z-ylwRmy.js";
3
- import { useDialog as it, useSnackbar as Fe, components as Je, useProxiedModel as Ze, useDialogChild as zt, useBreakpoints as Lt } from "@feedmepos/ui-library";
4
- import { i as Ot, _ as Ht } from "./is-linked-ingredient-error-fJ2TJb3z.js";
5
- import { useI18n as re, useCoreStore as be } from "@feedmepos/mf-common";
6
- import { defineStore as jt, storeToRefs as Yt } from "pinia";
7
- import { g as qt, _ as Ie, S as $e } from "./StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js";
8
- import { _ as Gt } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-cpR3Sf2Y.js";
9
- import { _ as Ee } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-VYMMcwLl.js";
10
- import { _ as ke } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
11
- import { _ as Wt } from "./FmCustomAttribute.vue_vue_type_script_setup_true_lang-D-IWRjRD.js";
12
- import { r as Kt } from "./random-CSbEbElR.js";
13
- import "./array-Ca8T3f_G.js";
14
- import { u as Jt } from "./FmMultiselectDialog-BETfHs3j.js";
15
- const Ue = jt("ingredientForm", function() {
16
- const o = it(), y = Fe(), l = ee(), n = H(!1), { t: a } = re(), r = H();
17
- function m() {
18
- const b = {
19
- unit: {},
20
- mode: q.CREATE,
21
- show: !0,
22
- "onUpdate:show"(s) {
23
- r.value.show = s;
24
- }
25
- };
26
- r.value = b;
27
- }
28
- async function v(b) {
29
- const s = {
30
- unit: nt(b),
31
- mode: q.UPDATE,
32
- show: !0,
33
- "onUpdate:show"(_) {
34
- r.value.show = _;
35
- }
36
- };
37
- r.value = s;
38
- }
39
- async function g(b) {
40
- n.value = !0;
41
- try {
42
- await l.deleteSku(b), y.open({
43
- title: "Success",
44
- message: `Deleted ${b.name}`,
45
- type: "success"
46
- });
47
- } catch (s) {
48
- s instanceof _t && Ot(s) ? o.open({
49
- title: "Cannot delete ingredient",
50
- contentComponent: Ht,
51
- contentComponentProps: {
52
- subject: (b == null ? void 0 : b.name) ?? "",
53
- items: s.errorResponse.message
54
- },
55
- secondaryActions: {
56
- text: "Close",
57
- close: !0
58
- }
59
- }) : console.log("unable to delete ingredient", s), y.open({
60
- title: `Cannot delete ${b.name}`,
61
- message: "Please try again.",
62
- type: "error"
63
- }), console.error("failed to delete ingredient", s);
64
- } finally {
65
- n.value = !1;
66
- }
67
- }
68
- function u(b) {
69
- o.open({
70
- title: a("inventory.ingredient.delete.title", [(b == null ? void 0 : b.name) ?? ""]),
71
- closeButton: !1,
72
- message: a("inventory.ingredient.delete.message"),
73
- primaryActions: {
74
- text: a("common.delete"),
75
- close: !0,
76
- variant: "destructive"
77
- },
78
- secondaryActions: {
79
- text: a("common.cancel"),
80
- close: !0
81
- }
82
- }).onPrimary(() => g(b));
83
- }
84
- return {
85
- createIngredient: m,
86
- updateIngredient: v,
87
- deleteIngredient: u,
88
- ingredientDialogProps: r,
89
- ingredientViewLoading: n
90
- };
91
- });
92
- function Zt() {
93
- const { updateIngredient: i, deleteIngredient: o } = Ue(), y = ee(), { t: l } = re();
94
- async function n(r, m) {
95
- const v = nt(m);
96
- if (r === xe.Edit) {
97
- await i(v);
98
- return;
99
- }
100
- if (r === xe.Delete) {
101
- await o(v);
102
- return;
103
- }
104
- }
105
- return { columnDefs: [
106
- {
107
- accessorKey: "code",
108
- header: () => l("inventory.ingredient.code"),
109
- enableSorting: !0,
110
- size: 300
111
- },
112
- {
113
- accessorKey: "name",
114
- header: () => l("inventory.ingredient.name"),
115
- enableSorting: !0,
116
- size: 300,
117
- cell(r) {
118
- const m = r.row.original, v = y.skuBindingFlattenCache[m._id], g = v == null ? void 0 : v.inventoryBindings.some(
119
- (u) => "error" in u && u.reason === "circularDependency"
120
- );
121
- return Q("div", { class: "flex items-center w-full gap-4" }, [
122
- g ? Q(
123
- Je.FmTooltip,
124
- {},
125
- {
126
- default() {
127
- return Q(Je.FmIcon, {
128
- name: "info",
129
- color: "system-error-300",
130
- size: "sm"
131
- });
132
- },
133
- content() {
134
- return l("inventory.inventoryBindings.circularError");
135
- }
136
- }
137
- ) : null,
138
- m.name
139
- ]);
140
- }
141
- },
142
- {
143
- id: "unit",
144
- header: () => l("inventory.ingredient.unit"),
145
- cell(r) {
146
- var v;
147
- const m = r.row.original;
148
- if (m.trackingMeasurement) {
149
- const g = (v = m.unit.measurements) == null ? void 0 : v.find(
150
- (u) => u.id === m.trackingMeasurement
151
- );
152
- if (g)
153
- return `${g.name} (${g.abbrev})`;
154
- }
155
- return `${m.unit.name} (${m.unit.abbrev})`;
156
- },
157
- enableSorting: !1,
158
- size: "auto"
159
- },
160
- {
161
- accessorKey: "isInactive",
162
- header: () => l("inventory.ingredient.isInactive.title"),
163
- cell(r) {
164
- const m = r.row.original.isInactive;
165
- return Q(
166
- "span",
167
- {
168
- class: [
169
- "inline-block px-3 py-1 rounded-full text-xs font-semibold",
170
- m ? "bg-red-100 text-red-700" : "bg-green-100 text-green-700"
171
- ].join(" ")
172
- },
173
- l(m ? "inventory.ingredient.isInactive.yes" : "inventory.ingredient.isInactive.no")
174
- );
175
- },
176
- enableSorting: !0,
177
- size: 300
178
- },
179
- {
180
- id: "action",
181
- header: "",
182
- cell(r) {
183
- return xt(
184
- [Ye[xe.Edit], Ye[xe.Delete]],
185
- (m) => {
186
- n(m, r.row.original);
187
- }
188
- );
189
- },
190
- enableSorting: !1,
191
- size: 40,
192
- meta: {
193
- cellClass: "",
194
- headerClass: ""
195
- }
196
- }
197
- ] };
198
- }
199
- const Qt = /* @__PURE__ */ se({
200
- __name: "ConvertForm",
201
- props: {
202
- modelValue: {},
203
- rootValue: {},
204
- disabled: { type: Boolean },
205
- readonly: { type: Boolean }
206
- },
207
- emits: ["update:modelValue"],
208
- setup(i, { emit: o }) {
209
- const y = i, l = S(() => {
210
- var s;
211
- return (s = y.rootValue) == null ? void 0 : s.unit;
212
- }), n = S(() => {
213
- var s;
214
- return (s = y.rootValue) == null ? void 0 : s._id;
215
- }), a = o, { t: r } = re(), m = S({
216
- get() {
217
- return !!y.modelValue;
218
- },
219
- set(s) {
220
- s ? a("update:modelValue", {
221
- measurement: null,
222
- inventoryBindings: []
223
- }) : a("update:modelValue", null);
224
- }
225
- }), v = S(() => qt(l.value));
226
- function g(s) {
227
- const _ = y.modelValue ?? {};
228
- _.measurement = s ? `${s}` : null, a("update:modelValue", _);
229
- }
230
- function u(s) {
231
- const _ = y.modelValue ?? {};
232
- _.inventoryBindings = s, a("update:modelValue", _);
233
- }
234
- const b = S(() => {
235
- if (!y.modelValue) return null;
236
- const s = y.modelValue;
237
- return s.measurement ? v.value.find((_) => _.value === s.measurement) ?? null : v.value.find((_) => _.value === null) ?? null;
238
- });
239
- return (s, _) => {
240
- const N = w("FmSwitch"), E = w("FmSelect"), z = w("FmCard");
241
- return h(), T(z, {
242
- variant: "outlined",
243
- class: "p-16 flex flex-col gap-16"
244
- }, {
245
- default: V(() => {
246
- var x, $;
247
- return [
248
- p(N, {
249
- value: "",
250
- "model-value": m.value,
251
- "onUpdate:modelValue": _[0] || (_[0] = (C) => m.value = C),
252
- label: d(r)("inventory.ingredient.convertible.title"),
253
- sublabel: d(r)("inventory.ingredient.convertible.subtitle"),
254
- labelPlacement: "right",
255
- disabled: s.readonly
256
- }, null, 8, ["model-value", "label", "sublabel", "disabled"]),
257
- m.value ? (h(), B(X, { key: 0 }, [
258
- c("div", null, [
259
- p(E, {
260
- label: d(r)("inventory.ingredient.convertible.convertTo"),
261
- modelValue: (x = b.value) == null ? void 0 : x.value,
262
- "onUpdate:modelValue": g,
263
- items: v.value,
264
- disabled: s.readonly
265
- }, null, 8, ["label", "modelValue", "items", "disabled"])
266
- ]),
267
- p(Gt, {
268
- id: n.value,
269
- "model-value": (($ = s.modelValue) == null ? void 0 : $.inventoryBindings) ?? [],
270
- "onUpdate:modelValue": u,
271
- "exclude-binding-id": n.value,
272
- rules: [d(Ve)(1)],
273
- readonly: s.readonly
274
- }, null, 8, ["id", "model-value", "exclude-binding-id", "rules", "readonly"])
275
- ], 64)) : j("", !0)
276
- ];
277
- }),
278
- _: 1
279
- });
280
- };
281
- }
282
- });
283
- function ue() {
284
- return {
285
- low: 6,
286
- mid: 14
287
- };
288
- }
289
- const Xt = {
290
- key: 0,
291
- class: "flex flex-col gap-4"
292
- }, fe = /* @__PURE__ */ se({
293
- __name: "FmLockableField",
294
- props: {
295
- locked: { type: Boolean },
296
- disabled: { type: Boolean },
297
- label: {},
298
- helperText: {},
299
- modelValue: {},
300
- tooltipMessage: {},
301
- tooltipPlacement: {},
302
- tooltipZIndex: {}
303
- },
304
- setup(i) {
305
- return (o, y) => {
306
- const l = w("FmLabel"), n = w("FmIcon"), a = w("FmTooltip"), r = w("FmField");
307
- return o.locked ? (h(), B("div", Xt, [
308
- ve(o.$slots, "label", {}, () => [
309
- p(l, {
310
- label: o.label,
311
- disabled: o.disabled
312
- }, null, 8, ["label", "disabled"])
313
- ]),
314
- ve(o.$slots, "field", {}, () => [
315
- p(r, { disabled: o.disabled }, {
316
- prepend: V(() => [
317
- o.tooltipMessage ? (h(), T(a, {
318
- key: 0,
319
- placement: o.tooltipPlacement,
320
- "z-index": o.tooltipZIndex
321
- }, {
322
- content: V(() => [
323
- Re(D(o.tooltipMessage), 1)
324
- ]),
325
- default: V(() => [
326
- p(n, {
327
- name: "lock",
328
- color: "neutral-gray-400"
329
- })
330
- ]),
331
- _: 1
332
- }, 8, ["placement", "z-index"])) : (h(), T(n, {
333
- key: 1,
334
- name: "lock",
335
- color: "neutral-gray-400"
336
- }))
337
- ]),
338
- default: V(() => [
339
- ve(o.$slots, "modelValue", {}, () => [
340
- c("div", {
341
- class: J([
342
- o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary",
343
- "line-clamp-1 text-ellipsis break-all"
344
- ])
345
- }, D(o.modelValue), 3)
346
- ])
347
- ]),
348
- _: 3
349
- }, 8, ["disabled"])
350
- ]),
351
- ve(o.$slots, "helper-text", {}, () => [
352
- c("div", {
353
- class: J([
354
- "fm-typo-en-body-sm-400 line-clamp-1",
355
- o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
356
- ])
357
- }, D(o.helperText), 3)
358
- ])
359
- ])) : ve(o.$slots, "default", { key: 1 });
360
- };
361
- }
362
- }), en = { class: "flex gap-8" }, tn = { class: "flex-1" }, nn = { class: "flex-1" }, on = { class: "flex flex-col gap-5" }, ln = { class: "text-fm-color-typo-secondary" }, an = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, sn = {
363
- key: 3,
364
- class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
365
- }, rn = { class: "flex flex-col" }, un = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, dn = {
366
- key: 4,
367
- class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
368
- }, mn = { class: "flex flex-col gap-12" }, cn = { class: "flex flex-col gap-4" }, pn = { class: "fm-typo-en-title-sm-600" }, vn = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, fn = { class: "flex flex-col gap-4" }, yn = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, gn = { class: "flex-1 p-12 flex flex-col gap-8" }, bn = { class: "mx-auto" }, hn = { class: "flex flex-col" }, _n = { class: "fm-typo-en-body-sm-600 translate-y-4" }, xn = { class: "flex-1 p-12 flex flex-col gap-8" }, kn = { class: "mx-auto" }, Vn = { class: "flex flex-col" }, Sn = { class: "fm-typo-en-body-sm-600 translate-y-4" }, Fn = { class: "flex-1 p-12 flex flex-col gap-8" }, wn = { class: "mx-auto" }, Cn = { class: "flex flex-col" }, Mn = { class: "fm-typo-en-body-sm-600 translate-y-4" }, In = /* @__PURE__ */ se({
369
- __name: "IngredientForm",
370
- props: /* @__PURE__ */ Oe({
371
- mode: {},
372
- modelValue: {},
373
- disabled: { type: Boolean }
374
- }, {
375
- search: {},
376
- searchModifiers: {}
377
- }),
378
- emits: /* @__PURE__ */ Oe(["update:modelValue", "click:submit"], ["update:search"]),
379
- setup(i, { expose: o, emit: y }) {
380
- var ae;
381
- const { t: l } = re(), n = i, a = y, r = ee(), m = be(), v = at(), g = Ae(), u = S(() => g.isEnabled);
382
- function b(t) {
383
- if (t.length === 0) return;
384
- const e = t[0], f = n.modelValue ?? {
385
- unit: r.units.find((k) => k)
386
- };
387
- f.unit || (f.unit = e, a("update:modelValue", f));
388
- }
389
- ft(() => {
390
- b(r.units);
391
- }), et([() => r.units], ([t]) => {
392
- b(t);
393
- });
394
- function s() {
395
- a("click:submit");
396
- }
397
- const _ = S({
398
- get() {
399
- var t;
400
- return ((t = n.modelValue) == null ? void 0 : t.code) ?? "";
401
- },
402
- set(t) {
403
- const e = n.modelValue ? {
404
- ...n.modelValue
405
- } : {};
406
- e.code = t, a("update:modelValue", e);
407
- }
408
- }), N = S({
409
- get() {
410
- var t;
411
- return ((t = n.modelValue) == null ? void 0 : t.isInactive) ?? !1;
412
- },
413
- set(t) {
414
- const e = n.modelValue ? {
415
- ...n.modelValue
416
- } : {};
417
- e.isInactive = t, a("update:modelValue", e);
418
- }
419
- }), E = S({
420
- get() {
421
- var t;
422
- return ((t = n.modelValue) == null ? void 0 : t.name) ?? "";
423
- },
424
- set(t) {
425
- const e = n.modelValue ? {
426
- ...n.modelValue
427
- } : {};
428
- e.name = t, a("update:modelValue", e);
429
- }
430
- }), z = S({
431
- get() {
432
- var e, f;
433
- const t = (f = (e = n.modelValue) == null ? void 0 : e.defaultCost) == null ? void 0 : f.costPerUnit;
434
- return t ? +ot(t) : 0;
435
- },
436
- set(t) {
437
- var f, k, R, M;
438
- const e = n.modelValue ? {
439
- ...n.modelValue
440
- } : {};
441
- e.defaultCost ?? (e.defaultCost = {
442
- costPerUnit: {
443
- amount: 0,
444
- precision: 2,
445
- currency: ((f = Se(m.currentCountry.value)) == null ? void 0 : f.currency) ?? "MYR"
446
- },
447
- measurement: (M = (R = (k = n.modelValue) == null ? void 0 : k.unit) == null ? void 0 : R.measurements) == null ? void 0 : M.find(
448
- (G) => {
449
- var K;
450
- return G.id === ((K = n.modelValue) == null ? void 0 : K.trackingMeasurement);
451
- }
452
- )
453
- }), e.defaultCost.costPerUnit = {
454
- ...e.defaultCost.costPerUnit,
455
- ...lt(+t, 4)
456
- }, a("update:modelValue", e);
457
- }
458
- }), x = S(() => {
459
- var e, f, k;
460
- const t = ((e = n.modelValue) == null ? void 0 : e.unit) ?? r.units.find((R) => R);
461
- return t ? {
462
- _id: t._id,
463
- measurement: (f = n.modelValue) == null ? void 0 : f.trackingMeasurement,
464
- name: ((k = t.measurements.find((R) => {
465
- var M;
466
- return R.id === ((M = n.modelValue) == null ? void 0 : M.trackingMeasurement);
467
- })) == null ? void 0 : k.name) ?? t.name
468
- } : null;
469
- }), $ = S(
470
- () => r.units.flatMap(({ name: t, _id: e, abbrev: f, measurements: k }) => [
471
- {
472
- label: `${t}`,
473
- value: null,
474
- displayAsSection: !0
475
- },
476
- {
477
- label: `${t} (${f})`,
478
- value: { _id: e },
479
- displayAsSection: !1
480
- },
481
- ...k.map(({ id: R, name: M, abbrev: G }) => ({
482
- label: `${M} (${G})`,
483
- value: { _id: e, measurement: R },
484
- displayAsSection: !1
485
- }))
486
- ])
487
- ), C = yt(i, "search"), te = S(
488
- () => new kt($.value, ["label", "value"], {
489
- caseSensitive: !1,
490
- sort: !0
491
- })
492
- ), ne = S(() => te.value.search(C.value));
493
- function W(t) {
494
- var e, f, k, R, M;
495
- return ((f = (e = n.modelValue) == null ? void 0 : e.unit) == null ? void 0 : f._id) === ((k = t.value) == null ? void 0 : k._id) && ((R = n.modelValue) == null ? void 0 : R.trackingMeasurement) === ((M = t.value) == null ? void 0 : M.measurement);
496
- }
497
- function we(t) {
498
- var G, K;
499
- if (!t) return;
500
- const { _id: e, measurement: f } = t, k = f || void 0, R = r.units.find((pe) => pe._id === e);
501
- if (!R)
502
- return;
503
- const M = n.modelValue ?? {};
504
- M.unit = R, M.trackingMeasurement = k, M.convert && (M.convert.measurement = k || null), v.enableTotalCost && (M.defaultCost = {
505
- measurement: R.measurements.find((pe) => pe.id === k),
506
- costPerUnit: {
507
- ...((G = M.defaultCost) == null ? void 0 : G.costPerUnit) ?? {
508
- amount: 0,
509
- precision: 2,
510
- currency: ((K = Se(m.currentCountry.value)) == null ? void 0 : K.currency) ?? "MYR"
511
- }
512
- }
513
- }), a("update:modelValue", M);
514
- }
515
- const oe = S({
516
- get() {
517
- var t;
518
- return ((t = n.modelValue) == null ? void 0 : t.convert) ?? null;
519
- },
520
- set(t) {
521
- const e = n.modelValue ? {
522
- ...n.modelValue
523
- } : {};
524
- t ? e.convert = t : e.convert = null, a("update:modelValue", e);
525
- }
526
- }), Ce = S(() => ge.options.filter(
527
- (t) => t === ge.enum.FIFO || t === ge.enum.WAVG
528
- ).map((t) => ({
529
- label: l(`inventory.ingredient.valuationMethod.${t}`),
530
- value: t
531
- }))), de = S({
532
- get() {
533
- var t;
534
- return ((t = n.modelValue) == null ? void 0 : t.valuation) ?? "WAVG";
535
- },
536
- set(t) {
537
- const e = n.modelValue ? {
538
- ...n.modelValue
539
- } : {};
540
- e.valuation = t, a("update:modelValue", e);
541
- }
542
- }), he = S({
543
- get() {
544
- var t;
545
- return ((t = n.modelValue) == null ? void 0 : t.customAttributes) ?? {};
546
- },
547
- set(t) {
548
- const e = n.modelValue ? {
549
- ...n.modelValue
550
- } : {};
551
- e.customAttributes = t, a("update:modelValue", e);
552
- }
553
- }), le = H();
554
- o({
555
- validateInputs: () => {
556
- var t, e;
557
- (e = (t = le.value) == null ? void 0 : t.validateInputs) == null || e.call(t);
558
- },
559
- resetInputsValidation: () => {
560
- var t, e;
561
- (e = (t = le.value) == null ? void 0 : t.resetInputsValidation) == null || e.call(t);
562
- },
563
- resetInputs: () => {
564
- var t, e;
565
- (e = (t = le.value) == null ? void 0 : t.resetInputs) == null || e.call(t);
566
- }
567
- });
568
- const Z = H(!1), _e = S(
569
- () => {
570
- var t, e, f;
571
- return (t = n.modelValue) != null && t._id ? ((f = r.menu.bindedBySkuId[(e = n.modelValue) == null ? void 0 : e._id]) == null ? void 0 : f.filter(
572
- (k) => k.from === "INGREDIENT"
573
- )) ?? [] : [];
574
- }
575
- ), U = S(
576
- () => {
577
- var t, e, f;
578
- return (t = n.modelValue) != null && t._id ? ((f = r.menu.bindedBySkuId[(e = n.modelValue) == null ? void 0 : e._id]) == null ? void 0 : f.filter(
579
- (k) => k.from === "RECIPE"
580
- )) ?? [] : [];
581
- }
582
- ), F = S(
583
- () => {
584
- var t, e, f;
585
- return (t = n.modelValue) != null && t._id ? ((f = r.menu.bindedBySkuId[(e = n.modelValue) == null ? void 0 : e._id]) == null ? void 0 : f.filter((k) => k.from === "MENU")) ?? [] : [];
586
- }
587
- ), me = S(
588
- () => r.skus.map((t) => ({ label: t.name, value: t.code }))
589
- ), ie = H((ae = n.modelValue) == null ? void 0 : ae.code);
590
- function ce(t) {
591
- var f;
592
- const e = t.el;
593
- e && ((f = e.querySelector("[x-should-scroll-into=true]")) == null || f.scrollIntoView());
594
- }
595
- const L = S(
596
- () => {
597
- var t, e, f, k, R, M;
598
- return ((k = (f = (e = (t = n.modelValue) == null ? void 0 : t.unit) == null ? void 0 : e.measurements) == null ? void 0 : f.find(
599
- (G) => {
600
- var K;
601
- return G.id === ((K = n.modelValue) == null ? void 0 : K.trackingMeasurement);
602
- }
603
- )) == null ? void 0 : k.abbrev) ?? ((M = (R = n.modelValue) == null ? void 0 : R.unit) == null ? void 0 : M.abbrev);
604
- }
605
- ), A = S({
606
- get() {
607
- var t, e;
608
- return ((e = (t = n.modelValue) == null ? void 0 : t.thresholds) == null ? void 0 : e.low) ?? ue().low;
609
- },
610
- set(t) {
611
- var k;
612
- const e = ((k = n.modelValue) == null ? void 0 : k.thresholds) ?? ue();
613
- e.low = t;
614
- const f = n.modelValue ? {
615
- ...n.modelValue
616
- } : {};
617
- f.thresholds = e, a("update:modelValue", f);
618
- }
619
- }), P = S({
620
- get() {
621
- var t, e;
622
- return ((e = (t = n.modelValue) == null ? void 0 : t.thresholds) == null ? void 0 : e.mid) ?? ue().mid;
623
- },
624
- set(t) {
625
- var k;
626
- const e = ((k = n.modelValue) == null ? void 0 : k.thresholds) ?? ue();
627
- e.mid = t;
628
- const f = n.modelValue ? {
629
- ...n.modelValue
630
- } : {};
631
- f.thresholds = e, a("update:modelValue", f);
632
- }
633
- });
634
- function O() {
635
- return function(e) {
636
- return typeof (e == null ? void 0 : e.low) != "number" || typeof (e == null ? void 0 : e.mid) != "number" ? "Required" : e.low >= e.mid ? "Days for red indicator should be less than yellow indicator." : !0;
637
- };
638
- }
639
- return (t, e) => {
640
- const f = w("FmTextField"), k = w("FmLabel"), R = w("FmField"), M = w("FmIcon"), G = w("FmMenuHeader"), K = w("FmMenuDivider"), pe = w("FmMenuItem"), mt = w("FmMenu"), Te = w("FmFormGroup"), ct = w("FmSelect"), De = w("FmSwitch"), Be = w("FmStepperField"), pt = w("FmForm");
641
- return h(), T(pt, {
642
- disabled: t.disabled,
643
- ref_key: "formRef",
644
- ref: le,
645
- class: "flex flex-col gap-32",
646
- onValidationSuccess: s
647
- }, {
648
- default: V(() => {
649
- var Pe, Ne, ze, Le;
650
- return [
651
- c("div", en, [
652
- c("div", tn, [
653
- p(fe, {
654
- "tooltip-message": "This field is managed by NetSuite",
655
- "tooltip-z-index": 50,
656
- label: d(l)("inventory.ingredient.code"),
657
- "model-value": _.value,
658
- "onUpdate:modelValue": e[1] || (e[1] = (I) => _.value = I),
659
- locked: u.value,
660
- disabled: t.disabled
661
- }, {
662
- default: V(() => [
663
- p(f, {
664
- label: d(l)("inventory.ingredient.code"),
665
- "model-value": _.value,
666
- "onUpdate:modelValue": e[0] || (e[0] = (I) => _.value = I),
667
- rules: [d(Me)(), d(Vt)(me.value, ie.value)],
668
- "label-mark": "required"
669
- }, null, 8, ["label", "model-value", "rules"])
670
- ]),
671
- _: 1
672
- }, 8, ["label", "model-value", "locked", "disabled"])
673
- ]),
674
- c("div", nn, [
675
- p(fe, {
676
- "tooltip-message": "This field is managed by NetSuite",
677
- "tooltip-z-index": 50,
678
- label: d(l)("inventory.ingredient.name"),
679
- "model-value": E.value,
680
- "onUpdate:modelValue": e[3] || (e[3] = (I) => E.value = I),
681
- locked: u.value,
682
- disabled: t.disabled
683
- }, {
684
- default: V(() => [
685
- p(f, {
686
- label: d(l)("inventory.ingredient.name"),
687
- "model-value": E.value,
688
- "onUpdate:modelValue": e[2] || (e[2] = (I) => E.value = I),
689
- rules: [d(Me)()],
690
- "label-mark": "required"
691
- }, null, 8, ["label", "model-value", "rules"])
692
- ]),
693
- _: 1
694
- }, 8, ["label", "model-value", "locked", "disabled"])
695
- ])
696
- ]),
697
- p(fe, {
698
- "tooltip-message": "This field is managed by NetSuite",
699
- "tooltip-z-index": 50,
700
- label: d(l)("inventory.ingredient.unit"),
701
- "helper-text": (Pe = t.modelValue) != null && Pe.trackingMeasurement ? `Base unit: ${(ze = (Ne = t.modelValue) == null ? void 0 : Ne.unit) == null ? void 0 : ze.name}` : void 0,
702
- "model-value": (Le = x.value) == null ? void 0 : Le.name,
703
- locked: u.value,
704
- disabled: t.disabled
705
- }, {
706
- default: V(() => [
707
- p(Te, {
708
- "model-value": x.value,
709
- rules: [d(Me)()],
710
- "label-mark": "required"
711
- }, {
712
- label: V(() => [
713
- p(k, {
714
- label: d(l)("inventory.ingredient.unit")
715
- }, null, 8, ["label"])
716
- ]),
717
- default: V(({ invalid: I }) => [
718
- p(mt, null, {
719
- "menu-button": V(() => [
720
- p(R, {
721
- class: J([
722
- "fm-typo-en-body-lg-400",
723
- {
724
- "text-fm-color-typo-primary": !t.disabled,
725
- "text-fm-color-typo-disabled": t.disabled
726
- }
727
- ]),
728
- invalid: I,
729
- "append-icon": "expand_more"
730
- }, {
731
- default: V(() => {
732
- var Y;
733
- return [
734
- Re(D((Y = x.value) == null ? void 0 : Y.name), 1)
735
- ];
736
- }),
737
- _: 2
738
- }, 1032, ["class", "invalid"])
739
- ]),
740
- default: V(() => [
741
- c("div", on, [
742
- p(f, {
743
- modelValue: C.value,
744
- "onUpdate:modelValue": e[4] || (e[4] = (Y) => C.value = Y),
745
- placeholder: "Filter options"
746
- }, {
747
- prepend: V(() => [
748
- p(M, { name: "search" })
749
- ]),
750
- _: 1
751
- }, 8, ["modelValue"]),
752
- c("div", {
753
- class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
754
- onVnodeMounted: ce
755
- }, [
756
- (h(!0), B(X, null, ye(ne.value, (Y, vt) => (h(), B(X, { key: vt }, [
757
- Y.displayAsSection ? (h(), B(X, { key: 0 }, [
758
- p(G, {
759
- label: Y.label
760
- }, null, 8, ["label"]),
761
- p(K)
762
- ], 64)) : (h(), T(pe, {
763
- key: 1,
764
- label: Y.label,
765
- "model-value": W(Y),
766
- onClick: (ao) => we(Y.value),
767
- "x-should-scroll-into": `${W(Y)}`
768
- }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
769
- ], 64))), 128))
770
- ], 512)
771
- ])
772
- ]),
773
- _: 2
774
- }, 1024)
775
- ]),
776
- _: 1
777
- }, 8, ["model-value", "rules"])
778
- ]),
779
- _: 1
780
- }, 8, ["label", "helper-text", "model-value", "locked", "disabled"]),
781
- d(v).enableTotalCost ? (h(), T(fe, {
782
- key: 0,
783
- "tooltip-message": "This field is managed by NetSuite",
784
- "tooltip-z-index": 50,
785
- label: d(l)("inventory.ingredient.valuationMethod.title"),
786
- "model-value": d(l)("inventory.ingredient.valuationMethod." + de.value),
787
- locked: u.value,
788
- disabled: t.disabled
789
- }, {
790
- label: V(() => [
791
- p(ke, { "z-index": 50 }, {
792
- default: V(() => [
793
- p(k, {
794
- label: d(l)("inventory.ingredient.valuationMethod.title")
795
- }, null, 8, ["label"])
796
- ]),
797
- _: 1
798
- })
799
- ]),
800
- default: V(() => [
801
- p(ct, {
802
- class: "col-span-2",
803
- label: d(l)("inventory.ingredient.valuationMethod.title"),
804
- "model-value": de.value,
805
- "onUpdate:modelValue": e[5] || (e[5] = (I) => de.value = I),
806
- items: Ce.value
807
- }, null, 8, ["label", "model-value", "items"])
808
- ]),
809
- _: 1
810
- }, 8, ["label", "model-value", "locked", "disabled"])) : j("", !0),
811
- d(v).enableTotalCost ? (h(), T(fe, {
812
- key: 1,
813
- "tooltip-message": "This field is managed by NetSuite",
814
- "tooltip-z-index": 50,
815
- "model-value": `${d(St)()} ${z.value}`,
816
- locked: u.value,
817
- disabled: t.disabled
818
- }, {
819
- label: V(() => [
820
- p(ke, { "z-index": 50 }, {
821
- default: V(() => [
822
- p(k, {
823
- label: d(l)("inventory.ingredient.pricePerUnit")
824
- }, null, 8, ["label"])
825
- ]),
826
- _: 1
827
- })
828
- ]),
829
- default: V(() => [
830
- p(f, {
831
- "model-value": z.value,
832
- "onUpdate:modelValue": e[6] || (e[6] = (I) => z.value = I),
833
- rules: [d(Ve)(0), d(Ft)(4)]
834
- }, {
835
- label: V(() => [
836
- p(ke, { "z-index": 50 }, {
837
- default: V(() => [
838
- p(k, {
839
- label: d(l)("inventory.ingredient.pricePerUnit")
840
- }, null, 8, ["label"])
841
- ]),
842
- _: 1
843
- })
844
- ]),
845
- prepend: V(() => {
846
- var I, Y;
847
- return [
848
- c("div", ln, D(d(qe)(((I = d(m).currentCountry) == null ? void 0 : I.value) ?? d(Ge)) === "MYR" ? "RM" : d(qe)(((Y = d(m).currentCountry) == null ? void 0 : Y.value) ?? d(Ge))), 1)
849
- ];
850
- }),
851
- append: V(() => [
852
- c("div", an, " / " + D(L.value), 1)
853
- ]),
854
- _: 1
855
- }, 8, ["model-value", "rules"])
856
- ]),
857
- _: 1
858
- }, 8, ["model-value", "locked", "disabled"])) : j("", !0),
859
- !u.value || oe.value ? (h(), T(Qt, {
860
- key: 2,
861
- "model-value": oe.value,
862
- "onUpdate:modelValue": e[7] || (e[7] = (I) => oe.value = I),
863
- "root-value": t.modelValue,
864
- readonly: u.value
865
- }, null, 8, ["model-value", "root-value", "readonly"])) : j("", !0),
866
- t.mode !== d(q).CREATE ? (h(), B("div", sn, [
867
- p(De, {
868
- label: d(l)("inventory.ingredient.isInactive.title"),
869
- "model-value": N.value,
870
- "onUpdate:modelValue": e[8] || (e[8] = (I) => N.value = I),
871
- "label-placement": "right",
872
- disabled: u.value
873
- }, null, 8, ["label", "model-value", "disabled"]),
874
- c("div", rn, [
875
- c("div", un, D(d(l)("inventory.ingredient.isInactive.preventFromOrder")), 1)
876
- ])
877
- ])) : j("", !0),
878
- t.mode !== d(q).CREATE ? (h(), B("div", dn, [
879
- c("div", null, [
880
- p(De, {
881
- label: d(l)("inventory.ingredient.bindedItems.title"),
882
- modelValue: Z.value,
883
- "onUpdate:modelValue": e[9] || (e[9] = (I) => Z.value = I),
884
- "label-placement": "right"
885
- }, null, 8, ["label", "modelValue"])
886
- ]),
887
- Z.value && _e.value.length ? (h(), T(Ee, {
888
- key: 0,
889
- name: d(l)("inventory.ingredient.bindedItems.ingredient"),
890
- bindings: _e.value
891
- }, null, 8, ["name", "bindings"])) : j("", !0),
892
- Z.value && U.value.length ? (h(), T(Ee, {
893
- key: 1,
894
- name: d(l)("inventory.ingredient.bindedItems.recipe"),
895
- bindings: U.value
896
- }, null, 8, ["name", "bindings"])) : j("", !0),
897
- Z.value && F.value.length ? (h(), T(Ee, {
898
- key: 2,
899
- name: d(l)("inventory.ingredient.bindedItems.menu"),
900
- bindings: F.value
901
- }, null, 8, ["name", "bindings"])) : j("", !0)
902
- ])) : j("", !0),
903
- c("div", mn, [
904
- c("div", cn, [
905
- p(ke, null, {
906
- default: V(() => [
907
- c("div", pn, D(d(l)("inventory.ingredient.threshold.title")), 1)
908
- ]),
909
- _: 1
910
- }),
911
- c("div", vn, D(d(l)("inventory.ingredient.threshold.subtitle")), 1)
912
- ]),
913
- c("div", fn, [
914
- p(Te, {
915
- "model-value": { low: A.value, mid: P.value },
916
- rules: [O()]
917
- }, null, 8, ["model-value", "rules"]),
918
- c("div", yn, [
919
- c("div", gn, [
920
- c("div", bn, [
921
- p(Ie, {
922
- days: A.value,
923
- level: d($e).low
924
- }, null, 8, ["days", "level"])
925
- ]),
926
- c("div", hn, [
927
- c("div", _n, D(d(l)("inventory.ingredient.threshold.whenRemaining")), 1),
928
- p(Be, {
929
- modelValue: A.value,
930
- "onUpdate:modelValue": e[10] || (e[10] = (I) => A.value = I),
931
- rules: [d(Ve)(0)]
932
- }, {
933
- append: V(() => e[13] || (e[13] = [
934
- c("div", {
935
- class: "text-fm-color-typo-secondary",
936
- style: { "padding-right": "32px" }
937
- }, "days", -1)
938
- ])),
939
- _: 1
940
- }, 8, ["modelValue", "rules"])
941
- ])
942
- ]),
943
- e[15] || (e[15] = c("div", {
944
- class: "h-full bg-fm-color-neutral-gray-200 relative",
945
- style: { width: "1px" }
946
- }, [
947
- c("div", {
948
- class: "absolute bg-white",
949
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
950
- }, " < ")
951
- ], -1)),
952
- c("div", xn, [
953
- c("div", kn, [
954
- p(Ie, {
955
- days: P.value,
956
- level: d($e).mid
957
- }, null, 8, ["days", "level"])
958
- ]),
959
- c("div", Vn, [
960
- c("div", Sn, D(d(l)("inventory.ingredient.threshold.whenRemaining")), 1),
961
- p(Be, {
962
- modelValue: P.value,
963
- "onUpdate:modelValue": e[11] || (e[11] = (I) => P.value = I),
964
- rules: [d(Ve)(0)]
965
- }, {
966
- append: V(() => e[14] || (e[14] = [
967
- c("div", {
968
- class: "text-fm-color-typo-secondary",
969
- style: { "padding-right": "32px" }
970
- }, "days", -1)
971
- ])),
972
- _: 1
973
- }, 8, ["modelValue", "rules"])
974
- ])
975
- ]),
976
- e[16] || (e[16] = c("div", {
977
- class: "h-full bg-fm-color-neutral-gray-200 relative",
978
- style: { width: "1px" }
979
- }, [
980
- c("div", {
981
- class: "absolute bg-white",
982
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
983
- }, " < ")
984
- ], -1)),
985
- c("div", Fn, [
986
- c("div", wn, [
987
- p(Ie, {
988
- days: P.value + 1,
989
- level: d($e).high
990
- }, null, 8, ["days", "level"])
991
- ]),
992
- c("div", Cn, [
993
- c("div", Mn, D(d(l)("inventory.ingredient.threshold.stockIsStaple")), 1)
994
- ])
995
- ])
996
- ])
997
- ])
998
- ]),
999
- c("div", null, [
1000
- p(Wt, {
1001
- entity: "inventorySku",
1002
- modelValue: he.value,
1003
- "onUpdate:modelValue": e[12] || (e[12] = (I) => he.value = I)
1004
- }, null, 8, ["modelValue"])
1005
- ])
1006
- ];
1007
- }),
1008
- _: 1
1009
- }, 8, ["disabled"]);
1010
- };
1011
- }
1012
- }), $n = { class: "flex flex-col gap-32" }, En = { class: "flex gap-4" }, Un = /* @__PURE__ */ se({
1013
- __name: "IngredientDialog",
1014
- props: {
1015
- show: { type: Boolean },
1016
- unit: {},
1017
- mode: { default: q.READ }
1018
- },
1019
- emits: ["update:show"],
1020
- setup(i) {
1021
- const o = i, y = ee(), l = Ae(), n = Fe(), { t: a } = re(), r = Ze(o, "show"), m = Ze(o, "unit"), v = S(
1022
- () => {
1023
- var x;
1024
- return l.isEnabled && l.netSuiteItemBySkuId.has((x = o.unit) == null ? void 0 : x._id);
1025
- }
1026
- ), g = S(() => {
1027
- switch (o.mode) {
1028
- case q.READ:
1029
- return "";
1030
- case q.UPDATE:
1031
- return a("inventory.ingredient.update.title");
1032
- case q.CREATE:
1033
- return a("inventory.ingredient.create.title");
1034
- }
1035
- return "";
1036
- }), u = S(() => {
1037
- switch (o.mode) {
1038
- case q.READ:
1039
- return "";
1040
- case q.UPDATE:
1041
- return a("common.save");
1042
- case q.CREATE:
1043
- return a("common.add");
1044
- }
1045
- return "";
1046
- }), b = H(), s = H(!1);
1047
- async function _() {
1048
- s.value = !0;
1049
- try {
1050
- await y.createSku(m.value), r.value = !1, n.open({
1051
- title: a("inventory.common.success"),
1052
- message: a("inventory.ingredient.create.success", { name: m.value.name }),
1053
- type: "success"
1054
- });
1055
- } catch (x) {
1056
- x instanceof We || n.open({
1057
- title: a("inventory.ingredient.create.error.title"),
1058
- message: a("inventory.ingredient.create.error.message"),
1059
- type: "error"
1060
- });
1061
- } finally {
1062
- s.value = !1;
1063
- }
1064
- }
1065
- async function N() {
1066
- s.value = !0;
1067
- try {
1068
- await y.updateSku(m.value), s.value = !1, r.value = !1, n.open({
1069
- title: a("inventory.common.success"),
1070
- message: a("inventory.ingredient.update.success", { name: m.value.name }),
1071
- type: "success"
1072
- });
1073
- } catch (x) {
1074
- x instanceof We || n.open({
1075
- title: a("inventory.ingredient.update.error.title"),
1076
- message: a("inventory.ingredient.update.error.message"),
1077
- type: "error"
1078
- });
1079
- } finally {
1080
- s.value = !1;
1081
- }
1082
- }
1083
- function E() {
1084
- var x, $;
1085
- ($ = (x = b.value) == null ? void 0 : x.validateInputs) == null || $.call(x);
1086
- }
1087
- function z() {
1088
- switch (o.mode) {
1089
- case q.READ:
1090
- return;
1091
- case q.UPDATE:
1092
- return N();
1093
- case q.CREATE:
1094
- return _();
1095
- }
1096
- }
1097
- return (x, $) => {
1098
- const C = w("FmChip"), te = w("FmButton"), ne = w("FmSideSheet");
1099
- return h(), T(ne, {
1100
- "model-value": d(r),
1101
- "onUpdate:modelValue": $[3] || ($[3] = (W) => He(r) ? r.value = W : null),
1102
- header: g.value,
1103
- "close-button": "",
1104
- "dismiss-away": "",
1105
- "max-width": 500
1106
- }, {
1107
- "side-sheet-footer": V(() => [
1108
- c("div", En, [
1109
- p(te, {
1110
- loading: s.value,
1111
- label: u.value,
1112
- onClick: E
1113
- }, null, 8, ["loading", "label"]),
1114
- p(te, {
1115
- disabled: s.value,
1116
- label: d(a)("common.close"),
1117
- variant: "tertiary",
1118
- onClick: $[2] || ($[2] = (W) => r.value = !1)
1119
- }, null, 8, ["disabled", "label"])
1120
- ])
1121
- ]),
1122
- default: V(() => [
1123
- c("div", $n, [
1124
- c("div", null, [
1125
- v.value ? (h(), T(C, {
1126
- key: 0,
1127
- label: "Managed by Netsuite",
1128
- compact: ""
1129
- })) : j("", !0)
1130
- ]),
1131
- p(In, {
1132
- class: "w-full",
1133
- ref_key: "hasValidationExpose",
1134
- ref: b,
1135
- modelValue: d(m),
1136
- "onUpdate:modelValue": $[0] || ($[0] = (W) => He(m) ? m.value = W : null),
1137
- mode: x.mode,
1138
- disabled: s.value,
1139
- "onClick:submit": $[1] || ($[1] = (W) => z())
1140
- }, null, 8, ["modelValue", "mode", "disabled"])
1141
- ])
1142
- ]),
1143
- _: 1
1144
- }, 8, ["model-value", "header"]);
1145
- };
1146
- }
1147
- });
1148
- function Rn() {
1149
- return `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Kt()}`;
1150
- }
1151
- const An = {
1152
- _id: "",
1153
- name: "",
1154
- abbrev: "",
1155
- precision: 0,
1156
- measurements: []
1157
- };
1158
- function Tn(i) {
1159
- return !i || Object.keys(i).length === 0 ? "" : Object.entries(i).map(([o, y]) => `${o}: ${y}`).join(", ");
1160
- }
1161
- function ut(i) {
1162
- if (!i || i.trim() === "")
1163
- return;
1164
- const o = {}, y = i.split(",").map((l) => l.trim());
1165
- for (const l of y) {
1166
- const n = l.indexOf(":");
1167
- if (n > 0) {
1168
- const a = l.substring(0, n).trim(), r = l.substring(n + 1).trim();
1169
- a && r && (o[a] = r);
1170
- }
1171
- }
1172
- return Object.keys(o).length > 0 ? o : void 0;
1173
- }
1174
- function Dn(i) {
1175
- var y, l, n, a, r;
1176
- return {
1177
- code: i.code,
1178
- name: i.name,
1179
- unit: ((y = i.unit.measurements.find((m) => m.id === i.trackingMeasurement)) == null ? void 0 : y.abbrev) ?? i.unit.abbrev,
1180
- baseUnit: i.unit.abbrev,
1181
- valuationMethod: i.valuation ?? "WAVG",
1182
- pricePerUnit: (l = i.defaultCost) != null && l.costPerUnit ? +ot((n = i.defaultCost) == null ? void 0 : n.costPerUnit) : 0,
1183
- thresholdLow: ((a = i.thresholds) == null ? void 0 : a.low) ?? ue().low,
1184
- thresholdMid: ((r = i.thresholds) == null ? void 0 : r.mid) ?? ue().mid,
1185
- customAttributes: Tn(i.customAttributes)
1186
- };
1187
- }
1188
- function dt() {
1189
- var n;
1190
- const i = [
1191
- {
1192
- id: "code",
1193
- name: "Code"
1194
- },
1195
- {
1196
- id: "name",
1197
- name: "Name"
1198
- },
1199
- {
1200
- id: "unit",
1201
- name: "Unit"
1202
- },
1203
- {
1204
- id: "baseUnit",
1205
- name: "Base unit"
1206
- }
1207
- ], o = at(), y = be(), l = Se(y.currentCountry.value);
1208
- return o.enableTotalCost && i.push(
1209
- {
1210
- id: "valuationMethod",
1211
- name: "Valuation method"
1212
- },
1213
- {
1214
- id: "pricePerUnit",
1215
- name: `Price per unit (${l == null ? void 0 : l.currency})`
1216
- }
1217
- ), ((n = y.currentBusiness.value) == null ? void 0 : n.menuVersion) === "v4" && i.push(
1218
- {
1219
- id: "thresholdLow",
1220
- name: "Show RED when remaining"
1221
- },
1222
- {
1223
- id: "thresholdMid",
1224
- name: "Show YELLOW when remaining"
1225
- }
1226
- ), i.push({
1227
- id: "customAttributes",
1228
- name: "Custom Attributes"
1229
- }), i;
1230
- }
1231
- function Bn() {
1232
- const o = ee().skus.map(Dn), l = be().currentBusiness.value, n = dt(), a = [
1233
- ["Business name:", l == null ? void 0 : l.name],
1234
- ["Business ID:", l == null ? void 0 : l._id],
1235
- ["Menu version", l == null ? void 0 : l.menuVersion],
1236
- [],
1237
- n.map((g) => g.name),
1238
- ...o.map((g) => n.map((u) => g[u.id]))
1239
- ], r = n.map((g) => `system:${g.id}`), m = st(a, r), v = `${l == null ? void 0 : l.name} ingredients (${wt(/* @__PURE__ */ new Date())}).xlsx`;
1240
- return rt(m, v), v;
1241
- }
1242
- function Pn() {
1243
- const o = be().currentBusiness.value, y = dt(), l = [
1244
- ["Business name:", o == null ? void 0 : o.name],
1245
- ["Business ID:", o == null ? void 0 : o._id],
1246
- ["Menu version", o == null ? void 0 : o.menuVersion],
1247
- [],
1248
- y.map((m) => m.name)
1249
- ], n = y.map((m) => `system:${m.id}`), a = st(l, n), r = "FeedMe ingredients template.xlsx";
1250
- return rt(a, r), r;
1251
- }
1252
- function Nn(i) {
1253
- const [
1254
- o,
1255
- y,
1256
- l,
1257
- n,
1258
- a,
1259
- r,
1260
- ...m
1261
- ] = Mt(i);
1262
- if (!o || !o.length || o.some((s) => s.length && !s.startsWith("system:")))
1263
- throw new Error("Missing meta header. Excel file does not come from the template.");
1264
- const v = o.map((s) => s.split(":")[1]), u = ["code", "name", "unit", "baseUnit"].filter((s) => !v.includes(s));
1265
- if (u.length)
1266
- throw new Error(
1267
- `Missing meta headers (${u.join()}). Excel file does not come from the template.`
1268
- );
1269
- return m.map((s, _) => {
1270
- const N = {};
1271
- for (const E in v) {
1272
- const z = v[E];
1273
- Object.assign(N, { [z]: s[E] });
1274
- }
1275
- return {
1276
- index: _,
1277
- data: N
1278
- };
1279
- });
1280
- }
1281
- function Qe(i, o, y) {
1282
- var $;
1283
- const n = ee().units, a = new Array(), r = y.filter((C) => C.data.code === i.code);
1284
- r.length > 1 && a.push(
1285
- `Code ${i.code} is already used in row ${r.map((C) => C.index + 6).join()}.`
1286
- );
1287
- const m = n.find((C) => C.abbrev === i.baseUnit), v = m == null ? void 0 : m.measurements.find((C) => C.abbrev === i.unit);
1288
- if (!m)
1289
- a.push(`Cannot find base unit of symbol ${i.baseUnit}.`);
1290
- else if (i.baseUnit !== i.unit && !v) {
1291
- const C = `Cannot find unit conversion for ${i.baseUnit} with symbol ${i.unit || "[empty]"}.`;
1292
- a.push(C);
1293
- }
1294
- const g = ge.options.find(
1295
- (C) => C === i.valuationMethod
1296
- );
1297
- i.valuationMethod && !g && a.push(
1298
- `Expected valuation method to be one of ${ge.options.join()} but got ${i.valuationMethod} instead.`
1299
- );
1300
- const b = be().currentCountry.value, s = (C) => `${C}`.length && It()(C) === !0, _ = s(`${i.pricePerUnit}`) === !0 ? {
1301
- costPerUnit: {
1302
- ...lt(Number(i.pricePerUnit) || 0),
1303
- currency: (($ = Se(b)) == null ? void 0 : $.currency) ?? "MYR"
1304
- },
1305
- measurement: v
1306
- } : void 0, N = s(`${i.thresholdLow}`) && s(`${i.thresholdMid}`) ? {
1307
- low: Number(i.thresholdLow) || 0,
1308
- mid: Number(i.thresholdMid) || 0
1309
- } : void 0, E = "customAttributes" in i ? ut(i.customAttributes) : null;
1310
- return {
1311
- type: "create",
1312
- sku: {
1313
- _id: Rn(),
1314
- code: i.code,
1315
- name: i.name,
1316
- unit: m ?? n.find((C) => C) ?? An,
1317
- trackingMeasurement: v == null ? void 0 : v.id,
1318
- valuation: g,
1319
- defaultCost: _,
1320
- thresholds: N,
1321
- ...E !== null && { customAttributes: E }
1322
- },
1323
- errors: a,
1324
- excelRowNumber: o + 6
1325
- };
1326
- }
1327
- function zn(i) {
1328
- try {
1329
- const o = Nn(i).filter((g) => g.data.code), l = ee().skus, n = Ct(l, "code"), a = o.filter((g) => !n[g.data.code]), r = o.filter((g) => n[g.data.code]), m = a.map(
1330
- (g) => Qe(g.data, g.index, o)
1331
- ), v = r.map((g) => {
1332
- const u = Qe(g.data, g.index, o), b = n[g.data.code];
1333
- let s = b.customAttributes;
1334
- return "customAttributes" in g.data && (s = ut(g.data.customAttributes)), {
1335
- ...u,
1336
- type: "update",
1337
- original: b,
1338
- sku: {
1339
- // to maintain original props not in the import excel, e.g. inventory binding, etc...
1340
- ...b,
1341
- code: u.sku.code || b.code,
1342
- name: u.sku.name || b.name,
1343
- unit: u.sku.unit || b.unit,
1344
- trackingMeasurement: u.sku.trackingMeasurement || b.trackingMeasurement,
1345
- valuation: u.sku.valuation || b.valuation,
1346
- defaultCost: u.sku.defaultCost || b.defaultCost,
1347
- thresholds: u.sku.thresholds || b.thresholds,
1348
- customAttributes: s
1349
- }
1350
- };
1351
- });
1352
- return {
1353
- invalidExcel: !1,
1354
- importCreateResult: m,
1355
- importUpdateResult: v
1356
- };
1357
- } catch (o) {
1358
- return {
1359
- invalidExcel: !0,
1360
- invalidExcelMessage: (o == null ? void 0 : o.message) ?? "Invalid excel",
1361
- importCreateResult: [],
1362
- importUpdateResult: []
1363
- };
1364
- }
1365
- }
1366
- const Ln = { class: "flex items-center gap-12 pl-8" }, On = { class: "flex flex-col" }, Hn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, jn = {
1367
- key: 0,
1368
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1369
- }, Yn = { key: 0 }, Xe = /* @__PURE__ */ se({
1370
- __name: "ImportIngredientItem",
1371
- props: {
1372
- type: {},
1373
- code: {},
1374
- name: {},
1375
- errors: {}
1376
- },
1377
- setup(i) {
1378
- return (o, y) => {
1379
- const l = w("FmIcon"), n = w("FmTooltip");
1380
- return h(), B("div", Ln, [
1381
- y[0] || (y[0] = c("div", null, "•", -1)),
1382
- c("div", On, [
1383
- c("div", Hn, [
1384
- c("div", {
1385
- class: J({
1386
- "text-fm-color-system-error-300": o.errors.length
1387
- })
1388
- }, [
1389
- Re(D(o.name) + " ", 1),
1390
- o.type === "create" ? (h(), B("span", jn, "(new)")) : j("", !0)
1391
- ], 2),
1392
- o.errors.length ? (h(), B("div", Yn, [
1393
- p(n, { "z-index": 50 }, {
1394
- content: V(() => [
1395
- c("ol", null, [
1396
- (h(!0), B(X, null, ye(o.errors, (a, r) => (h(), B("li", { key: r }, D(a), 1))), 128))
1397
- ])
1398
- ]),
1399
- default: V(() => [
1400
- p(l, {
1401
- name: "error",
1402
- size: "sm",
1403
- color: "system-error-300"
1404
- })
1405
- ]),
1406
- _: 1
1407
- })
1408
- ])) : j("", !0)
1409
- ]),
1410
- c("div", {
1411
- class: J([
1412
- "fm-typo-en-body-sm-400",
1413
- {
1414
- "text-fm-color-system-error-200": o.errors.length,
1415
- "text-fm-color-typo-secondary": !o.errors.length
1416
- }
1417
- ])
1418
- }, D(o.code), 3)
1419
- ])
1420
- ]);
1421
- };
1422
- }
1423
- }), qn = { class: "flex flex-col gap-24" }, Gn = { class: "fm-typo-en-body-md-400" }, Wn = { class: "flex flex-col gap-8" }, Kn = { class: "line-clamp-2 text-ellipsis break-all" }, Jn = {
1424
- key: 2,
1425
- class: "shrink-0"
1426
- }, Zn = {
1427
- key: 0,
1428
- class: "flex flex-col"
1429
- }, Qn = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Xn = {
1430
- key: 0,
1431
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1432
- }, eo = { class: "fm-typo-en-body-lg-600" }, to = /* @__PURE__ */ se({
1433
- __name: "ImportIngredients",
1434
- setup(i) {
1435
- const o = H(null), y = zt(), l = Fe(), n = H(!1), a = H(new Array()), r = H([]), m = H([]), v = S(
1436
- () => !!a.value.length || r.value.some((s) => s.errors.length) || m.value.some((s) => s.errors.length)
1437
- ), g = S(
1438
- () => !!r.value.length || !!m.value.length
1439
- ), { t: u } = re();
1440
- async function b(s) {
1441
- a.value = [], r.value = [], m.value = [];
1442
- try {
1443
- n.value = !0;
1444
- const [_] = await Promise.all([
1445
- Et(s),
1446
- // fake buffer
1447
- new Promise((z) => setTimeout(z, 1e3))
1448
- ]), N = _.SheetNames.find((z) => z);
1449
- if (!N) {
1450
- a.value.push(u("inventory.ingredient.import.fileError.noSheet"));
1451
- return;
1452
- }
1453
- const E = zn(_.Sheets[N]);
1454
- if (E.invalidExcel) {
1455
- a.value.push(E.invalidExcelMessage ?? u("inventory.ingredient.import.fileError.invalidExcel"));
1456
- return;
1457
- }
1458
- if (r.value = E.importCreateResult, m.value = E.importUpdateResult, !r.value.length && !m.value.length) {
1459
- a.value.push(u("inventory.ingredient.import.fileError.noData"));
1460
- return;
1461
- }
1462
- y.emitData(E);
1463
- } catch (_) {
1464
- l.open({
1465
- title: u("inventory.ingredient.import.fileError.unableToRead"),
1466
- message: _ == null ? void 0 : _.message,
1467
- type: "error"
1468
- }), console.error("Error in reading file", _);
1469
- } finally {
1470
- a.value.length && l.open({
1471
- title: u("inventory.ingredient.import.fileError.invalidExcel"),
1472
- type: "error"
1473
- }), n.value = !1;
1474
- }
1475
- }
1476
- return et(o, (s) => {
1477
- s && b(s);
1478
- }), (s, _) => {
1479
- const N = w("FmCircularProgress"), E = w("FmIcon"), z = w("FmButton");
1480
- return h(), B("div", qn, [
1481
- c("div", Gn, D(d(u)("inventory.ingredient.import.uploadDescription")), 1),
1482
- p($t, {
1483
- class: J({
1484
- "w-full": !0,
1485
- "h-[200px]": !o.value
1486
- }),
1487
- accept: ".xlsx",
1488
- onFileUpload: _[0] || (_[0] = (x) => o.value = x),
1489
- label: d(u)("inventory.ingredient.import.uploadTemplate"),
1490
- "button-label": d(u)("inventory.ingredient.import.selectFile")
1491
- }, tt({ _: 2 }, [
1492
- o.value ? {
1493
- name: "default",
1494
- fn: V(({ openFileDialog: x }) => [
1495
- c("div", Wn, [
1496
- c("div", {
1497
- class: J([
1498
- "fm-corner-radius-md p-16 flex items-center gap-16",
1499
- {
1500
- "border border-fm-color-neutral-gray-100": n.value,
1501
- "border border-fm-color-neutral-gray-200": !n.value && !v.value,
1502
- "border border-fm-color-system-error-200": v.value
1503
- }
1504
- ])
1505
- }, [
1506
- n.value ? (h(), T(N, {
1507
- key: 0,
1508
- size: "md",
1509
- color: "neutral-gray-200"
1510
- })) : (h(), T(E, {
1511
- key: 1,
1512
- name: v.value ? "error" : "attach_file",
1513
- outline: "",
1514
- color: v.value ? "system-error-300" : void 0
1515
- }, null, 8, ["name", "color"])),
1516
- c("div", {
1517
- class: J([
1518
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
1519
- {
1520
- "text-fm-color-typo-disabled": n.value,
1521
- "text-fm-color-typo-primary": !n.value
1522
- }
1523
- ])
1524
- }, [
1525
- c("div", Kn, D(o.value.name), 1)
1526
- ], 2),
1527
- n.value ? j("", !0) : (h(), B("div", Jn, [
1528
- p(z, {
1529
- label: d(u)("inventory.ingredient.import.replaceFile"),
1530
- variant: v.value ? "destructive" : "secondary",
1531
- "prepend-icon": v.value ? void 0 : "autorenew",
1532
- onClick: x
1533
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
1534
- ]))
1535
- ], 2),
1536
- a.value.length ? (h(), B("div", Zn, [
1537
- (h(!0), B(X, null, ye(a.value, ($, C) => (h(), B("div", {
1538
- key: C,
1539
- class: "flex gap-8 items-center"
1540
- }, [
1541
- p(E, {
1542
- name: "error",
1543
- size: "sm",
1544
- color: "system-error-300"
1545
- }),
1546
- c("div", Qn, D($), 1)
1547
- ]))), 128))
1548
- ])) : j("", !0)
1549
- ])
1550
- ]),
1551
- key: "0"
1552
- } : void 0
1553
- ]), 1032, ["class", "label", "button-label"]),
1554
- g.value ? (h(), B("div", Xn, [
1555
- c("div", eo, D(d(u)("inventory.ingredient.import.summary")), 1),
1556
- (h(!0), B(X, null, ye(r.value, (x) => (h(), T(Xe, {
1557
- key: x.sku._id,
1558
- code: x.sku.code,
1559
- name: x.sku.name,
1560
- errors: x.errors,
1561
- type: "create"
1562
- }, null, 8, ["code", "name", "errors"]))), 128)),
1563
- (h(!0), B(X, null, ye(m.value, (x) => (h(), T(Xe, {
1564
- key: x.sku._id,
1565
- code: x.sku.code,
1566
- name: x.sku.name,
1567
- errors: x.errors,
1568
- type: "update"
1569
- }, null, 8, ["code", "name", "errors"]))), 128))
1570
- ])) : j("", !0)
1571
- ]);
1572
- };
1573
- }
1574
- }), no = { class: "flex flex-col py-8" }, oo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, lo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, xo = /* @__PURE__ */ se({
1575
- __name: "IngredientsView",
1576
- setup(i) {
1577
- const o = ee(), y = S(() => [
1578
- {
1579
- type: "string",
1580
- key: "skuCode",
1581
- entity: "sku",
1582
- values: o.skus.map((F) => F.code)
1583
- },
1584
- {
1585
- type: "string",
1586
- key: "skuUnitAbbrev",
1587
- entity: "sku",
1588
- values: o.units.map((F) => F.abbrev)
1589
- },
1590
- {
1591
- type: "string",
1592
- key: "skuInactive",
1593
- entity: "sku",
1594
- values: ["Yes", "No"]
1595
- }
1596
- ]), l = H(null), n = S(() => {
1597
- if (!l.value)
1598
- return o.skus;
1599
- const U = Ut.build(l.value);
1600
- return o.skus.filter((F) => Rt(
1601
- {
1602
- skuCode: F.code,
1603
- skuUnitAbbrev: F.unit.abbrev,
1604
- skuInactive: F.isInactive ? "Yes" : "No"
1605
- },
1606
- U
1607
- ));
1608
- }), a = At(), r = it(), m = Jt(), v = Fe(), g = Ae(), { t: u } = re(), { createIngredient: b, updateIngredient: s } = Ue(), { ingredientDialogProps: _, ingredientViewLoading: N } = Yt(Ue()), { columnDefs: E } = Zt();
1609
- function z(U) {
1610
- switch (U) {
1611
- case "add":
1612
- return g.isEnabled ? void 0 : b();
1613
- case "import":
1614
- return Z();
1615
- case "export":
1616
- return le();
1617
- }
1618
- }
1619
- const x = H(""), $ = H(!1), C = S(() => $.value || N.value), { breakpoints: te } = Lt(), ne = S(() => te.value.xs || te.value.sm), W = S(() => ne.value ? 10 : 20), we = Tt(), oe = H(!1), Ce = [
1620
- {
1621
- value: "import",
1622
- label: u("common.import")
1623
- },
1624
- {
1625
- value: "export",
1626
- label: u("common.export")
1627
- }
1628
- ];
1629
- function de(U) {
1630
- switch (oe.value = !1, U) {
1631
- case "import":
1632
- return Z();
1633
- case "export":
1634
- return le();
1635
- }
1636
- }
1637
- const he = S(() => [
1638
- ...g.isEnabled ? [] : [
1639
- {
1640
- label: u("inventory.ingredient.create.title"),
1641
- value: "add",
1642
- isPrimary: !0,
1643
- prependIcon: "add"
1644
- }
1645
- ],
1646
- { label: u("common.import"), value: "import" },
1647
- { label: u("common.export"), value: "export" }
1648
- ]);
1649
- function le() {
1650
- const U = Bn();
1651
- v.open({
1652
- title: u("inventory.ingredient.export.success"),
1653
- message: u("inventory.ingredient.export.filename", [U]),
1654
- type: "success"
1655
- });
1656
- }
1657
- function Z() {
1658
- r.open({
1659
- title: u("inventory.ingredient.import.title"),
1660
- contentComponent: to,
1661
- overlay: !0,
1662
- closeButton: !0,
1663
- primaryActions: {
1664
- text: u("common.import"),
1665
- close: !1
1666
- },
1667
- secondaryActions: {
1668
- text: u("common.close"),
1669
- close: !0
1670
- },
1671
- tertiaryActions: {
1672
- text: u("inventory.ingredient.import.actions.downloadTemplate"),
1673
- close: !1,
1674
- variant: "plain"
1675
- }
1676
- }).onPrimary((U) => {
1677
- if (!U) {
1678
- v.open({
1679
- title: u("inventory.ingredient.import.error.noData"),
1680
- type: "error"
1681
- });
1682
- return;
1683
- }
1684
- if (!U.importCreateResult.length && !U.importUpdateResult.length) {
1685
- v.open({
1686
- title: u("inventory.ingredient.import.error.invalidContent"),
1687
- message: u("inventory.ingredient.import.error.noImportData"),
1688
- type: "error"
1689
- });
1690
- return;
1691
- }
1692
- if (U.importCreateResult.some((F) => F.errors.length) || U.importUpdateResult.some((F) => F.errors.length)) {
1693
- v.open({
1694
- title: u("inventory.ingredient.import.error.invalidContent"),
1695
- message: u("inventory.ingredient.import.error.hasErrors"),
1696
- type: "error"
1697
- });
1698
- return;
1699
- }
1700
- r.close(), _e(U);
1701
- }).onTertiary(Pn);
1702
- }
1703
- async function _e(U) {
1704
- $.value = !0;
1705
- try {
1706
- const F = [
1707
- ...U.importCreateResult.map(({ sku: A }) => ({ type: "create", sku: A })),
1708
- ...U.importUpdateResult.map(({ sku: A }) => ({ type: "update", sku: A }))
1709
- ], me = 100;
1710
- let ie = 0;
1711
- const ce = () => {
1712
- ie += me, v.open({
1713
- title: u("inventory.ingredient.import.progress", [
1714
- Math.min(ie, F.length),
1715
- F.length
1716
- ])
1717
- });
1718
- }, L = new Array();
1719
- for (const A of F.chunk(100)) {
1720
- ce();
1721
- try {
1722
- const P = await o.importSkus({
1723
- create: A.filter((O) => O.type === "create").map((O) => O.sku),
1724
- update: A.filter((O) => O.type === "update").map((O) => O.sku)
1725
- });
1726
- L.push(...P.errors);
1727
- } catch (P) {
1728
- L.push(
1729
- ...A.map((O) => {
1730
- const ae = {
1731
- module: Nt.enum.sku,
1732
- _id: O.sku._id,
1733
- name: O.sku.name,
1734
- message: (P == null ? void 0 : P.stack) ?? P
1735
- };
1736
- return {
1737
- data: O.sku,
1738
- error: [ae]
1739
- };
1740
- })
1741
- );
1742
- }
1743
- }
1744
- v.open({
1745
- title: u("inventory.ingredient.import.success"),
1746
- type: "success"
1747
- }), L.length && m.alert(
1748
- "Some operation failed",
1749
- Q(
1750
- "div",
1751
- { class: "flex flex-col gap-8" },
1752
- L.map(
1753
- (A) => Q("div", { class: "flex flex-col" }, [
1754
- Q("div", { class: "fm-typo-en-body-lg-600" }, `(${A.data.code}) ${A.data.name}`),
1755
- Q(
1756
- "div",
1757
- { class: "fm-typo-en-body-lg-400" },
1758
- `${A.error.map((P) => (P == null ? void 0 : P.message) ?? "Unknown error").join(", ")}`
1759
- )
1760
- ])
1761
- )
1762
- )
1763
- );
1764
- } catch (F) {
1765
- v.open({
1766
- title: u("inventory.ingredient.import.error.failed"),
1767
- message: u("inventory.ingredient.import.error.systemMessage", [F == null ? void 0 : F.message]),
1768
- type: "error"
1769
- }), console.error("Error in importing skus", U, F);
1770
- } finally {
1771
- $.value = !1;
1772
- }
1773
- }
1774
- return (U, F) => {
1775
- const me = w("FmTable"), ie = w("FmCollapsibleTabs"), ce = w("FmBottomSheet");
1776
- return h(), T(Dt, {
1777
- title: d(u)("inventory.ingredient.title"),
1778
- actions: he.value,
1779
- "onClick:action": z
1780
- }, {
1781
- default: V(() => [
1782
- c("div", {
1783
- class: J([
1784
- "flex flex-col gap-8 max-h-full",
1785
- {
1786
- "p-0": ne.value,
1787
- "px-24 ": !ne.value
1788
- }
1789
- ])
1790
- }, [
1791
- p(Bt, {
1792
- searchable: "",
1793
- search: x.value,
1794
- "onUpdate:search": F[0] || (F[0] = (L) => x.value = L),
1795
- filterable: "",
1796
- "filter-attributes": y.value,
1797
- filter: l.value,
1798
- "onUpdate:filter": F[1] || (F[1] = (L) => l.value = L)
1799
- }, null, 8, ["search", "filter-attributes", "filter"]),
1800
- (h(), T(me, {
1801
- key: JSON.stringify(l.value),
1802
- style: gt(d(we).tableHeight),
1803
- "column-defs": d(E),
1804
- "row-data": n.value,
1805
- "search-value": x.value,
1806
- loading: !d(a)._currentLocation || C.value,
1807
- "loading-text": "Loading",
1808
- onRowClick: F[2] || (F[2] = (L) => d(s)(L.original)),
1809
- "page-size": W.value
1810
- }, {
1811
- "list-row": V((L) => [
1812
- p(Pt, {
1813
- row: L,
1814
- onRowClick: d(s)
1815
- }, tt({
1816
- default: V((A) => {
1817
- var P, O, ae, t, e, f, k, R, M, G;
1818
- return [
1819
- c("div", no, [
1820
- c("div", oo, [
1821
- p(d(Ke), {
1822
- render: (ae = (O = (P = A.code) == null ? void 0 : P.column) == null ? void 0 : O.columnDef) == null ? void 0 : ae.cell,
1823
- props: (e = (t = A.code) == null ? void 0 : t.getContext) == null ? void 0 : e.call(t)
1824
- }, null, 8, ["render", "props"])
1825
- ]),
1826
- c("div", lo, [
1827
- p(d(Ke), {
1828
- render: (R = (k = (f = A.name) == null ? void 0 : f.column) == null ? void 0 : k.columnDef) == null ? void 0 : R.cell,
1829
- props: (G = (M = A.name) == null ? void 0 : M.getContext) == null ? void 0 : G.call(M)
1830
- }, null, 8, ["render", "props"])
1831
- ])
1832
- ])
1833
- ];
1834
- }),
1835
- _: 2
1836
- }, [
1837
- $.value ? {
1838
- name: "loading-text",
1839
- fn: V(() => [
1840
- c("div", null, D(d(u)("inventory.ingredient.table.importing")), 1)
1841
- ]),
1842
- key: "0"
1843
- } : void 0
1844
- ]), 1032, ["row", "onRowClick"])
1845
- ]),
1846
- _: 1
1847
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1848
- ], 2),
1849
- (h(), T(je, { to: "body" }, [
1850
- p(Un, bt(ht(d(_))), null, 16)
1851
- ])),
1852
- (h(), T(je, { to: "body" }, [
1853
- p(ce, {
1854
- "dismiss-away": "",
1855
- modelValue: oe.value,
1856
- "onUpdate:modelValue": F[4] || (F[4] = (L) => oe.value = L)
1857
- }, {
1858
- default: V(() => [
1859
- p(ie, {
1860
- class: "pb-8",
1861
- items: Ce,
1862
- "onUpdate:modelValue": F[3] || (F[3] = (L) => de(L))
1863
- })
1864
- ]),
1865
- _: 1
1866
- }, 8, ["modelValue"])
1867
- ]))
1868
- ]),
1869
- _: 1
1870
- }, 8, ["title", "actions"]);
1871
- };
1872
- }
1873
- });
1874
- export {
1875
- xo as default
1876
- };