@feedmepos/mf-inventory-portal 1.2.1 → 1.2.2-5.dev-1

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