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