@feedmepos/mf-inventory-portal 0.0.19-dev.5 → 0.0.19-dev.7

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