@feedmepos/mf-inventory-portal 1.2.64 → 1.2.66-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/{App-apJIvz1w.js → App-BUNonuLz.js} +82 -78
  2. package/dist/{ApprovalView-CnT6gEI8.js → ApprovalView-BlS1tfbh.js} +6 -6
  3. package/dist/{BindingsDialog-DLEGDbV2.js → BindingsDialog-tRpsVTm0.js} +5 -5
  4. package/dist/{BindingsPicker-1Xt1vCu9.js → BindingsPicker-CUvkqcAG.js} +3 -3
  5. package/dist/{BindingsTable-_0cOM0Kx.js → BindingsTable-B86pWYMk.js} +5 -5
  6. package/dist/{ClosingDraftView-DsVPsN87.js → ClosingDraftView-gMVnQcWw.js} +226 -224
  7. package/dist/ClosingHistoryView-DhbE1pEl.js +1147 -0
  8. package/dist/{ClosingTemplateView-DB3F1wul.js → ClosingTemplateView-Ywbdj05y.js} +15 -15
  9. package/dist/{DeliveryOrderPrintPreview-CglCMgHc.js → DeliveryOrderPrintPreview-BPhVNc_r.js} +7 -7
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-MMPTJodu.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BrPh_Nvx.js} +16 -16
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CCID5O2Y.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CkUwLhut.js} +3 -3
  12. package/dist/{FmMultiselectDialog-B8xFmCsH.js → FmMultiselectDialog-C6E_KMFO.js} +1 -1
  13. package/dist/{FmMultiselectDialog-lQM1qEEW.js → FmMultiselectDialog-DBXpkw5b.js} +16 -16
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BLDz8wwK.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D-ZqJ8sU.js} +23 -22
  15. package/dist/{ImportView-DeC-MPFn.js → ImportView-DV1e51qk.js} +7 -7
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BGDZlmsr.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DkQL7hK2.js} +1 -1
  17. package/dist/{IngredientGroupView-CuFwQ8Bo.js → IngredientGroupView-CdXGO34J.js} +6 -6
  18. package/dist/{IngredientsView-CfloqEqn.js → IngredientsView-D2qffNiJ.js} +26 -25
  19. package/dist/{IntegrationView-CFU0yG6C.js → IntegrationView-RFJIHXQv.js} +19 -18
  20. package/dist/{InventoryBindingForm-i7eNurS2.js → InventoryBindingForm-CPn-IXgg.js} +1 -1
  21. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-zOo9YVJe.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-0Vrih8D5.js} +17 -16
  22. package/dist/{InventoryBindingSummary-BbHLCdjj.js → InventoryBindingSummary-B_WUQ6By.js} +1 -1
  23. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-NEPqmkHR.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BmDuR4Yb.js} +5 -5
  24. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-DhIHSpzG.js +93 -0
  25. package/dist/{PublishView-CbwCLtph.js → PublishView-BtTSOUyL.js} +9 -9
  26. package/dist/{PurchaseOrderPrintPreview-DLhgjhHB.js → PurchaseOrderPrintPreview-CxhMPx5u.js} +11 -11
  27. package/dist/{ReceiveRequestView-CE2aQR-o.js → ReceiveRequestView-CsqEjf7r.js} +144 -142
  28. package/dist/RecipeView-DASoba97.js +1558 -0
  29. package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-mvRR4CrP.js +254 -0
  30. package/dist/StockView-B4Km4DgB.js +2395 -0
  31. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-D0BDdq4d.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Cki-LAZR.js} +1 -1
  32. package/dist/{SupplierView-wSzWjZLY.js → SupplierView-CrzFvBIx.js} +21 -20
  33. package/dist/{SurchargeView-G8OyE60y.js → SurchargeView-BoNWpxFY.js} +7 -7
  34. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-CROQL761.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-Dcp5vZPM.js} +3 -3
  35. package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-IAknr-ye.js +292 -0
  36. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-D1AGDeEP.js → TransferDetails.vue_vue_type_script_setup_true_lang-D9aNX0oM.js} +131 -130
  37. package/dist/{TransferTemplateView-CVfi8jsk.js → TransferTemplateView-DwIU0paO.js} +23 -22
  38. package/dist/UnitCostHistoryView-Bjs4RwyR.js +651 -0
  39. package/dist/UnitDisplayControl.vue_vue_type_script_setup_true_lang-BH0PxivU.js +137 -0
  40. package/dist/{UnitView-Dn3nuQHm.js → UnitView-BbQ0jOgS.js} +12 -10
  41. package/dist/{WarehouseView-GSxQ_Ev2.js → WarehouseView-DzPttKzE.js} +6 -6
  42. package/dist/WastageTemplateView-CxyZz5JC.js +2327 -0
  43. package/dist/api/adjustment-template.d.ts +1 -0
  44. package/dist/api/closing.d.ts +2 -0
  45. package/dist/api/inventory.d.ts +126 -36
  46. package/dist/api/netsuite.d.ts +8 -1
  47. package/dist/api/stock.d.ts +5 -1
  48. package/dist/api/unit-cost-history.d.ts +28 -0
  49. package/dist/{app-CYbiMVcX.js → app-EoCCjoRh.js} +9021 -7945
  50. package/dist/app.d.ts +236 -0
  51. package/dist/app.js +1 -1
  52. package/dist/{closing-template-Dq16W8vW.js → closing-template-O_hzhisU.js} +5 -1
  53. package/dist/components/TemplatePublishDialog.d.ts +1 -0
  54. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +37 -1
  55. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +14 -0
  56. package/dist/components/shell/inventory/binding-ui.vue.d.ts +16 -1
  57. package/dist/{date2-De3BHKh5.js → date2-CTHKdfXp.js} +1 -1
  58. package/dist/{dayjs.min-DxdfVXA-.js → dayjs.min-Ccv4NdEp.js} +16 -16
  59. package/dist/decimal-tRyklLh0.js +99 -0
  60. package/dist/{defineDeepModel-2n_afItE.js → defineDeepModel-rmOd66to.js} +1 -1
  61. package/dist/{duplicate-template-DM7YIgor.js → duplicate-template-k8Erwdzo.js} +1 -1
  62. package/dist/export-TmaGpV98.js +25 -0
  63. package/dist/{feature-_nNpSZuh.js → feature-D4-lt7R6.js} +94 -89
  64. package/dist/{format-time-from-id-D5HSMsS-.js → format-time-from-id-Cru7cG1h.js} +1 -1
  65. package/dist/{format-unit-display-CQUFDxVm.js → format-unit-display-DZDD796a.js} +16 -15
  66. package/dist/{import-export.helper-BoxczUsX.js → import-export.helper-BjzXGudc.js} +16 -15
  67. package/dist/{index-B6nDUCCe.js → index-BeEz64I1.js} +3 -3
  68. package/dist/{index-Cp_mpu5S.js → index-DKCY6354.js} +1471 -1412
  69. package/dist/{index-CdfF5GGW.js → index-gGbN4qbt.js} +1 -1
  70. package/dist/{lodash-2R7Rgorb.js → lodash-BSCFf0k7.js} +1 -1
  71. package/dist/{netsuite-Bss4fURp.js → netsuite-DwoCq3Mv.js} +92 -92
  72. package/dist/number-CEUoMyIk.js +138 -0
  73. package/dist/{purchase-order-template-CBSvv0b2.js → purchase-order-template-DWTdjo9l.js} +1 -1
  74. package/dist/router/name.d.ts +1 -0
  75. package/dist/rules-CyW1Bx31.js +98 -0
  76. package/dist/{stock-DMX_hH5c.js → stock-DYWJ4DZW.js} +28 -27
  77. package/dist/stock-Ds3GNgHG.js +75 -0
  78. package/dist/stores/feature.d.ts +2 -0
  79. package/dist/stores/integration/netsuite.d.ts +8 -1
  80. package/dist/stores/inventory.d.ts +120 -30
  81. package/dist/{supplier-Cf5HW15s.js → supplier-DwUb1oVo.js} +2 -2
  82. package/dist/{surcharge-CyReT8lG.js → surcharge-UTJFNBLN.js} +1 -1
  83. package/dist/tsconfig.app.tsbuildinfo +1 -1
  84. package/dist/{use-ingredient-select-dialog-BCyydlHR.js → use-ingredient-select-dialog-D8A3bPTe.js} +2 -2
  85. package/dist/{use-inventory-binding-dialog-WGQs-_2i.js → use-inventory-binding-dialog-DFmiAQ9d.js} +2 -2
  86. package/dist/{use-template-enabled-locations-2-B0nlqUjb.js → use-template-enabled-locations-2-snlITfW8.js} +2 -2
  87. package/dist/views/adjustment-template/wastage-template/table.d.ts +10 -1
  88. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +68 -12
  89. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +204 -36
  90. package/dist/views/closing-history/ClosingDetailDialog.vue.d.ts +23 -0
  91. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +8 -1
  92. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +96 -12
  93. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +96 -12
  94. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +18 -18
  95. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +14 -0
  96. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +32 -4
  97. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +28 -0
  98. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +169 -0
  99. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryBindingAlternative.vue.d.ts +43 -0
  100. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryBindingRule.vue.d.ts +25 -0
  101. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryRecipeBindingV2Field.vue.d.ts +125 -0
  102. package/dist/views/ingredients/components/inventory-binding/v2/components/InventorySkuBindingV2Field.vue.d.ts +129 -0
  103. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-alternative-table.d.ts +30 -0
  104. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-dialog.d.ts +4 -0
  105. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +8 -1
  106. package/dist/views/integration/components/netsuite/InventoryTransferIngredientTable.vue.d.ts +16 -2
  107. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +33 -5
  108. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +16 -2
  109. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +32 -4
  110. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +8 -1
  111. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +41 -6
  112. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +246 -36
  113. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +287 -42
  114. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +16 -0
  115. package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -0
  116. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +16 -2
  117. package/dist/views/stock/components/dialog/SnapshotRecalculationDialog.vue.d.ts +11 -0
  118. package/dist/views/stock/components/dialog/recalculationUtils.d.ts +16 -0
  119. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +16 -2
  120. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +16 -2
  121. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +16 -2
  122. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +8 -1
  123. package/dist/views/transfer-template/composables/use-netsuite-custom-field.d.ts +24 -3
  124. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +96 -12
  125. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +96 -12
  126. package/dist/views/unit-cost-history/UnitCostHistoryView.vue.d.ts +2 -0
  127. package/dist/views/unit-cost-history/components/UnitCostDetailsSideSheet.vue.d.ts +19 -0
  128. package/dist/views/unit-cost-history/components/UnitCostRecalculationDialog.vue.d.ts +11 -0
  129. package/dist/views/unit-cost-history/composables/use-unit-cost-history.d.ts +65 -0
  130. package/dist/{vue-i18n-DwS_fjo9.js → vue-i18n-CY4442Fb.js} +510 -510
  131. package/dist/{xlsx-9MOvXxhT.js → xlsx-Kc1XotGV.js} +1 -1
  132. package/dist/{xlsx.util-D1DdGA1N.js → xlsx.util-Dy4jmPyv.js} +1 -1
  133. package/package.json +1 -1
  134. package/dist/ClosingHistoryView-YrEVWvGu.js +0 -447
  135. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-BDVHkTSE.js +0 -116
  136. package/dist/RecipeView-B-gmrXHR.js +0 -646
  137. package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js +0 -251
  138. package/dist/StockView-BNe2_5bA.js +0 -2520
  139. package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CwV2luel.js +0 -263
  140. package/dist/WastageTemplateView-BG-y48uc.js +0 -2388
  141. package/dist/rules-T-fs8_4_.js +0 -327
  142. package/dist/stock-CFWu5bRA.js +0 -75
@@ -0,0 +1,2327 @@
1
+ import { ref as R, h as E, defineComponent as Y, resolveComponent as M, openBlock as A, createElementBlock as D, createElementVNode as _, normalizeClass as K, createTextVNode as re, toDisplayString as V, unref as k, createCommentVNode as z, createVNode as F, createBlock as O, Fragment as W, renderList as Q, computed as N, watch as ie, createSlots as Ve, withCtx as j, isRef as je, withModifiers as Je, normalizeStyle as qe, Teleport as Qe, normalizeProps as Xe, guardReactiveProps as Ze, mergeProps as Me } from "vue";
2
+ import { u as et, _ as tt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-mvRR4CrP.js";
3
+ import { useI18n as G, useCoreStore as Ue } from "@feedmepos/mf-common";
4
+ import { D as ae, R as B } from "./row-action.enum-BcW_L_nE.js";
5
+ import { _ as nt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CkUwLhut.js";
6
+ import { useDialog as X, useDialogChild as ot, useSnackbar as ue, FmButtonVariant as q, components as H, useProxiedModel as Le, useBreakpoints as st } from "@feedmepos/ui-library";
7
+ import { defineStore as Ne, storeToRefs as Be } from "pinia";
8
+ import { _ as at, F as le } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
9
+ import { u as ye, c as ze, a as Z, I as L, n as lt, G as pe } from "./app-EoCCjoRh.js";
10
+ import { F as J } from "./form-mode.enum-BKiNVH6A.js";
11
+ import { c as rt } from "./component-DpCUABT3.js";
12
+ import { f as it } from "./format-time-from-id-Cru7cG1h.js";
13
+ import { u as ce } from "./closing-template-O_hzhisU.js";
14
+ import { _ as Ee } from "./TemplatePublishDialog.vue_vue_type_script_setup_true_lang-IAknr-ye.js";
15
+ import { t as fe, a as Oe, d as He, s as We, r as ut } from "./xlsx.util-Dy4jmPyv.js";
16
+ import { f as ct, a as mt } from "./date2-CTHKdfXp.js";
17
+ import { u as dt } from "./netsuite-DwoCq3Mv.js";
18
+ import { F as pt } from "./FmDroppableField-J0xUsOTV.js";
19
+ import { u as ft } from "./duplicate-template-k8Erwdzo.js";
20
+ import { A as vt, R as Ke } from "./rules-CyW1Bx31.js";
21
+ import { d as yt } from "./defineDeepModel-rmOd66to.js";
22
+ import { u as ht } from "./use-template-enabled-locations-2-snlITfW8.js";
23
+ import { a as gt } from "./FmMultiselectDialog-DBXpkw5b.js";
24
+ import { _ as bt } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-Dcp5vZPM.js";
25
+ import { _ as _t } from "./_plugin-vue_export-helper-CHgC5LLL.js";
26
+ const me = Ne(
27
+ "wastageTable",
28
+ function() {
29
+ const { t: l } = G(), c = X(), v = ve(), d = R({}), i = R(new Array()), m = R(!1), o = ye(), t = ce(), s = R({}), r = R();
30
+ async function h() {
31
+ if (o._currentLocation)
32
+ try {
33
+ r.value = await t.getReasons();
34
+ } catch (u) {
35
+ console.log("Something went wrong when fetching reasons:", u);
36
+ }
37
+ }
38
+ function x() {
39
+ if (!r.value) return !1;
40
+ const e = o.locations.filter((g) => !!o.locationByDbName[g.dbName]), a = e.filter((g) => !!(s.value[g.dbName] || []).find(
41
+ (I) => I._id === r.value._id && (I.updatedAt ? I.updatedAt === r.value.updatedAt : I._rev === r.value._rev)
42
+ )).length;
43
+ return e.length > 0 && a === e.length;
44
+ }
45
+ function w(u) {
46
+ const e = {
47
+ title: u.name,
48
+ doc: u,
49
+ controller: {
50
+ publishAll: async (a) => {
51
+ const S = a || u.locations, g = await t.publishSingleDoc(
52
+ u._id,
53
+ S == null ? void 0 : S.map((y) => y.dbName)
54
+ );
55
+ return s.value = g.publishedRevByLocation || {}, s.value;
56
+ },
57
+ publishAtLocation: async (a) => {
58
+ const S = await t.publishSingleDoc(u._id, [
59
+ a.dbName
60
+ ]);
61
+ return s.value = S.publishedRevByLocation || {}, s.value;
62
+ },
63
+ unpublishAll: async (a) => {
64
+ const S = a || u.locations, g = await t.unpublishSingleDoc(
65
+ u._id,
66
+ S == null ? void 0 : S.map((y) => y.dbName)
67
+ );
68
+ return s.value = g.publishedRevByLocation || {}, s.value;
69
+ },
70
+ unpublishAtLocation: async (a) => {
71
+ const S = await t.unpublishSingleDoc(u._id, [
72
+ a.dbName
73
+ ]);
74
+ return s.value = S.publishedRevByLocation || {}, s.value;
75
+ }
76
+ },
77
+ initialPublishedRev: s.value,
78
+ locations: o.locations,
79
+ enabledLocations: u.locations
80
+ };
81
+ c.open({
82
+ title: "Publish template",
83
+ contentComponent: Ee,
84
+ contentComponentProps: e,
85
+ closeButton: !0,
86
+ minWidth: 700,
87
+ maxHeight: "80vh",
88
+ contentScrollable: !1,
89
+ primaryActions: {
90
+ text: l("common.close"),
91
+ close: !0,
92
+ variant: "tertiary"
93
+ }
94
+ });
95
+ }
96
+ function T() {
97
+ if (!r.value) return;
98
+ const u = {
99
+ title: "Adjustment Reasons",
100
+ doc: r.value,
101
+ controller: {
102
+ publishAll: async (e) => {
103
+ const a = await t.publishReasonDoc(
104
+ e == null ? void 0 : e.map((S) => S.dbName)
105
+ );
106
+ return s.value = a.publishedRevByLocation || {}, s.value;
107
+ },
108
+ publishAtLocation: async (e) => {
109
+ const a = await t.publishReasonDoc([e.dbName]);
110
+ return s.value = a.publishedRevByLocation || {}, s.value;
111
+ },
112
+ unpublishAll: async () => s.value,
113
+ unpublishAtLocation: async () => s.value
114
+ },
115
+ initialPublishedRev: s.value,
116
+ locations: o.locations,
117
+ enabledLocations: null,
118
+ hideUnpublish: !0
119
+ };
120
+ c.open({
121
+ title: "Publish reasons",
122
+ contentComponent: Ee,
123
+ contentComponentProps: u,
124
+ closeButton: !0,
125
+ minWidth: 700,
126
+ maxHeight: "80vh",
127
+ contentScrollable: !1,
128
+ primaryActions: {
129
+ text: l("common.close"),
130
+ close: !0,
131
+ variant: "tertiary"
132
+ }
133
+ });
134
+ }
135
+ async function $() {
136
+ if (i.value = [], !!o._currentLocation) {
137
+ m.value = !0;
138
+ try {
139
+ const [u, e, a] = await Promise.all([
140
+ t.readTemplates(),
141
+ t.getRecentPublishingJob(),
142
+ t.getRecentPublishInfo()
143
+ ]).delayed(1e3);
144
+ i.value = u, d.value = e, s.value = (a == null ? void 0 : a.publishedRevByLocation) || {}, await h();
145
+ } catch (u) {
146
+ console.log("Something went wrong when fetching templates:", u);
147
+ } finally {
148
+ m.value = !1;
149
+ }
150
+ }
151
+ }
152
+ async function b(u) {
153
+ if (!i.value.find((e) => e._id) && o._currentLocation) {
154
+ m.value = !0;
155
+ try {
156
+ const [e] = await Promise.all([
157
+ t.getTemplate(u),
158
+ new Promise((a) => setTimeout(a, 1e3))
159
+ ]);
160
+ i.value = [e];
161
+ } catch (e) {
162
+ console.log("Something went wrong when fetching templates:", e);
163
+ } finally {
164
+ m.value = !1;
165
+ }
166
+ }
167
+ }
168
+ function n(u, e) {
169
+ switch (e = ze(e), u) {
170
+ case B.Details:
171
+ return v.viewTemplate(e);
172
+ case B.Edit:
173
+ return v.updateTemplate(e);
174
+ case B.Delete:
175
+ return v.deleteTemplate(e, m, $);
176
+ case B.Publish:
177
+ return w(e);
178
+ case B.Duplicate:
179
+ return v.duplicateTemplate(e, m, $);
180
+ }
181
+ }
182
+ return {
183
+ columnDefs: [
184
+ {
185
+ id: "_id",
186
+ accessorKey: "_id",
187
+ header: () => l("inventory.adjustment.template.table.createdAt"),
188
+ cell(u) {
189
+ return it(`${u.getValue()}`);
190
+ },
191
+ enableSorting: !0
192
+ },
193
+ {
194
+ id: "name",
195
+ accessorKey: "name",
196
+ header: () => l("inventory.adjustment.template.table.name"),
197
+ enableSorting: !0,
198
+ size: 200
199
+ },
200
+ {
201
+ id: "noOfItems",
202
+ accessorKey: "items.length",
203
+ header: () => l("inventory.adjustment.template.table.noOfItems"),
204
+ enableSorting: !1,
205
+ meta: {
206
+ width: "10rem",
207
+ textAlign: "right"
208
+ }
209
+ },
210
+ {
211
+ id: "enabledLocations",
212
+ accessorKey: "locations.length",
213
+ header: () => l("inventory.adjustment.template.table.enabledOutlets"),
214
+ cell(u) {
215
+ var a;
216
+ const e = (a = u.row.original.locations) == null ? void 0 : a.length;
217
+ return e ? `${e}` : "All";
218
+ },
219
+ enableSorting: !1,
220
+ meta: {
221
+ width: "10rem",
222
+ textAlign: "right"
223
+ }
224
+ },
225
+ {
226
+ id: "status",
227
+ header: () => l("inventory.adjustment.template.table.status"),
228
+ enableSorting: !1,
229
+ cell(u) {
230
+ const e = u.row.original, S = (u.row.original.locations || o.locations).filter((C) => !!o.locationByDbName[C.dbName]), g = S.filter((C) => !!(s.value[C.dbName] || []).find(
231
+ (U) => U._id === e._id && (U.updatedAt ? U.updatedAt === e.updatedAt : U._rev === e._rev)
232
+ )).length, y = S.length > 0 && g === S.length;
233
+ return E(
234
+ "div",
235
+ {
236
+ class: "flex items-center gap-8"
237
+ },
238
+ E(
239
+ "div",
240
+ {
241
+ class: [
242
+ "fm-status-badge",
243
+ y ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
244
+ ]
245
+ },
246
+ y ? "Published" : "Unpublished"
247
+ )
248
+ );
249
+ }
250
+ },
251
+ {
252
+ id: "action",
253
+ cell(u) {
254
+ const e = u.row.original, a = [
255
+ ae[B.Edit],
256
+ ae[B.Duplicate],
257
+ ae[B.Delete],
258
+ ae[B.Publish]
259
+ ];
260
+ return rt(a, (S) => n(S, e));
261
+ },
262
+ enableSorting: !1,
263
+ size: 40,
264
+ meta: {
265
+ cellClass: "",
266
+ headerClass: ""
267
+ }
268
+ }
269
+ ],
270
+ recentPublish: d,
271
+ templates: i,
272
+ reasons: r,
273
+ isReasonPublished: x,
274
+ showReasonPublishDialog: T,
275
+ loading: m,
276
+ fetchTemplates: $,
277
+ loadTemplate: b
278
+ };
279
+ }
280
+ );
281
+ var he = /* @__PURE__ */ ((p) => (p.Ingredients = "Ingredients", p))(he || {});
282
+ function Ye(p, l, c) {
283
+ var d, i, m;
284
+ const v = [];
285
+ if (p.type == L.Enum.sku) {
286
+ const o = new Set(p.disabledMeasurements), t = (d = l.sku) == null ? void 0 : d.find((s) => s._id === p.id);
287
+ if (t) {
288
+ const s = {
289
+ type: p.type,
290
+ code: p.code,
291
+ name: p.name,
292
+ unit: t.unit.abbrev,
293
+ enabled: !o.has(t.unit._id)
294
+ };
295
+ v.push(
296
+ s,
297
+ ...t.unit.measurements.map((r) => ({
298
+ unit: r.abbrev,
299
+ enabled: !o.has(r.id)
300
+ }))
301
+ );
302
+ }
303
+ }
304
+ return p.type == L.Enum.recipe && ((i = l.recipe) != null && i.find((t) => t._id === p.id)) && v.push(p), p.type == L.Enum.menu && ((m = c == null ? void 0 : c.modules.item) != null && m.find((t) => t._id === p.id)) && v.push(p), v;
305
+ }
306
+ function Ge() {
307
+ return [
308
+ {
309
+ id: "code",
310
+ name: "Code"
311
+ },
312
+ {
313
+ id: "type",
314
+ name: "Type"
315
+ },
316
+ {
317
+ id: "name",
318
+ name: "Name"
319
+ },
320
+ {
321
+ id: "unit",
322
+ name: "Unit"
323
+ },
324
+ {
325
+ id: "enabled",
326
+ name: "Enabled (Unit)"
327
+ }
328
+ ];
329
+ }
330
+ function xt(p) {
331
+ var s;
332
+ const l = Ue(), c = Z(), v = c.menu.cache, d = l.currentBusiness.value, m = (s = p.map((r) => {
333
+ var b;
334
+ const h = r.items.flatMap(
335
+ (n) => Ye(n, c.state.inventory, v)
336
+ ), x = Ge(), w = [
337
+ ["Template ID", r._id],
338
+ ["Template name", r.name],
339
+ ["Business name", d == null ? void 0 : d.name],
340
+ ["Business ID", d == null ? void 0 : d._id],
341
+ ["Menu version", d == null ? void 0 : d.menuVersion],
342
+ [
343
+ "Locations",
344
+ ...(b = r.locations) != null && b.length ? r.locations.map((n) => `${n.name} (${n.dbName})`) : ["All"]
345
+ ],
346
+ // ['Reference', template.ref ?? ''],
347
+ [],
348
+ x.map((n) => n.name),
349
+ ...h.map((n) => x.map((f) => n[f.id]))
350
+ ], T = x.map((n) => `system:${n.id}`), $ = fe(w, T);
351
+ return { name: r.name, sheet: $ };
352
+ }).reduce(
353
+ (r, h) => {
354
+ var w;
355
+ const x = h.name.slice(0, 12);
356
+ return (w = r.sheetOccurence)[x] ?? (w[x] = 0), r.sheetOccurence[x] += 1, r.sheets[`${x} (${r.sheetOccurence[x]})`] = h.sheet, r;
357
+ },
358
+ {
359
+ sheets: {},
360
+ sheetOccurence: {}
361
+ }
362
+ )) == null ? void 0 : s.sheets, o = `${d == null ? void 0 : d.name} adjustment templates (${ct(/* @__PURE__ */ new Date())}).xlsx`, t = Oe(m);
363
+ return He(t, o), o;
364
+ }
365
+ function wt() {
366
+ var b;
367
+ const p = Ue(), l = Z(), c = dt(), v = (b = l.state.inventory.sku) == null ? void 0 : b[0];
368
+ if (!v)
369
+ throw new Error("No inventory items");
370
+ const i = Ye(
371
+ {
372
+ type: L.Enum.sku,
373
+ code: v.code,
374
+ id: v._id,
375
+ name: v.name
376
+ },
377
+ l.state.inventory,
378
+ l.menu.cache
379
+ )[0], m = p.currentBusiness.value, o = Ge(), t = [
380
+ ["Template ID (leave empty to create new)", ""],
381
+ ["Template Name", "New template"],
382
+ ["Business name", m == null ? void 0 : m.name],
383
+ ["Business ID", m == null ? void 0 : m._id],
384
+ ["Menu version", m == null ? void 0 : m.menuVersion],
385
+ [
386
+ "Location codes (leave empty to enable all)",
387
+ "Example outlet (restaurant_xxx)",
388
+ "Example outlet 2 (restaurant_xxx)"
389
+ ],
390
+ // ['Reference:'],
391
+ [],
392
+ o.map((n) => n.name),
393
+ o.map((n) => i[n.id])
394
+ ], s = o.map((n) => `system:${n.id}`), r = fe(t, s), h = c.isEnabled ? c.state.setting.childItems ?? [] : [], x = h.reduce(
395
+ (n, f) => {
396
+ var g, y;
397
+ const u = (g = c.netSuiteItemIdToSkuId.get(f.parentNetSuiteId)) == null ? void 0 : g[0], e = (y = c.netSuiteMeasurementIdToMeasurementId.get(
398
+ f.unitOfMeasureId
399
+ )) == null ? void 0 : y[0];
400
+ if (!f.externalId)
401
+ return n;
402
+ if (!u)
403
+ return console.error(`Item ${f.externalId} cannot be mapped to parent FdoInventorySku.`, f), n;
404
+ const a = l.skuById[u], S = a.unit.measurements.find((C) => C.id === e);
405
+ return S ? (n[f.externalId] = {
406
+ sku: a,
407
+ measurement: S
408
+ }, n) : (console.error(
409
+ `Item ${f.externalId} found parent FdoInventorySku of ${a.code} ${a.name} but the measurement of netsuite id ${f.unitOfMeasureId} cannot be found.`,
410
+ f
411
+ ), n);
412
+ },
413
+ {}
414
+ ), w = fe(
415
+ [
416
+ ...l.skus.flatMap((n) => [
417
+ [n.code, n.name, n.unit.abbrev, !0],
418
+ ...n.unit.measurements.map((u) => [
419
+ "",
420
+ "",
421
+ u.abbrev,
422
+ !u.abbrev.toLocaleLowerCase("en-us").includes("inactive")
423
+ ])
424
+ ]),
425
+ ...Object.entries(x).map(([n, { sku: f, measurement: u }]) => [
426
+ f.code,
427
+ f.name,
428
+ u.abbrev,
429
+ !u.abbrev.toLocaleLowerCase("en-us").includes("inactive"),
430
+ n
431
+ ])
432
+ ],
433
+ [
434
+ "Code",
435
+ "Type",
436
+ "Name",
437
+ "Units",
438
+ "Enabled (true/false)",
439
+ ...h.length ? ["Netsuite Parent"] : []
440
+ ]
441
+ ), T = Oe({
442
+ Template: r,
443
+ Ingredients: w
444
+ }), $ = `${m == null ? void 0 : m.name} transfer templates import.xlsx`;
445
+ return He(T, $), $;
446
+ }
447
+ function Tt(p) {
448
+ if (!p.length || `${p[0]}`.toLocaleLowerCase() === "all")
449
+ return [];
450
+ const l = /(.*) \(((warehouse_|restaurant_).{24,})\)/, v = ye().locationByDbName;
451
+ return p.map((d) => {
452
+ const i = new Array(), m = d.trim(), o = l.exec(m);
453
+ if (!o)
454
+ return i.push(`Enabled location value of ${m} cannot be read.`), {
455
+ errors: i
456
+ };
457
+ const t = o[1], s = o[2], r = v[s];
458
+ return r ? (t !== r.name && i.push(
459
+ `Location id ${s} has non-matching name. Found ${t} but expected ${r.name}`
460
+ ), {
461
+ errors: i,
462
+ location: r
463
+ }) : (i.push(`Location (${t}) of id ${s} is not found.`), {
464
+ errors: i
465
+ });
466
+ });
467
+ }
468
+ function kt(p) {
469
+ const [
470
+ l,
471
+ c,
472
+ v,
473
+ d,
474
+ i,
475
+ m,
476
+ o,
477
+ t
478
+ ] = We(p);
479
+ return {
480
+ id: `${c[1] ?? ""}`.trim(),
481
+ name: `${v[1] ?? ""}`.trim(),
482
+ locations: o.slice(1).map((s) => `${s}`.trim()).filter((s) => s),
483
+ reference: `${t[1] ?? ""}`.trim()
484
+ };
485
+ }
486
+ function $t(p) {
487
+ const [
488
+ l,
489
+ c,
490
+ v,
491
+ d,
492
+ i,
493
+ m,
494
+ o,
495
+ t,
496
+ s,
497
+ ...r
498
+ ] = We(p);
499
+ if (!l || !l.length || l.some(($) => $.length && !$.startsWith("system:")))
500
+ throw new Error("Missing meta header. Excel file does not come from the template.");
501
+ const h = l.map(($) => $.split(":")[1]), w = [
502
+ "code",
503
+ "type",
504
+ "name",
505
+ "unit",
506
+ "enabled"
507
+ ].filter(($) => !h.includes($));
508
+ if (w.length)
509
+ throw new Error(
510
+ `Missing meta headers (${w.join()}). Excel file does not come from the template.`
511
+ );
512
+ return r.map(($, b) => {
513
+ const n = {};
514
+ for (const f in h) {
515
+ const u = h[f];
516
+ Object.assign(n, { [u]: $[f] });
517
+ }
518
+ return {
519
+ index: b,
520
+ data: n
521
+ };
522
+ });
523
+ }
524
+ function St(p) {
525
+ return p.reduce(
526
+ (l, c) => {
527
+ var i;
528
+ const v = c.data, d = c.index;
529
+ if (v.type == L.Enum.recipe)
530
+ l.result.push({ parent: c, children: [] });
531
+ else if (v.type == L.Enum.menu)
532
+ v.code ? l.result.push({ parent: c, children: [] }) : l.errors.push(`Menu item row ${d + 9} does not have a code.`);
533
+ else {
534
+ if (!v.unit) return l;
535
+ v.code ? l.result.push({ parent: c, children: [] }) : l.result.length ? (i = l.result.at(-1)) == null || i.children.push(c) : l.errors.push(`Cannot find parent for row ${d + 9}`);
536
+ }
537
+ return l;
538
+ },
539
+ { result: new Array(), errors: new Array() }
540
+ );
541
+ }
542
+ function It(p) {
543
+ var t;
544
+ const l = p.parent.data, c = new Array(), v = Z();
545
+ if (p.parent.data.type == L.Enum.menu) {
546
+ const s = v.menu.cache, r = (t = s == null ? void 0 : s.modules.item) == null ? void 0 : t.find((x) => x.code === l.code);
547
+ if (!r)
548
+ return c.push(`Cannot find menu module of id ${l.code}`), { errors: c };
549
+ const h = {
550
+ type: L.Enum.menu,
551
+ code: r.code,
552
+ id: r._id,
553
+ name: r.name ?? ""
554
+ };
555
+ return { errors: c, templateItem: h };
556
+ }
557
+ if (p.parent.data.type == L.Enum.recipe) {
558
+ const r = v.recipes.find((x) => x.name === l.name);
559
+ if (!r)
560
+ return c.push(`Cannot find recipe module of id ${l.code}`), { errors: c };
561
+ const h = {
562
+ type: L.Enum.recipe,
563
+ id: r._id,
564
+ name: r.name ?? ""
565
+ };
566
+ return { errors: c, templateItem: h };
567
+ }
568
+ const d = v.skuByCode[l.code ?? ""];
569
+ if (!d)
570
+ return c.push(`Cannot find ingredient of code [${l.code}] [${l.name}]`), { errors: c };
571
+ const i = {
572
+ type: L.Enum.sku,
573
+ code: l.code,
574
+ id: d._id,
575
+ name: l.name ?? "",
576
+ disabledMeasurements: []
577
+ }, m = d.unit.measurements.find((s) => s.abbrev === l.unit);
578
+ l.unit !== d.unit.abbrev && !m ? c.push(
579
+ `Cannot find measurement unit of ${l.unit} for (${l.code}) ${l.name}.`
580
+ ) : (!l.enabled || `${l.enabled}`.toLocaleLowerCase() === "false") && (i.disabledMeasurements ?? (i.disabledMeasurements = []), i.disabledMeasurements.push((m == null ? void 0 : m.id) ?? d.unit._id));
581
+ for (const s of p.children) {
582
+ const r = s.data, h = r.unit === d.unit.abbrev ? d.unit : void 0, x = d.unit.measurements.find((w) => w.abbrev === r.unit);
583
+ if (!x && !h) {
584
+ c.push(
585
+ `Cannot find measurement unit of ${r.unit} for (${l.code}) ${l.name}.`
586
+ );
587
+ continue;
588
+ }
589
+ (!r.enabled || `${r.enabled}`.toLocaleLowerCase() === "false") && (i.disabledMeasurements ?? (i.disabledMeasurements = []), i.disabledMeasurements.push((x == null ? void 0 : x.id) ?? (h == null ? void 0 : h._id) ?? ""));
590
+ }
591
+ const o = new Set(i.disabledMeasurements);
592
+ return o.has(d.unit._id) && d.unit.measurements.every((s) => o.has(s.id)) && c.push(`Ingredient ${d.code} - ${d.name} must have at least one unit enabled.`), { errors: c, templateItem: i };
593
+ }
594
+ function At(p) {
595
+ const l = p.SheetNames.filter(
596
+ (i) => !Object.values(he).map(String).includes(i)
597
+ ), v = me().templates, d = lt(v, "_id");
598
+ try {
599
+ return l.reduce(
600
+ (m, o) => {
601
+ const t = new Array(), s = p.Sheets[o], r = kt(s), h = Tt(r.locations), x = h.filter((u) => u.location).map((u) => u.location);
602
+ t.push(...h.flatMap((u) => u.errors));
603
+ const w = $t(s).filter((u) => {
604
+ const e = u.data;
605
+ return e.type == L.Enum.menu ? e.code : e.type == L.Enum.recipe ? e.name : u.data.code || u.data.unit;
606
+ }), T = St(w);
607
+ t.push(...T.errors);
608
+ const $ = T.result.map(
609
+ (u) => It(u)
610
+ );
611
+ t.push(...$.flatMap((u) => u.errors));
612
+ const b = $.filter((u) => u.templateItem).map((u) => u.templateItem);
613
+ if (r.id) {
614
+ const u = d[r.id];
615
+ if (!u) {
616
+ const a = {
617
+ type: pe.Enum.WASTAGE,
618
+ _id: r.id,
619
+ _rev: "",
620
+ name: r.name || `(unnamed from sheet ${o || "<unnamed sheet>"})`,
621
+ items: []
622
+ };
623
+ return t.push(`Template ID ${r.id} is not found.`), m.importUpdateResult.push({
624
+ type: "update",
625
+ original: a,
626
+ template: a,
627
+ excelSheetName: o,
628
+ errors: t
629
+ }), m;
630
+ }
631
+ const e = {
632
+ type: "update",
633
+ original: u,
634
+ template: {
635
+ ...u,
636
+ name: r.name,
637
+ locations: x.length ? x : null,
638
+ items: b
639
+ },
640
+ excelSheetName: o,
641
+ errors: t
642
+ };
643
+ return m.importUpdateResult.push(e), m;
644
+ }
645
+ const f = {
646
+ type: "create",
647
+ template: {
648
+ type: pe.Enum.WASTAGE,
649
+ name: r.name,
650
+ locations: x.length ? x : null,
651
+ items: b
652
+ },
653
+ excelSheetName: o,
654
+ errors: t
655
+ };
656
+ return m.importCreateResult.push(f), m;
657
+ },
658
+ {
659
+ invalidExcel: !1,
660
+ importCreateResult: new Array(),
661
+ importUpdateResult: new Array()
662
+ }
663
+ );
664
+ } catch (i) {
665
+ return {
666
+ invalidExcel: !0,
667
+ invalidExcelMessage: (i == null ? void 0 : i.message) ?? "Invalid excel",
668
+ importCreateResult: [],
669
+ importUpdateResult: []
670
+ };
671
+ }
672
+ }
673
+ const Ft = { class: "flex" }, Ct = { class: "flex flex-col flex-1" }, Rt = { class: "flex flex-col" }, Dt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, Mt = {
674
+ key: 0,
675
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
676
+ }, Et = { key: 0 }, Pt = { class: "ml-auto" }, Vt = { key: 0 }, Pe = /* @__PURE__ */ Y({
677
+ __name: "AdjustmentTemplateImportItem",
678
+ props: {
679
+ type: {},
680
+ name: {},
681
+ locations: {},
682
+ items: {},
683
+ errors: {}
684
+ },
685
+ setup(p) {
686
+ const l = p, { t: c } = G(), v = R(!1), d = () => {
687
+ l.errors.length && (v.value = !v.value);
688
+ };
689
+ return (i, m) => {
690
+ var t, s, r;
691
+ const o = M("FmIcon");
692
+ return A(), D("div", Ft, [
693
+ m[0] || (m[0] = _("div", null, "•", -1)),
694
+ _("div", Ct, [
695
+ _("div", {
696
+ class: K(["flex items-center gap-12 pl-8", {
697
+ "cursor-pointer": i.errors.length
698
+ }]),
699
+ onClick: d
700
+ }, [
701
+ _("div", Rt, [
702
+ _("div", Dt, [
703
+ _("div", {
704
+ class: K({
705
+ "text-fm-color-system-error-300": i.errors.length
706
+ })
707
+ }, [
708
+ re(V(i.name) + " ", 1),
709
+ i.type === "create" ? (A(), D("span", Mt, "(" + V(k(c)("inventory.closing.template.import.new")) + ")", 1)) : z("", !0)
710
+ ], 2),
711
+ i.errors.length ? (A(), D("div", Et, [
712
+ F(o, {
713
+ name: "error",
714
+ size: "sm",
715
+ color: "system-error-300"
716
+ })
717
+ ])) : z("", !0)
718
+ ]),
719
+ _("div", {
720
+ class: K([
721
+ "fm-typo-en-body-sm-400",
722
+ {
723
+ "text-fm-color-system-error-200": i.errors.length,
724
+ "text-fm-color-typo-secondary": !i.errors.length
725
+ }
726
+ ])
727
+ }, V((t = i.locations) != null && t.length ? k(c)("inventory.closing.template.import.nLocations", { count: (s = i.locations) == null ? void 0 : s.length }) : k(c)("inventory.closing.template.import.allLocations")) + ", " + V(k(c)("inventory.closing.template.import.nItems", { count: (r = i.items) == null ? void 0 : r.length })), 3)
728
+ ]),
729
+ _("div", Pt, [
730
+ i.errors.length ? (A(), O(o, {
731
+ key: 0,
732
+ name: v.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
733
+ size: "md"
734
+ }, null, 8, ["name"])) : z("", !0)
735
+ ])
736
+ ], 2),
737
+ v.value ? (A(), D("div", {
738
+ key: 0,
739
+ class: K(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
740
+ "text-fm-color-typo-secondary": !i.errors.length,
741
+ "text-fm-color-system-error-300": i.errors.length
742
+ }])
743
+ }, [
744
+ i.errors.length ? (A(), D("div", Vt, [
745
+ _("ol", null, [
746
+ (A(!0), D(W, null, Q(i.errors, (h, x) => (A(), D("li", { key: x }, V(h), 1))), 128))
747
+ ])
748
+ ])) : z("", !0)
749
+ ], 2)) : z("", !0)
750
+ ])
751
+ ]);
752
+ };
753
+ }
754
+ }), jt = { class: "flex flex-col gap-24" }, Ut = { class: "fm-typo-en-body-md-400" }, Lt = {
755
+ key: 0,
756
+ class: "flex items-center gap-8"
757
+ }, Nt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bt = { class: "flex flex-col gap-8" }, zt = { class: "line-clamp-2 text-ellipsis break-all" }, Ot = {
758
+ key: 2,
759
+ class: "shrink-0"
760
+ }, Ht = {
761
+ key: 0,
762
+ class: "flex flex-col"
763
+ }, Wt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Kt = {
764
+ key: 0,
765
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
766
+ }, Yt = { class: "fm-typo-en-body-lg-600" }, Gt = /* @__PURE__ */ Y({
767
+ __name: "AdjustmentTemplateImport",
768
+ setup(p) {
769
+ const l = R(null), c = ot(), v = ue(), d = R(!1), i = R(!1), m = R(new Array()), o = R([]), t = R([]), s = N(
770
+ () => !!m.value.length || o.value.some((w) => w.errors.length) || t.value.some((w) => w.errors.length)
771
+ ), r = N(
772
+ () => !!o.value.length || !!t.value.length
773
+ ), { t: h } = G();
774
+ async function x(w) {
775
+ m.value = [], o.value = [], t.value = [];
776
+ try {
777
+ d.value = !0;
778
+ const [T] = await Promise.all([
779
+ ut(w),
780
+ // fake buffer
781
+ new Promise((f) => setTimeout(f, 1e3))
782
+ ]);
783
+ if (!T.SheetNames.filter(
784
+ (f) => !Object.values(he).map(String).includes(f)
785
+ ).find((f) => f)) {
786
+ m.value.push(h("inventory.ingredient.import.fileError.noSheet"));
787
+ return;
788
+ }
789
+ const n = At(T);
790
+ if (n.invalidExcel) {
791
+ m.value.push(
792
+ n.invalidExcelMessage ?? h("inventory.ingredient.import.fileError.invalidExcel")
793
+ );
794
+ return;
795
+ }
796
+ if (o.value = n.importCreateResult, t.value = n.importUpdateResult, !o.value.length && !t.value.length) {
797
+ m.value.push(h("inventory.ingredient.import.fileError.noData"));
798
+ return;
799
+ }
800
+ c.emitData(n);
801
+ } catch (T) {
802
+ v.open({
803
+ title: h("inventory.ingredient.import.fileError.unableToRead"),
804
+ message: T == null ? void 0 : T.message,
805
+ type: "error"
806
+ }), console.error("Error in reading file", T);
807
+ } finally {
808
+ m.value.length && v.open({
809
+ title: h("inventory.ingredient.import.fileError.invalidExcel"),
810
+ type: "error"
811
+ }), d.value = !1;
812
+ }
813
+ }
814
+ return ie(l, (w) => {
815
+ w && x(w);
816
+ }), (w, T) => {
817
+ const $ = M("FmCircularProgress"), b = M("FmIcon"), n = M("FmButton");
818
+ return A(), D("div", jt, [
819
+ _("div", Ut, V(k(h)("inventory.adjustment.template.import.message")), 1),
820
+ i.value ? (A(), D("div", Lt, [
821
+ _("div", null, [
822
+ F($, {
823
+ size: "md",
824
+ color: "neutral-gray-200"
825
+ })
826
+ ]),
827
+ _("div", Nt, V(k(h)("inventory.formField.loading")), 1)
828
+ ])) : (A(), D(W, { key: 1 }, [
829
+ F(pt, {
830
+ class: K({
831
+ "w-full": !0,
832
+ "h-[200px]": !l.value
833
+ }),
834
+ accept: ".xlsx",
835
+ onFileUpload: T[0] || (T[0] = (f) => l.value = f),
836
+ label: k(h)("inventory.ingredient.import.uploadTemplate"),
837
+ "button-label": k(h)("inventory.ingredient.import.selectFile")
838
+ }, Ve({ _: 2 }, [
839
+ l.value ? {
840
+ name: "default",
841
+ fn: j(({ openFileDialog: f }) => [
842
+ _("div", Bt, [
843
+ _("div", {
844
+ class: K([
845
+ "fm-corner-radius-md p-16 flex items-center gap-16",
846
+ {
847
+ "border border-fm-color-neutral-gray-100": d.value,
848
+ "border border-fm-color-neutral-gray-200": !d.value && !s.value,
849
+ "border border-fm-color-system-error-200": s.value
850
+ }
851
+ ])
852
+ }, [
853
+ d.value ? (A(), O($, {
854
+ key: 0,
855
+ size: "md",
856
+ color: "neutral-gray-200"
857
+ })) : (A(), O(b, {
858
+ key: 1,
859
+ name: s.value ? "error" : "attach_file",
860
+ outline: "",
861
+ color: s.value ? "system-error-300" : void 0
862
+ }, null, 8, ["name", "color"])),
863
+ _("div", {
864
+ class: K([
865
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
866
+ {
867
+ "text-fm-color-typo-disabled": d.value,
868
+ "text-fm-color-typo-primary": !d.value
869
+ }
870
+ ])
871
+ }, [
872
+ _("div", zt, V(l.value.name), 1)
873
+ ], 2),
874
+ d.value ? z("", !0) : (A(), D("div", Ot, [
875
+ F(n, {
876
+ label: k(h)("inventory.ingredient.import.replaceFile"),
877
+ variant: s.value ? "destructive" : "secondary",
878
+ "prepend-icon": s.value ? void 0 : "autorenew",
879
+ onClick: f
880
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
881
+ ]))
882
+ ], 2),
883
+ m.value.length ? (A(), D("div", Ht, [
884
+ (A(!0), D(W, null, Q(m.value, (u, e) => (A(), D("div", {
885
+ key: e,
886
+ class: "flex gap-8 items-center"
887
+ }, [
888
+ F(b, {
889
+ name: "error",
890
+ size: "sm",
891
+ color: "system-error-300"
892
+ }),
893
+ _("div", Wt, V(u), 1)
894
+ ]))), 128))
895
+ ])) : z("", !0)
896
+ ])
897
+ ]),
898
+ key: "0"
899
+ } : void 0
900
+ ]), 1032, ["class", "label", "button-label"]),
901
+ r.value ? (A(), D("div", Kt, [
902
+ _("div", Yt, V(k(h)("inventory.ingredient.import.summary")), 1),
903
+ (A(!0), D(W, null, Q(o.value, (f, u) => (A(), O(Pe, {
904
+ key: u,
905
+ name: f.template.name,
906
+ locations: f.template.locations,
907
+ items: f.template.items,
908
+ errors: f.errors,
909
+ type: "create"
910
+ }, null, 8, ["name", "locations", "items", "errors"]))), 128)),
911
+ (A(!0), D(W, null, Q(t.value, (f) => (A(), O(Pe, {
912
+ key: f.template._id,
913
+ name: f.template.name,
914
+ locations: f.template.locations,
915
+ items: f.template.items,
916
+ errors: f.errors,
917
+ type: "update"
918
+ }, null, 8, ["name", "locations", "items", "errors"]))), 128))
919
+ ])) : z("", !0)
920
+ ], 64))
921
+ ]);
922
+ };
923
+ }
924
+ }), ve = Ne("wastageTemplateAction", () => {
925
+ const { t: p } = G(), l = X(), c = ue(), v = ce(), d = ft(), i = me(), { loading: m } = Be(i), o = R({});
926
+ function t() {
927
+ o.value = {
928
+ mode: J.CREATE,
929
+ show: !0,
930
+ "onUpdate:show"(e) {
931
+ o.value.show = e;
932
+ }
933
+ };
934
+ }
935
+ function s(e) {
936
+ o.value = {
937
+ mode: J.UPDATE,
938
+ modelValue: e,
939
+ show: !0,
940
+ "onUpdate:show"(a) {
941
+ o.value.show = a;
942
+ }
943
+ };
944
+ }
945
+ function r(e, a, S) {
946
+ l.open({
947
+ title: `Confirm deleting template ${e.name}?`,
948
+ message: "Deleted template can no longer be retrieved",
949
+ primaryActions: {
950
+ text: "Delete",
951
+ variant: q.Destructive,
952
+ close: !0
953
+ },
954
+ secondaryActions: {
955
+ text: "Cancel",
956
+ variant: q.Plain,
957
+ close: !0
958
+ }
959
+ }).onPrimary(async () => {
960
+ c.open({
961
+ title: `Deleting ${e.name}`,
962
+ type: "info"
963
+ });
964
+ try {
965
+ a.value = !0;
966
+ const [g] = await Promise.allSettled([
967
+ v.deleteTemplate(e),
968
+ new Promise((y) => setTimeout(y, 1e3))
969
+ ]);
970
+ if (g.status === "rejected") throw g.reason;
971
+ c.open({
972
+ title: `Deleted "${e.name}"`,
973
+ type: "success"
974
+ });
975
+ } catch (g) {
976
+ c.open({
977
+ title: `Unable to delete "${e.name}"`,
978
+ message: g.message,
979
+ type: "error"
980
+ });
981
+ } finally {
982
+ a.value = !1, S();
983
+ }
984
+ });
985
+ }
986
+ function h(e, a, S) {
987
+ l.open({
988
+ title: `Confirm unpublishing template "${e.name}"?`,
989
+ message: "Unpublished template will no longer be available at locations",
990
+ primaryActions: {
991
+ text: "Unpublish",
992
+ variant: q.Destructive,
993
+ close: !0
994
+ },
995
+ secondaryActions: {
996
+ text: "Cancel",
997
+ variant: q.Plain,
998
+ close: !0
999
+ }
1000
+ }).onPrimary(async () => {
1001
+ c.open({
1002
+ title: `Unpublishing "${e.name}"`,
1003
+ type: "info"
1004
+ });
1005
+ try {
1006
+ a.value = !0;
1007
+ const [g] = await Promise.allSettled([
1008
+ v.unpublishSingleDoc(e._id),
1009
+ new Promise((y) => setTimeout(y, 1e3))
1010
+ ]);
1011
+ if (g.status === "rejected") throw g.reason;
1012
+ c.open({
1013
+ title: `Unpublished "${e.name}"`,
1014
+ type: "success"
1015
+ });
1016
+ } catch (g) {
1017
+ c.open({
1018
+ title: `Unable to unpublish "${e.name}"`,
1019
+ message: `See error from server: ${g}`,
1020
+ type: "error"
1021
+ }), console.error("error on unpublishing adjustment template", g);
1022
+ } finally {
1023
+ a.value = !1, S();
1024
+ }
1025
+ });
1026
+ }
1027
+ function x(e, a, S) {
1028
+ let g;
1029
+ l.open({
1030
+ title: `Confirm duplicating template "${e.name}"?`,
1031
+ message: "Duplicated template can be edited after creation",
1032
+ primaryActions: {
1033
+ text: "Duplicate",
1034
+ variant: q.Destructive,
1035
+ close: !0
1036
+ },
1037
+ secondaryActions: {
1038
+ text: "Cancel",
1039
+ variant: q.Plain,
1040
+ close: !0
1041
+ },
1042
+ contentComponent: Y({
1043
+ props: ["modelValue"],
1044
+ emits: ["update:modelValue"],
1045
+ setup(y) {
1046
+ return () => E(H.FmTextField, {
1047
+ modelValue: y.modelValue,
1048
+ "onUpdate:modelValue": (C) => g = C,
1049
+ label: "New Template Name",
1050
+ size: "md",
1051
+ variant: "primary"
1052
+ });
1053
+ }
1054
+ })
1055
+ }).onPrimary(async () => {
1056
+ c.open({
1057
+ title: `Duplicating "${e.name}"`,
1058
+ type: "info"
1059
+ });
1060
+ try {
1061
+ a.value = !0;
1062
+ const [y] = await Promise.allSettled([
1063
+ d.duplicateWastagetemplate(e._id, g),
1064
+ new Promise((C) => setTimeout(C, 1e3))
1065
+ ]);
1066
+ if (y.status === "rejected") throw y.reason;
1067
+ c.open({
1068
+ title: `Duplicated "${e.name}"`,
1069
+ type: "success"
1070
+ });
1071
+ } catch (y) {
1072
+ c.open({
1073
+ title: `Unable to duplicate "${e.name}"`,
1074
+ message: `See error from server: ${y}`,
1075
+ type: "error"
1076
+ }), console.error("error on duplicating adjustment template", y);
1077
+ } finally {
1078
+ a.value = !1, S();
1079
+ }
1080
+ });
1081
+ }
1082
+ const w = R({});
1083
+ function T(e) {
1084
+ w.value = {
1085
+ template: e,
1086
+ show: !0,
1087
+ "onUpdate:show"(a) {
1088
+ w.value.show = a;
1089
+ },
1090
+ "onAction:edit"() {
1091
+ w.value.show = !1, s(ze(e));
1092
+ }
1093
+ };
1094
+ }
1095
+ function $() {
1096
+ if (!i.templates.length) {
1097
+ c.open({
1098
+ title: "No data to export",
1099
+ type: "error"
1100
+ });
1101
+ return;
1102
+ }
1103
+ const e = xt(i.templates);
1104
+ c.open({
1105
+ title: p("inventory.ingredient.export.success"),
1106
+ message: p("inventory.ingredient.export.filename", [e]),
1107
+ type: "success"
1108
+ });
1109
+ }
1110
+ function b() {
1111
+ i.loading || l.open({
1112
+ title: p("inventory.adjustment.template.import.title"),
1113
+ contentComponent: Gt,
1114
+ overlay: !0,
1115
+ closeButton: !0,
1116
+ primaryActions: {
1117
+ text: p("common.import"),
1118
+ close: !1
1119
+ },
1120
+ secondaryActions: {
1121
+ text: p("common.close"),
1122
+ close: !0
1123
+ },
1124
+ tertiaryActions: {
1125
+ text: p("inventory.ingredient.import.actions.downloadTemplate"),
1126
+ close: !1,
1127
+ variant: "plain"
1128
+ }
1129
+ }).onPrimary((e) => {
1130
+ if (!e) {
1131
+ c.open({
1132
+ title: p("inventory.ingredient.import.error.noData"),
1133
+ type: "error"
1134
+ });
1135
+ return;
1136
+ }
1137
+ if (!e.importCreateResult.length && !e.importUpdateResult.length) {
1138
+ c.open({
1139
+ title: p("inventory.ingredient.import.error.invalidContent"),
1140
+ message: p("inventory.ingredient.import.error.noImportData"),
1141
+ type: "error"
1142
+ });
1143
+ return;
1144
+ }
1145
+ if (e.importCreateResult.some((a) => a.errors.length) || e.importUpdateResult.some((a) => a.errors.length)) {
1146
+ c.open({
1147
+ title: p("inventory.ingredient.import.error.invalidContent"),
1148
+ message: p("inventory.ingredient.import.error.hasErrors"),
1149
+ type: "error"
1150
+ });
1151
+ return;
1152
+ }
1153
+ l.close(), n(e);
1154
+ }).onTertiary(wt);
1155
+ }
1156
+ async function n(e) {
1157
+ m.value = !0;
1158
+ try {
1159
+ const a = [
1160
+ ...e.importCreateResult.map(
1161
+ (C) => C.template
1162
+ ),
1163
+ ...e.importUpdateResult.map(
1164
+ (C) => C.template
1165
+ )
1166
+ ], S = 100;
1167
+ let g = 0;
1168
+ const y = () => {
1169
+ g += S, c.open({
1170
+ title: p("inventory.ingredient.import.progress", [
1171
+ Math.min(g, a.length),
1172
+ a.length
1173
+ ])
1174
+ });
1175
+ };
1176
+ for (const C of a.chunk(100))
1177
+ y(), await v.importTemplates(C);
1178
+ c.open({
1179
+ title: p("inventory.ingredient.import.success"),
1180
+ type: "success"
1181
+ });
1182
+ } catch (a) {
1183
+ c.open({
1184
+ title: p("inventory.ingredient.import.error.failed"),
1185
+ message: p("inventory.ingredient.import.error.systemMessage", [a == null ? void 0 : a.message]),
1186
+ type: "error"
1187
+ }), console.error("Error in importing skus", e, a);
1188
+ } finally {
1189
+ m.value = !1, i.fetchTemplates();
1190
+ }
1191
+ }
1192
+ const f = R({});
1193
+ function u() {
1194
+ f.value = {
1195
+ show: !0,
1196
+ "onUpdate:show"(e) {
1197
+ f.value.show = e;
1198
+ }
1199
+ };
1200
+ }
1201
+ return {
1202
+ createTemplate: t,
1203
+ viewTemplate: T,
1204
+ updateTemplate: s,
1205
+ deleteTemplate: r,
1206
+ unpublishTemplate: h,
1207
+ duplicateTemplate: x,
1208
+ exportTemplates: $,
1209
+ importTemplates: b,
1210
+ viewReason: u,
1211
+ templateDialogProps: o,
1212
+ templateDetailsProps: w,
1213
+ templateReasonProps: f
1214
+ };
1215
+ });
1216
+ function Jt(p) {
1217
+ const l = Z(), c = N(() => {
1218
+ const i = /* @__PURE__ */ new Map();
1219
+ for (const m of l.skus)
1220
+ i.set(m._id, m);
1221
+ return i;
1222
+ }), v = N(() => {
1223
+ const i = [];
1224
+ for (const m of p.items)
1225
+ m.type === "sku" && (c.value.get(m.id) || i.push(m));
1226
+ return i;
1227
+ });
1228
+ return {
1229
+ columnDefs: N(() => {
1230
+ const i = p.items.map((o) => {
1231
+ if (o.type !== "sku") return 0;
1232
+ const t = c.value.get(o.id);
1233
+ return t ? t.unit.measurements.length : 0;
1234
+ }).reduce((o, t) => Math.max(o, t), 0);
1235
+ return [
1236
+ {
1237
+ id: "Delete",
1238
+ header: "",
1239
+ cell(o) {
1240
+ const t = o.row.original;
1241
+ return E(
1242
+ "div",
1243
+ { class: "w-full flex justify-end" },
1244
+ E(H.FmButton, {
1245
+ class: "delete-button",
1246
+ key: t.id,
1247
+ type: "button",
1248
+ icon: "delete",
1249
+ variant: "tertiary",
1250
+ size: "md",
1251
+ disabled: p.disabled,
1252
+ onClick: () => {
1253
+ p.deleteItem(t);
1254
+ }
1255
+ })
1256
+ );
1257
+ },
1258
+ enableSorting: !1,
1259
+ size: 40,
1260
+ meta: {
1261
+ cellClass: "",
1262
+ headerClass: ""
1263
+ }
1264
+ },
1265
+ {
1266
+ id: "Name",
1267
+ header: () => "Name",
1268
+ enableSorting: !1,
1269
+ size: 400,
1270
+ minSize: 400,
1271
+ accessorFn: (o) => `${o.name} ${o.code}`,
1272
+ cell(o) {
1273
+ const t = o.row.original;
1274
+ return E("div", { class: "flex", style: { minWidth: "400px" } }, [
1275
+ E(
1276
+ "div",
1277
+ {
1278
+ class: "flex flex-col grow"
1279
+ },
1280
+ [
1281
+ E(
1282
+ H.FmTooltip,
1283
+ {
1284
+ content: t.name,
1285
+ placement: "top",
1286
+ variant: "plain",
1287
+ zIndex: 50
1288
+ },
1289
+ E(
1290
+ "span",
1291
+ {
1292
+ class: "flex-auto fm-typo-en-body-lg-400 text-fm-color-typo-primary line-clamp-1"
1293
+ },
1294
+ t.name
1295
+ )
1296
+ ),
1297
+ E(
1298
+ "span",
1299
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" },
1300
+ t.code ?? ""
1301
+ )
1302
+ ]
1303
+ ),
1304
+ E(
1305
+ "div",
1306
+ {
1307
+ class: "flex flex-col justify-center"
1308
+ },
1309
+ [
1310
+ E(
1311
+ H.FmChip,
1312
+ {
1313
+ compact: !0
1314
+ },
1315
+ t.type === "sku" ? "Ingredient" : t.type === "recipe" ? "Recipe" : "Menu"
1316
+ )
1317
+ ]
1318
+ )
1319
+ ]);
1320
+ }
1321
+ },
1322
+ {
1323
+ id: "Unit",
1324
+ header: () => "Enable unit",
1325
+ enableSorting: !1,
1326
+ minSize: 200,
1327
+ maxSize: 400,
1328
+ cell(o) {
1329
+ var r, h, x;
1330
+ const t = o.row.original;
1331
+ if (t.type !== "sku") return E("span", "N/A");
1332
+ const s = c.value.get(t.id);
1333
+ return E("div", { class: "flex items-center gap-32" }, [
1334
+ E(
1335
+ H.FmFormGroup,
1336
+ {
1337
+ value: s.unit._id,
1338
+ modelValue: !((r = t.disabledMeasurements) != null && r.includes(s.unit._id))
1339
+ },
1340
+ E(
1341
+ "div",
1342
+ {
1343
+ class: "flex items-center gap-4",
1344
+ style: { width: "120px" }
1345
+ },
1346
+ [
1347
+ E(H.FmCheckbox, {
1348
+ value: s.unit._id,
1349
+ modelValue: !((h = t.disabledMeasurements) != null && h.includes(s.unit._id)),
1350
+ disabled: p.disabled || !((x = t.disabledMeasurements) != null && x.includes(s.unit._id)) && s.unit.measurements.every(
1351
+ (w) => {
1352
+ var T;
1353
+ return (T = t.disabledMeasurements) == null ? void 0 : T.includes(w.id);
1354
+ }
1355
+ ),
1356
+ "onUpdate:modelValue"(w) {
1357
+ var T;
1358
+ if (console.log("active", w), w)
1359
+ p.updateItem({
1360
+ ...t,
1361
+ disabledMeasurements: (T = t.disabledMeasurements) == null ? void 0 : T.filter(
1362
+ ($) => $ !== s.unit._id
1363
+ )
1364
+ });
1365
+ else {
1366
+ const $ = t.disabledMeasurements ?? [];
1367
+ p.updateItem({
1368
+ ...t,
1369
+ disabledMeasurements: [...$, s.unit._id]
1370
+ });
1371
+ }
1372
+ }
1373
+ }),
1374
+ E(
1375
+ H.FmTooltip,
1376
+ { zIndex: 51 },
1377
+ {
1378
+ content() {
1379
+ return c.value.get(t.id).unit.abbrev;
1380
+ },
1381
+ default() {
1382
+ const w = c.value.get(t.id);
1383
+ return E(
1384
+ "div",
1385
+ { class: "line-clamp-2 fm-typo-en-body-lg-400" },
1386
+ w.unit.abbrev
1387
+ );
1388
+ }
1389
+ }
1390
+ )
1391
+ ]
1392
+ )
1393
+ ),
1394
+ ...Array.from({ length: Math.max(i, 0) }).map((w, T) => {
1395
+ var f, u, e, a;
1396
+ const $ = o.row.original, b = c.value.get($.id), n = b.unit.measurements[T];
1397
+ return n ? E(
1398
+ H.FmFormGroup,
1399
+ {
1400
+ modelValue: !((f = $.disabledMeasurements) != null && f.includes(n.id)),
1401
+ value: n.id
1402
+ },
1403
+ E(
1404
+ "div",
1405
+ {
1406
+ class: "flex items-center gap-4",
1407
+ style: { width: "120px" }
1408
+ },
1409
+ [
1410
+ E(H.FmCheckbox, {
1411
+ value: n.id,
1412
+ modelValue: !((u = $.disabledMeasurements) != null && u.includes(n.id)),
1413
+ disabled: p.disabled || !((e = $.disabledMeasurements) != null && e.includes(n.id)) && ((a = $.disabledMeasurements) == null ? void 0 : a.includes(b.unit._id)) && b.unit.measurements.filter((S) => S.id != n.id).every((S) => {
1414
+ var g;
1415
+ return (g = $.disabledMeasurements) == null ? void 0 : g.includes(S.id);
1416
+ }),
1417
+ "onUpdate:modelValue"(S) {
1418
+ var g;
1419
+ if (console.log("active", S), S)
1420
+ p.updateItem({
1421
+ ...$,
1422
+ disabledMeasurements: (g = $.disabledMeasurements) == null ? void 0 : g.filter(
1423
+ (y) => y !== n.id
1424
+ )
1425
+ });
1426
+ else {
1427
+ const y = $.disabledMeasurements ?? [];
1428
+ p.updateItem({
1429
+ ...$,
1430
+ disabledMeasurements: [...y, n.id]
1431
+ });
1432
+ }
1433
+ }
1434
+ }),
1435
+ E(
1436
+ H.FmTooltip,
1437
+ { zIndex: 51 },
1438
+ {
1439
+ content() {
1440
+ return n.abbrev;
1441
+ },
1442
+ default() {
1443
+ return E(
1444
+ "div",
1445
+ { class: "line-clamp-2 fm-typo-en-body-lg-400" },
1446
+ n.abbrev
1447
+ );
1448
+ }
1449
+ }
1450
+ )
1451
+ ]
1452
+ )
1453
+ ) : null;
1454
+ })
1455
+ ]);
1456
+ }
1457
+ }
1458
+ ];
1459
+ }),
1460
+ missingSKUs: v
1461
+ };
1462
+ }
1463
+ const qt = { class: "flex flex-col gap-16" }, Qt = { class: "flex items-center" }, Xt = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Zt = {
1464
+ key: 0,
1465
+ class: "flex flex-col gap-8 p-16 bg-fm-color-system-warning-100 border border-fm-color-system-warning-400 rounded-lg"
1466
+ }, en = { class: "fm-typo-en-title-xs-600 text-fm-color-system-warning-400 flex items-center gap-8" }, tn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary" }, nn = { class: "list-disc pl-20 mt-8" }, on = /* @__PURE__ */ Y({
1467
+ __name: "WastageTemplateItemTable",
1468
+ props: {
1469
+ modelValue: {},
1470
+ disabled: { type: Boolean }
1471
+ },
1472
+ emits: ["update:modelValue"],
1473
+ setup(p, { expose: l, emit: c }) {
1474
+ const v = p, d = R(v.modelValue), { t: i } = G(), m = c, o = Z(), t = X(), s = R(), r = R("");
1475
+ l({
1476
+ validateInputs: () => {
1477
+ var b, n;
1478
+ (n = (b = s.value) == null ? void 0 : b.validateInputs) == null || n.call(b);
1479
+ },
1480
+ resetInputsValidation: () => {
1481
+ var b, n;
1482
+ (n = (b = s.value) == null ? void 0 : b.resetInputsValidation) == null || n.call(b);
1483
+ },
1484
+ resetInputs: () => {
1485
+ var b, n;
1486
+ (n = (b = s.value) == null ? void 0 : b.resetInputs) == null || n.call(b);
1487
+ }
1488
+ });
1489
+ const h = Jt({
1490
+ updateItem: (b) => {
1491
+ d.value = d.value.map((n) => n.id !== b.id ? n : b), m("update:modelValue", T.value);
1492
+ },
1493
+ deleteItem: (b) => {
1494
+ d.value = d.value.filter((n) => n.id !== b.id), m("update:modelValue", T.value);
1495
+ },
1496
+ get items() {
1497
+ return d.value;
1498
+ },
1499
+ get disabled() {
1500
+ return v.disabled;
1501
+ }
1502
+ }), x = N(() => h.columnDefs.value), w = N(() => h.missingSKUs.value), T = N(() => {
1503
+ const b = new Set(w.value.map((n) => n.id));
1504
+ return d.value.filter((n) => !b.has(n.id));
1505
+ });
1506
+ ie(
1507
+ () => T.value,
1508
+ (b, n) => {
1509
+ w.value.length > 0 && JSON.stringify(b) !== JSON.stringify(n) && m("update:modelValue", b);
1510
+ },
1511
+ { immediate: !0 }
1512
+ );
1513
+ function $() {
1514
+ var g;
1515
+ const b = o.skus.map((y) => {
1516
+ var C, I;
1517
+ return {
1518
+ type: "sku",
1519
+ name: y.name,
1520
+ description: y.code,
1521
+ data: y,
1522
+ searchKeys: (C = y.customAttributes) != null && C.tag ? [(I = y.customAttributes) == null ? void 0 : I.tag] : void 0
1523
+ };
1524
+ }), n = o.recipes.map((y) => {
1525
+ var C, I;
1526
+ return {
1527
+ type: "recipe",
1528
+ name: y.name,
1529
+ description: "",
1530
+ data: y,
1531
+ searchKeys: (C = y.customAttributes) != null && C.tag ? [(I = y.customAttributes) == null ? void 0 : I.tag] : void 0
1532
+ };
1533
+ }), f = ((g = o.menu.cache) == null ? void 0 : g.modules.item.map((y) => ({
1534
+ type: "menu",
1535
+ name: y.name,
1536
+ description: `${y.code}`,
1537
+ data: y
1538
+ }))) ?? [], u = [...b, ...n, ...f].map((y) => {
1539
+ var I;
1540
+ const C = [y.type == "sku" ? "Ingredient" : y.type == "recipe" ? "Recipe" : "Menu"];
1541
+ if (y.type == "sku" || y.type == "recipe") {
1542
+ const U = (I = y.data.customAttributes) == null ? void 0 : I.tag;
1543
+ U && C.push(U);
1544
+ }
1545
+ return {
1546
+ label: y.name,
1547
+ sublabel: y.description,
1548
+ value: y,
1549
+ tags: C,
1550
+ searchKeys: y.searchKeys
1551
+ };
1552
+ }), e = /* @__PURE__ */ new Set();
1553
+ u.forEach((y) => {
1554
+ y.tags && y.tags.forEach((C) => {
1555
+ e.add(C);
1556
+ });
1557
+ });
1558
+ const a = e.size > 0 ? [
1559
+ {
1560
+ type: "string",
1561
+ key: "tags",
1562
+ entity: "item",
1563
+ values: Array.from(e)
1564
+ }
1565
+ ] : [], S = u.filter((y) => d.value.find((C) => C.id === y.value.data._id)).map((y) => y.value);
1566
+ t.open({
1567
+ title: i("inventory.closing.form.items.selectItem"),
1568
+ closeButton: !0,
1569
+ contentComponent: gt,
1570
+ contentComponentProps: {
1571
+ modelValue: S,
1572
+ items: u,
1573
+ virtualScroll: !0,
1574
+ filterAttributes: a
1575
+ },
1576
+ primaryActions: {
1577
+ text: i("common.confirm"),
1578
+ close: !0
1579
+ },
1580
+ secondaryActions: {
1581
+ text: i("common.close"),
1582
+ close: !0,
1583
+ variant: "tertiary"
1584
+ }
1585
+ }).onPrimary((y) => {
1586
+ const C = d.value ?? [], I = y.map((P) => {
1587
+ const U = C.find((ee) => ee.id === P.data._id);
1588
+ return U ? {
1589
+ ...U
1590
+ } : {
1591
+ id: P.data._id,
1592
+ name: P.name,
1593
+ code: P.description,
1594
+ type: P.type,
1595
+ disabledMeasurements: []
1596
+ };
1597
+ });
1598
+ I.sort((P, U) => P.name.localeCompare(U.name)), console.log(d.value), d.value = I, m("update:modelValue", T.value);
1599
+ });
1600
+ }
1601
+ return (b, n) => {
1602
+ const f = M("FmButton"), u = M("FmIcon"), e = M("FmTextField"), a = M("FmTable"), S = M("FmFormGroup");
1603
+ return A(), D("div", qt, [
1604
+ _("div", Qt, [
1605
+ _("div", Xt, V(k(i)("inventory.closing.form.items.title")), 1),
1606
+ F(f, {
1607
+ disabled: b.disabled,
1608
+ label: k(i)("inventory.closing.form.items.addItem"),
1609
+ "prepend-icon": "add",
1610
+ variant: "plain",
1611
+ class: "border-2 rounded-lg border-fm-color-primary",
1612
+ onClick: n[0] || (n[0] = (g) => $()),
1613
+ size: "md"
1614
+ }, null, 8, ["disabled", "label"])
1615
+ ]),
1616
+ w.value.length > 0 ? (A(), D("div", Zt, [
1617
+ _("div", en, [
1618
+ F(u, {
1619
+ name: "warning",
1620
+ size: "sm"
1621
+ }),
1622
+ n[3] || (n[3] = _("span", null, "Invalid items", -1))
1623
+ ]),
1624
+ _("div", tn, [
1625
+ re(" The following " + V(w.value.length) + " item(s) no longer exist in the system and have been excluded: ", 1),
1626
+ _("ul", nn, [
1627
+ (A(!0), D(W, null, Q(w.value, (g) => (A(), D("li", {
1628
+ key: g.id
1629
+ }, "(" + V(g.code) + ") " + V(g.name), 1))), 128))
1630
+ ])
1631
+ ])
1632
+ ])) : z("", !0),
1633
+ F(e, {
1634
+ placeholder: "Filter items",
1635
+ modelValue: r.value,
1636
+ "onUpdate:modelValue": n[2] || (n[2] = (g) => r.value = g)
1637
+ }, Ve({ _: 2 }, [
1638
+ r.value ? {
1639
+ name: "append",
1640
+ fn: j(() => [
1641
+ F(u, {
1642
+ name: "close",
1643
+ onClick: n[1] || (n[1] = (g) => r.value = ""),
1644
+ class: "cursor-pointer"
1645
+ })
1646
+ ]),
1647
+ key: "0"
1648
+ } : void 0
1649
+ ]), 1032, ["modelValue"]),
1650
+ (A(), O(a, {
1651
+ "search-value": r.value,
1652
+ "column-defs": x.value,
1653
+ "row-data": T.value,
1654
+ key: T.value.map((g) => g.id).join("."),
1655
+ "hide-footer": T.value.length <= 10,
1656
+ "page-size": Math.min(10, T.value.length)
1657
+ }, null, 8, ["search-value", "column-defs", "row-data", "hide-footer", "page-size"])),
1658
+ F(S, {
1659
+ "model-value": T.value.length,
1660
+ rules: [k(vt)(1)]
1661
+ }, null, 8, ["model-value", "rules"])
1662
+ ]);
1663
+ };
1664
+ }
1665
+ }), sn = { class: "flex flex-col gap-16" }, an = { class: "flex flex-col gap-24" }, ln = { class: "flex flex-col gap-16" }, rn = { class: "flex items-center" }, un = { class: "flex-1 fm-typo-en-title-sm-600" }, cn = /* @__PURE__ */ Y({
1666
+ __name: "WastageTemplateForm",
1667
+ props: {
1668
+ modelValue: {},
1669
+ disabled: { type: Boolean }
1670
+ },
1671
+ setup(p, { expose: l }) {
1672
+ const c = yt(), { t: v } = G(), {
1673
+ promptSelectLocations: d,
1674
+ columnDefs: i,
1675
+ rowData: m
1676
+ } = ht({
1677
+ getLocations() {
1678
+ return c.locations;
1679
+ },
1680
+ setLocations(t) {
1681
+ c.locations = t;
1682
+ }
1683
+ }), o = R();
1684
+ return l({
1685
+ validateInputs: () => {
1686
+ var t, s;
1687
+ (s = (t = o.value) == null ? void 0 : t.validateInputs) == null || s.call(t);
1688
+ },
1689
+ resetInputsValidation: () => {
1690
+ var t, s;
1691
+ (s = (t = o.value) == null ? void 0 : t.resetInputsValidation) == null || s.call(t);
1692
+ },
1693
+ resetInputs: () => {
1694
+ var t, s;
1695
+ (s = (t = o.value) == null ? void 0 : t.resetInputs) == null || s.call(t);
1696
+ }
1697
+ }), (t, s) => {
1698
+ const r = M("FmTextField"), h = M("FmButton"), x = M("FmTable"), w = M("FmForm");
1699
+ return A(), O(w, {
1700
+ ref_key: "formRef",
1701
+ ref: o,
1702
+ class: "flex flex-col gap-32",
1703
+ disabled: t.disabled
1704
+ }, {
1705
+ default: j(() => [
1706
+ _("div", sn, [
1707
+ _("div", an, [
1708
+ F(r, {
1709
+ label: k(v)("inventory.closing.form.name"),
1710
+ "label-mark": "required",
1711
+ modelValue: k(c).name,
1712
+ "onUpdate:modelValue": s[0] || (s[0] = (T) => k(c).name = T),
1713
+ rules: [k(Ke)()]
1714
+ }, null, 8, ["label", "modelValue", "rules"])
1715
+ ])
1716
+ ]),
1717
+ _("div", ln, [
1718
+ _("div", rn, [
1719
+ _("div", un, V(k(v)("inventory.closing.form.locations")), 1),
1720
+ F(h, {
1721
+ disabled: t.disabled,
1722
+ label: k(v)("inventory.closing.form.selectLocation"),
1723
+ "prepend-icon": "add",
1724
+ variant: "plain",
1725
+ class: "border-2 rounded-lg border-fm-color-primary",
1726
+ onClick: k(d)
1727
+ }, null, 8, ["disabled", "label", "onClick"])
1728
+ ]),
1729
+ F(x, {
1730
+ "column-defs": k(i),
1731
+ "row-data": k(m),
1732
+ "shrink-at": 9999,
1733
+ onRowClick: k(d),
1734
+ "hide-footer": ""
1735
+ }, null, 8, ["column-defs", "row-data", "onRowClick"])
1736
+ ]),
1737
+ F(on, {
1738
+ "model-value": k(c).items,
1739
+ "onUpdate:modelValue": s[1] || (s[1] = (T) => k(c).items = T)
1740
+ }, null, 8, ["model-value"])
1741
+ ]),
1742
+ _: 1
1743
+ }, 8, ["disabled"]);
1744
+ };
1745
+ }
1746
+ }), mn = { class: "flex items-center" }, dn = { class: "fm-typo-en-title-md-600" }, pn = { class: "flex justify-between" }, fn = { class: "fm-typo-en-body-lg-600" }, vn = { class: "flex flex-col gap-8" }, yn = { class: "flex flex-col gap-4" }, hn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, gn = { class: "flex items-center gap-8" }, bn = { class: "fm-typo-en-body-lg-600" }, _n = { class: "flex gap-4" }, xn = /* @__PURE__ */ Y({
1747
+ __name: "WastageTemplateDialog",
1748
+ props: {
1749
+ mode: {},
1750
+ modelValue: {},
1751
+ show: { type: Boolean }
1752
+ },
1753
+ emits: ["update:show", "submitted"],
1754
+ setup(p, { expose: l, emit: c }) {
1755
+ var u;
1756
+ const v = p, d = c, i = ce(), m = ue(), { t: o } = G(), t = Le(v, "show");
1757
+ function s() {
1758
+ return {
1759
+ _id: "",
1760
+ name: "",
1761
+ type: pe.Enum.WASTAGE,
1762
+ items: []
1763
+ };
1764
+ }
1765
+ const r = R(v.modelValue ?? s()), h = R(((u = v.modelValue) == null ? void 0 : u._id) ?? `${Math.random()}`);
1766
+ ie(
1767
+ () => v.show,
1768
+ (e) => {
1769
+ var a;
1770
+ e && (r.value = v.modelValue ?? s(), h.value = ((a = v.modelValue) == null ? void 0 : a._id) ?? `${Math.random()}`);
1771
+ }
1772
+ );
1773
+ const x = R(!1), w = N(() => {
1774
+ switch (v.mode) {
1775
+ case J.READ:
1776
+ return "";
1777
+ case J.CREATE:
1778
+ return o("inventory.adjustment.template.create.title");
1779
+ case J.UPDATE:
1780
+ return o("inventory.adjustment.template.update.title");
1781
+ }
1782
+ return "";
1783
+ }), T = R();
1784
+ l({
1785
+ validateInputs: () => {
1786
+ var e, a;
1787
+ (a = (e = T.value) == null ? void 0 : e.validateInputs) == null || a.call(e);
1788
+ },
1789
+ resetInputsValidation: () => {
1790
+ var e, a;
1791
+ (a = (e = T.value) == null ? void 0 : e.resetInputsValidation) == null || a.call(e);
1792
+ },
1793
+ resetInputs: () => {
1794
+ var e, a;
1795
+ (a = (e = T.value) == null ? void 0 : e.resetInputs) == null || a.call(e);
1796
+ }
1797
+ });
1798
+ async function $() {
1799
+ const e = r.value;
1800
+ if (e) {
1801
+ x.value = !0;
1802
+ try {
1803
+ await i.createTemplate(e), await new Promise((a) => setTimeout(a, 1e3)), m.open({
1804
+ title: o("inventory.adjustment.template.create.success"),
1805
+ message: o("inventory.adjustment.template.create.successMessage"),
1806
+ type: "success"
1807
+ }), d("update:show", !1), d("submitted");
1808
+ } catch (a) {
1809
+ m.open({
1810
+ title: o("inventory.adjustment.template.create.error"),
1811
+ message: o("inventory.adjustment.template.create.errorMessage"),
1812
+ type: "error"
1813
+ }), console.error("Error in creating adjustment template", a);
1814
+ } finally {
1815
+ x.value = !1;
1816
+ }
1817
+ }
1818
+ }
1819
+ async function b() {
1820
+ const e = r.value;
1821
+ if (e) {
1822
+ x.value = !0;
1823
+ try {
1824
+ await i.updateTemplate({
1825
+ ...e,
1826
+ _rev: e._rev ?? ""
1827
+ }), await new Promise((a) => setTimeout(a, 1e3)), m.open({
1828
+ title: o("inventory.adjustment.template.update.success"),
1829
+ message: o("inventory.adjustment.template.update.successMessage"),
1830
+ type: "success"
1831
+ }), d("update:show", !1), d("submitted");
1832
+ } catch (a) {
1833
+ m.open({
1834
+ title: o("inventory.adjustment.template.update.error"),
1835
+ message: o("inventory.adjustment.template.update.errorMessage"),
1836
+ type: "error"
1837
+ }), console.error("Error in updating adjustment template", a);
1838
+ } finally {
1839
+ x.value = !1;
1840
+ }
1841
+ }
1842
+ }
1843
+ function n() {
1844
+ switch (v.mode) {
1845
+ case J.CREATE:
1846
+ return $();
1847
+ case J.UPDATE:
1848
+ return b();
1849
+ }
1850
+ }
1851
+ function f() {
1852
+ var e, a;
1853
+ (a = (e = T.value) == null ? void 0 : e.validateInputs) == null || a.call(e);
1854
+ }
1855
+ return (e, a) => {
1856
+ const S = M("FmMenuDivider"), g = M("FmCard"), y = M("FmButton"), C = M("FmSideSheet");
1857
+ return A(), O(C, {
1858
+ modelValue: k(t),
1859
+ "onUpdate:modelValue": a[2] || (a[2] = (I) => je(t) ? t.value = I : null),
1860
+ "dismiss-away": "",
1861
+ "close-button": "",
1862
+ "max-width": 800
1863
+ }, {
1864
+ "side-sheet-header": j(() => [
1865
+ _("div", mn, [
1866
+ _("div", dn, V(w.value), 1)
1867
+ ])
1868
+ ]),
1869
+ default: j(() => [
1870
+ r.value.updatedAt ? (A(), D(W, { key: 0 }, [
1871
+ r.value.updatedAt ? (A(), O(g, {
1872
+ key: 0,
1873
+ variant: "outlined",
1874
+ class: "flex flex-col gap-8 px-12 py-16 mb-16"
1875
+ }, {
1876
+ default: j(() => {
1877
+ var I;
1878
+ return [
1879
+ _("div", pn, [
1880
+ _("div", fn, V(k(o)("inventory.transfer.template.details.templateSummary")), 1)
1881
+ ]),
1882
+ F(S),
1883
+ _("div", vn, [
1884
+ _("div", yn, [
1885
+ _("div", hn, V(k(o)("inventory.transfer.receiveRequest.details.updatedAt")), 1),
1886
+ _("div", gn, [
1887
+ _("div", bn, [
1888
+ re(V(k(mt)(r.value.updatedAt)) + " ", 1),
1889
+ (I = r.value.updatedBy) != null && I.name ? (A(), D(W, { key: 0 }, [
1890
+ re(" (" + V(r.value.updatedBy.name) + ") ", 1)
1891
+ ], 64)) : z("", !0)
1892
+ ]),
1893
+ F(bt, {
1894
+ "adjustment-id": r.value._id
1895
+ }, null, 8, ["adjustment-id"])
1896
+ ])
1897
+ ])
1898
+ ])
1899
+ ];
1900
+ }),
1901
+ _: 1
1902
+ })) : z("", !0)
1903
+ ], 64)) : z("", !0),
1904
+ (A(), O(cn, {
1905
+ class: "w-full",
1906
+ ref_key: "formRef",
1907
+ ref: T,
1908
+ onValidationSuccess: n,
1909
+ "model-value": r.value,
1910
+ "onUpdate:modelValue": a[0] || (a[0] = (I) => r.value = I),
1911
+ disabled: x.value,
1912
+ key: h.value
1913
+ }, null, 8, ["model-value", "disabled"]))
1914
+ ]),
1915
+ "side-sheet-footer": j(() => [
1916
+ _("div", _n, [
1917
+ F(y, {
1918
+ loading: x.value,
1919
+ label: k(o)("common.save"),
1920
+ onClick: f
1921
+ }, null, 8, ["loading", "label"]),
1922
+ F(y, {
1923
+ disabled: x.value,
1924
+ variant: "tertiary",
1925
+ label: k(o)("common.close"),
1926
+ onClick: a[1] || (a[1] = (I) => d("update:show", !1))
1927
+ }, null, 8, ["disabled", "label"])
1928
+ ])
1929
+ ]),
1930
+ _: 1
1931
+ }, 8, ["modelValue"]);
1932
+ };
1933
+ }
1934
+ }), wn = {};
1935
+ function Tn(p, l) {
1936
+ return A(), D("div");
1937
+ }
1938
+ const kn = /* @__PURE__ */ _t(wn, [["render", Tn]]), $n = { class: "flex flex-col gap-16" }, Sn = { class: "flex" }, In = { class: "flex gap-24" }, An = { class: "flex" }, Fn = { class: "flex-1" }, Cn = { class: "flex" }, Rn = { class: "flex gap-8 items-center justify-start" }, Dn = /* @__PURE__ */ Y({
1939
+ __name: "WastageTemplateReason",
1940
+ props: {
1941
+ show: { type: Boolean }
1942
+ },
1943
+ emits: ["update:show", "submitted"],
1944
+ setup(p, { emit: l }) {
1945
+ const c = p, v = Le(c, "show"), d = R(""), i = ue(), m = X(), o = R([]), t = l, s = me(), r = ce(), h = R(!1);
1946
+ ie(
1947
+ () => c.show,
1948
+ (n) => {
1949
+ var f;
1950
+ n && (o.value = ((f = s.reasons) == null ? void 0 : f.value) ?? []);
1951
+ }
1952
+ );
1953
+ const x = (n) => {
1954
+ if (o.value.indexOf(o.value[n]) === -1)
1955
+ return;
1956
+ const f = o.value[n];
1957
+ if (f.trim() === "") {
1958
+ o.value.splice(n, 1);
1959
+ return;
1960
+ }
1961
+ m.open({
1962
+ title: "Delete reason",
1963
+ message: `Are you sure you want to delete this reason? "${f}"`,
1964
+ primaryActions: {
1965
+ text: "Delete",
1966
+ close: !0,
1967
+ variant: "destructive"
1968
+ },
1969
+ secondaryActions: {
1970
+ text: "Cancel",
1971
+ close: !0,
1972
+ variant: "secondary"
1973
+ }
1974
+ }).onPrimary(() => {
1975
+ o.value.splice(n, 1);
1976
+ });
1977
+ }, w = () => {
1978
+ o.value.push("");
1979
+ const n = d.value.trim();
1980
+ if (n) {
1981
+ if (o.value.some((f) => f === n)) {
1982
+ i.open({
1983
+ title: "Reason already exists",
1984
+ message: "Please enter a different reason",
1985
+ type: "error"
1986
+ });
1987
+ return;
1988
+ }
1989
+ d.value = "";
1990
+ }
1991
+ }, T = async () => {
1992
+ const n = o.value.map((f) => f.trim()).filter((f) => f);
1993
+ if (s.reasons) {
1994
+ h.value = !0;
1995
+ try {
1996
+ await r.update({
1997
+ _id: s.reasons._id,
1998
+ _rev: s.reasons._rev,
1999
+ value: n
2000
+ }), i.open({
2001
+ title: "Reasons updated",
2002
+ message: "Reasons have been updated successfully",
2003
+ type: "success"
2004
+ }), t("update:show", !1), t("submitted");
2005
+ } catch {
2006
+ i.open({
2007
+ title: "Error updating reasons",
2008
+ message: "There was an error updating reasons",
2009
+ type: "error"
2010
+ });
2011
+ } finally {
2012
+ h.value = !1;
2013
+ }
2014
+ }
2015
+ }, $ = R(), b = () => {
2016
+ var n, f;
2017
+ (f = (n = $.value) == null ? void 0 : n.validateInputs) == null || f.call(n);
2018
+ };
2019
+ return (n, f) => {
2020
+ const u = M("FmButton"), e = M("FmAvatar"), a = M("FmTextField"), S = M("FmList"), g = M("FmForm"), y = M("FmSideSheet");
2021
+ return A(), O(y, {
2022
+ modelValue: k(v),
2023
+ "onUpdate:modelValue": f[0] || (f[0] = (C) => je(v) ? v.value = C : null),
2024
+ header: "Reason for wastage",
2025
+ "close-button": "",
2026
+ "dismiss-away": !h.value,
2027
+ "max-width": 500
2028
+ }, {
2029
+ default: j(() => [
2030
+ F(g, {
2031
+ ref_key: "formRef",
2032
+ ref: $,
2033
+ class: "flex flex-col gap-32",
2034
+ blameFormChildOnValidationFailed: "",
2035
+ onValidationSuccess: T
2036
+ }, {
2037
+ default: j(() => [
2038
+ _("div", $n, [
2039
+ _("div", Sn, [
2040
+ F(u, {
2041
+ class: "ml-auto px-5",
2042
+ variant: "primary",
2043
+ label: "Add new reason",
2044
+ size: "md",
2045
+ onClick: w
2046
+ })
2047
+ ])
2048
+ ]),
2049
+ _("div", In, [
2050
+ F(S, {
2051
+ class: "w-full",
2052
+ separator: ""
2053
+ }, {
2054
+ default: j(() => [
2055
+ (A(!0), D(W, null, Q(o.value, (C, I) => (A(), D("div", {
2056
+ key: I,
2057
+ class: "flex items-center gap-8 px-1 py-2"
2058
+ }, [
2059
+ _("div", An, [
2060
+ F(e, {
2061
+ initials: String(I + 1),
2062
+ size: "sm"
2063
+ }, null, 8, ["initials"])
2064
+ ]),
2065
+ _("div", Fn, [
2066
+ F(a, {
2067
+ class: "cursor-pointer text-fm-color-typo-tertiary",
2068
+ modelValue: o.value[I],
2069
+ "onUpdate:modelValue": (P) => o.value[I] = P,
2070
+ maxLength: 500,
2071
+ rules: [k(Ke)()]
2072
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "rules"])
2073
+ ]),
2074
+ _("div", Cn, [
2075
+ F(u, {
2076
+ variant: "tertiary",
2077
+ size: "md",
2078
+ "prepend-icon": "delete",
2079
+ onClick: (P) => x(I)
2080
+ }, null, 8, ["onClick"])
2081
+ ])
2082
+ ]))), 128))
2083
+ ]),
2084
+ _: 1
2085
+ })
2086
+ ])
2087
+ ]),
2088
+ _: 1
2089
+ }, 512)
2090
+ ]),
2091
+ "side-sheet-footer": j(() => [
2092
+ _("div", Rn, [
2093
+ F(u, {
2094
+ variant: "primary",
2095
+ label: "Save",
2096
+ size: "lg",
2097
+ onClick: b,
2098
+ disabled: h.value,
2099
+ loading: h.value
2100
+ }, null, 8, ["disabled", "loading"]),
2101
+ F(u, {
2102
+ variant: "secondary",
2103
+ label: "Close",
2104
+ size: "lg"
2105
+ })
2106
+ ])
2107
+ ]),
2108
+ _: 1
2109
+ }, 8, ["modelValue", "dismiss-away"]);
2110
+ };
2111
+ }
2112
+ }), Mn = { class: "flex items-center gap-1" }, En = { class: "flex-1 flex flex-col gap-8" }, Pn = { class: "flex flex-col" }, Vn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, jn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Un = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, co = /* @__PURE__ */ Y({
2113
+ __name: "WastageTemplateView",
2114
+ setup(p) {
2115
+ const { t: l } = G(), { createTemplate: c, updateTemplate: v, exportTemplates: d, importTemplates: i, viewReason: m } = ve(), { templateDialogProps: o, templateDetailsProps: t, templateReasonProps: s } = Be(
2116
+ ve()
2117
+ ), r = ye();
2118
+ X();
2119
+ const h = me(), x = et(), { breakpoints: w } = st();
2120
+ r.watchLocation(h.fetchTemplates);
2121
+ const T = N(() => h.loading), $ = R(""), b = N(() => w.value.xs || w.value.sm), n = N(() => b.value ? 10 : 20);
2122
+ function f(S) {
2123
+ switch (S) {
2124
+ case B.Add:
2125
+ return c();
2126
+ case "import":
2127
+ return i();
2128
+ case "export":
2129
+ return d();
2130
+ case "refresh":
2131
+ return h.fetchTemplates();
2132
+ }
2133
+ }
2134
+ function u(S) {
2135
+ return S;
2136
+ }
2137
+ const e = N(() => b.value ? [
2138
+ {
2139
+ label: l("inventory.adjustment.template.create.title"),
2140
+ value: B.Add,
2141
+ isPrimary: !0,
2142
+ prependIcon: "add"
2143
+ },
2144
+ {
2145
+ label: l("inventory.common.refresh"),
2146
+ value: "refresh",
2147
+ isPrimary: !1
2148
+ },
2149
+ // {
2150
+ // label: t('inventory.common.publish'),
2151
+ // value: 'publish',
2152
+ // isPrimary: false
2153
+ // },
2154
+ {
2155
+ label: l("inventory.common.import"),
2156
+ value: "import",
2157
+ isPrimary: !1
2158
+ },
2159
+ {
2160
+ label: l("inventory.common.export"),
2161
+ value: "export",
2162
+ isPrimary: !1
2163
+ }
2164
+ ] : [
2165
+ {
2166
+ label: l("inventory.adjustment.template.create.title"),
2167
+ value: B.Add,
2168
+ isPrimary: !0,
2169
+ prependIcon: "add"
2170
+ },
2171
+ // {
2172
+ // label: t('inventory.common.publish'),
2173
+ // value: 'publish',
2174
+ // isPrimary: false
2175
+ // },
2176
+ {
2177
+ label: l("inventory.common.import"),
2178
+ value: "import",
2179
+ isPrimary: !1
2180
+ },
2181
+ {
2182
+ label: l("inventory.common.refresh"),
2183
+ value: "refresh",
2184
+ isPrimary: !1
2185
+ },
2186
+ {
2187
+ label: l("inventory.common.export"),
2188
+ value: "export",
2189
+ isPrimary: !1
2190
+ }
2191
+ ]), a = () => {
2192
+ m();
2193
+ };
2194
+ return (S, g) => {
2195
+ const y = M("FmButton"), C = M("FmTable");
2196
+ return A(), D(W, null, [
2197
+ F(tt, {
2198
+ title: k(l)("inventory.adjustment.template.wastage.title"),
2199
+ actions: e.value,
2200
+ "onClick:action": f
2201
+ }, {
2202
+ default: j(() => [
2203
+ _("div", {
2204
+ class: K([
2205
+ "flex flex-col gap-8 max-h-full",
2206
+ {
2207
+ "p-0": b.value,
2208
+ "px-24 ": !b.value
2209
+ }
2210
+ ])
2211
+ }, [
2212
+ _("div", Mn, [
2213
+ F(y, {
2214
+ class: "ml-auto",
2215
+ "prepend-icon": "edit",
2216
+ key: "Reason for wastage",
2217
+ label: "Default label",
2218
+ "bg-color": "neutral-gray-100",
2219
+ "text-color": "neutral-gray-400",
2220
+ onClick: a
2221
+ }, {
2222
+ default: j(() => g[5] || (g[5] = [
2223
+ _("div", { class: "flex items-center gap-2" }, [
2224
+ _("span", null, "Reasons")
2225
+ ], -1)
2226
+ ])),
2227
+ _: 1
2228
+ }),
2229
+ F(y, {
2230
+ "prepend-icon": "info",
2231
+ label: "Default label",
2232
+ variant: "tertiary",
2233
+ onClick: g[0] || (g[0] = Je((I) => k(h).showReasonPublishDialog(), ["stop"]))
2234
+ }, {
2235
+ default: j(() => [
2236
+ _("div", {
2237
+ class: K([
2238
+ "fm-status-badge",
2239
+ k(h).isReasonPublished() ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
2240
+ ])
2241
+ }, V(k(h).isReasonPublished() ? "Published" : "Unpublished"), 3)
2242
+ ]),
2243
+ _: 1
2244
+ }),
2245
+ F(nt, {
2246
+ class: "flex-1",
2247
+ searchable: "",
2248
+ search: $.value,
2249
+ "onUpdate:search": g[1] || (g[1] = (I) => $.value = I)
2250
+ }, null, 8, ["search"])
2251
+ ]),
2252
+ F(C, {
2253
+ style: qe(k(x).tableHeight),
2254
+ "column-defs": k(h).columnDefs,
2255
+ "row-data": k(h).templates,
2256
+ "search-value": $.value,
2257
+ loading: T.value,
2258
+ onRowClick: g[2] || (g[2] = (I) => k(v)(I.original)),
2259
+ "page-size": n.value
2260
+ }, {
2261
+ "list-row": j((I) => [
2262
+ F(at, {
2263
+ row: I,
2264
+ onRowClick: (P) => k(v)(P)
2265
+ }, {
2266
+ default: j((P) => {
2267
+ var U, de, ee, te, ge, be, _e, xe, ne, we, Te, ke, $e, Se, Ie, oe, Ae, Fe, Ce, Re, se, De;
2268
+ return [
2269
+ _("div", En, [
2270
+ _("div", Pn, [
2271
+ _("div", Vn, [
2272
+ F(k(le), {
2273
+ render: (ee = (de = (U = P._id) == null ? void 0 : U.column) == null ? void 0 : de.columnDef) == null ? void 0 : ee.cell,
2274
+ props: (ge = (te = P._id) == null ? void 0 : te.getContext) == null ? void 0 : ge.call(te)
2275
+ }, null, 8, ["render", "props"])
2276
+ ]),
2277
+ _("div", jn, [
2278
+ F(k(le), {
2279
+ render: (xe = (_e = (be = P.name) == null ? void 0 : be.column) == null ? void 0 : _e.columnDef) == null ? void 0 : xe.cell,
2280
+ props: (we = (ne = P.name) == null ? void 0 : ne.getContext) == null ? void 0 : we.call(ne)
2281
+ }, null, 8, ["render", "props"])
2282
+ ]),
2283
+ _("div", null, V((Te = I.original.locations) != null && Te.length ? k(l)("inventory.adjustment.template.table.enabledForN", {
2284
+ count: ((ke = I.original.locations) == null ? void 0 : ke.length) ?? 0
2285
+ }) : k(l)("inventory.adjustment.template.table.enabledForAll")), 1),
2286
+ g[6] || (g[6] = _("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, null, -1)),
2287
+ _("div", Un, [
2288
+ F(k(le), {
2289
+ render: (Ie = (Se = ($e = P.ref) == null ? void 0 : $e.column) == null ? void 0 : Se.columnDef) == null ? void 0 : Ie.cell,
2290
+ props: (Ae = (oe = P.ref) == null ? void 0 : oe.getContext) == null ? void 0 : Ae.call(oe)
2291
+ }, null, 8, ["render", "props"])
2292
+ ])
2293
+ ]),
2294
+ _("div", null, [
2295
+ F(k(le), {
2296
+ render: (Re = (Ce = (Fe = P.status) == null ? void 0 : Fe.column) == null ? void 0 : Ce.columnDef) == null ? void 0 : Re.cell,
2297
+ props: (De = (se = P.status) == null ? void 0 : se.getContext) == null ? void 0 : De.call(se)
2298
+ }, null, 8, ["render", "props"])
2299
+ ])
2300
+ ])
2301
+ ];
2302
+ }),
2303
+ _: 2
2304
+ }, 1032, ["row", "onRowClick"])
2305
+ ]),
2306
+ _: 1
2307
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
2308
+ ], 2)
2309
+ ]),
2310
+ _: 1
2311
+ }, 8, ["title", "actions"]),
2312
+ (A(), O(Qe, { to: "body" }, [
2313
+ F(kn, Xe(Ze(k(t))), null, 16),
2314
+ F(xn, Me(k(o), {
2315
+ onSubmitted: g[3] || (g[3] = (I) => k(h).fetchTemplates())
2316
+ }), null, 16),
2317
+ F(Dn, Me(k(s), {
2318
+ onSubmitted: g[4] || (g[4] = (I) => k(h).fetchTemplates())
2319
+ }), null, 16)
2320
+ ]))
2321
+ ], 64);
2322
+ };
2323
+ }
2324
+ });
2325
+ export {
2326
+ co as default
2327
+ };