@feedmepos/mf-inventory-portal 0.0.22-dev.36 → 0.0.22-dev.38

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 (64) hide show
  1. package/dist/{ApprovalView-av_qng0N.js → ApprovalView-B1EiHn4f.js} +8 -8
  2. package/dist/{BindingsDialog-VZ6YelwP.js → BindingsDialog-DmYWCMdc.js} +9 -9
  3. package/dist/{BindingsPicker-BFYv2ftI.js → BindingsPicker-B35A7Px5.js} +17 -17
  4. package/dist/{BindingsTable-DFowW8vT.js → BindingsTable-CtN6XTmL.js} +1 -1
  5. package/dist/{ClosingTemplateView-DNcgyBVw.js → ClosingTemplateView-Ch8hg35a.js} +15 -15
  6. package/dist/FmDroppableField-DK78vkN3.js +152 -0
  7. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CAZ4P0Ax.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-0p8dn-rc.js} +76 -76
  8. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DqOb7e4M.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DSQW1Ayz.js} +20 -20
  9. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-Bb0W0wUH.js +51 -0
  10. package/dist/IngredientsView-C47jIp0f.js +1611 -0
  11. package/dist/{IntegrationView-DT5F9V0h.js → IntegrationView-Dulaskd9.js} +71 -71
  12. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CXw4tAI_.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-btsYefZJ.js} +1 -1
  13. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-C6a6F_jD.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BGLxTaW8.js} +16 -16
  14. package/dist/{PurchaseOrderPrintPreview-BMCy5C1z.js → PurchaseOrderPrintPreview-BtDEZAgl.js} +7 -7
  15. package/dist/{ReceiveRequestView-DBU59iYm.js → ReceiveRequestView-Cf6UV1Gz.js} +1042 -1029
  16. package/dist/{RecipeView-Brnk8Ar7.js → RecipeView-MagbCdki.js} +30 -29
  17. package/dist/StockView-D1TK5omK.js +7762 -0
  18. package/dist/{SupplierView-C0GT_JzY.js → SupplierView-CIUY0y12.js} +11 -11
  19. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-BzJ8TnL_.js → TransferDetails.vue_vue_type_script_setup_true_lang-CacJUhOj.js} +99 -101
  20. package/dist/TransferTemplateView-CetnHs4Q.js +2054 -0
  21. package/dist/{UnitView-Dw2xLWy4.js → UnitView-BDZRBWlk.js} +16 -16
  22. package/dist/{WarehouseView-Cgf1mP8s.js → WarehouseView-DtUxLB_u.js} +20 -20
  23. package/dist/api/bill.d.ts +84 -238
  24. package/dist/api/purchase-order-template.d.ts +4 -2
  25. package/dist/{app-Iz-opVBA.js → app-BGqgEJv-.js} +18166 -18188
  26. package/dist/app.js +2 -2
  27. package/dist/{decimal-ffsKJesh.js → decimal-NPqoitzq.js} +1 -1
  28. package/dist/defineDeepModel-C4ebJegy.js +13 -0
  29. package/dist/format-time-from-id-DkB5tphe.js +15 -0
  30. package/dist/helper/xlsx.util.d.ts +7 -0
  31. package/dist/purchase-order-transaction-type-ag48uMYt.js +348 -0
  32. package/dist/stores/inventory.d.ts +63 -0
  33. package/dist/stores/location.d.ts +89 -0
  34. package/dist/stores/supplier.d.ts +120 -3
  35. package/dist/stores/warehouse.d.ts +7 -4
  36. package/dist/supplier-CBaaZ4vA.js +70 -0
  37. package/dist/tsconfig.app.tsbuildinfo +1 -1
  38. package/dist/{use-template-enabled-locations-2-BSLLHtkm.js → use-template-enabled-locations-2-CYsM7ABF.js} +1 -1
  39. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +2 -2
  40. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +2 -2
  41. package/dist/views/ingredients/composables/use-ingredient-form.d.ts +2 -2
  42. package/dist/views/recipe/composables/use-recipe-form.d.ts +2 -2
  43. package/dist/views/stock/components/StockRecordCard.vue.d.ts +42 -119
  44. package/dist/views/stock/composables/use-stock-action.d.ts +2 -2
  45. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImport.vue.d.ts +2 -0
  46. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImportItem.vue.d.ts +12 -0
  47. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImportItemProps.d.ts +9 -0
  48. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +10 -6
  49. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +1850 -5
  50. package/dist/views/transfer-template/helpers/import-export.helper.d.ts +76 -0
  51. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +1 -230
  52. package/dist/views/unit/composables/use-unit-form.d.ts +2 -2
  53. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +14 -8
  54. package/dist/{xlsx-C8qXPxB4.js → xlsx-DQC0TWcU.js} +651 -651
  55. package/dist/xlsx.util-N5bu_PXw.js +78 -0
  56. package/package.json +3 -3
  57. package/dist/IngredientsView-afICUj_U.js +0 -1755
  58. package/dist/StockView-BtTZNhlp.js +0 -1909
  59. package/dist/TransferTemplateView-SrBMTzU-.js +0 -1237
  60. package/dist/defineDeepModel-CDrYKSnU.js +0 -13
  61. package/dist/format-time-from-id-e9QU46u4.js +0 -15
  62. package/dist/purchase-order-transaction-type-DN3Czz6K.js +0 -338
  63. package/dist/supplier-DdJIh1nj.js +0 -69
  64. package/dist/xlsx.util-DGLr1W_5.js +0 -109
@@ -0,0 +1,2054 @@
1
+ import { defineComponent as J, onMounted as ye, computed as N, ref as L, watch as ve, inject as yt, resolveComponent as D, openBlock as F, createElementBlock as E, createElementVNode as n, createVNode as $, withCtx as q, renderSlot as ze, withDirectives as je, normalizeClass as Y, vModelText as We, reactive as vt, h as te, toDisplayString as A, unref as t, createBlock as W, mergeProps as Xe, isRef as et, createCommentVNode as K, Fragment as X, renderList as le, createTextVNode as ht, createSlots as gt, normalizeStyle as bt, Teleport as xt, normalizeProps as _t, guardReactiveProps as kt } from "vue";
2
+ import { u as Tt, _ as $t, a as wt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DSQW1Ayz.js";
3
+ import { useI18n as ee, useCoreStore as tt } from "@feedmepos/mf-common";
4
+ import { P, a as St, f as Ft, t as Ct, u as ot, b as Ge } from "./purchase-order-transaction-type-ag48uMYt.js";
5
+ import { F as se, R as Ke } from "./row-action.enum-PMKMRrZR.js";
6
+ import { ai as be, t as oe, I as Rt, aj as It, ak as Mt, a as z, al as nt, D as Ye, R as xe, u as he, a3 as Ot, a6 as At, a4 as Dt, r as Z, a5 as Et, l as Vt, A as _e, M as Pt, b as rt, i as ie, y as Nt, k as Lt, W as ne, G as Bt, f as Ut, h as qt, af as Qt, w as Ht } from "./app-BGqgEJv-.js";
7
+ import { components as fe, useDialog as st, useSnackbar as ke, useProxiedModel as at, useDialogChild as zt, useBreakpoints as jt } from "@feedmepos/ui-library";
8
+ import { storeToRefs as Ze } from "pinia";
9
+ import "vue-router";
10
+ import { d as lt } from "./defineDeepModel-C4ebJegy.js";
11
+ import { c as Wt, u as Gt, _ as Kt } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-0p8dn-rc.js";
12
+ import { u as ge } from "./supplier-CBaaZ4vA.js";
13
+ import { F as G, _ as it } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
14
+ import { u as Yt } from "./use-template-enabled-locations-2-CYsM7ABF.js";
15
+ import { f as Zt } from "./format-time-from-id-DkB5tphe.js";
16
+ import { a as ae, b as ut, d as mt, s as ct, r as Jt } from "./xlsx.util-N5bu_PXw.js";
17
+ import { F as Xt } from "./FmDroppableField-DK78vkN3.js";
18
+ const eo = { class: "flex flex-col" }, to = { class: "flex flex-col" }, oo = { class: "flex-1" }, no = { class: "flex items-center" }, ro = { class: "flex-1" }, so = { class: "flex-1" }, ao = /* @__PURE__ */ J({
19
+ __name: "FmMinMaxInput",
20
+ props: {
21
+ rules: {},
22
+ label: {},
23
+ minPlaceholder: {},
24
+ maxPlaceholder: {},
25
+ modelValue: {},
26
+ precision: {},
27
+ minLength: {},
28
+ maxLength: {},
29
+ inputmode: {},
30
+ type: {},
31
+ readonly: { type: Boolean },
32
+ labelMark: {},
33
+ prependIcon: {},
34
+ appendIcon: {},
35
+ showValidBorder: { type: Boolean },
36
+ labelInfo: {},
37
+ showWordCount: { type: Boolean },
38
+ invalid: { type: Boolean },
39
+ autofocus: { type: Boolean },
40
+ formatter: { type: Function },
41
+ decimal: {},
42
+ datalist: {},
43
+ shiftDatalist: { type: Boolean },
44
+ datalistMaxHeight: {},
45
+ datalistMinHeight: {},
46
+ offsetDatalist: {},
47
+ datalistPlacement: {},
48
+ datalistZIndex: {},
49
+ datalistWidth: {},
50
+ disabled: { type: Boolean },
51
+ focused: { type: Boolean },
52
+ helperText: {},
53
+ helperState: {}
54
+ },
55
+ setup(l) {
56
+ const a = l, d = lt("modelValue"), o = Rt();
57
+ ye(() => {
58
+ const { min: k, max: v } = d ?? {};
59
+ if (!(!k || !v) && k.precision !== v.precision) {
60
+ const p = Math.max(k.precision, v.precision), i = be(k, p), T = be(v, p);
61
+ d.min = i, d.max = T;
62
+ }
63
+ });
64
+ const u = N(() => {
65
+ const { min: k, max: v } = d ?? {};
66
+ return Math.max((k == null ? void 0 : k.precision) ?? 0, (v == null ? void 0 : v.precision) ?? 0, a.precision ?? 0);
67
+ }), r = (k) => {
68
+ if (!k) return "";
69
+ const v = It(k), p = u.value, i = be(v, p);
70
+ return Mt(
71
+ +z(i),
72
+ i.precision
73
+ );
74
+ }, e = L(r(d.min)), s = L(r(d.max));
75
+ ve([e, s], ([k, v]) => {
76
+ const p = d ?? {}, i = o(k), T = o(v), c = u.value;
77
+ if (k !== "" && i === !0) {
78
+ const g = oe(+k, c);
79
+ p.min = g;
80
+ } else
81
+ p.min = null;
82
+ if (v !== "" && T === !0) {
83
+ const g = oe(+v, c);
84
+ p.max = g;
85
+ } else
86
+ p.max = null;
87
+ d.min = p.min, d.max = p.max;
88
+ });
89
+ const f = Symbol.for("fm:form-state"), y = yt(f, null), b = N(() => a.disabled ?? (y == null ? void 0 : y.getDisabled()) ?? !1), S = L(), _ = L(), h = L(!1), m = L(!1), x = N(() => h.value || m.value), I = N(() => [...[
90
+ function() {
91
+ return typeof o(e.value) == "string" || typeof o(s.value) == "string" ? "Must be a number" : !0;
92
+ },
93
+ function(p) {
94
+ return !p || !p.min || !p.max ? !0 : +z(p.min) > +z(p.max) ? "Min must be less than or equal to max" : !0;
95
+ }
96
+ ], ...a.rules ?? []]);
97
+ return (k, v) => {
98
+ const p = D("FmLabel"), i = D("FmField"), T = D("FmFormGroup");
99
+ return F(), E("div", eo, [
100
+ n("div", to, [
101
+ n("div", oo, [
102
+ $(p, {
103
+ label: k.label,
104
+ disabled: k.disabled,
105
+ required: k.labelMark === "required",
106
+ optional: k.labelMark === "optional"
107
+ }, null, 8, ["label", "disabled", "required", "optional"])
108
+ ]),
109
+ $(i, { focused: x.value }, {
110
+ default: q(() => [
111
+ n("div", no, [
112
+ ze(k.$slots, "prepend"),
113
+ v[6] || (v[6] = n("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Min.", -1)),
114
+ n("div", ro, [
115
+ je(n("input", {
116
+ type: "text",
117
+ ref_key: "minInputRef",
118
+ ref: S,
119
+ onFocus: v[0] || (v[0] = () => h.value = !0),
120
+ onBlur: v[1] || (v[1] = () => h.value = !1),
121
+ "onUpdate:modelValue": v[2] || (v[2] = (c) => e.value = c),
122
+ class: Y({
123
+ "fm-text-field--input fm-typo-en-body-lg-400": !0,
124
+ "text-fm-color-typo-primary": !b.value,
125
+ "text-fm-color-typo-disabled": b.value
126
+ })
127
+ }, null, 34), [
128
+ [We, e.value]
129
+ ])
130
+ ]),
131
+ v[7] || (v[7] = n("div", { class: "block h-32 mx-4 w-[1px] bg-fm-color-neutral-gray-200" }, null, -1)),
132
+ v[8] || (v[8] = n("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Max.", -1)),
133
+ n("div", so, [
134
+ je(n("input", {
135
+ type: "text",
136
+ ref_key: "maxInputRef",
137
+ ref: _,
138
+ onFocus: v[3] || (v[3] = () => m.value = !0),
139
+ onBlur: v[4] || (v[4] = () => m.value = !1),
140
+ "onUpdate:modelValue": v[5] || (v[5] = (c) => s.value = c),
141
+ class: Y({
142
+ "fm-text-field--input fm-typo-en-body-lg-400": !0,
143
+ "text-fm-color-typo-primary": !b.value,
144
+ "text-fm-color-typo-disabled": b.value
145
+ })
146
+ }, null, 34), [
147
+ [We, s.value]
148
+ ])
149
+ ]),
150
+ ze(k.$slots, "append")
151
+ ])
152
+ ]),
153
+ _: 3
154
+ }, 8, ["focused"])
155
+ ]),
156
+ $(T, {
157
+ class: "flex-1",
158
+ "model-value": k.modelValue,
159
+ info: k.labelInfo,
160
+ rules: I.value,
161
+ "helper-text": k.helperText,
162
+ "helper-state": k.helperState
163
+ }, null, 8, ["model-value", "info", "rules", "helper-text", "helper-state"])
164
+ ]);
165
+ };
166
+ }
167
+ });
168
+ function lo() {
169
+ return function(a) {
170
+ return !a || !a.min || !a.max ? "Required" : !0;
171
+ };
172
+ }
173
+ function io(l, a) {
174
+ return function(o) {
175
+ return !o || !o.min || !o.max ? !0 : +z(o.min) < l ? `Must be between ${l} and ${a}` : +z(o.max) > a ? `Must be between ${l} and ${a}` : !0;
176
+ };
177
+ }
178
+ function uo(l) {
179
+ const a = nt(l), d = z(l);
180
+ return function(u) {
181
+ if (!(u != null && u.min) || !(u != null && u.max)) return !0;
182
+ const r = a(u.min) === !0, e = a(u.max) === !0;
183
+ return !r && !e ? `Min & max must be a multiple of ${d}` : r ? e ? !0 : `Max must be a multiple of ${d}` : `Min must be a multiple of ${d}`;
184
+ };
185
+ }
186
+ var Q = /* @__PURE__ */ ((l) => (l.Code = "Code", l.Name = "Name", l.DefaultAmount = "DefaultAmount", l.Limit = "Limit", l.MinimumAmount = "MinimumAmount", l.Step = "Step", l.Cost = "Cost", l.Delete = "Delete", l))(Q || {});
187
+ function mo(l) {
188
+ const { t: a } = ee(), d = vt({});
189
+ ye(() => {
190
+ for (const r of l.items) {
191
+ if (!r.totalCost)
192
+ continue;
193
+ const e = Wt(r.sku, r.quantity, r.measurement, {
194
+ supplier: l.supplier
195
+ }), s = r.totalCost ?? Ye.reset();
196
+ e ? d[r.sku._id] = e.amount !== s.amount || e.precision !== s.precision : d[r.sku._id] = !0;
197
+ }
198
+ });
199
+ const o = [
200
+ {
201
+ id: "Code",
202
+ header: () => a("inventory.transfer.form.items.table.Code"),
203
+ accessorKey: "code",
204
+ size: 96,
205
+ cell(r) {
206
+ const e = r.row.original;
207
+ return te(fe.FmTextField, {
208
+ modelValue: e.code,
209
+ "onUpdate:modelValue": (s) => {
210
+ l.updateItem({
211
+ ...e,
212
+ code: s
213
+ });
214
+ },
215
+ key: e.sku._id,
216
+ rules: [xe()],
217
+ labelMark: "required"
218
+ });
219
+ },
220
+ enableSorting: !1
221
+ },
222
+ {
223
+ id: "Name",
224
+ header: () => a("inventory.transfer.form.items.table.Name"),
225
+ minSize: 300,
226
+ cell(r) {
227
+ const e = r.row.original;
228
+ return te(fe.FmTextField, {
229
+ modelValue: e.name,
230
+ "onUpdate:modelValue": (s) => {
231
+ l.updateItem({
232
+ ...e,
233
+ name: s
234
+ });
235
+ },
236
+ key: e.sku._id,
237
+ rules: [xe()],
238
+ labelMark: "required"
239
+ });
240
+ },
241
+ enableSorting: !1
242
+ },
243
+ {
244
+ id: "DefaultAmount",
245
+ header: () => a("inventory.transfer.form.items.table.DefaultAmount"),
246
+ minSize: 200,
247
+ cell(r) {
248
+ var _;
249
+ const e = r.row.original, s = he(), f = s.skuById[e.sku._id], y = s.unitById[(_ = f.unit) == null ? void 0 : _._id], b = y.measurements.find((h) => {
250
+ var m;
251
+ return ((m = e.measurement) == null ? void 0 : m.id) === h.id;
252
+ }), S = e.sku.unit._id !== f.unit._id || !y || e.measurement && !b;
253
+ return te(Ot, {
254
+ style: {
255
+ flex: "1 1 0%"
256
+ },
257
+ modelValue: {
258
+ amount: e.quantity ?? { amount: 1, precision: 0 },
259
+ // NOTE: leave this reading from row.sku.unit and row.measurement instead,
260
+ measurement: e.measurement ?? (e.sku.unit._id !== f.unit._id ? { ...e.sku.unit, id: "", conversion: { amount: 1, precision: 0 } } : null)
261
+ },
262
+ disabled: l.disabled,
263
+ key: e.sku._id,
264
+ unit: y,
265
+ "onUpdate:modelValue": (h) => {
266
+ l.updateItem({
267
+ ...e,
268
+ sku: f,
269
+ quantity: h.amount,
270
+ measurement: h.measurement
271
+ });
272
+ },
273
+ rules: [
274
+ At(e.quantityStep),
275
+ Dt(
276
+ +z(
277
+ e.minimumQuantity ?? {
278
+ amount: 1,
279
+ // NOTE: leave this reading from row.sku.unit and row.measurement instead,
280
+ precision: Z(e.sku.unit, e.measurement)
281
+ }
282
+ )
283
+ ),
284
+ Et(
285
+ e.maximumQuantity ? +z(e.maximumQuantity) : 1 / 0
286
+ ),
287
+ function(m) {
288
+ return S ? "This item is no longer valid due to change in unit. Please reapply unit." : !0;
289
+ }
290
+ ],
291
+ applyDefaultRules: !0
292
+ });
293
+ },
294
+ enableSorting: !1
295
+ },
296
+ {
297
+ id: "Limit",
298
+ header: () => "Limit",
299
+ // TODO: i18n,
300
+ minSize: 280,
301
+ cell(r) {
302
+ const e = r.row.original;
303
+ return te(ao, {
304
+ style: {
305
+ flex: "1 1 0%"
306
+ },
307
+ modelValue: {
308
+ min: e.minimumQuantity,
309
+ max: e.maximumQuantity
310
+ },
311
+ disabled: l.disabled,
312
+ key: e.sku._id,
313
+ unit: e.sku.unit,
314
+ "onUpdate:modelValue": (s) => {
315
+ const f = { ...e };
316
+ s != null && s.min && (f.minimumQuantity = s.min), s != null && s.max && (f.maximumQuantity = s.max), l.updateItem(f);
317
+ },
318
+ rules: [
319
+ lo(),
320
+ uo(e.quantityStep),
321
+ io(
322
+ +z({
323
+ amount: 1,
324
+ precision: Z(e.sku.unit, e.measurement)
325
+ }),
326
+ 1 / 0
327
+ )
328
+ ],
329
+ disableUnit: !0,
330
+ applyDefaultRules: !0
331
+ });
332
+ }
333
+ },
334
+ {
335
+ id: "Step",
336
+ header: () => a("inventory.transfer.form.items.table.Step"),
337
+ minSize: 100,
338
+ cell(r) {
339
+ const e = r.row.original;
340
+ return te(fe.FmTextField, {
341
+ modelValue: z(e.quantityStep ?? Ye.reset(), !1),
342
+ key: e.sku._id,
343
+ "onUpdate:modelValue": (s) => {
344
+ l.updateItem({
345
+ ...e,
346
+ quantityStep: Vt(+s)
347
+ });
348
+ },
349
+ rules: [
350
+ _e({
351
+ amount: 1,
352
+ precision: Z(e.sku.unit, e.measurement)
353
+ }),
354
+ Pt(e.sku.unit, e.measurement)
355
+ ]
356
+ });
357
+ },
358
+ enableSorting: !1
359
+ },
360
+ {
361
+ id: "Delete",
362
+ header: "",
363
+ cell(r) {
364
+ const e = r.row.original;
365
+ return te(fe.FmButton, {
366
+ class: "delete-button",
367
+ key: e.sku._id,
368
+ type: "button",
369
+ icon: "delete",
370
+ variant: "tertiary",
371
+ size: "md",
372
+ disabled: l.disabled,
373
+ onClick: () => {
374
+ l.deleteItem(e);
375
+ }
376
+ });
377
+ },
378
+ enableSorting: !1,
379
+ size: 40,
380
+ meta: {
381
+ cellClass: "",
382
+ headerClass: ""
383
+ }
384
+ }
385
+ ];
386
+ return {
387
+ columnDefs: N(() => rt().enableTotalCost && l.transferType === P.PURCHASE ? o : o.filter((e) => e.id !== "Cost"))
388
+ };
389
+ }
390
+ const co = { class: "flex flex-col gap-8 py-16" }, po = { class: "flex items-center" }, fo = { class: "flex-1 flex gap-1 items-center" }, yo = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, vo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, ho = { class: "flex gap-8 w-full" }, go = { class: "flex-1 flex flex-col gap-4" }, bo = { class: "flex-1 flex flex-col gap-4" }, xo = { class: "flex gap-8 w-full" }, _o = { class: "flex-1 flex flex-col gap-4" }, ko = { class: "flex-1 flex flex-col gap-4" }, To = { class: "flex gap-8 w-full" }, $o = { class: "flex-1 flex flex-col gap-4" }, wo = /* @__PURE__ */ J({
391
+ __name: "TransferTemplateItem",
392
+ props: {
393
+ cellByColId: {},
394
+ row: {}
395
+ },
396
+ setup(l) {
397
+ const { t: a } = ee();
398
+ return (d, o) => {
399
+ var r, e, s, f, y, b, S, _, h, m, x, I, k, v, p, i, T, c, g, w, V, U, B, C, R, j, H, M, O, re;
400
+ const u = D("FmLabel");
401
+ return F(), E("div", co, [
402
+ n("div", po, [
403
+ n("div", fo, [
404
+ n("span", yo, " (" + A(d.row.original.sku.code) + ") ", 1),
405
+ n("span", vo, A(d.row.original.sku.name), 1)
406
+ ]),
407
+ n("div", null, [
408
+ $(t(G), {
409
+ render: (s = (e = (r = d.cellByColId.Delete) == null ? void 0 : r.column) == null ? void 0 : e.columnDef) == null ? void 0 : s.cell,
410
+ props: (y = (f = d.cellByColId.Delete) == null ? void 0 : f.getContext) == null ? void 0 : y.call(f)
411
+ }, null, 8, ["render", "props"])
412
+ ])
413
+ ]),
414
+ n("div", ho, [
415
+ n("div", go, [
416
+ $(u, {
417
+ label: t(a)(`inventory.transfer.form.items.table.${t(Q).Code}`)
418
+ }, null, 8, ["label"]),
419
+ $(t(G), {
420
+ render: (_ = (S = (b = d.cellByColId[t(Q).Code]) == null ? void 0 : b.column) == null ? void 0 : S.columnDef) == null ? void 0 : _.cell,
421
+ props: (m = (h = d.cellByColId[t(Q).Code]) == null ? void 0 : h.getContext) == null ? void 0 : m.call(h)
422
+ }, null, 8, ["render", "props"]),
423
+ o[0] || (o[0] = n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
424
+ ]),
425
+ n("div", bo, [
426
+ $(u, {
427
+ label: t(a)(`inventory.transfer.form.items.table.${t(Q).Name}`)
428
+ }, null, 8, ["label"]),
429
+ $(t(G), {
430
+ render: (k = (I = (x = d.cellByColId[t(Q).Name]) == null ? void 0 : x.column) == null ? void 0 : I.columnDef) == null ? void 0 : k.cell,
431
+ props: (p = (v = d.cellByColId[t(Q).Name]) == null ? void 0 : v.getContext) == null ? void 0 : p.call(v)
432
+ }, null, 8, ["render", "props"]),
433
+ o[1] || (o[1] = n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
434
+ ])
435
+ ]),
436
+ n("div", xo, [
437
+ n("div", _o, [
438
+ $(u, {
439
+ label: t(a)(`inventory.transfer.form.items.table.${t(Q).DefaultAmount}`)
440
+ }, null, 8, ["label"]),
441
+ $(t(G), {
442
+ render: (c = (T = (i = d.cellByColId[t(Q).DefaultAmount]) == null ? void 0 : i.column) == null ? void 0 : T.columnDef) == null ? void 0 : c.cell,
443
+ props: (w = (g = d.cellByColId[t(Q).DefaultAmount]) == null ? void 0 : g.getContext) == null ? void 0 : w.call(g)
444
+ }, null, 8, ["render", "props"]),
445
+ o[2] || (o[2] = n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
446
+ ]),
447
+ n("div", ko, [
448
+ $(u, {
449
+ label: t(a)(`inventory.transfer.form.items.table.${t(Q).Step}`)
450
+ }, null, 8, ["label"]),
451
+ $(t(G), {
452
+ render: (B = (U = (V = d.cellByColId[t(Q).Step]) == null ? void 0 : V.column) == null ? void 0 : U.columnDef) == null ? void 0 : B.cell,
453
+ props: (R = (C = d.cellByColId[t(Q).Step]) == null ? void 0 : C.getContext) == null ? void 0 : R.call(C)
454
+ }, null, 8, ["render", "props"]),
455
+ o[3] || (o[3] = n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
456
+ ])
457
+ ]),
458
+ n("div", To, [
459
+ n("div", $o, [
460
+ $(u, {
461
+ label: t(a)(`inventory.transfer.form.items.table.${t(Q).Limit}`)
462
+ }, null, 8, ["label"]),
463
+ $(t(G), {
464
+ render: (M = (H = (j = d.cellByColId[t(Q).Limit]) == null ? void 0 : j.column) == null ? void 0 : H.columnDef) == null ? void 0 : M.cell,
465
+ props: (re = (O = d.cellByColId[t(Q).Limit]) == null ? void 0 : O.getContext) == null ? void 0 : re.call(O)
466
+ }, null, 8, ["render", "props"]),
467
+ o[4] || (o[4] = n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
468
+ ])
469
+ ])
470
+ ]);
471
+ };
472
+ }
473
+ }), So = { class: "flex flex-col gap-16" }, Fo = { class: "flex flex-col gap-24" }, Co = { class: "flex flex-col gap-16" }, Ro = { class: "flex items-center" }, Io = { class: "flex flex-col" }, Mo = { class: "flex flex-col gap-16" }, Oo = { class: "flex" }, Ao = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Do = /* @__PURE__ */ J({
474
+ __name: "TransferTemplateForm",
475
+ props: {
476
+ modelValue: {},
477
+ disabled: { type: Boolean }
478
+ },
479
+ setup(l, { expose: a }) {
480
+ const d = l, o = lt(), { t: u } = ee(), r = ie(), e = he(), s = ge();
481
+ ve(
482
+ () => d.modelValue,
483
+ (c) => {
484
+ console.log("TransferTemplateForm.model", c);
485
+ }
486
+ ), r.watchLocation(async () => {
487
+ location && (o.purchaseOrder.supplier || (o.purchaseOrder.supplier = s.suppliers.find((c) => c) ?? o.purchaseOrder.supplier));
488
+ });
489
+ const f = st(), y = Gt(
490
+ () => o.purchaseOrder,
491
+ (c) => {
492
+ o.purchaseOrder = {
493
+ ...o.purchaseOrder,
494
+ supplier: c.supplier ?? (o == null ? void 0 : o.purchaseOrder.supplier)
495
+ };
496
+ }
497
+ ), b = N({
498
+ get() {
499
+ var c, g;
500
+ return typeof ((g = (c = o.purchaseOrder) == null ? void 0 : c.supplier) == null ? void 0 : g.internal) == "string" ? P.TRANSFER : P.PURCHASE;
501
+ },
502
+ set(c) {
503
+ var w, V;
504
+ const g = typeof ((V = (w = o.purchaseOrder) == null ? void 0 : w.supplier) == null ? void 0 : V.internal) == "string" ? P.TRANSFER : P.PURCHASE;
505
+ c !== g && (o.purchaseOrder.supplier = c === P.PURCHASE ? y.locationOptionsTypePurchase.value[0] : y.locationOptionsTypeTransfer.value[0]);
506
+ }
507
+ }), S = N(() => y.transferLocationOptions.value), _ = N({
508
+ get() {
509
+ var c;
510
+ return (c = o.purchaseOrder.supplier) == null ? void 0 : c._id;
511
+ },
512
+ set(c) {
513
+ y.transferLocationModel.value = c;
514
+ }
515
+ }), {
516
+ promptSelectLocations: h,
517
+ columnDefs: m,
518
+ rowData: x
519
+ } = Yt({
520
+ getLocations() {
521
+ return o.locations;
522
+ },
523
+ setLocations(c) {
524
+ o.locations = c;
525
+ }
526
+ });
527
+ function I() {
528
+ var c, g;
529
+ return (c = o.locations) != null && c.find((w) => {
530
+ var V, U;
531
+ return ((V = w.doc) == null ? void 0 : V._id) === ((U = o.purchaseOrder.supplier) == null ? void 0 : U._id);
532
+ }) ? `Location ${(g = o.purchaseOrder.supplier) == null ? void 0 : g.name} must be removed because template cannot be used to transfer to itself.` : !0;
533
+ }
534
+ const k = N({
535
+ get() {
536
+ return o.purchaseOrder.remark ?? void 0;
537
+ },
538
+ set(c) {
539
+ o.purchaseOrder.remark = c;
540
+ }
541
+ }), v = L();
542
+ a({
543
+ validateInputs: () => {
544
+ var c, g;
545
+ (g = (c = v.value) == null ? void 0 : c.validateInputs) == null || g.call(c);
546
+ },
547
+ resetInputsValidation: () => {
548
+ var c, g;
549
+ (g = (c = v.value) == null ? void 0 : c.resetInputsValidation) == null || g.call(c);
550
+ },
551
+ resetInputs: () => {
552
+ var c, g;
553
+ (g = (c = v.value) == null ? void 0 : c.resetInputs) == null || g.call(c);
554
+ }
555
+ });
556
+ const p = mo({
557
+ updateItem: (c) => {
558
+ o.purchaseOrder.items = o.purchaseOrder.items.map((g) => g.sku._id !== c.sku._id ? g : c);
559
+ },
560
+ deleteItem: (c) => {
561
+ o.purchaseOrder.items = o.purchaseOrder.items.filter(
562
+ (g) => g.sku._id !== c.sku._id
563
+ );
564
+ },
565
+ get supplier() {
566
+ return o.purchaseOrder.supplier;
567
+ },
568
+ get items() {
569
+ return o.purchaseOrder.items;
570
+ },
571
+ get transferType() {
572
+ return P.PURCHASE;
573
+ },
574
+ get disabled() {
575
+ return d.disabled;
576
+ }
577
+ }), i = N(() => p.columnDefs.value);
578
+ function T() {
579
+ const c = e.skus.map((w) => ({
580
+ label: w.name,
581
+ sublabel: w.code,
582
+ value: w
583
+ })), g = c.filter((w) => {
584
+ var V;
585
+ return (V = o.purchaseOrder.items) == null ? void 0 : V.find((U) => U.sku._id === w.value._id);
586
+ }).map((w) => w.value);
587
+ f.open({
588
+ title: u("inventory.transfer.form.items.selectItem"),
589
+ closeButton: !0,
590
+ contentComponent: Nt,
591
+ contentComponentProps: {
592
+ modelValue: g,
593
+ items: c,
594
+ virtualScroll: !0
595
+ },
596
+ primaryActions: {
597
+ text: u("common.confirm"),
598
+ close: !0
599
+ },
600
+ secondaryActions: {
601
+ text: u("common.close"),
602
+ close: !0,
603
+ variant: "tertiary"
604
+ }
605
+ }).onPrimary((w) => {
606
+ const V = o.purchaseOrder.items ?? [], U = w.map((B) => {
607
+ const C = V.find((H) => H.sku._id === B._id);
608
+ if (C)
609
+ return C;
610
+ const R = { amount: 1, precision: Z(B.unit) };
611
+ return {
612
+ sku: B,
613
+ code: B.code,
614
+ name: B.name,
615
+ quantity: R,
616
+ minimumQuantity: R,
617
+ maximumQuantity: Lt(R, {
618
+ amount: 100,
619
+ precision: 0
620
+ }),
621
+ quantityStep: R
622
+ };
623
+ });
624
+ U.sort((B, C) => B.sku.code.localeCompare(C.sku.code)), o.purchaseOrder.items = U;
625
+ });
626
+ }
627
+ return (c, g) => {
628
+ const w = D("FmTextField"), V = D("FmSelect"), U = D("FmTextarea"), B = D("FmButton"), C = D("FmTable"), R = D("FmFormGroup"), j = D("FmForm");
629
+ return F(), W(j, {
630
+ ref_key: "formRef",
631
+ ref: v,
632
+ class: "flex flex-col gap-32",
633
+ disabled: c.disabled
634
+ }, {
635
+ default: q(() => {
636
+ var H;
637
+ return [
638
+ n("div", So, [
639
+ n("div", Fo, [
640
+ $(w, {
641
+ label: t(u)("inventory.transfer.form.name"),
642
+ "label-mark": "required",
643
+ modelValue: t(o).name,
644
+ "onUpdate:modelValue": g[0] || (g[0] = (M) => t(o).name = M),
645
+ rules: [t(xe)()]
646
+ }, null, 8, ["label", "modelValue", "rules"]),
647
+ $(V, {
648
+ label: t(u)("inventory.transfer.form.type.title"),
649
+ "model-value": b.value,
650
+ "onUpdate:modelValue": g[1] || (g[1] = (M) => b.value = M),
651
+ items: [
652
+ {
653
+ label: t(u)("inventory.transfer.form.type.purchase"),
654
+ value: t(P).PURCHASE,
655
+ disabled: !t(y).locationOptionsTypePurchase.value.length,
656
+ sublabel: t(y).locationOptionsTypePurchase.value.length ? void 0 : t(u)("inventory.transfer.form.noSupplierAvailable")
657
+ },
658
+ {
659
+ label: t(u)("inventory.transfer.form.type.transfer"),
660
+ value: t(P).TRANSFER,
661
+ disabled: !t(y).locationOptionsTypeTransfer.value.length,
662
+ sublabel: t(y).locationOptionsTypeTransfer.value.length ? void 0 : t(u)("inventory.transfer.form.noLocationAvailable")
663
+ }
664
+ ],
665
+ rules: [t(_e)(1)(S.value)]
666
+ }, null, 8, ["label", "model-value", "items", "rules"]),
667
+ $(V, {
668
+ label: b.value === t(P).PURCHASE ? t(u)("inventory.transfer.form.purchaseFrom") : t(u)("inventory.transfer.form.transferFrom"),
669
+ modelValue: _.value,
670
+ "onUpdate:modelValue": g[2] || (g[2] = (M) => _.value = M),
671
+ items: S.value
672
+ }, {
673
+ "menu-wrapper": q((M) => {
674
+ var O;
675
+ return [
676
+ $(Kt, Xe(M, {
677
+ items: S.value,
678
+ "model-value": (O = c.modelValue.purchaseOrder.supplier) == null ? void 0 : O._id
679
+ }), null, 16, ["items", "model-value"])
680
+ ];
681
+ }),
682
+ _: 1
683
+ }, 8, ["label", "modelValue", "items"]),
684
+ $(w, {
685
+ label: t(u)("inventory.transfer.form.reference"),
686
+ "label-mark": "optional",
687
+ modelValue: t(o).purchaseOrder.ref,
688
+ "onUpdate:modelValue": g[3] || (g[3] = (M) => t(o).purchaseOrder.ref = M)
689
+ }, null, 8, ["label", "modelValue"]),
690
+ $(U, {
691
+ label: t(u)("inventory.transfer.form.remark"),
692
+ "label-mark": "optional",
693
+ "max-length": 240,
694
+ modelValue: k.value,
695
+ "onUpdate:modelValue": g[4] || (g[4] = (M) => k.value = M),
696
+ class: Y({ "text-fm-color-typo-disabled": c.disabled })
697
+ }, null, 8, ["label", "modelValue", "class"])
698
+ ])
699
+ ]),
700
+ n("div", Co, [
701
+ n("div", Ro, [
702
+ g[6] || (g[6] = n("div", { class: "flex-1 fm-typo-en-title-sm-600" }, "Locations", -1)),
703
+ $(B, {
704
+ disabled: c.disabled,
705
+ label: "Select location",
706
+ "prepend-icon": "add",
707
+ variant: "plain",
708
+ class: "border-2 rounded-lg border-fm-color-primary",
709
+ onClick: t(h)
710
+ }, null, 8, ["disabled", "onClick"])
711
+ ]),
712
+ $(C, {
713
+ "column-defs": t(m),
714
+ "row-data": t(x),
715
+ "shrink-at": 9999,
716
+ onRowClick: t(h),
717
+ "hide-footer": ""
718
+ }, null, 8, ["column-defs", "row-data", "onRowClick"]),
719
+ n("div", Io, [
720
+ $(R, {
721
+ "model-value": [
722
+ (H = d.modelValue.purchaseOrder.supplier) == null ? void 0 : H._id,
723
+ ...d.modelValue.locations ?? []
724
+ ].join(","),
725
+ rules: [I]
726
+ }, null, 8, ["model-value", "rules"])
727
+ ])
728
+ ]),
729
+ n("div", Mo, [
730
+ n("div", Oo, [
731
+ n("div", Ao, A(t(u)("inventory.transfer.form.items.title")), 1),
732
+ $(B, {
733
+ disabled: c.disabled,
734
+ label: t(u)("inventory.transfer.form.items.addItem"),
735
+ "prepend-icon": "add",
736
+ variant: "plain",
737
+ class: "border-2 rounded-lg border-fm-color-primary",
738
+ onClick: g[5] || (g[5] = (M) => T()),
739
+ size: "md"
740
+ }, null, 8, ["disabled", "label"])
741
+ ]),
742
+ (F(), W(C, {
743
+ "column-defs": i.value,
744
+ "row-data": t(o).purchaseOrder.items,
745
+ key: t(o).purchaseOrder.items.map((M) => M.sku._id).join("."),
746
+ "hide-footer": "",
747
+ "page-size": t(o).purchaseOrder.items.length
748
+ }, {
749
+ "list-row": q((M) => [
750
+ (F(), W(it, {
751
+ row: M,
752
+ key: t(o).purchaseOrder.items.map((O) => O.sku._id).join(".")
753
+ }, {
754
+ default: q((O) => [
755
+ $(wo, {
756
+ row: M,
757
+ "cell-by-col-id": O
758
+ }, null, 8, ["row", "cell-by-col-id"])
759
+ ]),
760
+ _: 2
761
+ }, 1032, ["row"]))
762
+ ]),
763
+ _: 1
764
+ }, 8, ["column-defs", "row-data", "page-size"])),
765
+ $(R, {
766
+ "model-value": t(o).purchaseOrder.items.length,
767
+ rules: [t(_e)(1)]
768
+ }, null, 8, ["model-value", "rules"])
769
+ ])
770
+ ];
771
+ }),
772
+ _: 1
773
+ }, 8, ["disabled"]);
774
+ };
775
+ }
776
+ }), Eo = { class: "flex items-center" }, Vo = { class: "fm-typo-en-title-md-800" }, Po = { class: "flex gap-4" }, No = /* @__PURE__ */ J({
777
+ __name: "TransferTemplateDialog",
778
+ props: {
779
+ mode: {},
780
+ modelValue: {},
781
+ show: { type: Boolean }
782
+ },
783
+ emits: ["update:show", "submitted"],
784
+ setup(l, { expose: a, emit: d }) {
785
+ var p;
786
+ const o = l, u = d, r = St(), e = ke(), { t: s } = ee(), f = at(o, "show");
787
+ function y() {
788
+ return {
789
+ _id: "",
790
+ name: "",
791
+ purchaseOrder: {
792
+ remark: void 0,
793
+ ref: void 0,
794
+ items: [],
795
+ supplier: {
796
+ _rev: void 0,
797
+ email: void 0,
798
+ internal: void 0,
799
+ contactName: void 0,
800
+ phoneNumber: void 0,
801
+ registrationNumber: void 0,
802
+ supplyItems: void 0,
803
+ _id: "",
804
+ name: "",
805
+ address: {
806
+ line2: void 0,
807
+ line1: "",
808
+ state: "",
809
+ city: "",
810
+ postcode: "",
811
+ country: ""
812
+ }
813
+ }
814
+ }
815
+ };
816
+ }
817
+ const b = L(o.modelValue ?? y()), S = L(((p = o.modelValue) == null ? void 0 : p._id) ?? `${Math.random()}`);
818
+ ve(
819
+ () => o.show,
820
+ (i) => {
821
+ var T;
822
+ i && (b.value = o.modelValue ?? y(), S.value = ((T = o.modelValue) == null ? void 0 : T._id) ?? `${Math.random()}`);
823
+ }
824
+ );
825
+ const _ = L(!1), h = N(() => {
826
+ switch (o.mode) {
827
+ case se.READ:
828
+ return "";
829
+ case se.CREATE:
830
+ return s("inventory.transfer.template.create.title");
831
+ case se.UPDATE:
832
+ return s("inventory.transfer.template.update.title");
833
+ }
834
+ return "";
835
+ }), m = L();
836
+ a({
837
+ validateInputs: () => {
838
+ var i, T;
839
+ (T = (i = m.value) == null ? void 0 : i.validateInputs) == null || T.call(i);
840
+ },
841
+ resetInputsValidation: () => {
842
+ var i, T;
843
+ (T = (i = m.value) == null ? void 0 : i.resetInputsValidation) == null || T.call(i);
844
+ },
845
+ resetInputs: () => {
846
+ var i, T;
847
+ (T = (i = m.value) == null ? void 0 : i.resetInputs) == null || T.call(i);
848
+ }
849
+ });
850
+ async function x() {
851
+ var T, c;
852
+ const i = b.value;
853
+ if (i) {
854
+ _.value = !0, (((T = i.purchaseOrder.supplier) == null ? void 0 : T.internal) === ne.enum.warehouse || ((c = i.purchaseOrder.supplier) == null ? void 0 : c.internal) === ne.enum.restaurant) && (i.purchaseOrder.items = i.purchaseOrder.items.map(
855
+ ({ totalCost: g, ...w }) => w
856
+ ));
857
+ try {
858
+ await r.createTemplate(i), await new Promise((g) => setTimeout(g, 1e3)), e.open({
859
+ title: s("inventory.transfer.template.create.success"),
860
+ message: s("inventory.transfer.template.create.successMessage"),
861
+ type: "success"
862
+ }), u("update:show", !1), u("submitted");
863
+ } catch (g) {
864
+ e.open({
865
+ title: s("inventory.transfer.template.create.error"),
866
+ message: s("inventory.transfer.template.create.errorMessage"),
867
+ type: "error"
868
+ }), console.error("Error in creating transfer template", g);
869
+ } finally {
870
+ _.value = !1;
871
+ }
872
+ }
873
+ }
874
+ async function I() {
875
+ var T, c;
876
+ const i = b.value;
877
+ if (i) {
878
+ _.value = !0, (((T = i.purchaseOrder.supplier) == null ? void 0 : T.internal) === ne.enum.warehouse || ((c = i.purchaseOrder.supplier) == null ? void 0 : c.internal) === ne.enum.restaurant) && (i.purchaseOrder.items = i.purchaseOrder.items.map(
879
+ ({ totalCost: g, ...w }) => w
880
+ ));
881
+ try {
882
+ await r.updateTemplate(i), await new Promise((g) => setTimeout(g, 1e3)), e.open({
883
+ title: s("inventory.transfer.template.update.success"),
884
+ message: s("inventory.transfer.template.update.successMessage"),
885
+ type: "success"
886
+ }), u("update:show", !1), u("submitted");
887
+ } catch (g) {
888
+ e.open({
889
+ title: s("inventory.transfer.template.update.error"),
890
+ message: s("inventory.transfer.template.update.errorMessage"),
891
+ type: "error"
892
+ }), console.error("Error in updating transfer template", g);
893
+ } finally {
894
+ _.value = !1;
895
+ }
896
+ }
897
+ }
898
+ function k() {
899
+ switch (o.mode) {
900
+ case se.CREATE:
901
+ return x();
902
+ case se.UPDATE:
903
+ return I();
904
+ }
905
+ }
906
+ function v() {
907
+ var i, T;
908
+ (T = (i = m.value) == null ? void 0 : i.validateInputs) == null || T.call(i);
909
+ }
910
+ return (i, T) => {
911
+ const c = D("FmButton"), g = D("FmSideSheet");
912
+ return F(), W(g, {
913
+ modelValue: t(f),
914
+ "onUpdate:modelValue": T[2] || (T[2] = (w) => et(f) ? f.value = w : null),
915
+ "dismiss-away": "",
916
+ "close-button": "",
917
+ "max-width": 1200
918
+ }, {
919
+ "side-sheet-header": q(() => [
920
+ n("div", Eo, [
921
+ n("div", Vo, A(h.value), 1)
922
+ ])
923
+ ]),
924
+ default: q(() => [
925
+ (F(), W(Do, {
926
+ class: "w-full",
927
+ ref_key: "formRef",
928
+ ref: m,
929
+ onValidationSuccess: k,
930
+ "model-value": b.value,
931
+ "onUpdate:modelValue": T[0] || (T[0] = (w) => b.value = w),
932
+ disabled: _.value,
933
+ key: S.value
934
+ }, null, 8, ["model-value", "disabled"]))
935
+ ]),
936
+ "side-sheet-footer": q(() => [
937
+ n("div", Po, [
938
+ $(c, {
939
+ loading: _.value,
940
+ label: t(s)("common.save"),
941
+ onClick: v
942
+ }, null, 8, ["loading", "label"]),
943
+ $(c, {
944
+ disabled: _.value,
945
+ variant: "tertiary",
946
+ label: t(s)("common.close"),
947
+ onClick: T[1] || (T[1] = (w) => u("update:show", !1))
948
+ }, null, 8, ["disabled", "label"])
949
+ ])
950
+ ]),
951
+ _: 1
952
+ }, 8, ["modelValue"]);
953
+ };
954
+ }
955
+ }), Lo = { class: "flex flex-col gap-16 w-full h-full overflow-y-auto" }, Bo = { class: "flex justify-between" }, Uo = { class: "fm-typo-en-body-lg-600" }, qo = { class: "fm-status-badge fm-status-badge-info-secondary" }, Qo = { class: "flex flex-col gap-8" }, Ho = { class: "flex flex-col gap-4" }, zo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, jo = { class: "flex gap-1" }, Wo = { class: "fm-typo-en-body-lg-600" }, Go = {
956
+ key: 0,
957
+ class: "flex flex-col gap-4"
958
+ }, Ko = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Yo = { class: "fm-typo-en-body-lg-600" }, Zo = {
959
+ key: 1,
960
+ class: "flex flex-col gap-4"
961
+ }, Jo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xo = { class: "fm-typo-en-body-lg-600" }, en = {
962
+ key: 2,
963
+ class: "flex flex-col gap-4"
964
+ }, tn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, on = { class: "fm-typo-en-body-lg-600" }, nn = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, rn = { class: "flex flex-col gap-8" }, sn = { class: "fm-typo-en-body-lg-600" }, an = { class: "flex w-full gap-4" }, ln = { class: "grow fm-typo-en-body-lg-400 line-clamp-2" }, un = { class: "fm-typo-en-body-lg-600 shrink-0" }, mn = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, cn = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, dn = {
965
+ key: 0,
966
+ class: "shrink-0 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
967
+ }, pn = {
968
+ key: 0,
969
+ class: "flex gap-4 items-center"
970
+ }, fn = { class: "flex flex-col gap-12" }, yn = { class: "flex flex-col gap-8" }, vn = { class: "flex gap-8 xs:flex-col" }, hn = /* @__PURE__ */ J({
971
+ __name: "TransferTemplateDetails",
972
+ props: {
973
+ template: {},
974
+ show: { type: Boolean }
975
+ },
976
+ emits: ["update:show", "action:edit"],
977
+ setup(l, { emit: a }) {
978
+ const d = l, o = a, u = rt(), { t: r } = ee(), e = N(() => {
979
+ var _;
980
+ return (_ = d.template) == null ? void 0 : _.purchaseOrder;
981
+ }), s = [
982
+ { accessorKey: "name", header: () => "Name" },
983
+ { accessorKey: "type", header: () => "Type" }
984
+ ], f = L(""), y = N(
985
+ () => {
986
+ var _, h, m, x;
987
+ return ((h = (_ = e.value) == null ? void 0 : _.supplier) == null ? void 0 : h.internal) === "restaurant" || ((x = (m = e.value) == null ? void 0 : m.supplier) == null ? void 0 : x.internal) === "warehouse" ? P.TRANSFER : P.PURCHASE;
988
+ }
989
+ ), b = L(!0), S = at(d, "show");
990
+ return (_, h) => {
991
+ var T;
992
+ const m = D("FmMenuDivider"), x = D("FmCard"), I = D("FmIcon"), k = D("FmTextField"), v = D("FmTable"), p = D("FmButton"), i = D("FmSideSheet");
993
+ return F(), W(i, {
994
+ header: t(r)("inventory.transfer.template.details.view", { template: (T = _.template) == null ? void 0 : T.name }),
995
+ modelValue: t(S),
996
+ "onUpdate:modelValue": h[2] || (h[2] = (c) => et(S) ? S.value = c : null),
997
+ "dismiss-away": b.value,
998
+ "close-button": "",
999
+ "max-width": 500
1000
+ }, {
1001
+ default: q(() => {
1002
+ var c, g;
1003
+ return [
1004
+ n("div", Lo, [
1005
+ n("div", null, [
1006
+ $(x, {
1007
+ variant: "outlined",
1008
+ class: "flex flex-col gap-8 px-12 py-16"
1009
+ }, {
1010
+ default: q(() => {
1011
+ var w, V, U, B, C, R, j;
1012
+ return [
1013
+ n("div", Bo, [
1014
+ n("div", Uo, A(t(r)("inventory.transfer.template.details.templateSummary")), 1),
1015
+ n("div", qo, A(t(r)(
1016
+ `inventory.transfer.receiveRequest.details.type.${y.value.toLocaleLowerCase("en-US")}`
1017
+ )), 1)
1018
+ ]),
1019
+ $(m),
1020
+ n("div", Qo, [
1021
+ n("div", Ho, [
1022
+ n("div", zo, [
1023
+ n("div", jo, A(t(r)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1024
+ ]),
1025
+ n("div", Wo, A(t(Zt)(((w = _.template) == null ? void 0 : w._id) ?? "")), 1)
1026
+ ]),
1027
+ (U = (V = e.value) == null ? void 0 : V.supplier) != null && U.name ? (F(), E("div", Go, [
1028
+ n("div", Ko, A(t(r)("inventory.transfer.receiveRequest.details.from")), 1),
1029
+ n("div", Yo, A((C = (B = e.value) == null ? void 0 : B.supplier) == null ? void 0 : C.name), 1)
1030
+ ])) : K("", !0),
1031
+ (R = e.value) != null && R.ref ? (F(), E("div", Zo, [
1032
+ n("div", Jo, A(t(r)("inventory.transfer.receiveRequest.details.reference")), 1),
1033
+ n("div", Xo, A(e.value.ref), 1)
1034
+ ])) : K("", !0),
1035
+ (j = e.value) != null && j.remark ? (F(), E("div", en, [
1036
+ n("div", tn, A(t(r)("inventory.transfer.receiveRequest.details.remark")), 1),
1037
+ n("div", on, A(e.value.remark), 1)
1038
+ ])) : K("", !0)
1039
+ ])
1040
+ ];
1041
+ }),
1042
+ _: 1
1043
+ })
1044
+ ]),
1045
+ n("div", nn, [
1046
+ n("div", rn, [
1047
+ n("div", sn, A(t(r)("inventory.transfer.receiveRequest.details.requestedItems")), 1),
1048
+ (F(!0), E(X, null, le(((c = e.value) == null ? void 0 : c.items) ?? [], (w) => (F(), E("div", {
1049
+ key: w.code,
1050
+ class: "flex flex-col"
1051
+ }, [
1052
+ n("div", an, [
1053
+ n("div", ln, A(w.name), 1),
1054
+ h[3] || (h[3] = n("div", { class: "flex-1 min-w-32" }, null, -1)),
1055
+ n("div", un, A(t(Ft)(w.quantity, w.sku.unit, w.measurement)), 1)
1056
+ ]),
1057
+ n("div", mn, [
1058
+ n("div", cn, A(w.code), 1),
1059
+ w.totalCost && t(u).enableTotalCost ? (F(), E("div", dn, " (" + A(t(Bt)(w.totalCost)) + ") ", 1)) : K("", !0)
1060
+ ]),
1061
+ t(Ct)(w) ? (F(), E("div", pn, [
1062
+ $(I, {
1063
+ name: "error",
1064
+ color: "system-error-300",
1065
+ size: "sm"
1066
+ }),
1067
+ h[4] || (h[4] = n("div", { class: "fm-typo-en-body-sm-400 text-fm-color-system-error-400" }, " This item has invalid unit configuration. Apply update on this item. ", -1))
1068
+ ])) : K("", !0)
1069
+ ]))), 128))
1070
+ ])
1071
+ ]),
1072
+ h[6] || (h[6] = n("div", null, null, -1)),
1073
+ h[7] || (h[7] = n("div", null, null, -1)),
1074
+ n("div", fn, [
1075
+ h[5] || (h[5] = n("div", { class: "flex flex-col" }, [
1076
+ n("div", { class: "fm-typo-en-body-lg-600" }, "Enabled locations"),
1077
+ n("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " This template is only usable for the following locations. ")
1078
+ ], -1)),
1079
+ n("div", yn, [
1080
+ $(k, {
1081
+ modelValue: f.value,
1082
+ "onUpdate:modelValue": h[0] || (h[0] = (w) => f.value = w),
1083
+ placeholder: "Filter locations",
1084
+ "prepend-icon": "search"
1085
+ }, null, 8, ["modelValue"]),
1086
+ $(v, {
1087
+ "hide-footer": "",
1088
+ style: { height: "500px" },
1089
+ "column-defs": s,
1090
+ "search-value": f.value,
1091
+ "row-data": ((g = d.template) == null ? void 0 : g.locations) ?? [{ name: "All locations" }]
1092
+ }, null, 8, ["search-value", "row-data"])
1093
+ ])
1094
+ ])
1095
+ ])
1096
+ ];
1097
+ }),
1098
+ "side-sheet-footer": q(() => [
1099
+ n("div", vn, [
1100
+ $(p, {
1101
+ label: t(r)("common.edit"),
1102
+ onClick: h[1] || (h[1] = (c) => o("action:edit")),
1103
+ variant: "tertiary"
1104
+ }, null, 8, ["label"])
1105
+ ])
1106
+ ]),
1107
+ _: 1
1108
+ }, 8, ["header", "modelValue", "dismiss-away"]);
1109
+ };
1110
+ }
1111
+ });
1112
+ var Te = /* @__PURE__ */ ((l) => (l.Source = "Source", l.Destination = "Destination", l.Ingredient = "Ingredient", l))(Te || {});
1113
+ function gn(l) {
1114
+ var o;
1115
+ const a = l.sku;
1116
+ return {
1117
+ code: a.code,
1118
+ name: a.name,
1119
+ unit: ((o = a.unit.measurements.find((u) => u.id === a.trackingMeasurement)) == null ? void 0 : o.abbrev) ?? a.unit.abbrev,
1120
+ defaultQuantity: +z(l.quantity),
1121
+ minimumQuantity: +z(l.minimumQuantity),
1122
+ maximumQuantity: +z(l.maximumQuantity),
1123
+ quantityStep: +z(l.quantityStep)
1124
+ };
1125
+ }
1126
+ function dt() {
1127
+ return [
1128
+ {
1129
+ id: "code",
1130
+ name: "Code"
1131
+ },
1132
+ {
1133
+ id: "name",
1134
+ name: "Name"
1135
+ },
1136
+ {
1137
+ id: "unit",
1138
+ name: "Unit"
1139
+ },
1140
+ {
1141
+ id: "defaultQuantity",
1142
+ name: "Default Quantity"
1143
+ },
1144
+ {
1145
+ id: "minimumQuantity",
1146
+ name: "Minimum Quantity"
1147
+ },
1148
+ {
1149
+ id: "maximumQuantity",
1150
+ name: "Maximum Quantity"
1151
+ },
1152
+ {
1153
+ id: "quantityStep",
1154
+ name: "Quantity Step"
1155
+ }
1156
+ ];
1157
+ }
1158
+ function bn(l) {
1159
+ var s;
1160
+ const d = tt().currentBusiness.value, u = (s = l.map((f) => {
1161
+ var m;
1162
+ const y = f.purchaseOrder.items.map(gn), b = dt(), S = [
1163
+ ["Template ID", f._id],
1164
+ ["Template name", f.name],
1165
+ ["Business name", d == null ? void 0 : d.name],
1166
+ ["Business ID", d == null ? void 0 : d._id],
1167
+ ["Menu version", d == null ? void 0 : d.menuVersion],
1168
+ [
1169
+ "Purchase/Transfer",
1170
+ typeof f.purchaseOrder.supplier.internal == "string" ? P.TRANSFER : P.PURCHASE
1171
+ ],
1172
+ [
1173
+ "Transfer from",
1174
+ `${f.purchaseOrder.supplier.name} (${[
1175
+ f.purchaseOrder.supplier.internal,
1176
+ f.purchaseOrder.supplier._id
1177
+ ].filter((x) => x).join("_")})`
1178
+ ],
1179
+ ["Location codes", ...((m = f.locations) == null ? void 0 : m.map((x) => `${x.name} (${x.dbName})`)) ?? ["All"]],
1180
+ ["Reference", f.purchaseOrder.ref ?? ""],
1181
+ ["Remark", f.purchaseOrder.remark ?? ""],
1182
+ [],
1183
+ b.map((x) => x.name),
1184
+ ...y.map((x) => b.map((I) => x[I.id]))
1185
+ ], _ = b.map((x) => `system:${x.id}`), h = ae(S, _);
1186
+ return { name: f.name, sheet: h };
1187
+ }).reduce(
1188
+ (f, y) => {
1189
+ var S;
1190
+ const b = y.name.slice(0, 12);
1191
+ return (S = f.sheetOccurence)[b] ?? (S[b] = 0), f.sheetOccurence[b] += 1, f.sheets[`${b} (${f.sheetOccurence[b]})`] = y.sheet, f;
1192
+ },
1193
+ {
1194
+ sheets: {},
1195
+ sheetOccurence: {}
1196
+ }
1197
+ )) == null ? void 0 : s.sheets, r = `${d == null ? void 0 : d.name} transfer templates (${Ut(/* @__PURE__ */ new Date())}).xlsx`, e = ut(u);
1198
+ return mt(e, r), r;
1199
+ }
1200
+ function xn() {
1201
+ const l = tt(), a = ge(), d = ie(), o = he(), u = l.currentBusiness.value, r = dt(), e = [
1202
+ ["Template ID", "(System ID, leave empty to create new)"],
1203
+ ["Template Name", "New template"],
1204
+ ["Business name", u == null ? void 0 : u.name],
1205
+ ["Business ID", u == null ? void 0 : u._id],
1206
+ ["Menu version", u == null ? void 0 : u.menuVersion],
1207
+ ["Purchase/Transfer", "Purchase"],
1208
+ ["Transfer from", "(refer to source list)"],
1209
+ ["Location codes", "All", "(or fill location name by cell, refer to destination list)"],
1210
+ ["Reference:"],
1211
+ ["Remark:"],
1212
+ [],
1213
+ r.map((m) => m.name)
1214
+ ], s = r.map((m) => `system:${m.id}`), f = ae(e, s), y = ae(
1215
+ [
1216
+ ...a.businessSuppliers.map((m) => [
1217
+ `${m.name} (${m._id})`,
1218
+ "Purchase",
1219
+ m.address.line1,
1220
+ m.address.line2,
1221
+ m.address.city,
1222
+ m.address.postcode,
1223
+ m.address.state,
1224
+ m.address.country
1225
+ ]),
1226
+ ...d.locations.map((m) => {
1227
+ var x, I, k, v, p, i;
1228
+ return [
1229
+ `${m.name} (${m.dbName})`,
1230
+ "Transfer",
1231
+ (x = m.doc.profile.address) == null ? void 0 : x.line1,
1232
+ (I = m.doc.profile.address) == null ? void 0 : I.line2,
1233
+ (k = m.doc.profile.address) == null ? void 0 : k.city,
1234
+ (v = m.doc.profile.address) == null ? void 0 : v.postcode,
1235
+ (p = m.doc.profile.address) == null ? void 0 : p.state,
1236
+ (i = m.doc.profile.address) == null ? void 0 : i.country
1237
+ ];
1238
+ })
1239
+ ],
1240
+ ["Name", "Type", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
1241
+ ), b = ae(
1242
+ d.locations.map((m) => {
1243
+ var x, I, k, v, p, i;
1244
+ return [
1245
+ `${m.name} (${m.dbName})`,
1246
+ (x = m.doc.profile.address) == null ? void 0 : x.line1,
1247
+ (I = m.doc.profile.address) == null ? void 0 : I.line2,
1248
+ (k = m.doc.profile.address) == null ? void 0 : k.city,
1249
+ (v = m.doc.profile.address) == null ? void 0 : v.postcode,
1250
+ (p = m.doc.profile.address) == null ? void 0 : p.state,
1251
+ (i = m.doc.profile.address) == null ? void 0 : i.country
1252
+ ];
1253
+ }),
1254
+ ["Name", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
1255
+ ), S = ae(
1256
+ o.skus.map((m) => [
1257
+ m.code,
1258
+ m.name,
1259
+ m.unit.abbrev,
1260
+ ...m.unit.measurements.map((x) => x.abbrev)
1261
+ ]),
1262
+ ["Code", "Name", "Base unit", "Measurements"]
1263
+ ), _ = ut({
1264
+ Template: f,
1265
+ Source: y,
1266
+ Destination: b,
1267
+ Ingredient: S
1268
+ }), h = `${u == null ? void 0 : u.name} transfer templates import.xlsx`;
1269
+ return mt(_, h), h;
1270
+ }
1271
+ function _n(l, a) {
1272
+ const d = new Array(), o = /(.*) \(((supplier_|warehouse_|restaurant_).{24,})\)/, r = ie().locationByDbName, s = ge().supplierById, f = l.trim(), y = o.exec(f);
1273
+ if (!y)
1274
+ return d.push(`Transfer from location value of ${f} cannot be read.`), {
1275
+ errors: d
1276
+ };
1277
+ const b = y[1], S = y[2];
1278
+ let _;
1279
+ if (S.startsWith("supplier"))
1280
+ _ = s[S], a !== P.PURCHASE && d.push(`Expected transfer type Purchase but found ${a} instead.`);
1281
+ else {
1282
+ const h = r[S];
1283
+ if (!h)
1284
+ return d.push(`Location (${b}) of id ${S} is not found.`), {
1285
+ errors: d
1286
+ };
1287
+ b !== h.name && d.push(
1288
+ `Location id ${S} has non-matching name. Found ${b} but expected ${h.name}`
1289
+ ), _ = {
1290
+ _id: h.doc._id,
1291
+ name: h.name,
1292
+ address: h.doc.profile.address ?? {
1293
+ line1: "",
1294
+ state: "",
1295
+ country: "",
1296
+ city: "",
1297
+ postcode: "",
1298
+ coordinates: [0, 0]
1299
+ },
1300
+ internal: S.split("_")[0] === "restaurant" ? ne.enum.restaurant : ne.enum.warehouse,
1301
+ phoneNumber: h.doc.profile.phoneNo ?? "",
1302
+ email: h.doc.profile.email ?? "",
1303
+ _rev: "",
1304
+ contactName: h.doc.profile.name ?? "",
1305
+ registrationNumber: h.doc.profile.regNo ?? ""
1306
+ };
1307
+ }
1308
+ return {
1309
+ from: _,
1310
+ errors: d
1311
+ };
1312
+ }
1313
+ function kn(l) {
1314
+ if (`${l[0]}`.toLocaleLowerCase() === "all")
1315
+ return [];
1316
+ const a = /(.*) \(((warehouse_|restaurant_).{24,})\)/, o = ie().locationByDbName;
1317
+ return l.map((u) => {
1318
+ const r = new Array(), e = u.trim(), s = a.exec(e);
1319
+ if (!s)
1320
+ return r.push(`Enabled location value of ${e} cannot be read.`), {
1321
+ errors: r
1322
+ };
1323
+ const f = s[1], y = s[2], b = o[y];
1324
+ return b ? (f !== b.name && r.push(
1325
+ `Location id ${y} has non-matching name. Found ${f} but expected ${b.name}`
1326
+ ), {
1327
+ errors: r,
1328
+ location: b
1329
+ }) : (r.push(`Location (${f}) of id ${y} is not found.`), {
1330
+ errors: r
1331
+ });
1332
+ });
1333
+ }
1334
+ function Tn(l) {
1335
+ const [
1336
+ a,
1337
+ d,
1338
+ o,
1339
+ u,
1340
+ r,
1341
+ e,
1342
+ s,
1343
+ f,
1344
+ y,
1345
+ b,
1346
+ S
1347
+ ] = ct(l);
1348
+ return {
1349
+ id: `${d[1] ?? ""}`.trim(),
1350
+ name: `${o[1] ?? ""}`.trim(),
1351
+ type: `${s[1] ?? ""}`.trim().toLocaleLowerCase() === "transfer" ? P.TRANSFER : P.PURCHASE,
1352
+ transferFrom: `${f[1] ?? ""}`.trim(),
1353
+ locations: y.slice(1).map((_) => `${_}`.trim()).filter((_) => _),
1354
+ reference: `${b[1] ?? ""}`.trim(),
1355
+ remark: `${S[1] ?? ""}`.trim()
1356
+ };
1357
+ }
1358
+ function $n(l) {
1359
+ const [
1360
+ a,
1361
+ d,
1362
+ o,
1363
+ u,
1364
+ r,
1365
+ e,
1366
+ s,
1367
+ f,
1368
+ y,
1369
+ b,
1370
+ S,
1371
+ _,
1372
+ h,
1373
+ ...m
1374
+ ] = ct(l);
1375
+ if (!a || !a.length || a.some((p) => p.length && !p.startsWith("system:")))
1376
+ throw new Error("Missing meta header. Excel file does not come from the template.");
1377
+ const x = a.map((p) => p.split(":")[1]), k = [
1378
+ "code",
1379
+ "name",
1380
+ "unit",
1381
+ "defaultQuantity",
1382
+ "minimumQuantity",
1383
+ "maximumQuantity",
1384
+ "quantityStep"
1385
+ ].filter((p) => !x.includes(p));
1386
+ if (k.length)
1387
+ throw new Error(
1388
+ `Missing meta headers (${k.join()}). Excel file does not come from the template.`
1389
+ );
1390
+ return m.map((p, i) => {
1391
+ const T = {};
1392
+ for (const c in x) {
1393
+ const g = x[c];
1394
+ Object.assign(T, { [g]: p[c] });
1395
+ }
1396
+ return {
1397
+ index: i,
1398
+ data: T
1399
+ };
1400
+ });
1401
+ }
1402
+ function wn(l, a, d) {
1403
+ const u = he().skuByCode[l.code], r = new Array();
1404
+ if (!u)
1405
+ return r.push(`Cannot find ingredient with code (${l.code}) ${l.name}.`), {
1406
+ index: a,
1407
+ errors: r
1408
+ };
1409
+ if (d.filter((p) => p.data.code === l.code).length > 1)
1410
+ return r.push(`Ingredient ${l.code} is defined twice.`), {
1411
+ index: a,
1412
+ errors: r
1413
+ };
1414
+ const e = u.unit, s = e == null ? void 0 : e.measurements.find((p) => p.abbrev === l.unit);
1415
+ if (e.abbrev !== l.unit && !s) {
1416
+ const p = `Cannot find unit measurement of symbol ${l.unit || "[empty]"} for ingredient (${l.code}) ${l.name}.`;
1417
+ r.push(p);
1418
+ const i = {
1419
+ sku: u,
1420
+ code: u.code,
1421
+ name: u.name,
1422
+ measurement: s,
1423
+ quantity: { amount: 0, precision: 0 },
1424
+ quantityStep: { amount: 0, precision: 0 },
1425
+ minimumQuantity: { amount: 0, precision: 0 },
1426
+ maximumQuantity: { amount: 0, precision: 0 }
1427
+ };
1428
+ return {
1429
+ index: a,
1430
+ errors: r,
1431
+ templateItem: i
1432
+ };
1433
+ }
1434
+ const f = oe(
1435
+ l.quantityStep,
1436
+ Z(e, s)
1437
+ );
1438
+ (Number.isNaN(Number(l.quantityStep)) || Number(l.quantityStep) <= 0) && r.push("Amount step must be more than 0");
1439
+ const y = nt(f), b = oe(
1440
+ l.minimumQuantity,
1441
+ Z(e, s)
1442
+ ), S = y(b);
1443
+ typeof S == "string" && r.push(`Minimum amount: ${S}`);
1444
+ const _ = oe(
1445
+ l.maximumQuantity,
1446
+ Z(e, s)
1447
+ ), h = y(_);
1448
+ typeof h == "string" && r.push(`Maximum amount: ${h}`), +l.minimumQuantity > +l.maximumQuantity && r.push("Minimum amount must be less than or equal to maximum amount");
1449
+ const m = Qt(+l.minimumQuantity, +l.maximumQuantity), x = oe(
1450
+ l.defaultQuantity,
1451
+ Z(e, s)
1452
+ ), I = y(x), k = m(`${l.defaultQuantity}`);
1453
+ typeof I == "string" && r.push(`Default amount: ${I}`), typeof k == "string" && r.push(`Default amount: ${k}`);
1454
+ const v = {
1455
+ sku: u,
1456
+ code: u.code,
1457
+ name: u.name,
1458
+ measurement: s,
1459
+ quantity: x,
1460
+ quantityStep: f,
1461
+ minimumQuantity: b,
1462
+ maximumQuantity: _
1463
+ };
1464
+ return {
1465
+ index: a,
1466
+ errors: r,
1467
+ templateItem: v
1468
+ };
1469
+ }
1470
+ function Sn(l) {
1471
+ const a = l.SheetNames.filter(
1472
+ (r) => !Object.values(Te).map(String).includes(r)
1473
+ ), o = ot().templates, u = qt(o, "_id");
1474
+ try {
1475
+ return a.reduce(
1476
+ (r, e) => {
1477
+ var p;
1478
+ const s = new Array(), f = l.Sheets[e], y = Tn(f), b = _n(y.transferFrom, y.type);
1479
+ s.push(...b.errors);
1480
+ const S = b.from, _ = kn(y.locations), h = _.filter((i) => i.location).map((i) => i.location);
1481
+ s.push(..._.flatMap((i) => i.errors));
1482
+ const m = $n(f).filter((i) => i.data.code), x = m.map(
1483
+ (i, T) => wn(i.data, T, m)
1484
+ );
1485
+ s.push(
1486
+ ...x.flatMap(
1487
+ (i) => i.errors.map((T) => `(Excel row ${i.index + 14}) ${T}`)
1488
+ )
1489
+ );
1490
+ const I = x.filter((i) => i.templateItem).map((i) => i.templateItem);
1491
+ if (y.id) {
1492
+ const i = u[y.id];
1493
+ if (!i) {
1494
+ const c = {
1495
+ _id: y.id,
1496
+ _rev: "",
1497
+ name: y.name || `(unnamed from sheet ${e || "<unnamed sheet>"})`,
1498
+ purchaseOrder: Fn()
1499
+ };
1500
+ return s.push(`Template ID ${y.id} is not found.`), r.importUpdateResult.push({
1501
+ type: "update",
1502
+ original: c,
1503
+ template: c,
1504
+ excelSheetName: e,
1505
+ errors: s
1506
+ }), r;
1507
+ }
1508
+ const T = {
1509
+ type: "update",
1510
+ original: i,
1511
+ template: {
1512
+ ...i,
1513
+ name: y.name,
1514
+ locations: h.length ? h : null,
1515
+ purchaseOrder: {
1516
+ ...i.purchaseOrder,
1517
+ supplier: S ?? ((p = i.purchaseOrder) == null ? void 0 : p.supplier),
1518
+ ref: y.reference,
1519
+ remark: y.remark,
1520
+ items: I
1521
+ }
1522
+ },
1523
+ excelSheetName: e,
1524
+ errors: s
1525
+ };
1526
+ return r.importUpdateResult.push(T), r;
1527
+ }
1528
+ const v = {
1529
+ type: "create",
1530
+ template: {
1531
+ name: y.id,
1532
+ locations: h,
1533
+ purchaseOrder: {
1534
+ supplier: S ?? pt(),
1535
+ ref: y.reference,
1536
+ remark: y.remark,
1537
+ items: I
1538
+ }
1539
+ },
1540
+ excelSheetName: e,
1541
+ errors: s
1542
+ };
1543
+ return r.importCreateResult.push(v), r;
1544
+ },
1545
+ {
1546
+ invalidExcel: !1,
1547
+ importCreateResult: new Array(),
1548
+ importUpdateResult: new Array()
1549
+ }
1550
+ );
1551
+ } catch (r) {
1552
+ return {
1553
+ invalidExcel: !0,
1554
+ invalidExcelMessage: (r == null ? void 0 : r.message) ?? "Invalid excel",
1555
+ importCreateResult: [],
1556
+ importUpdateResult: []
1557
+ };
1558
+ }
1559
+ }
1560
+ function pt() {
1561
+ return {
1562
+ _id: "",
1563
+ name: "",
1564
+ address: {
1565
+ line2: void 0,
1566
+ line1: "",
1567
+ state: "",
1568
+ city: "",
1569
+ postcode: "",
1570
+ country: ""
1571
+ }
1572
+ };
1573
+ }
1574
+ function Fn() {
1575
+ return {
1576
+ remark: void 0,
1577
+ ref: void 0,
1578
+ items: [],
1579
+ supplier: pt()
1580
+ };
1581
+ }
1582
+ const Cn = { class: "flex items-center gap-12 pl-8" }, Rn = { class: "flex flex-col" }, In = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, Mn = { class: "text-fm-color-typo-secondary fm-typo-en-body-md-400" }, On = {
1583
+ key: 0,
1584
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1585
+ }, An = { key: 0 }, Je = /* @__PURE__ */ J({
1586
+ __name: "TransferTemplateImportItem",
1587
+ props: {
1588
+ type: {},
1589
+ name: {},
1590
+ transferType: {},
1591
+ locations: {},
1592
+ items: {},
1593
+ errors: {}
1594
+ },
1595
+ setup(l) {
1596
+ return (a, d) => {
1597
+ var r, e, s;
1598
+ const o = D("FmIcon"), u = D("FmTooltip");
1599
+ return F(), E("div", Cn, [
1600
+ d[0] || (d[0] = n("div", null, "•", -1)),
1601
+ n("div", Rn, [
1602
+ n("div", In, [
1603
+ n("div", {
1604
+ class: Y({
1605
+ "text-fm-color-system-error-300": a.errors.length
1606
+ })
1607
+ }, [
1608
+ ht(A(a.name) + " ", 1),
1609
+ n("span", Mn, " (" + A(t(Ht)(`${a.transferType}`)) + ") ", 1),
1610
+ a.type === "create" ? (F(), E("span", On, "(new)")) : K("", !0)
1611
+ ], 2),
1612
+ a.errors.length ? (F(), E("div", An, [
1613
+ $(u, { "z-index": 50 }, {
1614
+ content: q(() => [
1615
+ n("ol", null, [
1616
+ (F(!0), E(X, null, le(a.errors, (f, y) => (F(), E("li", { key: y }, A(f), 1))), 128))
1617
+ ])
1618
+ ]),
1619
+ default: q(() => [
1620
+ $(o, {
1621
+ name: "error",
1622
+ size: "sm",
1623
+ color: "system-error-300"
1624
+ })
1625
+ ]),
1626
+ _: 1
1627
+ })
1628
+ ])) : K("", !0)
1629
+ ]),
1630
+ n("div", {
1631
+ class: Y([
1632
+ "fm-typo-en-body-sm-400",
1633
+ {
1634
+ "text-fm-color-system-error-200": a.errors.length,
1635
+ "text-fm-color-typo-secondary": !a.errors.length
1636
+ }
1637
+ ])
1638
+ }, A((r = a.locations) != null && r.length ? `${(e = a.locations) == null ? void 0 : e.length} locations` : "All locations") + ", " + A(`${(s = a.items) == null ? void 0 : s.length} items`), 3)
1639
+ ])
1640
+ ]);
1641
+ };
1642
+ }
1643
+ }), Dn = { class: "flex flex-col gap-24" }, En = {
1644
+ key: 0,
1645
+ class: "flex items-center gap-8"
1646
+ }, Vn = { class: "flex flex-col gap-8" }, Pn = { class: "line-clamp-2 text-ellipsis break-all" }, Nn = {
1647
+ key: 2,
1648
+ class: "shrink-0"
1649
+ }, Ln = {
1650
+ key: 0,
1651
+ class: "flex flex-col"
1652
+ }, Bn = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Un = {
1653
+ key: 0,
1654
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1655
+ }, qn = { class: "fm-typo-en-body-lg-600" }, Qn = /* @__PURE__ */ J({
1656
+ __name: "TransferTemplateImport",
1657
+ setup(l) {
1658
+ const a = L(null), d = zt(), o = ke(), u = L(!1), r = L(!1), e = ge();
1659
+ ye(async () => {
1660
+ r.value = !0;
1661
+ try {
1662
+ await e.readSuppliers().delayed(1e3);
1663
+ } catch {
1664
+ o.open({
1665
+ title: "Something went wrong.",
1666
+ message: "Error at reading suppliers list. Please try again.",
1667
+ type: "error"
1668
+ });
1669
+ } finally {
1670
+ r.value = !1;
1671
+ }
1672
+ });
1673
+ const s = L(new Array()), f = L([]), y = L([]), b = N(
1674
+ () => !!s.value.length || f.value.some((m) => m.errors.length) || y.value.some((m) => m.errors.length)
1675
+ ), S = N(
1676
+ () => !!f.value.length || !!y.value.length
1677
+ ), { t: _ } = ee();
1678
+ async function h(m) {
1679
+ s.value = [], f.value = [], y.value = [];
1680
+ try {
1681
+ u.value = !0;
1682
+ const [x] = await Promise.all([
1683
+ Jt(m),
1684
+ // fake buffer
1685
+ new Promise((p) => setTimeout(p, 1e3))
1686
+ ]);
1687
+ if (!x.SheetNames.filter(
1688
+ (p) => !Object.values(Te).map(String).includes(p)
1689
+ ).find((p) => p)) {
1690
+ s.value.push(_("inventory.ingredient.import.fileError.noSheet"));
1691
+ return;
1692
+ }
1693
+ const v = Sn(x);
1694
+ if (v.invalidExcel) {
1695
+ s.value.push(
1696
+ v.invalidExcelMessage ?? _("inventory.ingredient.import.fileError.invalidExcel")
1697
+ );
1698
+ return;
1699
+ }
1700
+ if (f.value = v.importCreateResult, y.value = v.importUpdateResult, !f.value.length && !y.value.length) {
1701
+ s.value.push(_("inventory.ingredient.import.fileError.noData"));
1702
+ return;
1703
+ }
1704
+ d.emitData(v);
1705
+ } catch (x) {
1706
+ o.open({
1707
+ title: _("inventory.ingredient.import.fileError.unableToRead"),
1708
+ message: x == null ? void 0 : x.message,
1709
+ type: "error"
1710
+ }), console.error("Error in reading file", x);
1711
+ } finally {
1712
+ s.value.length && o.open({
1713
+ title: _("inventory.ingredient.import.fileError.invalidExcel"),
1714
+ type: "error"
1715
+ }), u.value = !1;
1716
+ }
1717
+ }
1718
+ return ve(a, (m) => {
1719
+ m && h(m);
1720
+ }), (m, x) => {
1721
+ const I = D("FmCircularProgress"), k = D("FmIcon"), v = D("FmButton");
1722
+ return F(), E("div", Dn, [
1723
+ x[2] || (x[2] = n("div", { class: "fm-typo-en-body-md-400" }, "Import transfer templates from excel sheets.", -1)),
1724
+ r.value ? (F(), E("div", En, [
1725
+ n("div", null, [
1726
+ $(I, {
1727
+ size: "md",
1728
+ color: "neutral-gray-200"
1729
+ })
1730
+ ]),
1731
+ x[1] || (x[1] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Loading...", -1))
1732
+ ])) : (F(), E(X, { key: 1 }, [
1733
+ $(Xt, {
1734
+ class: Y({
1735
+ "w-full": !0,
1736
+ "h-[200px]": !a.value
1737
+ }),
1738
+ accept: ".xlsx",
1739
+ onFileUpload: x[0] || (x[0] = (p) => a.value = p),
1740
+ label: t(_)("inventory.ingredient.import.uploadTemplate"),
1741
+ "button-label": t(_)("inventory.ingredient.import.selectFile")
1742
+ }, gt({ _: 2 }, [
1743
+ a.value ? {
1744
+ name: "default",
1745
+ fn: q(({ openFileDialog: p }) => [
1746
+ n("div", Vn, [
1747
+ n("div", {
1748
+ class: Y([
1749
+ "fm-corner-radius-md p-16 flex items-center gap-16",
1750
+ {
1751
+ "border border-fm-color-neutral-gray-100": u.value,
1752
+ "border border-fm-color-neutral-gray-200": !u.value && !b.value,
1753
+ "border border-fm-color-system-error-200": b.value
1754
+ }
1755
+ ])
1756
+ }, [
1757
+ u.value ? (F(), W(I, {
1758
+ key: 0,
1759
+ size: "md",
1760
+ color: "neutral-gray-200"
1761
+ })) : (F(), W(k, {
1762
+ key: 1,
1763
+ name: b.value ? "error" : "attach_file",
1764
+ outline: "",
1765
+ color: b.value ? "system-error-300" : void 0
1766
+ }, null, 8, ["name", "color"])),
1767
+ n("div", {
1768
+ class: Y([
1769
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
1770
+ {
1771
+ "text-fm-color-typo-disabled": u.value,
1772
+ "text-fm-color-typo-primary": !u.value
1773
+ }
1774
+ ])
1775
+ }, [
1776
+ n("div", Pn, A(a.value.name), 1)
1777
+ ], 2),
1778
+ u.value ? K("", !0) : (F(), E("div", Nn, [
1779
+ $(v, {
1780
+ label: t(_)("inventory.ingredient.import.replaceFile"),
1781
+ variant: b.value ? "destructive" : "secondary",
1782
+ "prepend-icon": b.value ? void 0 : "autorenew",
1783
+ onClick: p
1784
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
1785
+ ]))
1786
+ ], 2),
1787
+ s.value.length ? (F(), E("div", Ln, [
1788
+ (F(!0), E(X, null, le(s.value, (i, T) => (F(), E("div", {
1789
+ key: T,
1790
+ class: "flex gap-8 items-center"
1791
+ }, [
1792
+ $(k, {
1793
+ name: "error",
1794
+ size: "sm",
1795
+ color: "system-error-300"
1796
+ }),
1797
+ n("div", Bn, A(i), 1)
1798
+ ]))), 128))
1799
+ ])) : K("", !0)
1800
+ ])
1801
+ ]),
1802
+ key: "0"
1803
+ } : void 0
1804
+ ]), 1032, ["class", "label", "button-label"]),
1805
+ S.value ? (F(), E("div", Un, [
1806
+ n("div", qn, A(t(_)("inventory.ingredient.import.summary")), 1),
1807
+ (F(!0), E(X, null, le(f.value, (p, i) => (F(), W(Je, {
1808
+ key: i,
1809
+ name: p.template.name,
1810
+ "transfer-type": typeof p.template.purchaseOrder.supplier.internal == "string" ? t(P).TRANSFER : t(P).PURCHASE,
1811
+ locations: p.template.locations,
1812
+ items: p.template.purchaseOrder.items,
1813
+ errors: p.errors,
1814
+ type: "create"
1815
+ }, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128)),
1816
+ (F(!0), E(X, null, le(y.value, (p) => (F(), W(Je, {
1817
+ key: p.template._id,
1818
+ name: p.template.name,
1819
+ "transfer-type": typeof p.template.purchaseOrder.supplier.internal == "string" ? t(P).TRANSFER : t(P).PURCHASE,
1820
+ locations: p.template.locations,
1821
+ items: p.template.purchaseOrder.items,
1822
+ errors: p.errors,
1823
+ type: "update"
1824
+ }, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128))
1825
+ ])) : K("", !0)
1826
+ ], 64))
1827
+ ]);
1828
+ };
1829
+ }
1830
+ }), Hn = { class: "flex-1 flex flex-col gap-8" }, zn = { class: "flex flex-col" }, jn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Wn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Gn = { class: "fm-typo-en-body-lg-400" }, Kn = { class: "fm-typo-en-body-lg-400 line-clamp-1" }, Yn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, fr = /* @__PURE__ */ J({
1831
+ __name: "TransferTemplateView",
1832
+ setup(l) {
1833
+ const { t: a } = ee(), { createTemplate: d, viewTemplate: o, importTemplates: u } = Ge(), { templateDialogProps: r, templateDetailsProps: e } = Ze(Ge()), s = ot(), { loading: f, templates: y } = Ze(s), b = L(!1), S = Tt(), _ = ie(), { breakpoints: h } = jt(), m = ke(), x = st();
1834
+ ye(s.fetchTemplates);
1835
+ const I = N(
1836
+ () => b.value || f.value || !_._currentLocation
1837
+ ), k = N(() => y.value), v = L(""), p = N(() => h.value.xs || h.value.sm), i = N(() => p.value ? 10 : 20);
1838
+ function T(C) {
1839
+ switch (C) {
1840
+ case Ke.Add:
1841
+ return d();
1842
+ case "import":
1843
+ return w();
1844
+ }
1845
+ }
1846
+ function c(C) {
1847
+ return C;
1848
+ }
1849
+ function g() {
1850
+ const C = bn(s.templates);
1851
+ m.open({
1852
+ title: a("inventory.ingredient.export.success"),
1853
+ message: a("inventory.ingredient.export.filename", [C]),
1854
+ type: "success"
1855
+ });
1856
+ }
1857
+ function w() {
1858
+ I.value || x.open({
1859
+ title: a("inventory.ingredient.import.title"),
1860
+ contentComponent: Qn,
1861
+ overlay: !0,
1862
+ closeButton: !0,
1863
+ primaryActions: {
1864
+ text: a("common.import"),
1865
+ close: !1
1866
+ },
1867
+ secondaryActions: {
1868
+ text: a("common.close"),
1869
+ close: !0
1870
+ },
1871
+ tertiaryActions: {
1872
+ text: a("inventory.ingredient.import.actions.downloadTemplate"),
1873
+ close: !1,
1874
+ variant: "plain"
1875
+ }
1876
+ }).onPrimary((C) => {
1877
+ if (!C) {
1878
+ m.open({
1879
+ title: a("inventory.ingredient.import.error.noData"),
1880
+ type: "error"
1881
+ });
1882
+ return;
1883
+ }
1884
+ if (!C.importCreateResult.length && !C.importUpdateResult.length) {
1885
+ m.open({
1886
+ title: a("inventory.ingredient.import.error.invalidContent"),
1887
+ message: a("inventory.ingredient.import.error.noImportData"),
1888
+ type: "error"
1889
+ });
1890
+ return;
1891
+ }
1892
+ if (C.importCreateResult.some((R) => R.errors.length) || C.importUpdateResult.some((R) => R.errors.length)) {
1893
+ m.open({
1894
+ title: a("inventory.ingredient.import.error.invalidContent"),
1895
+ message: a("inventory.ingredient.import.error.hasErrors"),
1896
+ type: "error"
1897
+ });
1898
+ return;
1899
+ }
1900
+ x.close(), V(C);
1901
+ }).onTertiary(xn);
1902
+ }
1903
+ async function V(C) {
1904
+ b.value = !0;
1905
+ try {
1906
+ const R = [
1907
+ ...C.importCreateResult.map(
1908
+ (O) => O.template
1909
+ ),
1910
+ ...C.importUpdateResult.map(
1911
+ (O) => O.template
1912
+ )
1913
+ ], j = 100;
1914
+ let H = 0;
1915
+ const M = () => {
1916
+ H += j, m.open({
1917
+ title: a("inventory.ingredient.import.progress", [
1918
+ Math.min(H, R.length),
1919
+ R.length
1920
+ ])
1921
+ });
1922
+ };
1923
+ for (const O of R.chunk(100))
1924
+ M(), await u(O);
1925
+ m.open({
1926
+ title: a("inventory.ingredient.import.success"),
1927
+ type: "success"
1928
+ });
1929
+ } catch (R) {
1930
+ m.open({
1931
+ title: a("inventory.ingredient.import.error.failed"),
1932
+ message: a("inventory.ingredient.import.error.systemMessage", [R == null ? void 0 : R.message]),
1933
+ type: "error"
1934
+ }), console.error("Error in importing skus", C, R);
1935
+ } finally {
1936
+ b.value = !1, s.fetchTemplates();
1937
+ }
1938
+ }
1939
+ const U = N(() => [
1940
+ { icon: "refresh", onClick: s.fetchTemplates },
1941
+ { icon: "ios_share", onClick: g }
1942
+ ]), B = N(() => [...[
1943
+ {
1944
+ label: a("inventory.transfer.template.create.title"),
1945
+ value: Ke.Add,
1946
+ isPrimary: !0,
1947
+ prependIcon: "add"
1948
+ }
1949
+ ], { label: "Import templates", value: "import" }]);
1950
+ return (C, R) => {
1951
+ const j = D("FmTable");
1952
+ return F(), E(X, null, [
1953
+ $($t, {
1954
+ title: t(a)("inventory.transfer.template.title2"),
1955
+ actions: B.value,
1956
+ "onClick:action": T
1957
+ }, {
1958
+ default: q(() => {
1959
+ var H;
1960
+ return [
1961
+ n("div", {
1962
+ class: Y([
1963
+ "flex flex-col gap-8 max-h-full",
1964
+ {
1965
+ "p-0": p.value,
1966
+ "px-24 ": !p.value
1967
+ }
1968
+ ])
1969
+ }, [
1970
+ $(wt, {
1971
+ searchable: "",
1972
+ search: v.value,
1973
+ "onUpdate:search": R[0] || (R[0] = (M) => v.value = M),
1974
+ actions: U.value
1975
+ }, null, 8, ["search", "actions"]),
1976
+ (F(), W(j, {
1977
+ style: bt(t(S).tableHeight),
1978
+ "column-defs": t(s).columnDefs,
1979
+ "row-data": k.value,
1980
+ "search-value": v.value,
1981
+ loading: I.value,
1982
+ key: (H = t(_)._currentLocation) == null ? void 0 : H.dbName,
1983
+ onRowClick: R[1] || (R[1] = (M) => t(o)(M.original)),
1984
+ "page-size": i.value
1985
+ }, {
1986
+ "list-row": q((M) => [
1987
+ $(it, {
1988
+ row: M,
1989
+ onRowClick: (O) => t(o)(O)
1990
+ }, {
1991
+ default: q((O) => {
1992
+ var re, $e, we, ue, Se, Fe, Ce, Re, me, Ie, Me, Oe, Ae, ce, De, Ee, Ve, Pe, Ne, Le, de, Be, Ue, qe, Qe, pe, He;
1993
+ return [
1994
+ n("div", Hn, [
1995
+ n("div", zn, [
1996
+ n("div", jn, [
1997
+ $(t(G), {
1998
+ render: (we = ($e = (re = O._id) == null ? void 0 : re.column) == null ? void 0 : $e.columnDef) == null ? void 0 : we.cell,
1999
+ props: (Se = (ue = O._id) == null ? void 0 : ue.getContext) == null ? void 0 : Se.call(ue)
2000
+ }, null, 8, ["render", "props"])
2001
+ ]),
2002
+ n("div", Wn, [
2003
+ $(t(G), {
2004
+ render: (Re = (Ce = (Fe = O.name) == null ? void 0 : Fe.column) == null ? void 0 : Ce.columnDef) == null ? void 0 : Re.cell,
2005
+ props: (Ie = (me = O.name) == null ? void 0 : me.getContext) == null ? void 0 : Ie.call(me)
2006
+ }, null, 8, ["render", "props"])
2007
+ ]),
2008
+ n("div", Gn, [
2009
+ $(t(G), {
2010
+ render: (Ae = (Oe = (Me = O.supplier) == null ? void 0 : Me.column) == null ? void 0 : Oe.columnDef) == null ? void 0 : Ae.cell,
2011
+ props: (De = (ce = O.supplier) == null ? void 0 : ce.getContext) == null ? void 0 : De.call(ce)
2012
+ }, null, 8, ["render", "props"])
2013
+ ]),
2014
+ n("div", null, A((Ee = M.original.locations) != null && Ee.length ? `Enabled for ${(Ve = M.original.locations) == null ? void 0 : Ve.length} outlets` : "Enabled for all outlets"), 1),
2015
+ n("div", Kn, A(M.original.purchaseOrder.items.length ? M.original.purchaseOrder.items.map((ft) => ft.name).join(", ") : "No items"), 1),
2016
+ n("div", Yn, [
2017
+ $(t(G), {
2018
+ render: (Le = (Ne = (Pe = O.ref) == null ? void 0 : Pe.column) == null ? void 0 : Ne.columnDef) == null ? void 0 : Le.cell,
2019
+ props: (Be = (de = O.ref) == null ? void 0 : de.getContext) == null ? void 0 : Be.call(de)
2020
+ }, null, 8, ["render", "props"])
2021
+ ])
2022
+ ]),
2023
+ n("div", null, [
2024
+ $(t(G), {
2025
+ render: (Qe = (qe = (Ue = O.type) == null ? void 0 : Ue.column) == null ? void 0 : qe.columnDef) == null ? void 0 : Qe.cell,
2026
+ props: (He = (pe = O.type) == null ? void 0 : pe.getContext) == null ? void 0 : He.call(pe)
2027
+ }, null, 8, ["render", "props"])
2028
+ ])
2029
+ ])
2030
+ ];
2031
+ }),
2032
+ _: 2
2033
+ }, 1032, ["row", "onRowClick"])
2034
+ ]),
2035
+ _: 1
2036
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2037
+ ], 2)
2038
+ ];
2039
+ }),
2040
+ _: 1
2041
+ }, 8, ["title", "actions"]),
2042
+ (F(), W(xt, { to: "body" }, [
2043
+ $(hn, _t(kt(t(e))), null, 16),
2044
+ $(No, Xe(t(r), {
2045
+ onSubmitted: R[2] || (R[2] = (H) => t(s).fetchTemplates())
2046
+ }), null, 16)
2047
+ ]))
2048
+ ], 64);
2049
+ };
2050
+ }
2051
+ });
2052
+ export {
2053
+ fr as default
2054
+ };