@feedmepos/mf-inventory-portal 0.0.20-dev.1 → 0.0.21-dev.1

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