@feedmepos/mf-inventory-portal 1.7.14 → 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 (137) hide show
  1. package/dist/App-aeh6OigH.js +1476 -0
  2. package/dist/{ApprovalView-BPDiAWh_.js → ApprovalView-D9U2VmYa.js} +9 -9
  3. package/dist/{BindingsDialog-RUlhC05W.js → BindingsDialog-Ddh44o3y.js} +2 -2
  4. package/dist/{BindingsPicker-voEXbc8p.js → BindingsPicker-CFtdG6ld.js} +2 -2
  5. package/dist/{BindingsTable-QuFV3fHq.js → BindingsTable-Dl44JUUS.js} +4 -4
  6. package/dist/BulkReceiveRequestView-DzjYw8z3.js +2657 -0
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CSxFa-Hr.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-Bg8FBGzq.js} +6 -2
  8. package/dist/{ClosingDraftView-BUWt7ufW.js → ClosingDraftView-D0SGlTkF.js} +19 -19
  9. package/dist/{ClosingHistoryView-BzQ7f_31.js → ClosingHistoryView-BKfhpOEw.js} +5 -5
  10. package/dist/{ClosingTemplateView-BoDHKL2a.js → ClosingTemplateView-Ikq2OM4z.js} +16 -16
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-B-t0N1PO.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-BhTM2C3K.js} +1 -1
  12. package/dist/{DefaultView-CO4Fk0X3.js → DefaultView-ClKfklyX.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-Clslc2Wf.js → DeliveryOrderPrintPreview-Cfz_N8Bf.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-BfQdw5-j.js → EmailDialog.vue_vue_type_script_setup_true_lang-C-GPckzY.js} +2259 -2254
  15. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-Brtj-hCD.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BxkzheM9.js} +6 -6
  16. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CHUQOFif.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-BqIWvN-i.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-D7cnUmM5.js → FmMultiselectDialog-CiOdsRlf.js} +1 -1
  20. package/dist/{FmMultiselectDialog-GAdb6F9O.js → FmMultiselectDialog-Dr8wRNW7.js} +2 -2
  21. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DAjM0Dya.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D-Ycop6K.js} +6 -6
  22. package/dist/{ImportView-CrmY9zsK.js → ImportView-BBqak01n.js} +499 -496
  23. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-Sm0goJ7U.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CAJDLjrN.js} +1 -1
  24. package/dist/{IngredientGroupView-BebnVDQI.js → IngredientGroupView-CghsReO0.js} +5 -5
  25. package/dist/IngredientsView-DLxTWo-n.js +2239 -0
  26. package/dist/{IntegrationExplorerView-DxjMZi_f.js → IntegrationExplorerView-C05R8EzL.js} +4 -4
  27. package/dist/{IntegrationView-Dm6Bkv1g.js → IntegrationView-DpN7PYPc.js} +3077 -3001
  28. package/dist/{InventoryBindingForm-B5Dd6UGk.js → InventoryBindingForm-CnHzZu12.js} +1 -1
  29. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-Cls49Zgb.js +563 -0
  30. package/dist/{InventoryBindingSummary-BO8imeDG.js → InventoryBindingSummary-DK5Z9AKC.js} +1 -1
  31. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Dp6O-oVL.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-FsxbejSt.js} +1 -1
  32. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-Mkt2BoGf.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DvIbqRH9.js} +1 -1
  33. package/dist/{ProductionView-DIwvqo6L.js → ProductionView-DeUmELdm.js} +7 -7
  34. package/dist/{PublishView-CbeljE1v.js → PublishView-CGHFmmCG.js} +3 -3
  35. package/dist/{PurchaseOrderPrintPreview-PzYdJJW9.js → PurchaseOrderPrintPreview-xyXZU3oQ.js} +2 -2
  36. package/dist/{ReceiveRequestView-NKnqWM_b.js → ReceiveRequestView-CVmAUuqN.js} +14 -14
  37. package/dist/RecipeView-BSd1V9En.js +3625 -0
  38. package/dist/{SettingsView-BjX4I2pe.js → SettingsView-AI-JaGxh.js} +4 -4
  39. package/dist/{StockView--9-NLfX0.js → StockView-CRrYes0h.js} +21 -21
  40. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BWHPauQW.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DNXdZVOA.js} +1 -1
  41. package/dist/{SupplierView-B8T6cose.js → SupplierView-BMupiPVi.js} +1156 -1035
  42. package/dist/{SurchargeView-eVcM29Ss.js → SurchargeView-77KsLF2T.js} +6 -6
  43. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-CYXfguPD.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-Brw98Ihw.js} +2 -2
  44. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CMM1DWU3.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Cjt4YAII.js} +1 -1
  45. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-CuNAt9UU.js → TransferDetails.vue_vue_type_script_setup_true_lang-BHeqFlka.js} +1599 -1535
  46. package/dist/{TransferTemplateView-D_oKyOUD.js → TransferTemplateView-BMF1_tLd.js} +20 -20
  47. package/dist/{UnitCostHistoryView-DThFdkNP.js → UnitCostHistoryView-Gp8uWjMQ.js} +4 -4
  48. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-B6cHxf2Q.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-mwAMQ0B3.js} +4 -4
  49. package/dist/{UnitView-BQZepbTS.js → UnitView-Cuk5oaOf.js} +8 -8
  50. package/dist/WarehouseView-Bat0looR.js +1082 -0
  51. package/dist/{WastageTemplateView-BQO1geZz.js → WastageTemplateView-Coag2jbG.js} +14 -14
  52. package/dist/api/changelog.d.ts +132 -0
  53. package/dist/api/netsuite.d.ts +2 -0
  54. package/dist/api/purchase-order.d.ts +2 -0
  55. package/dist/{app-KaSY7GIt.js → app-C3gNrduY.js} +10397 -9443
  56. package/dist/app.d.ts +940 -9
  57. package/dist/app.js +1 -1
  58. package/dist/{closing-template-BFEWl8-N.js → closing-template-DKklbhBW.js} +1 -1
  59. package/dist/cypress/component/ChangelogPanel.cy.d.ts +1 -0
  60. package/dist/cypress/support/component.d.ts +1 -2
  61. package/dist/{date2-DnqAk4pp.js → date2-Cx-YVc4N.js} +5 -5
  62. package/dist/{dayjs.min-e3pyVvVk.js → dayjs.min-Cj2Eh8Tj.js} +1 -1
  63. package/dist/{decimal-DUKpY1WE.js → decimal-OxPQV_Pd.js} +2 -2
  64. package/dist/{defineDeepModel-T75uoBAd.js → defineDeepModel-Dud4PiVz.js} +1 -1
  65. package/dist/{duplicate-template-CdBNGLA2.js → duplicate-template-XAhspiYs.js} +1 -1
  66. package/dist/{feature-dE--ixN-.js → feature-gYL54g_K.js} +2 -2
  67. package/dist/{format-time-from-id-D8SWSpBR.js → format-time-from-id-T7WHy_x1.js} +1 -1
  68. package/dist/{format-unit-display-ChGKpRsq.js → format-unit-display-BsjRSrAe.js} +27 -27
  69. package/dist/{import-export.helper-BGjE6JjK.js → import-export.helper-CEdt0BWR.js} +6 -6
  70. package/dist/{index-D_QylMOJ.js → index-BZynONs2.js} +3 -3
  71. package/dist/{index-JPtVC3tk.js → index-CBcKeIhg.js} +3306 -3232
  72. package/dist/{index-DdMg0SgN.js → index-DQKbOIoT.js} +1 -1
  73. package/dist/{inventory-core-dart.default-0h8jmf3F.js → inventory-core-dart.default-D4zV0IQQ.js} +1 -1
  74. package/dist/{lz-string-NnYfN1XC.js → lz-string-BtyfM17N.js} +1 -1
  75. package/dist/{netsuite-CAphkhg7.js → netsuite-BEW5HsxM.js} +1717 -1692
  76. package/dist/{number-C8J8sC6d.js → number-CQBgN-M7.js} +3 -3
  77. package/dist/{predefined-templates-CB1opHrA.js → predefined-templates-CpP9HOqv.js} +1 -1
  78. package/dist/{purchase-order-template-p6EdpieI.js → purchase-order-template-PekDPb4u.js} +1 -1
  79. package/dist/{recalculationUtils-C5whNKrN.js → recalculationUtils-lfhKnVFx.js} +1 -1
  80. package/dist/{rules-sRZqLpuQ.js → rules-5x2UEFmU.js} +2 -2
  81. package/dist/{stock-BpfRRZPr.js → stock-Ch5c3jO9.js} +3 -3
  82. package/dist/{stock-DWrhlch4.js → stock-DqIRhhsu.js} +4 -4
  83. package/dist/stores/bulk-job.d.ts +13 -0
  84. package/dist/stores/integration/netsuite.d.ts +54 -0
  85. package/dist/style.css +1 -1
  86. package/dist/{supplier-MzC5sRqv.js → supplier-DVxdFpgr.js} +2 -2
  87. package/dist/{surcharge-ClMtrRgS.js → surcharge-CNGep-bs.js} +8 -8
  88. package/dist/tsconfig.app.tsbuildinfo +1 -1
  89. package/dist/{uom-rules-Di7y-2Xl.js → uom-rules-RPvKxFQI.js} +1 -1
  90. package/dist/{use-ingredient-select-dialog-BPhQJhXq.js → use-ingredient-select-dialog-CPdwTQrN.js} +2 -2
  91. package/dist/{use-inventory-binding-dialog-BStbsMsT.js → use-inventory-binding-dialog-CeyqcDPW.js} +2 -2
  92. package/dist/{use-template-enabled-locations-ChCTz0-t.js → use-template-enabled-locations-DJ46fm8w.js} +2 -2
  93. package/dist/{use-transfer-locations-D8N8x1cE.js → use-transfer-locations-DBIAb9MY.js} +2 -2
  94. package/dist/{useHrmPermission-DCSqbLxW.js → useHrmPermission-BEDY0i29.js} +1 -1
  95. package/dist/{useNavigationMenu-D3-zmwIs.js → useNavigationMenu-xXANo9uC.js} +2 -2
  96. package/dist/{useSseClient-BRHLaPnM.js → useSseClient-B-dfDpdW.js} +1 -1
  97. package/dist/views/changelog/components/ChangelogDialog.vue.d.ts +19 -0
  98. package/dist/views/changelog/components/ChangelogFloatingButton.spec.d.ts +1 -0
  99. package/dist/views/changelog/components/ChangelogFloatingButton.vue.d.ts +2 -0
  100. package/dist/views/changelog/components/ChangelogPanel.spec.d.ts +1 -0
  101. package/dist/views/changelog/components/ChangelogPanel.vue.d.ts +20 -0
  102. package/dist/views/changelog/composables/change-path.d.ts +10 -0
  103. package/dist/views/changelog/composables/commit-message.d.ts +9 -0
  104. package/dist/views/changelog/composables/commit-message.spec.d.ts +1 -0
  105. package/dist/views/changelog/composables/fab-position.d.ts +21 -0
  106. package/dist/views/changelog/composables/json-line-diff.d.ts +10 -0
  107. package/dist/views/changelog/composables/json-line-diff.spec.d.ts +1 -0
  108. package/dist/views/changelog/composables/use-changelog.d.ts +90 -0
  109. package/dist/views/changelog/composables/use-changelog.spec.d.ts +1 -0
  110. package/dist/views/changelog/composables/use-inventory-record-commits.d.ts +97 -0
  111. package/dist/views/changelog/composables/use-inventory-record-commits.spec.d.ts +1 -0
  112. package/dist/views/changelog/composables/use-snapshot-diff.d.ts +29 -0
  113. package/dist/views/changelog/composables/use-snapshot-diff.spec.d.ts +1 -0
  114. package/dist/views/changelog/composables/value-tree.d.ts +14 -0
  115. package/dist/views/changelog/composables/value-tree.spec.d.ts +1 -0
  116. package/dist/views/import/helper/submit-rows.d.ts +13 -0
  117. package/dist/views/import/helper/submit-rows.spec.d.ts +1 -0
  118. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +2 -0
  119. package/dist/views/ingredients/components/inventory-binding/RecipeBindingBreakdown.vue.d.ts +25 -0
  120. package/dist/views/ingredients/components/inventory-binding/composables/recipe-breakdown.d.ts +34 -0
  121. package/dist/views/ingredients/components/inventory-binding/composables/recipe-breakdown.spec.d.ts +1 -0
  122. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +2 -0
  123. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryRecipeBindingV2Field.vue.d.ts +4 -0
  124. package/dist/views/integration/components/netsuite/business/vendor-publish.d.ts +7 -0
  125. package/dist/views/integration/components/netsuite/business/vendor-publish.spec.d.ts +1 -0
  126. package/dist/views/receive-request/components/email-dialog/EmailDialog.spec.d.ts +1 -0
  127. package/dist/views/receive-request/components/email-dialog/EmailDialogProps.d.ts +23 -9
  128. package/dist/views/recipe/composables/use-recipe-table.d.ts +11 -0
  129. package/dist/{vue-i18n-BMo8ADYz.js → vue-i18n-D64MVhs-.js} +196 -196
  130. package/dist/{xlsx.util-BSzjcX4G.js → xlsx.util-BntGs-ye.js} +2 -2
  131. package/package.json +3 -3
  132. package/dist/App-Blx6Ojzj.js +0 -311
  133. package/dist/BulkReceiveRequestView-Bix6MV0Z.js +0 -2595
  134. package/dist/IngredientsView-CZ6Angq_.js +0 -2321
  135. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-D4shlQ9Z.js +0 -441
  136. package/dist/RecipeView-COQ6WUcz.js +0 -3584
  137. package/dist/WarehouseView-BZSn9BHl.js +0 -1079
@@ -1,2321 +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, d as pt, e as Wt, f as vt, h as ft, i as yt, j as gt, u as qt, k as Ht } from "./app-KaSY7GIt.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-CAphkhg7.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-sRZqLpuQ.js";
14
- import { g as sn, _ as We, S as qe, a as rn } from "./SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BWHPauQW.js";
15
- import { _ as dn } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-D4shlQ9Z.js";
16
- import { _ as He } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-Sm0goJ7U.js";
17
- import { u as Vt } from "./feature-dE--ixN-.js";
18
- import { t as un, a as mn, g as cn } from "./number-C8J8sC6d.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-BGjE6JjK.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-GAdb6F9O.js";
23
- import { u as It } from "./purchase-order-template-p6EdpieI.js";
24
- import { u as Ft, a as St } from "./closing-template-BFEWl8-N.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-BSzjcX4G.js";
27
- import { F as _n } from "./FmDroppableField-J0tG_U3w.js";
28
- import { _ as xn } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BqIWvN-i.js";
29
- import { u as kn } from "./FmMultiselectDialog-D7cnUmM5.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
- }, null, 8, ["id", "model-value", "exclude-binding-id", "rules", "readonly"])
512
- ], 64)) : z("", !0)
513
- ];
514
- }),
515
- _: 1
516
- });
517
- };
518
- }
519
- }), jn = {
520
- key: 0,
521
- class: "flex flex-col gap-4"
522
- }, Wn = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, Ce = /* @__PURE__ */ pe({
523
- __name: "FmLockableField",
524
- props: {
525
- locked: { type: Boolean },
526
- disabled: { type: Boolean },
527
- label: {},
528
- helperText: {},
529
- modelValue: {},
530
- tooltipMessage: {},
531
- tooltipPlacement: {},
532
- tooltipZIndex: {},
533
- appendText: {}
534
- },
535
- setup(W) {
536
- return (i, k) => {
537
- const d = T("FmLabel"), _ = T("FmIcon"), F = T("FmTooltip"), C = T("FmField");
538
- return i.locked ? (c(), w("div", jn, [
539
- Te(i.$slots, "label", {}, () => [
540
- s(d, {
541
- label: i.label,
542
- disabled: i.disabled
543
- }, null, 8, ["label", "disabled"])
544
- ]),
545
- Te(i.$slots, "field", {}, () => [
546
- s(C, { disabled: i.disabled }, Ge({
547
- prepend: g(() => [
548
- i.tooltipMessage ? (c(), O(F, {
549
- key: 0,
550
- placement: i.tooltipPlacement,
551
- "z-index": i.tooltipZIndex
552
- }, {
553
- content: g(() => [
554
- Je(A(i.tooltipMessage), 1)
555
- ]),
556
- default: g(() => [
557
- s(_, {
558
- name: "lock",
559
- color: "neutral-gray-400"
560
- })
561
- ]),
562
- _: 1
563
- }, 8, ["placement", "z-index"])) : (c(), O(_, {
564
- key: 1,
565
- name: "lock",
566
- color: "neutral-gray-400"
567
- }))
568
- ]),
569
- default: g(() => [
570
- Te(i.$slots, "modelValue", {}, () => [
571
- n("div", {
572
- class: ne([
573
- i.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary",
574
- "line-clamp-1 text-ellipsis break-all"
575
- ])
576
- }, A(i.modelValue), 3)
577
- ])
578
- ]),
579
- _: 2
580
- }, [
581
- i.appendText || i.$slots.fieldAppend ? {
582
- name: "append",
583
- fn: g(() => [
584
- Te(i.$slots, "fieldAppend", {}, () => [
585
- n("div", Wn, A(i.appendText), 1)
586
- ])
587
- ]),
588
- key: "0"
589
- } : void 0
590
- ]), 1032, ["disabled"])
591
- ]),
592
- Te(i.$slots, "helper-text", {}, () => [
593
- n("div", {
594
- class: ne([
595
- "fm-typo-en-body-sm-400 line-clamp-1",
596
- i.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
597
- ])
598
- }, A(i.helperText), 3)
599
- ])
600
- ])) : Te(i.$slots, "default", { key: 1 });
601
- };
602
- }
603
- }), 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 = {
604
- key: 3,
605
- class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
606
- }, Qn = { class: "flex flex-col" }, Xn = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, el = {
607
- key: 4,
608
- class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
609
- }, 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 = {
610
- key: 5,
611
- class: "flex flex-col gap-12"
612
- }, _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 = {
613
- key: 0,
614
- class: "flex flex-col gap-8"
615
- }, Vl = { class: "flex flex-wrap gap-8" }, Il = {
616
- key: 6,
617
- class: "flex flex-col gap-12"
618
- }, 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 = {
619
- key: 0,
620
- class: "flex flex-col gap-8"
621
- }, El = { class: "flex flex-wrap gap-8" }, Ml = {
622
- key: 7,
623
- class: "flex flex-col gap-12"
624
- }, 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 = {
625
- key: 0,
626
- class: "flex flex-col gap-8"
627
- }, Dl = { class: "flex flex-wrap gap-8" }, Nl = /* @__PURE__ */ pe({
628
- __name: "IngredientForm",
629
- props: /* @__PURE__ */ dt({
630
- mode: {},
631
- modelValue: {},
632
- disabled: { type: Boolean },
633
- purchaseOrderTemplateIds: {},
634
- wastageTemplateIds: {},
635
- closingTemplateIds: {}
636
- }, {
637
- search: {},
638
- searchModifiers: {}
639
- }),
640
- emits: /* @__PURE__ */ dt(["update:modelValue", "click:submit", "update:purchaseOrderTemplateIds", "update:wastageTemplateIds", "update:closingTemplateIds"], ["update:search"]),
641
- setup(W, { expose: i, emit: k }) {
642
- var tt;
643
- const { t: d } = ve(), _ = Ze();
644
- $e();
645
- const F = It(), C = Ft(), U = St(), o = W, u = k, p = Ae(), a = Qe(), m = Vt(), r = Ee(), y = h(() => r.isEnabled);
646
- P(void 0);
647
- const V = P([]), $ = P([]), v = P([]), D = P(!1);
648
- function R(e) {
649
- if (e.length === 0) return;
650
- const t = e[0], x = o.modelValue ?? {
651
- unit: p.units.find((S) => S)
652
- };
653
- x.unit || (x.unit = t, u("update:modelValue", x));
654
- }
655
- Ot(() => {
656
- R(p.units), o.mode === q.CREATE && (m.mustUsePoTemplate && le(), m.enableWastageTemplate && ue(), m.enableClosingTemplate && oe());
657
- }), Tt([() => p.units], ([e]) => {
658
- R(e);
659
- });
660
- function fe() {
661
- u("click:submit");
662
- }
663
- async function le() {
664
- V.value = [], D.value = !0;
665
- try {
666
- const [e] = await Promise.all([F.readTemplates()]).delayed(1e3);
667
- V.value = e;
668
- } catch (e) {
669
- console.log("Something went wrong when fetching templates:", e);
670
- } finally {
671
- D.value = !1;
672
- }
673
- }
674
- async function ue() {
675
- $.value = [], D.value = !0;
676
- try {
677
- const [e] = await Promise.all([C.readTemplates()]).delayed(
678
- 1e3
679
- );
680
- $.value = e;
681
- } catch (e) {
682
- console.log("Something went wrong when fetching wastage templates:", e);
683
- } finally {
684
- D.value = !1;
685
- }
686
- }
687
- async function oe() {
688
- v.value = [], D.value = !0;
689
- try {
690
- const [e] = await Promise.all([U.listTemplates()]).delayed(
691
- 1e3
692
- );
693
- v.value = e;
694
- } catch (e) {
695
- console.log("Something went wrong when fetching closing templates:", e);
696
- } finally {
697
- D.value = !1;
698
- }
699
- }
700
- const ae = h({
701
- get() {
702
- var e;
703
- return ((e = o.modelValue) == null ? void 0 : e.code) ?? "";
704
- },
705
- set(e) {
706
- const t = o.modelValue ? {
707
- ...o.modelValue
708
- } : {};
709
- t.code = e, u("update:modelValue", t);
710
- }
711
- }), te = h({
712
- get() {
713
- var e;
714
- return ((e = o.modelValue) == null ? void 0 : e.isInactive) ?? !1;
715
- },
716
- set(e) {
717
- const t = o.modelValue ? {
718
- ...o.modelValue
719
- } : {};
720
- t.isInactive = e, u("update:modelValue", t);
721
- }
722
- }), se = h({
723
- get() {
724
- var e;
725
- return ((e = o.modelValue) == null ? void 0 : e.name) ?? "";
726
- },
727
- set(e) {
728
- const t = o.modelValue ? {
729
- ...o.modelValue
730
- } : {};
731
- t.name = e, u("update:modelValue", t);
732
- }
733
- }), ye = h({
734
- get() {
735
- var t, x;
736
- const e = (x = (t = o.modelValue) == null ? void 0 : t.defaultCost) == null ? void 0 : x.costPerUnit;
737
- return e ? +mn(e) : 0;
738
- },
739
- set(e) {
740
- var x, S, Y, N;
741
- const t = o.modelValue ? {
742
- ...o.modelValue
743
- } : {};
744
- t.defaultCost ?? (t.defaultCost = {
745
- costPerUnit: {
746
- amount: 0,
747
- precision: 2,
748
- currency: ((x = ct(a.currentCountry.value)) == null ? void 0 : x.currency) ?? "MYR"
749
- },
750
- measurement: (N = (Y = (S = o.modelValue) == null ? void 0 : S.unit) == null ? void 0 : Y.measurements) == null ? void 0 : N.find(
751
- (re) => {
752
- var ie;
753
- return re.id === ((ie = o.modelValue) == null ? void 0 : ie.trackingMeasurement);
754
- }
755
- )
756
- }), t.defaultCost.costPerUnit = {
757
- ...t.defaultCost.costPerUnit,
758
- ...un(+e, 4)
759
- }, u("update:modelValue", t);
760
- }
761
- }), ge = h(() => {
762
- var t, x, S;
763
- const e = ((t = o.modelValue) == null ? void 0 : t.unit) ?? p.units.find((Y) => Y);
764
- return e ? {
765
- _id: e._id,
766
- measurement: (x = o.modelValue) == null ? void 0 : x.trackingMeasurement,
767
- name: ((S = e.measurements.find((Y) => {
768
- var N;
769
- return Y.id === ((N = o.modelValue) == null ? void 0 : N.trackingMeasurement);
770
- })) == null ? void 0 : S.name) ?? e.name
771
- } : null;
772
- }), we = h(
773
- () => p.units.flatMap(({ name: e, _id: t, abbrev: x, measurements: S }) => [
774
- {
775
- label: `${e}`,
776
- value: null,
777
- displayAsSection: !0
778
- },
779
- {
780
- label: `${e} (${x})`,
781
- value: { _id: t },
782
- displayAsSection: !1
783
- },
784
- ...S.map(({ id: Y, name: N, abbrev: re }) => ({
785
- label: `${N} (${re})`,
786
- value: { _id: t, measurement: Y },
787
- displayAsSection: !1
788
- }))
789
- ])
790
- ), b = Dt(W, "search"), M = h(
791
- () => new gn(we.value, ["label", "value"], {
792
- caseSensitive: !1,
793
- sort: !0
794
- })
795
- ), G = h(() => M.value.search(b.value));
796
- function E(e) {
797
- var t, x, S, Y, N;
798
- 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);
799
- }
800
- function f(e) {
801
- var re, ie;
802
- if (!e) return;
803
- const { _id: t, measurement: x } = e, S = x || void 0, Y = p.units.find((Se) => Se._id === t);
804
- if (!Y)
805
- return;
806
- const N = o.modelValue ?? {};
807
- N.unit = Y, N.trackingMeasurement = S, N.convert && (N.convert.measurement = S || null), m.enableTotalCost && (N.defaultCost = {
808
- measurement: Y.measurements.find((Se) => Se.id === S),
809
- costPerUnit: {
810
- ...((re = N.defaultCost) == null ? void 0 : re.costPerUnit) ?? {
811
- amount: 0,
812
- precision: 2,
813
- currency: ((ie = ct(a.currentCountry.value)) == null ? void 0 : ie.currency) ?? "MYR"
814
- }
815
- }
816
- }), u("update:modelValue", N);
817
- }
818
- const L = h({
819
- get() {
820
- var e;
821
- return ((e = o.modelValue) == null ? void 0 : e.convert) ?? null;
822
- },
823
- set(e) {
824
- const t = o.modelValue ? {
825
- ...o.modelValue
826
- } : {};
827
- e ? t.convert = e : t.convert = null, u("update:modelValue", t);
828
- }
829
- }), J = h(() => pt.options.filter(
830
- (e) => (
831
- // e === F_INVENTORY_VALUATION_METHODS.enum.FIFO ||
832
- e === pt.enum.WAVG
833
- )
834
- ).map((e) => ({
835
- label: d(`inventory.ingredient.valuationMethod.${e}`),
836
- value: e
837
- }))), me = h({
838
- get() {
839
- var e;
840
- return ((e = o.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
841
- },
842
- set(e) {
843
- const t = o.modelValue ? {
844
- ...o.modelValue
845
- } : {};
846
- t.valuation = e, u("update:modelValue", t);
847
- }
848
- }), Z = h({
849
- get() {
850
- var e;
851
- return ((e = o.modelValue) == null ? void 0 : e.customAttributes) ?? {};
852
- },
853
- set(e) {
854
- const t = o.modelValue ? {
855
- ...o.modelValue
856
- } : {};
857
- t.customAttributes = e, u("update:modelValue", t);
858
- }
859
- }), H = P();
860
- i({
861
- validateInputs: () => {
862
- var e, t;
863
- (t = (e = H.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
864
- },
865
- resetInputsValidation: () => {
866
- var e, t;
867
- (t = (e = H.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
868
- },
869
- resetInputs: () => {
870
- var e, t;
871
- (t = (e = H.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
872
- }
873
- });
874
- const B = P(!1), K = h(
875
- () => {
876
- var e, t, x;
877
- return (e = o.modelValue) != null && e._id ? ((x = p.menu.bindedBySkuId[(t = o.modelValue) == null ? void 0 : t._id]) == null ? void 0 : x.filter(
878
- (S) => S.from === "INGREDIENT"
879
- )) ?? [] : [];
880
- }
881
- ), j = h(
882
- () => {
883
- var e, t, x;
884
- return (e = o.modelValue) != null && e._id ? ((x = p.menu.bindedBySkuId[(t = o.modelValue) == null ? void 0 : t._id]) == null ? void 0 : x.filter(
885
- (S) => S.from === "RECIPE"
886
- )) ?? [] : [];
887
- }
888
- ), be = h(
889
- () => {
890
- var e, t, x;
891
- 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")) ?? [] : [];
892
- }
893
- ), Me = h(
894
- () => p.skus.map((e) => ({ label: e.name, value: e.code }))
895
- ), Ue = P((tt = o.modelValue) == null ? void 0 : tt.code);
896
- function Pe(e) {
897
- var x;
898
- const t = e.el;
899
- t && ((x = t.querySelector("[x-should-scroll-into=true]")) == null || x.scrollIntoView());
900
- }
901
- const he = h(
902
- () => {
903
- var e, t, x, S, Y, N;
904
- return ((S = (x = (t = (e = o.modelValue) == null ? void 0 : e.unit) == null ? void 0 : t.measurements) == null ? void 0 : x.find(
905
- (re) => {
906
- var ie;
907
- return re.id === ((ie = o.modelValue) == null ? void 0 : ie.trackingMeasurement);
908
- }
909
- )) == null ? void 0 : S.abbrev) ?? ((N = (Y = o.modelValue) == null ? void 0 : Y.unit) == null ? void 0 : N.abbrev);
910
- }
911
- ), _e = h({
912
- get() {
913
- var e, t;
914
- return ((t = (e = o.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.low) ?? Be().low;
915
- },
916
- set(e) {
917
- var S;
918
- const t = ((S = o.modelValue) == null ? void 0 : S.thresholds) ?? Be();
919
- t.low = e;
920
- const x = o.modelValue ? {
921
- ...o.modelValue
922
- } : {};
923
- x.thresholds = t, u("update:modelValue", x);
924
- }
925
- }), ce = h({
926
- get() {
927
- var e, t;
928
- return ((t = (e = o.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.mid) ?? Be().mid;
929
- },
930
- set(e) {
931
- var S;
932
- const t = ((S = o.modelValue) == null ? void 0 : S.thresholds) ?? Be();
933
- t.mid = e;
934
- const x = o.modelValue ? {
935
- ...o.modelValue
936
- } : {};
937
- x.thresholds = t, u("update:modelValue", x);
938
- }
939
- }), Ve = h(() => m.mustUsePoTemplate && o.mode === q.CREATE && V.value.length > 0 ? V.value.map((e) => ({
940
- label: e.name || "Template",
941
- value: e._id || "template_" + e.name
942
- })) : []), Ie = h(() => Ve.value.filter(
943
- (e) => (o.purchaseOrderTemplateIds ?? []).includes(e.value)
944
- )), xe = h(() => m.enableWastageTemplate && o.mode === q.CREATE && $.value.length > 0 ? $.value.map((e) => ({
945
- label: e.name || "Template",
946
- value: e._id || "template_" + e.name
947
- })) : []), Fe = h(() => xe.value.filter(
948
- (e) => (o.wastageTemplateIds ?? []).includes(e.value)
949
- )), Xe = h(() => m.enableClosingTemplate && o.mode === q.CREATE && v.value.length > 0 ? v.value.map((e) => ({
950
- label: e.name || "Template",
951
- value: e._id || "template_" + e.name
952
- })) : []), et = h(() => Xe.value.filter(
953
- (e) => (o.closingTemplateIds ?? []).includes(e.value)
954
- ));
955
- function Ct() {
956
- _.open({
957
- title: d("inventory.ingredient.purchaseOrderTemplates.selectTitle"),
958
- closeButton: !0,
959
- contentComponent: Ye,
960
- contentComponentProps: {
961
- modelValue: o.purchaseOrderTemplateIds ?? [],
962
- items: Ve.value
963
- },
964
- primaryActions: {
965
- text: d("common.confirm"),
966
- close: !0
967
- },
968
- secondaryActions: {
969
- text: d("common.cancel"),
970
- close: !0,
971
- variant: "tertiary"
972
- }
973
- }).onPrimary((e) => {
974
- u("update:purchaseOrderTemplateIds", e);
975
- });
976
- }
977
- function At() {
978
- _.open({
979
- title: d("inventory.ingredient.wastageTemplates.selectTitle"),
980
- closeButton: !0,
981
- contentComponent: Ye,
982
- contentComponentProps: {
983
- modelValue: o.wastageTemplateIds ?? [],
984
- items: xe.value
985
- },
986
- primaryActions: {
987
- text: d("common.confirm"),
988
- close: !0
989
- },
990
- secondaryActions: {
991
- text: d("common.cancel"),
992
- close: !0,
993
- variant: "tertiary"
994
- }
995
- }).onPrimary((e) => {
996
- u("update:wastageTemplateIds", e);
997
- });
998
- }
999
- function $t() {
1000
- _.open({
1001
- title: d("inventory.ingredient.closingTemplates.selectTitle"),
1002
- closeButton: !0,
1003
- contentComponent: Ye,
1004
- contentComponentProps: {
1005
- modelValue: o.closingTemplateIds ?? [],
1006
- items: Xe.value
1007
- },
1008
- primaryActions: {
1009
- text: d("common.confirm"),
1010
- close: !0
1011
- },
1012
- secondaryActions: {
1013
- text: d("common.cancel"),
1014
- close: !0,
1015
- variant: "tertiary"
1016
- }
1017
- }).onPrimary((e) => {
1018
- u("update:closingTemplateIds", e);
1019
- });
1020
- }
1021
- function Et() {
1022
- return function(t) {
1023
- 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;
1024
- };
1025
- }
1026
- return (e, t) => {
1027
- 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");
1028
- return c(), O(Pt, {
1029
- disabled: e.disabled,
1030
- ref_key: "formRef",
1031
- ref: H,
1032
- class: "flex flex-col gap-32",
1033
- onValidationSuccess: fe
1034
- }, {
1035
- default: g(() => {
1036
- var at, st, rt, it;
1037
- return [
1038
- n("div", qn, [
1039
- n("div", Hn, [
1040
- s(Ce, {
1041
- "tooltip-message": "This field is managed by NetSuite",
1042
- "tooltip-z-index": 50,
1043
- label: l(d)("inventory.ingredient.code"),
1044
- "model-value": ae.value,
1045
- "onUpdate:modelValue": t[1] || (t[1] = (I) => ae.value = I),
1046
- locked: y.value,
1047
- disabled: e.disabled
1048
- }, {
1049
- default: g(() => [
1050
- s(x, {
1051
- label: l(d)("inventory.ingredient.code"),
1052
- "model-value": ae.value,
1053
- "onUpdate:modelValue": t[0] || (t[0] = (I) => ae.value = I),
1054
- rules: [l(je)(), l(on)(Me.value, Ue.value)],
1055
- "label-mark": "required"
1056
- }, null, 8, ["label", "model-value", "rules"])
1057
- ]),
1058
- _: 1
1059
- }, 8, ["label", "model-value", "locked", "disabled"])
1060
- ]),
1061
- n("div", Yn, [
1062
- s(Ce, {
1063
- "tooltip-message": "This field is managed by NetSuite",
1064
- "tooltip-z-index": 50,
1065
- label: l(d)("inventory.ingredient.name"),
1066
- "model-value": se.value,
1067
- "onUpdate:modelValue": t[3] || (t[3] = (I) => se.value = I),
1068
- locked: y.value,
1069
- disabled: e.disabled
1070
- }, {
1071
- default: g(() => [
1072
- s(x, {
1073
- label: l(d)("inventory.ingredient.name"),
1074
- "model-value": se.value,
1075
- "onUpdate:modelValue": t[2] || (t[2] = (I) => se.value = I),
1076
- rules: [l(je)()],
1077
- "label-mark": "required"
1078
- }, null, 8, ["label", "model-value", "rules"])
1079
- ]),
1080
- _: 1
1081
- }, 8, ["label", "model-value", "locked", "disabled"])
1082
- ])
1083
- ]),
1084
- s(Ce, {
1085
- "tooltip-message": "This field is managed by NetSuite",
1086
- "tooltip-z-index": 50,
1087
- label: l(d)("inventory.ingredient.unit"),
1088
- "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,
1089
- "model-value": (it = ge.value) == null ? void 0 : it.name,
1090
- locked: y.value,
1091
- disabled: e.disabled
1092
- }, {
1093
- default: g(() => [
1094
- s(nt, {
1095
- "model-value": ge.value,
1096
- rules: [l(je)()],
1097
- "label-mark": "required"
1098
- }, {
1099
- label: g(() => [
1100
- s(S, {
1101
- label: l(d)("inventory.ingredient.unit")
1102
- }, null, 8, ["label"])
1103
- ]),
1104
- default: g(({ invalid: I }) => [
1105
- s(Mt, null, {
1106
- "menu-button": g(() => [
1107
- s(Y, {
1108
- class: ne([
1109
- "fm-typo-en-body-lg-400",
1110
- {
1111
- "text-fm-color-typo-primary": !e.disabled,
1112
- "text-fm-color-typo-disabled": e.disabled
1113
- }
1114
- ]),
1115
- invalid: I,
1116
- "append-icon": "expand_more"
1117
- }, {
1118
- default: g(() => {
1119
- var Q;
1120
- return [
1121
- Je(A((Q = ge.value) == null ? void 0 : Q.name), 1)
1122
- ];
1123
- }),
1124
- _: 2
1125
- }, 1032, ["class", "invalid"])
1126
- ]),
1127
- default: g(() => [
1128
- n("div", Kn, [
1129
- s(x, {
1130
- modelValue: b.value,
1131
- "onUpdate:modelValue": t[4] || (t[4] = (Q) => b.value = Q),
1132
- placeholder: "Filter options"
1133
- }, {
1134
- prepend: g(() => [
1135
- s(N, { name: "search" })
1136
- ]),
1137
- _: 1
1138
- }, 8, ["modelValue"]),
1139
- n("div", {
1140
- class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
1141
- onVnodeMounted: Pe
1142
- }, [
1143
- (c(!0), w(ee, null, de(G.value, (Q, Rt) => (c(), w(ee, { key: Rt }, [
1144
- Q.displayAsSection ? (c(), w(ee, { key: 0 }, [
1145
- s(re, {
1146
- label: Q.label
1147
- }, null, 8, ["label"]),
1148
- s(ie)
1149
- ], 64)) : (c(), O(Se, {
1150
- key: 1,
1151
- label: Q.label,
1152
- "model-value": E(Q),
1153
- onClick: (co) => f(Q.value),
1154
- "x-should-scroll-into": `${E(Q)}`
1155
- }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
1156
- ], 64))), 128))
1157
- ], 512)
1158
- ])
1159
- ]),
1160
- _: 2
1161
- }, 1024)
1162
- ]),
1163
- _: 1
1164
- }, 8, ["model-value", "rules"])
1165
- ]),
1166
- _: 1
1167
- }, 8, ["label", "helper-text", "model-value", "locked", "disabled"]),
1168
- l(m).enableTotalCost ? (c(), O(Ce, {
1169
- key: 0,
1170
- "tooltip-message": "This field is managed by NetSuite",
1171
- "tooltip-z-index": 50,
1172
- label: l(d)("inventory.ingredient.valuationMethod.title"),
1173
- "model-value": l(d)("inventory.ingredient.valuationMethod." + me.value),
1174
- locked: y.value,
1175
- disabled: e.disabled
1176
- }, {
1177
- label: g(() => [
1178
- s(ke, { "z-index": 50 }, {
1179
- default: g(() => [
1180
- s(S, {
1181
- label: l(d)("inventory.ingredient.valuationMethod.title")
1182
- }, null, 8, ["label"])
1183
- ]),
1184
- _: 1
1185
- })
1186
- ]),
1187
- default: g(() => [
1188
- s(Ut, {
1189
- class: "col-span-2",
1190
- label: l(d)("inventory.ingredient.valuationMethod.title"),
1191
- "model-value": me.value,
1192
- "onUpdate:modelValue": t[5] || (t[5] = (I) => me.value = I),
1193
- items: J.value
1194
- }, null, 8, ["label", "model-value", "items"])
1195
- ]),
1196
- _: 1
1197
- }, 8, ["label", "model-value", "locked", "disabled"])) : z("", !0),
1198
- l(m).enableTotalCost ? (c(), O(Ce, {
1199
- key: 1,
1200
- "tooltip-message": "This field is managed by NetSuite",
1201
- "tooltip-z-index": 50,
1202
- "model-value": `${l(Wt)()} ${ye.value}`,
1203
- locked: y.value,
1204
- "append-text": `/ ${he.value}`,
1205
- disabled: e.disabled
1206
- }, {
1207
- label: g(() => [
1208
- s(ke, { "z-index": 50 }, {
1209
- default: g(() => [
1210
- s(S, {
1211
- label: l(d)("inventory.ingredient.pricePerUnit")
1212
- }, null, 8, ["label"])
1213
- ]),
1214
- _: 1
1215
- })
1216
- ]),
1217
- default: g(() => [
1218
- s(x, {
1219
- "model-value": ye.value,
1220
- "onUpdate:modelValue": t[6] || (t[6] = (I) => ye.value = I),
1221
- rules: [l(Oe)(0), l(an)(4)]
1222
- }, {
1223
- label: g(() => [
1224
- s(ke, { "z-index": 50 }, {
1225
- default: g(() => [
1226
- s(S, {
1227
- label: l(d)("inventory.ingredient.pricePerUnit")
1228
- }, null, 8, ["label"])
1229
- ]),
1230
- _: 1
1231
- })
1232
- ]),
1233
- prepend: g(() => {
1234
- var I, Q;
1235
- return [
1236
- 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)
1237
- ];
1238
- }),
1239
- append: g(() => [
1240
- n("div", Jn, " / " + A(he.value), 1)
1241
- ]),
1242
- _: 1
1243
- }, 8, ["model-value", "rules"])
1244
- ]),
1245
- _: 1
1246
- }, 8, ["model-value", "locked", "append-text", "disabled"])) : z("", !0),
1247
- !y.value || L.value ? (c(), O(Ln, {
1248
- key: 2,
1249
- "model-value": L.value,
1250
- "onUpdate:modelValue": t[7] || (t[7] = (I) => L.value = I),
1251
- "root-value": e.modelValue,
1252
- readonly: y.value
1253
- }, null, 8, ["model-value", "root-value", "readonly"])) : z("", !0),
1254
- e.mode !== l(q).CREATE ? (c(), w("div", Zn, [
1255
- s(lt, {
1256
- label: l(d)("inventory.ingredient.status.inactive"),
1257
- "model-value": te.value,
1258
- "onUpdate:modelValue": t[8] || (t[8] = (I) => te.value = I),
1259
- "label-placement": "right",
1260
- disabled: y.value
1261
- }, null, 8, ["label", "model-value", "disabled"]),
1262
- n("div", Qn, [
1263
- n("div", Xn, A(l(d)("inventory.ingredient.status.preventFromOrder")), 1)
1264
- ])
1265
- ])) : z("", !0),
1266
- e.mode !== l(q).CREATE ? (c(), w("div", el, [
1267
- n("div", null, [
1268
- s(lt, {
1269
- label: l(d)("inventory.ingredient.bindedItems.title"),
1270
- modelValue: B.value,
1271
- "onUpdate:modelValue": t[9] || (t[9] = (I) => B.value = I),
1272
- "label-placement": "right"
1273
- }, null, 8, ["label", "modelValue"])
1274
- ]),
1275
- B.value && K.value.length ? (c(), O(He, {
1276
- key: 0,
1277
- name: l(d)("inventory.ingredient.bindedItems.ingredient"),
1278
- bindings: K.value
1279
- }, null, 8, ["name", "bindings"])) : z("", !0),
1280
- B.value && j.value.length ? (c(), O(He, {
1281
- key: 1,
1282
- name: l(d)("inventory.ingredient.bindedItems.recipe"),
1283
- bindings: j.value
1284
- }, null, 8, ["name", "bindings"])) : z("", !0),
1285
- B.value && be.value.length ? (c(), O(He, {
1286
- key: 2,
1287
- name: l(d)("inventory.ingredient.bindedItems.menu"),
1288
- bindings: be.value
1289
- }, null, 8, ["name", "bindings"])) : z("", !0)
1290
- ])) : z("", !0),
1291
- n("div", tl, [
1292
- n("div", nl, [
1293
- s(ke, null, {
1294
- default: g(() => [
1295
- n("div", ll, A(l(d)("inventory.ingredient.threshold.title")), 1)
1296
- ]),
1297
- _: 1
1298
- }),
1299
- n("div", ol, A(l(d)("inventory.ingredient.threshold.subtitle")), 1)
1300
- ]),
1301
- n("div", al, [
1302
- s(nt, {
1303
- "model-value": { low: _e.value, mid: ce.value },
1304
- rules: [Et()]
1305
- }, null, 8, ["model-value", "rules"]),
1306
- n("div", sl, [
1307
- n("div", rl, [
1308
- n("div", il, [
1309
- s(We, {
1310
- days: _e.value,
1311
- level: l(qe).low
1312
- }, null, 8, ["days", "level"])
1313
- ]),
1314
- n("div", dl, [
1315
- n("div", ul, A(l(d)("inventory.ingredient.threshold.whenRemaining")), 1),
1316
- s(ot, {
1317
- modelValue: _e.value,
1318
- "onUpdate:modelValue": t[10] || (t[10] = (I) => _e.value = I),
1319
- rules: [l(Oe)(0)]
1320
- }, {
1321
- append: g(() => t[13] || (t[13] = [
1322
- n("div", {
1323
- class: "text-fm-color-typo-secondary",
1324
- style: { "padding-right": "32px" }
1325
- }, "days", -1)
1326
- ])),
1327
- _: 1
1328
- }, 8, ["modelValue", "rules"])
1329
- ])
1330
- ]),
1331
- t[15] || (t[15] = n("div", {
1332
- class: "h-full bg-fm-color-neutral-gray-200 relative",
1333
- style: { width: "1px" }
1334
- }, [
1335
- n("div", {
1336
- class: "absolute bg-white",
1337
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
1338
- }, " < ")
1339
- ], -1)),
1340
- n("div", ml, [
1341
- n("div", cl, [
1342
- s(We, {
1343
- days: ce.value,
1344
- level: l(qe).mid
1345
- }, null, 8, ["days", "level"])
1346
- ]),
1347
- n("div", pl, [
1348
- n("div", vl, A(l(d)("inventory.ingredient.threshold.whenRemaining")), 1),
1349
- s(ot, {
1350
- modelValue: ce.value,
1351
- "onUpdate:modelValue": t[11] || (t[11] = (I) => ce.value = I),
1352
- rules: [l(Oe)(0)]
1353
- }, {
1354
- append: g(() => t[14] || (t[14] = [
1355
- n("div", {
1356
- class: "text-fm-color-typo-secondary",
1357
- style: { "padding-right": "32px" }
1358
- }, "days", -1)
1359
- ])),
1360
- _: 1
1361
- }, 8, ["modelValue", "rules"])
1362
- ])
1363
- ]),
1364
- t[16] || (t[16] = n("div", {
1365
- class: "h-full bg-fm-color-neutral-gray-200 relative",
1366
- style: { width: "1px" }
1367
- }, [
1368
- n("div", {
1369
- class: "absolute bg-white",
1370
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
1371
- }, " < ")
1372
- ], -1)),
1373
- n("div", fl, [
1374
- n("div", yl, [
1375
- s(We, {
1376
- days: ce.value + 1,
1377
- level: l(qe).high
1378
- }, null, 8, ["days", "level"])
1379
- ]),
1380
- n("div", gl, [
1381
- n("div", bl, A(l(d)("inventory.ingredient.threshold.stockIsStaple")), 1)
1382
- ])
1383
- ])
1384
- ])
1385
- ])
1386
- ]),
1387
- l(m).mustUsePoTemplate && e.mode === l(q).CREATE ? (c(), w("div", hl, [
1388
- n("div", _l, [
1389
- n("div", xl, [
1390
- s(ke, null, {
1391
- default: g(() => [
1392
- n("div", kl, A(l(d)("inventory.ingredient.purchaseOrderTemplates.title")), 1)
1393
- ]),
1394
- _: 1
1395
- }),
1396
- s(Ne, {
1397
- variant: "secondary",
1398
- "text-color": "primary",
1399
- "border-color": "primary",
1400
- "prepend-icon": "add",
1401
- onClick: Ct
1402
- })
1403
- ]),
1404
- n("div", Tl, A(l(d)("inventory.ingredient.purchaseOrderTemplates.description")), 1)
1405
- ]),
1406
- Ie.value.length > 0 ? (c(), w("div", wl, [
1407
- n("div", Vl, [
1408
- (c(!0), w(ee, null, de(Ie.value, (I) => (c(), O(ze, {
1409
- key: I.value,
1410
- label: I.label,
1411
- variant: "info",
1412
- compact: ""
1413
- }, null, 8, ["label"]))), 128))
1414
- ])
1415
- ])) : z("", !0)
1416
- ])) : z("", !0),
1417
- l(m).enableWastageTemplate && e.mode === l(q).CREATE ? (c(), w("div", Il, [
1418
- n("div", Fl, [
1419
- n("div", Sl, [
1420
- s(ke, null, {
1421
- default: g(() => [
1422
- n("div", Cl, A(l(d)("inventory.ingredient.wastageTemplates.title")), 1)
1423
- ]),
1424
- _: 1
1425
- }),
1426
- s(Ne, {
1427
- variant: "secondary",
1428
- "text-color": "primary",
1429
- "border-color": "primary",
1430
- "prepend-icon": "add",
1431
- onClick: At
1432
- })
1433
- ]),
1434
- n("div", Al, A(l(d)("inventory.ingredient.wastageTemplates.description")), 1)
1435
- ]),
1436
- Fe.value.length > 0 ? (c(), w("div", $l, [
1437
- n("div", El, [
1438
- (c(!0), w(ee, null, de(Fe.value, (I) => (c(), O(ze, {
1439
- key: I.value,
1440
- label: I.label,
1441
- variant: "info",
1442
- compact: ""
1443
- }, null, 8, ["label"]))), 128))
1444
- ])
1445
- ])) : z("", !0)
1446
- ])) : z("", !0),
1447
- l(m).enableClosingTemplate && e.mode === l(q).CREATE ? (c(), w("div", Ml, [
1448
- n("div", Ul, [
1449
- n("div", Pl, [
1450
- s(ke, null, {
1451
- default: g(() => [
1452
- n("div", Rl, A(l(d)("inventory.ingredient.closingTemplates.title")), 1)
1453
- ]),
1454
- _: 1
1455
- }),
1456
- s(Ne, {
1457
- variant: "secondary",
1458
- "text-color": "primary",
1459
- "border-color": "primary",
1460
- "prepend-icon": "add",
1461
- onClick: $t
1462
- })
1463
- ]),
1464
- n("div", Bl, A(l(d)("inventory.ingredient.closingTemplates.description")), 1)
1465
- ]),
1466
- et.value.length > 0 ? (c(), w("div", Ol, [
1467
- n("div", Dl, [
1468
- (c(!0), w(ee, null, de(et.value, (I) => (c(), O(ze, {
1469
- key: I.value,
1470
- label: I.label,
1471
- variant: "info",
1472
- compact: ""
1473
- }, null, 8, ["label"]))), 128))
1474
- ])
1475
- ])) : z("", !0)
1476
- ])) : z("", !0),
1477
- n("div", null, [
1478
- s(yn, {
1479
- entity: "inventorySku",
1480
- modelValue: Z.value,
1481
- "onUpdate:modelValue": t[12] || (t[12] = (I) => Z.value = I)
1482
- }, null, 8, ["modelValue"])
1483
- ])
1484
- ];
1485
- }),
1486
- _: 1
1487
- }, 8, ["disabled"]);
1488
- };
1489
- }
1490
- }), zl = { class: "flex flex-col gap-32" }, Ll = {
1491
- key: 0,
1492
- class: "flex justify-between items-center"
1493
- }, jl = { class: "flex gap-4" }, Wl = /* @__PURE__ */ pe({
1494
- __name: "IngredientDialog",
1495
- props: {
1496
- show: { type: Boolean },
1497
- sku: {},
1498
- mode: { default: q.READ }
1499
- },
1500
- emits: ["update:show"],
1501
- setup(W) {
1502
- 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(
1503
- () => {
1504
- var b;
1505
- return _.isEnabled && _.netSuiteItemBySkuId.has((b = i.sku) == null ? void 0 : b._id);
1506
- }
1507
- ), $ = h(() => {
1508
- switch (i.mode) {
1509
- case q.READ:
1510
- return "";
1511
- case q.UPDATE:
1512
- return u("inventory.ingredient.update.title");
1513
- case q.CREATE:
1514
- return u("inventory.ingredient.create.title");
1515
- }
1516
- return "";
1517
- }), v = h(() => {
1518
- switch (i.mode) {
1519
- case q.READ:
1520
- return "";
1521
- case q.UPDATE:
1522
- return u("common.save");
1523
- case q.CREATE:
1524
- return u("common.add");
1525
- }
1526
- return "";
1527
- }), D = P(), R = P(!1);
1528
- async function fe() {
1529
- R.value = !0;
1530
- try {
1531
- await k.createSku(a.value);
1532
- const b = k.skuByCode[a.value.code];
1533
- 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({
1534
- title: u("inventory.common.success"),
1535
- message: u("inventory.ingredient.create.success", { name: a.value.name }),
1536
- type: "success"
1537
- });
1538
- } catch (b) {
1539
- b instanceof yt || o.open({
1540
- title: u("inventory.ingredient.create.error.title"),
1541
- message: u("inventory.ingredient.create.error.message"),
1542
- type: "error"
1543
- });
1544
- } finally {
1545
- R.value = !1;
1546
- }
1547
- }
1548
- async function le() {
1549
- R.value = !0;
1550
- try {
1551
- await k.updateSku(a.value), R.value = !1, p.value = !1, o.open({
1552
- title: u("inventory.common.success"),
1553
- message: u("inventory.ingredient.update.success", { name: a.value.name }),
1554
- type: "success"
1555
- });
1556
- } catch (b) {
1557
- b instanceof yt || o.open({
1558
- title: u("inventory.ingredient.update.error.title"),
1559
- message: u("inventory.ingredient.update.error.message"),
1560
- type: "error"
1561
- });
1562
- } finally {
1563
- R.value = !1;
1564
- }
1565
- }
1566
- async function ue(b) {
1567
- var M, G, E, f;
1568
- try {
1569
- for (const L of m.value) {
1570
- const J = await F.getTemplate(L);
1571
- if (!J) {
1572
- console.warn(`Template with ID ${L} not found`);
1573
- continue;
1574
- }
1575
- if (!J.purchaseOrder.items.find(
1576
- (Z) => Z.sku._id === b._id
1577
- )) {
1578
- const Z = { amount: 1, precision: cn(b.unit) }, H = {
1579
- sku: b,
1580
- name: b.name,
1581
- code: b.code,
1582
- quantity: Z,
1583
- minimumQuantity: Z,
1584
- quantityStep: Z,
1585
- measurement: ((G = (M = b.unit) == null ? void 0 : M.measurements) == null ? void 0 : G[0]) || null
1586
- }, B = {
1587
- ...J,
1588
- purchaseOrder: {
1589
- ...J.purchaseOrder,
1590
- items: [...J.purchaseOrder.items, H]
1591
- }
1592
- };
1593
- (((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(
1594
- ({ totalCost: K, ...j }) => j
1595
- )), await F.updateTemplate(B), await new Promise((K) => setTimeout(K, 1e3));
1596
- }
1597
- }
1598
- } catch (L) {
1599
- o.open({
1600
- title: u("inventory.transfer.template.update.error"),
1601
- message: u("inventory.transfer.template.update.errorMessage"),
1602
- type: "error"
1603
- }), console.error("Error in updating transfer template", L);
1604
- }
1605
- }
1606
- async function oe(b) {
1607
- try {
1608
- for (const M of r.value) {
1609
- const G = await C.getTemplate(M);
1610
- if (!G) {
1611
- console.warn(`Wastage Template with ID ${M} not found`);
1612
- continue;
1613
- }
1614
- if (!G.items.find((f) => f.id === b._id)) {
1615
- const f = {
1616
- id: b._id,
1617
- name: b.name,
1618
- code: b.code,
1619
- type: "sku",
1620
- disabledMeasurements: []
1621
- }, L = {
1622
- ...G,
1623
- items: [...G.items, f]
1624
- };
1625
- await C.updateTemplate(L), await new Promise((J) => setTimeout(J, 1e3));
1626
- }
1627
- }
1628
- } catch (M) {
1629
- o.open({
1630
- title: u("inventory.wastage.template.update.error"),
1631
- message: u("inventory.wastage.template.update.errorMessage"),
1632
- type: "error"
1633
- }), console.error("Error in updating wastage template", M);
1634
- }
1635
- }
1636
- async function ae(b) {
1637
- try {
1638
- for (const M of y.value) {
1639
- const G = await U.getTemplate(M);
1640
- if (!G) {
1641
- console.warn(`Closing Template with ID ${M} not found`);
1642
- continue;
1643
- }
1644
- if (!G.items.find((f) => f.sku._id === b._id)) {
1645
- const f = {
1646
- sku: b
1647
- }, L = {
1648
- ...G,
1649
- items: [...G.items, f]
1650
- };
1651
- await U.updateTemplate(L), await new Promise((J) => setTimeout(J, 1e3));
1652
- }
1653
- }
1654
- } catch (M) {
1655
- o.open({
1656
- title: u("inventory.closing.template.update.error"),
1657
- message: u("inventory.closing.template.update.errorMessage"),
1658
- type: "error"
1659
- }), console.error("Error in updating closing template", M);
1660
- }
1661
- }
1662
- function te() {
1663
- var b, M;
1664
- (M = (b = D.value) == null ? void 0 : b.validateInputs) == null || M.call(b);
1665
- }
1666
- function se() {
1667
- switch (i.mode) {
1668
- case q.READ:
1669
- return;
1670
- case q.UPDATE:
1671
- return le();
1672
- case q.CREATE:
1673
- return fe();
1674
- }
1675
- }
1676
- function ye(b) {
1677
- m.value = b;
1678
- }
1679
- function ge(b) {
1680
- r.value = b;
1681
- }
1682
- function we(b) {
1683
- y.value = b;
1684
- }
1685
- return (b, M) => {
1686
- const G = T("FmChip"), E = T("FmButton"), f = T("FmSideSheet");
1687
- return c(), O(f, {
1688
- "model-value": l(p),
1689
- "onUpdate:modelValue": M[3] || (M[3] = (L) => ut(p) ? p.value = L : null),
1690
- header: $.value,
1691
- "close-button": "",
1692
- "dismiss-away": "",
1693
- "max-width": 500
1694
- }, {
1695
- "side-sheet-footer": g(() => [
1696
- n("div", jl, [
1697
- s(E, {
1698
- loading: R.value,
1699
- label: v.value,
1700
- onClick: te
1701
- }, null, 8, ["loading", "label"]),
1702
- s(E, {
1703
- disabled: R.value,
1704
- label: l(u)("common.close"),
1705
- variant: "tertiary",
1706
- onClick: M[2] || (M[2] = (L) => p.value = !1)
1707
- }, null, 8, ["disabled", "label"])
1708
- ])
1709
- ]),
1710
- default: g(() => [
1711
- n("div", zl, [
1712
- V.value ? (c(), w("div", Ll, [
1713
- s(G, {
1714
- label: "Managed by Netsuite",
1715
- compact: ""
1716
- }),
1717
- s(tn, {
1718
- readonly: "",
1719
- sku: b.sku,
1720
- settingOptions: l(_).skuSettingOptions
1721
- }, null, 8, ["sku", "settingOptions"])
1722
- ])) : z("", !0),
1723
- s(Nl, {
1724
- class: "w-full",
1725
- ref_key: "hasValidationExpose",
1726
- ref: D,
1727
- modelValue: l(a),
1728
- "onUpdate:modelValue": M[0] || (M[0] = (L) => ut(a) ? a.value = L : null),
1729
- mode: b.mode,
1730
- disabled: R.value,
1731
- purchaseOrderTemplateIds: m.value,
1732
- wastageTemplateIds: r.value,
1733
- closingTemplateIds: y.value,
1734
- "onClick:submit": M[1] || (M[1] = (L) => se()),
1735
- "onUpdate:purchaseOrderTemplateIds": ye,
1736
- "onUpdate:wastageTemplateIds": ge,
1737
- "onUpdate:closingTemplateIds": we
1738
- }, null, 8, ["modelValue", "mode", "disabled", "purchaseOrderTemplateIds", "wastageTemplateIds", "closingTemplateIds"])
1739
- ])
1740
- ]),
1741
- _: 1
1742
- }, 8, ["model-value", "header"]);
1743
- };
1744
- }
1745
- }), 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 = {
1746
- key: 0,
1747
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1748
- }, Gl = { key: 0 }, kt = /* @__PURE__ */ pe({
1749
- __name: "ImportIngredientItem",
1750
- props: {
1751
- type: {},
1752
- code: {},
1753
- name: {},
1754
- errors: {}
1755
- },
1756
- setup(W) {
1757
- return (i, k) => {
1758
- const d = T("FmIcon"), _ = T("FmTooltip");
1759
- return c(), w("div", ql, [
1760
- k[0] || (k[0] = n("div", null, "•", -1)),
1761
- n("div", Hl, [
1762
- n("div", Yl, [
1763
- n("div", {
1764
- class: ne({
1765
- "text-fm-color-system-error-300": i.errors.length
1766
- })
1767
- }, [
1768
- Je(A(i.name) + " ", 1),
1769
- i.type === "create" ? (c(), w("span", Kl, "(new)")) : z("", !0)
1770
- ], 2),
1771
- i.errors.length ? (c(), w("div", Gl, [
1772
- s(_, { "z-index": 50 }, {
1773
- content: g(() => [
1774
- n("ol", null, [
1775
- (c(!0), w(ee, null, de(i.errors, (F, C) => (c(), w("li", { key: C }, A(F), 1))), 128))
1776
- ])
1777
- ]),
1778
- default: g(() => [
1779
- s(d, {
1780
- name: "error",
1781
- size: "sm",
1782
- color: "system-error-300"
1783
- })
1784
- ]),
1785
- _: 1
1786
- })
1787
- ])) : z("", !0)
1788
- ]),
1789
- n("div", {
1790
- class: ne([
1791
- "fm-typo-en-body-sm-400",
1792
- {
1793
- "text-fm-color-system-error-200": i.errors.length,
1794
- "text-fm-color-typo-secondary": !i.errors.length
1795
- }
1796
- ])
1797
- }, A(i.code), 3)
1798
- ])
1799
- ]);
1800
- };
1801
- }
1802
- }), 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 = {
1803
- key: 2,
1804
- class: "shrink-0"
1805
- }, to = {
1806
- key: 0,
1807
- class: "flex flex-col"
1808
- }, no = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, lo = {
1809
- key: 0,
1810
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1811
- }, oo = { class: "fm-typo-en-body-lg-600" }, ao = /* @__PURE__ */ pe({
1812
- __name: "ImportIngredients",
1813
- setup(W) {
1814
- const i = P(null), k = Yt(), d = $e(), _ = P(!1), F = P(new Array()), C = P([]), U = P([]), o = h(
1815
- () => !!F.value.length || C.value.some((m) => m.errors.length) || U.value.some((m) => m.errors.length)
1816
- ), u = h(
1817
- () => !!C.value.length || !!U.value.length
1818
- ), { t: p } = ve();
1819
- async function a(m) {
1820
- F.value = [], C.value = [], U.value = [];
1821
- try {
1822
- _.value = !0;
1823
- const [r] = await Promise.all([
1824
- hn(m),
1825
- // fake buffer
1826
- new Promise(($) => setTimeout($, 1e3))
1827
- ]), y = r.SheetNames.find(($) => $);
1828
- if (!y) {
1829
- F.value.push(p("inventory.ingredient.import.fileError.noSheet"));
1830
- return;
1831
- }
1832
- const V = pn(r.Sheets[y]);
1833
- if (V.invalidExcel) {
1834
- F.value.push(V.invalidExcelMessage ?? p("inventory.ingredient.import.fileError.invalidExcel"));
1835
- return;
1836
- }
1837
- if (C.value = V.importCreateResult, U.value = V.importUpdateResult, !C.value.length && !U.value.length) {
1838
- F.value.push(p("inventory.ingredient.import.fileError.noData"));
1839
- return;
1840
- }
1841
- k.emitData(V);
1842
- } catch (r) {
1843
- d.open({
1844
- title: p("inventory.ingredient.import.fileError.unableToRead"),
1845
- message: r == null ? void 0 : r.message,
1846
- type: "error"
1847
- }), console.error("Error in reading file", r);
1848
- } finally {
1849
- F.value.length && d.open({
1850
- title: p("inventory.ingredient.import.fileError.invalidExcel"),
1851
- type: "error"
1852
- }), _.value = !1;
1853
- }
1854
- }
1855
- return Tt(i, (m) => {
1856
- m && a(m);
1857
- }), (m, r) => {
1858
- const y = T("FmCircularProgress"), V = T("FmIcon"), $ = T("FmButton");
1859
- return c(), w("div", Jl, [
1860
- n("div", Zl, A(l(p)("inventory.ingredient.import.uploadDescription")), 1),
1861
- s(_n, {
1862
- class: ne({
1863
- "w-full": !0,
1864
- "h-[200px]": !i.value
1865
- }),
1866
- accept: ".xlsx",
1867
- onFileUpload: r[0] || (r[0] = (v) => i.value = v),
1868
- label: l(p)("inventory.ingredient.import.uploadTemplate"),
1869
- "button-label": l(p)("inventory.ingredient.import.selectFile")
1870
- }, Ge({ _: 2 }, [
1871
- i.value ? {
1872
- name: "default",
1873
- fn: g(({ openFileDialog: v }) => [
1874
- n("div", Ql, [
1875
- n("div", {
1876
- class: ne([
1877
- "fm-corner-radius-md p-16 flex items-center gap-16",
1878
- {
1879
- "border border-fm-color-neutral-gray-100": _.value,
1880
- "border border-fm-color-neutral-gray-200": !_.value && !o.value,
1881
- "border border-fm-color-system-error-200": o.value
1882
- }
1883
- ])
1884
- }, [
1885
- _.value ? (c(), O(y, {
1886
- key: 0,
1887
- size: "md",
1888
- color: "neutral-gray-200"
1889
- })) : (c(), O(V, {
1890
- key: 1,
1891
- name: o.value ? "error" : "attach_file",
1892
- outline: "",
1893
- color: o.value ? "system-error-300" : void 0
1894
- }, null, 8, ["name", "color"])),
1895
- n("div", {
1896
- class: ne([
1897
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
1898
- {
1899
- "text-fm-color-typo-disabled": _.value,
1900
- "text-fm-color-typo-primary": !_.value
1901
- }
1902
- ])
1903
- }, [
1904
- n("div", Xl, A(i.value.name), 1)
1905
- ], 2),
1906
- _.value ? z("", !0) : (c(), w("div", eo, [
1907
- s($, {
1908
- label: l(p)("inventory.ingredient.import.replaceFile"),
1909
- variant: o.value ? "destructive" : "secondary",
1910
- "prepend-icon": o.value ? void 0 : "autorenew",
1911
- onClick: v
1912
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
1913
- ]))
1914
- ], 2),
1915
- F.value.length ? (c(), w("div", to, [
1916
- (c(!0), w(ee, null, de(F.value, (D, R) => (c(), w("div", {
1917
- key: R,
1918
- class: "flex gap-8 items-center"
1919
- }, [
1920
- s(V, {
1921
- name: "error",
1922
- size: "sm",
1923
- color: "system-error-300"
1924
- }),
1925
- n("div", no, A(D), 1)
1926
- ]))), 128))
1927
- ])) : z("", !0)
1928
- ])
1929
- ]),
1930
- key: "0"
1931
- } : void 0
1932
- ]), 1032, ["class", "label", "button-label"]),
1933
- u.value ? (c(), w("div", lo, [
1934
- n("div", oo, A(l(p)("inventory.ingredient.import.summary")), 1),
1935
- (c(!0), w(ee, null, de(C.value, (v) => (c(), O(kt, {
1936
- key: v.sku._id,
1937
- code: v.sku.code,
1938
- name: v.sku.name,
1939
- errors: v.errors,
1940
- type: "create"
1941
- }, null, 8, ["code", "name", "errors"]))), 128)),
1942
- (c(!0), w(ee, null, de(U.value, (v) => (c(), O(kt, {
1943
- key: v.sku._id,
1944
- code: v.sku.code,
1945
- name: v.sku.name,
1946
- errors: v.errors,
1947
- type: "update"
1948
- }, null, 8, ["code", "name", "errors"]))), 128))
1949
- ])) : z("", !0)
1950
- ]);
1951
- };
1952
- }
1953
- }), so = {
1954
- key: 0,
1955
- class: "flex items-center gap-1"
1956
- }, 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({
1957
- __name: "IngredientsView",
1958
- setup(W) {
1959
- const i = Ae(), k = Ee(), d = h(() => [
1960
- {
1961
- type: "string",
1962
- key: "skuCode",
1963
- entity: "sku",
1964
- values: i.skus.map((f) => f.code)
1965
- },
1966
- {
1967
- type: "string",
1968
- key: "skuUnitAbbrev",
1969
- entity: "sku",
1970
- values: i.units.map((f) => f.abbrev)
1971
- },
1972
- {
1973
- type: "string",
1974
- key: "status",
1975
- entity: "sku",
1976
- values: ["Active", "Inactive"]
1977
- }
1978
- ]), _ = P({
1979
- logic: "AND",
1980
- rules: [
1981
- {
1982
- property: "status",
1983
- operator: "$in",
1984
- value: ["Active"],
1985
- type: "string"
1986
- }
1987
- ]
1988
- }), F = h(
1989
- () => new Set(k.getAvailableItems(k.businessSubsidiaryId))
1990
- ), C = h(() => {
1991
- if (!_.value)
1992
- return i.skus;
1993
- const E = Tn.build(_.value);
1994
- return i.skus.filter((f) => k.isEnabled && le.value && F.value && !F.value.has(f._id) ? !1 : wn(
1995
- {
1996
- skuCode: f.code,
1997
- skuUnitAbbrev: f.unit.abbrev,
1998
- status: f.isInactive ? "Inactive" : "Active"
1999
- },
2000
- E
2001
- ));
2002
- }), U = qt(), o = Ze(), u = kn(), p = $e(), { t: a } = ve(), { createIngredient: m, updateIngredient: r } = Ke(), { ingredientDialogProps: y, ingredientViewLoading: V } = Xt(Ke()), { columnDefs: $ } = zn();
2003
- function v(E) {
2004
- switch (E) {
2005
- case "add":
2006
- return k.isEnabled ? void 0 : m();
2007
- case "import":
2008
- return M();
2009
- case "export-all":
2010
- return b();
2011
- case "export-filtered":
2012
- return b(C.value);
2013
- }
2014
- }
2015
- 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 = [
2016
- {
2017
- value: "import",
2018
- label: a("common.import")
2019
- },
2020
- {
2021
- value: "export-all",
2022
- label: a("inventory.ingredient.export.exportAll")
2023
- },
2024
- {
2025
- value: "export-filtered",
2026
- label: a("inventory.ingredient.export.exportFiltered")
2027
- }
2028
- ];
2029
- function ge(E) {
2030
- switch (se.value = !1, E) {
2031
- case "import":
2032
- return M();
2033
- case "export-all":
2034
- return b();
2035
- case "export-filtered":
2036
- return b(C.value);
2037
- }
2038
- }
2039
- const we = h(() => [
2040
- ...k.isEnabled ? [] : [
2041
- {
2042
- label: a("inventory.ingredient.create.title"),
2043
- value: "add",
2044
- isPrimary: !0,
2045
- prependIcon: "add"
2046
- }
2047
- ],
2048
- { label: a("common.import"), value: "import" },
2049
- { label: a("inventory.ingredient.export.exportAll"), value: "export-all", mobileOnly: !0 },
2050
- { label: a("inventory.ingredient.export.exportFiltered"), value: "export-filtered", mobileOnly: !0 }
2051
- ]);
2052
- function b(E) {
2053
- const f = vn(E);
2054
- p.open({
2055
- title: a("inventory.ingredient.export.success"),
2056
- message: a("inventory.ingredient.export.filename", [f]),
2057
- type: "success"
2058
- });
2059
- }
2060
- function M() {
2061
- o.open({
2062
- title: a("inventory.ingredient.import.title"),
2063
- contentComponent: ao,
2064
- overlay: !0,
2065
- closeButton: !0,
2066
- primaryActions: {
2067
- text: a("common.import"),
2068
- close: !1
2069
- },
2070
- secondaryActions: {
2071
- text: a("common.close"),
2072
- close: !0
2073
- },
2074
- tertiaryActions: {
2075
- text: a("inventory.ingredient.import.actions.downloadTemplate"),
2076
- close: !1,
2077
- variant: "plain"
2078
- }
2079
- }).onPrimary((E) => {
2080
- if (!E) {
2081
- p.open({
2082
- title: a("inventory.ingredient.import.error.noData"),
2083
- type: "error"
2084
- });
2085
- return;
2086
- }
2087
- if (!E.importCreateResult.length && !E.importUpdateResult.length) {
2088
- p.open({
2089
- title: a("inventory.ingredient.import.error.invalidContent"),
2090
- message: a("inventory.ingredient.import.error.noImportData"),
2091
- type: "error"
2092
- });
2093
- return;
2094
- }
2095
- if (E.importCreateResult.some((f) => f.errors.length) || E.importUpdateResult.some((f) => f.errors.length)) {
2096
- p.open({
2097
- title: a("inventory.ingredient.import.error.invalidContent"),
2098
- message: a("inventory.ingredient.import.error.hasErrors"),
2099
- type: "error"
2100
- });
2101
- return;
2102
- }
2103
- o.close(), G(E);
2104
- }).onTertiary(fn);
2105
- }
2106
- async function G(E) {
2107
- R.value = !0;
2108
- try {
2109
- const f = [
2110
- ...E.importCreateResult.map(({ sku: H }) => ({ type: "create", sku: H })),
2111
- ...E.importUpdateResult.map(({ sku: H }) => ({ type: "update", sku: H }))
2112
- ], L = 100;
2113
- let J = 0;
2114
- const me = () => {
2115
- J += L, p.open({
2116
- title: a("inventory.ingredient.import.progress", [
2117
- Math.min(J, f.length),
2118
- f.length
2119
- ])
2120
- });
2121
- }, Z = new Array();
2122
- for (const H of f.chunk(100)) {
2123
- me();
2124
- try {
2125
- const B = await i.importSkus({
2126
- create: H.filter((K) => K.type === "create").map((K) => K.sku),
2127
- update: H.filter((K) => K.type === "update").map((K) => K.sku)
2128
- });
2129
- Z.push(...B.errors);
2130
- } catch (B) {
2131
- Z.push(
2132
- ...H.map((K) => {
2133
- const j = {
2134
- module: Ht.enum.sku,
2135
- _id: K.sku._id,
2136
- name: K.sku.name,
2137
- message: (B == null ? void 0 : B.stack) ?? B
2138
- };
2139
- return {
2140
- data: K.sku,
2141
- error: [j]
2142
- };
2143
- })
2144
- );
2145
- }
2146
- }
2147
- p.open({
2148
- title: a("inventory.ingredient.import.success"),
2149
- type: "success"
2150
- }), Z.length && u.alert(
2151
- "Some operation failed",
2152
- X(
2153
- "div",
2154
- { class: "flex flex-col gap-8" },
2155
- Z.map(
2156
- (H) => X("div", { class: "flex flex-col" }, [
2157
- X("div", { class: "fm-typo-en-body-lg-600" }, `(${H.data.code}) ${H.data.name}`),
2158
- X(
2159
- "div",
2160
- { class: "fm-typo-en-body-lg-400" },
2161
- `${H.error.map((B) => (B == null ? void 0 : B.message) ?? "Unknown error").join(", ")}`
2162
- )
2163
- ])
2164
- )
2165
- )
2166
- );
2167
- } catch (f) {
2168
- p.open({
2169
- title: a("inventory.ingredient.import.error.failed"),
2170
- message: a("inventory.ingredient.import.error.systemMessage", [f == null ? void 0 : f.message]),
2171
- type: "error"
2172
- }), console.error("Error in importing skus", E, f);
2173
- } finally {
2174
- R.value = !1;
2175
- }
2176
- }
2177
- return (E, f) => {
2178
- const L = T("FmButton"), J = T("FmMenuItem"), me = T("FmMenu"), Z = T("FmSwitch"), H = T("FmTable"), B = T("FmCollapsibleTabs"), K = T("FmBottomSheet");
2179
- return c(), O(ln, {
2180
- title: l(a)("inventory.ingredient.title"),
2181
- actions: we.value,
2182
- "onClick:action": v
2183
- }, {
2184
- "header-end": g(() => [
2185
- s(me, { "close-on-click": !0 }, {
2186
- "menu-button": g(() => [
2187
- s(L, {
2188
- label: l(a)("common.export"),
2189
- "bg-color": "neutral-gray-100",
2190
- "text-color": "neutral-gray-400"
2191
- }, null, 8, ["label"])
2192
- ]),
2193
- default: g(() => [
2194
- s(J, {
2195
- label: l(a)("inventory.ingredient.export.exportAll"),
2196
- onClick: f[0] || (f[0] = (j) => b())
2197
- }, null, 8, ["label"]),
2198
- s(J, {
2199
- label: l(a)("inventory.ingredient.export.exportFiltered"),
2200
- onClick: f[1] || (f[1] = (j) => b(C.value))
2201
- }, null, 8, ["label"])
2202
- ]),
2203
- _: 1
2204
- })
2205
- ]),
2206
- default: g(() => [
2207
- n("div", {
2208
- class: ne([
2209
- "flex flex-col gap-8 max-h-full",
2210
- {
2211
- "p-0": oe.value,
2212
- "px-24 ": !oe.value
2213
- }
2214
- ])
2215
- }, [
2216
- s(xn, {
2217
- searchable: "",
2218
- search: D.value,
2219
- "onUpdate:search": f[3] || (f[3] = (j) => D.value = j),
2220
- filterable: "",
2221
- "filter-attributes": d.value,
2222
- filter: _.value,
2223
- "onUpdate:filter": f[4] || (f[4] = (j) => _.value = j)
2224
- }, {
2225
- default: g(() => [
2226
- l(k).isEnabled ? (c(), w("div", so, [
2227
- n("span", ro, A(l(a)("inventory.integration.netsuite.subsidiaryHierarchy.filtering")), 1),
2228
- s(rn),
2229
- s(De, null, {
2230
- default: g(() => [
2231
- s(Z, {
2232
- modelValue: le.value,
2233
- "onUpdate:modelValue": f[2] || (f[2] = (j) => le.value = j)
2234
- }, null, 8, ["modelValue"])
2235
- ]),
2236
- _: 1
2237
- })
2238
- ])) : z("", !0)
2239
- ]),
2240
- _: 1
2241
- }, 8, ["search", "filter-attributes", "filter"]),
2242
- (c(), O(H, {
2243
- key: JSON.stringify(_.value),
2244
- style: Nt(l(te).tableHeight),
2245
- "column-defs": l($),
2246
- "row-data": C.value,
2247
- "search-value": D.value,
2248
- columnVisibility: {
2249
- netsuiteSubsidiary: l(k).isEnabled
2250
- },
2251
- loading: (!l(U)._currentLocation || fe.value) && l(k).isReady,
2252
- "loading-text": l(a)("inventory.common.loading"),
2253
- onRowClick: f[5] || (f[5] = (j) => l(r)(j.original)),
2254
- "page-size": ae.value
2255
- }, {
2256
- "list-row": g((j) => [
2257
- s(bn, {
2258
- row: j,
2259
- onRowClick: l(r)
2260
- }, Ge({
2261
- default: g((be) => {
2262
- var Me, Ue, Pe, he, _e, ce, Ve, Ie, xe, Fe;
2263
- return [
2264
- n("div", io, [
2265
- n("div", uo, [
2266
- s(l(_t), {
2267
- render: (Pe = (Ue = (Me = be.code) == null ? void 0 : Me.column) == null ? void 0 : Ue.columnDef) == null ? void 0 : Pe.cell,
2268
- props: (_e = (he = be.code) == null ? void 0 : he.getContext) == null ? void 0 : _e.call(he)
2269
- }, null, 8, ["render", "props"])
2270
- ]),
2271
- n("div", mo, [
2272
- s(l(_t), {
2273
- render: (Ie = (Ve = (ce = be.name) == null ? void 0 : ce.column) == null ? void 0 : Ve.columnDef) == null ? void 0 : Ie.cell,
2274
- props: (Fe = (xe = be.name) == null ? void 0 : xe.getContext) == null ? void 0 : Fe.call(xe)
2275
- }, null, 8, ["render", "props"])
2276
- ])
2277
- ])
2278
- ];
2279
- }),
2280
- _: 2
2281
- }, [
2282
- R.value ? {
2283
- name: "loading-text",
2284
- fn: g(() => [
2285
- n("div", null, A(l(a)("inventory.ingredient.table.importing")), 1)
2286
- ]),
2287
- key: "0"
2288
- } : void 0
2289
- ]), 1032, ["row", "onRowClick"])
2290
- ]),
2291
- _: 1
2292
- }, 8, ["style", "column-defs", "row-data", "search-value", "columnVisibility", "loading", "loading-text", "page-size"]))
2293
- ], 2),
2294
- (c(), O(mt, { to: "body" }, [
2295
- s(Wl, zt(Lt(l(y))), null, 16)
2296
- ])),
2297
- (c(), O(mt, { to: "body" }, [
2298
- s(K, {
2299
- "dismiss-away": "",
2300
- modelValue: se.value,
2301
- "onUpdate:modelValue": f[7] || (f[7] = (j) => se.value = j)
2302
- }, {
2303
- default: g(() => [
2304
- s(B, {
2305
- class: "pb-8",
2306
- items: ye,
2307
- "onUpdate:modelValue": f[6] || (f[6] = (j) => ge(j))
2308
- })
2309
- ]),
2310
- _: 1
2311
- }, 8, ["modelValue"])
2312
- ]))
2313
- ]),
2314
- _: 1
2315
- }, 8, ["title", "actions"]);
2316
- };
2317
- }
2318
- });
2319
- export {
2320
- jo as default
2321
- };