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

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 (48) hide show
  1. package/dist/{ApprovalView-CKBg-CUO.js → ApprovalView-av_qng0N.js} +9 -10
  2. package/dist/{BindingsDialog-BHQkDST3.js → BindingsDialog-VZ6YelwP.js} +1 -1
  3. package/dist/{BindingsPicker-DtGzKn9l.js → BindingsPicker-BFYv2ftI.js} +1 -1
  4. package/dist/{BindingsTable-CSKzOCxK.js → BindingsTable-DFowW8vT.js} +1 -1
  5. package/dist/{ClosingTemplateView-CcO_vSoD.js → ClosingTemplateView-DNcgyBVw.js} +5 -5
  6. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CAZ4P0Ax.js +266 -0
  7. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CC55eT4X.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DqOb7e4M.js} +1 -1
  8. package/dist/{IngredientsView-DKf2RyTT.js → IngredientsView-afICUj_U.js} +3 -3
  9. package/dist/{IntegrationView-IT9fT1o3.js → IntegrationView-DT5F9V0h.js} +120 -120
  10. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BfQYvMQo.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CXw4tAI_.js} +1 -1
  11. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-C6a6F_jD.js +116 -0
  12. package/dist/{PurchaseOrderPrintPreview-CmUwBVJj.js → PurchaseOrderPrintPreview-BMCy5C1z.js} +1 -1
  13. package/dist/ReceiveRequestView-DBU59iYm.js +4050 -0
  14. package/dist/{RecipeView-DoVjHcdn.js → RecipeView-Brnk8Ar7.js} +3 -3
  15. package/dist/{StockView-0e2NTA6y.js → StockView-BtTZNhlp.js} +14 -15
  16. package/dist/{SupplierView-Kp_qdI0x.js → SupplierView-C0GT_JzY.js} +3 -3
  17. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BzJ8TnL_.js +1139 -0
  18. package/dist/TransferTemplateView-SrBMTzU-.js +1237 -0
  19. package/dist/{UnitView-Bn4Di9oJ.js → UnitView-Dw2xLWy4.js} +4 -4
  20. package/dist/{WarehouseView-D_UpeFJI.js → WarehouseView-Cgf1mP8s.js} +2 -2
  21. package/dist/{app-Cp8AtZVK.js → app-Iz-opVBA.js} +270 -261
  22. package/dist/app.js +1 -1
  23. package/dist/{decimal-BdGSddMR.js → decimal-ffsKJesh.js} +1 -1
  24. package/dist/{defineDeepModel-BmWycBqN.js → defineDeepModel-CDrYKSnU.js} +3 -3
  25. package/dist/format-time-from-id-e9QU46u4.js +15 -0
  26. package/dist/purchase-order-transaction-type-DN3Czz6K.js +338 -0
  27. package/dist/stores/netsuite.d.ts +1 -0
  28. package/dist/{supplier-nSbJROl8.js → supplier-DdJIh1nj.js} +1 -1
  29. package/dist/tsconfig.app.tsbuildinfo +1 -1
  30. package/dist/{use-template-enabled-locations-2-DHQhRyhX.js → use-template-enabled-locations-2-BSLLHtkm.js} +1 -1
  31. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +44 -0
  32. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +42 -34
  33. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +75 -51
  34. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +75 -51
  35. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetails.vue.d.ts +0 -2
  36. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetailsProps.d.ts +0 -1
  37. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +5 -8
  38. package/dist/{xlsx-CyyozDQ4.js → xlsx-C8qXPxB4.js} +1 -1
  39. package/dist/{xlsx.util-io3Y9wY0.js → xlsx.util-DGLr1W_5.js} +2 -2
  40. package/package.json +3 -3
  41. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-B1Hplfop.js +0 -88
  42. package/dist/ReceiveRequestView-CowLFbXJ.js +0 -215
  43. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-pOCLtZSW.js +0 -858
  44. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-YgNt1e4d.js +0 -1678
  45. package/dist/TransferTemplateView-DnZqm1NS.js +0 -1244
  46. package/dist/format-time-from-id-bNKNgPR2.js +0 -15
  47. package/dist/id-to-date-uL3PyIfz.js +0 -30
  48. package/dist/purchase-order-transaction-type-DQvXZvHo.js +0 -685
@@ -0,0 +1,1237 @@
1
+ import { defineComponent as Z, onMounted as me, computed as R, ref as U, watch as ce, inject as Ne, resolveComponent as C, openBlock as D, createElementBlock as Q, createElementVNode as n, createVNode as f, withCtx as E, renderSlot as ke, withDirectives as Me, normalizeClass as re, vModelText as $e, reactive as ze, h as W, toDisplayString as $, unref as e, createBlock as K, mergeProps as Ve, isRef as De, createCommentVNode as Y, Fragment as Re, renderList as He, normalizeStyle as je, Teleport as Qe, normalizeProps as Ge, guardReactiveProps as Ke } from "vue";
2
+ import { u as We, _ as Ze, a as Je } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DqOb7e4M.js";
3
+ import { useI18n as J } from "@feedmepos/mf-common";
4
+ import { P as N, a as Xe, f as Ye, t as et, b as Ce, u as tt } from "./purchase-order-transaction-type-DN3Czz6K.js";
5
+ import { F as ee, R as Se } from "./row-action.enum-PMKMRrZR.js";
6
+ import { ad as ie, t as Oe, I as ot, ae as nt, af as st, a as G, ag as lt, E as Ie, R as ue, u as Ae, $ as at, a2 as rt, a0 as it, s as ae, a1 as ut, m as dt, A as de, M as mt, b as Pe, j as Le, z as ct, l as pt, ah as se, H as ft } from "./app-Iz-opVBA.js";
7
+ import { components as le, useDialog as yt, useSnackbar as vt, useProxiedModel as Be, useBreakpoints as bt } from "@feedmepos/ui-library";
8
+ import { storeToRefs as _t } from "pinia";
9
+ import "vue-router";
10
+ import { d as Ue } from "./defineDeepModel-CDrYKSnU.js";
11
+ import { c as xt, u as ht, _ as gt } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CAZ4P0Ax.js";
12
+ import { u as Ft } from "./supplier-DdJIh1nj.js";
13
+ import { F as j, _ as Ee } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
14
+ import { u as Tt } from "./use-template-enabled-locations-2-BSLLHtkm.js";
15
+ import { f as wt } from "./format-time-from-id-e9QU46u4.js";
16
+ const kt = { class: "flex flex-col" }, Mt = { class: "flex flex-col" }, $t = { class: "flex-1" }, Ct = { class: "flex items-center" }, St = { class: "flex-1" }, Ot = { class: "flex-1" }, It = /* @__PURE__ */ Z({
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, c = Ue("modelValue"), s = ot();
55
+ me(() => {
56
+ const { min: v, max: r } = c ?? {};
57
+ if (!(!v || !r) && v.precision !== r.precision) {
58
+ const h = Math.max(v.precision, r.precision), a = ie(v, h), i = ie(r, h);
59
+ c.min = a, c.max = i;
60
+ }
61
+ });
62
+ const p = R(() => {
63
+ const { min: v, max: r } = c ?? {};
64
+ return Math.max((v == null ? void 0 : v.precision) ?? 0, (r == null ? void 0 : r.precision) ?? 0, _.precision ?? 0);
65
+ }), m = (v) => {
66
+ if (!v) return "";
67
+ const r = nt(v), h = p.value, a = ie(r, h);
68
+ return st(
69
+ +G(a),
70
+ a.precision
71
+ );
72
+ }, o = U(m(c.min)), u = U(m(c.max));
73
+ ce([o, u], ([v, r]) => {
74
+ const h = c ?? {}, a = s(v), i = s(r), t = p.value;
75
+ if (v !== "" && a === !0) {
76
+ const l = Oe(+v, t);
77
+ h.min = l;
78
+ } else
79
+ h.min = null;
80
+ if (r !== "" && i === !0) {
81
+ const l = Oe(+r, t);
82
+ h.max = l;
83
+ } else
84
+ h.max = null;
85
+ c.min = h.min, c.max = h.max;
86
+ });
87
+ const g = Symbol.for("fm:form-state"), F = Ne(g, null), w = R(() => _.disabled ?? (F == null ? void 0 : F.getDisabled()) ?? !1), O = U(), x = U(), y = U(!1), T = U(!1), L = R(() => y.value || T.value), z = R(() => [...[
88
+ function() {
89
+ return typeof s(o.value) == "string" || typeof s(u.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, r) => {
96
+ const h = C("FmLabel"), a = C("FmField"), i = C("FmFormGroup");
97
+ return D(), Q("div", kt, [
98
+ n("div", Mt, [
99
+ n("div", $t, [
100
+ f(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
+ f(a, { focused: L.value }, {
108
+ default: E(() => [
109
+ n("div", Ct, [
110
+ ke(v.$slots, "prepend"),
111
+ r[6] || (r[6] = n("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Min.", -1)),
112
+ n("div", St, [
113
+ Me(n("input", {
114
+ type: "text",
115
+ ref_key: "minInputRef",
116
+ ref: O,
117
+ onFocus: r[0] || (r[0] = () => y.value = !0),
118
+ onBlur: r[1] || (r[1] = () => y.value = !1),
119
+ "onUpdate:modelValue": r[2] || (r[2] = (t) => o.value = t),
120
+ class: re({
121
+ "fm-text-field--input fm-typo-en-body-lg-400": !0,
122
+ "text-fm-color-typo-primary": !w.value,
123
+ "text-fm-color-typo-disabled": w.value
124
+ })
125
+ }, null, 34), [
126
+ [$e, o.value]
127
+ ])
128
+ ]),
129
+ r[7] || (r[7] = n("div", { class: "block h-32 mx-4 w-[1px] bg-fm-color-neutral-gray-200" }, null, -1)),
130
+ r[8] || (r[8] = n("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Max.", -1)),
131
+ n("div", Ot, [
132
+ Me(n("input", {
133
+ type: "text",
134
+ ref_key: "maxInputRef",
135
+ ref: x,
136
+ onFocus: r[3] || (r[3] = () => T.value = !0),
137
+ onBlur: r[4] || (r[4] = () => T.value = !1),
138
+ "onUpdate:modelValue": r[5] || (r[5] = (t) => u.value = t),
139
+ class: re({
140
+ "fm-text-field--input fm-typo-en-body-lg-400": !0,
141
+ "text-fm-color-typo-primary": !w.value,
142
+ "text-fm-color-typo-disabled": w.value
143
+ })
144
+ }, null, 34), [
145
+ [$e, u.value]
146
+ ])
147
+ ]),
148
+ ke(v.$slots, "append")
149
+ ])
150
+ ]),
151
+ _: 3
152
+ }, 8, ["focused"])
153
+ ]),
154
+ f(i, {
155
+ class: "flex-1",
156
+ "model-value": v.modelValue,
157
+ info: v.labelInfo,
158
+ rules: z.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 Vt() {
167
+ return function(_) {
168
+ return !_ || !_.min || !_.max ? "Required" : !0;
169
+ };
170
+ }
171
+ function Dt(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 Rt(b) {
177
+ const _ = lt(b), c = G(b);
178
+ return function(p) {
179
+ if (!(p != null && p.min) || !(p != null && p.max)) return !0;
180
+ const m = _(p.min) === !0, o = _(p.max) === !0;
181
+ return !m && !o ? `Min & max must be a multiple of ${c}` : m ? o ? !0 : `Max must be a multiple of ${c}` : `Min must be a multiple of ${c}`;
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 At(b) {
186
+ const { t: _ } = J(), c = ze({});
187
+ me(() => {
188
+ for (const m of b.items) {
189
+ if (!m.totalCost)
190
+ continue;
191
+ const o = xt(m.sku, m.quantity, m.measurement, {
192
+ supplier: b.supplier
193
+ }), u = m.totalCost ?? Ie.reset();
194
+ o ? c[m.sku._id] = o.amount !== u.amount || o.precision !== u.precision : c[m.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(m) {
204
+ const o = m.row.original;
205
+ return W(le.FmTextField, {
206
+ modelValue: o.code,
207
+ "onUpdate:modelValue": (u) => {
208
+ b.updateItem({
209
+ ...o,
210
+ code: u
211
+ });
212
+ },
213
+ key: o.sku._id,
214
+ rules: [ue()],
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(m) {
225
+ const o = m.row.original;
226
+ return W(le.FmTextField, {
227
+ modelValue: o.name,
228
+ "onUpdate:modelValue": (u) => {
229
+ b.updateItem({
230
+ ...o,
231
+ name: u
232
+ });
233
+ },
234
+ key: o.sku._id,
235
+ rules: [ue()],
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(m) {
246
+ var x;
247
+ const o = m.row.original, u = Ae(), g = u.skuById[o.sku._id], F = u.unitById[(x = g.unit) == null ? void 0 : x._id], w = F.measurements.find((y) => {
248
+ var T;
249
+ return ((T = o.measurement) == null ? void 0 : T.id) === y.id;
250
+ }), O = o.sku.unit._id !== g.unit._id || !F || o.measurement && !w;
251
+ return W(at, {
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 !== g.unit._id ? { ...o.sku.unit, id: "", conversion: { amount: 1, precision: 0 } } : null)
259
+ },
260
+ disabled: b.disabled,
261
+ key: o.sku._id,
262
+ unit: F,
263
+ "onUpdate:modelValue": (y) => {
264
+ b.updateItem({
265
+ ...o,
266
+ sku: g,
267
+ quantity: y.amount,
268
+ measurement: y.measurement
269
+ });
270
+ },
271
+ rules: [
272
+ rt(o.quantityStep),
273
+ it(
274
+ +G(
275
+ o.minimumQuantity ?? {
276
+ amount: 1,
277
+ // NOTE: leave this reading from row.sku.unit and row.measurement instead,
278
+ precision: ae(o.sku.unit, o.measurement)
279
+ }
280
+ )
281
+ ),
282
+ ut(
283
+ o.maximumQuantity ? +G(o.maximumQuantity) : 1 / 0
284
+ ),
285
+ function(T) {
286
+ return O ? "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(m) {
300
+ const o = m.row.original;
301
+ return W(It, {
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": (u) => {
313
+ const g = { ...o };
314
+ u != null && u.min && (g.minimumQuantity = u.min), u != null && u.max && (g.maximumQuantity = u.max), b.updateItem(g);
315
+ },
316
+ rules: [
317
+ Vt(),
318
+ Rt(o.quantityStep),
319
+ Dt(
320
+ +G({
321
+ amount: 1,
322
+ precision: ae(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(m) {
337
+ const o = m.row.original;
338
+ return W(le.FmTextField, {
339
+ modelValue: G(o.quantityStep ?? Ie.reset(), !1),
340
+ key: o.sku._id,
341
+ "onUpdate:modelValue": (u) => {
342
+ b.updateItem({
343
+ ...o,
344
+ quantityStep: dt(+u)
345
+ });
346
+ },
347
+ rules: [
348
+ de({
349
+ amount: 1,
350
+ precision: ae(o.sku.unit, o.measurement)
351
+ }),
352
+ mt(o.sku.unit, o.measurement)
353
+ ]
354
+ });
355
+ },
356
+ enableSorting: !1
357
+ },
358
+ {
359
+ id: "Delete",
360
+ header: "",
361
+ cell(m) {
362
+ const o = m.row.original;
363
+ return W(le.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: R(() => Pe().enableTotalCost && b.transferType === N.PURCHASE ? s : s.filter((o) => o.id !== "Cost"))
386
+ };
387
+ }
388
+ const Pt = { class: "flex flex-col gap-8 py-16" }, Lt = { class: "flex items-center" }, Bt = { class: "flex-1 flex gap-1 items-center" }, Ut = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Et = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, qt = { class: "flex gap-8 w-full" }, Nt = { class: "flex-1 flex flex-col gap-4" }, zt = { class: "flex-1 flex flex-col gap-4" }, Ht = { class: "flex gap-8 w-full" }, jt = { class: "flex-1 flex flex-col gap-4" }, Qt = { class: "flex-1 flex flex-col gap-4" }, Gt = { class: "flex gap-8 w-full" }, Kt = { class: "flex-1 flex flex-col gap-4" }, Wt = /* @__PURE__ */ Z({
389
+ __name: "TransferTemplateItem",
390
+ props: {
391
+ cellByColId: {},
392
+ row: {}
393
+ },
394
+ setup(b) {
395
+ const { t: _ } = J();
396
+ return (c, s) => {
397
+ var m, o, u, g, F, w, O, x, y, T, L, z, v, r, h, a, i, t, l, d, M, S, I, V, A, H, q, k, B, X;
398
+ const p = C("FmLabel");
399
+ return D(), Q("div", Pt, [
400
+ n("div", Lt, [
401
+ n("div", Bt, [
402
+ n("span", Ut, " (" + $(c.row.original.sku.code) + ") ", 1),
403
+ n("span", Et, $(c.row.original.sku.name), 1)
404
+ ]),
405
+ n("div", null, [
406
+ f(e(j), {
407
+ render: (u = (o = (m = c.cellByColId.Delete) == null ? void 0 : m.column) == null ? void 0 : o.columnDef) == null ? void 0 : u.cell,
408
+ props: (F = (g = c.cellByColId.Delete) == null ? void 0 : g.getContext) == null ? void 0 : F.call(g)
409
+ }, null, 8, ["render", "props"])
410
+ ])
411
+ ]),
412
+ n("div", qt, [
413
+ n("div", Nt, [
414
+ f(p, {
415
+ label: e(_)(`inventory.transfer.form.items.table.${e(P).Code}`)
416
+ }, null, 8, ["label"]),
417
+ f(e(j), {
418
+ render: (x = (O = (w = c.cellByColId[e(P).Code]) == null ? void 0 : w.column) == null ? void 0 : O.columnDef) == null ? void 0 : x.cell,
419
+ props: (T = (y = c.cellByColId[e(P).Code]) == null ? void 0 : y.getContext) == null ? void 0 : T.call(y)
420
+ }, null, 8, ["render", "props"]),
421
+ s[0] || (s[0] = n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
422
+ ]),
423
+ n("div", zt, [
424
+ f(p, {
425
+ label: e(_)(`inventory.transfer.form.items.table.${e(P).Name}`)
426
+ }, null, 8, ["label"]),
427
+ f(e(j), {
428
+ render: (v = (z = (L = c.cellByColId[e(P).Name]) == null ? void 0 : L.column) == null ? void 0 : z.columnDef) == null ? void 0 : v.cell,
429
+ props: (h = (r = c.cellByColId[e(P).Name]) == null ? void 0 : r.getContext) == null ? void 0 : h.call(r)
430
+ }, null, 8, ["render", "props"]),
431
+ s[1] || (s[1] = n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
432
+ ])
433
+ ]),
434
+ n("div", Ht, [
435
+ n("div", jt, [
436
+ f(p, {
437
+ label: e(_)(`inventory.transfer.form.items.table.${e(P).DefaultAmount}`)
438
+ }, null, 8, ["label"]),
439
+ f(e(j), {
440
+ render: (t = (i = (a = c.cellByColId[e(P).DefaultAmount]) == null ? void 0 : a.column) == null ? void 0 : i.columnDef) == null ? void 0 : t.cell,
441
+ props: (d = (l = c.cellByColId[e(P).DefaultAmount]) == null ? void 0 : l.getContext) == null ? void 0 : d.call(l)
442
+ }, null, 8, ["render", "props"]),
443
+ s[2] || (s[2] = n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
444
+ ]),
445
+ n("div", Qt, [
446
+ f(p, {
447
+ label: e(_)(`inventory.transfer.form.items.table.${e(P).Step}`)
448
+ }, null, 8, ["label"]),
449
+ f(e(j), {
450
+ render: (I = (S = (M = c.cellByColId[e(P).Step]) == null ? void 0 : M.column) == null ? void 0 : S.columnDef) == null ? void 0 : I.cell,
451
+ props: (A = (V = c.cellByColId[e(P).Step]) == null ? void 0 : V.getContext) == null ? void 0 : A.call(V)
452
+ }, null, 8, ["render", "props"]),
453
+ s[3] || (s[3] = n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
454
+ ])
455
+ ]),
456
+ n("div", Gt, [
457
+ n("div", Kt, [
458
+ f(p, {
459
+ label: e(_)(`inventory.transfer.form.items.table.${e(P).Limit}`)
460
+ }, null, 8, ["label"]),
461
+ f(e(j), {
462
+ render: (k = (q = (H = c.cellByColId[e(P).Limit]) == null ? void 0 : H.column) == null ? void 0 : q.columnDef) == null ? void 0 : k.cell,
463
+ props: (X = (B = c.cellByColId[e(P).Limit]) == null ? void 0 : B.getContext) == null ? void 0 : X.call(B)
464
+ }, null, 8, ["render", "props"]),
465
+ s[4] || (s[4] = n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
466
+ ])
467
+ ])
468
+ ]);
469
+ };
470
+ }
471
+ }), Zt = { class: "flex flex-col gap-16" }, Jt = { class: "flex flex-col gap-24" }, Xt = { class: "flex flex-col gap-16" }, Yt = { class: "flex items-center" }, eo = { class: "flex flex-col" }, to = { class: "flex flex-col gap-16" }, oo = { class: "flex" }, no = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, so = /* @__PURE__ */ Z({
472
+ __name: "TransferTemplateForm",
473
+ props: {
474
+ modelValue: {},
475
+ disabled: { type: Boolean }
476
+ },
477
+ setup(b, { expose: _ }) {
478
+ const c = b, s = Ue(), { t: p } = J(), m = Le(), o = Ae(), u = Ft();
479
+ ce(
480
+ () => c.modelValue,
481
+ (t) => {
482
+ console.log("TransferTemplateForm.model", t);
483
+ }
484
+ ), m.watchLocation(async () => {
485
+ location && (s.purchaseOrder.supplier || (s.purchaseOrder.supplier = u.suppliers.find((t) => t) ?? s.purchaseOrder.supplier));
486
+ });
487
+ const g = yt(), F = ht(
488
+ () => s.purchaseOrder,
489
+ (t) => {
490
+ s.purchaseOrder = {
491
+ ...s.purchaseOrder,
492
+ supplier: t.supplier ?? (s == null ? void 0 : s.purchaseOrder.supplier)
493
+ };
494
+ }
495
+ ), w = R({
496
+ get() {
497
+ var t, l;
498
+ return typeof ((l = (t = s.purchaseOrder) == null ? void 0 : t.supplier) == null ? void 0 : l.internal) == "string" ? N.TRANSFER : N.PURCHASE;
499
+ },
500
+ set(t) {
501
+ var d, M;
502
+ const l = typeof ((M = (d = s.purchaseOrder) == null ? void 0 : d.supplier) == null ? void 0 : M.internal) == "string" ? N.TRANSFER : N.PURCHASE;
503
+ t !== l && (s.purchaseOrder.supplier = t === N.PURCHASE ? F.locationOptionsTypePurchase.value[0] : F.locationOptionsTypeTransfer.value[0]);
504
+ }
505
+ }), O = R(() => F.transferLocationOptions.value), x = R({
506
+ get() {
507
+ var t;
508
+ return (t = s.purchaseOrder.supplier) == null ? void 0 : t._id;
509
+ },
510
+ set(t) {
511
+ F.transferLocationModel.value = t;
512
+ }
513
+ }), {
514
+ promptSelectLocations: y,
515
+ columnDefs: T,
516
+ rowData: L
517
+ } = Tt({
518
+ getLocations() {
519
+ return s.locations;
520
+ },
521
+ setLocations(t) {
522
+ s.locations = t;
523
+ }
524
+ });
525
+ function z() {
526
+ var t, l;
527
+ return (t = s.locations) != null && t.find((d) => {
528
+ var M, S;
529
+ return ((M = d.doc) == null ? void 0 : M._id) === ((S = s.purchaseOrder.supplier) == null ? void 0 : S._id);
530
+ }) ? `Location ${(l = s.purchaseOrder.supplier) == null ? void 0 : l.name} must be removed because template cannot be used to transfer to itself.` : !0;
531
+ }
532
+ const v = R({
533
+ get() {
534
+ return s.purchaseOrder.remark ?? void 0;
535
+ },
536
+ set(t) {
537
+ s.purchaseOrder.remark = t;
538
+ }
539
+ }), r = U();
540
+ _({
541
+ validateInputs: () => {
542
+ var t, l;
543
+ (l = (t = r.value) == null ? void 0 : t.validateInputs) == null || l.call(t);
544
+ },
545
+ resetInputsValidation: () => {
546
+ var t, l;
547
+ (l = (t = r.value) == null ? void 0 : t.resetInputsValidation) == null || l.call(t);
548
+ },
549
+ resetInputs: () => {
550
+ var t, l;
551
+ (l = (t = r.value) == null ? void 0 : t.resetInputs) == null || l.call(t);
552
+ }
553
+ });
554
+ const h = At({
555
+ updateItem: (t) => {
556
+ s.purchaseOrder.items = s.purchaseOrder.items.map((l) => l.sku._id !== t.sku._id ? l : t);
557
+ },
558
+ deleteItem: (t) => {
559
+ s.purchaseOrder.items = s.purchaseOrder.items.filter(
560
+ (l) => l.sku._id !== t.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 N.PURCHASE;
571
+ },
572
+ get disabled() {
573
+ return c.disabled;
574
+ }
575
+ }), a = R(() => h.columnDefs.value);
576
+ function i() {
577
+ const t = o.skus.map((d) => ({
578
+ label: d.name,
579
+ sublabel: d.code,
580
+ value: d
581
+ })), l = t.filter((d) => {
582
+ var M;
583
+ return (M = s.purchaseOrder.items) == null ? void 0 : M.find((S) => S.sku._id === d.value._id);
584
+ }).map((d) => d.value);
585
+ g.open({
586
+ title: p("inventory.transfer.form.items.selectItem"),
587
+ closeButton: !0,
588
+ contentComponent: ct,
589
+ contentComponentProps: {
590
+ modelValue: l,
591
+ items: t,
592
+ virtualScroll: !0
593
+ },
594
+ primaryActions: {
595
+ text: p("common.confirm"),
596
+ close: !0
597
+ },
598
+ secondaryActions: {
599
+ text: p("common.close"),
600
+ close: !0,
601
+ variant: "tertiary"
602
+ }
603
+ }).onPrimary((d) => {
604
+ const M = s.purchaseOrder.items ?? [], S = d.map((I) => {
605
+ const V = M.find((q) => q.sku._id === I._id);
606
+ if (V)
607
+ return V;
608
+ const A = { amount: 1, precision: ae(I.unit) };
609
+ return {
610
+ sku: I,
611
+ code: I.code,
612
+ name: I.name,
613
+ quantity: A,
614
+ minimumQuantity: A,
615
+ maximumQuantity: pt(A, {
616
+ amount: 100,
617
+ precision: 0
618
+ }),
619
+ quantityStep: A
620
+ };
621
+ });
622
+ S.sort((I, V) => I.sku.code.localeCompare(V.sku.code)), s.purchaseOrder.items = S;
623
+ });
624
+ }
625
+ return (t, l) => {
626
+ const d = C("FmTextField"), M = C("FmSelect"), S = C("FmTextarea"), I = C("FmButton"), V = C("FmTable"), A = C("FmFormGroup"), H = C("FmForm");
627
+ return D(), K(H, {
628
+ ref_key: "formRef",
629
+ ref: r,
630
+ class: "flex flex-col gap-32",
631
+ disabled: t.disabled
632
+ }, {
633
+ default: E(() => {
634
+ var q;
635
+ return [
636
+ n("div", Zt, [
637
+ n("div", Jt, [
638
+ f(d, {
639
+ label: e(p)("inventory.transfer.form.name"),
640
+ "label-mark": "required",
641
+ modelValue: e(s).name,
642
+ "onUpdate:modelValue": l[0] || (l[0] = (k) => e(s).name = k),
643
+ rules: [e(ue)()]
644
+ }, null, 8, ["label", "modelValue", "rules"]),
645
+ f(M, {
646
+ label: e(p)("inventory.transfer.form.type.title"),
647
+ "model-value": w.value,
648
+ "onUpdate:modelValue": l[1] || (l[1] = (k) => w.value = k),
649
+ items: [
650
+ {
651
+ label: e(p)("inventory.transfer.form.type.purchase"),
652
+ value: e(N).PURCHASE,
653
+ disabled: !e(F).locationOptionsTypePurchase.value.length,
654
+ sublabel: e(F).locationOptionsTypePurchase.value.length ? void 0 : e(p)("inventory.transfer.form.noSupplierAvailable")
655
+ },
656
+ {
657
+ label: e(p)("inventory.transfer.form.type.transfer"),
658
+ value: e(N).TRANSFER,
659
+ disabled: !e(F).locationOptionsTypeTransfer.value.length,
660
+ sublabel: e(F).locationOptionsTypeTransfer.value.length ? void 0 : e(p)("inventory.transfer.form.noLocationAvailable")
661
+ }
662
+ ],
663
+ rules: [e(de)(1)(O.value)]
664
+ }, null, 8, ["label", "model-value", "items", "rules"]),
665
+ f(M, {
666
+ label: w.value === e(N).PURCHASE ? e(p)("inventory.transfer.form.purchaseFrom") : e(p)("inventory.transfer.form.transferFrom"),
667
+ modelValue: x.value,
668
+ "onUpdate:modelValue": l[2] || (l[2] = (k) => x.value = k),
669
+ items: O.value
670
+ }, {
671
+ "menu-wrapper": E((k) => {
672
+ var B;
673
+ return [
674
+ f(gt, Ve(k, {
675
+ items: O.value,
676
+ "model-value": (B = t.modelValue.purchaseOrder.supplier) == null ? void 0 : B._id
677
+ }), null, 16, ["items", "model-value"])
678
+ ];
679
+ }),
680
+ _: 1
681
+ }, 8, ["label", "modelValue", "items"]),
682
+ f(d, {
683
+ label: e(p)("inventory.transfer.form.reference"),
684
+ "label-mark": "optional",
685
+ modelValue: e(s).purchaseOrder.ref,
686
+ "onUpdate:modelValue": l[3] || (l[3] = (k) => e(s).purchaseOrder.ref = k)
687
+ }, null, 8, ["label", "modelValue"]),
688
+ f(S, {
689
+ label: e(p)("inventory.transfer.form.remark"),
690
+ "label-mark": "optional",
691
+ "max-length": 240,
692
+ modelValue: v.value,
693
+ "onUpdate:modelValue": l[4] || (l[4] = (k) => v.value = k),
694
+ class: re({ "text-fm-color-typo-disabled": t.disabled })
695
+ }, null, 8, ["label", "modelValue", "class"])
696
+ ])
697
+ ]),
698
+ n("div", Xt, [
699
+ n("div", Yt, [
700
+ l[6] || (l[6] = n("div", { class: "flex-1 fm-typo-en-title-sm-600" }, "Locations", -1)),
701
+ f(I, {
702
+ disabled: t.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(y)
708
+ }, null, 8, ["disabled", "onClick"])
709
+ ]),
710
+ f(V, {
711
+ "column-defs": e(T),
712
+ "row-data": e(L),
713
+ "shrink-at": 9999,
714
+ onRowClick: e(y),
715
+ "hide-footer": ""
716
+ }, null, 8, ["column-defs", "row-data", "onRowClick"]),
717
+ n("div", eo, [
718
+ f(A, {
719
+ "model-value": [
720
+ (q = c.modelValue.purchaseOrder.supplier) == null ? void 0 : q._id,
721
+ ...c.modelValue.locations ?? []
722
+ ].join(","),
723
+ rules: [z]
724
+ }, null, 8, ["model-value", "rules"])
725
+ ])
726
+ ]),
727
+ n("div", to, [
728
+ n("div", oo, [
729
+ n("div", no, $(e(p)("inventory.transfer.form.items.title")), 1),
730
+ f(I, {
731
+ disabled: t.disabled,
732
+ label: e(p)("inventory.transfer.form.items.addItem"),
733
+ "prepend-icon": "add",
734
+ variant: "plain",
735
+ class: "border-2 rounded-lg border-fm-color-primary",
736
+ onClick: l[5] || (l[5] = (k) => i()),
737
+ size: "md"
738
+ }, null, 8, ["disabled", "label"])
739
+ ]),
740
+ (D(), K(V, {
741
+ "column-defs": a.value,
742
+ "row-data": e(s).purchaseOrder.items,
743
+ key: e(s).purchaseOrder.items.map((k) => k.sku._id).join("."),
744
+ "hide-footer": "",
745
+ "page-size": e(s).purchaseOrder.items.length
746
+ }, {
747
+ "list-row": E((k) => [
748
+ (D(), K(Ee, {
749
+ row: k,
750
+ key: e(s).purchaseOrder.items.map((B) => B.sku._id).join(".")
751
+ }, {
752
+ default: E((B) => [
753
+ f(Wt, {
754
+ row: k,
755
+ "cell-by-col-id": B
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
+ f(A, {
764
+ "model-value": e(s).purchaseOrder.items.length,
765
+ rules: [e(de)(1)]
766
+ }, null, 8, ["model-value", "rules"])
767
+ ])
768
+ ];
769
+ }),
770
+ _: 1
771
+ }, 8, ["disabled"]);
772
+ };
773
+ }
774
+ }), lo = { class: "flex items-center" }, ao = { class: "fm-typo-en-title-md-800" }, ro = { class: "flex gap-4" }, io = /* @__PURE__ */ Z({
775
+ __name: "TransferTemplateDialog",
776
+ props: {
777
+ mode: {},
778
+ modelValue: {},
779
+ show: { type: Boolean }
780
+ },
781
+ emits: ["update:show", "submitted"],
782
+ setup(b, { expose: _, emit: c }) {
783
+ var h;
784
+ const s = b, p = c, m = Xe(), o = vt(), { t: u } = J(), g = Be(s, "show");
785
+ function F() {
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 w = U(s.modelValue ?? F()), O = U(((h = s.modelValue) == null ? void 0 : h._id) ?? `${Math.random()}`);
816
+ ce(
817
+ () => s.show,
818
+ (a) => {
819
+ var i;
820
+ a && (w.value = s.modelValue ?? F(), O.value = ((i = s.modelValue) == null ? void 0 : i._id) ?? `${Math.random()}`);
821
+ }
822
+ );
823
+ const x = U(!1), y = R(() => {
824
+ switch (s.mode) {
825
+ case ee.READ:
826
+ return "";
827
+ case ee.CREATE:
828
+ return u("inventory.transfer.template.create.title");
829
+ case ee.UPDATE:
830
+ return u("inventory.transfer.template.update.title");
831
+ }
832
+ return "";
833
+ }), T = U();
834
+ _({
835
+ validateInputs: () => {
836
+ var a, i;
837
+ (i = (a = T.value) == null ? void 0 : a.validateInputs) == null || i.call(a);
838
+ },
839
+ resetInputsValidation: () => {
840
+ var a, i;
841
+ (i = (a = T.value) == null ? void 0 : a.resetInputsValidation) == null || i.call(a);
842
+ },
843
+ resetInputs: () => {
844
+ var a, i;
845
+ (i = (a = T.value) == null ? void 0 : a.resetInputs) == null || i.call(a);
846
+ }
847
+ });
848
+ async function L() {
849
+ var i, t;
850
+ const a = w.value;
851
+ if (a) {
852
+ x.value = !0, (((i = a.purchaseOrder.supplier) == null ? void 0 : i.internal) === se.enum.warehouse || ((t = a.purchaseOrder.supplier) == null ? void 0 : t.internal) === se.enum.restaurant) && (a.purchaseOrder.items = a.purchaseOrder.items.map(
853
+ ({ totalCost: l, ...d }) => d
854
+ ));
855
+ try {
856
+ await m.createTemplate(a), await new Promise((l) => setTimeout(l, 1e3)), o.open({
857
+ title: u("inventory.transfer.template.create.success"),
858
+ message: u("inventory.transfer.template.create.successMessage"),
859
+ type: "success"
860
+ }), p("update:show", !1), p("submitted");
861
+ } catch (l) {
862
+ o.open({
863
+ title: u("inventory.transfer.template.create.error"),
864
+ message: u("inventory.transfer.template.create.errorMessage"),
865
+ type: "error"
866
+ }), console.error("Error in creating transfer template", l);
867
+ } finally {
868
+ x.value = !1;
869
+ }
870
+ }
871
+ }
872
+ async function z() {
873
+ var i, t;
874
+ const a = w.value;
875
+ if (a) {
876
+ x.value = !0, (((i = a.purchaseOrder.supplier) == null ? void 0 : i.internal) === se.enum.warehouse || ((t = a.purchaseOrder.supplier) == null ? void 0 : t.internal) === se.enum.restaurant) && (a.purchaseOrder.items = a.purchaseOrder.items.map(
877
+ ({ totalCost: l, ...d }) => d
878
+ ));
879
+ try {
880
+ await m.updateTemplate(a), await new Promise((l) => setTimeout(l, 1e3)), o.open({
881
+ title: u("inventory.transfer.template.update.success"),
882
+ message: u("inventory.transfer.template.update.successMessage"),
883
+ type: "success"
884
+ }), p("update:show", !1), p("submitted");
885
+ } catch (l) {
886
+ o.open({
887
+ title: u("inventory.transfer.template.update.error"),
888
+ message: u("inventory.transfer.template.update.errorMessage"),
889
+ type: "error"
890
+ }), console.error("Error in updating transfer template", l);
891
+ } finally {
892
+ x.value = !1;
893
+ }
894
+ }
895
+ }
896
+ function v() {
897
+ switch (s.mode) {
898
+ case ee.CREATE:
899
+ return L();
900
+ case ee.UPDATE:
901
+ return z();
902
+ }
903
+ }
904
+ function r() {
905
+ var a, i;
906
+ (i = (a = T.value) == null ? void 0 : a.validateInputs) == null || i.call(a);
907
+ }
908
+ return (a, i) => {
909
+ const t = C("FmButton"), l = C("FmSideSheet");
910
+ return D(), K(l, {
911
+ modelValue: e(g),
912
+ "onUpdate:modelValue": i[2] || (i[2] = (d) => De(g) ? g.value = d : null),
913
+ "dismiss-away": "",
914
+ "close-button": "",
915
+ "max-width": 1200
916
+ }, {
917
+ "side-sheet-header": E(() => [
918
+ n("div", lo, [
919
+ n("div", ao, $(y.value), 1)
920
+ ])
921
+ ]),
922
+ default: E(() => [
923
+ (D(), K(so, {
924
+ class: "w-full",
925
+ ref_key: "formRef",
926
+ ref: T,
927
+ onValidationSuccess: v,
928
+ "model-value": w.value,
929
+ "onUpdate:modelValue": i[0] || (i[0] = (d) => w.value = d),
930
+ disabled: x.value,
931
+ key: O.value
932
+ }, null, 8, ["model-value", "disabled"]))
933
+ ]),
934
+ "side-sheet-footer": E(() => [
935
+ n("div", ro, [
936
+ f(t, {
937
+ loading: x.value,
938
+ label: e(u)("common.save"),
939
+ onClick: r
940
+ }, null, 8, ["loading", "label"]),
941
+ f(t, {
942
+ disabled: x.value,
943
+ variant: "tertiary",
944
+ label: e(u)("common.close"),
945
+ onClick: i[1] || (i[1] = (d) => p("update:show", !1))
946
+ }, null, 8, ["disabled", "label"])
947
+ ])
948
+ ]),
949
+ _: 1
950
+ }, 8, ["modelValue"]);
951
+ };
952
+ }
953
+ }), uo = { class: "flex flex-col gap-16 w-full h-full overflow-y-auto" }, mo = { class: "flex justify-between" }, co = { class: "fm-typo-en-body-lg-600" }, po = { class: "fm-status-badge fm-status-badge-info-secondary" }, fo = { class: "flex flex-col gap-8" }, yo = { class: "flex flex-col gap-4" }, vo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, bo = { class: "flex gap-1" }, _o = { class: "fm-typo-en-body-lg-600" }, xo = {
954
+ key: 0,
955
+ class: "flex flex-col gap-4"
956
+ }, ho = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, go = { class: "fm-typo-en-body-lg-600" }, Fo = {
957
+ key: 1,
958
+ class: "flex flex-col gap-4"
959
+ }, To = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, wo = { class: "fm-typo-en-body-lg-600" }, ko = {
960
+ key: 2,
961
+ class: "flex flex-col gap-4"
962
+ }, Mo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, $o = { class: "fm-typo-en-body-lg-600" }, Co = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, So = { class: "flex flex-col gap-8" }, Oo = { class: "fm-typo-en-body-lg-600" }, Io = { class: "flex w-full gap-4" }, Vo = { class: "grow fm-typo-en-body-lg-400 line-clamp-2" }, Do = { class: "fm-typo-en-body-lg-600 shrink-0" }, Ro = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Ao = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Po = {
963
+ key: 0,
964
+ class: "shrink-0 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
965
+ }, Lo = {
966
+ key: 0,
967
+ class: "flex gap-4 items-center"
968
+ }, Bo = { class: "flex flex-col gap-12" }, Uo = { class: "flex flex-col gap-8" }, Eo = { class: "flex gap-8 xs:flex-col" }, qo = /* @__PURE__ */ Z({
969
+ __name: "TransferTemplateDetails",
970
+ props: {
971
+ template: {},
972
+ show: { type: Boolean }
973
+ },
974
+ emits: ["update:show", "action:edit"],
975
+ setup(b, { emit: _ }) {
976
+ const c = b, s = _, p = Pe(), { t: m } = J(), o = R(() => {
977
+ var x;
978
+ return (x = c.template) == null ? void 0 : x.purchaseOrder;
979
+ }), u = [
980
+ { accessorKey: "name", header: () => "Name" },
981
+ { accessorKey: "type", header: () => "Type" }
982
+ ], g = U(""), F = R(
983
+ () => {
984
+ var x, y, T, L;
985
+ return ((y = (x = o.value) == null ? void 0 : x.supplier) == null ? void 0 : y.internal) === "restaurant" || ((L = (T = o.value) == null ? void 0 : T.supplier) == null ? void 0 : L.internal) === "warehouse" ? N.TRANSFER : N.PURCHASE;
986
+ }
987
+ ), w = U(!0), O = Be(c, "show");
988
+ return (x, y) => {
989
+ var i;
990
+ const T = C("FmMenuDivider"), L = C("FmCard"), z = C("FmIcon"), v = C("FmTextField"), r = C("FmTable"), h = C("FmButton"), a = C("FmSideSheet");
991
+ return D(), K(a, {
992
+ header: e(m)("inventory.transfer.template.details.view", { template: (i = x.template) == null ? void 0 : i.name }),
993
+ modelValue: e(O),
994
+ "onUpdate:modelValue": y[2] || (y[2] = (t) => De(O) ? O.value = t : null),
995
+ "dismiss-away": w.value,
996
+ "close-button": "",
997
+ "max-width": 500
998
+ }, {
999
+ default: E(() => {
1000
+ var t, l;
1001
+ return [
1002
+ n("div", uo, [
1003
+ n("div", null, [
1004
+ f(L, {
1005
+ variant: "outlined",
1006
+ class: "flex flex-col gap-8 px-12 py-16"
1007
+ }, {
1008
+ default: E(() => {
1009
+ var d, M, S, I, V, A, H;
1010
+ return [
1011
+ n("div", mo, [
1012
+ n("div", co, $(e(m)("inventory.transfer.template.details.templateSummary")), 1),
1013
+ n("div", po, $(e(m)(
1014
+ `inventory.transfer.receiveRequest.details.type.${F.value.toLocaleLowerCase("en-US")}`
1015
+ )), 1)
1016
+ ]),
1017
+ f(T),
1018
+ n("div", fo, [
1019
+ n("div", yo, [
1020
+ n("div", vo, [
1021
+ n("div", bo, $(e(m)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1022
+ ]),
1023
+ n("div", _o, $(e(wt)(((d = x.template) == null ? void 0 : d._id) ?? "")), 1)
1024
+ ]),
1025
+ (S = (M = o.value) == null ? void 0 : M.supplier) != null && S.name ? (D(), Q("div", xo, [
1026
+ n("div", ho, $(e(m)("inventory.transfer.receiveRequest.details.from")), 1),
1027
+ n("div", go, $((V = (I = o.value) == null ? void 0 : I.supplier) == null ? void 0 : V.name), 1)
1028
+ ])) : Y("", !0),
1029
+ (A = o.value) != null && A.ref ? (D(), Q("div", Fo, [
1030
+ n("div", To, $(e(m)("inventory.transfer.receiveRequest.details.reference")), 1),
1031
+ n("div", wo, $(o.value.ref), 1)
1032
+ ])) : Y("", !0),
1033
+ (H = o.value) != null && H.remark ? (D(), Q("div", ko, [
1034
+ n("div", Mo, $(e(m)("inventory.transfer.receiveRequest.details.remark")), 1),
1035
+ n("div", $o, $(o.value.remark), 1)
1036
+ ])) : Y("", !0)
1037
+ ])
1038
+ ];
1039
+ }),
1040
+ _: 1
1041
+ })
1042
+ ]),
1043
+ n("div", Co, [
1044
+ n("div", So, [
1045
+ n("div", Oo, $(e(m)("inventory.transfer.receiveRequest.details.requestedItems")), 1),
1046
+ (D(!0), Q(Re, null, He(((t = o.value) == null ? void 0 : t.items) ?? [], (d) => (D(), Q("div", {
1047
+ key: d.code,
1048
+ class: "flex flex-col"
1049
+ }, [
1050
+ n("div", Io, [
1051
+ n("div", Vo, $(d.name), 1),
1052
+ y[3] || (y[3] = n("div", { class: "flex-1 min-w-32" }, null, -1)),
1053
+ n("div", Do, $(e(Ye)(d.quantity, d.sku.unit, d.measurement)), 1)
1054
+ ]),
1055
+ n("div", Ro, [
1056
+ n("div", Ao, $(d.code), 1),
1057
+ d.totalCost && e(p).enableTotalCost ? (D(), Q("div", Po, " (" + $(e(ft)(d.totalCost)) + ") ", 1)) : Y("", !0)
1058
+ ]),
1059
+ e(et)(d) ? (D(), Q("div", Lo, [
1060
+ f(z, {
1061
+ name: "error",
1062
+ color: "system-error-300",
1063
+ size: "sm"
1064
+ }),
1065
+ y[4] || (y[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))
1066
+ ])) : Y("", !0)
1067
+ ]))), 128))
1068
+ ])
1069
+ ]),
1070
+ y[6] || (y[6] = n("div", null, null, -1)),
1071
+ y[7] || (y[7] = n("div", null, null, -1)),
1072
+ n("div", Bo, [
1073
+ y[5] || (y[5] = n("div", { class: "flex flex-col" }, [
1074
+ n("div", { class: "fm-typo-en-body-lg-600" }, "Enabled locations"),
1075
+ n("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
+ n("div", Uo, [
1078
+ f(v, {
1079
+ modelValue: g.value,
1080
+ "onUpdate:modelValue": y[0] || (y[0] = (d) => g.value = d),
1081
+ placeholder: "Filter locations",
1082
+ "prepend-icon": "search"
1083
+ }, null, 8, ["modelValue"]),
1084
+ f(r, {
1085
+ "hide-footer": "",
1086
+ style: { height: "500px" },
1087
+ "column-defs": u,
1088
+ "search-value": g.value,
1089
+ "row-data": ((l = c.template) == null ? void 0 : l.locations) ?? [{ name: "All locations" }]
1090
+ }, null, 8, ["search-value", "row-data"])
1091
+ ])
1092
+ ])
1093
+ ])
1094
+ ];
1095
+ }),
1096
+ "side-sheet-footer": E(() => [
1097
+ n("div", Eo, [
1098
+ f(h, {
1099
+ label: e(m)("common.edit"),
1100
+ onClick: y[1] || (y[1] = (t) => s("action:edit")),
1101
+ variant: "tertiary"
1102
+ }, null, 8, ["label"])
1103
+ ])
1104
+ ]),
1105
+ _: 1
1106
+ }, 8, ["header", "modelValue", "dismiss-away"]);
1107
+ };
1108
+ }
1109
+ }), No = { class: "flex-1 flex flex-col gap-8" }, zo = { class: "flex flex-col" }, Ho = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, jo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Qo = { class: "fm-typo-en-body-lg-400" }, Go = { class: "fm-typo-en-body-lg-400 line-clamp-1" }, Ko = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, mn = /* @__PURE__ */ Z({
1110
+ __name: "TransferTemplateView",
1111
+ setup(b) {
1112
+ const { t: _ } = J(), { createTemplate: c, viewTemplate: s } = Ce(), { templateDialogProps: p, templateDetailsProps: m } = _t(Ce()), o = tt(), u = We(), g = Le(), { breakpoints: F } = bt();
1113
+ me(o.fetchTemplates);
1114
+ const w = R(
1115
+ () => o.loading.value || !g._currentLocation
1116
+ ), O = R(() => o.templates.value), x = U(""), y = R(() => F.value.xs || F.value.sm), T = R(() => y.value ? 10 : 20);
1117
+ function L(v) {
1118
+ switch (v) {
1119
+ case Se.Add:
1120
+ return c();
1121
+ }
1122
+ }
1123
+ function z(v) {
1124
+ return v;
1125
+ }
1126
+ return (v, r) => {
1127
+ const h = C("FmTable");
1128
+ return D(), Q(Re, null, [
1129
+ f(Ze, {
1130
+ title: e(_)("inventory.transfer.template.title2"),
1131
+ actions: [
1132
+ {
1133
+ label: e(_)("inventory.transfer.template.create.title"),
1134
+ value: e(Se).Add,
1135
+ isPrimary: !0,
1136
+ prependIcon: "add"
1137
+ }
1138
+ ],
1139
+ "onClick:action": L
1140
+ }, {
1141
+ default: E(() => {
1142
+ var a;
1143
+ return [
1144
+ n("div", {
1145
+ class: re([
1146
+ "flex flex-col gap-8 max-h-full",
1147
+ {
1148
+ "p-0": y.value,
1149
+ "px-24 ": !y.value
1150
+ }
1151
+ ])
1152
+ }, [
1153
+ f(Je, {
1154
+ searchable: "",
1155
+ search: x.value,
1156
+ "onUpdate:search": r[0] || (r[0] = (i) => x.value = i),
1157
+ actions: [{ icon: "refresh", onClick: e(o).fetchTemplates }]
1158
+ }, null, 8, ["search", "actions"]),
1159
+ (D(), K(h, {
1160
+ style: je(e(u).tableHeight),
1161
+ "column-defs": e(o).columnDefs,
1162
+ "row-data": O.value,
1163
+ "search-value": x.value,
1164
+ loading: w.value,
1165
+ key: (a = e(g)._currentLocation) == null ? void 0 : a.dbName,
1166
+ onRowClick: r[1] || (r[1] = (i) => e(s)(i.original)),
1167
+ "page-size": T.value
1168
+ }, {
1169
+ "list-row": E((i) => [
1170
+ f(Ee, {
1171
+ row: i,
1172
+ onRowClick: (t) => e(s)(t)
1173
+ }, {
1174
+ default: E((t) => {
1175
+ var l, d, M, S, I, V, A, H, q, k, B, X, pe, te, fe, ye, ve, be, _e, xe, oe, he, ge, Fe, Te, ne, we;
1176
+ return [
1177
+ n("div", No, [
1178
+ n("div", zo, [
1179
+ n("div", Ho, [
1180
+ f(e(j), {
1181
+ render: (M = (d = (l = t._id) == null ? void 0 : l.column) == null ? void 0 : d.columnDef) == null ? void 0 : M.cell,
1182
+ props: (I = (S = t._id) == null ? void 0 : S.getContext) == null ? void 0 : I.call(S)
1183
+ }, null, 8, ["render", "props"])
1184
+ ]),
1185
+ n("div", jo, [
1186
+ f(e(j), {
1187
+ render: (H = (A = (V = t.name) == null ? void 0 : V.column) == null ? void 0 : A.columnDef) == null ? void 0 : H.cell,
1188
+ props: (k = (q = t.name) == null ? void 0 : q.getContext) == null ? void 0 : k.call(q)
1189
+ }, null, 8, ["render", "props"])
1190
+ ]),
1191
+ n("div", Qo, [
1192
+ f(e(j), {
1193
+ render: (pe = (X = (B = t.supplier) == null ? void 0 : B.column) == null ? void 0 : X.columnDef) == null ? void 0 : pe.cell,
1194
+ props: (fe = (te = t.supplier) == null ? void 0 : te.getContext) == null ? void 0 : fe.call(te)
1195
+ }, null, 8, ["render", "props"])
1196
+ ]),
1197
+ n("div", null, $((ye = i.original.locations) != null && ye.length ? `Enabled for ${(ve = i.original.locations) == null ? void 0 : ve.length} outlets` : "Enabled for all outlets"), 1),
1198
+ n("div", Go, $(i.original.purchaseOrder.items.length ? i.original.purchaseOrder.items.map((qe) => qe.name).join(", ") : "No items"), 1),
1199
+ n("div", Ko, [
1200
+ f(e(j), {
1201
+ render: (xe = (_e = (be = t.ref) == null ? void 0 : be.column) == null ? void 0 : _e.columnDef) == null ? void 0 : xe.cell,
1202
+ props: (he = (oe = t.ref) == null ? void 0 : oe.getContext) == null ? void 0 : he.call(oe)
1203
+ }, null, 8, ["render", "props"])
1204
+ ])
1205
+ ]),
1206
+ n("div", null, [
1207
+ f(e(j), {
1208
+ render: (Te = (Fe = (ge = t.type) == null ? void 0 : ge.column) == null ? void 0 : Fe.columnDef) == null ? void 0 : Te.cell,
1209
+ props: (we = (ne = t.type) == null ? void 0 : ne.getContext) == null ? void 0 : we.call(ne)
1210
+ }, null, 8, ["render", "props"])
1211
+ ])
1212
+ ])
1213
+ ];
1214
+ }),
1215
+ _: 2
1216
+ }, 1032, ["row", "onRowClick"])
1217
+ ]),
1218
+ _: 1
1219
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1220
+ ], 2)
1221
+ ];
1222
+ }),
1223
+ _: 1
1224
+ }, 8, ["title", "actions"]),
1225
+ (D(), K(Qe, { to: "body" }, [
1226
+ f(qo, Ge(Ke(e(m))), null, 16),
1227
+ f(io, Ve(e(p), {
1228
+ onSubmitted: r[2] || (r[2] = (a) => e(o).fetchTemplates())
1229
+ }), null, 16)
1230
+ ]))
1231
+ ], 64);
1232
+ };
1233
+ }
1234
+ });
1235
+ export {
1236
+ mn as default
1237
+ };