@feedmepos/mf-inventory-portal 1.7.13 → 1.7.15-dev.0

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