@feedmepos/mf-inventory-portal 0.0.22-dev.41 → 0.0.22-dev.42

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 (44) hide show
  1. package/dist/{ApprovalView-DKqwRFlF.js → ApprovalView-5YpqaJKy.js} +3 -3
  2. package/dist/{BindingsDialog-CtMSqEuE.js → BindingsDialog-lGoLNJyU.js} +1 -1
  3. package/dist/{BindingsPicker-DCLNF1PL.js → BindingsPicker-CdvkacXh.js} +1 -1
  4. package/dist/{BindingsTable-6ndQuHeA.js → BindingsTable-B8G9Ckdk.js} +1 -1
  5. package/dist/ClosingTemplateView-Dcy08dPm.js +1775 -0
  6. package/dist/FmDroppableField-DeW5xBTW.js +154 -0
  7. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BUGB0uk3.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DBpTwDEI.js} +3 -3
  8. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CM93v-jp.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-cSTp7zUx.js} +1 -1
  9. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-SNp8etCc.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DFHzlUVu.js} +1 -1
  10. package/dist/{IngredientsView-B1jGkWYN.js → IngredientsView-DKJjOK_4.js} +5 -5
  11. package/dist/IntegrationView-CgqU4EBV.js +1141 -0
  12. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-mZQlrYaY.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-gvpXGm1X.js} +1 -1
  13. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BEFmqnHk.js → PremiumBadge.vue_vue_type_script_setup_true_lang-B3JDjoOu.js} +2 -2
  14. package/dist/{PurchaseOrderPrintPreview-DTQViYuX.js → PurchaseOrderPrintPreview-olI-JfjI.js} +1 -1
  15. package/dist/{ReceiveRequestView-CNRixgQu.js → ReceiveRequestView-flhI8D2c.js} +10 -10
  16. package/dist/{RecipeView-HStPC5pE.js → RecipeView-CoMyQ92u.js} +4 -4
  17. package/dist/{StockView-JO3NtkX9.js → StockView-Dae47pLA.js} +5 -5
  18. package/dist/{SupplierView-gtaS4K3U.js → SupplierView-CxYZUHrc.js} +3 -3
  19. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-dPt3qbcX.js → TransferDetails.vue_vue_type_script_setup_true_lang-DoEEedkk.js} +5 -5
  20. package/dist/TransferTemplateView-DdB7z0b4.js +1302 -0
  21. package/dist/{UnitView-dbInWUk4.js → UnitView-B0E2nG3J.js} +4 -4
  22. package/dist/{WarehouseView-BlTBvLF0.js → WarehouseView-NQ2JwyWK.js} +2 -2
  23. package/dist/{app-TB3IWuaU.js → app-tiUQG6R0.js} +3917 -3873
  24. package/dist/app.d.ts +50 -3
  25. package/dist/app.js +1 -1
  26. package/dist/components/FmMultiselectDialog.vue.d.ts +3 -9
  27. package/dist/{decimal-BRAYgPnN.js → decimal-BOvNv58m.js} +1 -1
  28. package/dist/{defineDeepModel-DrEk5Fhq.js → defineDeepModel-CNgIKGt8.js} +1 -1
  29. package/dist/{format-time-from-id-kpVYfVQb.js → format-time-from-id-DWlH-AZV.js} +1 -1
  30. package/dist/format-unit-display-DIhXvTxN.js +1195 -0
  31. package/dist/stores/netsuite.d.ts +1 -1
  32. package/dist/style.css +1 -1
  33. package/dist/{supplier-CJcqHpaM.js → supplier-rpkSwf7L.js} +1 -1
  34. package/dist/tsconfig.app.tsbuildinfo +1 -1
  35. package/dist/{use-template-enabled-locations-2-DyD24laW.js → use-template-enabled-locations-2-BrK8SKvw.js} +1 -1
  36. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +7 -5
  37. package/dist/{xlsx-Dd5ckm6-.js → xlsx-DGqkxpZX.js} +1 -1
  38. package/dist/{xlsx.util-qlqvEcJz.js → xlsx.util-CvycJwUf.js} +1 -1
  39. package/package.json +1 -1
  40. package/dist/ClosingTemplateView-BPrDQ_8-.js +0 -1688
  41. package/dist/FmDroppableField-DQFPEiJn.js +0 -152
  42. package/dist/IntegrationView-Bu0waSjB.js +0 -1141
  43. package/dist/TransferTemplateView-C0pjLfbz.js +0 -2054
  44. package/dist/purchase-order-transaction-type-ZMNa__2l.js +0 -348
@@ -0,0 +1,1302 @@
1
+ import { defineComponent as J, onMounted as pe, computed as A, ref as L, watch as fe, inject as tt, resolveComponent as M, openBlock as D, createElementBlock as Q, createElementVNode as t, createVNode as c, withCtx as E, renderSlot as Le, withDirectives as Be, normalizeClass as ue, vModelText as Ue, reactive as ot, h as Z, toDisplayString as O, unref as e, createBlock as W, mergeProps as He, isRef as Qe, createCommentVNode as Y, Fragment as Ge, renderList as lt, normalizeStyle as st, Teleport as nt, normalizeProps as at, guardReactiveProps as rt } from "vue";
2
+ import { u as it, _ as ut, a as mt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-cSTp7zUx.js";
3
+ import { useI18n as X } from "@feedmepos/mf-common";
4
+ import { P as z, a as dt, f as ct, t as pt, b as qe, u as ft } from "./format-unit-display-DIhXvTxN.js";
5
+ import { F as ee, R as Ee } from "./row-action.enum-PMKMRrZR.js";
6
+ import { ai as me, t as Ne, I as yt, aj as vt, ak as bt, a as G, al as _t, D as ze, R as de, u as Ke, a3 as xt, a6 as ht, a4 as gt, r as ie, a5 as Ft, l as Tt, A as ce, M as kt, b as We, i as Ze, y as wt, k as Ct, W as ae, G as St } from "./app-tiUQG6R0.js";
7
+ import { components as re, useDialog as Mt, useSnackbar as $t, useProxiedModel as Je, useBreakpoints as It } from "@feedmepos/ui-library";
8
+ import { storeToRefs as je } from "pinia";
9
+ import "vue-router";
10
+ import { d as Xe } from "./defineDeepModel-CNgIKGt8.js";
11
+ import { c as Ot, u as Vt, _ as At } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DBpTwDEI.js";
12
+ import { u as Dt } from "./supplier-rpkSwf7L.js";
13
+ import { F as j, _ as Ye } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
14
+ import { u as Rt } from "./use-template-enabled-locations-2-BrK8SKvw.js";
15
+ import { f as Pt } from "./format-time-from-id-DWlH-AZV.js";
16
+ const Lt = { class: "flex flex-col" }, Bt = { class: "flex flex-col" }, Ut = { class: "flex-1" }, qt = { class: "flex items-center" }, Et = { class: "flex-1" }, Nt = { class: "flex-1" }, zt = /* @__PURE__ */ J({
17
+ __name: "FmMinMaxInput",
18
+ props: {
19
+ rules: {},
20
+ label: {},
21
+ minPlaceholder: {},
22
+ maxPlaceholder: {},
23
+ modelValue: {},
24
+ precision: {},
25
+ minLength: {},
26
+ maxLength: {},
27
+ inputmode: {},
28
+ type: {},
29
+ readonly: { type: Boolean },
30
+ labelMark: {},
31
+ prependIcon: {},
32
+ appendIcon: {},
33
+ showValidBorder: { type: Boolean },
34
+ labelInfo: {},
35
+ showWordCount: { type: Boolean },
36
+ invalid: { type: Boolean },
37
+ autofocus: { type: Boolean },
38
+ formatter: { type: Function },
39
+ decimal: {},
40
+ datalist: {},
41
+ shiftDatalist: { type: Boolean },
42
+ datalistMaxHeight: {},
43
+ datalistMinHeight: {},
44
+ offsetDatalist: {},
45
+ datalistPlacement: {},
46
+ datalistZIndex: {},
47
+ datalistWidth: {},
48
+ disabled: { type: Boolean },
49
+ focused: { type: Boolean },
50
+ helperText: {},
51
+ helperState: {}
52
+ },
53
+ setup(b) {
54
+ const _ = b, p = Xe("modelValue"), s = yt();
55
+ pe(() => {
56
+ const { min: v, max: a } = p ?? {};
57
+ if (!(!v || !a) && v.precision !== a.precision) {
58
+ const h = Math.max(v.precision, a.precision), r = me(v, h), y = me(a, h);
59
+ p.min = r, p.max = y;
60
+ }
61
+ });
62
+ const d = A(() => {
63
+ const { min: v, max: a } = p ?? {};
64
+ return Math.max((v == null ? void 0 : v.precision) ?? 0, (a == null ? void 0 : a.precision) ?? 0, _.precision ?? 0);
65
+ }), u = (v) => {
66
+ if (!v) return "";
67
+ const a = vt(v), h = d.value, r = me(a, h);
68
+ return bt(
69
+ +G(r),
70
+ r.precision
71
+ );
72
+ }, o = L(u(p.min)), m = L(u(p.max));
73
+ fe([o, m], ([v, a]) => {
74
+ const h = p ?? {}, r = s(v), y = s(a), l = d.value;
75
+ if (v !== "" && r === !0) {
76
+ const n = Ne(+v, l);
77
+ h.min = n;
78
+ } else
79
+ h.min = null;
80
+ if (a !== "" && y === !0) {
81
+ const n = Ne(+a, l);
82
+ h.max = n;
83
+ } else
84
+ h.max = null;
85
+ p.min = h.min, p.max = h.max;
86
+ });
87
+ const x = Symbol.for("fm:form-state"), k = tt(x, null), S = A(() => _.disabled ?? (k == null ? void 0 : k.getDisabled()) ?? !1), V = L(), g = L(), f = L(!1), w = L(!1), B = A(() => f.value || w.value), N = A(() => [...[
88
+ function() {
89
+ return typeof s(o.value) == "string" || typeof s(m.value) == "string" ? "Must be a number" : !0;
90
+ },
91
+ function(h) {
92
+ return !h || !h.min || !h.max ? !0 : +G(h.min) > +G(h.max) ? "Min must be less than or equal to max" : !0;
93
+ }
94
+ ], ..._.rules ?? []]);
95
+ return (v, a) => {
96
+ const h = M("FmLabel"), r = M("FmField"), y = M("FmFormGroup");
97
+ return D(), Q("div", Lt, [
98
+ t("div", Bt, [
99
+ t("div", Ut, [
100
+ c(h, {
101
+ label: v.label,
102
+ disabled: v.disabled,
103
+ required: v.labelMark === "required",
104
+ optional: v.labelMark === "optional"
105
+ }, null, 8, ["label", "disabled", "required", "optional"])
106
+ ]),
107
+ c(r, { focused: B.value }, {
108
+ default: E(() => [
109
+ t("div", qt, [
110
+ Le(v.$slots, "prepend"),
111
+ a[6] || (a[6] = t("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Min.", -1)),
112
+ t("div", Et, [
113
+ Be(t("input", {
114
+ type: "text",
115
+ ref_key: "minInputRef",
116
+ ref: V,
117
+ onFocus: a[0] || (a[0] = () => f.value = !0),
118
+ onBlur: a[1] || (a[1] = () => f.value = !1),
119
+ "onUpdate:modelValue": a[2] || (a[2] = (l) => o.value = l),
120
+ class: ue({
121
+ "fm-text-field--input fm-typo-en-body-lg-400": !0,
122
+ "text-fm-color-typo-primary": !S.value,
123
+ "text-fm-color-typo-disabled": S.value
124
+ })
125
+ }, null, 34), [
126
+ [Ue, o.value]
127
+ ])
128
+ ]),
129
+ a[7] || (a[7] = t("div", { class: "block h-32 mx-4 w-[1px] bg-fm-color-neutral-gray-200" }, null, -1)),
130
+ a[8] || (a[8] = t("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Max.", -1)),
131
+ t("div", Nt, [
132
+ Be(t("input", {
133
+ type: "text",
134
+ ref_key: "maxInputRef",
135
+ ref: g,
136
+ onFocus: a[3] || (a[3] = () => w.value = !0),
137
+ onBlur: a[4] || (a[4] = () => w.value = !1),
138
+ "onUpdate:modelValue": a[5] || (a[5] = (l) => m.value = l),
139
+ class: ue({
140
+ "fm-text-field--input fm-typo-en-body-lg-400": !0,
141
+ "text-fm-color-typo-primary": !S.value,
142
+ "text-fm-color-typo-disabled": S.value
143
+ })
144
+ }, null, 34), [
145
+ [Ue, m.value]
146
+ ])
147
+ ]),
148
+ Le(v.$slots, "append")
149
+ ])
150
+ ]),
151
+ _: 3
152
+ }, 8, ["focused"])
153
+ ]),
154
+ c(y, {
155
+ class: "flex-1",
156
+ "model-value": v.modelValue,
157
+ info: v.labelInfo,
158
+ rules: N.value,
159
+ "helper-text": v.helperText,
160
+ "helper-state": v.helperState
161
+ }, null, 8, ["model-value", "info", "rules", "helper-text", "helper-state"])
162
+ ]);
163
+ };
164
+ }
165
+ });
166
+ function jt() {
167
+ return function(_) {
168
+ return !_ || !_.min || !_.max ? "Required" : !0;
169
+ };
170
+ }
171
+ function Ht(b, _) {
172
+ return function(s) {
173
+ return !s || !s.min || !s.max ? !0 : +G(s.min) < b ? `Must be between ${b} and ${_}` : +G(s.max) > _ ? `Must be between ${b} and ${_}` : !0;
174
+ };
175
+ }
176
+ function Qt(b) {
177
+ const _ = _t(b), p = G(b);
178
+ return function(d) {
179
+ if (!(d != null && d.min) || !(d != null && d.max)) return !0;
180
+ const u = _(d.min) === !0, o = _(d.max) === !0;
181
+ return !u && !o ? `Min & max must be a multiple of ${p}` : u ? o ? !0 : `Max must be a multiple of ${p}` : `Min must be a multiple of ${p}`;
182
+ };
183
+ }
184
+ var P = /* @__PURE__ */ ((b) => (b.Code = "Code", b.Name = "Name", b.DefaultAmount = "DefaultAmount", b.Limit = "Limit", b.MinimumAmount = "MinimumAmount", b.Step = "Step", b.Cost = "Cost", b.Delete = "Delete", b))(P || {});
185
+ function Gt(b) {
186
+ const { t: _ } = X(), p = ot({});
187
+ pe(() => {
188
+ for (const u of b.items) {
189
+ if (!u.totalCost)
190
+ continue;
191
+ const o = Ot(u.sku, u.quantity, u.measurement, {
192
+ supplier: b.supplier
193
+ }), m = u.totalCost ?? ze.reset();
194
+ o ? p[u.sku._id] = o.amount !== m.amount || o.precision !== m.precision : p[u.sku._id] = !0;
195
+ }
196
+ });
197
+ const s = [
198
+ {
199
+ id: "Code",
200
+ header: () => _("inventory.transfer.form.items.table.Code"),
201
+ accessorKey: "code",
202
+ size: 96,
203
+ cell(u) {
204
+ const o = u.row.original;
205
+ return Z(re.FmTextField, {
206
+ modelValue: o.code,
207
+ "onUpdate:modelValue": (m) => {
208
+ b.updateItem({
209
+ ...o,
210
+ code: m
211
+ });
212
+ },
213
+ key: o.sku._id,
214
+ rules: [de()],
215
+ labelMark: "required"
216
+ });
217
+ },
218
+ enableSorting: !1
219
+ },
220
+ {
221
+ id: "Name",
222
+ header: () => _("inventory.transfer.form.items.table.Name"),
223
+ minSize: 300,
224
+ cell(u) {
225
+ const o = u.row.original;
226
+ return Z(re.FmTextField, {
227
+ modelValue: o.name,
228
+ "onUpdate:modelValue": (m) => {
229
+ b.updateItem({
230
+ ...o,
231
+ name: m
232
+ });
233
+ },
234
+ key: o.sku._id,
235
+ rules: [de()],
236
+ labelMark: "required"
237
+ });
238
+ },
239
+ enableSorting: !1
240
+ },
241
+ {
242
+ id: "DefaultAmount",
243
+ header: () => _("inventory.transfer.form.items.table.DefaultAmount"),
244
+ minSize: 200,
245
+ cell(u) {
246
+ var g;
247
+ const o = u.row.original, m = Ke(), x = m.skuById[o.sku._id], k = m.unitById[(g = x.unit) == null ? void 0 : g._id], S = k.measurements.find((f) => {
248
+ var w;
249
+ return ((w = o.measurement) == null ? void 0 : w.id) === f.id;
250
+ }), V = o.sku.unit._id !== x.unit._id || !k || o.measurement && !S;
251
+ return Z(xt, {
252
+ style: {
253
+ flex: "1 1 0%"
254
+ },
255
+ modelValue: {
256
+ amount: o.quantity ?? { amount: 1, precision: 0 },
257
+ // NOTE: leave this reading from row.sku.unit and row.measurement instead,
258
+ measurement: o.measurement ?? (o.sku.unit._id !== x.unit._id ? { ...o.sku.unit, id: "", conversion: { amount: 1, precision: 0 } } : null)
259
+ },
260
+ disabled: b.disabled,
261
+ key: o.sku._id,
262
+ unit: k,
263
+ "onUpdate:modelValue": (f) => {
264
+ b.updateItem({
265
+ ...o,
266
+ sku: x,
267
+ quantity: f.amount,
268
+ measurement: f.measurement
269
+ });
270
+ },
271
+ rules: [
272
+ ht(o.quantityStep),
273
+ gt(
274
+ +G(
275
+ o.minimumQuantity ?? {
276
+ amount: 1,
277
+ // NOTE: leave this reading from row.sku.unit and row.measurement instead,
278
+ precision: ie(o.sku.unit, o.measurement)
279
+ }
280
+ )
281
+ ),
282
+ Ft(
283
+ o.maximumQuantity ? +G(o.maximumQuantity) : 1 / 0
284
+ ),
285
+ function(w) {
286
+ return V ? "This item is no longer valid due to change in unit. Please reapply unit." : !0;
287
+ }
288
+ ],
289
+ applyDefaultRules: !0
290
+ });
291
+ },
292
+ enableSorting: !1
293
+ },
294
+ {
295
+ id: "Limit",
296
+ header: () => "Limit",
297
+ // TODO: i18n,
298
+ minSize: 280,
299
+ cell(u) {
300
+ const o = u.row.original;
301
+ return Z(zt, {
302
+ style: {
303
+ flex: "1 1 0%"
304
+ },
305
+ modelValue: {
306
+ min: o.minimumQuantity,
307
+ max: o.maximumQuantity
308
+ },
309
+ disabled: b.disabled,
310
+ key: o.sku._id,
311
+ unit: o.sku.unit,
312
+ "onUpdate:modelValue": (m) => {
313
+ const x = { ...o };
314
+ m != null && m.min && (x.minimumQuantity = m.min), m != null && m.max && (x.maximumQuantity = m.max), b.updateItem(x);
315
+ },
316
+ rules: [
317
+ jt(),
318
+ Qt(o.quantityStep),
319
+ Ht(
320
+ +G({
321
+ amount: 1,
322
+ precision: ie(o.sku.unit, o.measurement)
323
+ }),
324
+ 1 / 0
325
+ )
326
+ ],
327
+ disableUnit: !0,
328
+ applyDefaultRules: !0
329
+ });
330
+ }
331
+ },
332
+ {
333
+ id: "Step",
334
+ header: () => _("inventory.transfer.form.items.table.Step"),
335
+ minSize: 100,
336
+ cell(u) {
337
+ const o = u.row.original;
338
+ return Z(re.FmTextField, {
339
+ modelValue: G(o.quantityStep ?? ze.reset(), !1),
340
+ key: o.sku._id,
341
+ "onUpdate:modelValue": (m) => {
342
+ b.updateItem({
343
+ ...o,
344
+ quantityStep: Tt(+m)
345
+ });
346
+ },
347
+ rules: [
348
+ ce({
349
+ amount: 1,
350
+ precision: ie(o.sku.unit, o.measurement)
351
+ }),
352
+ kt(o.sku.unit, o.measurement)
353
+ ]
354
+ });
355
+ },
356
+ enableSorting: !1
357
+ },
358
+ {
359
+ id: "Delete",
360
+ header: "",
361
+ cell(u) {
362
+ const o = u.row.original;
363
+ return Z(re.FmButton, {
364
+ class: "delete-button",
365
+ key: o.sku._id,
366
+ type: "button",
367
+ icon: "delete",
368
+ variant: "tertiary",
369
+ size: "md",
370
+ disabled: b.disabled,
371
+ onClick: () => {
372
+ b.deleteItem(o);
373
+ }
374
+ });
375
+ },
376
+ enableSorting: !1,
377
+ size: 40,
378
+ meta: {
379
+ cellClass: "",
380
+ headerClass: ""
381
+ }
382
+ }
383
+ ];
384
+ return {
385
+ columnDefs: A(() => We().enableTotalCost && b.transferType === z.PURCHASE ? s : s.filter((o) => o.id !== "Cost"))
386
+ };
387
+ }
388
+ const Kt = { class: "flex flex-col gap-8 py-16" }, Wt = { class: "flex items-center" }, Zt = { class: "flex-1 flex gap-1 items-center" }, Jt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Xt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Yt = { class: "flex gap-8 w-full" }, eo = { class: "flex-1 flex flex-col gap-4" }, to = { class: "flex-1 flex flex-col gap-4" }, oo = { class: "flex gap-8 w-full" }, lo = { class: "flex-1 flex flex-col gap-4" }, so = { class: "flex-1 flex flex-col gap-4" }, no = { class: "flex gap-8 w-full" }, ao = { class: "flex-1 flex flex-col gap-4" }, ro = /* @__PURE__ */ J({
389
+ __name: "TransferTemplateItem",
390
+ props: {
391
+ cellByColId: {},
392
+ row: {}
393
+ },
394
+ setup(b) {
395
+ const { t: _ } = X();
396
+ return (p, s) => {
397
+ var u, o, m, x, k, S, V, g, f, w, B, N, v, a, h, r, y, l, n, i, $, R, F, C, U, H, K, T, I, q;
398
+ const d = M("FmLabel");
399
+ return D(), Q("div", Kt, [
400
+ t("div", Wt, [
401
+ t("div", Zt, [
402
+ t("span", Jt, " (" + O(p.row.original.sku.code) + ") ", 1),
403
+ t("span", Xt, O(p.row.original.sku.name), 1)
404
+ ]),
405
+ t("div", null, [
406
+ c(e(j), {
407
+ render: (m = (o = (u = p.cellByColId.Delete) == null ? void 0 : u.column) == null ? void 0 : o.columnDef) == null ? void 0 : m.cell,
408
+ props: (k = (x = p.cellByColId.Delete) == null ? void 0 : x.getContext) == null ? void 0 : k.call(x)
409
+ }, null, 8, ["render", "props"])
410
+ ])
411
+ ]),
412
+ t("div", Yt, [
413
+ t("div", eo, [
414
+ c(d, {
415
+ label: e(_)(`inventory.transfer.form.items.table.${e(P).Code}`)
416
+ }, null, 8, ["label"]),
417
+ c(e(j), {
418
+ render: (g = (V = (S = p.cellByColId[e(P).Code]) == null ? void 0 : S.column) == null ? void 0 : V.columnDef) == null ? void 0 : g.cell,
419
+ props: (w = (f = p.cellByColId[e(P).Code]) == null ? void 0 : f.getContext) == null ? void 0 : w.call(f)
420
+ }, null, 8, ["render", "props"]),
421
+ s[0] || (s[0] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
422
+ ]),
423
+ t("div", to, [
424
+ c(d, {
425
+ label: e(_)(`inventory.transfer.form.items.table.${e(P).Name}`)
426
+ }, null, 8, ["label"]),
427
+ c(e(j), {
428
+ render: (v = (N = (B = p.cellByColId[e(P).Name]) == null ? void 0 : B.column) == null ? void 0 : N.columnDef) == null ? void 0 : v.cell,
429
+ props: (h = (a = p.cellByColId[e(P).Name]) == null ? void 0 : a.getContext) == null ? void 0 : h.call(a)
430
+ }, null, 8, ["render", "props"]),
431
+ s[1] || (s[1] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
432
+ ])
433
+ ]),
434
+ t("div", oo, [
435
+ t("div", lo, [
436
+ c(d, {
437
+ label: e(_)(`inventory.transfer.form.items.table.${e(P).DefaultAmount}`)
438
+ }, null, 8, ["label"]),
439
+ c(e(j), {
440
+ render: (l = (y = (r = p.cellByColId[e(P).DefaultAmount]) == null ? void 0 : r.column) == null ? void 0 : y.columnDef) == null ? void 0 : l.cell,
441
+ props: (i = (n = p.cellByColId[e(P).DefaultAmount]) == null ? void 0 : n.getContext) == null ? void 0 : i.call(n)
442
+ }, null, 8, ["render", "props"]),
443
+ s[2] || (s[2] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
444
+ ]),
445
+ t("div", so, [
446
+ c(d, {
447
+ label: e(_)(`inventory.transfer.form.items.table.${e(P).Step}`)
448
+ }, null, 8, ["label"]),
449
+ c(e(j), {
450
+ render: (F = (R = ($ = p.cellByColId[e(P).Step]) == null ? void 0 : $.column) == null ? void 0 : R.columnDef) == null ? void 0 : F.cell,
451
+ props: (U = (C = p.cellByColId[e(P).Step]) == null ? void 0 : C.getContext) == null ? void 0 : U.call(C)
452
+ }, null, 8, ["render", "props"]),
453
+ s[3] || (s[3] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
454
+ ])
455
+ ]),
456
+ t("div", no, [
457
+ t("div", ao, [
458
+ c(d, {
459
+ label: e(_)(`inventory.transfer.form.items.table.${e(P).Limit}`)
460
+ }, null, 8, ["label"]),
461
+ c(e(j), {
462
+ render: (T = (K = (H = p.cellByColId[e(P).Limit]) == null ? void 0 : H.column) == null ? void 0 : K.columnDef) == null ? void 0 : T.cell,
463
+ props: (q = (I = p.cellByColId[e(P).Limit]) == null ? void 0 : I.getContext) == null ? void 0 : q.call(I)
464
+ }, null, 8, ["render", "props"]),
465
+ s[4] || (s[4] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
466
+ ])
467
+ ])
468
+ ]);
469
+ };
470
+ }
471
+ }), io = { class: "flex flex-col gap-16" }, uo = { class: "flex flex-col gap-24" }, mo = { class: "flex flex-col gap-16" }, co = { class: "flex items-center" }, po = { class: "flex flex-col" }, fo = { class: "flex flex-col gap-16" }, yo = { class: "flex" }, vo = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, bo = /* @__PURE__ */ J({
472
+ __name: "TransferTemplateForm",
473
+ props: {
474
+ modelValue: {},
475
+ disabled: { type: Boolean }
476
+ },
477
+ setup(b, { expose: _ }) {
478
+ const p = b, s = Xe(), { t: d } = X(), u = Ze(), o = Ke(), m = Dt();
479
+ fe(
480
+ () => p.modelValue,
481
+ (l) => {
482
+ console.log("TransferTemplateForm.model", l);
483
+ }
484
+ ), u.watchLocation(async () => {
485
+ location && (s.purchaseOrder.supplier || (s.purchaseOrder.supplier = m.suppliers.find((l) => l) ?? s.purchaseOrder.supplier));
486
+ });
487
+ const x = Mt(), k = Vt(
488
+ () => s.purchaseOrder,
489
+ (l) => {
490
+ s.purchaseOrder = {
491
+ ...s.purchaseOrder,
492
+ supplier: l.supplier ?? (s == null ? void 0 : s.purchaseOrder.supplier)
493
+ };
494
+ }
495
+ ), S = A({
496
+ get() {
497
+ var l, n;
498
+ return typeof ((n = (l = s.purchaseOrder) == null ? void 0 : l.supplier) == null ? void 0 : n.internal) == "string" ? z.TRANSFER : z.PURCHASE;
499
+ },
500
+ set(l) {
501
+ var i, $;
502
+ const n = typeof (($ = (i = s.purchaseOrder) == null ? void 0 : i.supplier) == null ? void 0 : $.internal) == "string" ? z.TRANSFER : z.PURCHASE;
503
+ l !== n && (s.purchaseOrder.supplier = l === z.PURCHASE ? k.locationOptionsTypePurchase.value[0] : k.locationOptionsTypeTransfer.value[0]);
504
+ }
505
+ }), V = A(() => k.transferLocationOptions.value), g = A({
506
+ get() {
507
+ var l;
508
+ return (l = s.purchaseOrder.supplier) == null ? void 0 : l._id;
509
+ },
510
+ set(l) {
511
+ k.transferLocationModel.value = l;
512
+ }
513
+ }), {
514
+ promptSelectLocations: f,
515
+ columnDefs: w,
516
+ rowData: B
517
+ } = Rt({
518
+ getLocations() {
519
+ return s.locations;
520
+ },
521
+ setLocations(l) {
522
+ s.locations = l;
523
+ }
524
+ });
525
+ function N() {
526
+ var l, n;
527
+ return (l = s.locations) != null && l.find((i) => {
528
+ var $, R;
529
+ return (($ = i.doc) == null ? void 0 : $._id) === ((R = s.purchaseOrder.supplier) == null ? void 0 : R._id);
530
+ }) ? `Location ${(n = s.purchaseOrder.supplier) == null ? void 0 : n.name} must be removed because template cannot be used to transfer to itself.` : !0;
531
+ }
532
+ const v = A({
533
+ get() {
534
+ return s.purchaseOrder.remark ?? void 0;
535
+ },
536
+ set(l) {
537
+ s.purchaseOrder.remark = l;
538
+ }
539
+ }), a = L();
540
+ _({
541
+ validateInputs: () => {
542
+ var l, n;
543
+ (n = (l = a.value) == null ? void 0 : l.validateInputs) == null || n.call(l);
544
+ },
545
+ resetInputsValidation: () => {
546
+ var l, n;
547
+ (n = (l = a.value) == null ? void 0 : l.resetInputsValidation) == null || n.call(l);
548
+ },
549
+ resetInputs: () => {
550
+ var l, n;
551
+ (n = (l = a.value) == null ? void 0 : l.resetInputs) == null || n.call(l);
552
+ }
553
+ });
554
+ const h = Gt({
555
+ updateItem: (l) => {
556
+ s.purchaseOrder.items = s.purchaseOrder.items.map((n) => n.sku._id !== l.sku._id ? n : l);
557
+ },
558
+ deleteItem: (l) => {
559
+ s.purchaseOrder.items = s.purchaseOrder.items.filter(
560
+ (n) => n.sku._id !== l.sku._id
561
+ );
562
+ },
563
+ get supplier() {
564
+ return s.purchaseOrder.supplier;
565
+ },
566
+ get items() {
567
+ return s.purchaseOrder.items;
568
+ },
569
+ get transferType() {
570
+ return z.PURCHASE;
571
+ },
572
+ get disabled() {
573
+ return p.disabled;
574
+ }
575
+ }), r = A(() => h.columnDefs.value);
576
+ function y() {
577
+ const l = o.skus.map((i) => ({
578
+ label: i.name,
579
+ sublabel: i.code,
580
+ value: i
581
+ })), n = l.filter((i) => {
582
+ var $;
583
+ return ($ = s.purchaseOrder.items) == null ? void 0 : $.find((R) => R.sku._id === i.value._id);
584
+ }).map((i) => i.value);
585
+ x.open({
586
+ title: d("inventory.transfer.form.items.selectItem"),
587
+ closeButton: !0,
588
+ contentComponent: wt,
589
+ contentComponentProps: {
590
+ modelValue: n,
591
+ items: l,
592
+ virtualScroll: !0
593
+ },
594
+ primaryActions: {
595
+ text: d("common.confirm"),
596
+ close: !0
597
+ },
598
+ secondaryActions: {
599
+ text: d("common.close"),
600
+ close: !0,
601
+ variant: "tertiary"
602
+ }
603
+ }).onPrimary((i) => {
604
+ const $ = s.purchaseOrder.items ?? [], R = i.map((F) => {
605
+ const C = $.find((K) => K.sku._id === F._id);
606
+ if (C)
607
+ return C;
608
+ const U = { amount: 1, precision: ie(F.unit) };
609
+ return {
610
+ sku: F,
611
+ code: F.code,
612
+ name: F.name,
613
+ quantity: U,
614
+ minimumQuantity: U,
615
+ maximumQuantity: Ct(U, {
616
+ amount: 100,
617
+ precision: 0
618
+ }),
619
+ quantityStep: U
620
+ };
621
+ });
622
+ R.sort((F, C) => F.sku.code.localeCompare(C.sku.code)), s.purchaseOrder.items = R;
623
+ });
624
+ }
625
+ return (l, n) => {
626
+ const i = M("FmTextField"), $ = M("FmSelect"), R = M("FmTextarea"), F = M("FmButton"), C = M("FmTable"), U = M("FmFormGroup"), H = M("FmForm");
627
+ return D(), W(H, {
628
+ ref_key: "formRef",
629
+ ref: a,
630
+ class: "flex flex-col gap-32",
631
+ disabled: l.disabled
632
+ }, {
633
+ default: E(() => {
634
+ var K;
635
+ return [
636
+ t("div", io, [
637
+ t("div", uo, [
638
+ c(i, {
639
+ label: e(d)("inventory.transfer.form.name"),
640
+ "label-mark": "required",
641
+ modelValue: e(s).name,
642
+ "onUpdate:modelValue": n[0] || (n[0] = (T) => e(s).name = T),
643
+ rules: [e(de)()]
644
+ }, null, 8, ["label", "modelValue", "rules"]),
645
+ c($, {
646
+ label: e(d)("inventory.transfer.form.type.title"),
647
+ "model-value": S.value,
648
+ "onUpdate:modelValue": n[1] || (n[1] = (T) => S.value = T),
649
+ items: [
650
+ {
651
+ label: e(d)("inventory.transfer.form.type.purchase"),
652
+ value: e(z).PURCHASE,
653
+ disabled: !e(k).locationOptionsTypePurchase.value.length,
654
+ sublabel: e(k).locationOptionsTypePurchase.value.length ? void 0 : e(d)("inventory.transfer.form.noSupplierAvailable")
655
+ },
656
+ {
657
+ label: e(d)("inventory.transfer.form.type.transfer"),
658
+ value: e(z).TRANSFER,
659
+ disabled: !e(k).locationOptionsTypeTransfer.value.length,
660
+ sublabel: e(k).locationOptionsTypeTransfer.value.length ? void 0 : e(d)("inventory.transfer.form.noLocationAvailable")
661
+ }
662
+ ],
663
+ rules: [e(ce)(1)(V.value)]
664
+ }, null, 8, ["label", "model-value", "items", "rules"]),
665
+ c($, {
666
+ label: S.value === e(z).PURCHASE ? e(d)("inventory.transfer.form.purchaseFrom") : e(d)("inventory.transfer.form.transferFrom"),
667
+ modelValue: g.value,
668
+ "onUpdate:modelValue": n[2] || (n[2] = (T) => g.value = T),
669
+ items: V.value
670
+ }, {
671
+ "menu-wrapper": E((T) => {
672
+ var I;
673
+ return [
674
+ c(At, He(T, {
675
+ items: V.value,
676
+ "model-value": (I = l.modelValue.purchaseOrder.supplier) == null ? void 0 : I._id
677
+ }), null, 16, ["items", "model-value"])
678
+ ];
679
+ }),
680
+ _: 1
681
+ }, 8, ["label", "modelValue", "items"]),
682
+ c(i, {
683
+ label: e(d)("inventory.transfer.form.reference"),
684
+ "label-mark": "optional",
685
+ modelValue: e(s).purchaseOrder.ref,
686
+ "onUpdate:modelValue": n[3] || (n[3] = (T) => e(s).purchaseOrder.ref = T)
687
+ }, null, 8, ["label", "modelValue"]),
688
+ c(R, {
689
+ label: e(d)("inventory.transfer.form.remark"),
690
+ "label-mark": "optional",
691
+ "max-length": 240,
692
+ modelValue: v.value,
693
+ "onUpdate:modelValue": n[4] || (n[4] = (T) => v.value = T),
694
+ class: ue({ "text-fm-color-typo-disabled": l.disabled })
695
+ }, null, 8, ["label", "modelValue", "class"])
696
+ ])
697
+ ]),
698
+ t("div", mo, [
699
+ t("div", co, [
700
+ n[6] || (n[6] = t("div", { class: "flex-1 fm-typo-en-title-sm-600" }, "Locations", -1)),
701
+ c(F, {
702
+ disabled: l.disabled,
703
+ label: "Select location",
704
+ "prepend-icon": "add",
705
+ variant: "plain",
706
+ class: "border-2 rounded-lg border-fm-color-primary",
707
+ onClick: e(f)
708
+ }, null, 8, ["disabled", "onClick"])
709
+ ]),
710
+ c(C, {
711
+ "column-defs": e(w),
712
+ "row-data": e(B),
713
+ "shrink-at": 9999,
714
+ onRowClick: e(f),
715
+ "hide-footer": ""
716
+ }, null, 8, ["column-defs", "row-data", "onRowClick"]),
717
+ t("div", po, [
718
+ c(U, {
719
+ "model-value": [
720
+ (K = p.modelValue.purchaseOrder.supplier) == null ? void 0 : K._id,
721
+ ...p.modelValue.locations ?? []
722
+ ].join(","),
723
+ rules: [N]
724
+ }, null, 8, ["model-value", "rules"])
725
+ ])
726
+ ]),
727
+ t("div", fo, [
728
+ t("div", yo, [
729
+ t("div", vo, O(e(d)("inventory.transfer.form.items.title")), 1),
730
+ c(F, {
731
+ disabled: l.disabled,
732
+ label: e(d)("inventory.transfer.form.items.addItem"),
733
+ "prepend-icon": "add",
734
+ variant: "plain",
735
+ class: "border-2 rounded-lg border-fm-color-primary",
736
+ onClick: n[5] || (n[5] = (T) => y()),
737
+ size: "md"
738
+ }, null, 8, ["disabled", "label"])
739
+ ]),
740
+ (D(), W(C, {
741
+ "column-defs": r.value,
742
+ "row-data": e(s).purchaseOrder.items,
743
+ key: e(s).purchaseOrder.items.map((T) => T.sku._id).join("."),
744
+ "hide-footer": "",
745
+ "page-size": e(s).purchaseOrder.items.length
746
+ }, {
747
+ "list-row": E((T) => [
748
+ (D(), W(Ye, {
749
+ row: T,
750
+ key: e(s).purchaseOrder.items.map((I) => I.sku._id).join(".")
751
+ }, {
752
+ default: E((I) => [
753
+ c(ro, {
754
+ row: T,
755
+ "cell-by-col-id": I
756
+ }, null, 8, ["row", "cell-by-col-id"])
757
+ ]),
758
+ _: 2
759
+ }, 1032, ["row"]))
760
+ ]),
761
+ _: 1
762
+ }, 8, ["column-defs", "row-data", "page-size"])),
763
+ c(U, {
764
+ "model-value": e(s).purchaseOrder.items.length,
765
+ rules: [e(ce)(1)]
766
+ }, null, 8, ["model-value", "rules"])
767
+ ])
768
+ ];
769
+ }),
770
+ _: 1
771
+ }, 8, ["disabled"]);
772
+ };
773
+ }
774
+ }), _o = { class: "flex items-center" }, xo = { class: "fm-typo-en-title-md-800" }, ho = { class: "flex gap-4" }, go = /* @__PURE__ */ J({
775
+ __name: "TransferTemplateDialog",
776
+ props: {
777
+ mode: {},
778
+ modelValue: {},
779
+ show: { type: Boolean }
780
+ },
781
+ emits: ["update:show", "submitted"],
782
+ setup(b, { expose: _, emit: p }) {
783
+ var h;
784
+ const s = b, d = p, u = dt(), o = $t(), { t: m } = X(), x = Je(s, "show");
785
+ function k() {
786
+ return {
787
+ _id: "",
788
+ name: "",
789
+ purchaseOrder: {
790
+ remark: void 0,
791
+ ref: void 0,
792
+ items: [],
793
+ supplier: {
794
+ _rev: void 0,
795
+ email: void 0,
796
+ internal: void 0,
797
+ contactName: void 0,
798
+ phoneNumber: void 0,
799
+ registrationNumber: void 0,
800
+ supplyItems: void 0,
801
+ _id: "",
802
+ name: "",
803
+ address: {
804
+ line2: void 0,
805
+ line1: "",
806
+ state: "",
807
+ city: "",
808
+ postcode: "",
809
+ country: ""
810
+ }
811
+ }
812
+ }
813
+ };
814
+ }
815
+ const S = L(s.modelValue ?? k()), V = L(((h = s.modelValue) == null ? void 0 : h._id) ?? `${Math.random()}`);
816
+ fe(
817
+ () => s.show,
818
+ (r) => {
819
+ var y;
820
+ r && (S.value = s.modelValue ?? k(), V.value = ((y = s.modelValue) == null ? void 0 : y._id) ?? `${Math.random()}`);
821
+ }
822
+ );
823
+ const g = L(!1), f = A(() => {
824
+ switch (s.mode) {
825
+ case ee.READ:
826
+ return "";
827
+ case ee.CREATE:
828
+ return m("inventory.transfer.template.create.title");
829
+ case ee.UPDATE:
830
+ return m("inventory.transfer.template.update.title");
831
+ }
832
+ return "";
833
+ }), w = L();
834
+ _({
835
+ validateInputs: () => {
836
+ var r, y;
837
+ (y = (r = w.value) == null ? void 0 : r.validateInputs) == null || y.call(r);
838
+ },
839
+ resetInputsValidation: () => {
840
+ var r, y;
841
+ (y = (r = w.value) == null ? void 0 : r.resetInputsValidation) == null || y.call(r);
842
+ },
843
+ resetInputs: () => {
844
+ var r, y;
845
+ (y = (r = w.value) == null ? void 0 : r.resetInputs) == null || y.call(r);
846
+ }
847
+ });
848
+ async function B() {
849
+ var y, l;
850
+ const r = S.value;
851
+ if (r) {
852
+ g.value = !0, (((y = r.purchaseOrder.supplier) == null ? void 0 : y.internal) === ae.enum.warehouse || ((l = r.purchaseOrder.supplier) == null ? void 0 : l.internal) === ae.enum.restaurant) && (r.purchaseOrder.items = r.purchaseOrder.items.map(
853
+ ({ totalCost: n, ...i }) => i
854
+ ));
855
+ try {
856
+ await u.createTemplate(r), await new Promise((n) => setTimeout(n, 1e3)), o.open({
857
+ title: m("inventory.transfer.template.create.success"),
858
+ message: m("inventory.transfer.template.create.successMessage"),
859
+ type: "success"
860
+ }), d("update:show", !1), d("submitted");
861
+ } catch (n) {
862
+ o.open({
863
+ title: m("inventory.transfer.template.create.error"),
864
+ message: m("inventory.transfer.template.create.errorMessage"),
865
+ type: "error"
866
+ }), console.error("Error in creating transfer template", n);
867
+ } finally {
868
+ g.value = !1;
869
+ }
870
+ }
871
+ }
872
+ async function N() {
873
+ var y, l;
874
+ const r = S.value;
875
+ if (r) {
876
+ g.value = !0, (((y = r.purchaseOrder.supplier) == null ? void 0 : y.internal) === ae.enum.warehouse || ((l = r.purchaseOrder.supplier) == null ? void 0 : l.internal) === ae.enum.restaurant) && (r.purchaseOrder.items = r.purchaseOrder.items.map(
877
+ ({ totalCost: n, ...i }) => i
878
+ ));
879
+ try {
880
+ await u.updateTemplate(r), await new Promise((n) => setTimeout(n, 1e3)), o.open({
881
+ title: m("inventory.transfer.template.update.success"),
882
+ message: m("inventory.transfer.template.update.successMessage"),
883
+ type: "success"
884
+ }), d("update:show", !1), d("submitted");
885
+ } catch (n) {
886
+ o.open({
887
+ title: m("inventory.transfer.template.update.error"),
888
+ message: m("inventory.transfer.template.update.errorMessage"),
889
+ type: "error"
890
+ }), console.error("Error in updating transfer template", n);
891
+ } finally {
892
+ g.value = !1;
893
+ }
894
+ }
895
+ }
896
+ function v() {
897
+ switch (s.mode) {
898
+ case ee.CREATE:
899
+ return B();
900
+ case ee.UPDATE:
901
+ return N();
902
+ }
903
+ }
904
+ function a() {
905
+ var r, y;
906
+ (y = (r = w.value) == null ? void 0 : r.validateInputs) == null || y.call(r);
907
+ }
908
+ return (r, y) => {
909
+ const l = M("FmButton"), n = M("FmSideSheet");
910
+ return D(), W(n, {
911
+ modelValue: e(x),
912
+ "onUpdate:modelValue": y[2] || (y[2] = (i) => Qe(x) ? x.value = i : null),
913
+ "dismiss-away": "",
914
+ "close-button": "",
915
+ "max-width": 1200
916
+ }, {
917
+ "side-sheet-header": E(() => [
918
+ t("div", _o, [
919
+ t("div", xo, O(f.value), 1)
920
+ ])
921
+ ]),
922
+ default: E(() => [
923
+ (D(), W(bo, {
924
+ class: "w-full",
925
+ ref_key: "formRef",
926
+ ref: w,
927
+ onValidationSuccess: v,
928
+ "model-value": S.value,
929
+ "onUpdate:modelValue": y[0] || (y[0] = (i) => S.value = i),
930
+ disabled: g.value,
931
+ key: V.value
932
+ }, null, 8, ["model-value", "disabled"]))
933
+ ]),
934
+ "side-sheet-footer": E(() => [
935
+ t("div", ho, [
936
+ c(l, {
937
+ loading: g.value,
938
+ label: e(m)("common.save"),
939
+ onClick: a
940
+ }, null, 8, ["loading", "label"]),
941
+ c(l, {
942
+ disabled: g.value,
943
+ variant: "tertiary",
944
+ label: e(m)("common.close"),
945
+ onClick: y[1] || (y[1] = (i) => d("update:show", !1))
946
+ }, null, 8, ["disabled", "label"])
947
+ ])
948
+ ]),
949
+ _: 1
950
+ }, 8, ["modelValue"]);
951
+ };
952
+ }
953
+ }), Fo = { class: "flex flex-col gap-16 w-full h-full overflow-y-auto" }, To = { class: "flex justify-between" }, ko = { class: "fm-typo-en-body-lg-600" }, wo = { class: "fm-status-badge fm-status-badge-info-secondary" }, Co = { class: "flex flex-col gap-8" }, So = { class: "flex flex-col gap-4" }, Mo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, $o = { class: "flex gap-1" }, Io = { class: "fm-typo-en-body-lg-600" }, Oo = {
954
+ key: 0,
955
+ class: "flex flex-col gap-4"
956
+ }, Vo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ao = { class: "fm-typo-en-body-lg-600" }, Do = {
957
+ key: 1,
958
+ class: "flex flex-col gap-4"
959
+ }, Ro = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Po = { class: "fm-typo-en-body-lg-600" }, Lo = {
960
+ key: 2,
961
+ class: "flex flex-col gap-4"
962
+ }, Bo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Uo = { class: "fm-typo-en-body-lg-600" }, qo = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Eo = { class: "flex flex-col gap-8" }, No = { class: "fm-typo-en-body-lg-600" }, zo = { class: "flex w-full gap-4" }, jo = { class: "grow fm-typo-en-body-lg-400 line-clamp-2" }, Ho = { class: "fm-typo-en-body-lg-600 shrink-0" }, Qo = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Go = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Ko = {
963
+ key: 0,
964
+ class: "shrink-0 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
965
+ }, Wo = {
966
+ key: 0,
967
+ class: "flex gap-4 items-center"
968
+ }, Zo = { class: "flex flex-col gap-12" }, Jo = { class: "flex flex-col gap-8" }, Xo = { class: "flex gap-8 xs:flex-col" }, Yo = /* @__PURE__ */ J({
969
+ __name: "TransferTemplateDetails",
970
+ props: {
971
+ template: {},
972
+ show: { type: Boolean }
973
+ },
974
+ emits: ["update:show", "action:edit"],
975
+ setup(b, { emit: _ }) {
976
+ const p = b, s = _, d = We(), { t: u } = X(), o = A(() => {
977
+ var g;
978
+ return (g = p.template) == null ? void 0 : g.purchaseOrder;
979
+ }), m = [
980
+ { accessorKey: "name", header: () => "Name" },
981
+ { accessorKey: "type", header: () => "Type" }
982
+ ], x = L(""), k = A(
983
+ () => {
984
+ var g, f, w, B;
985
+ return ((f = (g = o.value) == null ? void 0 : g.supplier) == null ? void 0 : f.internal) === "restaurant" || ((B = (w = o.value) == null ? void 0 : w.supplier) == null ? void 0 : B.internal) === "warehouse" ? z.TRANSFER : z.PURCHASE;
986
+ }
987
+ ), S = L(!0), V = Je(p, "show");
988
+ return (g, f) => {
989
+ var y;
990
+ const w = M("FmMenuDivider"), B = M("FmCard"), N = M("FmIcon"), v = M("FmTextField"), a = M("FmTable"), h = M("FmButton"), r = M("FmSideSheet");
991
+ return D(), W(r, {
992
+ header: e(u)("inventory.transfer.template.details.view", { template: (y = g.template) == null ? void 0 : y.name }),
993
+ modelValue: e(V),
994
+ "onUpdate:modelValue": f[2] || (f[2] = (l) => Qe(V) ? V.value = l : null),
995
+ "dismiss-away": S.value,
996
+ "close-button": "",
997
+ "max-width": 500
998
+ }, {
999
+ default: E(() => {
1000
+ var l, n;
1001
+ return [
1002
+ t("div", Fo, [
1003
+ t("div", null, [
1004
+ c(B, {
1005
+ variant: "outlined",
1006
+ class: "flex flex-col gap-8 px-12 py-16"
1007
+ }, {
1008
+ default: E(() => {
1009
+ var i, $, R, F, C, U, H;
1010
+ return [
1011
+ t("div", To, [
1012
+ t("div", ko, O(e(u)("inventory.transfer.template.details.templateSummary")), 1),
1013
+ t("div", wo, O(e(u)(
1014
+ `inventory.transfer.receiveRequest.details.type.${k.value.toLocaleLowerCase("en-US")}`
1015
+ )), 1)
1016
+ ]),
1017
+ c(w),
1018
+ t("div", Co, [
1019
+ t("div", So, [
1020
+ t("div", Mo, [
1021
+ t("div", $o, O(e(u)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1022
+ ]),
1023
+ t("div", Io, O(e(Pt)(((i = g.template) == null ? void 0 : i._id) ?? "")), 1)
1024
+ ]),
1025
+ (R = ($ = o.value) == null ? void 0 : $.supplier) != null && R.name ? (D(), Q("div", Oo, [
1026
+ t("div", Vo, O(e(u)("inventory.transfer.receiveRequest.details.from")), 1),
1027
+ t("div", Ao, O((C = (F = o.value) == null ? void 0 : F.supplier) == null ? void 0 : C.name), 1)
1028
+ ])) : Y("", !0),
1029
+ (U = o.value) != null && U.ref ? (D(), Q("div", Do, [
1030
+ t("div", Ro, O(e(u)("inventory.transfer.receiveRequest.details.reference")), 1),
1031
+ t("div", Po, O(o.value.ref), 1)
1032
+ ])) : Y("", !0),
1033
+ (H = o.value) != null && H.remark ? (D(), Q("div", Lo, [
1034
+ t("div", Bo, O(e(u)("inventory.transfer.receiveRequest.details.remark")), 1),
1035
+ t("div", Uo, O(o.value.remark), 1)
1036
+ ])) : Y("", !0)
1037
+ ])
1038
+ ];
1039
+ }),
1040
+ _: 1
1041
+ })
1042
+ ]),
1043
+ t("div", qo, [
1044
+ t("div", Eo, [
1045
+ t("div", No, O(e(u)("inventory.transfer.receiveRequest.details.requestedItems")), 1),
1046
+ (D(!0), Q(Ge, null, lt(((l = o.value) == null ? void 0 : l.items) ?? [], (i) => (D(), Q("div", {
1047
+ key: i.code,
1048
+ class: "flex flex-col"
1049
+ }, [
1050
+ t("div", zo, [
1051
+ t("div", jo, O(i.name), 1),
1052
+ f[3] || (f[3] = t("div", { class: "flex-1 min-w-32" }, null, -1)),
1053
+ t("div", Ho, O(e(ct)(i.quantity, i.sku.unit, i.measurement)), 1)
1054
+ ]),
1055
+ t("div", Qo, [
1056
+ t("div", Go, O(i.code), 1),
1057
+ i.totalCost && e(d).enableTotalCost ? (D(), Q("div", Ko, " (" + O(e(St)(i.totalCost)) + ") ", 1)) : Y("", !0)
1058
+ ]),
1059
+ e(pt)(i) ? (D(), Q("div", Wo, [
1060
+ c(N, {
1061
+ name: "error",
1062
+ color: "system-error-300",
1063
+ size: "sm"
1064
+ }),
1065
+ f[4] || (f[4] = t("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))
1066
+ ])) : Y("", !0)
1067
+ ]))), 128))
1068
+ ])
1069
+ ]),
1070
+ f[6] || (f[6] = t("div", null, null, -1)),
1071
+ f[7] || (f[7] = t("div", null, null, -1)),
1072
+ t("div", Zo, [
1073
+ f[5] || (f[5] = t("div", { class: "flex flex-col" }, [
1074
+ t("div", { class: "fm-typo-en-body-lg-600" }, "Enabled locations"),
1075
+ t("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " This template is only usable for the following locations. ")
1076
+ ], -1)),
1077
+ t("div", Jo, [
1078
+ c(v, {
1079
+ modelValue: x.value,
1080
+ "onUpdate:modelValue": f[0] || (f[0] = (i) => x.value = i),
1081
+ placeholder: "Filter locations",
1082
+ "prepend-icon": "search"
1083
+ }, null, 8, ["modelValue"]),
1084
+ c(a, {
1085
+ "hide-footer": "",
1086
+ style: { height: "500px" },
1087
+ "column-defs": m,
1088
+ "search-value": x.value,
1089
+ "row-data": ((n = p.template) == null ? void 0 : n.locations) ?? [{ name: "All locations" }]
1090
+ }, null, 8, ["search-value", "row-data"])
1091
+ ])
1092
+ ])
1093
+ ])
1094
+ ];
1095
+ }),
1096
+ "side-sheet-footer": E(() => [
1097
+ t("div", Xo, [
1098
+ c(h, {
1099
+ label: e(u)("common.edit"),
1100
+ onClick: f[1] || (f[1] = (l) => s("action:edit")),
1101
+ variant: "tertiary"
1102
+ }, null, 8, ["label"])
1103
+ ])
1104
+ ]),
1105
+ _: 1
1106
+ }, 8, ["header", "modelValue", "dismiss-away"]);
1107
+ };
1108
+ }
1109
+ }), el = { class: "flex-1 flex flex-col gap-8" }, tl = { class: "flex flex-col" }, ol = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ll = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, sl = { class: "fm-typo-en-body-lg-400" }, nl = { class: "fm-typo-en-body-lg-400 line-clamp-1" }, al = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Fl = /* @__PURE__ */ J({
1110
+ __name: "TransferTemplateView",
1111
+ setup(b) {
1112
+ const { t: _ } = X(), { createTemplate: p, viewTemplate: s, importTemplates: d, exportTemplates: u } = qe(), { templateDialogProps: o, templateDetailsProps: m } = je(qe()), x = ft(), { loading: k, templates: S } = je(x), V = L(!1), g = it(), f = Ze(), { breakpoints: w } = It();
1113
+ pe(x.fetchTemplates);
1114
+ const B = A(
1115
+ () => V.value || k.value || !f._currentLocation
1116
+ ), N = A(() => S.value), v = L(""), a = A(() => w.value.xs || w.value.sm), h = A(() => a.value ? 10 : 20);
1117
+ function r(F) {
1118
+ switch (F) {
1119
+ case Ee.Add:
1120
+ return p();
1121
+ case "import":
1122
+ return d();
1123
+ case "export":
1124
+ return u();
1125
+ }
1126
+ }
1127
+ function y(F) {
1128
+ return F;
1129
+ }
1130
+ const l = A(() => {
1131
+ const F = [
1132
+ {
1133
+ label: _("inventory.closing.template.create.title"),
1134
+ value: Ee.Add,
1135
+ isPrimary: !0,
1136
+ prependIcon: "add"
1137
+ }
1138
+ ];
1139
+ return a.value ? F : [
1140
+ ...F,
1141
+ {
1142
+ label: "Import",
1143
+ value: "import",
1144
+ isPrimary: !1
1145
+ }
1146
+ ];
1147
+ }), n = A(() => {
1148
+ const F = [
1149
+ {
1150
+ icon: "refresh",
1151
+ onClick: x.fetchTemplates
1152
+ }
1153
+ ];
1154
+ return a.value ? [...F, { icon: "more_vert", onClick: () => i.value = !0 }] : [
1155
+ ...F,
1156
+ {
1157
+ icon: "upload_file",
1158
+ onClick: d
1159
+ },
1160
+ {
1161
+ icon: "ios_share",
1162
+ onClick: u
1163
+ }
1164
+ ];
1165
+ }), i = L(!1), $ = [
1166
+ {
1167
+ value: "import",
1168
+ label: _("common.import")
1169
+ },
1170
+ {
1171
+ value: "export",
1172
+ label: _("common.export")
1173
+ }
1174
+ ];
1175
+ function R(F) {
1176
+ switch (i.value = !1, F) {
1177
+ case "import":
1178
+ return d();
1179
+ case "export":
1180
+ return u();
1181
+ }
1182
+ }
1183
+ return (F, C) => {
1184
+ const U = M("FmTable"), H = M("FmCollapsibleTabs"), K = M("FmBottomSheet");
1185
+ return D(), Q(Ge, null, [
1186
+ c(ut, {
1187
+ title: e(_)("inventory.transfer.template.title2"),
1188
+ actions: l.value,
1189
+ "onClick:action": r
1190
+ }, {
1191
+ default: E(() => {
1192
+ var T;
1193
+ return [
1194
+ t("div", {
1195
+ class: ue([
1196
+ "flex flex-col gap-8 max-h-full",
1197
+ {
1198
+ "p-0": a.value,
1199
+ "px-24 ": !a.value
1200
+ }
1201
+ ])
1202
+ }, [
1203
+ c(mt, {
1204
+ searchable: "",
1205
+ search: v.value,
1206
+ "onUpdate:search": C[0] || (C[0] = (I) => v.value = I),
1207
+ actions: n.value
1208
+ }, null, 8, ["search", "actions"]),
1209
+ (D(), W(U, {
1210
+ style: st(e(g).tableHeight),
1211
+ "column-defs": e(x).columnDefs,
1212
+ "row-data": N.value,
1213
+ "search-value": v.value,
1214
+ loading: B.value,
1215
+ key: (T = e(f)._currentLocation) == null ? void 0 : T.dbName,
1216
+ onRowClick: C[1] || (C[1] = (I) => e(s)(I.original)),
1217
+ "page-size": h.value
1218
+ }, {
1219
+ "list-row": E((I) => [
1220
+ c(Ye, {
1221
+ row: I,
1222
+ onRowClick: (q) => e(s)(q)
1223
+ }, {
1224
+ default: E((q) => {
1225
+ var ye, ve, be, te, _e, xe, he, ge, oe, Fe, Te, ke, we, le, Ce, Se, Me, $e, Ie, Oe, se, Ve, Ae, De, Re, ne, Pe;
1226
+ return [
1227
+ t("div", el, [
1228
+ t("div", tl, [
1229
+ t("div", ol, [
1230
+ c(e(j), {
1231
+ render: (be = (ve = (ye = q._id) == null ? void 0 : ye.column) == null ? void 0 : ve.columnDef) == null ? void 0 : be.cell,
1232
+ props: (_e = (te = q._id) == null ? void 0 : te.getContext) == null ? void 0 : _e.call(te)
1233
+ }, null, 8, ["render", "props"])
1234
+ ]),
1235
+ t("div", ll, [
1236
+ c(e(j), {
1237
+ render: (ge = (he = (xe = q.name) == null ? void 0 : xe.column) == null ? void 0 : he.columnDef) == null ? void 0 : ge.cell,
1238
+ props: (Fe = (oe = q.name) == null ? void 0 : oe.getContext) == null ? void 0 : Fe.call(oe)
1239
+ }, null, 8, ["render", "props"])
1240
+ ]),
1241
+ t("div", sl, [
1242
+ c(e(j), {
1243
+ render: (we = (ke = (Te = q.supplier) == null ? void 0 : Te.column) == null ? void 0 : ke.columnDef) == null ? void 0 : we.cell,
1244
+ props: (Ce = (le = q.supplier) == null ? void 0 : le.getContext) == null ? void 0 : Ce.call(le)
1245
+ }, null, 8, ["render", "props"])
1246
+ ]),
1247
+ t("div", null, O((Se = I.original.locations) != null && Se.length ? `Enabled for ${(Me = I.original.locations) == null ? void 0 : Me.length} outlets` : "Enabled for all outlets"), 1),
1248
+ t("div", nl, O(I.original.purchaseOrder.items.length ? I.original.purchaseOrder.items.map((et) => et.name).join(", ") : "No items"), 1),
1249
+ t("div", al, [
1250
+ c(e(j), {
1251
+ render: (Oe = (Ie = ($e = q.ref) == null ? void 0 : $e.column) == null ? void 0 : Ie.columnDef) == null ? void 0 : Oe.cell,
1252
+ props: (Ve = (se = q.ref) == null ? void 0 : se.getContext) == null ? void 0 : Ve.call(se)
1253
+ }, null, 8, ["render", "props"])
1254
+ ])
1255
+ ]),
1256
+ t("div", null, [
1257
+ c(e(j), {
1258
+ render: (Re = (De = (Ae = q.type) == null ? void 0 : Ae.column) == null ? void 0 : De.columnDef) == null ? void 0 : Re.cell,
1259
+ props: (Pe = (ne = q.type) == null ? void 0 : ne.getContext) == null ? void 0 : Pe.call(ne)
1260
+ }, null, 8, ["render", "props"])
1261
+ ])
1262
+ ])
1263
+ ];
1264
+ }),
1265
+ _: 2
1266
+ }, 1032, ["row", "onRowClick"])
1267
+ ]),
1268
+ _: 1
1269
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1270
+ ], 2)
1271
+ ];
1272
+ }),
1273
+ _: 1
1274
+ }, 8, ["title", "actions"]),
1275
+ (D(), W(nt, { to: "body" }, [
1276
+ c(Yo, at(rt(e(m))), null, 16),
1277
+ c(go, He(e(o), {
1278
+ onSubmitted: C[2] || (C[2] = (T) => e(x).fetchTemplates())
1279
+ }), null, 16),
1280
+ c(K, {
1281
+ "dismiss-away": "",
1282
+ "no-header": "",
1283
+ modelValue: i.value,
1284
+ "onUpdate:modelValue": C[4] || (C[4] = (T) => i.value = T)
1285
+ }, {
1286
+ default: E(() => [
1287
+ c(H, {
1288
+ class: "pb-8",
1289
+ items: $,
1290
+ "onUpdate:modelValue": C[3] || (C[3] = (T) => R(T))
1291
+ })
1292
+ ]),
1293
+ _: 1
1294
+ }, 8, ["modelValue"])
1295
+ ]))
1296
+ ], 64);
1297
+ };
1298
+ }
1299
+ });
1300
+ export {
1301
+ Fl as default
1302
+ };