@feedmepos/mf-inventory-portal 1.2.11-dev.2 → 1.2.12-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 (70) hide show
  1. package/dist/{App-7THD1njR.js → App-DAWBJNxz.js} +44 -40
  2. package/dist/{ApprovalView-DMEJRr68.js → ApprovalView-B2WUwSN4.js} +30 -30
  3. package/dist/{BindingsDialog-BNzLPDnk.js → BindingsDialog-C3OOcB8g.js} +2 -2
  4. package/dist/{BindingsPicker-b6IVAFK_.js → BindingsPicker-R3Zz0fWB.js} +1 -1
  5. package/dist/{BindingsTable-C-4XGO_N.js → BindingsTable-B46C8p7M.js} +1 -1
  6. package/dist/{ClosingDraftView-DVTloUym.js → ClosingDraftView-a_QhmaM4.js} +180 -180
  7. package/dist/{ClosingTemplateView-C-eHKV0N.js → ClosingTemplateView-CEVmIsVw.js} +3 -3
  8. package/dist/{DeliveryOrderPrintPreview-ChIV_Wxd.js → DeliveryOrderPrintPreview-BeQFF6sn.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DPkGmSYU.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DIG9NwPj.js} +3 -3
  10. package/dist/{FmMultiselectDialog-aRqxOX4h.js → FmMultiselectDialog-BunyF2O-.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-_MPI8AAx.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Bx0dzfHO.js} +39 -39
  12. package/dist/ImportView-CwBeBbXz.js +1220 -0
  13. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BiHvGyAN.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CfwprwJN.js} +1 -1
  14. package/dist/{IngredientGroupView-DtExVKaV.js → IngredientGroupView-CIPTj0hf.js} +16 -17
  15. package/dist/IngredientsView-BwBaeLtw.js +2240 -0
  16. package/dist/{IntegrationView-LnHPQMs8.js → IntegrationView-CvRD-5O6.js} +57 -57
  17. package/dist/{InventoryBindingForm-Cm9TOWWe.js → InventoryBindingForm-DLQTH1di.js} +1 -1
  18. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DwGz8gLR.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-XvIklIYw.js} +31 -31
  19. package/dist/{InventoryBindingSummary-BQ6ysLf9.js → InventoryBindingSummary-BGFSPQIw.js} +1 -1
  20. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-B_ASTDtr.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-B3J0i5IU.js} +1 -1
  21. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DdFHN7A8.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CyMRTB5L.js} +1 -1
  22. package/dist/{PublishView-Dg_U3hW1.js → PublishView-7g0bx6KO.js} +16 -16
  23. package/dist/{PurchaseOrderPrintPreview-DnwHiTGF.js → PurchaseOrderPrintPreview-LEfLcjkd.js} +1 -1
  24. package/dist/{ReceiveRequestView-CIzZf6q8.js → ReceiveRequestView-DUNfHRGf.js} +193 -194
  25. package/dist/RecipeView-XzqGQg_a.js +636 -0
  26. package/dist/{StockView-D6RmCUZZ.js → StockView-vZr9etBj.js} +165 -166
  27. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BAcaiBqq.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-3_csD6uU.js} +1 -1
  28. package/dist/{SupplierView-DmJXuznz.js → SupplierView-CUORFWJW.js} +52 -52
  29. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-9wk6mQHT.js → TransferDetails.vue_vue_type_script_setup_true_lang-DhXoNkss.js} +5 -5
  30. package/dist/{TransferTemplateView-wcXRmuoK.js → TransferTemplateView-DeliKkYY.js} +97 -97
  31. package/dist/UnitView-B4NCl6jJ.js +674 -0
  32. package/dist/{WarehouseView-643lOh1p.js → WarehouseView-jLGGlnwV.js} +32 -32
  33. package/dist/api/inventory.d.ts +306 -0
  34. package/dist/{app-CsyUwsea.js → app-DJcCTZjT.js} +7663 -7341
  35. package/dist/app.d.ts +169 -0
  36. package/dist/app.js +1 -1
  37. package/dist/{closing-template-DaHVCTUh.js → closing-template-hM43IpP-.js} +1 -1
  38. package/dist/{decimal-DveC9JMl.js → decimal-BVu2HlCS.js} +1 -1
  39. package/dist/{format-unit-display-_9FgoZom.js → format-unit-display-C-M_AirC.js} +25 -25
  40. package/dist/helper/number.d.ts +1 -0
  41. package/dist/import-export.helper-C05Vl6i-.js +243 -0
  42. package/dist/{index-ChAOZMz9.js → index-CNQtmSfJ.js} +1 -1
  43. package/dist/{index-CZmm0Xbi.js → index-v6hU4gAy.js} +1 -1
  44. package/dist/{purchase-order-template-D2kAwN4O.js → purchase-order-template-BBCEFnbo.js} +1 -1
  45. package/dist/router/name.d.ts +1 -0
  46. package/dist/{stock-CL0X5Bnh.js → stock-CK3LBQmj.js} +1 -1
  47. package/dist/stores/inventory.d.ts +26 -199
  48. package/dist/{supplier-D3mOSUzY.js → supplier-CoCAyG12.js} +1 -1
  49. package/dist/tsconfig.app.tsbuildinfo +1 -1
  50. package/dist/{use-ingredient-select-dialog-Ba-l0gZ1.js → use-ingredient-select-dialog-DYfpyC4u.js} +1 -1
  51. package/dist/{use-inventory-binding-dialog-CpaprD6M.js → use-inventory-binding-dialog-CDwm6TPx.js} +1 -1
  52. package/dist/views/import/ImportView.vue.d.ts +3 -0
  53. package/dist/views/import/components/ImportDialog.vue.d.ts +2 -0
  54. package/dist/views/import/helper/import-export.helper.d.ts +4 -0
  55. package/dist/views/ingredients/helper/import-export.helper.d.ts +3 -1
  56. package/dist/views/recipe/RecipeView.vue.d.ts +1 -0
  57. package/dist/views/recipe/components/import-recipes/ImportRecipeItem.vue.d.ts +16 -0
  58. package/dist/views/recipe/components/import-recipes/ImportRecipes.vue.d.ts +2 -0
  59. package/dist/views/recipe/helper/import-recipe.d.ts +48 -0
  60. package/dist/views/unit/UnitView.vue.d.ts +1 -0
  61. package/dist/views/unit/components/import-units/ImportUnitItem.vue.d.ts +12 -0
  62. package/dist/views/unit/components/import-units/ImportUnitItemProps.d.ts +6 -0
  63. package/dist/views/unit/components/import-units/ImportUnits.vue.d.ts +9 -0
  64. package/dist/views/unit/components/import-units/ImportUnitsProps.d.ts +5 -0
  65. package/dist/views/unit/helper/import-export.helper.d.ts +40 -0
  66. package/package.json +3 -3
  67. package/dist/IngredientsView-DQUK8EMq.js +0 -2475
  68. package/dist/RecipeView-BQeJBUvu.js +0 -621
  69. package/dist/UnitView-C1cxS42T.js +0 -667
  70. package/dist/array-Ca8T3f_G.js +0 -44
@@ -0,0 +1,2240 @@
1
+ import { ref as B, defineComponent as pe, computed as y, resolveComponent as F, openBlock as d, createElementBlock as w, Fragment as X, unref as o, createVNode as a, withModifiers as Bt, createCommentVNode as L, withCtx as g, createElementVNode as l, toDisplayString as A, normalizeClass as te, renderList as ue, createBlock as D, h as Q, renderSlot as Ve, createTextVNode as Ge, mergeModels as it, onMounted as Ot, watch as xt, useModel as Dt, isRef as dt, createSlots as kt, normalizeStyle as Nt, Teleport as ut, normalizeProps as zt, guardReactiveProps as Lt } from "vue";
2
+ import { a as Se, e as H, f as Tt, S as jt, b as Ce, h as qe, i as Wt, D as ct, j as Me, A as Pe, k as wt, l as Ht, m as mt, t as qt, n as Yt, o as De, p as Ne, U as Gt, q as Kt, M as Jt, r as pt, s as vt, c as Vt, v as ze, _ as Zt, w as ft, x as Qt, y as yt, z as Xt, B as en, N as tn, H as nn, u as ln, C as on, E as an, G as sn, I as rn, J as gt, K as dn } from "./app-DJcCTZjT.js";
3
+ import { useDialog as Re, useSnackbar as Fe, components as Le, useProxiedModel as bt, useDialogChild as un, useBreakpoints as cn } from "@feedmepos/ui-library";
4
+ import { i as mn, _ as pn } from "./is-linked-ingredient-error-fJ2TJb3z.js";
5
+ import { useI18n as ve, useCoreStore as It } from "@feedmepos/mf-common";
6
+ import { defineStore as vn, storeToRefs as fn } from "pinia";
7
+ import { g as yn, _ as je, S as We, a as gn } from "./SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-3_csD6uU.js";
8
+ import { _ as bn } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-XvIklIYw.js";
9
+ import { _ as He } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-CfwprwJN.js";
10
+ import { _ as he } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
11
+ import { d as Ue, g as hn, e as _n, a as xn } from "./import-export.helper-C05Vl6i-.js";
12
+ import { _ as kn } from "./FmCustomAttribute.vue_vue_type_script_setup_true_lang-D-IWRjRD.js";
13
+ import { u as St } from "./purchase-order-template-BBCEFnbo.js";
14
+ import { u as Ct } from "./closing-template-hM43IpP-.js";
15
+ import { u as Tn } from "./FmMultiselectDialog-BunyF2O-.js";
16
+ const Ye = vn("ingredientForm", function() {
17
+ const u = Re(), T = Fe(), s = Se(), b = B(!1), { t: S } = ve(), U = B();
18
+ function k() {
19
+ const r = {
20
+ sku: {},
21
+ mode: H.CREATE,
22
+ show: !0,
23
+ "onUpdate:show"(i) {
24
+ U.value.show = i;
25
+ }
26
+ };
27
+ U.value = r;
28
+ }
29
+ async function n(r) {
30
+ const i = {
31
+ sku: Tt(r),
32
+ mode: H.UPDATE,
33
+ show: !0,
34
+ "onUpdate:show"(m) {
35
+ U.value.show = m;
36
+ }
37
+ };
38
+ U.value = i;
39
+ }
40
+ async function c(r) {
41
+ b.value = !0;
42
+ try {
43
+ await s.deleteSku(r), T.open({
44
+ title: "Success",
45
+ message: `Deleted ${r.name}`,
46
+ type: "success"
47
+ });
48
+ } catch (i) {
49
+ i instanceof jt && mn(i) ? u.open({
50
+ title: "Cannot delete ingredient",
51
+ contentComponent: pn,
52
+ contentComponentProps: {
53
+ subject: (r == null ? void 0 : r.name) ?? "",
54
+ items: i.errorResponse.message
55
+ },
56
+ secondaryActions: {
57
+ text: "Close",
58
+ close: !0
59
+ }
60
+ }) : console.log("unable to delete ingredient", i), T.open({
61
+ title: `Cannot delete ${r.name}`,
62
+ message: "Please try again.",
63
+ type: "error"
64
+ }), console.error("failed to delete ingredient", i);
65
+ } finally {
66
+ b.value = !1;
67
+ }
68
+ }
69
+ function _(r) {
70
+ u.open({
71
+ title: S("inventory.ingredient.delete.title", [(r == null ? void 0 : r.name) ?? ""]),
72
+ closeButton: !1,
73
+ message: S("inventory.ingredient.delete.message"),
74
+ primaryActions: {
75
+ text: S("common.delete"),
76
+ close: !0,
77
+ variant: "destructive"
78
+ },
79
+ secondaryActions: {
80
+ text: S("common.cancel"),
81
+ close: !0
82
+ }
83
+ }).onPrimary(() => c(r));
84
+ }
85
+ return {
86
+ createIngredient: k,
87
+ updateIngredient: n,
88
+ deleteIngredient: _,
89
+ ingredientDialogProps: U,
90
+ ingredientViewLoading: b
91
+ };
92
+ }), wn = {
93
+ key: 0,
94
+ class: "flex items-center gap-8"
95
+ }, Vn = { class: "flex flex-col gap-1" }, In = { class: "fm-typo-en-heading-lg-600" }, Sn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Cn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fn = {
96
+ key: 0,
97
+ class: "fm-typo-en-body-md-400 text-fm-color-system-warning-300"
98
+ }, En = {
99
+ key: 1,
100
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
101
+ }, An = { class: "flex flex-col gap-2 mt-4" }, $n = { class: "flex items-center gap-2 fm-typo-en-body-md-400" }, Mn = { class: "flex flex-wrap gap-2" }, Un = { class: "flex flex-col" }, Pn = { class: "flex flex-col bg-fm-color-bg-secondary font-mono p-4 rounded-md" }, Rn = { class: "text-fm-color-typo-tertiary flex-shrink-0 fm-typo-en-body-md-400 whitespace-pre flex items-center" }, Bn = { class: "px-2 py-1 rounded-md bg-blue-200 border-2 border-blue-400" }, On = { class: "fm-typo-en-body-md-600 text-fm-color-typo-primary" }, Dn = /* @__PURE__ */ pe({
102
+ __name: "ItemSubsidiaryTreeDialog",
103
+ props: {
104
+ skuId: {},
105
+ itemName: {},
106
+ itemCode: {}
107
+ },
108
+ setup(W) {
109
+ const u = W, { t: T } = ve(), s = It(), b = Ce(), S = B(!1), U = y(() => {
110
+ var m;
111
+ return ((m = s.sessionUser.value) == null ? void 0 : m.role.isAdmin) ?? !1;
112
+ }), k = y(() => b.getSkuSubsidiaries(u.skuId)), n = y(() => {
113
+ const m = /* @__PURE__ */ new Set();
114
+ function v(E) {
115
+ for (const p of E)
116
+ p.isAssigned && (m.add(p.id), k.value.includeChildren && V(p)), p.children && p.children.length > 0 && v(p.children);
117
+ }
118
+ function V(E) {
119
+ if (E.children)
120
+ for (const p of E.children)
121
+ m.add(p.id), V(p);
122
+ }
123
+ return v(k.value.subsidiaryTree), m;
124
+ });
125
+ function c(m, v = [], V = !1) {
126
+ const E = [];
127
+ return m.forEach((p, N) => {
128
+ const O = N === m.length - 1, fe = [...v, O];
129
+ let ne = "";
130
+ for (let ee = 0; ee < v.length; ee++)
131
+ ne += v[ee] ? " " : "│ ";
132
+ ne += O ? "└── " : "├── ";
133
+ const ce = n.value.has(p.id), le = p.isAssigned === !0, oe = V && !le;
134
+ if (E.push({
135
+ id: p.id,
136
+ name: p.name,
137
+ prefix: v.length === 0 ? "" : ne,
138
+ isHighlighted: ce,
139
+ isDirectlyBound: le,
140
+ isParentIncludedChild: oe,
141
+ isRoot: v.length === 0
142
+ }), p.children && p.children.length > 0) {
143
+ const ee = V || le && k.value.includeChildren;
144
+ E.push(...c(p.children, fe, ee));
145
+ }
146
+ }), E;
147
+ }
148
+ function _(m, v = []) {
149
+ const V = /* @__PURE__ */ new Set();
150
+ for (const E of m) {
151
+ const p = [...v, E.id];
152
+ E.isAssigned === !0 && p.forEach((N) => V.add(N)), E.children && E.children.length > 0 && _(E.children, p).forEach((O) => V.add(O));
153
+ }
154
+ return V;
155
+ }
156
+ function r(m, v) {
157
+ return m.map((V) => v.has(V.id) || V.isAssigned === !0 ? {
158
+ ...V,
159
+ // Recursively filter children
160
+ children: V.children ? r(V.children, v) : []
161
+ } : null).filter(Boolean);
162
+ }
163
+ const i = y(() => {
164
+ let m = k.value.subsidiaryTree;
165
+ if ((!m || m.length === 0) && (m = b.getBusinessSubsidiaryTree()), !U.value) {
166
+ const v = _(m);
167
+ m = r(m, v);
168
+ }
169
+ return c(m, []);
170
+ });
171
+ return (m, v) => {
172
+ const V = F("FmButton"), E = F("FmDialog");
173
+ return d(), w(X, null, [
174
+ o(b).isEnabled ? (d(), w("div", wn, [
175
+ a(V, {
176
+ "prepend-icon": "info",
177
+ variant: "tertiary",
178
+ onClick: v[0] || (v[0] = Bt((p) => S.value = !0, ["stop"]))
179
+ })
180
+ ])) : L("", !0),
181
+ a(E, {
182
+ modelValue: S.value,
183
+ "onUpdate:modelValue": v[1] || (v[1] = (p) => S.value = p),
184
+ "close-button": "",
185
+ dismissAway: ""
186
+ }, {
187
+ "dialog-header": g(() => [
188
+ l("div", Vn, [
189
+ l("div", In, A(o(T)("inventory.integration.netsuite.subsidiaryHierarchy.title")), 1),
190
+ l("p", Sn, " Name: " + A(u.itemName), 1),
191
+ l("p", Cn, " Code: " + A(u.itemCode), 1),
192
+ U.value ? (d(), w("p", Fn, " All subsidiaries are shown since you are an admin. ")) : (d(), w("p", En, " Only showing subsidiaries in your business path and bound subsidiaries. ")),
193
+ l("div", An, [
194
+ l("div", $n, [
195
+ v[2] || (v[2] = l("span", { class: "font-semibold" }, "Include Children Subsidiaries:", -1)),
196
+ l("span", {
197
+ class: te(
198
+ k.value.includeChildren ? "text-green-600 font-semibold" : "text-red-600 font-semibold"
199
+ )
200
+ }, A(k.value.includeChildren ? "Yes" : "No"), 3)
201
+ ]),
202
+ l("div", Mn, [
203
+ v[4] || (v[4] = l("div", { class: "flex items-center gap-2 px-2 py-1 bg-fm-color-bg-brand-secondary rounded-md" }, [
204
+ l("span", { class: "w-3 h-3 rounded-sm bg-green-400" }),
205
+ l("span", { class: "fm-typo-en-body-sm-400" }, "Directly Bound")
206
+ ], -1)),
207
+ a(qe, null, {
208
+ default: g(() => v[3] || (v[3] = [
209
+ l("div", { class: "flex items-center gap-2 px-2 py-1 rounded-md" }, [
210
+ l("span", { class: "w-3 h-3 rounded-sm bg-blue-400" }),
211
+ l("span", { class: "fm-typo-en-body-sm-400" }, "Included as Child")
212
+ ], -1)
213
+ ])),
214
+ _: 1
215
+ })
216
+ ])
217
+ ])
218
+ ])
219
+ ]),
220
+ default: g(() => [
221
+ l("div", Un, [
222
+ l("div", Pn, [
223
+ (d(!0), w(X, null, ue(i.value, (p) => (d(), w("div", {
224
+ key: p.id,
225
+ class: "flex items-stretch"
226
+ }, [
227
+ l("span", Rn, A(p.prefix), 1),
228
+ p.isParentIncludedChild ? (d(), D(qe, {
229
+ key: 0,
230
+ class: "flex-1"
231
+ }, {
232
+ default: g(() => [
233
+ l("div", Bn, [
234
+ l("span", On, A(p.name), 1)
235
+ ])
236
+ ]),
237
+ _: 2
238
+ }, 1024)) : (d(), w("div", {
239
+ key: 1,
240
+ class: te([
241
+ "px-2 py-1 rounded-md flex-1",
242
+ p.isDirectlyBound ? "border-2 bg-green-200 border-green-400" : "bg-fm-color-bg-primary border border-fm-color-border-secondary"
243
+ ])
244
+ }, [
245
+ l("span", {
246
+ class: te([
247
+ p.isHighlighted ? "fm-typo-en-body-md-600 text-fm-color-typo-primary" : "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
248
+ ])
249
+ }, A(p.name), 3)
250
+ ], 2))
251
+ ]))), 128))
252
+ ])
253
+ ])
254
+ ]),
255
+ _: 1
256
+ }, 8, ["modelValue"])
257
+ ], 64);
258
+ };
259
+ }
260
+ });
261
+ function Nn() {
262
+ const { updateIngredient: W, deleteIngredient: u } = Ye(), T = Se(), s = Ce();
263
+ Re();
264
+ const { t: b } = ve();
265
+ async function S(k, n) {
266
+ const c = Tt(n);
267
+ if (k === Me.Edit) {
268
+ await W(c);
269
+ return;
270
+ }
271
+ if (k === Me.Delete) {
272
+ await u(c);
273
+ return;
274
+ }
275
+ }
276
+ return { columnDefs: [
277
+ {
278
+ accessorKey: "code",
279
+ header: () => b("inventory.ingredient.code"),
280
+ enableSorting: !0,
281
+ size: 200
282
+ },
283
+ {
284
+ accessorKey: "name",
285
+ header: () => b("inventory.ingredient.name"),
286
+ enableSorting: !0,
287
+ size: 300,
288
+ cell(k) {
289
+ const n = k.row.original, c = T.skuBindingFlattenCache[n._id], _ = c == null ? void 0 : c.inventoryBindings.some(
290
+ (r) => "error" in r && r.reason === "circularDependency"
291
+ );
292
+ return Q("div", { class: "flex items-center w-full gap-4" }, [
293
+ _ ? Q(
294
+ Le.FmTooltip,
295
+ { class: "text-left" },
296
+ {
297
+ default() {
298
+ return Q(Le.FmIcon, {
299
+ name: "info",
300
+ color: "system-error-300",
301
+ size: "sm"
302
+ });
303
+ },
304
+ content() {
305
+ return b("inventory.inventoryBindings.circularError");
306
+ }
307
+ }
308
+ ) : null,
309
+ n.name
310
+ ]);
311
+ }
312
+ },
313
+ {
314
+ id: "unit",
315
+ header: () => b("inventory.ingredient.unit"),
316
+ accessorFn: (k) => ht(k),
317
+ cell(k) {
318
+ const n = k.row.original, c = ht(n);
319
+ return Q(
320
+ Le.FmTooltip,
321
+ { zIndex: 51, content: c },
322
+ Q(
323
+ "span",
324
+ {
325
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
326
+ },
327
+ c
328
+ )
329
+ );
330
+ },
331
+ enableSorting: !1,
332
+ size: 300
333
+ },
334
+ {
335
+ accessorKey: "isInactive",
336
+ header: () => b("inventory.ingredient.status.title"),
337
+ cell(k) {
338
+ const n = k.row.original.isInactive;
339
+ return Q(
340
+ "span",
341
+ {
342
+ class: [
343
+ "inline-block px-3 py-1 rounded-full text-xs font-semibold",
344
+ n ? "bg-red-100 text-red-700" : "bg-green-100 text-green-700"
345
+ ].join(" ")
346
+ },
347
+ b(n ? "inventory.ingredient.status.inactive" : "inventory.ingredient.status.active")
348
+ );
349
+ },
350
+ enableSorting: !0
351
+ },
352
+ {
353
+ id: "netsuiteSubsidiary",
354
+ accessorFn: (k) => s.getSkuSubsidiaries(k._id),
355
+ header: () => "NetSuite Subsidiary",
356
+ cell(k) {
357
+ const n = k.row.original, { flattenedSubsidiaryNames: c } = s.getSkuSubsidiaries(n._id);
358
+ return Q("div", { class: "flex gap-2 items-start" }, [
359
+ Q(
360
+ "span",
361
+ {
362
+ class: "flex-1 line-clamp-2 text-ellipsis break-all whitespace-pre-wrap"
363
+ },
364
+ c.join(", ")
365
+ ),
366
+ Q(Dn, { skuId: n._id, itemName: n.name, itemCode: n.code })
367
+ ]);
368
+ },
369
+ enableSorting: !1,
370
+ size: "auto"
371
+ },
372
+ {
373
+ id: "action",
374
+ header: "",
375
+ cell(k) {
376
+ return Wt(
377
+ [ct[Me.Edit], ct[Me.Delete]],
378
+ (n) => {
379
+ S(n, k.row.original);
380
+ }
381
+ );
382
+ },
383
+ enableSorting: !1,
384
+ size: 40,
385
+ meta: {
386
+ cellClass: "",
387
+ headerClass: ""
388
+ }
389
+ }
390
+ ] };
391
+ }
392
+ function ht(W) {
393
+ var u;
394
+ if (W.trackingMeasurement) {
395
+ const T = (u = W.unit.measurements) == null ? void 0 : u.find((s) => s.id === W.trackingMeasurement);
396
+ if (T)
397
+ return `${T.name} (${T.abbrev})`;
398
+ }
399
+ return `${W.unit.name} (${W.unit.abbrev})`;
400
+ }
401
+ const zn = /* @__PURE__ */ pe({
402
+ __name: "ConvertForm",
403
+ props: {
404
+ modelValue: {},
405
+ rootValue: {},
406
+ disabled: { type: Boolean },
407
+ readonly: { type: Boolean }
408
+ },
409
+ emits: ["update:modelValue"],
410
+ setup(W, { emit: u }) {
411
+ const T = W, s = y(() => {
412
+ var i;
413
+ return (i = T.rootValue) == null ? void 0 : i.unit;
414
+ }), b = y(() => {
415
+ var i;
416
+ return (i = T.rootValue) == null ? void 0 : i._id;
417
+ }), S = u, { t: U } = ve(), k = y({
418
+ get() {
419
+ return !!T.modelValue;
420
+ },
421
+ set(i) {
422
+ i ? S("update:modelValue", {
423
+ measurement: null,
424
+ inventoryBindings: []
425
+ }) : S("update:modelValue", null);
426
+ }
427
+ }), n = y(() => yn(s.value));
428
+ function c(i) {
429
+ const m = T.modelValue ?? {};
430
+ m.measurement = i ? `${i}` : null, S("update:modelValue", m);
431
+ }
432
+ function _(i) {
433
+ const m = T.modelValue ?? {};
434
+ m.inventoryBindings = i, S("update:modelValue", m);
435
+ }
436
+ const r = y(() => {
437
+ if (!T.modelValue) return null;
438
+ const i = T.modelValue;
439
+ return i.measurement ? n.value.find((m) => m.value === i.measurement) ?? null : n.value.find((m) => m.value === null) ?? null;
440
+ });
441
+ return (i, m) => {
442
+ const v = F("FmSwitch"), V = F("FmSelect"), E = F("FmCard");
443
+ return d(), D(E, {
444
+ variant: "outlined",
445
+ class: "p-16 flex flex-col gap-16"
446
+ }, {
447
+ default: g(() => {
448
+ var p, N;
449
+ return [
450
+ a(v, {
451
+ value: "",
452
+ "model-value": k.value,
453
+ "onUpdate:modelValue": m[0] || (m[0] = (O) => k.value = O),
454
+ label: o(U)("inventory.ingredient.convertible.title"),
455
+ sublabel: o(U)("inventory.ingredient.convertible.subtitle"),
456
+ labelPlacement: "right",
457
+ disabled: i.readonly
458
+ }, null, 8, ["model-value", "label", "sublabel", "disabled"]),
459
+ k.value ? (d(), w(X, { key: 0 }, [
460
+ l("div", null, [
461
+ a(V, {
462
+ label: o(U)("inventory.ingredient.convertible.convertTo"),
463
+ modelValue: (p = r.value) == null ? void 0 : p.value,
464
+ "onUpdate:modelValue": c,
465
+ items: n.value,
466
+ disabled: i.readonly
467
+ }, null, 8, ["label", "modelValue", "items", "disabled"])
468
+ ]),
469
+ a(bn, {
470
+ id: b.value,
471
+ "model-value": ((N = i.modelValue) == null ? void 0 : N.inventoryBindings) ?? [],
472
+ "onUpdate:modelValue": _,
473
+ "exclude-binding-id": b.value,
474
+ rules: [o(Pe)(1)],
475
+ readonly: i.readonly
476
+ }, null, 8, ["id", "model-value", "exclude-binding-id", "rules", "readonly"])
477
+ ], 64)) : L("", !0)
478
+ ];
479
+ }),
480
+ _: 1
481
+ });
482
+ };
483
+ }
484
+ }), Ln = {
485
+ key: 0,
486
+ class: "flex flex-col gap-4"
487
+ }, Ie = /* @__PURE__ */ pe({
488
+ __name: "FmLockableField",
489
+ props: {
490
+ locked: { type: Boolean },
491
+ disabled: { type: Boolean },
492
+ label: {},
493
+ helperText: {},
494
+ modelValue: {},
495
+ tooltipMessage: {},
496
+ tooltipPlacement: {},
497
+ tooltipZIndex: {}
498
+ },
499
+ setup(W) {
500
+ return (u, T) => {
501
+ const s = F("FmLabel"), b = F("FmIcon"), S = F("FmTooltip"), U = F("FmField");
502
+ return u.locked ? (d(), w("div", Ln, [
503
+ Ve(u.$slots, "label", {}, () => [
504
+ a(s, {
505
+ label: u.label,
506
+ disabled: u.disabled
507
+ }, null, 8, ["label", "disabled"])
508
+ ]),
509
+ Ve(u.$slots, "field", {}, () => [
510
+ a(U, { disabled: u.disabled }, {
511
+ prepend: g(() => [
512
+ u.tooltipMessage ? (d(), D(S, {
513
+ key: 0,
514
+ placement: u.tooltipPlacement,
515
+ "z-index": u.tooltipZIndex
516
+ }, {
517
+ content: g(() => [
518
+ Ge(A(u.tooltipMessage), 1)
519
+ ]),
520
+ default: g(() => [
521
+ a(b, {
522
+ name: "lock",
523
+ color: "neutral-gray-400"
524
+ })
525
+ ]),
526
+ _: 1
527
+ }, 8, ["placement", "z-index"])) : (d(), D(b, {
528
+ key: 1,
529
+ name: "lock",
530
+ color: "neutral-gray-400"
531
+ }))
532
+ ]),
533
+ default: g(() => [
534
+ Ve(u.$slots, "modelValue", {}, () => [
535
+ l("div", {
536
+ class: te([
537
+ u.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary",
538
+ "line-clamp-1 text-ellipsis break-all"
539
+ ])
540
+ }, A(u.modelValue), 3)
541
+ ])
542
+ ]),
543
+ _: 3
544
+ }, 8, ["disabled"])
545
+ ]),
546
+ Ve(u.$slots, "helper-text", {}, () => [
547
+ l("div", {
548
+ class: te([
549
+ "fm-typo-en-body-sm-400 line-clamp-1",
550
+ u.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
551
+ ])
552
+ }, A(u.helperText), 3)
553
+ ])
554
+ ])) : Ve(u.$slots, "default", { key: 1 });
555
+ };
556
+ }
557
+ }), jn = { class: "flex gap-8" }, Wn = { class: "flex-1" }, Hn = { class: "flex-1" }, qn = { class: "flex flex-col gap-5" }, Yn = { class: "text-fm-color-typo-secondary" }, Gn = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, Kn = {
558
+ key: 3,
559
+ class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
560
+ }, Jn = { class: "flex flex-col" }, Zn = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Qn = {
561
+ key: 4,
562
+ class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
563
+ }, Xn = { class: "flex flex-col gap-12" }, el = { class: "flex flex-col gap-4" }, tl = { class: "fm-typo-en-title-sm-600" }, nl = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ll = { class: "flex flex-col gap-4" }, ol = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, al = { class: "flex-1 p-12 flex flex-col gap-8" }, sl = { class: "mx-auto" }, rl = { class: "flex flex-col" }, il = { class: "fm-typo-en-body-sm-600 translate-y-4" }, dl = { class: "flex-1 p-12 flex flex-col gap-8" }, ul = { class: "mx-auto" }, cl = { class: "flex flex-col" }, ml = { class: "fm-typo-en-body-sm-600 translate-y-4" }, pl = { class: "flex-1 p-12 flex flex-col gap-8" }, vl = { class: "mx-auto" }, fl = { class: "flex flex-col" }, yl = { class: "fm-typo-en-body-sm-600 translate-y-4" }, gl = {
564
+ key: 5,
565
+ class: "flex flex-col gap-12"
566
+ }, bl = { class: "flex flex-col" }, hl = { class: "flex items-center justify-between" }, _l = { class: "fm-typo-en-title-sm-600" }, xl = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, kl = {
567
+ key: 0,
568
+ class: "flex flex-col gap-8"
569
+ }, Tl = { class: "flex flex-wrap gap-8" }, wl = {
570
+ key: 6,
571
+ class: "flex flex-col gap-12"
572
+ }, Vl = { class: "flex flex-col" }, Il = { class: "flex items-center justify-between" }, Sl = { class: "fm-typo-en-title-sm-600" }, Cl = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Fl = {
573
+ key: 0,
574
+ class: "flex flex-col gap-8"
575
+ }, El = { class: "flex flex-wrap gap-8" }, Al = {
576
+ key: 7,
577
+ class: "flex flex-col gap-12"
578
+ }, $l = { class: "flex flex-col" }, Ml = { class: "flex items-center justify-between" }, Ul = { class: "fm-typo-en-title-sm-600" }, Pl = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Rl = {
579
+ key: 0,
580
+ class: "flex flex-col gap-8"
581
+ }, Bl = { class: "flex flex-wrap gap-8" }, Ol = /* @__PURE__ */ pe({
582
+ __name: "IngredientForm",
583
+ props: /* @__PURE__ */ it({
584
+ mode: {},
585
+ modelValue: {},
586
+ disabled: { type: Boolean },
587
+ purchaseOrderTemplateIds: {},
588
+ wastageTemplateIds: {},
589
+ closingTemplateIds: {}
590
+ }, {
591
+ search: {},
592
+ searchModifiers: {}
593
+ }),
594
+ emits: /* @__PURE__ */ it(["update:modelValue", "click:submit", "update:purchaseOrderTemplateIds", "update:wastageTemplateIds", "update:closingTemplateIds"], ["update:search"]),
595
+ setup(W, { expose: u, emit: T }) {
596
+ var et;
597
+ const { t: s } = ve(), b = Re();
598
+ Fe();
599
+ const S = St(), U = wt(), k = Ct(), n = W, c = T, _ = Se(), r = It(), i = Vt(), m = Ce(), v = y(() => m.isEnabled);
600
+ B(void 0);
601
+ const V = B([]), E = B([]), p = B([]), N = B(!1);
602
+ function O(e) {
603
+ if (e.length === 0) return;
604
+ const t = e[0], x = n.modelValue ?? {
605
+ unit: _.units.find((C) => C)
606
+ };
607
+ x.unit || (x.unit = t, c("update:modelValue", x));
608
+ }
609
+ Ot(() => {
610
+ O(_.units), n.mode === H.CREATE && (i.mustUsePoTemplate && ne(), i.enableWastageTemplate && ce(), i.enableClosingTemplate && le());
611
+ }), xt([() => _.units], ([e]) => {
612
+ O(e);
613
+ });
614
+ function fe() {
615
+ c("click:submit");
616
+ }
617
+ async function ne() {
618
+ V.value = [], N.value = !0;
619
+ try {
620
+ const [e] = await Promise.all([S.readTemplates()]).delayed(1e3);
621
+ V.value = e;
622
+ } catch (e) {
623
+ console.log("Something went wrong when fetching templates:", e);
624
+ } finally {
625
+ N.value = !1;
626
+ }
627
+ }
628
+ async function ce() {
629
+ E.value = [], N.value = !0;
630
+ try {
631
+ const [e] = await Promise.all([U.readTemplates()]).delayed(
632
+ 1e3
633
+ );
634
+ E.value = e;
635
+ } catch (e) {
636
+ console.log("Something went wrong when fetching wastage templates:", e);
637
+ } finally {
638
+ N.value = !1;
639
+ }
640
+ }
641
+ async function le() {
642
+ p.value = [], N.value = !0;
643
+ try {
644
+ const [e] = await Promise.all([k.readTemplates()]).delayed(
645
+ 1e3
646
+ );
647
+ p.value = e;
648
+ } catch (e) {
649
+ console.log("Something went wrong when fetching closing templates:", e);
650
+ } finally {
651
+ N.value = !1;
652
+ }
653
+ }
654
+ const oe = y({
655
+ get() {
656
+ var e;
657
+ return ((e = n.modelValue) == null ? void 0 : e.code) ?? "";
658
+ },
659
+ set(e) {
660
+ const t = n.modelValue ? {
661
+ ...n.modelValue
662
+ } : {};
663
+ t.code = e, c("update:modelValue", t);
664
+ }
665
+ }), ee = y({
666
+ get() {
667
+ var e;
668
+ return ((e = n.modelValue) == null ? void 0 : e.isInactive) ?? !1;
669
+ },
670
+ set(e) {
671
+ const t = n.modelValue ? {
672
+ ...n.modelValue
673
+ } : {};
674
+ t.isInactive = e, c("update:modelValue", t);
675
+ }
676
+ }), ae = y({
677
+ get() {
678
+ var e;
679
+ return ((e = n.modelValue) == null ? void 0 : e.name) ?? "";
680
+ },
681
+ set(e) {
682
+ const t = n.modelValue ? {
683
+ ...n.modelValue
684
+ } : {};
685
+ t.name = e, c("update:modelValue", t);
686
+ }
687
+ }), ye = y({
688
+ get() {
689
+ var t, x;
690
+ const e = (x = (t = n.modelValue) == null ? void 0 : t.defaultCost) == null ? void 0 : x.costPerUnit;
691
+ return e ? +Ht(e) : 0;
692
+ },
693
+ set(e) {
694
+ var x, C, Y, z;
695
+ const t = n.modelValue ? {
696
+ ...n.modelValue
697
+ } : {};
698
+ t.defaultCost ?? (t.defaultCost = {
699
+ costPerUnit: {
700
+ amount: 0,
701
+ precision: 2,
702
+ currency: ((x = mt(r.currentCountry.value)) == null ? void 0 : x.currency) ?? "MYR"
703
+ },
704
+ measurement: (z = (Y = (C = n.modelValue) == null ? void 0 : C.unit) == null ? void 0 : Y.measurements) == null ? void 0 : z.find(
705
+ (re) => {
706
+ var ie;
707
+ return re.id === ((ie = n.modelValue) == null ? void 0 : ie.trackingMeasurement);
708
+ }
709
+ )
710
+ }), t.defaultCost.costPerUnit = {
711
+ ...t.defaultCost.costPerUnit,
712
+ ...qt(+e, 4)
713
+ }, c("update:modelValue", t);
714
+ }
715
+ }), ge = y(() => {
716
+ var t, x, C;
717
+ const e = ((t = n.modelValue) == null ? void 0 : t.unit) ?? _.units.find((Y) => Y);
718
+ return e ? {
719
+ _id: e._id,
720
+ measurement: (x = n.modelValue) == null ? void 0 : x.trackingMeasurement,
721
+ name: ((C = e.measurements.find((Y) => {
722
+ var z;
723
+ return Y.id === ((z = n.modelValue) == null ? void 0 : z.trackingMeasurement);
724
+ })) == null ? void 0 : C.name) ?? e.name
725
+ } : null;
726
+ }), xe = y(
727
+ () => _.units.flatMap(({ name: e, _id: t, abbrev: x, measurements: C }) => [
728
+ {
729
+ label: `${e}`,
730
+ value: null,
731
+ displayAsSection: !0
732
+ },
733
+ {
734
+ label: `${e} (${x})`,
735
+ value: { _id: t },
736
+ displayAsSection: !1
737
+ },
738
+ ...C.map(({ id: Y, name: z, abbrev: re }) => ({
739
+ label: `${z} (${re})`,
740
+ value: { _id: t, measurement: Y },
741
+ displayAsSection: !1
742
+ }))
743
+ ])
744
+ ), h = Dt(W, "search"), P = y(
745
+ () => new Yt(xe.value, ["label", "value"], {
746
+ caseSensitive: !1,
747
+ sort: !0
748
+ })
749
+ ), G = y(() => P.value.search(h.value));
750
+ function $(e) {
751
+ var t, x, C, Y, z;
752
+ return ((x = (t = n.modelValue) == null ? void 0 : t.unit) == null ? void 0 : x._id) === ((C = e.value) == null ? void 0 : C._id) && ((Y = n.modelValue) == null ? void 0 : Y.trackingMeasurement) === ((z = e.value) == null ? void 0 : z.measurement);
753
+ }
754
+ function f(e) {
755
+ var re, ie;
756
+ if (!e) return;
757
+ const { _id: t, measurement: x } = e, C = x || void 0, Y = _.units.find((we) => we._id === t);
758
+ if (!Y)
759
+ return;
760
+ const z = n.modelValue ?? {};
761
+ z.unit = Y, z.trackingMeasurement = C, z.convert && (z.convert.measurement = C || null), i.enableTotalCost && (z.defaultCost = {
762
+ measurement: Y.measurements.find((we) => we.id === C),
763
+ costPerUnit: {
764
+ ...((re = z.defaultCost) == null ? void 0 : re.costPerUnit) ?? {
765
+ amount: 0,
766
+ precision: 2,
767
+ currency: ((ie = mt(r.currentCountry.value)) == null ? void 0 : ie.currency) ?? "MYR"
768
+ }
769
+ }
770
+ }), c("update:modelValue", z);
771
+ }
772
+ const j = y({
773
+ get() {
774
+ var e;
775
+ return ((e = n.modelValue) == null ? void 0 : e.convert) ?? null;
776
+ },
777
+ set(e) {
778
+ const t = n.modelValue ? {
779
+ ...n.modelValue
780
+ } : {};
781
+ e ? t.convert = e : t.convert = null, c("update:modelValue", t);
782
+ }
783
+ }), K = y(() => De.options.filter(
784
+ (e) => e === De.enum.FIFO || e === De.enum.WAVG
785
+ ).map((e) => ({
786
+ label: s(`inventory.ingredient.valuationMethod.${e}`),
787
+ value: e
788
+ }))), me = y({
789
+ get() {
790
+ var e;
791
+ return ((e = n.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
792
+ },
793
+ set(e) {
794
+ const t = n.modelValue ? {
795
+ ...n.modelValue
796
+ } : {};
797
+ t.valuation = e, c("update:modelValue", t);
798
+ }
799
+ }), J = y({
800
+ get() {
801
+ var e;
802
+ return ((e = n.modelValue) == null ? void 0 : e.customAttributes) ?? {};
803
+ },
804
+ set(e) {
805
+ const t = n.modelValue ? {
806
+ ...n.modelValue
807
+ } : {};
808
+ t.customAttributes = e, c("update:modelValue", t);
809
+ }
810
+ }), M = B();
811
+ u({
812
+ validateInputs: () => {
813
+ var e, t;
814
+ (t = (e = M.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
815
+ },
816
+ resetInputsValidation: () => {
817
+ var e, t;
818
+ (t = (e = M.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
819
+ },
820
+ resetInputs: () => {
821
+ var e, t;
822
+ (t = (e = M.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
823
+ }
824
+ });
825
+ const R = B(!1), q = y(
826
+ () => {
827
+ var e, t, x;
828
+ return (e = n.modelValue) != null && e._id ? ((x = _.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : x.filter(
829
+ (C) => C.from === "INGREDIENT"
830
+ )) ?? [] : [];
831
+ }
832
+ ), de = y(
833
+ () => {
834
+ var e, t, x;
835
+ return (e = n.modelValue) != null && e._id ? ((x = _.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : x.filter(
836
+ (C) => C.from === "RECIPE"
837
+ )) ?? [] : [];
838
+ }
839
+ ), ke = y(
840
+ () => {
841
+ var e, t, x;
842
+ return (e = n.modelValue) != null && e._id ? ((x = _.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : x.filter((C) => C.from === "MENU")) ?? [] : [];
843
+ }
844
+ ), _e = y(
845
+ () => _.skus.map((e) => ({ label: e.name, value: e.code }))
846
+ ), Ee = B((et = n.modelValue) == null ? void 0 : et.code);
847
+ function Ae(e) {
848
+ var x;
849
+ const t = e.el;
850
+ t && ((x = t.querySelector("[x-should-scroll-into=true]")) == null || x.scrollIntoView());
851
+ }
852
+ const $e = y(
853
+ () => {
854
+ var e, t, x, C, Y, z;
855
+ return ((C = (x = (t = (e = n.modelValue) == null ? void 0 : e.unit) == null ? void 0 : t.measurements) == null ? void 0 : x.find(
856
+ (re) => {
857
+ var ie;
858
+ return re.id === ((ie = n.modelValue) == null ? void 0 : ie.trackingMeasurement);
859
+ }
860
+ )) == null ? void 0 : C.abbrev) ?? ((z = (Y = n.modelValue) == null ? void 0 : Y.unit) == null ? void 0 : z.abbrev);
861
+ }
862
+ ), be = y({
863
+ get() {
864
+ var e, t;
865
+ return ((t = (e = n.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.low) ?? Ue().low;
866
+ },
867
+ set(e) {
868
+ var C;
869
+ const t = ((C = n.modelValue) == null ? void 0 : C.thresholds) ?? Ue();
870
+ t.low = e;
871
+ const x = n.modelValue ? {
872
+ ...n.modelValue
873
+ } : {};
874
+ x.thresholds = t, c("update:modelValue", x);
875
+ }
876
+ }), se = y({
877
+ get() {
878
+ var e, t;
879
+ return ((t = (e = n.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.mid) ?? Ue().mid;
880
+ },
881
+ set(e) {
882
+ var C;
883
+ const t = ((C = n.modelValue) == null ? void 0 : C.thresholds) ?? Ue();
884
+ t.mid = e;
885
+ const x = n.modelValue ? {
886
+ ...n.modelValue
887
+ } : {};
888
+ x.thresholds = t, c("update:modelValue", x);
889
+ }
890
+ }), Te = y(() => i.mustUsePoTemplate && n.mode === H.CREATE && V.value.length > 0 ? V.value.map((e) => ({
891
+ label: e.name || "Template",
892
+ value: e._id || "template_" + e.name
893
+ })) : []), Ke = y(() => Te.value.filter(
894
+ (e) => (n.purchaseOrderTemplateIds ?? []).includes(e.value)
895
+ )), Je = y(() => i.enableWastageTemplate && n.mode === H.CREATE && E.value.length > 0 ? E.value.map((e) => ({
896
+ label: e.name || "Template",
897
+ value: e._id || "template_" + e.name
898
+ })) : []), Ze = y(() => Je.value.filter(
899
+ (e) => (n.wastageTemplateIds ?? []).includes(e.value)
900
+ )), Qe = y(() => i.enableClosingTemplate && n.mode === H.CREATE && p.value.length > 0 ? p.value.map((e) => ({
901
+ label: e.name || "Template",
902
+ value: e._id || "template_" + e.name
903
+ })) : []), Xe = y(() => Qe.value.filter(
904
+ (e) => (n.closingTemplateIds ?? []).includes(e.value)
905
+ ));
906
+ function Ft() {
907
+ b.open({
908
+ title: s("inventory.ingredient.purchaseOrderTemplates.selectTitle"),
909
+ closeButton: !0,
910
+ contentComponent: ze,
911
+ contentComponentProps: {
912
+ modelValue: n.purchaseOrderTemplateIds ?? [],
913
+ items: Te.value
914
+ },
915
+ primaryActions: {
916
+ text: s("common.confirm"),
917
+ close: !0
918
+ },
919
+ secondaryActions: {
920
+ text: s("common.cancel"),
921
+ close: !0,
922
+ variant: "tertiary"
923
+ }
924
+ }).onPrimary((e) => {
925
+ c("update:purchaseOrderTemplateIds", e);
926
+ });
927
+ }
928
+ function Et() {
929
+ b.open({
930
+ title: s("inventory.ingredient.wastageTemplates.selectTitle"),
931
+ closeButton: !0,
932
+ contentComponent: ze,
933
+ contentComponentProps: {
934
+ modelValue: n.wastageTemplateIds ?? [],
935
+ items: Je.value
936
+ },
937
+ primaryActions: {
938
+ text: s("common.confirm"),
939
+ close: !0
940
+ },
941
+ secondaryActions: {
942
+ text: s("common.cancel"),
943
+ close: !0,
944
+ variant: "tertiary"
945
+ }
946
+ }).onPrimary((e) => {
947
+ c("update:wastageTemplateIds", e);
948
+ });
949
+ }
950
+ function At() {
951
+ b.open({
952
+ title: s("inventory.ingredient.closingTemplates.selectTitle"),
953
+ closeButton: !0,
954
+ contentComponent: ze,
955
+ contentComponentProps: {
956
+ modelValue: n.closingTemplateIds ?? [],
957
+ items: Qe.value
958
+ },
959
+ primaryActions: {
960
+ text: s("common.confirm"),
961
+ close: !0
962
+ },
963
+ secondaryActions: {
964
+ text: s("common.cancel"),
965
+ close: !0,
966
+ variant: "tertiary"
967
+ }
968
+ }).onPrimary((e) => {
969
+ c("update:closingTemplateIds", e);
970
+ });
971
+ }
972
+ function $t() {
973
+ return function(t) {
974
+ 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;
975
+ };
976
+ }
977
+ return (e, t) => {
978
+ const x = F("FmTextField"), C = F("FmLabel"), Y = F("FmField"), z = F("FmIcon"), re = F("FmMenuHeader"), ie = F("FmMenuDivider"), we = F("FmMenuItem"), Mt = F("FmMenu"), tt = F("FmFormGroup"), Ut = F("FmSelect"), nt = F("FmSwitch"), lt = F("FmStepperField"), Be = F("FmButton"), Oe = F("FmChip"), Pt = F("FmForm");
979
+ return d(), D(Pt, {
980
+ disabled: e.disabled,
981
+ ref_key: "formRef",
982
+ ref: M,
983
+ class: "flex flex-col gap-32",
984
+ onValidationSuccess: fe
985
+ }, {
986
+ default: g(() => {
987
+ var ot, at, st, rt;
988
+ return [
989
+ l("div", jn, [
990
+ l("div", Wn, [
991
+ a(Ie, {
992
+ "tooltip-message": "This field is managed by NetSuite",
993
+ "tooltip-z-index": 50,
994
+ label: o(s)("inventory.ingredient.code"),
995
+ "model-value": oe.value,
996
+ "onUpdate:modelValue": t[1] || (t[1] = (I) => oe.value = I),
997
+ locked: v.value,
998
+ disabled: e.disabled
999
+ }, {
1000
+ default: g(() => [
1001
+ a(x, {
1002
+ label: o(s)("inventory.ingredient.code"),
1003
+ "model-value": oe.value,
1004
+ "onUpdate:modelValue": t[0] || (t[0] = (I) => oe.value = I),
1005
+ rules: [o(Ne)(), o(Gt)(_e.value, Ee.value)],
1006
+ "label-mark": "required"
1007
+ }, null, 8, ["label", "model-value", "rules"])
1008
+ ]),
1009
+ _: 1
1010
+ }, 8, ["label", "model-value", "locked", "disabled"])
1011
+ ]),
1012
+ l("div", Hn, [
1013
+ a(Ie, {
1014
+ "tooltip-message": "This field is managed by NetSuite",
1015
+ "tooltip-z-index": 50,
1016
+ label: o(s)("inventory.ingredient.name"),
1017
+ "model-value": ae.value,
1018
+ "onUpdate:modelValue": t[3] || (t[3] = (I) => ae.value = I),
1019
+ locked: v.value,
1020
+ disabled: e.disabled
1021
+ }, {
1022
+ default: g(() => [
1023
+ a(x, {
1024
+ label: o(s)("inventory.ingredient.name"),
1025
+ "model-value": ae.value,
1026
+ "onUpdate:modelValue": t[2] || (t[2] = (I) => ae.value = I),
1027
+ rules: [o(Ne)()],
1028
+ "label-mark": "required"
1029
+ }, null, 8, ["label", "model-value", "rules"])
1030
+ ]),
1031
+ _: 1
1032
+ }, 8, ["label", "model-value", "locked", "disabled"])
1033
+ ])
1034
+ ]),
1035
+ a(Ie, {
1036
+ "tooltip-message": "This field is managed by NetSuite",
1037
+ "tooltip-z-index": 50,
1038
+ label: o(s)("inventory.ingredient.unit"),
1039
+ "helper-text": (ot = e.modelValue) != null && ot.trackingMeasurement ? `Base unit: ${(st = (at = e.modelValue) == null ? void 0 : at.unit) == null ? void 0 : st.name}` : void 0,
1040
+ "model-value": (rt = ge.value) == null ? void 0 : rt.name,
1041
+ locked: v.value,
1042
+ disabled: e.disabled
1043
+ }, {
1044
+ default: g(() => [
1045
+ a(tt, {
1046
+ "model-value": ge.value,
1047
+ rules: [o(Ne)()],
1048
+ "label-mark": "required"
1049
+ }, {
1050
+ label: g(() => [
1051
+ a(C, {
1052
+ label: o(s)("inventory.ingredient.unit")
1053
+ }, null, 8, ["label"])
1054
+ ]),
1055
+ default: g(({ invalid: I }) => [
1056
+ a(Mt, null, {
1057
+ "menu-button": g(() => [
1058
+ a(Y, {
1059
+ class: te([
1060
+ "fm-typo-en-body-lg-400",
1061
+ {
1062
+ "text-fm-color-typo-primary": !e.disabled,
1063
+ "text-fm-color-typo-disabled": e.disabled
1064
+ }
1065
+ ]),
1066
+ invalid: I,
1067
+ "append-icon": "expand_more"
1068
+ }, {
1069
+ default: g(() => {
1070
+ var Z;
1071
+ return [
1072
+ Ge(A((Z = ge.value) == null ? void 0 : Z.name), 1)
1073
+ ];
1074
+ }),
1075
+ _: 2
1076
+ }, 1032, ["class", "invalid"])
1077
+ ]),
1078
+ default: g(() => [
1079
+ l("div", qn, [
1080
+ a(x, {
1081
+ modelValue: h.value,
1082
+ "onUpdate:modelValue": t[4] || (t[4] = (Z) => h.value = Z),
1083
+ placeholder: "Filter options"
1084
+ }, {
1085
+ prepend: g(() => [
1086
+ a(z, { name: "search" })
1087
+ ]),
1088
+ _: 1
1089
+ }, 8, ["modelValue"]),
1090
+ l("div", {
1091
+ class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
1092
+ onVnodeMounted: Ae
1093
+ }, [
1094
+ (d(!0), w(X, null, ue(G.value, (Z, Rt) => (d(), w(X, { key: Rt }, [
1095
+ Z.displayAsSection ? (d(), w(X, { key: 0 }, [
1096
+ a(re, {
1097
+ label: Z.label
1098
+ }, null, 8, ["label"]),
1099
+ a(ie)
1100
+ ], 64)) : (d(), D(we, {
1101
+ key: 1,
1102
+ label: Z.label,
1103
+ "model-value": $(Z),
1104
+ onClick: (uo) => f(Z.value),
1105
+ "x-should-scroll-into": `${$(Z)}`
1106
+ }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
1107
+ ], 64))), 128))
1108
+ ], 512)
1109
+ ])
1110
+ ]),
1111
+ _: 2
1112
+ }, 1024)
1113
+ ]),
1114
+ _: 1
1115
+ }, 8, ["model-value", "rules"])
1116
+ ]),
1117
+ _: 1
1118
+ }, 8, ["label", "helper-text", "model-value", "locked", "disabled"]),
1119
+ o(i).enableTotalCost ? (d(), D(Ie, {
1120
+ key: 0,
1121
+ "tooltip-message": "This field is managed by NetSuite",
1122
+ "tooltip-z-index": 50,
1123
+ label: o(s)("inventory.ingredient.valuationMethod.title"),
1124
+ "model-value": o(s)("inventory.ingredient.valuationMethod." + me.value),
1125
+ locked: v.value,
1126
+ disabled: e.disabled
1127
+ }, {
1128
+ label: g(() => [
1129
+ a(he, { "z-index": 50 }, {
1130
+ default: g(() => [
1131
+ a(C, {
1132
+ label: o(s)("inventory.ingredient.valuationMethod.title")
1133
+ }, null, 8, ["label"])
1134
+ ]),
1135
+ _: 1
1136
+ })
1137
+ ]),
1138
+ default: g(() => [
1139
+ a(Ut, {
1140
+ class: "col-span-2",
1141
+ label: o(s)("inventory.ingredient.valuationMethod.title"),
1142
+ "model-value": me.value,
1143
+ "onUpdate:modelValue": t[5] || (t[5] = (I) => me.value = I),
1144
+ items: K.value
1145
+ }, null, 8, ["label", "model-value", "items"])
1146
+ ]),
1147
+ _: 1
1148
+ }, 8, ["label", "model-value", "locked", "disabled"])) : L("", !0),
1149
+ o(i).enableTotalCost ? (d(), D(Ie, {
1150
+ key: 1,
1151
+ "tooltip-message": "This field is managed by NetSuite",
1152
+ "tooltip-z-index": 50,
1153
+ "model-value": `${o(Kt)()} ${ye.value}`,
1154
+ locked: v.value,
1155
+ disabled: e.disabled
1156
+ }, {
1157
+ label: g(() => [
1158
+ a(he, { "z-index": 50 }, {
1159
+ default: g(() => [
1160
+ a(C, {
1161
+ label: o(s)("inventory.ingredient.pricePerUnit")
1162
+ }, null, 8, ["label"])
1163
+ ]),
1164
+ _: 1
1165
+ })
1166
+ ]),
1167
+ default: g(() => [
1168
+ a(x, {
1169
+ "model-value": ye.value,
1170
+ "onUpdate:modelValue": t[6] || (t[6] = (I) => ye.value = I),
1171
+ rules: [o(Pe)(0), o(Jt)(4)]
1172
+ }, {
1173
+ label: g(() => [
1174
+ a(he, { "z-index": 50 }, {
1175
+ default: g(() => [
1176
+ a(C, {
1177
+ label: o(s)("inventory.ingredient.pricePerUnit")
1178
+ }, null, 8, ["label"])
1179
+ ]),
1180
+ _: 1
1181
+ })
1182
+ ]),
1183
+ prepend: g(() => {
1184
+ var I, Z;
1185
+ return [
1186
+ l("div", Yn, A(o(pt)(((I = o(r).currentCountry) == null ? void 0 : I.value) ?? o(vt)) === "MYR" ? "RM" : o(pt)(((Z = o(r).currentCountry) == null ? void 0 : Z.value) ?? o(vt))), 1)
1187
+ ];
1188
+ }),
1189
+ append: g(() => [
1190
+ l("div", Gn, " / " + A($e.value), 1)
1191
+ ]),
1192
+ _: 1
1193
+ }, 8, ["model-value", "rules"])
1194
+ ]),
1195
+ _: 1
1196
+ }, 8, ["model-value", "locked", "disabled"])) : L("", !0),
1197
+ !v.value || j.value ? (d(), D(zn, {
1198
+ key: 2,
1199
+ "model-value": j.value,
1200
+ "onUpdate:modelValue": t[7] || (t[7] = (I) => j.value = I),
1201
+ "root-value": e.modelValue,
1202
+ readonly: v.value
1203
+ }, null, 8, ["model-value", "root-value", "readonly"])) : L("", !0),
1204
+ e.mode !== o(H).CREATE ? (d(), w("div", Kn, [
1205
+ a(nt, {
1206
+ label: o(s)("inventory.ingredient.status.inactive"),
1207
+ "model-value": ee.value,
1208
+ "onUpdate:modelValue": t[8] || (t[8] = (I) => ee.value = I),
1209
+ "label-placement": "right",
1210
+ disabled: v.value
1211
+ }, null, 8, ["label", "model-value", "disabled"]),
1212
+ l("div", Jn, [
1213
+ l("div", Zn, A(o(s)("inventory.ingredient.status.preventFromOrder")), 1)
1214
+ ])
1215
+ ])) : L("", !0),
1216
+ e.mode !== o(H).CREATE ? (d(), w("div", Qn, [
1217
+ l("div", null, [
1218
+ a(nt, {
1219
+ label: o(s)("inventory.ingredient.bindedItems.title"),
1220
+ modelValue: R.value,
1221
+ "onUpdate:modelValue": t[9] || (t[9] = (I) => R.value = I),
1222
+ "label-placement": "right"
1223
+ }, null, 8, ["label", "modelValue"])
1224
+ ]),
1225
+ R.value && q.value.length ? (d(), D(He, {
1226
+ key: 0,
1227
+ name: o(s)("inventory.ingredient.bindedItems.ingredient"),
1228
+ bindings: q.value
1229
+ }, null, 8, ["name", "bindings"])) : L("", !0),
1230
+ R.value && de.value.length ? (d(), D(He, {
1231
+ key: 1,
1232
+ name: o(s)("inventory.ingredient.bindedItems.recipe"),
1233
+ bindings: de.value
1234
+ }, null, 8, ["name", "bindings"])) : L("", !0),
1235
+ R.value && ke.value.length ? (d(), D(He, {
1236
+ key: 2,
1237
+ name: o(s)("inventory.ingredient.bindedItems.menu"),
1238
+ bindings: ke.value
1239
+ }, null, 8, ["name", "bindings"])) : L("", !0)
1240
+ ])) : L("", !0),
1241
+ l("div", Xn, [
1242
+ l("div", el, [
1243
+ a(he, null, {
1244
+ default: g(() => [
1245
+ l("div", tl, A(o(s)("inventory.ingredient.threshold.title")), 1)
1246
+ ]),
1247
+ _: 1
1248
+ }),
1249
+ l("div", nl, A(o(s)("inventory.ingredient.threshold.subtitle")), 1)
1250
+ ]),
1251
+ l("div", ll, [
1252
+ a(tt, {
1253
+ "model-value": { low: be.value, mid: se.value },
1254
+ rules: [$t()]
1255
+ }, null, 8, ["model-value", "rules"]),
1256
+ l("div", ol, [
1257
+ l("div", al, [
1258
+ l("div", sl, [
1259
+ a(je, {
1260
+ days: be.value,
1261
+ level: o(We).low
1262
+ }, null, 8, ["days", "level"])
1263
+ ]),
1264
+ l("div", rl, [
1265
+ l("div", il, A(o(s)("inventory.ingredient.threshold.whenRemaining")), 1),
1266
+ a(lt, {
1267
+ modelValue: be.value,
1268
+ "onUpdate:modelValue": t[10] || (t[10] = (I) => be.value = I),
1269
+ rules: [o(Pe)(0)]
1270
+ }, {
1271
+ append: g(() => t[13] || (t[13] = [
1272
+ l("div", {
1273
+ class: "text-fm-color-typo-secondary",
1274
+ style: { "padding-right": "32px" }
1275
+ }, "days", -1)
1276
+ ])),
1277
+ _: 1
1278
+ }, 8, ["modelValue", "rules"])
1279
+ ])
1280
+ ]),
1281
+ t[15] || (t[15] = l("div", {
1282
+ class: "h-full bg-fm-color-neutral-gray-200 relative",
1283
+ style: { width: "1px" }
1284
+ }, [
1285
+ l("div", {
1286
+ class: "absolute bg-white",
1287
+ style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
1288
+ }, " < ")
1289
+ ], -1)),
1290
+ l("div", dl, [
1291
+ l("div", ul, [
1292
+ a(je, {
1293
+ days: se.value,
1294
+ level: o(We).mid
1295
+ }, null, 8, ["days", "level"])
1296
+ ]),
1297
+ l("div", cl, [
1298
+ l("div", ml, A(o(s)("inventory.ingredient.threshold.whenRemaining")), 1),
1299
+ a(lt, {
1300
+ modelValue: se.value,
1301
+ "onUpdate:modelValue": t[11] || (t[11] = (I) => se.value = I),
1302
+ rules: [o(Pe)(0)]
1303
+ }, {
1304
+ append: g(() => t[14] || (t[14] = [
1305
+ l("div", {
1306
+ class: "text-fm-color-typo-secondary",
1307
+ style: { "padding-right": "32px" }
1308
+ }, "days", -1)
1309
+ ])),
1310
+ _: 1
1311
+ }, 8, ["modelValue", "rules"])
1312
+ ])
1313
+ ]),
1314
+ t[16] || (t[16] = l("div", {
1315
+ class: "h-full bg-fm-color-neutral-gray-200 relative",
1316
+ style: { width: "1px" }
1317
+ }, [
1318
+ l("div", {
1319
+ class: "absolute bg-white",
1320
+ style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
1321
+ }, " < ")
1322
+ ], -1)),
1323
+ l("div", pl, [
1324
+ l("div", vl, [
1325
+ a(je, {
1326
+ days: se.value + 1,
1327
+ level: o(We).high
1328
+ }, null, 8, ["days", "level"])
1329
+ ]),
1330
+ l("div", fl, [
1331
+ l("div", yl, A(o(s)("inventory.ingredient.threshold.stockIsStaple")), 1)
1332
+ ])
1333
+ ])
1334
+ ])
1335
+ ])
1336
+ ]),
1337
+ o(i).mustUsePoTemplate && e.mode === o(H).CREATE ? (d(), w("div", gl, [
1338
+ l("div", bl, [
1339
+ l("div", hl, [
1340
+ a(he, null, {
1341
+ default: g(() => [
1342
+ l("div", _l, A(o(s)("inventory.ingredient.purchaseOrderTemplates.title")), 1)
1343
+ ]),
1344
+ _: 1
1345
+ }),
1346
+ a(Be, {
1347
+ variant: "secondary",
1348
+ "text-color": "primary",
1349
+ "border-color": "primary",
1350
+ "prepend-icon": "add",
1351
+ onClick: Ft
1352
+ })
1353
+ ]),
1354
+ l("div", xl, A(o(s)("inventory.ingredient.purchaseOrderTemplates.description")), 1)
1355
+ ]),
1356
+ Ke.value.length > 0 ? (d(), w("div", kl, [
1357
+ l("div", Tl, [
1358
+ (d(!0), w(X, null, ue(Ke.value, (I) => (d(), D(Oe, {
1359
+ key: I.value,
1360
+ label: I.label,
1361
+ variant: "info",
1362
+ compact: ""
1363
+ }, null, 8, ["label"]))), 128))
1364
+ ])
1365
+ ])) : L("", !0)
1366
+ ])) : L("", !0),
1367
+ o(i).enableWastageTemplate && e.mode === o(H).CREATE ? (d(), w("div", wl, [
1368
+ l("div", Vl, [
1369
+ l("div", Il, [
1370
+ a(he, null, {
1371
+ default: g(() => [
1372
+ l("div", Sl, A(o(s)("inventory.ingredient.wastageTemplates.title")), 1)
1373
+ ]),
1374
+ _: 1
1375
+ }),
1376
+ a(Be, {
1377
+ variant: "secondary",
1378
+ "text-color": "primary",
1379
+ "border-color": "primary",
1380
+ "prepend-icon": "add",
1381
+ onClick: Et
1382
+ })
1383
+ ]),
1384
+ l("div", Cl, A(o(s)("inventory.ingredient.wastageTemplates.description")), 1)
1385
+ ]),
1386
+ Ze.value.length > 0 ? (d(), w("div", Fl, [
1387
+ l("div", El, [
1388
+ (d(!0), w(X, null, ue(Ze.value, (I) => (d(), D(Oe, {
1389
+ key: I.value,
1390
+ label: I.label,
1391
+ variant: "info",
1392
+ compact: ""
1393
+ }, null, 8, ["label"]))), 128))
1394
+ ])
1395
+ ])) : L("", !0)
1396
+ ])) : L("", !0),
1397
+ o(i).enableClosingTemplate && e.mode === o(H).CREATE ? (d(), w("div", Al, [
1398
+ l("div", $l, [
1399
+ l("div", Ml, [
1400
+ a(he, null, {
1401
+ default: g(() => [
1402
+ l("div", Ul, A(o(s)("inventory.ingredient.closingTemplates.title")), 1)
1403
+ ]),
1404
+ _: 1
1405
+ }),
1406
+ a(Be, {
1407
+ variant: "secondary",
1408
+ "text-color": "primary",
1409
+ "border-color": "primary",
1410
+ "prepend-icon": "add",
1411
+ onClick: At
1412
+ })
1413
+ ]),
1414
+ l("div", Pl, A(o(s)("inventory.ingredient.closingTemplates.description")), 1)
1415
+ ]),
1416
+ Xe.value.length > 0 ? (d(), w("div", Rl, [
1417
+ l("div", Bl, [
1418
+ (d(!0), w(X, null, ue(Xe.value, (I) => (d(), D(Oe, {
1419
+ key: I.value,
1420
+ label: I.label,
1421
+ variant: "info",
1422
+ compact: ""
1423
+ }, null, 8, ["label"]))), 128))
1424
+ ])
1425
+ ])) : L("", !0)
1426
+ ])) : L("", !0),
1427
+ l("div", null, [
1428
+ a(kn, {
1429
+ entity: "inventorySku",
1430
+ modelValue: J.value,
1431
+ "onUpdate:modelValue": t[12] || (t[12] = (I) => J.value = I)
1432
+ }, null, 8, ["modelValue"])
1433
+ ])
1434
+ ];
1435
+ }),
1436
+ _: 1
1437
+ }, 8, ["disabled"]);
1438
+ };
1439
+ }
1440
+ }), Dl = { class: "flex flex-col gap-32" }, Nl = {
1441
+ key: 0,
1442
+ class: "flex justify-between items-center"
1443
+ }, zl = { class: "flex gap-4" }, Ll = /* @__PURE__ */ pe({
1444
+ __name: "IngredientDialog",
1445
+ props: {
1446
+ show: { type: Boolean },
1447
+ sku: {},
1448
+ mode: { default: H.READ }
1449
+ },
1450
+ emits: ["update:show"],
1451
+ setup(W) {
1452
+ const u = W, T = Se(), s = Vt(), b = Ce(), S = St(), U = wt(), k = Ct(), n = Fe(), { t: c } = ve(), _ = bt(u, "show"), r = bt(u, "sku"), i = B([]), m = B([]), v = B([]), V = y(
1453
+ () => {
1454
+ var h;
1455
+ return b.isEnabled && b.netSuiteItemBySkuId.has((h = u.sku) == null ? void 0 : h._id);
1456
+ }
1457
+ ), E = y(() => {
1458
+ switch (u.mode) {
1459
+ case H.READ:
1460
+ return "";
1461
+ case H.UPDATE:
1462
+ return c("inventory.ingredient.update.title");
1463
+ case H.CREATE:
1464
+ return c("inventory.ingredient.create.title");
1465
+ }
1466
+ return "";
1467
+ }), p = y(() => {
1468
+ switch (u.mode) {
1469
+ case H.READ:
1470
+ return "";
1471
+ case H.UPDATE:
1472
+ return c("common.save");
1473
+ case H.CREATE:
1474
+ return c("common.add");
1475
+ }
1476
+ return "";
1477
+ }), N = B(), O = B(!1);
1478
+ async function fe() {
1479
+ O.value = !0;
1480
+ try {
1481
+ await T.createSku(r.value);
1482
+ const h = T.skuByCode[r.value.code];
1483
+ s.enablePoTemplate && i.value.length > 0 && await ce(h), s.enableWastageTemplate && m.value.length > 0 && await le(h), s.enableClosingTemplate && v.value.length > 0 && await oe(h), _.value = !1, n.open({
1484
+ title: c("inventory.common.success"),
1485
+ message: c("inventory.ingredient.create.success", { name: r.value.name }),
1486
+ type: "success"
1487
+ });
1488
+ } catch (h) {
1489
+ h instanceof ft || n.open({
1490
+ title: c("inventory.ingredient.create.error.title"),
1491
+ message: c("inventory.ingredient.create.error.message"),
1492
+ type: "error"
1493
+ });
1494
+ } finally {
1495
+ O.value = !1;
1496
+ }
1497
+ }
1498
+ async function ne() {
1499
+ O.value = !0;
1500
+ try {
1501
+ await T.updateSku(r.value), O.value = !1, _.value = !1, n.open({
1502
+ title: c("inventory.common.success"),
1503
+ message: c("inventory.ingredient.update.success", { name: r.value.name }),
1504
+ type: "success"
1505
+ });
1506
+ } catch (h) {
1507
+ h instanceof ft || n.open({
1508
+ title: c("inventory.ingredient.update.error.title"),
1509
+ message: c("inventory.ingredient.update.error.message"),
1510
+ type: "error"
1511
+ });
1512
+ } finally {
1513
+ O.value = !1;
1514
+ }
1515
+ }
1516
+ async function ce(h) {
1517
+ var P, G, $, f;
1518
+ try {
1519
+ for (const j of i.value) {
1520
+ const K = await S.getTemplate(j);
1521
+ if (!K) {
1522
+ console.warn(`Template with ID ${j} not found`);
1523
+ continue;
1524
+ }
1525
+ if (!K.purchaseOrder.items.find(
1526
+ (J) => J.sku._id === h._id
1527
+ )) {
1528
+ const J = { amount: 1, precision: Qt(h.unit) }, M = {
1529
+ sku: h,
1530
+ name: h.name,
1531
+ code: h.code,
1532
+ quantity: J,
1533
+ minimumQuantity: J,
1534
+ quantityStep: J,
1535
+ measurement: ((G = (P = h.unit) == null ? void 0 : P.measurements) == null ? void 0 : G[0]) || null
1536
+ }, R = {
1537
+ ...K,
1538
+ purchaseOrder: {
1539
+ ...K.purchaseOrder,
1540
+ items: [...K.purchaseOrder.items, M]
1541
+ }
1542
+ };
1543
+ ((($ = R.purchaseOrder.supplier) == null ? void 0 : $.internal) === yt.enum.warehouse || ((f = R.purchaseOrder.supplier) == null ? void 0 : f.internal) === yt.enum.restaurant) && (R.purchaseOrder.items = R.purchaseOrder.items.map(
1544
+ ({ totalCost: q, ...de }) => de
1545
+ )), await S.updateTemplate(R), await new Promise((q) => setTimeout(q, 1e3));
1546
+ }
1547
+ }
1548
+ } catch (j) {
1549
+ n.open({
1550
+ title: c("inventory.transfer.template.update.error"),
1551
+ message: c("inventory.transfer.template.update.errorMessage"),
1552
+ type: "error"
1553
+ }), console.error("Error in updating transfer template", j);
1554
+ }
1555
+ }
1556
+ async function le(h) {
1557
+ try {
1558
+ for (const P of m.value) {
1559
+ const G = await U.getTemplate(P);
1560
+ if (!G) {
1561
+ console.warn(`Wastage Template with ID ${P} not found`);
1562
+ continue;
1563
+ }
1564
+ if (!G.items.find((f) => f.id === h._id)) {
1565
+ const f = {
1566
+ id: h._id,
1567
+ name: h.name,
1568
+ code: h.code,
1569
+ type: "sku",
1570
+ disabledMeasurements: []
1571
+ }, j = {
1572
+ ...G,
1573
+ items: [...G.items, f]
1574
+ };
1575
+ await U.updateTemplate(j), await new Promise((K) => setTimeout(K, 1e3));
1576
+ }
1577
+ }
1578
+ } catch (P) {
1579
+ n.open({
1580
+ title: c("inventory.wastage.template.update.error"),
1581
+ message: c("inventory.wastage.template.update.errorMessage"),
1582
+ type: "error"
1583
+ }), console.error("Error in updating wastage template", P);
1584
+ }
1585
+ }
1586
+ async function oe(h) {
1587
+ try {
1588
+ for (const P of v.value) {
1589
+ const G = await k.getTemplate(P);
1590
+ if (!G) {
1591
+ console.warn(`Closing Template with ID ${P} not found`);
1592
+ continue;
1593
+ }
1594
+ if (!G.items.find((f) => f.sku._id === h._id)) {
1595
+ const f = {
1596
+ sku: h
1597
+ }, j = {
1598
+ ...G,
1599
+ items: [...G.items, f]
1600
+ };
1601
+ await k.updateTemplate(j), await new Promise((K) => setTimeout(K, 1e3));
1602
+ }
1603
+ }
1604
+ } catch (P) {
1605
+ n.open({
1606
+ title: c("inventory.closing.template.update.error"),
1607
+ message: c("inventory.closing.template.update.errorMessage"),
1608
+ type: "error"
1609
+ }), console.error("Error in updating closing template", P);
1610
+ }
1611
+ }
1612
+ function ee() {
1613
+ var h, P;
1614
+ (P = (h = N.value) == null ? void 0 : h.validateInputs) == null || P.call(h);
1615
+ }
1616
+ function ae() {
1617
+ switch (u.mode) {
1618
+ case H.READ:
1619
+ return;
1620
+ case H.UPDATE:
1621
+ return ne();
1622
+ case H.CREATE:
1623
+ return fe();
1624
+ }
1625
+ }
1626
+ function ye(h) {
1627
+ i.value = h;
1628
+ }
1629
+ function ge(h) {
1630
+ m.value = h;
1631
+ }
1632
+ function xe(h) {
1633
+ v.value = h;
1634
+ }
1635
+ return (h, P) => {
1636
+ const G = F("FmChip"), $ = F("FmButton"), f = F("FmSideSheet");
1637
+ return d(), D(f, {
1638
+ "model-value": o(_),
1639
+ "onUpdate:modelValue": P[3] || (P[3] = (j) => dt(_) ? _.value = j : null),
1640
+ header: E.value,
1641
+ "close-button": "",
1642
+ "dismiss-away": "",
1643
+ "max-width": 500
1644
+ }, {
1645
+ "side-sheet-footer": g(() => [
1646
+ l("div", zl, [
1647
+ a($, {
1648
+ loading: O.value,
1649
+ label: p.value,
1650
+ onClick: ee
1651
+ }, null, 8, ["loading", "label"]),
1652
+ a($, {
1653
+ disabled: O.value,
1654
+ label: o(c)("common.close"),
1655
+ variant: "tertiary",
1656
+ onClick: P[2] || (P[2] = (j) => _.value = !1)
1657
+ }, null, 8, ["disabled", "label"])
1658
+ ])
1659
+ ]),
1660
+ default: g(() => [
1661
+ l("div", Dl, [
1662
+ V.value ? (d(), w("div", Nl, [
1663
+ a(G, {
1664
+ label: "Managed by Netsuite",
1665
+ compact: ""
1666
+ }),
1667
+ a(Zt, {
1668
+ readonly: "",
1669
+ sku: h.sku,
1670
+ settingOptions: o(b).skuSettingOptions
1671
+ }, null, 8, ["sku", "settingOptions"])
1672
+ ])) : L("", !0),
1673
+ a(Ol, {
1674
+ class: "w-full",
1675
+ ref_key: "hasValidationExpose",
1676
+ ref: N,
1677
+ modelValue: o(r),
1678
+ "onUpdate:modelValue": P[0] || (P[0] = (j) => dt(r) ? r.value = j : null),
1679
+ mode: h.mode,
1680
+ disabled: O.value,
1681
+ purchaseOrderTemplateIds: i.value,
1682
+ wastageTemplateIds: m.value,
1683
+ closingTemplateIds: v.value,
1684
+ "onClick:submit": P[1] || (P[1] = (j) => ae()),
1685
+ "onUpdate:purchaseOrderTemplateIds": ye,
1686
+ "onUpdate:wastageTemplateIds": ge,
1687
+ "onUpdate:closingTemplateIds": xe
1688
+ }, null, 8, ["modelValue", "mode", "disabled", "purchaseOrderTemplateIds", "wastageTemplateIds", "closingTemplateIds"])
1689
+ ])
1690
+ ]),
1691
+ _: 1
1692
+ }, 8, ["model-value", "header"]);
1693
+ };
1694
+ }
1695
+ }), jl = { class: "flex items-center gap-12 pl-8" }, Wl = { class: "flex flex-col" }, Hl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, ql = {
1696
+ key: 0,
1697
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1698
+ }, Yl = { key: 0 }, _t = /* @__PURE__ */ pe({
1699
+ __name: "ImportIngredientItem",
1700
+ props: {
1701
+ type: {},
1702
+ code: {},
1703
+ name: {},
1704
+ errors: {}
1705
+ },
1706
+ setup(W) {
1707
+ return (u, T) => {
1708
+ const s = F("FmIcon"), b = F("FmTooltip");
1709
+ return d(), w("div", jl, [
1710
+ T[0] || (T[0] = l("div", null, "•", -1)),
1711
+ l("div", Wl, [
1712
+ l("div", Hl, [
1713
+ l("div", {
1714
+ class: te({
1715
+ "text-fm-color-system-error-300": u.errors.length
1716
+ })
1717
+ }, [
1718
+ Ge(A(u.name) + " ", 1),
1719
+ u.type === "create" ? (d(), w("span", ql, "(new)")) : L("", !0)
1720
+ ], 2),
1721
+ u.errors.length ? (d(), w("div", Yl, [
1722
+ a(b, { "z-index": 50 }, {
1723
+ content: g(() => [
1724
+ l("ol", null, [
1725
+ (d(!0), w(X, null, ue(u.errors, (S, U) => (d(), w("li", { key: U }, A(S), 1))), 128))
1726
+ ])
1727
+ ]),
1728
+ default: g(() => [
1729
+ a(s, {
1730
+ name: "error",
1731
+ size: "sm",
1732
+ color: "system-error-300"
1733
+ })
1734
+ ]),
1735
+ _: 1
1736
+ })
1737
+ ])) : L("", !0)
1738
+ ]),
1739
+ l("div", {
1740
+ class: te([
1741
+ "fm-typo-en-body-sm-400",
1742
+ {
1743
+ "text-fm-color-system-error-200": u.errors.length,
1744
+ "text-fm-color-typo-secondary": !u.errors.length
1745
+ }
1746
+ ])
1747
+ }, A(u.code), 3)
1748
+ ])
1749
+ ]);
1750
+ };
1751
+ }
1752
+ }), Gl = { class: "flex flex-col gap-24" }, Kl = { class: "fm-typo-en-body-md-400" }, Jl = { class: "flex flex-col gap-8" }, Zl = { class: "line-clamp-2 text-ellipsis break-all" }, Ql = {
1753
+ key: 2,
1754
+ class: "shrink-0"
1755
+ }, Xl = {
1756
+ key: 0,
1757
+ class: "flex flex-col"
1758
+ }, eo = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, to = {
1759
+ key: 0,
1760
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1761
+ }, no = { class: "fm-typo-en-body-lg-600" }, lo = /* @__PURE__ */ pe({
1762
+ __name: "ImportIngredients",
1763
+ setup(W) {
1764
+ const u = B(null), T = un(), s = Fe(), b = B(!1), S = B(new Array()), U = B([]), k = B([]), n = y(
1765
+ () => !!S.value.length || U.value.some((i) => i.errors.length) || k.value.some((i) => i.errors.length)
1766
+ ), c = y(
1767
+ () => !!U.value.length || !!k.value.length
1768
+ ), { t: _ } = ve();
1769
+ async function r(i) {
1770
+ S.value = [], U.value = [], k.value = [];
1771
+ try {
1772
+ b.value = !0;
1773
+ const [m] = await Promise.all([
1774
+ en(i),
1775
+ // fake buffer
1776
+ new Promise((E) => setTimeout(E, 1e3))
1777
+ ]), v = m.SheetNames.find((E) => E);
1778
+ if (!v) {
1779
+ S.value.push(_("inventory.ingredient.import.fileError.noSheet"));
1780
+ return;
1781
+ }
1782
+ const V = hn(m.Sheets[v]);
1783
+ if (V.invalidExcel) {
1784
+ S.value.push(V.invalidExcelMessage ?? _("inventory.ingredient.import.fileError.invalidExcel"));
1785
+ return;
1786
+ }
1787
+ if (U.value = V.importCreateResult, k.value = V.importUpdateResult, !U.value.length && !k.value.length) {
1788
+ S.value.push(_("inventory.ingredient.import.fileError.noData"));
1789
+ return;
1790
+ }
1791
+ T.emitData(V);
1792
+ } catch (m) {
1793
+ s.open({
1794
+ title: _("inventory.ingredient.import.fileError.unableToRead"),
1795
+ message: m == null ? void 0 : m.message,
1796
+ type: "error"
1797
+ }), console.error("Error in reading file", m);
1798
+ } finally {
1799
+ S.value.length && s.open({
1800
+ title: _("inventory.ingredient.import.fileError.invalidExcel"),
1801
+ type: "error"
1802
+ }), b.value = !1;
1803
+ }
1804
+ }
1805
+ return xt(u, (i) => {
1806
+ i && r(i);
1807
+ }), (i, m) => {
1808
+ const v = F("FmCircularProgress"), V = F("FmIcon"), E = F("FmButton");
1809
+ return d(), w("div", Gl, [
1810
+ l("div", Kl, A(o(_)("inventory.ingredient.import.uploadDescription")), 1),
1811
+ a(Xt, {
1812
+ class: te({
1813
+ "w-full": !0,
1814
+ "h-[200px]": !u.value
1815
+ }),
1816
+ accept: ".xlsx",
1817
+ onFileUpload: m[0] || (m[0] = (p) => u.value = p),
1818
+ label: o(_)("inventory.ingredient.import.uploadTemplate"),
1819
+ "button-label": o(_)("inventory.ingredient.import.selectFile")
1820
+ }, kt({ _: 2 }, [
1821
+ u.value ? {
1822
+ name: "default",
1823
+ fn: g(({ openFileDialog: p }) => [
1824
+ l("div", Jl, [
1825
+ l("div", {
1826
+ class: te([
1827
+ "fm-corner-radius-md p-16 flex items-center gap-16",
1828
+ {
1829
+ "border border-fm-color-neutral-gray-100": b.value,
1830
+ "border border-fm-color-neutral-gray-200": !b.value && !n.value,
1831
+ "border border-fm-color-system-error-200": n.value
1832
+ }
1833
+ ])
1834
+ }, [
1835
+ b.value ? (d(), D(v, {
1836
+ key: 0,
1837
+ size: "md",
1838
+ color: "neutral-gray-200"
1839
+ })) : (d(), D(V, {
1840
+ key: 1,
1841
+ name: n.value ? "error" : "attach_file",
1842
+ outline: "",
1843
+ color: n.value ? "system-error-300" : void 0
1844
+ }, null, 8, ["name", "color"])),
1845
+ l("div", {
1846
+ class: te([
1847
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
1848
+ {
1849
+ "text-fm-color-typo-disabled": b.value,
1850
+ "text-fm-color-typo-primary": !b.value
1851
+ }
1852
+ ])
1853
+ }, [
1854
+ l("div", Zl, A(u.value.name), 1)
1855
+ ], 2),
1856
+ b.value ? L("", !0) : (d(), w("div", Ql, [
1857
+ a(E, {
1858
+ label: o(_)("inventory.ingredient.import.replaceFile"),
1859
+ variant: n.value ? "destructive" : "secondary",
1860
+ "prepend-icon": n.value ? void 0 : "autorenew",
1861
+ onClick: p
1862
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
1863
+ ]))
1864
+ ], 2),
1865
+ S.value.length ? (d(), w("div", Xl, [
1866
+ (d(!0), w(X, null, ue(S.value, (N, O) => (d(), w("div", {
1867
+ key: O,
1868
+ class: "flex gap-8 items-center"
1869
+ }, [
1870
+ a(V, {
1871
+ name: "error",
1872
+ size: "sm",
1873
+ color: "system-error-300"
1874
+ }),
1875
+ l("div", eo, A(N), 1)
1876
+ ]))), 128))
1877
+ ])) : L("", !0)
1878
+ ])
1879
+ ]),
1880
+ key: "0"
1881
+ } : void 0
1882
+ ]), 1032, ["class", "label", "button-label"]),
1883
+ c.value ? (d(), w("div", to, [
1884
+ l("div", no, A(o(_)("inventory.ingredient.import.summary")), 1),
1885
+ (d(!0), w(X, null, ue(U.value, (p) => (d(), D(_t, {
1886
+ key: p.sku._id,
1887
+ code: p.sku.code,
1888
+ name: p.sku.name,
1889
+ errors: p.errors,
1890
+ type: "create"
1891
+ }, null, 8, ["code", "name", "errors"]))), 128)),
1892
+ (d(!0), w(X, null, ue(k.value, (p) => (d(), D(_t, {
1893
+ key: p.sku._id,
1894
+ code: p.sku.code,
1895
+ name: p.sku.name,
1896
+ errors: p.errors,
1897
+ type: "update"
1898
+ }, null, 8, ["code", "name", "errors"]))), 128))
1899
+ ])) : L("", !0)
1900
+ ]);
1901
+ };
1902
+ }
1903
+ }), oo = {
1904
+ key: 0,
1905
+ class: "flex items-center gap-1"
1906
+ }, ao = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, so = { class: "flex flex-col py-8" }, ro = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, io = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Io = /* @__PURE__ */ pe({
1907
+ __name: "IngredientsView",
1908
+ setup(W) {
1909
+ const u = Se(), T = Ce(), s = y(() => [
1910
+ {
1911
+ type: "string",
1912
+ key: "skuCode",
1913
+ entity: "sku",
1914
+ values: u.skus.map((f) => f.code)
1915
+ },
1916
+ {
1917
+ type: "string",
1918
+ key: "skuUnitAbbrev",
1919
+ entity: "sku",
1920
+ values: u.units.map((f) => f.abbrev)
1921
+ },
1922
+ {
1923
+ type: "string",
1924
+ key: "status",
1925
+ entity: "sku",
1926
+ values: ["Active", "Inactive"]
1927
+ }
1928
+ ]), b = B({
1929
+ logic: "AND",
1930
+ rules: [
1931
+ {
1932
+ property: "status",
1933
+ operator: "$in",
1934
+ value: ["Active"],
1935
+ type: "string"
1936
+ }
1937
+ ]
1938
+ }), S = y(
1939
+ () => new Set(T.getAvailableItems(T.businessSubsidiaryId))
1940
+ ), U = y(() => {
1941
+ if (!b.value)
1942
+ return u.skus;
1943
+ const $ = tn.build(b.value);
1944
+ return u.skus.filter((f) => T.isEnabled && ne.value && S.value && !S.value.has(f._id) ? !1 : nn(
1945
+ {
1946
+ skuCode: f.code,
1947
+ skuUnitAbbrev: f.unit.abbrev,
1948
+ status: f.isInactive ? "Inactive" : "Active"
1949
+ },
1950
+ $
1951
+ ));
1952
+ }), k = ln(), n = Re(), c = Tn(), _ = Fe(), { t: r } = ve(), { createIngredient: i, updateIngredient: m } = Ye(), { ingredientDialogProps: v, ingredientViewLoading: V } = fn(Ye()), { columnDefs: E } = Nn();
1953
+ function p($) {
1954
+ switch ($) {
1955
+ case "add":
1956
+ return T.isEnabled ? void 0 : i();
1957
+ case "import":
1958
+ return P();
1959
+ case "export":
1960
+ return h();
1961
+ }
1962
+ }
1963
+ const N = B(""), O = B(!1), fe = y(() => O.value || V.value), ne = B(!0), { breakpoints: ce } = cn(), le = y(() => ce.value.xs || ce.value.sm), oe = y(() => le.value ? 10 : 20), ee = on(), ae = B(!1), ye = [
1964
+ {
1965
+ value: "import",
1966
+ label: r("common.import")
1967
+ },
1968
+ {
1969
+ value: "export",
1970
+ label: r("common.export")
1971
+ }
1972
+ ];
1973
+ function ge($) {
1974
+ switch (ae.value = !1, $) {
1975
+ case "import":
1976
+ return P();
1977
+ case "export":
1978
+ return h();
1979
+ }
1980
+ }
1981
+ const xe = y(() => [
1982
+ ...T.isEnabled ? [] : [
1983
+ {
1984
+ label: r("inventory.ingredient.create.title"),
1985
+ value: "add",
1986
+ isPrimary: !0,
1987
+ prependIcon: "add"
1988
+ }
1989
+ ],
1990
+ { label: r("common.import"), value: "import" },
1991
+ { label: r("common.export"), value: "export" }
1992
+ ]);
1993
+ function h() {
1994
+ const $ = _n();
1995
+ _.open({
1996
+ title: r("inventory.ingredient.export.success"),
1997
+ message: r("inventory.ingredient.export.filename", [$]),
1998
+ type: "success"
1999
+ });
2000
+ }
2001
+ function P() {
2002
+ n.open({
2003
+ title: r("inventory.ingredient.import.title"),
2004
+ contentComponent: lo,
2005
+ overlay: !0,
2006
+ closeButton: !0,
2007
+ primaryActions: {
2008
+ text: r("common.import"),
2009
+ close: !1
2010
+ },
2011
+ secondaryActions: {
2012
+ text: r("common.close"),
2013
+ close: !0
2014
+ },
2015
+ tertiaryActions: {
2016
+ text: r("inventory.ingredient.import.actions.downloadTemplate"),
2017
+ close: !1,
2018
+ variant: "plain"
2019
+ }
2020
+ }).onPrimary(($) => {
2021
+ if (!$) {
2022
+ _.open({
2023
+ title: r("inventory.ingredient.import.error.noData"),
2024
+ type: "error"
2025
+ });
2026
+ return;
2027
+ }
2028
+ if (!$.importCreateResult.length && !$.importUpdateResult.length) {
2029
+ _.open({
2030
+ title: r("inventory.ingredient.import.error.invalidContent"),
2031
+ message: r("inventory.ingredient.import.error.noImportData"),
2032
+ type: "error"
2033
+ });
2034
+ return;
2035
+ }
2036
+ if ($.importCreateResult.some((f) => f.errors.length) || $.importUpdateResult.some((f) => f.errors.length)) {
2037
+ _.open({
2038
+ title: r("inventory.ingredient.import.error.invalidContent"),
2039
+ message: r("inventory.ingredient.import.error.hasErrors"),
2040
+ type: "error"
2041
+ });
2042
+ return;
2043
+ }
2044
+ n.close(), G($);
2045
+ }).onTertiary(xn);
2046
+ }
2047
+ async function G($) {
2048
+ O.value = !0;
2049
+ try {
2050
+ const f = [
2051
+ ...$.importCreateResult.map(({ sku: M }) => ({ type: "create", sku: M })),
2052
+ ...$.importUpdateResult.map(({ sku: M }) => ({ type: "update", sku: M }))
2053
+ ], j = 100;
2054
+ let K = 0;
2055
+ const me = () => {
2056
+ K += j, _.open({
2057
+ title: r("inventory.ingredient.import.progress", [
2058
+ Math.min(K, f.length),
2059
+ f.length
2060
+ ])
2061
+ });
2062
+ }, J = new Array();
2063
+ for (const M of f.chunk(100)) {
2064
+ me();
2065
+ try {
2066
+ const R = await u.importSkus({
2067
+ create: M.filter((q) => q.type === "create").map((q) => q.sku),
2068
+ update: M.filter((q) => q.type === "update").map((q) => q.sku)
2069
+ });
2070
+ J.push(...R.errors);
2071
+ } catch (R) {
2072
+ J.push(
2073
+ ...M.map((q) => {
2074
+ const de = {
2075
+ module: dn.enum.sku,
2076
+ _id: q.sku._id,
2077
+ name: q.sku.name,
2078
+ message: (R == null ? void 0 : R.stack) ?? R
2079
+ };
2080
+ return {
2081
+ data: q.sku,
2082
+ error: [de]
2083
+ };
2084
+ })
2085
+ );
2086
+ }
2087
+ }
2088
+ _.open({
2089
+ title: r("inventory.ingredient.import.success"),
2090
+ type: "success"
2091
+ }), J.length && c.alert(
2092
+ "Some operation failed",
2093
+ Q(
2094
+ "div",
2095
+ { class: "flex flex-col gap-8" },
2096
+ J.map(
2097
+ (M) => Q("div", { class: "flex flex-col" }, [
2098
+ Q("div", { class: "fm-typo-en-body-lg-600" }, `(${M.data.code}) ${M.data.name}`),
2099
+ Q(
2100
+ "div",
2101
+ { class: "fm-typo-en-body-lg-400" },
2102
+ `${M.error.map((R) => (R == null ? void 0 : R.message) ?? "Unknown error").join(", ")}`
2103
+ )
2104
+ ])
2105
+ )
2106
+ )
2107
+ );
2108
+ } catch (f) {
2109
+ _.open({
2110
+ title: r("inventory.ingredient.import.error.failed"),
2111
+ message: r("inventory.ingredient.import.error.systemMessage", [f == null ? void 0 : f.message]),
2112
+ type: "error"
2113
+ }), console.error("Error in importing skus", $, f);
2114
+ } finally {
2115
+ O.value = !1;
2116
+ }
2117
+ }
2118
+ return ($, f) => {
2119
+ const j = F("FmSwitch"), K = F("FmTable"), me = F("FmCollapsibleTabs"), J = F("FmBottomSheet");
2120
+ return d(), D(an, {
2121
+ title: o(r)("inventory.ingredient.title"),
2122
+ actions: xe.value,
2123
+ "onClick:action": p
2124
+ }, {
2125
+ default: g(() => [
2126
+ l("div", {
2127
+ class: te([
2128
+ "flex flex-col gap-8 max-h-full",
2129
+ {
2130
+ "p-0": le.value,
2131
+ "px-24 ": !le.value
2132
+ }
2133
+ ])
2134
+ }, [
2135
+ a(sn, {
2136
+ searchable: "",
2137
+ search: N.value,
2138
+ "onUpdate:search": f[1] || (f[1] = (M) => N.value = M),
2139
+ filterable: "",
2140
+ "filter-attributes": s.value,
2141
+ filter: b.value,
2142
+ "onUpdate:filter": f[2] || (f[2] = (M) => b.value = M)
2143
+ }, {
2144
+ default: g(() => [
2145
+ o(T).isEnabled ? (d(), w("div", oo, [
2146
+ l("span", ao, A(o(r)("inventory.integration.netsuite.subsidiaryHierarchy.filtering")), 1),
2147
+ a(gn),
2148
+ a(qe, null, {
2149
+ default: g(() => [
2150
+ a(j, {
2151
+ modelValue: ne.value,
2152
+ "onUpdate:modelValue": f[0] || (f[0] = (M) => ne.value = M)
2153
+ }, null, 8, ["modelValue"])
2154
+ ]),
2155
+ _: 1
2156
+ })
2157
+ ])) : L("", !0)
2158
+ ]),
2159
+ _: 1
2160
+ }, 8, ["search", "filter-attributes", "filter"]),
2161
+ (d(), D(K, {
2162
+ key: JSON.stringify(b.value),
2163
+ style: Nt(o(ee).tableHeight),
2164
+ "column-defs": o(E),
2165
+ "row-data": U.value,
2166
+ "search-value": N.value,
2167
+ columnVisibility: {
2168
+ netsuiteSubsidiary: o(T).isEnabled
2169
+ },
2170
+ loading: (!o(k)._currentLocation || fe.value) && o(T).isReady,
2171
+ "loading-text": "Loading",
2172
+ onRowClick: f[3] || (f[3] = (M) => o(m)(M.original)),
2173
+ "page-size": oe.value
2174
+ }, {
2175
+ "list-row": g((M) => [
2176
+ a(rn, {
2177
+ row: M,
2178
+ onRowClick: o(m)
2179
+ }, kt({
2180
+ default: g((R) => {
2181
+ var q, de, ke, _e, Ee, Ae, $e, be, se, Te;
2182
+ return [
2183
+ l("div", so, [
2184
+ l("div", ro, [
2185
+ a(o(gt), {
2186
+ render: (ke = (de = (q = R.code) == null ? void 0 : q.column) == null ? void 0 : de.columnDef) == null ? void 0 : ke.cell,
2187
+ props: (Ee = (_e = R.code) == null ? void 0 : _e.getContext) == null ? void 0 : Ee.call(_e)
2188
+ }, null, 8, ["render", "props"])
2189
+ ]),
2190
+ l("div", io, [
2191
+ a(o(gt), {
2192
+ render: (be = ($e = (Ae = R.name) == null ? void 0 : Ae.column) == null ? void 0 : $e.columnDef) == null ? void 0 : be.cell,
2193
+ props: (Te = (se = R.name) == null ? void 0 : se.getContext) == null ? void 0 : Te.call(se)
2194
+ }, null, 8, ["render", "props"])
2195
+ ])
2196
+ ])
2197
+ ];
2198
+ }),
2199
+ _: 2
2200
+ }, [
2201
+ O.value ? {
2202
+ name: "loading-text",
2203
+ fn: g(() => [
2204
+ l("div", null, A(o(r)("inventory.ingredient.table.importing")), 1)
2205
+ ]),
2206
+ key: "0"
2207
+ } : void 0
2208
+ ]), 1032, ["row", "onRowClick"])
2209
+ ]),
2210
+ _: 1
2211
+ }, 8, ["style", "column-defs", "row-data", "search-value", "columnVisibility", "loading", "page-size"]))
2212
+ ], 2),
2213
+ (d(), D(ut, { to: "body" }, [
2214
+ a(Ll, zt(Lt(o(v))), null, 16)
2215
+ ])),
2216
+ (d(), D(ut, { to: "body" }, [
2217
+ a(J, {
2218
+ "dismiss-away": "",
2219
+ modelValue: ae.value,
2220
+ "onUpdate:modelValue": f[5] || (f[5] = (M) => ae.value = M)
2221
+ }, {
2222
+ default: g(() => [
2223
+ a(me, {
2224
+ class: "pb-8",
2225
+ items: ye,
2226
+ "onUpdate:modelValue": f[4] || (f[4] = (M) => ge(M))
2227
+ })
2228
+ ]),
2229
+ _: 1
2230
+ }, 8, ["modelValue"])
2231
+ ]))
2232
+ ]),
2233
+ _: 1
2234
+ }, 8, ["title", "actions"]);
2235
+ };
2236
+ }
2237
+ });
2238
+ export {
2239
+ Io as default
2240
+ };