@feedmepos/mf-inventory-portal 1.2.51-dev.1 → 1.2.52

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