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