@feedmepos/mf-inventory-portal 0.0.22-dev.2 → 0.0.22-dev.21

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 (81) hide show
  1. package/dist/App.vue.d.ts +2 -0
  2. package/dist/{ApprovalView-D7WEr35k.js → ApprovalView-CCYykhrK.js} +14 -14
  3. package/dist/{BindingsDialog-C-3uO6pD.js → BindingsDialog-33VV_AST.js} +1 -1
  4. package/dist/{BindingsPicker-B3tGisCE.js → BindingsPicker-BKu4vN8J.js} +8 -8
  5. package/dist/{BindingsTable-CPtiH3vj.js → BindingsTable-Dd0h5gDf.js} +1 -1
  6. package/dist/ClosingTemplateView-BhevjTLl.js +1067 -0
  7. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-ohHZLOuR.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-3gp56NNJ.js} +14 -16
  8. package/dist/{IngredientsView-D-EKGLq9.js → IngredientsView-DckIH9eR.js} +5 -6
  9. package/dist/{IntegrationView-BVAO_vch.js → IntegrationView-BqQ4jRIp.js} +2 -2
  10. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CJYmB7Ct.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Vi0q_bDz.js} +1 -1
  11. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BxkM-SOw.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BIL8LWRz.js} +1 -1
  12. package/dist/{PurchaseOrderPrintPreview-CP-mK62z.js → PurchaseOrderPrintPreview-Ct7daTTa.js} +1 -1
  13. package/dist/{ReceiveRequestView-x8WTvuDk.js → ReceiveRequestView-B4wHTogG.js} +25 -26
  14. package/dist/RecipeView-DuE4cXLz.js +590 -0
  15. package/dist/Standalone.vue.d.ts +2 -0
  16. package/dist/{StockView-SyWxT4Ee.js → StockView-Bn9v2Ix8.js} +602 -585
  17. package/dist/{SupplierView-a0HAZJau.js → SupplierView-C8rqHSOV.js} +37 -37
  18. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CStnY5Zh.js +851 -0
  19. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DRKiv_t8.js +1511 -0
  20. package/dist/TransferTemplateView-RM6Y-WL4.js +1209 -0
  21. package/dist/{UnitView-B3c7W5lw.js → UnitView-BXISVrop.js} +4 -4
  22. package/dist/{WarehouseView-DDV-yslF.js → WarehouseView-B055eB90.js} +18 -18
  23. package/dist/api/closing-template.d.ts +14 -0
  24. package/dist/api/inventory.d.ts +5 -7
  25. package/dist/api/netsuite.d.ts +46 -0
  26. package/dist/api/purchase-order-template.d.ts +0 -4
  27. package/dist/{app-DURkcZal.js → app-9algzyce.js} +16045 -15403
  28. package/dist/app.d.ts +6 -0
  29. package/dist/app.js +2 -2
  30. package/dist/components/FmMinMaxInputRules.d.ts +2 -0
  31. package/dist/components/FmUnitInputRules.d.ts +2 -0
  32. package/dist/{decimal-BGJlFDm8.js → decimal-CMuMGm4y.js} +1 -1
  33. package/dist/{defineDeepModel-pATZSiCT.js → defineDeepModel-CjPowyho.js} +1 -1
  34. package/dist/extensions/promises.d.ts +14 -0
  35. package/dist/{format-time-from-id-BCAuJEq2.js → format-time-from-id-DNKcbBFm.js} +1 -1
  36. package/dist/helper/date2.d.ts +1 -0
  37. package/dist/helper/rules.d.ts +7 -0
  38. package/dist/helper/rules.spec.d.ts +1 -0
  39. package/dist/{id-to-date-CVHmTOJk.js → id-to-date-C6W4aVdr.js} +1 -1
  40. package/dist/purchase-order-transaction-type-CscRvNAR.js +680 -0
  41. package/dist/stores/api.d.ts +1 -0
  42. package/dist/stores/feature.d.ts +0 -1
  43. package/dist/stores/helper/core-store-proxy.d.ts +3 -0
  44. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  45. package/dist/stores/inventory.d.ts +7 -0
  46. package/dist/stores/location.d.ts +24 -42
  47. package/dist/stores/netsuite.d.ts +56 -0
  48. package/dist/stores/route.d.ts +0 -5
  49. package/dist/stores/warehouse.d.ts +4 -7
  50. package/dist/style.css +1 -1
  51. package/dist/{supplier-DmBbGAwf.js → supplier-BiCX3dpL.js} +1 -1
  52. package/dist/tsconfig.app.tsbuildinfo +1 -1
  53. package/dist/use-template-enabled-locations-2-Dtg2qOTm.js +85 -0
  54. package/dist/views/closing-template/components/closing-template-publish/ClosingTemplatePublish.vue.d.ts +6 -0
  55. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +276 -84
  56. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +341 -85
  57. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
  58. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +916 -0
  59. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -0
  60. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +788 -152
  61. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +800 -164
  62. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +13 -0
  63. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +4 -7
  64. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +2 -2
  65. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1285 -109
  66. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +399 -993
  67. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +345 -0
  68. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -14
  69. package/dist/{xlsx-1DLm6bBD.js → xlsx-fKJqx2Qc.js} +1 -1
  70. package/dist/{xlsx.util-DLtch7r5.js → xlsx.util-LOnzE3KS.js} +2 -2
  71. package/package.json +5 -5
  72. package/dist/ClosingTemplateView-Df0lgpjS.js +0 -928
  73. package/dist/RecipeView-BysIWI1W.js +0 -581
  74. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-ckp8gcT_.js +0 -740
  75. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-BSvpuWY9.js +0 -1409
  76. package/dist/TransferTemplateView-BGi6zd6d.js +0 -1350
  77. package/dist/array-ClJzD_Lt.js +0 -30
  78. package/dist/layout/InventoryLayout.vue.d.ts +0 -2
  79. package/dist/layout/layout-routes.d.ts +0 -6
  80. package/dist/purchase-order-transaction-type-DvSpCSXr.js +0 -712
  81. package/dist/use-template-enabled-locations-BiuOdu1M.js +0 -57
@@ -1,1409 +0,0 @@
1
- import { reactive as We, onMounted as Ue, computed as F, h as E, defineComponent as se, openBlock as P, createElementBlock as $, Fragment as fe, renderList as Pe, createElementVNode as d, toDisplayString as A, unref as e, resolveComponent as T, createVNode as k, withCtx as V, createCommentVNode as H, ref as L, createBlock as z, watch as Me, normalizeClass as Fe, normalizeStyle as Ye, isRef as ie } from "vue";
2
- import { useBreakpoints as Ze, components as re, FmButtonVariant as Qe, useSnackbar as Ie, useDialog as Ke, useProxiedModel as Je } from "@feedmepos/ui-library";
3
- import { F as pe } from "./row-action.enum-PMKMRrZR.js";
4
- import { P as I, d as Ee, c as Xe } from "./purchase-order-transaction-type-DvSpCSXr.js";
5
- import { a as j, t as Ge, a8 as Te, D as et, b as Le, R as Re, a2 as tt, a3 as st, r as ot, a4 as Oe, G as qe, l as nt, A as ke, M as at, a9 as Ne, O as $e, P as He, aa as lt, j as Ae, ab as rt, u as De, ac as it, ad as ut, ae as dt, E as ct, af as pt, y as mt } from "./app-DURkcZal.js";
6
- import { _ as ze, u as ft } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-BxkM-SOw.js";
7
- import { useI18n as de } from "@feedmepos/mf-common";
8
- import "vue-router";
9
- import { u as he } from "./supplier-DmBbGAwf.js";
10
- import { d as yt } from "./defineDeepModel-pATZSiCT.js";
11
- import { F as ue, _ as vt } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
12
- import { _ as bt } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
13
- function te(o, m, r, n) {
14
- var u, p, C;
15
- if (n != null && n.manualTotalCost)
16
- return n == null ? void 0 : n.manualTotalCost;
17
- const v = (C = (p = (u = n == null ? void 0 : n.supplier) == null ? void 0 : u.supplyItems) == null ? void 0 : p.find(
18
- (b) => b.skuId === o._id
19
- )) == null ? void 0 : C.defaultCost, t = o.defaultCost, l = v ?? t, x = l == null ? void 0 : l.costPerUnit, c = x ? l != null && l.measurement ? +j(x) / +j(l == null ? void 0 : l.measurement.conversion) : +j(x) : void 0, s = c ? r ? c * +j(r.conversion) : c : void 0, a = s ? +j(m) * s : void 0;
20
- return a ? {
21
- ...Ge(a ?? 0, 2),
22
- currency: Te()
23
- } : {
24
- amount: 0,
25
- precision: 0,
26
- currency: Te()
27
- };
28
- }
29
- var R = /* @__PURE__ */ ((o) => (o.Code = "Code", o.Name = "Name", o.Amount = "Amount", o.Cost = "Cost", o.Delete = "Delete", o))(R || {});
30
- const _t = () => {
31
- const { t: o } = de();
32
- return E(
33
- ze,
34
- {
35
- zIndex: 50,
36
- class: "whitespace-nowrap"
37
- },
38
- o("inventory.transfer.form.items.table.Cost", [Ne()])
39
- );
40
- };
41
- function gt(o) {
42
- const { t: m } = de(), r = We({}), { breakpoints: n } = Ze(), v = Le();
43
- Ue(() => {
44
- for (const c of o.items) {
45
- if (!c.totalCost)
46
- continue;
47
- const s = te(c.sku, c.quantity, c.measurement, {
48
- supplier: o.supplier
49
- }), a = c.totalCost ?? et.reset();
50
- s ? r[c.sku._id] = s.amount !== a.amount || s.precision !== a.precision : r[c.sku._id] = !0;
51
- }
52
- });
53
- function t(c) {
54
- var a, f, u, p, C, b, h;
55
- return !!(((f = (a = c.defaultCost) == null ? void 0 : a.costPerUnit) == null ? void 0 : f.amount) ?? ((h = (b = (C = (p = (u = o.supplier) == null ? void 0 : u.supplyItems) == null ? void 0 : p.find((w) => w.skuId === c._id)) == null ? void 0 : C.defaultCost) == null ? void 0 : b.costPerUnit) == null ? void 0 : h.amount));
56
- }
57
- const l = [
58
- {
59
- id: "Code",
60
- header: () => m("inventory.transfer.form.items.table.Code"),
61
- accessorKey: "code",
62
- size: 96,
63
- cell(c) {
64
- const s = c.row.original;
65
- return E(re.FmTextField, {
66
- modelValue: s.code,
67
- "onUpdate:modelValue": (a) => {
68
- o.updateItem({
69
- ...s,
70
- code: a
71
- });
72
- },
73
- key: s.sku._id,
74
- rules: [Re()],
75
- labelMark: "required"
76
- });
77
- },
78
- enableSorting: !1
79
- },
80
- {
81
- id: "Name",
82
- header: () => m("inventory.transfer.form.items.table.Name"),
83
- minSize: 300,
84
- cell(c) {
85
- const s = c.row.original;
86
- return E(re.FmTextField, {
87
- modelValue: s.name,
88
- "onUpdate:modelValue": (a) => {
89
- o.updateItem({
90
- ...s,
91
- name: a
92
- });
93
- },
94
- key: s.sku._id,
95
- rules: [Re()],
96
- labelMark: "required"
97
- });
98
- },
99
- enableSorting: !1
100
- },
101
- {
102
- id: "Amount",
103
- header: () => m("inventory.transfer.form.items.table.Amount"),
104
- minSize: 200,
105
- cell(c) {
106
- var f, u, p;
107
- const s = c.row.original, a = (p = (u = (f = o.template) == null ? void 0 : f.purchaseOrder) == null ? void 0 : u.items) == null ? void 0 : p.find(
108
- (C) => C.sku._id === s.sku._id
109
- );
110
- return E(tt, {
111
- style: {
112
- flex: "1 1 0%"
113
- },
114
- modelValue: {
115
- amount: s.quantity ?? { amount: 1, precision: 0 },
116
- measurement: s.measurement ?? null
117
- },
118
- key: s.sku._id,
119
- unit: s.sku.unit,
120
- "onUpdate:modelValue": (C) => {
121
- const b = {
122
- ...s,
123
- quantity: C.amount,
124
- measurement: C.measurement
125
- };
126
- v.enableTotalCost && (b.totalCost = te(s.sku, s.quantity, s.measurement, {
127
- supplier: o.supplier,
128
- // NOTE: set undefined here if `manualTotalCost[row.sku._id] = false`, so that the function
129
- // will return the auto calculated default cost instead of the manual total cost
130
- manualTotalCost: r[s.sku._id] ? b.totalCost : void 0
131
- })), o.updateItem(b);
132
- },
133
- stepperOnly: !!(a != null && a.quantityStep),
134
- stepper: a == null ? void 0 : a.quantityStep,
135
- disableUnit: !!a,
136
- disabled: o.disabled,
137
- rules: [
138
- st(
139
- +j(
140
- (a == null ? void 0 : a.minimumQuantity) ?? {
141
- amount: 1,
142
- precision: ot(s.sku.unit, s.measurement)
143
- }
144
- )
145
- ),
146
- a != null && a.maximumQuantity ? Oe(
147
- +j(a == null ? void 0 : a.maximumQuantity)
148
- ) : Oe(1 / 0)
149
- ],
150
- applyDefaultRules: !0
151
- });
152
- },
153
- enableSorting: !1
154
- },
155
- {
156
- id: "Cost",
157
- header: _t,
158
- size: 180,
159
- cell(c) {
160
- const s = c.row.original, a = t(s.sku), f = n.value.xs || n.value.sm;
161
- return !r[s.sku._id] && a ? E(
162
- "div",
163
- {
164
- class: [
165
- "flex gap-4 fm-typo-en-body-md-400 items-center",
166
- o.disabled ? "text-fm-color-typo-disabled" : ""
167
- ],
168
- key: s.sku._id
169
- },
170
- [
171
- E(re.FmButton, {
172
- prependIcon: "edit",
173
- variant: Qe.Tertiary,
174
- disabled: o.disabled,
175
- onClick() {
176
- o.updateItem({
177
- ...s,
178
- totalCost: te(s.sku, s.quantity, s.measurement, {
179
- supplier: o.supplier
180
- })
181
- }), r[s.sku._id] = !0;
182
- }
183
- }),
184
- E(
185
- "div",
186
- {
187
- class: "flex flex-col"
188
- },
189
- [
190
- E(
191
- "span",
192
- f ? qe(
193
- te(s.sku, s.quantity, s.measurement, {
194
- supplier: o.supplier
195
- })
196
- ) : j(
197
- te(s.sku, s.quantity, s.measurement, {
198
- supplier: o.supplier
199
- })
200
- )
201
- ),
202
- E(
203
- "span",
204
- {
205
- class: [
206
- "fm-typo-en-body-sm-400",
207
- o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
208
- ]
209
- },
210
- m("inventory.transfer.form.items.autoCalculated")
211
- )
212
- ]
213
- )
214
- ]
215
- ) : E(
216
- re.FmTextField,
217
- {
218
- modelValue: j(s.totalCost ?? { amount: 0, precision: 0 }),
219
- key: s.sku._id,
220
- "onUpdate:modelValue": (u) => {
221
- o.updateItem({
222
- ...s,
223
- totalCost: {
224
- ...nt(+u),
225
- currency: Te()
226
- }
227
- });
228
- },
229
- rules: [ke(0), at(2)]
230
- },
231
- {
232
- prepend() {
233
- return f ? E(
234
- "div",
235
- {
236
- class: [
237
- "text-fm-typo-en-body-lg-400",
238
- o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
239
- ]
240
- },
241
- Ne()
242
- ) : null;
243
- },
244
- append() {
245
- return a ? E(re.FmButton, {
246
- prependIcon: "close",
247
- variant: "tertiary",
248
- disabled: o.disabled,
249
- onClick() {
250
- o.updateItem({
251
- ...s,
252
- // NOTE: different from PO template, if a default cost is reenabled,
253
- // the total cost will automatically assigned
254
- totalCost: te(s.sku, s.quantity, s.measurement, {
255
- supplier: o.supplier
256
- })
257
- }), r[s.sku._id] = !1;
258
- }
259
- }) : null;
260
- }
261
- }
262
- );
263
- },
264
- enableSorting: !1
265
- },
266
- {
267
- id: "Delete",
268
- header: "",
269
- cell(c) {
270
- const s = c.row.original;
271
- return E(re.FmButton, {
272
- key: s.sku._id,
273
- class: "delete-button",
274
- type: "button",
275
- icon: "delete",
276
- variant: "tertiary",
277
- size: "md",
278
- disabled: o.disabled,
279
- onClick: () => {
280
- o.deleteItem(s);
281
- }
282
- });
283
- },
284
- enableSorting: !1,
285
- size: 40,
286
- meta: {
287
- cellClass: "",
288
- headerClass: ""
289
- }
290
- }
291
- ];
292
- return {
293
- columnDefs: F(() => v.enableTotalCost && o.transferType === I.PURCHASE ? l : l.filter(
294
- (c) => c.id !== "Cost"
295
- /* Cost */
296
- ))
297
- };
298
- }
299
- const Ct = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, kt = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, ht = { class: "w-[450px] xs:w-full flex" }, wt = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, xt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, je = /* @__PURE__ */ se({
300
- __name: "SupplierPriceHistory",
301
- props: {
302
- prices: {}
303
- },
304
- setup(o) {
305
- const m = he();
306
- function r(n) {
307
- return m.suppliers.find((v) => v._id === n);
308
- }
309
- return (n, v) => (P(), $("div", Ct, [
310
- (P(!0), $(fe, null, Pe(Object.keys(n.prices), (t) => {
311
- var l;
312
- return P(), $("div", {
313
- key: t,
314
- class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
315
- }, [
316
- d("div", kt, A((l = r(t)) == null ? void 0 : l.name), 1),
317
- d("div", ht, [
318
- (P(!0), $(fe, null, Pe(n.prices[t].slice(0, 3), (x) => {
319
- var c;
320
- return P(), $("div", {
321
- key: x.date,
322
- class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
323
- }, [
324
- d("div", wt, [
325
- d("span", null, A(x.totalCost ? e(qe)(x.totalCost) : "No data"), 1),
326
- v[0] || (v[0] = d("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
327
- d("span", null, A(e(j)(x.totalUnit, !1)), 1),
328
- d("span", null, A(((c = x.measurement) == null ? void 0 : c.abbrev) ?? x.unit.abbrev), 1)
329
- ]),
330
- d("div", xt, [
331
- d("span", null, "(#" + A(x.seqNumber) + ")", 1),
332
- v[1] || (v[1] = d("span", null, A(" "), -1)),
333
- d("span", null, A(e($e)(new Date(x.date))), 1)
334
- ])
335
- ]);
336
- }), 128))
337
- ])
338
- ]);
339
- }), 128))
340
- ]));
341
- }
342
- }), St = { class: "flex flex-col gap-8 py-16" }, Pt = { class: "flex items-center" }, Ft = { class: "flex-1 flex gap-1 items-center" }, Tt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, It = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, $t = { class: "flex gap-8 w-full" }, At = { class: "flex-1 flex flex-col gap-4" }, Dt = { class: "flex-1 flex flex-col gap-4" }, Vt = { class: "flex gap-8 w-full" }, Rt = { class: "flex-1 flex flex-col gap-4" }, Ot = {
343
- key: 0,
344
- class: "flex-1 flex flex-col gap-4"
345
- }, Bt = /* @__PURE__ */ se({
346
- __name: "TransferItem",
347
- props: {
348
- cellByColId: {},
349
- comparePriceBySku: {},
350
- showComparePrice: { type: Boolean },
351
- row: {}
352
- },
353
- setup(o) {
354
- const { t: m } = de();
355
- return (r, n) => {
356
- var l, x, c, s, a, f, u, p, C, b, h, w, O, B, X, U, W, K, q, N, J, _, g, M, oe, Y, we;
357
- const v = T("FmLabel"), t = T("FmSpacer");
358
- return P(), $("div", St, [
359
- d("div", Pt, [
360
- d("div", Ft, [
361
- d("span", Tt, " (" + A(r.row.original.sku.code) + ") ", 1),
362
- d("span", It, A(r.row.original.sku.name), 1)
363
- ]),
364
- d("div", null, [
365
- k(e(ue), {
366
- render: (c = (x = (l = r.cellByColId.Delete) == null ? void 0 : l.column) == null ? void 0 : x.columnDef) == null ? void 0 : c.cell,
367
- props: (a = (s = r.cellByColId.Delete) == null ? void 0 : s.getContext) == null ? void 0 : a.call(s)
368
- }, null, 8, ["render", "props"])
369
- ])
370
- ]),
371
- d("div", $t, [
372
- d("div", At, [
373
- k(v, {
374
- label: e(m)(`inventory.transfer.form.items.table.${e(R).Code}`)
375
- }, null, 8, ["label"]),
376
- k(e(ue), {
377
- render: (p = (u = (f = r.cellByColId[e(R).Code]) == null ? void 0 : f.column) == null ? void 0 : u.columnDef) == null ? void 0 : p.cell,
378
- props: (b = (C = r.cellByColId[e(R).Code]) == null ? void 0 : C.getContext) == null ? void 0 : b.call(C)
379
- }, null, 8, ["render", "props"]),
380
- n[0] || (n[0] = d("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
381
- ]),
382
- d("div", Dt, [
383
- k(v, {
384
- label: e(m)(`inventory.transfer.form.items.table.${e(R).Name}`)
385
- }, null, 8, ["label"]),
386
- k(e(ue), {
387
- render: (O = (w = (h = r.cellByColId[e(R).Name]) == null ? void 0 : h.column) == null ? void 0 : w.columnDef) == null ? void 0 : O.cell,
388
- props: (X = (B = r.cellByColId[e(R).Name]) == null ? void 0 : B.getContext) == null ? void 0 : X.call(B)
389
- }, null, 8, ["render", "props"]),
390
- n[1] || (n[1] = d("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
391
- ])
392
- ]),
393
- d("div", Vt, [
394
- d("div", Rt, [
395
- k(v, {
396
- label: e(m)(`inventory.transfer.form.items.table.${e(R).Amount}`)
397
- }, null, 8, ["label"]),
398
- k(e(ue), {
399
- render: (K = (W = (U = r.cellByColId[e(R).Amount]) == null ? void 0 : U.column) == null ? void 0 : W.columnDef) == null ? void 0 : K.cell,
400
- props: (N = (q = r.cellByColId[e(R).Amount]) == null ? void 0 : q.getContext) == null ? void 0 : N.call(q)
401
- }, null, 8, ["render", "props"]),
402
- n[2] || (n[2] = d("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
403
- ]),
404
- r.cellByColId[e(R).Cost] ? (P(), $("div", Ot, [
405
- k(ze, { "z-index": 50 }, {
406
- default: V(() => [
407
- k(v, {
408
- label: e(m)(`inventory.transfer.form.items.table.${e(R).Cost}2`)
409
- }, null, 8, ["label"])
410
- ]),
411
- _: 1
412
- }),
413
- k(e(ue), {
414
- render: (g = (_ = (J = r.cellByColId[e(R).Cost]) == null ? void 0 : J.column) == null ? void 0 : _.columnDef) == null ? void 0 : g.cell,
415
- props: (oe = (M = r.cellByColId[e(R).Cost]) == null ? void 0 : M.getContext) == null ? void 0 : oe.call(M)
416
- }, null, 8, ["render", "props"]),
417
- n[3] || (n[3] = d("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
418
- ])) : H("", !0)
419
- ]),
420
- r.showComparePrice && Object.keys(r.comparePriceBySku[(Y = r.row.original.sku) == null ? void 0 : Y._id] ?? {}).length > 0 ? (P(), $(fe, { key: 0 }, [
421
- k(t, { class: "h-8" }),
422
- k(je, {
423
- prices: r.comparePriceBySku[(we = r.row.original.sku) == null ? void 0 : we._id]
424
- }, null, 8, ["prices"])
425
- ], 64)) : H("", !0)
426
- ]);
427
- };
428
- }
429
- });
430
- function me(o) {
431
- return lt.parse(o);
432
- }
433
- function Ce(o) {
434
- return {
435
- _id: o.doc._id,
436
- internal: o.type,
437
- contactName: o.doc.profile.name,
438
- name: o.doc.profile.name,
439
- email: o.doc.profile.email,
440
- phoneNumber: o.doc.profile.phoneNo,
441
- registrationNumber: o.doc.profile.regNo,
442
- address: o.doc.profile.address
443
- };
444
- }
445
- function Ut(o, m) {
446
- const r = he(), n = Ae(), v = F(() => !n.businessLevel);
447
- n.watchLocation(async () => {
448
- await r.readSuppliers();
449
- const u = o();
450
- if (u.supplier._id) return;
451
- const p = n.businessLevel ? r.businessSuppliers[0] : r.suppliers[0], b = (v.value ? n.locations.filter((h) => h.doc._id !== n.currentLocation.doc._id) : n.locations)[0];
452
- m({
453
- ...u,
454
- supplier: p ? me(p) : b ? Ce(b) : u.supplier
455
- });
456
- });
457
- const t = F(
458
- () => {
459
- var u, p;
460
- return typeof ((p = (u = o()) == null ? void 0 : u.supplier) == null ? void 0 : p.internal) == "string" ? I.TRANSFER : I.PURCHASE;
461
- }
462
- ), l = F({
463
- get() {
464
- var u, p;
465
- return (p = (u = o()) == null ? void 0 : u.supplier) == null ? void 0 : p._id;
466
- },
467
- set(u) {
468
- const p = o() ?? {};
469
- if (t.value === I.PURCHASE) {
470
- const O = (n.businessLevel ? r.businessSuppliers : r.suppliers).find((B) => B._id === u);
471
- m({
472
- ...p,
473
- supplier: O ? me(O) : p.supplier
474
- });
475
- return;
476
- }
477
- const h = (v.value ? n.locations.filter((w) => w.doc._id !== n.currentLocation.doc._id) : n.locations).find((w) => w.doc._id === u);
478
- m({
479
- ...p,
480
- supplier: h ? Ce(h) : p.supplier
481
- });
482
- }
483
- }), x = F(() => r.locationSuppliers.map(me)), c = F(() => r.businessSuppliers.map(me)), s = F(() => {
484
- var C;
485
- const u = ((C = n._currentLocation) == null ? void 0 : C.type) === He.warehouse;
486
- return (v.value ? n.locations.filter((b) => b.doc._id !== n.currentLocation.doc._id) : n.locations).filter((b) => u || b.acceptRequest).map(Ce);
487
- }), a = F(() => {
488
- if (t.value === I.PURCHASE) {
489
- const p = x.value.map((b) => ({
490
- label: b.name,
491
- value: b._id
492
- })), C = c.value.map((b) => ({
493
- label: b.name,
494
- sublabel: "Business supplier",
495
- value: b._id
496
- }));
497
- return n.businessLevel ? C : [...p, ...C];
498
- }
499
- return s.value.map((p) => ({
500
- label: p.name,
501
- sublabel: p.internal ? `${p.internal}` : void 0,
502
- value: p._id
503
- }));
504
- }), f = F(() => {
505
- var b, h;
506
- const u = (h = (b = o()) == null ? void 0 : b.supplier) == null ? void 0 : h._id;
507
- if (t.value === I.PURCHASE) {
508
- const w = r.suppliers.find((O) => O._id === u);
509
- return w ? me(w) : null;
510
- }
511
- const C = n.locations.find((w) => w.doc._id);
512
- return C ? Ce(C) : null;
513
- });
514
- return {
515
- transferLocationModel: l,
516
- transferLocationOptions: a,
517
- locationOptionsTypePurchase: x,
518
- locationOptionsTypeTransfer: s,
519
- selectedLocation: f
520
- };
521
- }
522
- function Mt(o) {
523
- const m = F({
524
- get() {
525
- const t = o.getEffectiveAt();
526
- return t ? new Date(t) : null;
527
- },
528
- set(t) {
529
- o.setEffectiveAt((t == null ? void 0 : t.toISOString()) ?? null);
530
- }
531
- }), r = F({
532
- get() {
533
- return !!m.value;
534
- },
535
- set(t) {
536
- t ? m.value = /* @__PURE__ */ new Date() : m.value = null;
537
- }
538
- }), n = F({
539
- get() {
540
- return m.value === null ? "" : $e(m.value);
541
- },
542
- set(t) {
543
- t ? m.value = /* @__PURE__ */ new Date(`${t} ${v.value}`) : m.value = null;
544
- }
545
- }), v = F({
546
- get() {
547
- return m.value === null ? "" : rt(m.value);
548
- },
549
- set(t) {
550
- t ? m.value = /* @__PURE__ */ new Date(`${n.value} ${t}`) : m.value = null;
551
- }
552
- });
553
- return {
554
- backdatePo: m,
555
- backdateSwitch: r,
556
- backdateModel: n,
557
- backdateTimeModel: v
558
- };
559
- }
560
- const Et = {
561
- width: "24",
562
- height: "24",
563
- viewBox: "0 0 24 24",
564
- fill: "none",
565
- xmlns: "http://www.w3.org/2000/svg"
566
- }, Lt = ["fill"], qt = ["fill"], Nt = ["stroke"], Ht = ["stroke"], zt = /* @__PURE__ */ se({
567
- __name: "SparkIcon",
568
- props: {
569
- size: {
570
- type: Number,
571
- default: 24
572
- },
573
- color: {
574
- type: String,
575
- default: "#c7c7cc"
576
- }
577
- },
578
- setup(o) {
579
- return (m, r) => (P(), $("svg", Et, [
580
- d("path", {
581
- d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
582
- fill: o.color
583
- }, null, 8, Lt),
584
- d("path", {
585
- d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
586
- fill: o.color
587
- }, null, 8, qt),
588
- d("path", {
589
- d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
590
- stroke: o.color,
591
- "stroke-width": "1.5",
592
- "stroke-linecap": "round",
593
- "stroke-linejoin": "round"
594
- }, null, 8, Nt),
595
- d("path", {
596
- d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
597
- stroke: o.color,
598
- "stroke-width": "1.5",
599
- "stroke-linecap": "round",
600
- "stroke-linejoin": "round"
601
- }, null, 8, Ht)
602
- ]));
603
- }
604
- }), jt = { class: "flex gap-8 items-center" }, Wt = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, Yt = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, Zt = { class: "flex items-center w-full" }, Qt = { class: "flex-1" }, Kt = { class: "fm-typo-en-title-sm-800" }, Jt = { class: "flex items-start gap-8" }, Xt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Gt = { class: "flex gap-1" }, Be = /* @__PURE__ */ se({
605
- __name: "ForecastStock",
606
- props: {
607
- disabled: { type: Boolean }
608
- },
609
- emits: ["update:poItems"],
610
- setup(o, { emit: m }) {
611
- const r = m, n = L(!1), v = L(7), t = ft(), l = Ie(), x = De(), { t: c } = de();
612
- async function s() {
613
- if (v.value < 1)
614
- return;
615
- n.value = !1, await t.readPurchaseOrder(v.value);
616
- const a = [];
617
- if (t.purchaseOrderForecast.skus.length <= 0) {
618
- l.open({
619
- message: c("inventory.transfer.form.items.forecastStock.notAvailable"),
620
- type: "info"
621
- });
622
- return;
623
- }
624
- const f = t.purchaseOrderForecast.skus.reduce((u, p) => {
625
- const C = x.skus.find((w) => w._id === p.id);
626
- if (u.find((w) => w.sku._id === p.id) || !C)
627
- return u;
628
- const h = {
629
- sku: C,
630
- code: C.code,
631
- name: C.name,
632
- quantity: {
633
- amount: p.amount,
634
- precision: 0
635
- }
636
- };
637
- return u.push(h), u;
638
- }, a);
639
- r("update:poItems", f);
640
- }
641
- return (a, f) => {
642
- const u = T("FmButton"), p = T("FmIcon"), C = T("FmStepperField"), b = T("FmPopover");
643
- return P(), z(b, {
644
- disabled: a.disabled,
645
- class: "flex",
646
- "show-popover": n.value,
647
- onPopoverChanged: f[3] || (f[3] = (h) => n.value = h)
648
- }, {
649
- "popover-button": V(() => [
650
- k(u, {
651
- label: "unused",
652
- variant: "secondary",
653
- "text-color": a.disabled ? "disabled" : "primary",
654
- "bg-color": "transparent",
655
- "border-color": a.disabled ? "disabled" : "primary",
656
- disabled: a.disabled
657
- }, {
658
- default: V(() => [
659
- d("div", jt, [
660
- k(zt, {
661
- size: 24,
662
- color: a.disabled ? "#c7c7cc" : "#ff7823"
663
- }, null, 8, ["color"]),
664
- d("div", Wt, A(e(c)("inventory.transfer.form.items.forecastStock.title")), 1)
665
- ])
666
- ]),
667
- _: 1
668
- }, 8, ["text-color", "border-color", "disabled"])
669
- ]),
670
- default: V(() => [
671
- d("div", Yt, [
672
- d("div", Zt, [
673
- d("div", Qt, [
674
- k(bt, { "z-index": 99 }, {
675
- default: V(() => [
676
- d("p", Kt, A(e(c)("inventory.transfer.form.items.forecastStock.title")), 1)
677
- ]),
678
- _: 1
679
- })
680
- ]),
681
- k(u, {
682
- icon: "close",
683
- size: "md",
684
- variant: "tertiary",
685
- onClick: f[0] || (f[0] = (h) => n.value = !1)
686
- })
687
- ]),
688
- k(C, {
689
- modelValue: v.value,
690
- "onUpdate:modelValue": f[1] || (f[1] = (h) => v.value = h),
691
- label: e(c)("inventory.transfer.form.items.forecastStock.days"),
692
- rules: [e(ke)(1)]
693
- }, {
694
- "helper-text": V(() => [
695
- d("div", Jt, [
696
- k(p, {
697
- name: "warning",
698
- size: "sm",
699
- class: "text-fm-color-system-warning-300"
700
- }),
701
- d("div", Xt, A(e(c)("inventory.transfer.form.items.forecastStock.replace")), 1)
702
- ])
703
- ]),
704
- _: 1
705
- }, 8, ["modelValue", "label", "rules"]),
706
- d("div", Gt, [
707
- f[4] || (f[4] = d("div", { class: "grow" }, null, -1)),
708
- k(u, {
709
- label: e(c)("common.cancel"),
710
- variant: "tertiary",
711
- onClick: f[2] || (f[2] = (h) => n.value = !1)
712
- }, null, 8, ["label"]),
713
- k(u, {
714
- label: e(c)("inventory.transfer.form.items.forecastStock.generate"),
715
- onClick: s
716
- }, null, 8, ["label"])
717
- ])
718
- ])
719
- ]),
720
- _: 1
721
- }, 8, ["disabled", "show-popover"]);
722
- };
723
- }
724
- });
725
- function es() {
726
- const o = Ie(), m = Ee(), r = L(!1);
727
- Me(r, (l) => {
728
- l && (v.value = !0, n().finally(() => {
729
- v.value = !1;
730
- }));
731
- });
732
- async function n() {
733
- try {
734
- const { startDate: l, endDate: x } = it(6), a = (await m.getPurchaseOrders({ start: l, end: x })).filter(
735
- (f) => {
736
- var u, p;
737
- return f.status === ut.enum.COMPLETE && ((u = f.supplier) == null ? void 0 : u.internal) !== "warehouse" && ((p = f.supplier) == null ? void 0 : p.internal) !== "restaurant";
738
- }
739
- ).reduce((f, u) => {
740
- const p = new Date(dt(u._id)), C = u.supplier._id;
741
- for (const b of u.items) {
742
- if (!b.totalCost) continue;
743
- const h = f[b.sku._id] ?? {}, w = h[C] ?? [];
744
- w.push({
745
- date: p.toISOString(),
746
- totalUnit: b.quantity,
747
- totalCost: b.totalCost,
748
- unit: b.sku.unit,
749
- measurement: b.measurement,
750
- seqNumber: u.seqNumber
751
- }), h[C] = w, f[b.sku._id] = h;
752
- }
753
- return f;
754
- }, {});
755
- t.value = a;
756
- } catch {
757
- o.open({
758
- title: "Something went wrong",
759
- message: "Cannot retrieve supplier purchase history. Please try again."
760
- }), r.value = !1;
761
- }
762
- }
763
- const v = L(!1), t = L({});
764
- return {
765
- comparePricesToggle: r,
766
- comparePriceFetching: v,
767
- comparePriceBySku: t
768
- };
769
- }
770
- const ts = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, ss = { key: 0 }, os = ["colspan"], ns = /* @__PURE__ */ se({
771
- __name: "TransferItemTable",
772
- props: {
773
- row: {},
774
- comparePriceBySku: {},
775
- showComparePrice: { type: Boolean }
776
- },
777
- setup(o) {
778
- function m(r) {
779
- return r.column.columnDef.meta;
780
- }
781
- return (r, n) => {
782
- var v, t;
783
- return P(), $(fe, null, [
784
- d("tr", {
785
- class: Fe(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
786
- "bg-fm-color-neutral-gray-100": r.row.getIsSelected()
787
- }])
788
- }, [
789
- (P(!0), $(fe, null, Pe(r.row.getVisibleCells(), (l) => {
790
- var x, c, s, a;
791
- return P(), $("td", {
792
- key: l.id,
793
- class: Fe([
794
- "h-[52px] px-16 text-fm-color-typo-primary",
795
- ((x = m(l)) == null ? void 0 : x.cellClass) ?? "px-16"
796
- ]),
797
- style: Ye({
798
- width: (c = m(l)) == null ? void 0 : c.width,
799
- maxWidth: (s = m(l)) == null ? void 0 : s.maxWidth,
800
- textAlign: ((a = m(l)) == null ? void 0 : a.textAlign) ?? "left"
801
- })
802
- }, [
803
- d("span", ts, [
804
- k(e(ue), {
805
- render: l.column.columnDef.cell,
806
- props: l.getContext()
807
- }, null, 8, ["render", "props"])
808
- ])
809
- ], 6);
810
- }), 128))
811
- ], 2),
812
- r.showComparePrice && Object.keys(r.comparePriceBySku[(v = r.row.original.sku) == null ? void 0 : v._id] ?? {}).length > 0 ? (P(), $("tr", ss, [
813
- d("td", {
814
- colspan: r.row.getVisibleCells().length
815
- }, [
816
- k(je, {
817
- prices: r.comparePriceBySku[(t = r.row.original.sku) == null ? void 0 : t._id]
818
- }, null, 8, ["prices"])
819
- ], 8, os)
820
- ])) : H("", !0)
821
- ], 64);
822
- };
823
- }
824
- }), as = { class: "flex flex-col gap-4" }, ls = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, rs = { class: "flex flex-col gap-16" }, is = { class: "flex flex-col gap-24" }, us = {
825
- key: 0,
826
- class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
827
- }, ds = { class: "flex xs:flex-col sm:flex-col" }, cs = {
828
- key: 0,
829
- class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
830
- }, ps = { class: "flex-1" }, ms = { class: "flex-1" }, fs = {
831
- key: 1,
832
- class: "flex items-center gap-4"
833
- }, ys = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, vs = { class: "flex flex-col gap-16" }, bs = { class: "flex sm:flex-col xs:flex-col gap-16 items-center xs:items-start sm:items-start" }, _s = { class: "flex-1 gap-8 fm-typo-en-title-sm-800" }, gs = { class: "flex gap-8" }, Cs = {
834
- key: 0,
835
- class: "xs:w-full"
836
- }, ks = /* @__PURE__ */ se({
837
- __name: "TransferForm2",
838
- props: {
839
- modelValue: {},
840
- disabled: { type: Boolean },
841
- suppliers: {},
842
- skus: {},
843
- lastClosingDate: {}
844
- },
845
- emits: ["validation-success", "form:ready"],
846
- setup(o, { expose: m, emit: r }) {
847
- const n = o, v = r, t = yt(), { t: l } = de(), x = Ae(), c = De(), s = he(), a = Le(), f = Xe(), u = F(
848
- () => f.templates.value.find((i) => i._id === t.template)
849
- ), p = F(() => t.status === "DRAFT" || !t._rev);
850
- Ue(async () => {
851
- var i;
852
- try {
853
- if (!t.template) return;
854
- await f.loadTemplate(t.template), t.items.length || (t.items = ((i = u.value) == null ? void 0 : i.purchaseOrder.items) ?? []);
855
- } finally {
856
- v("form:ready");
857
- }
858
- });
859
- const C = F(
860
- () => x.currentLocation.type === He.restaurant
861
- );
862
- x.watchLocation(async () => {
863
- location && (t.supplier || (t.supplier = s.suppliers.find((i) => i) ?? t.supplier));
864
- });
865
- const b = Ke(), h = Ut(
866
- () => t,
867
- (i) => {
868
- Object.assign(t, i);
869
- }
870
- ), w = F({
871
- get() {
872
- var i;
873
- return typeof ((i = t == null ? void 0 : t.supplier) == null ? void 0 : i.internal) == "string" ? I.TRANSFER : I.PURCHASE;
874
- },
875
- set(i) {
876
- var Z;
877
- const y = typeof ((Z = t == null ? void 0 : t.supplier) == null ? void 0 : Z.internal) == "string" ? I.TRANSFER : I.PURCHASE;
878
- i !== y && (t.supplier = i === I.PURCHASE ? h.locationOptionsTypePurchase.value[0] : h.locationOptionsTypeTransfer.value[0]);
879
- }
880
- }), O = F(() => h.transferLocationOptions.value), B = F({
881
- get() {
882
- return t.supplier._id;
883
- },
884
- set(i) {
885
- h.transferLocationModel.value = i;
886
- }
887
- }), X = F({
888
- get() {
889
- return t.remark ?? void 0;
890
- },
891
- set(i) {
892
- t.remark = i;
893
- }
894
- }), { backdatePo: U, backdateSwitch: W, backdateModel: K, backdateTimeModel: q } = Mt({
895
- getEffectiveAt() {
896
- return t.effectiveAt;
897
- },
898
- setEffectiveAt(i) {
899
- t.effectiveAt = i;
900
- }
901
- }), { comparePricesToggle: N, comparePriceFetching: J, comparePriceBySku: _ } = es(), g = L();
902
- m({
903
- validateInputs: () => {
904
- var i, y;
905
- (y = (i = g.value) == null ? void 0 : i.validateInputs) == null || y.call(i);
906
- },
907
- resetInputsValidation: () => {
908
- var i, y;
909
- (y = (i = g.value) == null ? void 0 : i.resetInputsValidation) == null || y.call(i);
910
- },
911
- resetInputs: () => {
912
- var i, y;
913
- (y = (i = g.value) == null ? void 0 : i.resetInputs) == null || y.call(i);
914
- }
915
- });
916
- const M = gt({
917
- updateItem: (i) => {
918
- t.items = t.items.map((y) => y.sku._id !== i.sku._id ? y : i);
919
- },
920
- deleteItem: (i) => {
921
- t.items = t.items.filter((y) => y.sku._id !== i.sku._id);
922
- },
923
- get supplier() {
924
- return t.supplier;
925
- },
926
- get items() {
927
- return t.items;
928
- },
929
- get transferType() {
930
- return w.value;
931
- },
932
- get template() {
933
- return u.value;
934
- },
935
- get disabled() {
936
- return n.disabled;
937
- }
938
- }), oe = F(() => M.columnDefs.value);
939
- function Y() {
940
- var ve, be, ce;
941
- const i = new Set((ce = (be = (ve = u.value) == null ? void 0 : ve.purchaseOrder) == null ? void 0 : be.items) == null ? void 0 : ce.map((D) => D.sku._id)), Z = (i.size ? c.skus.filter((D) => i.has(D._id)) : c.skus).map(
942
- (D) => ({
943
- label: D.name,
944
- sublabel: D.code,
945
- value: D
946
- })
947
- ), ye = Z.filter((D) => {
948
- var ne;
949
- return (ne = t.items) == null ? void 0 : ne.find((G) => G.sku._id === D.value._id);
950
- }).map((D) => D.value);
951
- b.open({
952
- title: l("inventory.transfer.form.items.selectItem"),
953
- closeButton: !0,
954
- contentComponent: mt,
955
- contentComponentProps: {
956
- modelValue: ye,
957
- items: Z,
958
- virtualScroll: !0
959
- },
960
- primaryActions: {
961
- text: l("common.confirm"),
962
- close: !0
963
- },
964
- secondaryActions: {
965
- text: l("common.close"),
966
- close: !0,
967
- variant: "tertiary"
968
- }
969
- }).onPrimary((D) => {
970
- const ne = t.items ?? [], G = D.map((Q) => {
971
- var _e, ge;
972
- const ae = ne.find((le) => le.sku._id === Q._id);
973
- if (ae)
974
- return ae;
975
- const ee = ((ge = (_e = u.value) == null ? void 0 : _e.purchaseOrder.items) == null ? void 0 : ge.find(
976
- (le) => le.sku._id === Q._id
977
- )) ?? {
978
- sku: Q,
979
- code: Q.code,
980
- name: Q.name,
981
- quantity: {
982
- amount: 1,
983
- precision: 0
984
- }
985
- };
986
- return w.value == I.PURCHASE && (ee.totalCost = te(
987
- ee.sku,
988
- ee.quantity,
989
- ee.measurement,
990
- {
991
- supplier: t.supplier
992
- }
993
- )), ee;
994
- });
995
- G.sort((Q, ae) => Q.sku.code.localeCompare(ae.sku.code)), t.items = G;
996
- });
997
- }
998
- function we(i) {
999
- return i;
1000
- }
1001
- return (i, y) => {
1002
- var le, Ve;
1003
- const Z = T("FmChip"), ye = T("FmSelect"), ve = T("FmTextField"), be = T("FmTextarea"), ce = T("FmSwitch"), D = T("FmDatePicker"), ne = T("FmTimePicker"), G = T("FmFormGroup"), Q = T("FmIcon"), ae = T("FmButton"), ee = T("FmTooltip"), _e = T("FmTable"), ge = T("FmForm");
1004
- return P(), $("div", as, [
1005
- d("div", ls, [
1006
- (le = n.modelValue) != null && le.template ? (P(), z(Z, {
1007
- key: 0,
1008
- variant: i.disabled ? "warning" : void 0,
1009
- label: `${e(l)("inventory.transfer.template.title")}: ${((Ve = u.value) == null ? void 0 : Ve.name) ?? e(l)("inventory.transfer.form.loading")}`,
1010
- icon: "summarize",
1011
- compact: ""
1012
- }, null, 8, ["variant", "label"])) : H("", !0),
1013
- k(Z, {
1014
- label: e(x).currentLocation.name,
1015
- icon: "storefront",
1016
- compact: ""
1017
- }, null, 8, ["label"]),
1018
- i.lastClosingDate ? (P(), z(Z, {
1019
- key: 1,
1020
- label: `${e(l)("inventory.transfer.form.lastClosing")}: ${e($e)(i.lastClosingDate)} ${e(ct)(i.lastClosingDate)}`,
1021
- icon: "calendar_month",
1022
- compact: ""
1023
- }, null, 8, ["label"])) : H("", !0)
1024
- ]),
1025
- k(ge, {
1026
- ref_key: "formRef",
1027
- ref: g,
1028
- class: "flex flex-col gap-32",
1029
- disabled: i.disabled,
1030
- onValidationFailed: console.log,
1031
- onValidationSuccess: y[12] || (y[12] = (xe) => v("validation-success"))
1032
- }, {
1033
- default: V(() => {
1034
- var xe;
1035
- return [
1036
- d("div", rs, [
1037
- d("div", is, [
1038
- k(ye, {
1039
- label: e(l)("inventory.transfer.form.type.title"),
1040
- "model-value": w.value,
1041
- "onUpdate:modelValue": y[0] || (y[0] = (S) => w.value = S),
1042
- items: [
1043
- {
1044
- label: e(l)("inventory.transfer.form.type.purchase"),
1045
- value: e(I).PURCHASE,
1046
- disabled: !e(h).locationOptionsTypePurchase.value.length,
1047
- sublabel: e(h).locationOptionsTypePurchase.value.length ? void 0 : e(l)("inventory.transfer.form.noSupplierAvailable")
1048
- },
1049
- {
1050
- label: e(l)("inventory.transfer.form.type.transfer"),
1051
- value: e(I).TRANSFER,
1052
- disabled: !e(h).locationOptionsTypeTransfer.value.length,
1053
- sublabel: e(h).locationOptionsTypeTransfer.value.length ? void 0 : e(l)("inventory.transfer.form.noLocationAvailable")
1054
- }
1055
- ],
1056
- rules: [e(ke)(1)(O.value)]
1057
- }, null, 8, ["label", "model-value", "items", "rules"]),
1058
- k(ye, {
1059
- label: w.value === e(I).PURCHASE ? e(l)("inventory.transfer.form.purchaseFrom") : e(l)("inventory.transfer.form.transferFrom"),
1060
- modelValue: B.value,
1061
- "onUpdate:modelValue": y[1] || (y[1] = (S) => B.value = S),
1062
- items: O.value
1063
- }, null, 8, ["label", "modelValue", "items"]),
1064
- k(ve, {
1065
- label: e(l)("inventory.transfer.form.reference"),
1066
- "label-mark": "optional",
1067
- modelValue: e(t).ref,
1068
- "onUpdate:modelValue": y[2] || (y[2] = (S) => e(t).ref = S)
1069
- }, null, 8, ["label", "modelValue"]),
1070
- k(be, {
1071
- label: e(l)("inventory.transfer.form.remark"),
1072
- "label-mark": "optional",
1073
- "max-length": 240,
1074
- modelValue: X.value,
1075
- "onUpdate:modelValue": y[3] || (y[3] = (S) => X.value = S),
1076
- class: Fe([i.disabled ? "text-fm-color-typo-disabled " : ""])
1077
- }, null, 8, ["label", "modelValue", "class"]),
1078
- e(a).enableBackdatePo ? (P(), $("div", us, [
1079
- d("div", ds, [
1080
- k(ce, {
1081
- modelValue: e(W),
1082
- "onUpdate:modelValue": y[4] || (y[4] = (S) => ie(W) ? W.value = S : null),
1083
- label: e(l)("inventory.transfer.form.backdate.title"),
1084
- sublabel: e(l)("inventory.transfer.form.backdate.subtitle"),
1085
- "label-placement": "right",
1086
- disabled: C.value && !i.lastClosingDate || i.disabled
1087
- }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1088
- y[13] || (y[13] = d("div", { class: "xs:hidden sm:hidden h-48 lg:w-16 md:w-16" }, null, -1)),
1089
- e(W) ? (P(), $("div", cs, [
1090
- d("div", ps, [
1091
- k(D, {
1092
- modelValue: e(K),
1093
- "onUpdate:modelValue": y[5] || (y[5] = (S) => ie(K) ? K.value = S : null)
1094
- }, null, 8, ["modelValue"])
1095
- ]),
1096
- d("div", ms, [
1097
- k(ne, {
1098
- modelValue: e(q),
1099
- "onUpdate:modelValue": y[6] || (y[6] = (S) => ie(q) ? q.value = S : null)
1100
- }, null, 8, ["modelValue"])
1101
- ])
1102
- ])) : H("", !0)
1103
- ]),
1104
- e(U) ? (P(), z(G, {
1105
- key: 0,
1106
- modelValue: e(U),
1107
- "onUpdate:modelValue": y[7] || (y[7] = (S) => ie(U) ? U.value = S : null),
1108
- rules: [e(pt)(new Date(i.lastClosingDate), /* @__PURE__ */ new Date())]
1109
- }, null, 8, ["modelValue", "rules"])) : H("", !0),
1110
- C.value && !i.lastClosingDate ? (P(), $("div", fs, [
1111
- k(Q, {
1112
- name: "error",
1113
- size: "sm",
1114
- class: "text-fm-color-typo-warning"
1115
- }),
1116
- d("span", ys, A(e(l)("inventory.transfer.form.backdate.error")), 1)
1117
- ])) : H("", !0)
1118
- ])) : H("", !0)
1119
- ])
1120
- ]),
1121
- d("div", vs, [
1122
- k(G, {
1123
- "model-value": e(t).items,
1124
- rules: [e(ke)(1)]
1125
- }, null, 8, ["model-value", "rules"]),
1126
- d("div", bs, [
1127
- d("div", _s, A(e(l)("inventory.transfer.form.items.title")), 1),
1128
- d("div", gs, [
1129
- k(ae, {
1130
- disabled: i.disabled,
1131
- label: e(l)("inventory.transfer.form.items.addItem"),
1132
- "prepend-icon": "add",
1133
- variant: "secondary",
1134
- "text-color": "primary",
1135
- "bg-color": "transparent",
1136
- "border-color": "primary",
1137
- onClick: y[8] || (y[8] = (S) => Y()),
1138
- size: "md"
1139
- }, null, 8, ["disabled", "label"]),
1140
- e(t).template ? (P(), z(ee, {
1141
- key: 0,
1142
- "z-index": 50
1143
- }, {
1144
- content: V(() => [
1145
- d("div", null, A(e(l)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1146
- ]),
1147
- default: V(() => [
1148
- k(Be, {
1149
- "onUpdate:poItems": y[9] || (y[9] = (S) => e(t).items = S),
1150
- disabled: ""
1151
- })
1152
- ]),
1153
- _: 1
1154
- })) : (P(), z(Be, {
1155
- key: 1,
1156
- "onUpdate:poItems": y[10] || (y[10] = (S) => e(t).items = S),
1157
- disabled: i.disabled || !!e(t).template
1158
- }, null, 8, ["disabled"]))
1159
- ])
1160
- ]),
1161
- w.value === e(I).PURCHASE && p.value && e(a).enableTotalCost && ((xe = i.modelValue) != null && xe.items.length) ? (P(), $("div", Cs, [
1162
- k(ce, {
1163
- label: e(J) ? e(l)("inventory.transfer.form.items.fetchingData") : e(l)("inventory.transfer.form.items.comparePriceHistory"),
1164
- "prepend-icon": "compare_arrows",
1165
- "label-placement": "right",
1166
- "model-value": e(N),
1167
- "onUpdate:modelValue": y[11] || (y[11] = (S) => ie(N) ? N.value = S : null),
1168
- disabled: e(J) || i.disabled
1169
- }, null, 8, ["label", "model-value", "disabled"])
1170
- ])) : H("", !0),
1171
- (P(), z(_e, {
1172
- "column-defs": oe.value,
1173
- "row-data": e(t).items,
1174
- key: e(t).items.map((S) => S.sku._id).join("."),
1175
- "hide-footer": "",
1176
- "page-size": e(t).items.length
1177
- }, {
1178
- "table-row": V((S) => [
1179
- k(ns, {
1180
- "compare-price-by-sku": e(_),
1181
- "show-compare-price": w.value === e(I).PURCHASE && e(N),
1182
- row: S
1183
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row"])
1184
- ]),
1185
- "list-row": V((S) => [
1186
- (P(), z(vt, {
1187
- row: S,
1188
- key: e(t).items.map((Se) => Se.sku._id).join(".")
1189
- }, {
1190
- default: V((Se) => [
1191
- k(Bt, {
1192
- "compare-price-by-sku": e(_),
1193
- "show-compare-price": w.value === e(I).PURCHASE && e(N),
1194
- row: S,
1195
- "cell-by-col-id": Se
1196
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1197
- ]),
1198
- _: 2
1199
- }, 1032, ["row"]))
1200
- ]),
1201
- _: 1
1202
- }, 8, ["column-defs", "row-data", "page-size"]))
1203
- ])
1204
- ];
1205
- }),
1206
- _: 1
1207
- }, 8, ["disabled", "onValidationFailed"])
1208
- ]);
1209
- };
1210
- }
1211
- }), hs = { class: "flex items-center" }, ws = { class: "fm-typo-en-title-md-800" }, xs = { class: "flex gap-4" }, Us = /* @__PURE__ */ se({
1212
- __name: "TransferDialog",
1213
- props: {
1214
- mode: {},
1215
- modelValue: {},
1216
- templateId: {},
1217
- show: { type: Boolean },
1218
- lastClosingDate: {}
1219
- },
1220
- emits: ["update:show", "submitted"],
1221
- setup(o, { expose: m, emit: r }) {
1222
- var J;
1223
- const n = o, v = r, t = Ee(), l = Ie(), x = he(), c = De(), s = Ae(), { t: a } = de(), f = L(!1), u = L(!1), p = L(!1);
1224
- async function C(_) {
1225
- if (_) {
1226
- u.value = !1;
1227
- try {
1228
- await x.readSuppliers(), u.value = !0;
1229
- } catch {
1230
- l.open({
1231
- title: a("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1232
- message: a("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1233
- type: "error"
1234
- });
1235
- }
1236
- }
1237
- }
1238
- s.watchLocation(C);
1239
- function b() {
1240
- return {
1241
- remark: void 0,
1242
- ref: void 0,
1243
- stockSnapshotId: void 0,
1244
- effectiveAt: void 0,
1245
- items: [],
1246
- supplier: {
1247
- _rev: void 0,
1248
- email: void 0,
1249
- internal: void 0,
1250
- contactName: void 0,
1251
- phoneNumber: void 0,
1252
- registrationNumber: void 0,
1253
- supplyItems: void 0,
1254
- _id: "",
1255
- name: "",
1256
- address: {
1257
- line2: void 0,
1258
- line1: "",
1259
- state: "",
1260
- city: "",
1261
- postcode: "",
1262
- country: ""
1263
- }
1264
- },
1265
- status: "DRAFT",
1266
- _id: "",
1267
- seqNumber: 0,
1268
- deliveryOrder: [],
1269
- template: n.templateId
1270
- };
1271
- }
1272
- const h = Je(n, "show"), w = L(n.modelValue ?? b()), O = L(((J = n.modelValue) == null ? void 0 : J._id) ?? `${Math.random()}`);
1273
- Me(
1274
- () => n.show,
1275
- (_) => {
1276
- var g;
1277
- _ && (p.value = !1, w.value = n.modelValue ?? b(), O.value = ((g = n.modelValue) == null ? void 0 : g._id) ?? `${Math.random()}`);
1278
- }
1279
- );
1280
- const B = F(() => !u.value || !p.value), X = F(() => {
1281
- switch (n.mode) {
1282
- case pe.READ:
1283
- return "View transfer";
1284
- case pe.CREATE:
1285
- return a("inventory.transfer.receiveRequest.create.title");
1286
- case pe.UPDATE:
1287
- return a("inventory.transfer.receiveRequest.update.title");
1288
- }
1289
- return "";
1290
- }), U = L();
1291
- m({
1292
- validateInputs: () => {
1293
- var _, g;
1294
- (g = (_ = U.value) == null ? void 0 : _.validateInputs) == null || g.call(_);
1295
- },
1296
- resetInputsValidation: () => {
1297
- var _, g;
1298
- (g = (_ = U.value) == null ? void 0 : _.resetInputsValidation) == null || g.call(_);
1299
- },
1300
- resetInputs: () => {
1301
- var _, g;
1302
- (g = (_ = U.value) == null ? void 0 : _.resetInputs) == null || g.call(_);
1303
- }
1304
- });
1305
- async function W() {
1306
- const _ = w.value;
1307
- f.value = !0, (_.supplier.internal === "warehouse" || _.supplier.internal === "restaurant") && (_.items = _.items.map(({ totalCost: g, ...M }) => M));
1308
- try {
1309
- await t.createPurchaseOrder(_), await new Promise((g) => setTimeout(g, 1e3)), l.open({
1310
- title: a("inventory.transfer.receiveRequest.create.success"),
1311
- message: a("inventory.transfer.receiveRequest.create.successMessage"),
1312
- type: "success"
1313
- }), v("update:show", !1), v("submitted");
1314
- } catch (g) {
1315
- l.open({
1316
- title: a("inventory.transfer.receiveRequest.create.error.title"),
1317
- message: a("inventory.transfer.receiveRequest.create.error.message"),
1318
- type: "error"
1319
- }), console.error("Error in creating purchase order", g);
1320
- } finally {
1321
- f.value = !1;
1322
- }
1323
- }
1324
- async function K() {
1325
- const _ = w.value;
1326
- f.value = !0, (_.supplier.internal === "warehouse" || _.supplier.internal === "restaurant") && (_.items = _.items.map(({ totalCost: g, ...M }) => M));
1327
- try {
1328
- await t.updatePurchaseOrder(_), await new Promise((g) => setTimeout(g, 1e3)), l.open({
1329
- title: a("inventory.transfer.receiveRequest.update.success"),
1330
- message: a("inventory.transfer.receiveRequest.update.successMessage"),
1331
- type: "success"
1332
- }), v("update:show", !1), v("submitted");
1333
- } catch (g) {
1334
- l.open({
1335
- title: a("inventory.transfer.receiveRequest.update.error.title"),
1336
- message: a("inventory.transfer.receiveRequest.update.error.message"),
1337
- type: "error"
1338
- }), console.error("Error in updating purchase order", g);
1339
- } finally {
1340
- f.value = !1;
1341
- }
1342
- }
1343
- function q() {
1344
- switch (n.mode) {
1345
- case pe.CREATE:
1346
- return W();
1347
- case pe.UPDATE:
1348
- return K();
1349
- }
1350
- }
1351
- function N() {
1352
- var _, g;
1353
- (g = (_ = U.value) == null ? void 0 : _.validateInputs) == null || g.call(_);
1354
- }
1355
- return (_, g) => {
1356
- const M = T("FmButton"), oe = T("FmSideSheet");
1357
- return P(), z(oe, {
1358
- modelValue: e(h),
1359
- "onUpdate:modelValue": g[3] || (g[3] = (Y) => ie(h) ? h.value = Y : null),
1360
- "dismiss-away": "",
1361
- "close-button": "",
1362
- "max-width": 900
1363
- }, {
1364
- "side-sheet-header": V(() => [
1365
- d("div", hs, [
1366
- d("div", ws, A(X.value), 1)
1367
- ])
1368
- ]),
1369
- default: V(() => [
1370
- (P(), z(ks, {
1371
- class: "w-full",
1372
- ref_key: "formRef",
1373
- ref: U,
1374
- "onForm:ready": g[0] || (g[0] = () => p.value = !0),
1375
- onValidationSuccess: q,
1376
- modelValue: w.value,
1377
- "onUpdate:modelValue": g[1] || (g[1] = (Y) => w.value = Y),
1378
- disabled: f.value || B.value,
1379
- suppliers: e(x).suppliers,
1380
- skus: e(c).skus,
1381
- key: O.value,
1382
- "last-closing-date": _.lastClosingDate
1383
- }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1384
- ]),
1385
- "side-sheet-footer": V(() => [
1386
- d("div", xs, [
1387
- k(M, {
1388
- loading: f.value,
1389
- disabled: B.value,
1390
- label: e(a)("common.save"),
1391
- onClick: N
1392
- }, null, 8, ["loading", "disabled", "label"]),
1393
- k(M, {
1394
- disabled: B.value,
1395
- variant: "tertiary",
1396
- label: e(a)("common.close"),
1397
- onClick: g[2] || (g[2] = (Y) => v("update:show", !1))
1398
- }, null, 8, ["disabled", "label"])
1399
- ])
1400
- ]),
1401
- _: 1
1402
- }, 8, ["modelValue"]);
1403
- };
1404
- }
1405
- });
1406
- export {
1407
- Us as _,
1408
- te as c
1409
- };