@feedmepos/mf-inventory-portal 1.0.36-dev.6 → 1.0.36

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