@feedmepos/mf-inventory-portal 1.2.7-dev.8 → 1.2.7

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