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