@feedmepos/mf-inventory-portal 0.0.25-dev.37 → 0.0.25-dev.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/{App-C0_9-oDP.js → App-hhvhfaVM.js} +2 -2
  2. package/dist/{ApprovalView-BDUbQAH0.js → ApprovalView-CQTi8xek.js} +2 -2
  3. package/dist/{BindingsDialog-BvKDyWAP.js → BindingsDialog-C79sZjTC.js} +2 -2
  4. package/dist/{BindingsPicker-zAexcP3H.js → BindingsPicker-BjDgP8ZY.js} +1 -1
  5. package/dist/{BindingsTable-6dPndhbk.js → BindingsTable-BZ9Umf7m.js} +1 -1
  6. package/dist/{ClosingDraftView-NwwxcHA-.js → ClosingDraftView-CiViDjmq.js} +2 -2
  7. package/dist/{ClosingTemplateView-Cfh0BZXH.js → ClosingTemplateView-BsdJoo_c.js} +2 -2
  8. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DKxW0e2c.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CVGQkbfy.js} +3 -3
  9. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CD0p0eOE.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CGoDBgGZ.js} +1 -1
  10. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-eGofs51J.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-4_lF2HuT.js} +1 -1
  11. package/dist/{IngredientGroupView-Cz4zcWgF.js → IngredientGroupView-BBFe2QNY.js} +1 -1
  12. package/dist/{IngredientsView-Ctmor1Ds.js → IngredientsView-DrkQVuCl.js} +4 -4
  13. package/dist/{IntegrationView-DYV2ISmc.js → IntegrationView-BR0_updv.js} +1 -1
  14. package/dist/{InventoryBindingForm-Be75Cpzd.js → InventoryBindingForm-qfm6N3kd.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-D8dK7h0Z.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-C7Y6qlbt.js} +3 -3
  16. package/dist/{InventoryBindingSummary-Cw1Woc3L.js → InventoryBindingSummary-BFeonJ57.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BhKk5nMz.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-OIti-A9w.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DECtXs-3.js → PremiumBadge.vue_vue_type_script_setup_true_lang-XrWWnbN_.js} +1 -1
  19. package/dist/{PublishView-D9mnP1d8.js → PublishView-ChEkvKGY.js} +2 -2
  20. package/dist/{PurchaseOrderPrintPreview-2DOgQczG.js → PurchaseOrderPrintPreview-BrnnwFGN.js} +1 -1
  21. package/dist/ReceiveRequestView-3-xKaZwM.js +2577 -0
  22. package/dist/{RecipeView-DTwkk7M_.js → RecipeView-BKpPv7My.js} +3 -3
  23. package/dist/{StockView-cd047f5L.js → StockView-CRxqN8lP.js} +7 -7
  24. package/dist/{SupplierView-CkYiC3sV.js → SupplierView-ex1jQt0k.js} +4 -4
  25. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-CE3vSlpG.js → TransferDetails.vue_vue_type_script_setup_true_lang-CZMz9g-n.js} +19 -20
  26. package/dist/TransferTemplateView-BsWk0vV4.js +1526 -0
  27. package/dist/{UnitView-C-1I-kVv.js → UnitView-DpbEefeR.js} +3 -3
  28. package/dist/{WarehouseView-CJTtNzco.js → WarehouseView-DxX8my77.js} +1 -1
  29. package/dist/{app-C720GM9g.js → app-fksh_4Zg.js} +1660 -1659
  30. package/dist/app.js +1 -1
  31. package/dist/{decimal-BCdHyq3s.js → decimal-BNkG2vLf.js} +1 -1
  32. package/dist/{feature-Df0TfAlQ.js → feature-CSOnhGSg.js} +1 -1
  33. package/dist/{format-unit-display-DhVGfJ3A.js → format-unit-display-BLcUGrLx.js} +2 -2
  34. package/dist/{index-BcO0U3XD.js → index-D4Or5bIy.js} +2 -2
  35. package/dist/{stock-AgQ9Kd12.js → stock-DEKMoEdQ.js} +1 -1
  36. package/dist/{supplier-y6wN-U1P.js → supplier-BRQmRIMB.js} +1 -1
  37. package/dist/tsconfig.app.tsbuildinfo +1 -1
  38. package/dist/{use-ingredient-select-dialog-DedAlRiZ.js → use-ingredient-select-dialog-lCrbZ411.js} +1 -1
  39. package/dist/{use-inventory-binding-dialog-D6ESCCxB.js → use-inventory-binding-dialog-DMQdYN2j.js} +1 -1
  40. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +2 -2
  41. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +3 -2
  42. package/dist/{vue-i18n-C4yPgaCz.js → vue-i18n-Dx5MlfSW.js} +251 -251
  43. package/package.json +3 -3
  44. package/dist/ReceiveRequestView-Ss803mII.js +0 -2547
  45. package/dist/TransferTemplateView-C6-6Db2r.js +0 -1524
@@ -1,1524 +0,0 @@
1
- import { defineComponent as re, onMounted as Te, computed as q, ref as K, watch as he, inject as tt, resolveComponent as A, openBlock as F, createElementBlock as j, createElementVNode as o, createVNode as m, withCtx as B, renderSlot as Ae, withDirectives as Ue, normalizeClass as ae, vModelText as Pe, reactive as ot, h as se, toDisplayString as D, unref as e, createCommentVNode as ne, Fragment as me, renderList as ke, normalizeStyle as He, createBlock as te, mergeProps as Qe, isRef as we, createSlots as lt, Teleport as st, normalizeProps as nt, guardReactiveProps as at } from "vue";
2
- import { G as je, aD as ge, t as Le, I as rt, aE as it, aF as ut, i as oe, aG as dt, b as Ke, a as Ge, Z as Be, l as xe, O as be, K as ye, A as _e, M as mt, E as Y, u as We, af as pt, T as ct, ag as ft, B as Ze, d as de, aH as ve, ac as yt, a0 as vt, y as bt, h as qe, _ as ht, z as gt } from "./app-C720GM9g.js";
3
- import { useI18n as ue } from "@feedmepos/mf-common";
4
- import { P as X, a as xt, f as _t, t as Tt, b as Ee, u as kt } from "./format-unit-display-DhVGfJ3A.js";
5
- import { components as ie, useSnackbar as wt, useProxiedModel as Je, useBreakpoints as Ft } from "@feedmepos/ui-library";
6
- import { defineStore as Ct, storeToRefs as Ne } from "pinia";
7
- import { _ as It, b as St, F as $t, a as Mt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-CD0p0eOE.js";
8
- import { u as Xe } from "./feature-Df0TfAlQ.js";
9
- import { c as Ot, u as Vt, _ as Dt } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DKxW0e2c.js";
10
- import { u as Rt } from "./supplier-y6wN-U1P.js";
11
- import { u as At } from "./use-ingredient-select-dialog-DedAlRiZ.js";
12
- const Ut = { class: "flex flex-col" }, Pt = { class: "flex flex-col" }, Lt = { class: "flex-1" }, Bt = { class: "flex items-center" }, qt = { class: "flex-1" }, Et = { class: "flex-1" }, Nt = /* @__PURE__ */ re({
13
- __name: "FmMinMaxInput",
14
- props: {
15
- rules: {},
16
- label: {},
17
- minPlaceholder: {},
18
- maxPlaceholder: {},
19
- modelValue: {},
20
- precision: {},
21
- minLength: {},
22
- maxLength: {},
23
- inputmode: {},
24
- type: {},
25
- readonly: { type: Boolean },
26
- labelMark: {},
27
- prependIcon: {},
28
- appendIcon: {},
29
- showValidBorder: { type: Boolean },
30
- labelInfo: {},
31
- showWordCount: { type: Boolean },
32
- invalid: { type: Boolean },
33
- autofocus: { type: Boolean },
34
- formatter: { type: Function },
35
- decimal: {},
36
- datalist: {},
37
- shiftDatalist: { type: Boolean },
38
- datalistMaxHeight: {},
39
- datalistMinHeight: {},
40
- offsetDatalist: {},
41
- datalistPlacement: {},
42
- datalistZIndex: {},
43
- datalistWidth: {},
44
- disabled: { type: Boolean },
45
- focused: { type: Boolean },
46
- helperText: {},
47
- helperState: {}
48
- },
49
- setup(p) {
50
- const v = p, b = je("modelValue"), t = rt();
51
- Te(() => {
52
- const { min: c, max: d } = b ?? {};
53
- if (!(!c || !d) && c.precision !== d.precision) {
54
- const x = Math.max(c.precision, d.precision), i = ge(c, x), y = ge(d, x);
55
- b.min = i, b.max = y;
56
- }
57
- });
58
- const n = q(() => {
59
- const { min: c, max: d } = b ?? {};
60
- return Math.max((c == null ? void 0 : c.precision) ?? 0, (d == null ? void 0 : d.precision) ?? 0, v.precision ?? 0);
61
- }), _ = (c) => {
62
- if (!c) return "";
63
- const d = it(c), x = n.value, i = ge(d, x);
64
- return ut(
65
- +oe(i),
66
- i.precision
67
- );
68
- }, a = K(_(b.min)), l = K(_(b.max));
69
- he([a, l], ([c, d]) => {
70
- const x = b ?? {}, i = t(c), y = t(d), O = n.value;
71
- if (c !== "" && i === !0) {
72
- const w = Le(+c, O);
73
- x.min = w;
74
- } else
75
- x.min = null;
76
- if (d !== "" && y === !0) {
77
- const w = Le(+d, O);
78
- x.max = w;
79
- } else
80
- x.max = null;
81
- b.min = x.min, b.max = x.max;
82
- });
83
- const u = Symbol.for("fm:form-state"), f = tt(u, null), M = q(() => v.disabled ?? (f == null ? void 0 : f.getDisabled()) ?? !1), E = K(), $ = K(), R = K(!1), g = K(!1), S = q(() => R.value || g.value), h = q(() => [...[
84
- function() {
85
- return typeof t(a.value) == "string" || typeof t(l.value) == "string" ? "Must be a number" : !0;
86
- },
87
- function(x) {
88
- return !x || !x.min || !x.max ? !0 : +oe(x.min) > +oe(x.max) ? "Min must be less than or equal to max" : !0;
89
- }
90
- ], ...v.rules ?? []]);
91
- return (c, d) => {
92
- const x = A("FmLabel"), i = A("FmField"), y = A("FmFormGroup");
93
- return F(), j("div", Ut, [
94
- o("div", Pt, [
95
- o("div", Lt, [
96
- m(x, {
97
- label: c.label,
98
- disabled: c.disabled,
99
- required: c.labelMark === "required",
100
- optional: c.labelMark === "optional"
101
- }, null, 8, ["label", "disabled", "required", "optional"])
102
- ]),
103
- m(i, { focused: S.value }, {
104
- default: B(() => [
105
- o("div", Bt, [
106
- Ae(c.$slots, "prepend"),
107
- d[6] || (d[6] = o("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Min.", -1)),
108
- o("div", qt, [
109
- Ue(o("input", {
110
- type: "text",
111
- ref_key: "minInputRef",
112
- ref: E,
113
- onFocus: d[0] || (d[0] = () => R.value = !0),
114
- onBlur: d[1] || (d[1] = () => R.value = !1),
115
- "onUpdate:modelValue": d[2] || (d[2] = (O) => a.value = O),
116
- class: ae({
117
- "fm-text-field--input fm-typo-en-body-lg-400": !0,
118
- "text-fm-color-typo-primary": !M.value,
119
- "text-fm-color-typo-disabled": M.value
120
- })
121
- }, null, 34), [
122
- [Pe, a.value]
123
- ])
124
- ]),
125
- d[7] || (d[7] = o("div", { class: "block h-32 mx-4 w-[1px] bg-fm-color-neutral-gray-200" }, null, -1)),
126
- d[8] || (d[8] = o("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Max.", -1)),
127
- o("div", Et, [
128
- Ue(o("input", {
129
- type: "text",
130
- ref_key: "maxInputRef",
131
- ref: $,
132
- onFocus: d[3] || (d[3] = () => g.value = !0),
133
- onBlur: d[4] || (d[4] = () => g.value = !1),
134
- "onUpdate:modelValue": d[5] || (d[5] = (O) => l.value = O),
135
- class: ae({
136
- "fm-text-field--input fm-typo-en-body-lg-400": !0,
137
- "text-fm-color-typo-primary": !M.value,
138
- "text-fm-color-typo-disabled": M.value
139
- })
140
- }, null, 34), [
141
- [Pe, l.value]
142
- ])
143
- ]),
144
- Ae(c.$slots, "append")
145
- ])
146
- ]),
147
- _: 3
148
- }, 8, ["focused"])
149
- ]),
150
- m(y, {
151
- class: "flex-1",
152
- "model-value": c.modelValue,
153
- info: c.labelInfo,
154
- rules: h.value,
155
- "helper-text": c.helperText,
156
- "helper-state": c.helperState
157
- }, null, 8, ["model-value", "info", "rules", "helper-text", "helper-state"])
158
- ]);
159
- };
160
- }
161
- });
162
- function zt({ min: p, max: v } = { min: !0, max: !0 }) {
163
- return function(t) {
164
- return !t || !t.min && p != !1 || !t.max && v != !1 ? "Required" : !0;
165
- };
166
- }
167
- function Ht(p, v) {
168
- return function(t) {
169
- return !t || !t.min || !t.max ? !0 : +oe(t.min) < p ? `Must be between ${p} and ${v}` : +oe(t.max) > v ? `Must be between ${p} and ${v}` : !0;
170
- };
171
- }
172
- function Qt(p) {
173
- const v = dt(p), b = oe(p);
174
- return function(n) {
175
- const _ = !(n != null && n.min) || v(n.min) === !0, a = !(n != null && n.max) || v(n.max) === !0;
176
- return !_ && !a ? `Min & max must be a multiple of ${b}` : _ ? a ? !0 : `Max must be a multiple of ${b}` : `Min must be a multiple of ${b}`;
177
- };
178
- }
179
- const Ye = Ct("transfer-template-helper", () => {
180
- const p = Ke();
181
- function v(b, t, n, _, a) {
182
- var u;
183
- if (!n) {
184
- a == null || a("Unit is not valid");
185
- return;
186
- }
187
- let l = b.code;
188
- if (p.isEnabled) {
189
- const f = p.getItemPKTCode(t, (u = n.measurement) == null ? void 0 : u.id);
190
- f && (l = f);
191
- }
192
- _({
193
- ...b,
194
- quantity: n.amount,
195
- measurement: n.measurement ?? null,
196
- code: l
197
- });
198
- }
199
- return {
200
- validateUnitInput: v
201
- };
202
- });
203
- var G = /* @__PURE__ */ ((p) => (p.Code = "Code", p.Name = "Name", p.DefaultAmount = "DefaultAmount", p.Limit = "Limit", p.Step = "Step", p.Cost = "Cost", p.Delete = "Delete", p))(G || {});
204
- const ze = Ye();
205
- function jt(p) {
206
- const { t: v } = ue(), b = Ge(), t = ot({});
207
- Te(() => {
208
- for (const a of p.items) {
209
- if (!a.totalCost)
210
- continue;
211
- const l = Ot(a.sku, a.quantity, a.measurement, {
212
- supplier: p.supplier
213
- }), u = a.totalCost ?? Be.reset();
214
- l ? t[a.sku._id] = l.amount !== u.amount || l.precision !== u.precision : t[a.sku._id] = !0;
215
- }
216
- });
217
- const n = [
218
- {
219
- id: "Code",
220
- header: () => v("inventory.transfer.form.items.table.Code"),
221
- accessorKey: "code",
222
- size: 180,
223
- cell(a) {
224
- const l = a.row.original;
225
- return se(ie.FmTextField, {
226
- modelValue: l.code,
227
- "onUpdate:modelValue": (u) => {
228
- p.updateItem({
229
- ...l,
230
- code: u
231
- });
232
- },
233
- key: l.sku._id,
234
- rules: [xe()],
235
- labelMark: "required"
236
- });
237
- },
238
- enableSorting: !1
239
- },
240
- {
241
- id: "Name",
242
- header: () => v("inventory.transfer.form.items.table.Name"),
243
- minSize: 300,
244
- cell(a) {
245
- const l = a.row.original;
246
- return se(ie.FmTextField, {
247
- modelValue: l.name,
248
- "onUpdate:modelValue": (u) => {
249
- p.updateItem({
250
- ...l,
251
- name: u
252
- });
253
- },
254
- key: l.sku._id,
255
- rules: [xe()],
256
- labelMark: "required"
257
- });
258
- },
259
- enableSorting: !1
260
- },
261
- {
262
- id: "DefaultAmount",
263
- header: () => v("inventory.transfer.form.items.table.DefaultAmount"),
264
- minSize: 200,
265
- cell(a) {
266
- var $;
267
- const l = a.row.original, u = b.skuById[l.sku._id], f = b.unitById[($ = u.unit) == null ? void 0 : $._id], M = f.measurements.find((R) => {
268
- var g;
269
- return ((g = l.measurement) == null ? void 0 : g.id) === R.id;
270
- }), E = l.sku.unit._id !== u.unit._id || !f || l.measurement && !M;
271
- return se(It, {
272
- style: {
273
- flex: "1 1 0%"
274
- },
275
- modelValue: {
276
- amount: l.quantity ?? { amount: 1, precision: 0 },
277
- // NOTE: leave this reading from row.sku.unit and row.measurement instead,
278
- measurement: l.measurement ?? (l.sku.unit._id !== u.unit._id ? { ...l.sku.unit, id: "", conversion: { amount: 1, precision: 0 } } : null)
279
- },
280
- disabled: p.disabled,
281
- key: l.sku._id,
282
- unit: f,
283
- "onUpdate:modelValue": (R) => {
284
- ze.validateUnitInput(
285
- l,
286
- u,
287
- R,
288
- (g) => {
289
- p.updateItem({
290
- ...l,
291
- code: g.code,
292
- sku: u,
293
- quantity: g.quantity,
294
- measurement: g.measurement
295
- });
296
- }
297
- );
298
- },
299
- rules: [
300
- St(l.quantityStep),
301
- ...+oe(l.quantity) ? [
302
- $t(
303
- +oe(
304
- l.minimumQuantity ?? {
305
- amount: 1,
306
- // NOTE: leave this reading from row.sku.unit and row.measurement instead,
307
- precision: be(l.sku.unit, l.measurement)
308
- }
309
- )
310
- )
311
- ] : [],
312
- Mt(
313
- l.maximumQuantity ? +oe(l.maximumQuantity) : 1 / 0
314
- ),
315
- function(g) {
316
- return E ? "This item is no longer valid due to change in unit. Please reapply unit." : !0;
317
- }
318
- ],
319
- applyDefaultRules: !0
320
- });
321
- },
322
- enableSorting: !1
323
- },
324
- {
325
- id: "Limit",
326
- header: () => "Limit",
327
- // TODO: i18n,
328
- minSize: 280,
329
- cell(a) {
330
- const l = a.row.original;
331
- return se(Nt, {
332
- style: {
333
- flex: "1 1 0%"
334
- },
335
- modelValue: {
336
- min: l.minimumQuantity,
337
- max: l.maximumQuantity
338
- },
339
- disabled: p.disabled,
340
- key: l.sku._id,
341
- unit: l.sku.unit,
342
- "onUpdate:modelValue": (u) => {
343
- const f = { ...l };
344
- u != null && u.min ? f.minimumQuantity = u.min : f.minimumQuantity = null, u != null && u.max ? f.maximumQuantity = u.max : f.maximumQuantity = null, p.updateItem(f);
345
- },
346
- rules: [
347
- zt({ max: !1 }),
348
- Qt(l.quantityStep),
349
- Ht(
350
- +oe({
351
- amount: 0,
352
- precision: be(l.sku.unit, l.measurement)
353
- }),
354
- 1 / 0
355
- )
356
- ],
357
- disableUnit: !0,
358
- applyDefaultRules: !0
359
- });
360
- }
361
- },
362
- {
363
- id: "Step",
364
- header: () => v("inventory.transfer.form.items.table.Step"),
365
- minSize: 100,
366
- cell(a) {
367
- const l = a.row.original;
368
- return se(ie.FmTextField, {
369
- modelValue: oe(l.quantityStep ?? Be.reset(), !1),
370
- key: l.sku._id,
371
- "onUpdate:modelValue": (u) => {
372
- p.updateItem({
373
- ...l,
374
- quantityStep: ye(+u)
375
- });
376
- },
377
- rules: [
378
- _e({
379
- amount: 1,
380
- precision: be(l.sku.unit, l.measurement)
381
- }),
382
- mt(l.sku.unit, l.measurement)
383
- ]
384
- });
385
- },
386
- enableSorting: !1
387
- },
388
- {
389
- id: "Delete",
390
- header: "",
391
- cell(a) {
392
- const l = a.row.original;
393
- return se("div", { class: "flex items-center" }, [
394
- se(
395
- ie.FmTooltip,
396
- {
397
- zIndex: 50,
398
- placement: "left"
399
- },
400
- {
401
- default() {
402
- return se(ie.FmButton, {
403
- key: l.sku._id,
404
- type: "button",
405
- icon: "add_circle",
406
- variant: "tertiary",
407
- size: "md",
408
- disabled: p.disabled,
409
- onClick: async () => {
410
- const u = {
411
- id: crypto.randomUUID(),
412
- sku: l.sku,
413
- code: l.sku.code,
414
- name: l.sku.name,
415
- quantity: ye(1),
416
- quantityStep: ye(1),
417
- minimumQuantity: ye(1)
418
- };
419
- ze.validateUnitInput(
420
- u,
421
- l.sku,
422
- {
423
- amount: u.quantity,
424
- measurement: null
425
- },
426
- (f) => {
427
- u.code = f.code;
428
- }
429
- ), p.duplicateItem(u);
430
- }
431
- });
432
- },
433
- content() {
434
- return "Duplicate entry";
435
- }
436
- }
437
- ),
438
- se(ie.FmButton, {
439
- class: "delete-button",
440
- key: l.sku._id,
441
- type: "button",
442
- icon: "delete",
443
- variant: "tertiary",
444
- size: "md",
445
- disabled: p.disabled,
446
- onClick: () => {
447
- p.deleteItem(l);
448
- }
449
- })
450
- ]);
451
- },
452
- enableSorting: !1,
453
- size: 40,
454
- meta: {
455
- cellClass: "",
456
- headerClass: ""
457
- }
458
- }
459
- ];
460
- return {
461
- columnDefs: q(() => Xe().enableTotalCost && p.transferType === X.PURCHASE ? n : n.filter((l) => l.id !== "Cost"))
462
- };
463
- }
464
- const Kt = { class: "flex flex-col gap-8 py-16" }, Gt = { class: "flex items-center" }, Wt = { class: "flex-1 flex gap-1 items-center" }, Zt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Jt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Xt = { class: "flex gap-8 w-full" }, Yt = { class: "flex-1 flex flex-col gap-4" }, eo = { class: "flex-1 flex flex-col gap-4" }, to = {
465
- key: 0,
466
- class: "flex gap-8 w-full"
467
- }, oo = { class: "flex-1 flex flex-col gap-4" }, lo = { class: "flex-1 flex flex-col gap-4" }, so = { class: "flex gap-8 w-full" }, no = { class: "flex-1 flex flex-col gap-4" }, ao = /* @__PURE__ */ re({
468
- __name: "TransferTemplateItem",
469
- props: {
470
- cellByColId: {},
471
- row: {}
472
- },
473
- setup(p) {
474
- const { t: v } = ue();
475
- function b(t) {
476
- return t;
477
- }
478
- return (t, n) => {
479
- var a, l, u, f, M, E, $, R, g, S, h, c, d, x, i, y, O, w, C, J, W, N, L, I, s, r, k, P, z, H;
480
- const _ = A("FmLabel");
481
- return F(), j("div", Kt, [
482
- o("div", Gt, [
483
- o("div", Wt, [
484
- o("span", Zt, " (" + D(t.row.original.sku.code) + ") ", 1),
485
- o("span", Jt, D(t.row.original.sku.name), 1)
486
- ]),
487
- o("div", null, [
488
- m(e(Y), {
489
- render: (u = (l = (a = t.cellByColId.Delete) == null ? void 0 : a.column) == null ? void 0 : l.columnDef) == null ? void 0 : u.cell,
490
- props: (M = (f = t.cellByColId.Delete) == null ? void 0 : f.getContext) == null ? void 0 : M.call(f)
491
- }, null, 8, ["render", "props"])
492
- ])
493
- ]),
494
- o("div", Xt, [
495
- o("div", Yt, [
496
- m(_, {
497
- label: e(v)(`inventory.transfer.form.items.table.${e(G).Code}`)
498
- }, null, 8, ["label"]),
499
- m(e(Y), {
500
- render: (R = ($ = (E = t.cellByColId[e(G).Code]) == null ? void 0 : E.column) == null ? void 0 : $.columnDef) == null ? void 0 : R.cell,
501
- props: (S = (g = t.cellByColId[e(G).Code]) == null ? void 0 : g.getContext) == null ? void 0 : S.call(g)
502
- }, null, 8, ["render", "props"]),
503
- n[0] || (n[0] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
504
- ]),
505
- o("div", eo, [
506
- m(_, {
507
- label: e(v)(`inventory.transfer.form.items.table.${e(G).Name}`)
508
- }, null, 8, ["label"]),
509
- m(e(Y), {
510
- render: (d = (c = (h = t.cellByColId[e(G).Name]) == null ? void 0 : h.column) == null ? void 0 : c.columnDef) == null ? void 0 : d.cell,
511
- props: (i = (x = t.cellByColId[e(G).Name]) == null ? void 0 : x.getContext) == null ? void 0 : i.call(x)
512
- }, null, 8, ["render", "props"]),
513
- n[1] || (n[1] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
514
- ])
515
- ]),
516
- t.row.original ? (F(), j("div", to, [
517
- o("div", oo, [
518
- m(_, {
519
- label: e(v)(`inventory.transfer.form.items.table.${e(G).DefaultAmount}`)
520
- }, null, 8, ["label"]),
521
- m(e(Y), {
522
- render: (w = (O = (y = t.cellByColId[e(G).DefaultAmount]) == null ? void 0 : y.column) == null ? void 0 : O.columnDef) == null ? void 0 : w.cell,
523
- props: (J = (C = t.cellByColId[e(G).DefaultAmount]) == null ? void 0 : C.getContext) == null ? void 0 : J.call(C)
524
- }, null, 8, ["render", "props"]),
525
- n[2] || (n[2] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
526
- ]),
527
- o("div", lo, [
528
- m(_, {
529
- label: e(v)(`inventory.transfer.form.items.table.${e(G).Step}`)
530
- }, null, 8, ["label"]),
531
- m(e(Y), {
532
- render: (L = (N = (W = t.cellByColId[e(G).Step]) == null ? void 0 : W.column) == null ? void 0 : N.columnDef) == null ? void 0 : L.cell,
533
- props: (s = (I = t.cellByColId[e(G).Step]) == null ? void 0 : I.getContext) == null ? void 0 : s.call(I)
534
- }, null, 8, ["render", "props"]),
535
- n[3] || (n[3] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
536
- ])
537
- ])) : ne("", !0),
538
- o("div", so, [
539
- o("div", no, [
540
- m(_, {
541
- label: e(v)(`inventory.transfer.form.items.table.${e(G).Limit}`)
542
- }, null, 8, ["label"]),
543
- m(e(Y), {
544
- render: (P = (k = (r = t.cellByColId[e(G).Limit]) == null ? void 0 : r.column) == null ? void 0 : k.columnDef) == null ? void 0 : P.cell,
545
- props: (H = (z = t.cellByColId[e(G).Limit]) == null ? void 0 : z.getContext) == null ? void 0 : H.call(z)
546
- }, null, 8, ["render", "props"]),
547
- n[4] || (n[4] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
548
- ])
549
- ])
550
- ]);
551
- };
552
- }
553
- }), ro = { class: "hover:bg-fm-color-opacity-sm" }, io = { class: "fm-typo-en-body-md-400 line-clamp-2 w-full" }, uo = /* @__PURE__ */ re({
554
- __name: "TransferTemplateItemTable",
555
- props: {
556
- row: {},
557
- disabled: { type: Boolean }
558
- },
559
- emits: ["update:item"],
560
- setup(p) {
561
- function v(b) {
562
- return b.column.columnDef.meta;
563
- }
564
- return (b, t) => (F(), j("tr", ro, [
565
- (F(!0), j(me, null, ke(b.row.getVisibleCells(), (n) => {
566
- var _, a, l, u, f;
567
- return F(), j("td", {
568
- key: n.id,
569
- class: ae(["text-fm-color-typo-primary", ((_ = v(n)) == null ? void 0 : _.cellClass) ?? "px-16"]),
570
- style: He({
571
- width: (a = v(n)) != null && a.width ? (l = v(n)) == null ? void 0 : l.width : n.column.getSize() !== 0 ? `${n.column.getSize()}px` : void 0,
572
- maxWidth: (u = v(n)) == null ? void 0 : u.maxWidth,
573
- textAlign: ((f = v(n)) == null ? void 0 : f.textAlign) ?? "left"
574
- })
575
- }, [
576
- o("span", io, [
577
- m(e(Y), {
578
- props: n.getContext(),
579
- render: n.column.columnDef.cell
580
- }, null, 8, ["props", "render"])
581
- ])
582
- ], 6);
583
- }), 128))
584
- ]));
585
- }
586
- }), mo = { class: "flex flex-col gap-16" }, po = { class: "flex flex-col gap-24" }, co = { class: "flex flex-col gap-16" }, fo = { class: "flex items-center" }, yo = { class: "flex flex-col" }, vo = { class: "flex flex-col gap-4" }, bo = {
587
- key: 0,
588
- class: "text-fm-color-typo-error fm-typo-en-body-sm-400"
589
- }, ho = {
590
- key: 1,
591
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
592
- }, go = { class: "flex flex-wrap gap-8 fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, xo = { class: "flex flex-col gap-16" }, _o = { class: "flex" }, To = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, ko = /* @__PURE__ */ re({
593
- __name: "TransferTemplateForm",
594
- props: {
595
- modelValue: {},
596
- disabled: { type: Boolean }
597
- },
598
- setup(p, { expose: v }) {
599
- const b = p, t = je(), { t: n } = ue(), _ = We(), a = Ge(), l = Rt();
600
- Ke();
601
- const u = Ye();
602
- he(
603
- () => b.modelValue,
604
- (s) => {
605
- console.log("TransferTemplateForm.model", s);
606
- }
607
- ), _.watchLocation(async () => {
608
- location && (t.purchaseOrder.supplier || (t.purchaseOrder.supplier = l.suppliers.find((s) => s) ?? t.purchaseOrder.supplier));
609
- });
610
- const f = Vt(
611
- () => t.purchaseOrder,
612
- (s) => {
613
- t.purchaseOrder = {
614
- ...t.purchaseOrder,
615
- supplier: s.supplier ?? (t == null ? void 0 : t.purchaseOrder.supplier)
616
- };
617
- }
618
- ), M = q({
619
- get() {
620
- var s, r;
621
- return typeof ((r = (s = t.purchaseOrder) == null ? void 0 : s.supplier) == null ? void 0 : r.internal) == "string" ? X.TRANSFER : X.PURCHASE;
622
- },
623
- set(s) {
624
- var k, P;
625
- const r = typeof ((P = (k = t.purchaseOrder) == null ? void 0 : k.supplier) == null ? void 0 : P.internal) == "string" ? X.TRANSFER : X.PURCHASE;
626
- s !== r && (t.purchaseOrder.supplier = s === X.PURCHASE ? f.locationOptionsTypePurchase.value[0] : f.locationOptionsTypeTransfer.value[0]);
627
- }
628
- }), E = q(() => f.transferLocationOptions.value), $ = q({
629
- get() {
630
- var s;
631
- return (s = t.purchaseOrder.supplier) == null ? void 0 : s._id;
632
- },
633
- set(s) {
634
- f.transferLocationModel.value = s;
635
- }
636
- }), {
637
- promptSelectLocations: R,
638
- columnDefs: g,
639
- rowData: S,
640
- hasCustomTag: h,
641
- locationTagModel: c,
642
- locationTagAutocomplete: d,
643
- pushLocationTag: x,
644
- removeLocationTag: i,
645
- locationTagError: y
646
- } = pt({
647
- getLocations() {
648
- return t.locations;
649
- },
650
- setLocations(s) {
651
- t.locations = s;
652
- },
653
- getLocationTags() {
654
- return t.locationTags;
655
- },
656
- setLocationTags(s) {
657
- t.locationTags = s;
658
- }
659
- });
660
- function O() {
661
- var s, r;
662
- return (s = t.locations) != null && s.find((k) => {
663
- var P, z;
664
- return ((P = k.doc) == null ? void 0 : P._id) === ((z = t.purchaseOrder.supplier) == null ? void 0 : z._id);
665
- }) ? `Location ${(r = t.purchaseOrder.supplier) == null ? void 0 : r.name} must be removed because template cannot be used to transfer to itself.` : !0;
666
- }
667
- const w = q({
668
- get() {
669
- return t.purchaseOrder.remark ?? void 0;
670
- },
671
- set(s) {
672
- t.purchaseOrder.remark = s;
673
- }
674
- }), C = K();
675
- v({
676
- validateInputs: () => {
677
- var s, r;
678
- (r = (s = C.value) == null ? void 0 : s.validateInputs) == null || r.call(s);
679
- },
680
- resetInputsValidation: () => {
681
- var s, r;
682
- (r = (s = C.value) == null ? void 0 : s.resetInputsValidation) == null || r.call(s);
683
- },
684
- resetInputs: () => {
685
- var s, r;
686
- (r = (s = C.value) == null ? void 0 : s.resetInputs) == null || r.call(s);
687
- }
688
- });
689
- const J = q(() => ({
690
- duplicateItem: (s) => {
691
- t.purchaseOrder.items = [
692
- ...t.purchaseOrder.items,
693
- {
694
- ...s
695
- }
696
- ];
697
- },
698
- updateItem: (s) => {
699
- let r = [];
700
- s.id ? r = t.purchaseOrder.items.map((k) => k.id !== s.id ? k : s) : r = t.purchaseOrder.items.map((k) => k.sku._id !== s.sku._id ? k : s), t.purchaseOrder.items = r;
701
- },
702
- deleteItem: (s) => {
703
- console.log(s.id);
704
- let r = [];
705
- s.id ? r = t.purchaseOrder.items.filter((k) => k.id !== s.id) : r = t.purchaseOrder.items.filter((k) => k.sku._id !== s.sku._id), t.purchaseOrder.items = r;
706
- }
707
- })), W = jt({
708
- duplicateItem: J.value.duplicateItem,
709
- updateItem: J.value.updateItem,
710
- deleteItem: J.value.deleteItem,
711
- get supplier() {
712
- return t.purchaseOrder.supplier;
713
- },
714
- get items() {
715
- return t.purchaseOrder.items;
716
- },
717
- get transferType() {
718
- return X.PURCHASE;
719
- },
720
- get disabled() {
721
- return b.disabled;
722
- }
723
- }), N = q(() => W.columnDefs.value), { promptSelectIngredients: L } = At();
724
- async function I() {
725
- const r = a.skus.map((V) => ({
726
- label: V.name,
727
- sublabel: V.code,
728
- value: V
729
- })).filter((V) => {
730
- var U;
731
- return (U = t.purchaseOrder.items) == null ? void 0 : U.find((Z) => Z.sku._id === V.value._id);
732
- }).map((V) => V.value), k = t.purchaseOrder.items ?? [], P = await L(
733
- r.map((V) => V._id),
734
- (V) => {
735
- const U = a.skuById[V], Z = k.find((T) => T.sku._id === U._id);
736
- if (Z)
737
- return Z;
738
- const ee = { amount: 1, precision: be(U.unit) };
739
- let le = {
740
- id: crypto.randomUUID(),
741
- sku: U,
742
- code: U.code,
743
- name: U.name,
744
- quantity: ee,
745
- minimumQuantity: ee,
746
- // maximumQuantity: adjustmentAmountMultiplyDecimal(minimumQuantity, {
747
- // amount: 100,
748
- // precision: 0
749
- // }),
750
- quantityStep: ee
751
- };
752
- return u.validateUnitInput(
753
- le,
754
- U,
755
- {
756
- amount: ee,
757
- measurement: null
758
- },
759
- (T) => {
760
- le.code = T.code;
761
- }
762
- ), le;
763
- }
764
- );
765
- if (!P) return;
766
- const z = P.map((V) => V.sku._id), H = [];
767
- for (const V of z) {
768
- const U = k.filter((Z) => Z.sku._id === V);
769
- if (U.length > 0)
770
- H.push(...U);
771
- else {
772
- const Z = P.find((ee) => ee.sku._id === V);
773
- Z && H.push(Z);
774
- }
775
- }
776
- H.sort((V, U) => V.sku.code.localeCompare(U.sku.code)), t.purchaseOrder.items = H;
777
- }
778
- return (s, r) => {
779
- const k = A("FmTextField"), P = A("FmSelect"), z = A("FmTextarea"), H = A("FmButton"), V = A("FmTable"), U = A("FmFormGroup"), Z = A("FmChip"), ee = A("FmForm");
780
- return F(), te(ee, {
781
- ref_key: "formRef",
782
- ref: C,
783
- class: "flex flex-col gap-32",
784
- disabled: s.disabled
785
- }, {
786
- default: B(() => {
787
- var le;
788
- return [
789
- o("div", mo, [
790
- o("div", po, [
791
- m(k, {
792
- label: e(n)("inventory.transfer.form.name"),
793
- "label-mark": "required",
794
- modelValue: e(t).name,
795
- "onUpdate:modelValue": r[0] || (r[0] = (T) => e(t).name = T),
796
- rules: [e(xe)()]
797
- }, null, 8, ["label", "modelValue", "rules"]),
798
- m(P, {
799
- label: e(n)("inventory.transfer.form.type.title"),
800
- "model-value": M.value,
801
- "onUpdate:modelValue": r[1] || (r[1] = (T) => M.value = T),
802
- items: [
803
- {
804
- label: e(n)("inventory.transfer.form.type.purchase"),
805
- value: e(X).PURCHASE,
806
- disabled: !e(f).locationOptionsTypePurchase.value.length,
807
- sublabel: e(f).locationOptionsTypePurchase.value.length ? void 0 : e(n)("inventory.transfer.form.noSupplierAvailable")
808
- },
809
- {
810
- label: e(n)("inventory.transfer.form.type.transfer"),
811
- value: e(X).TRANSFER,
812
- disabled: !e(f).locationOptionsTypeTransfer.value.length,
813
- sublabel: e(f).locationOptionsTypeTransfer.value.length ? void 0 : e(n)("inventory.transfer.form.noLocationAvailable")
814
- }
815
- ],
816
- rules: [e(_e)(1)(E.value)]
817
- }, {
818
- default: B(() => [
819
- o("span", {
820
- class: ae([
821
- "line-clamp-1 fm-typo-en-body-lg-400",
822
- s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
823
- ])
824
- }, D(e(ct)(M.value)), 3)
825
- ]),
826
- _: 1
827
- }, 8, ["label", "model-value", "items", "rules"]),
828
- m(P, {
829
- label: M.value === e(X).PURCHASE ? e(n)("inventory.transfer.form.purchaseFrom") : e(n)("inventory.transfer.form.transferFrom"),
830
- modelValue: $.value,
831
- "onUpdate:modelValue": r[2] || (r[2] = (T) => $.value = T),
832
- items: E.value
833
- }, {
834
- "menu-wrapper": B((T) => {
835
- var Q;
836
- return [
837
- m(Dt, Qe(T, {
838
- items: E.value,
839
- "model-value": (Q = s.modelValue.purchaseOrder.supplier) == null ? void 0 : Q._id
840
- }), null, 16, ["items", "model-value"])
841
- ];
842
- }),
843
- default: B(() => {
844
- var T;
845
- return [
846
- o("span", {
847
- class: ae([
848
- "line-clamp-1 fm-typo-en-body-lg-400",
849
- s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
850
- ])
851
- }, D((T = E.value.find((Q) => Q.value === $.value)) == null ? void 0 : T.label), 3)
852
- ];
853
- }),
854
- _: 1
855
- }, 8, ["label", "modelValue", "items"]),
856
- m(k, {
857
- label: e(n)("inventory.transfer.form.reference"),
858
- "label-mark": "optional",
859
- modelValue: e(t).purchaseOrder.ref,
860
- "onUpdate:modelValue": r[3] || (r[3] = (T) => e(t).purchaseOrder.ref = T)
861
- }, null, 8, ["label", "modelValue"]),
862
- m(z, {
863
- label: e(n)("inventory.transfer.form.remark"),
864
- "label-mark": "optional",
865
- "max-length": 240,
866
- modelValue: w.value,
867
- "onUpdate:modelValue": r[4] || (r[4] = (T) => w.value = T),
868
- class: ae({ "text-fm-color-typo-disabled": s.disabled })
869
- }, null, 8, ["label", "modelValue", "class"])
870
- ])
871
- ]),
872
- o("div", co, [
873
- o("div", fo, [
874
- r[9] || (r[9] = o("div", { class: "flex-1 fm-typo-en-title-sm-600" }, "Locations", -1)),
875
- m(H, {
876
- disabled: s.disabled,
877
- label: "Select location",
878
- "prepend-icon": "add",
879
- variant: "plain",
880
- class: "border-2 rounded-lg border-fm-color-primary",
881
- onClick: e(R)
882
- }, null, 8, ["disabled", "onClick"])
883
- ]),
884
- m(V, {
885
- "column-defs": e(g),
886
- "row-data": e(S),
887
- "shrink-at": 9999,
888
- onRowClick: e(R),
889
- "hide-footer": ""
890
- }, null, 8, ["column-defs", "row-data", "onRowClick"]),
891
- o("div", yo, [
892
- m(U, {
893
- "model-value": [
894
- (le = b.modelValue.purchaseOrder.supplier) == null ? void 0 : le._id,
895
- ...b.modelValue.locations ?? []
896
- ].join(","),
897
- rules: [O]
898
- }, null, 8, ["model-value", "rules"])
899
- ]),
900
- e(h) ? (F(), te(ft, {
901
- key: 0,
902
- label: "Location tag",
903
- modelValue: e(c),
904
- "onUpdate:modelValue": r[5] || (r[5] = (T) => we(c) ? c.value = T : null),
905
- "onClick:menuItem": e(x),
906
- options: e(d),
907
- placeholder: "Search location tag"
908
- }, lt({
909
- "helper-text": B(() => [
910
- o("div", vo, [
911
- e(y) ? (F(), j("div", bo, D(e(y)), 1)) : (F(), j("div", ho, " This will match all locations under these values. Tag is configured in the restaurant/warehouse settings. ")),
912
- o("div", go, [
913
- (F(!0), j(me, null, ke(s.modelValue.locationTags, (T, Q) => (F(), te(Z, {
914
- key: Q,
915
- label: T,
916
- removable: "",
917
- onChipClosed: () => e(i)(T)
918
- }, null, 8, ["label", "onChipClosed"]))), 128))
919
- ])
920
- ])
921
- ]),
922
- _: 2
923
- }, [
924
- e(c) ? {
925
- name: "append",
926
- fn: B(() => [
927
- o("div", null, [
928
- m(H, {
929
- variant: "tertiary",
930
- label: "Add",
931
- icon: "add",
932
- onClick: e(x)
933
- }, null, 8, ["onClick"])
934
- ])
935
- ]),
936
- key: "0"
937
- } : void 0
938
- ]), 1032, ["modelValue", "onClick:menuItem", "options"])) : ne("", !0)
939
- ]),
940
- o("div", xo, [
941
- o("div", _o, [
942
- o("div", To, D(e(n)("inventory.transfer.form.items.title")), 1),
943
- m(H, {
944
- disabled: s.disabled,
945
- label: e(n)("inventory.transfer.form.items.addItem"),
946
- "prepend-icon": "add",
947
- variant: "plain",
948
- class: "border-2 rounded-lg border-fm-color-primary",
949
- onClick: r[6] || (r[6] = (T) => I()),
950
- size: "md"
951
- }, null, 8, ["disabled", "label"])
952
- ]),
953
- (F(), te(V, {
954
- "column-defs": N.value,
955
- "row-data": e(t).purchaseOrder.items,
956
- key: e(t).purchaseOrder.items.map((T) => T.sku._id).join("."),
957
- "hide-footer": "",
958
- "page-size": e(t).purchaseOrder.items.length
959
- }, {
960
- "table-row": B((T) => [
961
- m(uo, {
962
- row: T,
963
- "onUpdate:item": r[7] || (r[7] = (Q) => J.value.updateItem(Q)),
964
- disabled: s.disabled
965
- }, null, 8, ["row", "disabled"])
966
- ]),
967
- "list-row": B((T) => [
968
- (F(), te(Ze, {
969
- row: T,
970
- key: e(t).purchaseOrder.items.map((Q) => Q.sku._id).join(".")
971
- }, {
972
- default: B((Q) => [
973
- m(ao, {
974
- row: T,
975
- "cell-by-col-id": Q,
976
- "onUpdate:item": r[8] || (r[8] = (pe) => J.value.updateItem(pe)),
977
- disabled: s.disabled
978
- }, null, 8, ["row", "cell-by-col-id", "disabled"])
979
- ]),
980
- _: 2
981
- }, 1032, ["row"]))
982
- ]),
983
- _: 1
984
- }, 8, ["column-defs", "row-data", "page-size"])),
985
- m(U, {
986
- "model-value": e(t).purchaseOrder.items.length,
987
- rules: [e(_e)(1)]
988
- }, null, 8, ["model-value", "rules"])
989
- ])
990
- ];
991
- }),
992
- _: 1
993
- }, 8, ["disabled"]);
994
- };
995
- }
996
- }), wo = { class: "flex items-center" }, Fo = { class: "fm-typo-en-title-md-800" }, Co = { class: "flex gap-4" }, Io = /* @__PURE__ */ re({
997
- __name: "TransferTemplateDialog",
998
- props: {
999
- mode: {},
1000
- modelValue: {},
1001
- show: { type: Boolean }
1002
- },
1003
- emits: ["update:show", "submitted"],
1004
- setup(p, { expose: v, emit: b }) {
1005
- var x;
1006
- const t = p, n = b, _ = xt(), a = wt(), { t: l } = ue(), u = Je(t, "show");
1007
- function f() {
1008
- return {
1009
- _id: "",
1010
- name: "",
1011
- purchaseOrder: {
1012
- remark: void 0,
1013
- ref: void 0,
1014
- items: [],
1015
- supplier: {
1016
- _rev: void 0,
1017
- email: void 0,
1018
- internal: void 0,
1019
- contactName: void 0,
1020
- phoneNumber: void 0,
1021
- registrationNumber: void 0,
1022
- supplyItems: void 0,
1023
- _id: "",
1024
- name: "",
1025
- address: {
1026
- line2: void 0,
1027
- line1: "",
1028
- state: "",
1029
- city: "",
1030
- postcode: "",
1031
- country: ""
1032
- }
1033
- }
1034
- }
1035
- };
1036
- }
1037
- const M = K(t.modelValue ?? f()), E = K(((x = t.modelValue) == null ? void 0 : x._id) ?? `${Math.random()}`);
1038
- he(
1039
- () => t.show,
1040
- (i) => {
1041
- var y;
1042
- i && (M.value = t.modelValue ?? f(), E.value = ((y = t.modelValue) == null ? void 0 : y._id) ?? `${Math.random()}`);
1043
- }
1044
- );
1045
- const $ = K(!1), R = q(() => {
1046
- switch (t.mode) {
1047
- case de.READ:
1048
- return "";
1049
- case de.CREATE:
1050
- return l("inventory.transfer.template.create.title");
1051
- case de.UPDATE:
1052
- return l("inventory.transfer.template.update.title");
1053
- }
1054
- return "";
1055
- }), g = K();
1056
- v({
1057
- validateInputs: () => {
1058
- var i, y;
1059
- (y = (i = g.value) == null ? void 0 : i.validateInputs) == null || y.call(i);
1060
- },
1061
- resetInputsValidation: () => {
1062
- var i, y;
1063
- (y = (i = g.value) == null ? void 0 : i.resetInputsValidation) == null || y.call(i);
1064
- },
1065
- resetInputs: () => {
1066
- var i, y;
1067
- (y = (i = g.value) == null ? void 0 : i.resetInputs) == null || y.call(i);
1068
- }
1069
- });
1070
- async function S() {
1071
- var y, O;
1072
- const i = M.value;
1073
- if (i) {
1074
- $.value = !0, (((y = i.purchaseOrder.supplier) == null ? void 0 : y.internal) === ve.enum.warehouse || ((O = i.purchaseOrder.supplier) == null ? void 0 : O.internal) === ve.enum.restaurant) && (i.purchaseOrder.items = i.purchaseOrder.items.map(
1075
- ({ totalCost: w, ...C }) => C
1076
- ));
1077
- try {
1078
- await _.createTemplate(i), await new Promise((w) => setTimeout(w, 1e3)), a.open({
1079
- title: l("inventory.transfer.template.create.success"),
1080
- message: l("inventory.transfer.template.create.successMessage"),
1081
- type: "success"
1082
- }), n("update:show", !1), n("submitted");
1083
- } catch (w) {
1084
- a.open({
1085
- title: l("inventory.transfer.template.create.error"),
1086
- message: l("inventory.transfer.template.create.errorMessage"),
1087
- type: "error"
1088
- }), console.error("Error in creating transfer template", w);
1089
- } finally {
1090
- $.value = !1;
1091
- }
1092
- }
1093
- }
1094
- async function h() {
1095
- var y, O;
1096
- const i = M.value;
1097
- if (i) {
1098
- $.value = !0, (((y = i.purchaseOrder.supplier) == null ? void 0 : y.internal) === ve.enum.warehouse || ((O = i.purchaseOrder.supplier) == null ? void 0 : O.internal) === ve.enum.restaurant) && (i.purchaseOrder.items = i.purchaseOrder.items.map(
1099
- ({ totalCost: w, ...C }) => C
1100
- ));
1101
- try {
1102
- await _.updateTemplate(i), await new Promise((w) => setTimeout(w, 1e3)), a.open({
1103
- title: l("inventory.transfer.template.update.success"),
1104
- message: l("inventory.transfer.template.update.successMessage"),
1105
- type: "success"
1106
- }), n("update:show", !1), n("submitted");
1107
- } catch (w) {
1108
- a.open({
1109
- title: l("inventory.transfer.template.update.error"),
1110
- message: l("inventory.transfer.template.update.errorMessage"),
1111
- type: "error"
1112
- }), console.error("Error in updating transfer template", w);
1113
- } finally {
1114
- $.value = !1;
1115
- }
1116
- }
1117
- }
1118
- function c() {
1119
- switch (t.mode) {
1120
- case de.CREATE:
1121
- return S();
1122
- case de.UPDATE:
1123
- return h();
1124
- }
1125
- }
1126
- function d() {
1127
- var i, y;
1128
- (y = (i = g.value) == null ? void 0 : i.validateInputs) == null || y.call(i);
1129
- }
1130
- return (i, y) => {
1131
- const O = A("FmButton"), w = A("FmSideSheet");
1132
- return F(), te(w, {
1133
- modelValue: e(u),
1134
- "onUpdate:modelValue": y[2] || (y[2] = (C) => we(u) ? u.value = C : null),
1135
- "dismiss-away": "",
1136
- "close-button": "",
1137
- "max-width": 1200
1138
- }, {
1139
- "side-sheet-header": B(() => [
1140
- o("div", wo, [
1141
- o("div", Fo, D(R.value), 1)
1142
- ])
1143
- ]),
1144
- default: B(() => [
1145
- (F(), te(ko, {
1146
- class: "w-full",
1147
- ref_key: "formRef",
1148
- ref: g,
1149
- onValidationSuccess: c,
1150
- "model-value": M.value,
1151
- "onUpdate:modelValue": y[0] || (y[0] = (C) => M.value = C),
1152
- disabled: $.value,
1153
- key: E.value
1154
- }, null, 8, ["model-value", "disabled"]))
1155
- ]),
1156
- "side-sheet-footer": B(() => [
1157
- o("div", Co, [
1158
- m(O, {
1159
- loading: $.value,
1160
- label: e(l)("common.save"),
1161
- onClick: d
1162
- }, null, 8, ["loading", "label"]),
1163
- m(O, {
1164
- disabled: $.value,
1165
- variant: "tertiary",
1166
- label: e(l)("common.close"),
1167
- onClick: y[1] || (y[1] = (C) => n("update:show", !1))
1168
- }, null, 8, ["disabled", "label"])
1169
- ])
1170
- ]),
1171
- _: 1
1172
- }, 8, ["modelValue"]);
1173
- };
1174
- }
1175
- }), So = { class: "flex flex-col gap-16 w-full h-full overflow-y-auto" }, $o = { class: "flex justify-between" }, Mo = { class: "fm-typo-en-body-lg-600" }, Oo = { class: "fm-status-badge fm-status-badge-info-secondary" }, Vo = { class: "flex flex-col gap-8" }, Do = { class: "flex flex-col gap-4" }, Ro = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ao = { class: "flex gap-1" }, Uo = { class: "fm-typo-en-body-lg-600" }, Po = {
1176
- key: 0,
1177
- class: "flex flex-col gap-4"
1178
- }, Lo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bo = { class: "fm-typo-en-body-lg-600" }, qo = {
1179
- key: 1,
1180
- class: "flex flex-col gap-4"
1181
- }, Eo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, No = { class: "fm-typo-en-body-lg-600" }, zo = {
1182
- key: 2,
1183
- class: "flex flex-col gap-4"
1184
- }, Ho = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Qo = { class: "fm-typo-en-body-lg-600" }, jo = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Ko = { class: "flex flex-col gap-8" }, Go = { class: "fm-typo-en-body-lg-600" }, Wo = { class: "w-full" }, Zo = { class: "flex flex-col py-8" }, Jo = { class: "flex w-full gap-4" }, Xo = { class: "grow fm-typo-en-body-lg-400 line-clamp-2" }, Yo = { class: "fm-typo-en-body-lg-600 shrink-0" }, el = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, tl = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, ol = {
1185
- key: 0,
1186
- class: "shrink-0 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1187
- }, ll = {
1188
- key: 0,
1189
- class: "flex gap-4 items-center"
1190
- }, sl = { class: "flex flex-col gap-12" }, nl = { class: "flex flex-row flex-wrap gap-8" }, al = { class: "flex flex-col gap-8" }, rl = { class: "flex gap-8 xs:flex-col" }, il = /* @__PURE__ */ re({
1191
- __name: "TransferTemplateDetails",
1192
- props: {
1193
- template: {},
1194
- show: { type: Boolean }
1195
- },
1196
- emits: ["update:show", "action:edit"],
1197
- setup(p, { emit: v }) {
1198
- const b = p, t = v, n = Xe(), { t: _ } = ue(), a = q(() => {
1199
- var S;
1200
- return (S = b.template) == null ? void 0 : S.purchaseOrder;
1201
- }), l = K(""), u = [
1202
- { accessorKey: "name", header: () => "Name" },
1203
- { accessorKey: "type", header: () => "Type" }
1204
- ], f = K(""), M = q(
1205
- () => {
1206
- var S, h, c, d;
1207
- return ((h = (S = a.value) == null ? void 0 : S.supplier) == null ? void 0 : h.internal) === "restaurant" || ((d = (c = a.value) == null ? void 0 : c.supplier) == null ? void 0 : d.internal) === "warehouse" ? X.TRANSFER : X.PURCHASE;
1208
- }
1209
- ), E = K(!0), $ = Je(b, "show"), R = K(!1);
1210
- he(
1211
- () => b.show,
1212
- (S) => {
1213
- S && (R.value = !0, setTimeout(() => R.value = !1, 300));
1214
- }
1215
- );
1216
- function g(S) {
1217
- return S.original;
1218
- }
1219
- return (S, h) => {
1220
- var J;
1221
- const c = A("FmMenuDivider"), d = A("FmCard"), x = A("FmTextField"), i = A("FmIcon"), y = A("FmTable"), O = A("FmChip"), w = A("FmButton"), C = A("FmSideSheet");
1222
- return F(), te(C, {
1223
- header: e(_)("inventory.transfer.template.details.view", { template: (J = S.template) == null ? void 0 : J.name }),
1224
- modelValue: e($),
1225
- "onUpdate:modelValue": h[3] || (h[3] = (W) => we($) ? $.value = W : null),
1226
- "dismiss-away": E.value,
1227
- "close-button": "",
1228
- "max-width": 600
1229
- }, {
1230
- default: B(() => {
1231
- var W, N, L;
1232
- return [
1233
- o("div", So, [
1234
- o("div", null, [
1235
- m(d, {
1236
- variant: "outlined",
1237
- class: "flex flex-col gap-8 px-12 py-16"
1238
- }, {
1239
- default: B(() => {
1240
- var I, s, r, k, P, z, H;
1241
- return [
1242
- o("div", $o, [
1243
- o("div", Mo, D(e(_)("inventory.transfer.template.details.templateSummary")), 1),
1244
- o("div", Oo, D(e(_)(
1245
- `inventory.transfer.receiveRequest.details.type.${M.value.toLocaleLowerCase("en-US")}`
1246
- )), 1)
1247
- ]),
1248
- m(c),
1249
- o("div", Vo, [
1250
- o("div", Do, [
1251
- o("div", Ro, [
1252
- o("div", Ao, D(e(_)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1253
- ]),
1254
- o("div", Uo, D(e(yt)(((I = S.template) == null ? void 0 : I._id) ?? "")), 1)
1255
- ]),
1256
- (r = (s = a.value) == null ? void 0 : s.supplier) != null && r.name ? (F(), j("div", Po, [
1257
- o("div", Lo, D(e(_)("inventory.transfer.receiveRequest.details.from")), 1),
1258
- o("div", Bo, D((P = (k = a.value) == null ? void 0 : k.supplier) == null ? void 0 : P.name), 1)
1259
- ])) : ne("", !0),
1260
- (z = a.value) != null && z.ref ? (F(), j("div", qo, [
1261
- o("div", Eo, D(e(_)("inventory.transfer.receiveRequest.details.reference")), 1),
1262
- o("div", No, D(a.value.ref), 1)
1263
- ])) : ne("", !0),
1264
- (H = a.value) != null && H.remark ? (F(), j("div", zo, [
1265
- o("div", Ho, D(e(_)("inventory.transfer.receiveRequest.details.remark")), 1),
1266
- o("div", Qo, D(a.value.remark), 1)
1267
- ])) : ne("", !0)
1268
- ])
1269
- ];
1270
- }),
1271
- _: 1
1272
- })
1273
- ]),
1274
- o("div", jo, [
1275
- o("div", Ko, [
1276
- o("div", Go, D(e(_)("inventory.transfer.receiveRequest.details.requestedItems")), 1),
1277
- m(x, {
1278
- modelValue: l.value,
1279
- "onUpdate:modelValue": h[0] || (h[0] = (I) => l.value = I),
1280
- placeholder: "Filter items"
1281
- }, null, 8, ["modelValue"]),
1282
- o("div", Wo, [
1283
- m(y, {
1284
- "shrink-at": -1,
1285
- "column-defs": [{ accessorKey: "code" }, { accessorKey: "name" }],
1286
- "row-data": ((W = S.template) == null ? void 0 : W.purchaseOrder.items) ?? [],
1287
- "search-value": l.value,
1288
- "force-mobile-footer": "",
1289
- "hide-header-row": "",
1290
- loading: R.value
1291
- }, {
1292
- "list-row": B((I) => [
1293
- o("div", Zo, [
1294
- o("div", Jo, [
1295
- o("div", Xo, D(g(I).name), 1),
1296
- h[4] || (h[4] = o("div", { class: "flex-1 min-w-32" }, null, -1)),
1297
- o("div", Yo, D(e(_t)(
1298
- g(I).quantity,
1299
- g(I).sku.unit,
1300
- g(I).measurement
1301
- )), 1)
1302
- ]),
1303
- o("div", el, [
1304
- o("div", tl, D(g(I).code), 1),
1305
- g(I).totalCost && e(n).enableTotalCost ? (F(), j("div", ol, " (" + D(e(vt)(g(I).totalCost)) + ") ", 1)) : ne("", !0)
1306
- ]),
1307
- e(Tt)(g(I)) ? (F(), j("div", ll, [
1308
- m(i, {
1309
- name: "error",
1310
- color: "system-error-300",
1311
- size: "sm"
1312
- }),
1313
- h[5] || (h[5] = o("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))
1314
- ])) : ne("", !0)
1315
- ])
1316
- ]),
1317
- _: 1
1318
- }, 8, ["row-data", "search-value", "loading"])
1319
- ])
1320
- ])
1321
- ]),
1322
- h[10] || (h[10] = o("div", null, null, -1)),
1323
- h[11] || (h[11] = o("div", null, null, -1)),
1324
- o("div", sl, [
1325
- (N = S.template) != null && N.locationTags ? (F(), j(me, { key: 0 }, [
1326
- h[6] || (h[6] = o("div", { class: "flex flex-col" }, [
1327
- o("div", { class: "fm-typo-en-body-lg-600" }, "Enabled location tags"),
1328
- o("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " This template is enabled for the following location tags. ")
1329
- ], -1)),
1330
- o("div", nl, [
1331
- (F(!0), j(me, null, ke(S.template.locationTags, (I, s) => (F(), te(O, {
1332
- label: I,
1333
- key: s
1334
- }, null, 8, ["label"]))), 128))
1335
- ]),
1336
- h[7] || (h[7] = o("div", null, null, -1)),
1337
- h[8] || (h[8] = o("div", null, null, -1))
1338
- ], 64)) : ne("", !0),
1339
- h[9] || (h[9] = o("div", { class: "flex flex-col" }, [
1340
- o("div", { class: "fm-typo-en-body-lg-600" }, "Enabled locations"),
1341
- o("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " This template is only usable for the following locations. ")
1342
- ], -1)),
1343
- o("div", al, [
1344
- m(x, {
1345
- modelValue: f.value,
1346
- "onUpdate:modelValue": h[1] || (h[1] = (I) => f.value = I),
1347
- placeholder: "Filter locations",
1348
- "prepend-icon": "search"
1349
- }, null, 8, ["modelValue"]),
1350
- m(y, {
1351
- "hide-footer": "",
1352
- style: { height: "500px" },
1353
- "column-defs": u,
1354
- "search-value": f.value,
1355
- "row-data": ((L = b.template) == null ? void 0 : L.locations) ?? [{ name: "All locations" }]
1356
- }, null, 8, ["search-value", "row-data"])
1357
- ])
1358
- ])
1359
- ])
1360
- ];
1361
- }),
1362
- "side-sheet-footer": B(() => [
1363
- o("div", rl, [
1364
- m(w, {
1365
- label: e(_)("common.edit"),
1366
- onClick: h[2] || (h[2] = (W) => t("action:edit")),
1367
- variant: "tertiary"
1368
- }, null, 8, ["label"])
1369
- ])
1370
- ]),
1371
- _: 1
1372
- }, 8, ["header", "modelValue", "dismiss-away"]);
1373
- };
1374
- }
1375
- }), ul = { class: "flex-1 flex flex-col gap-8" }, dl = { class: "flex flex-col" }, ml = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, pl = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, cl = { class: "fm-typo-en-body-lg-400" }, fl = { class: "fm-typo-en-body-lg-400 line-clamp-1" }, yl = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Il = /* @__PURE__ */ re({
1376
- __name: "TransferTemplateView",
1377
- setup(p) {
1378
- const { t: v } = ue(), { createTemplate: b, viewTemplate: t, importTemplates: n, exportTemplates: _ } = Ee(), { templateDialogProps: a, templateDetailsProps: l } = Ne(Ee()), u = kt(), { loading: f, templates: M } = Ne(u), E = K(!1), $ = bt(), R = We(), { breakpoints: g } = Ft();
1379
- Te(u.fetchTemplates);
1380
- const S = q(
1381
- () => E.value || f.value || !R._currentLocation
1382
- ), h = q(() => M.value), c = K(""), d = q(() => g.value.xs || g.value.sm), x = q(() => d.value ? 10 : 20);
1383
- function i(w) {
1384
- switch (w) {
1385
- case qe.Add:
1386
- return b();
1387
- case "refresh":
1388
- return u.fetchTemplates();
1389
- case "import":
1390
- return n();
1391
- case "export":
1392
- return _();
1393
- }
1394
- }
1395
- function y(w) {
1396
- return w;
1397
- }
1398
- const O = q(() => [
1399
- {
1400
- label: v("inventory.closing.template.create.title"),
1401
- value: qe.Add,
1402
- isPrimary: !0,
1403
- prependIcon: "add"
1404
- },
1405
- {
1406
- label: "Refresh",
1407
- value: "refresh",
1408
- isPrimary: !1
1409
- },
1410
- {
1411
- label: "Import",
1412
- value: "import",
1413
- isPrimary: !1
1414
- },
1415
- {
1416
- label: "Export",
1417
- value: "export",
1418
- isPrimary: !1
1419
- }
1420
- ]);
1421
- return (w, C) => {
1422
- const J = A("FmTable");
1423
- return F(), j(me, null, [
1424
- m(ht, {
1425
- title: e(v)("inventory.transfer.template.title2"),
1426
- actions: O.value,
1427
- "onClick:action": i
1428
- }, {
1429
- default: B(() => {
1430
- var W;
1431
- return [
1432
- o("div", {
1433
- class: ae([
1434
- "flex flex-col gap-8 max-h-full",
1435
- {
1436
- "p-0": d.value,
1437
- "px-24 ": !d.value
1438
- }
1439
- ])
1440
- }, [
1441
- m(gt, {
1442
- searchable: "",
1443
- search: c.value,
1444
- "onUpdate:search": C[0] || (C[0] = (N) => c.value = N)
1445
- }, null, 8, ["search"]),
1446
- (F(), te(J, {
1447
- style: He(e($).tableHeight),
1448
- "column-defs": e(u).columnDefs,
1449
- "row-data": h.value,
1450
- "search-value": c.value,
1451
- loading: S.value,
1452
- key: (W = e(R)._currentLocation) == null ? void 0 : W.dbName,
1453
- onRowClick: C[1] || (C[1] = (N) => e(t)(N.original)),
1454
- "page-size": x.value
1455
- }, {
1456
- "list-row": B((N) => [
1457
- m(Ze, {
1458
- row: N,
1459
- onRowClick: (L) => e(t)(L)
1460
- }, {
1461
- default: B((L) => {
1462
- var I, s, r, k, P, z, H, V, U, Z, ee, le, T, Q, pe, Fe, Ce, Ie, Se, $e, ce, Me, Oe, Ve, De, fe, Re;
1463
- return [
1464
- o("div", ul, [
1465
- o("div", dl, [
1466
- o("div", ml, [
1467
- m(e(Y), {
1468
- render: (r = (s = (I = L._id) == null ? void 0 : I.column) == null ? void 0 : s.columnDef) == null ? void 0 : r.cell,
1469
- props: (P = (k = L._id) == null ? void 0 : k.getContext) == null ? void 0 : P.call(k)
1470
- }, null, 8, ["render", "props"])
1471
- ]),
1472
- o("div", pl, [
1473
- m(e(Y), {
1474
- render: (V = (H = (z = L.name) == null ? void 0 : z.column) == null ? void 0 : H.columnDef) == null ? void 0 : V.cell,
1475
- props: (Z = (U = L.name) == null ? void 0 : U.getContext) == null ? void 0 : Z.call(U)
1476
- }, null, 8, ["render", "props"])
1477
- ]),
1478
- o("div", cl, [
1479
- m(e(Y), {
1480
- render: (T = (le = (ee = L.supplier) == null ? void 0 : ee.column) == null ? void 0 : le.columnDef) == null ? void 0 : T.cell,
1481
- props: (pe = (Q = L.supplier) == null ? void 0 : Q.getContext) == null ? void 0 : pe.call(Q)
1482
- }, null, 8, ["render", "props"])
1483
- ]),
1484
- o("div", null, D((Fe = N.original.locations) != null && Fe.length ? `Enabled for ${(Ce = N.original.locations) == null ? void 0 : Ce.length} outlets` : "Enabled for all outlets"), 1),
1485
- o("div", fl, D(N.original.purchaseOrder.items.length ? N.original.purchaseOrder.items.map((et) => et.name).join(", ") : "No items"), 1),
1486
- o("div", yl, [
1487
- m(e(Y), {
1488
- render: ($e = (Se = (Ie = L.ref) == null ? void 0 : Ie.column) == null ? void 0 : Se.columnDef) == null ? void 0 : $e.cell,
1489
- props: (Me = (ce = L.ref) == null ? void 0 : ce.getContext) == null ? void 0 : Me.call(ce)
1490
- }, null, 8, ["render", "props"])
1491
- ])
1492
- ]),
1493
- o("div", null, [
1494
- m(e(Y), {
1495
- render: (De = (Ve = (Oe = L.type) == null ? void 0 : Oe.column) == null ? void 0 : Ve.columnDef) == null ? void 0 : De.cell,
1496
- props: (Re = (fe = L.type) == null ? void 0 : fe.getContext) == null ? void 0 : Re.call(fe)
1497
- }, null, 8, ["render", "props"])
1498
- ])
1499
- ])
1500
- ];
1501
- }),
1502
- _: 2
1503
- }, 1032, ["row", "onRowClick"])
1504
- ]),
1505
- _: 1
1506
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1507
- ], 2)
1508
- ];
1509
- }),
1510
- _: 1
1511
- }, 8, ["title", "actions"]),
1512
- (F(), te(st, { to: "body" }, [
1513
- m(il, nt(at(e(l))), null, 16),
1514
- m(Io, Qe(e(a), {
1515
- onSubmitted: C[2] || (C[2] = (W) => e(u).fetchTemplates())
1516
- }), null, 16)
1517
- ]))
1518
- ], 64);
1519
- };
1520
- }
1521
- });
1522
- export {
1523
- Il as default
1524
- };