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