@feedmepos/mf-inventory-portal 0.0.19-dev.6 → 0.0.19-dev.9

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/{ApprovalView-CzKLgsJ9.js → ApprovalView-Bcxk6B7K.js} +5 -5
  2. package/dist/{BindingsDialog-D7CWodmi.js → BindingsDialog-XDkcjW_c.js} +6 -6
  3. package/dist/{BindingsPicker-Dxavpg09.js → BindingsPicker-CgbiqX72.js} +6 -6
  4. package/dist/{BindingsTable-BQEyLG4F.js → BindingsTable-xNXNsBAd.js} +1 -1
  5. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-4EAZjYHf.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DFPkUHl-.js} +1 -1
  6. package/dist/{IngredientsView-DLeVfaAy.js → IngredientsView-DD7ns3mP.js} +4 -4
  7. package/dist/{IntegrationView-CZTl4lcU.js → IntegrationView-CErHEVAO.js} +2 -2
  8. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CEhOhALE.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-XXoPyhlc.js} +1 -1
  9. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CCD2yMHJ.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BpyUheXn.js} +1 -1
  10. package/dist/{PurchaseOrderPrintPreview-pVhvi2XF.js → PurchaseOrderPrintPreview-L_iaaURb.js} +1 -1
  11. package/dist/{ReceiveRequestView-CzsOfdV4.js → ReceiveRequestView-BKbeFDxm.js} +7 -7
  12. package/dist/{RecipeView-DsTG2guX.js → RecipeView-Drp4l4gL.js} +4 -4
  13. package/dist/{StockView-ruZ30kOE.js → StockView-Cj6fErwD.js} +7 -7
  14. package/dist/{SupplierView-BT9IfLzB.js → SupplierView-EFsHWet-.js} +4 -4
  15. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-BUArpD4v.js → TransferDetails.vue_vue_type_script_setup_true_lang-kM5fyqq6.js} +4 -4
  16. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-CyFMCmXw.js +1605 -0
  17. package/dist/TransferTemplateView-Cymhrayh.js +933 -0
  18. package/dist/{UnitView-sSGMkQo5.js → UnitView-C_tAxIpq.js} +5 -5
  19. package/dist/{WarehouseView-B2ueU0Oq.js → WarehouseView-BAqVtbD6.js} +3 -3
  20. package/dist/{app-D8_IIKxj.js → app-CeUU5Gd8.js} +139 -138
  21. package/dist/app.d.ts +3 -1
  22. package/dist/app.js +1 -1
  23. package/dist/{decimal-BbpHeqMX.js → decimal-D3KXLC4T.js} +1 -1
  24. package/dist/{id-to-date-DNUSJ_a1.js → id-to-date-Cj02m808.js} +1 -1
  25. package/dist/{layout-D-dTwEwF.js → layout-2zzAZIVO.js} +1 -1
  26. package/dist/{purchase-order-transaction-type-M-fz1Vrz.js → purchase-order-transaction-type-Dz0YF5qh.js} +3 -4
  27. package/dist/style.css +1 -1
  28. package/dist/{supplier-tz4ui5Tz.js → supplier-mDVKd7Ge.js} +1 -1
  29. package/dist/tsconfig.app.tsbuildinfo +1 -1
  30. package/dist/views/receive-request/components/transfer-form/TransferForm2.vue.d.ts +16 -0
  31. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -1
  32. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +187 -0
  33. package/dist/views/receive-request/components/transfer-form/components/TransferItem.vue.d.ts +23 -0
  34. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +21 -0
  35. package/dist/views/receive-request/components/transfer-form/composables/use-backdate-po.d.ts +9 -0
  36. package/dist/views/receive-request/components/transfer-form/composables/use-compare-price.d.ts +6 -0
  37. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +111 -0
  38. package/dist/views/receive-request/helper/get-transfer-type.d.ts +2 -0
  39. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -1
  40. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +1 -0
  41. package/dist/{xlsx-CjvXXGPi.js → xlsx-B-2KyDJq.js} +1 -1
  42. package/dist/{xlsx.util-CTgyjOr7.js → xlsx.util-D6EzRE71.js} +2 -2
  43. package/package.json +3 -3
  44. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DqaAbttB.js +0 -1269
  45. package/dist/TransferTemplateView-CXafUQyI.js +0 -1130
@@ -0,0 +1,933 @@
1
+ import { reactive as Re, onMounted as $e, computed as R, h as T, defineComponent as ne, resolveComponent as I, openBlock as P, createElementBlock as we, createElementVNode as n, toDisplayString as re, createVNode as m, unref as o, withCtx as $, watch as Se, ref as Q, createBlock as j, isRef as Pe, Fragment as Ee, normalizeStyle as Ue, Teleport as Me, mergeProps as _e } from "vue";
2
+ import { _ as Be, a as Ne } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DFPkUHl-.js";
3
+ import { useI18n as oe } from "@feedmepos/mf-common";
4
+ import { c as te, d as Le, u as ze, a as qe, b as he, e as He, _ as je } from "./TransferDialog.vue_vue_type_script_setup_true_lang-CyFMCmXw.js";
5
+ import { F as ee, R as be } from "./row-action.enum-7jVyol1k.js";
6
+ import { D as ge, R as ie, $ as Ce, a0 as Qe, a as se, r as xe, a1 as Ke, l as Te, A as ue, M as ke, G as Ye, a2 as Ge, a3 as Ae, b as Je, u as We, j as Fe, y as Xe, a4 as Ze } from "./app-CeUU5Gd8.js";
7
+ import { F, _ as Oe, u as et } from "./layout-2zzAZIVO.js";
8
+ import { useBreakpoints as De, components as H, FmButtonVariant as tt, useDialog as ot, useSnackbar as at, useProxiedModel as lt } from "@feedmepos/ui-library";
9
+ import { storeToRefs as st } from "pinia";
10
+ import { P as A } from "./purchase-order-transaction-type-Dz0YF5qh.js";
11
+ import { _ as Ve } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-BpyUheXn.js";
12
+ import { useRouter as rt } from "vue-router";
13
+ import { u as nt } from "./supplier-mDVKd7Ge.js";
14
+ var g = /* @__PURE__ */ ((u) => (u.Code = "Code", u.Name = "Name", u.DefaultAmount = "DefaultAmount", u.MinimumAmount = "MinimumAmount", u.Step = "Step", u.Cost = "Cost", u.Delete = "Delete", u))(g || {});
15
+ const it = () => {
16
+ const { t: u } = oe();
17
+ return T(
18
+ Ve,
19
+ {
20
+ zIndex: 50,
21
+ class: "whitespace-nowrap"
22
+ },
23
+ u("inventory.transfer.form.items.table.Cost", [Ae()])
24
+ );
25
+ };
26
+ function ut(u) {
27
+ const { t: v } = oe(), p = Re({}), { breakpoints: s } = De();
28
+ $e(() => {
29
+ for (const i of u.items) {
30
+ if (!i.totalCost)
31
+ continue;
32
+ const t = te(i.sku, i.quantity, i.measurement, {
33
+ supplier: u.supplier
34
+ }), r = i.totalCost ?? ge.reset();
35
+ t ? p[i.sku._id] = t.amount !== r.amount || t.precision !== r.precision : p[i.sku._id] = !0;
36
+ }
37
+ });
38
+ function y(i) {
39
+ var r, _;
40
+ return !!(i.defaultCost ?? ((_ = (r = u.supplier) == null ? void 0 : r.supplyItems) == null ? void 0 : _.find((h) => h.skuId === i._id)));
41
+ }
42
+ const w = [
43
+ {
44
+ id: "Code",
45
+ header: () => v("inventory.transfer.form.items.table.Code"),
46
+ accessorKey: "code",
47
+ size: 96,
48
+ cell(i) {
49
+ const t = i.row.original;
50
+ return T(H.FmTextField, {
51
+ modelValue: t.code,
52
+ "onUpdate:modelValue": (r) => {
53
+ u.updateItem({
54
+ ...t,
55
+ code: r
56
+ });
57
+ },
58
+ key: t.sku._id,
59
+ rules: [ie()],
60
+ labelMark: "required"
61
+ });
62
+ },
63
+ enableSorting: !1
64
+ },
65
+ {
66
+ id: "Name",
67
+ header: () => v("inventory.transfer.form.items.table.Name"),
68
+ minSize: 300,
69
+ cell(i) {
70
+ const t = i.row.original;
71
+ return T(H.FmTextField, {
72
+ modelValue: t.name,
73
+ "onUpdate:modelValue": (r) => {
74
+ u.updateItem({
75
+ ...t,
76
+ name: r
77
+ });
78
+ },
79
+ key: t.sku._id,
80
+ rules: [ie()],
81
+ labelMark: "required"
82
+ });
83
+ },
84
+ enableSorting: !1
85
+ },
86
+ {
87
+ id: "DefaultAmount",
88
+ header: () => v("inventory.transfer.form.items.table.DefaultAmount2"),
89
+ minSize: 150,
90
+ cell(i) {
91
+ const t = i.row.original;
92
+ return T(Ce, {
93
+ style: {
94
+ flex: "1 1 0%"
95
+ },
96
+ modelValue: {
97
+ amount: t.quantity ?? { amount: 1, precision: 0 },
98
+ measurement: t.measurement ?? null
99
+ },
100
+ key: t.sku._id,
101
+ unit: t.sku.unit,
102
+ "onUpdate:modelValue": (r) => {
103
+ u.updateItem({
104
+ ...t,
105
+ quantity: r.amount,
106
+ measurement: r.measurement
107
+ });
108
+ },
109
+ rules: [
110
+ Qe(
111
+ +se(
112
+ t.minimumQuantity ?? {
113
+ amount: 1,
114
+ precision: xe(t.sku.unit, t.measurement)
115
+ }
116
+ )
117
+ )
118
+ ],
119
+ applyDefaultRules: !0
120
+ });
121
+ },
122
+ enableSorting: !1
123
+ },
124
+ {
125
+ id: "MinimumAmount",
126
+ header: () => v("inventory.transfer.form.items.table.MinimumAmount2"),
127
+ minSize: 124,
128
+ cell(i) {
129
+ const t = i.row.original;
130
+ return T(Ce, {
131
+ style: {
132
+ flex: "1 1 0%"
133
+ },
134
+ modelValue: {
135
+ amount: t.minimumQuantity ?? {
136
+ amount: 1,
137
+ precision: xe(t.sku.unit, t.measurement)
138
+ },
139
+ measurement: t.measurement ?? null
140
+ },
141
+ key: t.sku._id,
142
+ unit: t.sku.unit,
143
+ "onUpdate:modelValue": (r) => {
144
+ u.updateItem({
145
+ ...t,
146
+ minimumQuantity: r.amount
147
+ });
148
+ },
149
+ rules: [Ke(0)],
150
+ disableUnit: !0,
151
+ applyDefaultRules: !0
152
+ });
153
+ },
154
+ enableSorting: !1
155
+ },
156
+ {
157
+ id: "Step",
158
+ header: () => v("inventory.transfer.form.items.table.Step"),
159
+ minSize: 100,
160
+ cell(i) {
161
+ const t = i.row.original;
162
+ return T(H.FmTextField, {
163
+ modelValue: se(t.quantityStep ?? ge.reset(), !1),
164
+ key: t.sku._id,
165
+ "onUpdate:modelValue": (r) => {
166
+ u.updateItem({
167
+ ...t,
168
+ quantityStep: Te(+r)
169
+ });
170
+ },
171
+ rules: [ue(0), ke(t.sku.unit, t.measurement)]
172
+ });
173
+ },
174
+ enableSorting: !1
175
+ },
176
+ {
177
+ id: "Cost",
178
+ header: it,
179
+ size: 180,
180
+ cell(i) {
181
+ const t = i.row.original, r = y(t.sku), _ = s.value.xs || s.value.sm;
182
+ return !p[t.sku._id] && r ? T(
183
+ "div",
184
+ {
185
+ class: "flex gap-4 fm-typo-en-body-md-400 items-center",
186
+ key: t.sku._id
187
+ },
188
+ [
189
+ T(H.FmButton, {
190
+ prependIcon: "edit",
191
+ variant: tt.Tertiary,
192
+ onClick() {
193
+ u.updateItem({
194
+ ...t,
195
+ totalCost: te(t.sku, t.quantity, t.measurement, {
196
+ supplier: u.supplier
197
+ })
198
+ }), p[t.sku._id] = !0;
199
+ }
200
+ }),
201
+ T(
202
+ "div",
203
+ {
204
+ class: "flex flex-col"
205
+ },
206
+ [
207
+ T(
208
+ "span",
209
+ _ ? Ye(
210
+ te(t.sku, t.quantity, t.measurement, {
211
+ supplier: u.supplier
212
+ })
213
+ ) : se(
214
+ te(t.sku, t.quantity, t.measurement, {
215
+ supplier: u.supplier
216
+ })
217
+ )
218
+ ),
219
+ T(
220
+ "span",
221
+ {
222
+ class: "fm-typo-en-body-sm-400 text-fm-color-neutral-gray-400"
223
+ },
224
+ "Auto-calculated"
225
+ )
226
+ ]
227
+ )
228
+ ]
229
+ ) : T(
230
+ H.FmTextField,
231
+ {
232
+ modelValue: se(t.totalCost ?? { amount: 0, precision: 0 }),
233
+ key: t.sku._id,
234
+ "onUpdate:modelValue": (h) => {
235
+ u.updateItem({
236
+ ...t,
237
+ totalCost: {
238
+ ...Te(+h),
239
+ currency: Ge()
240
+ }
241
+ });
242
+ },
243
+ rules: [ue(0), ke(2)]
244
+ },
245
+ {
246
+ prepend() {
247
+ return _ ? T("div", { class: "text-fm-typo-en-body-lg-400" }, Ae()) : null;
248
+ },
249
+ append() {
250
+ return r ? T(H.FmButton, {
251
+ prependIcon: "close",
252
+ variant: "tertiary",
253
+ onClick() {
254
+ u.updateItem({
255
+ ...t,
256
+ totalCost: null
257
+ }), p[t.sku._id] = !1;
258
+ }
259
+ }) : null;
260
+ }
261
+ }
262
+ );
263
+ },
264
+ enableSorting: !1
265
+ },
266
+ {
267
+ id: "Delete",
268
+ header: "",
269
+ cell(i) {
270
+ const t = i.row.original;
271
+ return T(H.FmButton, {
272
+ class: "delete-button",
273
+ key: t.sku._id,
274
+ type: "button",
275
+ icon: "delete",
276
+ variant: "tertiary",
277
+ size: "md",
278
+ onClick: () => {
279
+ u.deleteItem(t);
280
+ }
281
+ });
282
+ },
283
+ enableSorting: !1,
284
+ size: 40,
285
+ meta: {
286
+ cellClass: "",
287
+ headerClass: ""
288
+ }
289
+ }
290
+ ];
291
+ return {
292
+ columnDefs: R(() => Je().enableTotalCost && u.transferType === A.PURCHASE ? w : w.filter((t) => t.id !== "Cost"))
293
+ };
294
+ }
295
+ const mt = { class: "flex flex-col gap-8 py-16" }, dt = { class: "flex items-center" }, pt = { class: "flex-1 flex gap-1 items-center" }, ct = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ft = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, yt = { class: "flex gap-8 w-full" }, vt = { class: "flex-1 flex flex-col gap-4" }, _t = /* @__PURE__ */ n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), ht = { class: "flex-1 flex flex-col gap-4" }, bt = /* @__PURE__ */ n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), gt = { class: "flex gap-8 w-full" }, Ct = { class: "flex-1 flex flex-col gap-4" }, xt = /* @__PURE__ */ n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), Tt = { class: "flex-1 flex flex-col gap-4" }, kt = /* @__PURE__ */ n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), wt = { class: "flex gap-8 w-full" }, St = { class: "flex-1 flex flex-col gap-4" }, At = /* @__PURE__ */ n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), Ft = { class: "flex-1 flex flex-col gap-4" }, Ot = /* @__PURE__ */ n("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), Dt = /* @__PURE__ */ ne({
296
+ __name: "TransferTemplateItem",
297
+ props: {
298
+ cellByColId: {},
299
+ row: {}
300
+ },
301
+ setup(u) {
302
+ const { t: v } = oe();
303
+ return (p, s) => {
304
+ var w, C, i, t, r, _, h, O, x, D, E, U, M, a, e, l, c, b, d, S, k, f, V, B, K, Y, G, N, L, J, W, X, z, q, Z;
305
+ const y = I("FmLabel");
306
+ return P(), we("div", mt, [
307
+ n("div", dt, [
308
+ n("div", pt, [
309
+ n("span", ct, " (" + re(p.row.original.sku.code) + ") ", 1),
310
+ n("span", ft, re(p.row.original.sku.name), 1)
311
+ ]),
312
+ n("div", null, [
313
+ m(o(F), {
314
+ render: (i = (C = (w = p.cellByColId.Delete) == null ? void 0 : w.column) == null ? void 0 : C.columnDef) == null ? void 0 : i.cell,
315
+ props: (r = (t = p.cellByColId.Delete) == null ? void 0 : t.getContext) == null ? void 0 : r.call(t)
316
+ }, null, 8, ["render", "props"])
317
+ ])
318
+ ]),
319
+ n("div", yt, [
320
+ n("div", vt, [
321
+ m(y, {
322
+ label: o(v)(`inventory.transfer.form.items.table.${o(g).Code}`)
323
+ }, null, 8, ["label"]),
324
+ m(o(F), {
325
+ render: (O = (h = (_ = p.cellByColId[o(g).Code]) == null ? void 0 : _.column) == null ? void 0 : h.columnDef) == null ? void 0 : O.cell,
326
+ props: (D = (x = p.cellByColId[o(g).Code]) == null ? void 0 : x.getContext) == null ? void 0 : D.call(x)
327
+ }, null, 8, ["render", "props"]),
328
+ _t
329
+ ]),
330
+ n("div", ht, [
331
+ m(y, {
332
+ label: o(v)(`inventory.transfer.form.items.table.${o(g).Name}`)
333
+ }, null, 8, ["label"]),
334
+ m(o(F), {
335
+ render: (M = (U = (E = p.cellByColId[o(g).Name]) == null ? void 0 : E.column) == null ? void 0 : U.columnDef) == null ? void 0 : M.cell,
336
+ props: (e = (a = p.cellByColId[o(g).Name]) == null ? void 0 : a.getContext) == null ? void 0 : e.call(a)
337
+ }, null, 8, ["render", "props"]),
338
+ bt
339
+ ])
340
+ ]),
341
+ n("div", gt, [
342
+ n("div", Ct, [
343
+ m(y, {
344
+ label: o(v)(`inventory.transfer.form.items.table.${o(g).MinimumAmount}`)
345
+ }, null, 8, ["label"]),
346
+ m(o(F), {
347
+ render: (b = (c = (l = p.cellByColId[o(g).MinimumAmount]) == null ? void 0 : l.column) == null ? void 0 : c.columnDef) == null ? void 0 : b.cell,
348
+ props: (S = (d = p.cellByColId[o(g).MinimumAmount]) == null ? void 0 : d.getContext) == null ? void 0 : S.call(d)
349
+ }, null, 8, ["render", "props"]),
350
+ xt
351
+ ]),
352
+ n("div", Tt, [
353
+ m(y, {
354
+ label: o(v)(`inventory.transfer.form.items.table.${o(g).Step}`)
355
+ }, null, 8, ["label"]),
356
+ m(o(F), {
357
+ render: (V = (f = (k = p.cellByColId[o(g).Step]) == null ? void 0 : k.column) == null ? void 0 : f.columnDef) == null ? void 0 : V.cell,
358
+ props: (K = (B = p.cellByColId[o(g).Step]) == null ? void 0 : B.getContext) == null ? void 0 : K.call(B)
359
+ }, null, 8, ["render", "props"]),
360
+ kt
361
+ ])
362
+ ]),
363
+ n("div", wt, [
364
+ n("div", St, [
365
+ m(y, {
366
+ label: o(v)(`inventory.transfer.form.items.table.${o(g).DefaultAmount}`)
367
+ }, null, 8, ["label"]),
368
+ m(o(F), {
369
+ render: (N = (G = (Y = p.cellByColId[o(g).DefaultAmount]) == null ? void 0 : Y.column) == null ? void 0 : G.columnDef) == null ? void 0 : N.cell,
370
+ props: (J = (L = p.cellByColId[o(g).DefaultAmount]) == null ? void 0 : L.getContext) == null ? void 0 : J.call(L)
371
+ }, null, 8, ["render", "props"]),
372
+ At
373
+ ]),
374
+ n("div", Ft, [
375
+ m(Ve, { "z-index": 50 }, {
376
+ default: $(() => [
377
+ m(y, {
378
+ label: o(v)(`inventory.transfer.form.items.table.${o(g).Cost}2`)
379
+ }, null, 8, ["label"])
380
+ ]),
381
+ _: 1
382
+ }),
383
+ m(o(F), {
384
+ render: (z = (X = (W = p.cellByColId[o(g).Cost]) == null ? void 0 : W.column) == null ? void 0 : X.columnDef) == null ? void 0 : z.cell,
385
+ props: (Z = (q = p.cellByColId[o(g).Cost]) == null ? void 0 : q.getContext) == null ? void 0 : Z.call(q)
386
+ }, null, 8, ["render", "props"]),
387
+ Ot
388
+ ])
389
+ ])
390
+ ]);
391
+ };
392
+ }
393
+ }), Vt = { class: "flex flex-col gap-16" }, It = { class: "flex flex-col gap-24" }, Rt = { class: "flex flex-col gap-16" }, $t = { class: "flex" }, Pt = /* @__PURE__ */ n("div", { class: "flex-1 gap-8 fm-typo-en-title-sm-800" }, "Transfer items", -1), Et = /* @__PURE__ */ ne({
394
+ __name: "TransferTemplateForm",
395
+ props: {
396
+ modelValue: {},
397
+ disabled: { type: Boolean }
398
+ },
399
+ setup(u, { expose: v }) {
400
+ const p = u, s = Le(), { t: y } = oe(), w = Fe(), C = We(), i = nt();
401
+ Se(
402
+ () => p.modelValue,
403
+ (a) => {
404
+ console.log("TransferTemplateForm.model", a);
405
+ }
406
+ ), w.watchLocation(async () => {
407
+ location && (s.purchaseOrder.supplier || (s.purchaseOrder.supplier = i.suppliers.find((a) => a) ?? s.purchaseOrder.supplier));
408
+ });
409
+ const t = ot(), r = ze(
410
+ () => s.purchaseOrder,
411
+ (a) => {
412
+ s.purchaseOrder = {
413
+ ...s.purchaseOrder,
414
+ ...a
415
+ };
416
+ }
417
+ ), _ = R({
418
+ get() {
419
+ var a, e;
420
+ return typeof ((e = (a = s.purchaseOrder) == null ? void 0 : a.supplier) == null ? void 0 : e.internal) == "string" ? A.TRANSFER : A.PURCHASE;
421
+ },
422
+ set(a) {
423
+ var l, c;
424
+ const e = typeof ((c = (l = s.purchaseOrder) == null ? void 0 : l.supplier) == null ? void 0 : c.internal) == "string" ? A.TRANSFER : A.PURCHASE;
425
+ a !== e && (s.purchaseOrder.supplier = a === A.PURCHASE ? r.locationOptionsTypePurchase.value[0] : r.locationOptionsTypeTransfer.value[0]);
426
+ }
427
+ }), h = R(() => r.transferLocationOptions.value), O = R({
428
+ get() {
429
+ return s.purchaseOrder.supplier._id;
430
+ },
431
+ set(a) {
432
+ r.transferLocationModel.value = a;
433
+ }
434
+ }), x = R({
435
+ get() {
436
+ return s.purchaseOrder.remark ?? void 0;
437
+ },
438
+ set(a) {
439
+ s.purchaseOrder.remark = a;
440
+ }
441
+ }), D = Q();
442
+ v({
443
+ validateInputs: () => {
444
+ var a, e;
445
+ (e = (a = D.value) == null ? void 0 : a.validateInputs) == null || e.call(a);
446
+ },
447
+ resetInputsValidation: () => {
448
+ var a, e;
449
+ (e = (a = D.value) == null ? void 0 : a.resetInputsValidation) == null || e.call(a);
450
+ },
451
+ resetInputs: () => {
452
+ var a, e;
453
+ (e = (a = D.value) == null ? void 0 : a.resetInputs) == null || e.call(a);
454
+ }
455
+ });
456
+ const E = ut({
457
+ updateItem: (a) => {
458
+ s.purchaseOrder.items = s.purchaseOrder.items.map((e) => e.sku._id !== a.sku._id ? e : a);
459
+ },
460
+ deleteItem: (a) => {
461
+ s.purchaseOrder.items = s.purchaseOrder.items.filter(
462
+ (e) => e.sku._id !== a.sku._id
463
+ );
464
+ },
465
+ get supplier() {
466
+ return s.purchaseOrder.supplier;
467
+ },
468
+ get items() {
469
+ return s.purchaseOrder.items;
470
+ },
471
+ get transferType() {
472
+ return _.value;
473
+ }
474
+ }), U = R(() => E.columnDefs.value);
475
+ function M() {
476
+ const a = C.skus.map((l) => ({
477
+ label: l.name,
478
+ sublabel: l.code,
479
+ value: l
480
+ })), e = a.filter((l) => {
481
+ var c;
482
+ return (c = s.purchaseOrder.items) == null ? void 0 : c.find((b) => b.sku._id === l.value._id);
483
+ }).map((l) => l.value);
484
+ t.open({
485
+ title: "Select item",
486
+ closeButton: !0,
487
+ contentComponent: Xe,
488
+ contentComponentProps: {
489
+ modelValue: e,
490
+ items: a
491
+ },
492
+ primaryActions: {
493
+ text: "Confirm",
494
+ close: !0
495
+ },
496
+ secondaryActions: {
497
+ text: "Close",
498
+ close: !0,
499
+ variant: "tertiary"
500
+ }
501
+ }).onPrimary((l) => {
502
+ const c = s.purchaseOrder.items ?? [], b = l.map((d) => {
503
+ const S = c.find((f) => f.sku._id === d._id);
504
+ if (S)
505
+ return S;
506
+ const k = {
507
+ sku: d,
508
+ code: d.code,
509
+ name: d.name,
510
+ quantity: {
511
+ amount: 1,
512
+ precision: 0
513
+ }
514
+ };
515
+ return _.value == A.PURCHASE && (k.totalCost = te(
516
+ k.sku,
517
+ k.quantity,
518
+ k.measurement,
519
+ {
520
+ supplier: s.purchaseOrder.supplier
521
+ }
522
+ )), k;
523
+ });
524
+ b.sort((d, S) => d.sku.code.localeCompare(S.sku.code)), s.purchaseOrder.items = b;
525
+ });
526
+ }
527
+ return (a, e) => {
528
+ const l = I("FmTextField"), c = I("FmSelect"), b = I("FmTextarea"), d = I("FmButton"), S = I("FmTable"), k = I("FmForm");
529
+ return P(), j(k, {
530
+ ref_key: "formRef",
531
+ ref: D,
532
+ class: "flex flex-col gap-32"
533
+ }, {
534
+ default: $(() => [
535
+ n("div", Vt, [
536
+ n("div", It, [
537
+ m(l, {
538
+ label: o(y)("inventory.transfer.form.name"),
539
+ "label-mark": "required",
540
+ modelValue: o(s).name,
541
+ "onUpdate:modelValue": e[0] || (e[0] = (f) => o(s).name = f),
542
+ rules: [o(ie)()]
543
+ }, null, 8, ["label", "modelValue", "rules"]),
544
+ m(c, {
545
+ label: o(y)("inventory.transfer.form.type.title"),
546
+ "model-value": _.value,
547
+ "onUpdate:modelValue": e[1] || (e[1] = (f) => _.value = f),
548
+ items: [
549
+ {
550
+ label: o(y)(
551
+ `inventory.transfer.form.type.${o(A).PURCHASE.toLocaleLowerCase()}`
552
+ ),
553
+ value: o(A).PURCHASE,
554
+ disabled: !o(r).locationOptionsTypePurchase.value.length,
555
+ sublabel: o(r).locationOptionsTypePurchase.value.length ? void 0 : "No supplier available"
556
+ },
557
+ {
558
+ label: o(y)(
559
+ `inventory.transfer.form.type.${o(A).TRANSFER.toLocaleLowerCase()}`
560
+ ),
561
+ value: o(A).TRANSFER,
562
+ disabled: !o(r).locationOptionsTypeTransfer.value.length,
563
+ sublabel: o(r).locationOptionsTypeTransfer.value.length ? void 0 : "No location available"
564
+ }
565
+ ],
566
+ rules: [o(ue)(1)(h.value)]
567
+ }, null, 8, ["label", "model-value", "items", "rules"]),
568
+ m(c, {
569
+ label: _.value === o(A).PURCHASE ? "Purchase from" : "Transfer from",
570
+ modelValue: O.value,
571
+ "onUpdate:modelValue": e[2] || (e[2] = (f) => O.value = f),
572
+ items: h.value
573
+ }, null, 8, ["label", "modelValue", "items"]),
574
+ m(l, {
575
+ label: "Reference",
576
+ "label-mark": "optional",
577
+ modelValue: o(s).purchaseOrder.ref,
578
+ "onUpdate:modelValue": e[3] || (e[3] = (f) => o(s).purchaseOrder.ref = f)
579
+ }, null, 8, ["modelValue"]),
580
+ m(b, {
581
+ label: "Remark",
582
+ "label-mark": "optional",
583
+ "max-length": 240,
584
+ modelValue: x.value,
585
+ "onUpdate:modelValue": e[4] || (e[4] = (f) => x.value = f)
586
+ }, null, 8, ["modelValue"])
587
+ ])
588
+ ]),
589
+ n("div", Rt, [
590
+ n("div", $t, [
591
+ Pt,
592
+ m(d, {
593
+ disabled: a.disabled,
594
+ label: "Add Item",
595
+ "prepend-icon": "add",
596
+ variant: "plain",
597
+ class: "border-2 rounded-lg border-fm-color-primary",
598
+ onClick: e[5] || (e[5] = (f) => M()),
599
+ size: "md"
600
+ }, null, 8, ["disabled"])
601
+ ]),
602
+ (P(), j(S, {
603
+ "column-defs": U.value,
604
+ "row-data": o(s).purchaseOrder.items,
605
+ key: o(s).purchaseOrder.items.map((f) => f.sku._id).join("."),
606
+ "hide-footer": ""
607
+ }, {
608
+ "list-row": $((f) => [
609
+ (P(), j(Oe, {
610
+ row: f,
611
+ key: o(s).purchaseOrder.items.map((V) => V.sku._id).join(".")
612
+ }, {
613
+ default: $((V) => [
614
+ m(Dt, {
615
+ row: f,
616
+ "cell-by-col-id": V
617
+ }, null, 8, ["row", "cell-by-col-id"])
618
+ ]),
619
+ _: 2
620
+ }, 1032, ["row"]))
621
+ ]),
622
+ _: 1
623
+ }, 8, ["column-defs", "row-data"]))
624
+ ])
625
+ ]),
626
+ _: 1
627
+ }, 512);
628
+ };
629
+ }
630
+ }), Ut = { class: "flex items-center" }, Mt = { class: "fm-typo-en-title-md-800" }, Bt = { class: "flex gap-4" }, Nt = /* @__PURE__ */ ne({
631
+ __name: "TransferTemplateDialog",
632
+ props: {
633
+ mode: {},
634
+ modelValue: {},
635
+ show: { type: Boolean }
636
+ },
637
+ emits: ["update:show", "submitted"],
638
+ setup(u, { expose: v, emit: p }) {
639
+ var a;
640
+ const s = u, y = p, w = qe(), C = at(), i = lt(s, "show");
641
+ function t() {
642
+ return {
643
+ _id: "",
644
+ name: "",
645
+ purchaseOrder: {
646
+ remark: void 0,
647
+ ref: void 0,
648
+ stockSnapshotId: void 0,
649
+ effectiveAt: void 0,
650
+ items: [],
651
+ supplier: {
652
+ _rev: void 0,
653
+ email: void 0,
654
+ internal: void 0,
655
+ contactName: void 0,
656
+ phoneNumber: void 0,
657
+ registrationNumber: void 0,
658
+ supplyItems: void 0,
659
+ _id: "",
660
+ name: "",
661
+ address: {
662
+ line2: void 0,
663
+ line1: "",
664
+ state: "",
665
+ city: "",
666
+ postcode: "",
667
+ country: ""
668
+ }
669
+ }
670
+ }
671
+ };
672
+ }
673
+ const r = Q(s.modelValue ?? t()), _ = Q(((a = s.modelValue) == null ? void 0 : a._id) ?? `${Math.random()}`);
674
+ Se(
675
+ () => s.show,
676
+ (e) => {
677
+ var l;
678
+ e && (r.value = s.modelValue ?? t(), _.value = ((l = s.modelValue) == null ? void 0 : l._id) ?? `${Math.random()}`);
679
+ }
680
+ );
681
+ const h = Q(!1), O = R(() => {
682
+ switch (s.mode) {
683
+ case ee.READ:
684
+ return "View template";
685
+ case ee.CREATE:
686
+ return "Add template";
687
+ case ee.UPDATE:
688
+ return "Edit template";
689
+ }
690
+ return "";
691
+ }), x = Q();
692
+ v({
693
+ validateInputs: () => {
694
+ var e, l;
695
+ (l = (e = x.value) == null ? void 0 : e.validateInputs) == null || l.call(e);
696
+ },
697
+ resetInputsValidation: () => {
698
+ var e, l;
699
+ (l = (e = x.value) == null ? void 0 : e.resetInputsValidation) == null || l.call(e);
700
+ },
701
+ resetInputs: () => {
702
+ var e, l;
703
+ (l = (e = x.value) == null ? void 0 : e.resetInputs) == null || l.call(e);
704
+ }
705
+ });
706
+ async function D() {
707
+ const e = r.value;
708
+ if (e) {
709
+ h.value = !0, (e.purchaseOrder.supplier.internal === "warehouse" || e.purchaseOrder.supplier.internal === "restaurant") && (e.purchaseOrder.items = e.purchaseOrder.items.map(
710
+ ({ totalCost: l, ...c }) => c
711
+ ));
712
+ try {
713
+ await w.createTemplate(e), await new Promise((l) => setTimeout(l, 1e3)), C.open({
714
+ title: "Created",
715
+ message: "Your transfer template has been created!",
716
+ type: "success"
717
+ }), y("update:show", !1), y("submitted");
718
+ } catch (l) {
719
+ C.open({
720
+ title: "Cannot create transfer template",
721
+ message: "Report to system administrator for troubleshooting.",
722
+ type: "error"
723
+ }), console.error("Error in creating transfer template", l);
724
+ } finally {
725
+ h.value = !1;
726
+ }
727
+ }
728
+ }
729
+ async function E() {
730
+ const e = r.value;
731
+ if (e) {
732
+ h.value = !0, (e.purchaseOrder.supplier.internal === "warehouse" || e.purchaseOrder.supplier.internal === "restaurant") && (e.purchaseOrder.items = e.purchaseOrder.items.map(
733
+ ({ totalCost: l, ...c }) => c
734
+ ));
735
+ try {
736
+ await w.updateTemplate(e), await new Promise((l) => setTimeout(l, 1e3)), C.open({
737
+ title: "Updated",
738
+ message: "Your transfer template has been updated!",
739
+ type: "success"
740
+ }), y("update:show", !1), y("submitted");
741
+ } catch (l) {
742
+ C.open({
743
+ title: "Cannot update transfer template",
744
+ message: "Report to system administrator for troubleshooting.",
745
+ type: "error"
746
+ }), console.error("Error in updating transfer template", l);
747
+ } finally {
748
+ h.value = !1;
749
+ }
750
+ }
751
+ }
752
+ function U() {
753
+ switch (s.mode) {
754
+ case ee.CREATE:
755
+ return D();
756
+ case ee.UPDATE:
757
+ return E();
758
+ }
759
+ }
760
+ function M() {
761
+ var e, l;
762
+ (l = (e = x.value) == null ? void 0 : e.validateInputs) == null || l.call(e);
763
+ }
764
+ return (e, l) => {
765
+ const c = I("FmButton"), b = I("FmSideSheet");
766
+ return P(), j(b, {
767
+ modelValue: o(i),
768
+ "onUpdate:modelValue": l[2] || (l[2] = (d) => Pe(i) ? i.value = d : null),
769
+ "dismiss-away": "",
770
+ "close-button": "",
771
+ "max-width": 900
772
+ }, {
773
+ "side-sheet-header": $(() => [
774
+ n("div", Ut, [
775
+ n("div", Mt, re(O.value), 1)
776
+ ])
777
+ ]),
778
+ default: $(() => [
779
+ (P(), j(Et, {
780
+ class: "w-full",
781
+ ref_key: "formRef",
782
+ ref: x,
783
+ onValidationSuccess: U,
784
+ "model-value": r.value,
785
+ "onUpdate:modelValue": l[0] || (l[0] = (d) => r.value = d),
786
+ disabled: h.value,
787
+ key: _.value
788
+ }, null, 8, ["model-value", "disabled"]))
789
+ ]),
790
+ "side-sheet-footer": $(() => [
791
+ n("div", Bt, [
792
+ m(c, {
793
+ loading: h.value,
794
+ label: "Save",
795
+ onClick: M
796
+ }, null, 8, ["loading"]),
797
+ m(c, {
798
+ disabled: h.value,
799
+ variant: "tertiary",
800
+ label: "Close",
801
+ onClick: l[1] || (l[1] = (d) => y("update:show", !1))
802
+ }, null, 8, ["disabled"])
803
+ ])
804
+ ]),
805
+ _: 1
806
+ }, 8, ["modelValue"]);
807
+ };
808
+ }
809
+ }), Lt = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 h-full" }, zt = { class: "flex-1 flex flex-col gap-8" }, qt = { class: "flex flex-col" }, Ht = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, jt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Qt = { class: "fm-typo-en-body-lg-400" }, Kt = { class: "fm-typo-en-body-lg-400 line-clamp-1" }, Yt = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, io = /* @__PURE__ */ ne({
810
+ __name: "TransferTemplateView",
811
+ setup(u) {
812
+ const { t: v } = oe(), { createTemplate: p, viewTemplate: s } = he(), { templateDialogProps: y, transferFormDialogProps: w } = st(he()), C = He(), i = et(), t = Fe(), { breakpoints: r } = De();
813
+ t.watchLocation(C.fetchTemplates);
814
+ const _ = R(
815
+ () => C.loading.value || !t._currentLocation
816
+ ), h = R(() => C.templates.value), O = Q(""), x = R(() => r.value.xs || r.value.sm ? 10 : 20);
817
+ function D(a) {
818
+ switch (a) {
819
+ case be.Add:
820
+ return p();
821
+ }
822
+ }
823
+ const E = rt();
824
+ function U() {
825
+ E.push({ name: Ze.RECEIVE_REQUEST });
826
+ }
827
+ function M(a) {
828
+ return a;
829
+ }
830
+ return (a, e) => {
831
+ const l = I("FmTable");
832
+ return P(), we(Ee, null, [
833
+ m(Be, {
834
+ title: o(v)("inventory.transfer.template.title2"),
835
+ actions: [
836
+ {
837
+ label: o(v)("inventory.transfer.template.create.title"),
838
+ value: o(be).Add,
839
+ isPrimary: !0,
840
+ prependIcon: "add"
841
+ }
842
+ ],
843
+ "onClick:action": D
844
+ }, {
845
+ default: $(() => {
846
+ var c;
847
+ return [
848
+ n("div", Lt, [
849
+ m(Ne, {
850
+ searchable: "",
851
+ "change-location": "",
852
+ search: O.value,
853
+ "onUpdate:search": e[0] || (e[0] = (b) => O.value = b),
854
+ actions: [{ icon: "refresh", onClick: o(C).fetchTemplates }]
855
+ }, null, 8, ["search", "actions"]),
856
+ (P(), j(l, {
857
+ style: Ue(o(i).tableHeight),
858
+ "column-defs": o(C).columnDefs,
859
+ "row-data": h.value,
860
+ "search-value": O.value,
861
+ loading: _.value,
862
+ key: (c = o(t)._currentLocation) == null ? void 0 : c.dbName,
863
+ onRowClick: e[1] || (e[1] = (b) => o(s)(b.original)),
864
+ "page-size": x.value
865
+ }, {
866
+ "list-row": $((b) => [
867
+ m(Oe, {
868
+ row: b,
869
+ onRowClick: (d) => o(s)(d)
870
+ }, {
871
+ default: $((d) => {
872
+ var S, k, f, V, B, K, Y, G, N, L, J, W, X, z, q, Z, me, de, ae, pe, ce, fe, ye, le, ve;
873
+ return [
874
+ n("div", zt, [
875
+ n("div", qt, [
876
+ n("div", Ht, [
877
+ m(o(F), {
878
+ render: (f = (k = (S = d._id) == null ? void 0 : S.column) == null ? void 0 : k.columnDef) == null ? void 0 : f.cell,
879
+ props: (B = (V = d._id) == null ? void 0 : V.getContext) == null ? void 0 : B.call(V)
880
+ }, null, 8, ["render", "props"])
881
+ ]),
882
+ n("div", jt, [
883
+ m(o(F), {
884
+ render: (G = (Y = (K = d.name) == null ? void 0 : K.column) == null ? void 0 : Y.columnDef) == null ? void 0 : G.cell,
885
+ props: (L = (N = d.name) == null ? void 0 : N.getContext) == null ? void 0 : L.call(N)
886
+ }, null, 8, ["render", "props"])
887
+ ]),
888
+ n("div", Qt, [
889
+ m(o(F), {
890
+ render: (X = (W = (J = d.supplier) == null ? void 0 : J.column) == null ? void 0 : W.columnDef) == null ? void 0 : X.cell,
891
+ props: (q = (z = d.supplier) == null ? void 0 : z.getContext) == null ? void 0 : q.call(z)
892
+ }, null, 8, ["render", "props"])
893
+ ]),
894
+ n("div", Kt, re(b.original.purchaseOrder.items.length ? b.original.purchaseOrder.items.map((Ie) => Ie.name).join(", ") : "No items"), 1),
895
+ n("div", Yt, [
896
+ m(o(F), {
897
+ render: (de = (me = (Z = d.ref) == null ? void 0 : Z.column) == null ? void 0 : me.columnDef) == null ? void 0 : de.cell,
898
+ props: (pe = (ae = d.ref) == null ? void 0 : ae.getContext) == null ? void 0 : pe.call(ae)
899
+ }, null, 8, ["render", "props"])
900
+ ])
901
+ ]),
902
+ n("div", null, [
903
+ m(o(F), {
904
+ render: (ye = (fe = (ce = d.type) == null ? void 0 : ce.column) == null ? void 0 : fe.columnDef) == null ? void 0 : ye.cell,
905
+ props: (ve = (le = d.type) == null ? void 0 : le.getContext) == null ? void 0 : ve.call(le)
906
+ }, null, 8, ["render", "props"])
907
+ ])
908
+ ])
909
+ ];
910
+ }),
911
+ _: 2
912
+ }, 1032, ["row", "onRowClick"])
913
+ ]),
914
+ _: 1
915
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
916
+ ])
917
+ ];
918
+ }),
919
+ _: 1
920
+ }, 8, ["title", "actions"]),
921
+ (P(), j(Me, { to: "body" }, [
922
+ m(je, _e(o(w), { onSubmitted: U }), null, 16),
923
+ m(Nt, _e(o(y), {
924
+ onSubmitted: e[2] || (e[2] = (c) => o(C).fetchTemplates())
925
+ }), null, 16)
926
+ ]))
927
+ ], 64);
928
+ };
929
+ }
930
+ });
931
+ export {
932
+ io as default
933
+ };