@feedmepos/mf-inventory-portal 0.0.22-dev.1 → 0.0.22-dev.10

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 (76) hide show
  1. package/dist/App.vue.d.ts +2 -0
  2. package/dist/{ApprovalView-CtH8I01g.js → ApprovalView-FwJEAzkU.js} +19 -19
  3. package/dist/{BindingsDialog-DFrk_fyd.js → BindingsDialog-DFLnNDpl.js} +1 -1
  4. package/dist/{BindingsPicker-400gISaV.js → BindingsPicker-Dsd2wQUR.js} +19 -19
  5. package/dist/{BindingsTable-CnFKI6iP.js → BindingsTable-CTvUEEjT.js} +1 -1
  6. package/dist/ClosingTemplateView-CPbDZmei.js +1066 -0
  7. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-B9RU_arW.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-MW-Ni07p.js} +13 -15
  8. package/dist/{IngredientsView-CRTAgKJz.js → IngredientsView-C07TvvCQ.js} +5 -6
  9. package/dist/{IntegrationView-CNFTKqjk.js → IntegrationView-BAnrTgio.js} +2 -2
  10. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-VkiVLx1K.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-YAjDfJ_v.js} +1 -1
  11. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DkZrgqyr.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CvzA5XrI.js} +1 -1
  12. package/dist/{PurchaseOrderPrintPreview-CJli-_Vn.js → PurchaseOrderPrintPreview-FiOxyAL2.js} +1 -1
  13. package/dist/{ReceiveRequestView-DV_GDzJG.js → ReceiveRequestView-BTZ_99LY.js} +15 -16
  14. package/dist/{RecipeView-CTm_7oNG.js → RecipeView-BTRlXuIp.js} +3 -3
  15. package/dist/{StockView-DtHT2ulM.js → StockView-B50nZjP-.js} +8 -9
  16. package/dist/{SupplierView-B9A5R2Vm.js → SupplierView-CYEdoZ7g.js} +37 -37
  17. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CMMMgbwA.js +762 -0
  18. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-BKmp6Emq.js +1505 -0
  19. package/dist/TransferTemplateView-DJYoQWDE.js +1277 -0
  20. package/dist/{UnitView-BL-jtVuZ.js → UnitView-Cg9lop9G.js} +4 -4
  21. package/dist/WarehouseView-DQKq_W8l.js +1017 -0
  22. package/dist/api/closing-template.d.ts +14 -0
  23. package/dist/api/inventory.d.ts +5 -7
  24. package/dist/api/netsuite.d.ts +46 -0
  25. package/dist/api/purchase-order-template.d.ts +0 -4
  26. package/dist/{app-C-z1MfF6.js → app-CRbOk4dN.js} +15759 -15399
  27. package/dist/app.d.ts +6 -0
  28. package/dist/app.js +2 -2
  29. package/dist/components/FmMultiselectDialogProps.d.ts +1 -0
  30. package/dist/components/VirtualScroll.vue.d.ts +47 -0
  31. package/dist/{decimal-DZz-_lgE.js → decimal-BrFW4i9P.js} +1 -1
  32. package/dist/{defineDeepModel-7VQajdPt.js → defineDeepModel-Dihj57Tu.js} +4 -4
  33. package/dist/extensions/promises.d.ts +14 -0
  34. package/dist/{format-time-from-id-9XFszs1J.js → format-time-from-id-CAMmsTAi.js} +1 -1
  35. package/dist/helper/date2.d.ts +1 -0
  36. package/dist/{id-to-date-Bkue77uI.js → id-to-date-CLOPCZAL.js} +1 -1
  37. package/dist/purchase-order-transaction-type-C6B_s24N.js +676 -0
  38. package/dist/stores/api.d.ts +1 -0
  39. package/dist/stores/feature.d.ts +0 -1
  40. package/dist/stores/helper/core-store-proxy.d.ts +3 -0
  41. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  42. package/dist/stores/inventory.d.ts +7 -0
  43. package/dist/stores/location.d.ts +24 -42
  44. package/dist/stores/netsuite.d.ts +56 -0
  45. package/dist/stores/route.d.ts +0 -5
  46. package/dist/stores/warehouse.d.ts +4 -7
  47. package/dist/style.css +1 -1
  48. package/dist/{supplier-C6YWXF2Y.js → supplier-CQ57ob8j.js} +1 -1
  49. package/dist/tsconfig.app.tsbuildinfo +1 -1
  50. package/dist/use-template-enabled-locations-2-D5I1uMwS.js +85 -0
  51. package/dist/views/closing-template/components/closing-template-publish/ClosingTemplatePublish.vue.d.ts +6 -0
  52. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +276 -84
  53. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +341 -85
  54. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +14 -0
  55. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +42 -0
  56. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +42 -0
  57. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +13 -0
  58. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +4 -7
  59. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +2 -2
  60. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +132 -84
  61. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +44 -1014
  62. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +251 -0
  63. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -14
  64. package/dist/{xlsx-Dl6dAHFx.js → xlsx-WWSZpgZu.js} +1 -1
  65. package/dist/{xlsx.util-C1tUhDb8.js → xlsx.util-DjCdSP8D.js} +2 -2
  66. package/package.json +5 -5
  67. package/dist/ClosingTemplateView--8m8cua_.js +0 -919
  68. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-mUNCQTNw.js +0 -740
  69. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-BwkUuXqj.js +0 -1428
  70. package/dist/TransferTemplateView-DnyenkGu.js +0 -1349
  71. package/dist/WarehouseView-BkUv1792.js +0 -1056
  72. package/dist/array-ClJzD_Lt.js +0 -30
  73. package/dist/layout/InventoryLayout.vue.d.ts +0 -2
  74. package/dist/layout/layout-routes.d.ts +0 -6
  75. package/dist/purchase-order-transaction-type-DHzMBgFs.js +0 -712
  76. package/dist/use-template-enabled-locations-CFCfbaOd.js +0 -57
@@ -1,1428 +0,0 @@
1
- import { reactive as We, onMounted as Ue, computed as T, h as E, defineComponent as se, openBlock as P, createElementBlock as A, Fragment as ve, renderList as Te, createElementVNode as d, toDisplayString as D, unref as e, resolveComponent as I, createVNode as k, withCtx as V, createCommentVNode as z, ref as L, createBlock as j, watch as Me, normalizeClass as Ie, normalizeStyle as Ye, isRef as ie } from "vue";
2
- import { useBreakpoints as Ze, components as re, FmButtonVariant as Qe, useSnackbar as $e, useDialog as Ke, useProxiedModel as Ge } from "@feedmepos/ui-library";
3
- import { F as fe } from "./row-action.enum-PMKMRrZR.js";
4
- import { P as $, d as Ee, c as Je } from "./purchase-order-transaction-type-DHzMBgFs.js";
5
- import { a as W, t as Xe, a8 as Fe, 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 Ae, P as He, aa as lt, j as De, ab as rt, u as Ve, ac as it, ad as ut, ae as dt, E as ct, af as pt, y as mt } from "./app-C-z1MfF6.js";
6
- import { _ as ze, u as ft } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-DkZrgqyr.js";
7
- import { useI18n as de } from "@feedmepos/mf-common";
8
- import "vue-router";
9
- import { u as he } from "./supplier-C6YWXF2Y.js";
10
- import { d as yt } from "./defineDeepModel-7VQajdPt.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, f, r, n) {
14
- var u, c, C;
15
- if (n != null && n.manualTotalCost)
16
- return n == null ? void 0 : n.manualTotalCost;
17
- const v = (C = (c = (u = n == null ? void 0 : n.supplier) == null ? void 0 : u.supplyItems) == null ? void 0 : c.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, p = x ? l != null && l.measurement ? +W(x) / +W(l == null ? void 0 : l.measurement.conversion) : +W(x) : void 0, s = p ? r ? p * +W(r.conversion) : p : void 0, a = s ? +W(f) * s : void 0;
20
- return a ? {
21
- ...Xe(a ?? 0, 2),
22
- currency: Fe()
23
- } : {
24
- amount: 0,
25
- precision: 0,
26
- currency: Fe()
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: f } = de(), r = We({}), { breakpoints: n } = Ze(), v = Le();
43
- Ue(() => {
44
- for (const p of o.items) {
45
- if (!p.totalCost)
46
- continue;
47
- const s = te(p.sku, p.quantity, p.measurement, {
48
- supplier: o.supplier
49
- }), a = p.totalCost ?? et.reset();
50
- s ? r[p.sku._id] = s.amount !== a.amount || s.precision !== a.precision : r[p.sku._id] = !0;
51
- }
52
- });
53
- function t(p) {
54
- var a, y, u, c, C, b, h;
55
- return !!(((y = (a = p.defaultCost) == null ? void 0 : a.costPerUnit) == null ? void 0 : y.amount) ?? ((h = (b = (C = (c = (u = o.supplier) == null ? void 0 : u.supplyItems) == null ? void 0 : c.find((w) => w.skuId === p._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: () => f("inventory.transfer.form.items.table.Code"),
61
- accessorKey: "code",
62
- size: 96,
63
- cell(p) {
64
- const s = p.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: () => f("inventory.transfer.form.items.table.Name"),
83
- minSize: 300,
84
- cell(p) {
85
- const s = p.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: () => f("inventory.transfer.form.items.table.Amount"),
104
- minSize: 200,
105
- cell(p) {
106
- var y, u, c;
107
- const s = p.row.original, a = (c = (u = (y = o.template) == null ? void 0 : y.purchaseOrder) == null ? void 0 : u.items) == null ? void 0 : c.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
- +W(
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
- +W(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(p) {
160
- const s = p.row.original, a = t(s.sku), y = 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
- y ? qe(
193
- te(s.sku, s.quantity, s.measurement, {
194
- supplier: o.supplier
195
- })
196
- ) : W(
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
- f("inventory.transfer.form.items.autoCalculated")
211
- )
212
- ]
213
- )
214
- ]
215
- ) : E(
216
- re.FmTextField,
217
- {
218
- modelValue: W(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: Fe()
226
- }
227
- });
228
- },
229
- rules: [ke(0), at(2)]
230
- },
231
- {
232
- prepend() {
233
- return y ? 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(p) {
270
- const s = p.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: T(() => v.enableTotalCost && o.transferType === $.PURCHASE ? l : l.filter(
294
- (p) => p.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 f = he();
306
- function r(n) {
307
- return f.suppliers.find((v) => v._id === n);
308
- }
309
- return (n, v) => (P(), A("div", Ct, [
310
- (P(!0), A(ve, null, Te(Object.keys(n.prices), (t) => {
311
- var l;
312
- return P(), A("div", {
313
- key: t,
314
- class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
315
- }, [
316
- d("div", kt, D((l = r(t)) == null ? void 0 : l.name), 1),
317
- d("div", ht, [
318
- (P(!0), A(ve, null, Te(n.prices[t].slice(0, 3), (x) => {
319
- var p;
320
- return P(), A("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, D(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, D(e(W)(x.totalUnit, !1)), 1),
328
- d("span", null, D(((p = x.measurement) == null ? void 0 : p.abbrev) ?? x.unit.abbrev), 1)
329
- ]),
330
- d("div", xt, [
331
- d("span", null, "(#" + D(x.seqNumber) + ")", 1),
332
- v[1] || (v[1] = d("span", null, D(" "), -1)),
333
- d("span", null, D(e(Ae)(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" }, Tt = { class: "flex-1 flex gap-1 items-center" }, It = { 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" }, $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: f } = de();
355
- return (r, n) => {
356
- var l, x, p, s, a, y, u, c, C, b, h, w, O, B, J, U, Y, K, N, H, G, _, g, M, oe, Z, we;
357
- const v = I("FmLabel"), t = I("FmSpacer");
358
- return P(), A("div", St, [
359
- d("div", Pt, [
360
- d("div", Tt, [
361
- d("span", It, " (" + D(r.row.original.sku.code) + ") ", 1),
362
- d("span", Ft, D(r.row.original.sku.name), 1)
363
- ]),
364
- d("div", null, [
365
- k(e(ue), {
366
- render: (p = (x = (l = r.cellByColId.Delete) == null ? void 0 : l.column) == null ? void 0 : x.columnDef) == null ? void 0 : p.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(f)(`inventory.transfer.form.items.table.${e(R).Code}`)
375
- }, null, 8, ["label"]),
376
- k(e(ue), {
377
- render: (c = (u = (y = r.cellByColId[e(R).Code]) == null ? void 0 : y.column) == null ? void 0 : u.columnDef) == null ? void 0 : c.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(f)(`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: (J = (B = r.cellByColId[e(R).Name]) == null ? void 0 : B.getContext) == null ? void 0 : J.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(f)(`inventory.transfer.form.items.table.${e(R).Amount}`)
397
- }, null, 8, ["label"]),
398
- k(e(ue), {
399
- render: (K = (Y = (U = r.cellByColId[e(R).Amount]) == null ? void 0 : U.column) == null ? void 0 : Y.columnDef) == null ? void 0 : K.cell,
400
- props: (H = (N = r.cellByColId[e(R).Amount]) == null ? void 0 : N.getContext) == null ? void 0 : H.call(N)
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(), A("div", Ot, [
405
- k(ze, { "z-index": 50 }, {
406
- default: V(() => [
407
- k(v, {
408
- label: e(f)(`inventory.transfer.form.items.table.${e(R).Cost}2`)
409
- }, null, 8, ["label"])
410
- ]),
411
- _: 1
412
- }),
413
- k(e(ue), {
414
- render: (g = (_ = (G = r.cellByColId[e(R).Cost]) == null ? void 0 : G.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
- ])) : z("", !0)
419
- ]),
420
- r.showComparePrice && Object.keys(r.comparePriceBySku[(Z = r.row.original.sku) == null ? void 0 : Z._id] ?? {}).length > 0 ? (P(), A(ve, { 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)) : z("", !0)
426
- ]);
427
- };
428
- }
429
- });
430
- function ye(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, f) {
446
- const r = he(), n = De(), v = T(() => !n.businessLevel);
447
- n.watchLocation(async () => {
448
- await r.readSuppliers();
449
- const u = o();
450
- if (u.supplier._id) return;
451
- const c = 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
- f({
453
- ...u,
454
- supplier: c ? ye(c) : b ? Ce(b) : u.supplier
455
- });
456
- });
457
- const t = T(
458
- () => {
459
- var u, c;
460
- return typeof ((c = (u = o()) == null ? void 0 : u.supplier) == null ? void 0 : c.internal) == "string" ? $.TRANSFER : $.PURCHASE;
461
- }
462
- ), l = T({
463
- get() {
464
- var u, c;
465
- return (c = (u = o()) == null ? void 0 : u.supplier) == null ? void 0 : c._id;
466
- },
467
- set(u) {
468
- const c = o() ?? {};
469
- if (t.value === $.PURCHASE) {
470
- const O = (n.businessLevel ? r.businessSuppliers : r.suppliers).find((B) => B._id === u);
471
- f({
472
- ...c,
473
- supplier: O ? ye(O) : c.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
- f({
479
- ...c,
480
- supplier: h ? Ce(h) : c.supplier
481
- });
482
- }
483
- }), x = T(() => r.locationSuppliers.map(ye)), p = T(() => r.businessSuppliers.map(ye)), s = T(() => {
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 = T(() => {
488
- if (t.value === $.PURCHASE) {
489
- const c = x.value.map((b) => ({
490
- label: b.name,
491
- value: b._id
492
- })), C = p.value.map((b) => ({
493
- label: b.name,
494
- sublabel: "Business supplier",
495
- value: b._id
496
- }));
497
- return n.businessLevel ? C : [...c, ...C];
498
- }
499
- return s.value.map((c) => ({
500
- label: c.name,
501
- sublabel: c.internal ? `${c.internal}` : void 0,
502
- value: c._id
503
- }));
504
- }), y = T(() => {
505
- var b, h;
506
- const u = (h = (b = o()) == null ? void 0 : b.supplier) == null ? void 0 : h._id;
507
- if (t.value === $.PURCHASE) {
508
- const w = r.suppliers.find((O) => O._id === u);
509
- return w ? ye(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: y
520
- };
521
- }
522
- function Mt(o) {
523
- const f = T({
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 = T({
532
- get() {
533
- return !!f.value;
534
- },
535
- set(t) {
536
- t ? f.value = /* @__PURE__ */ new Date() : f.value = null;
537
- }
538
- }), n = T({
539
- get() {
540
- return f.value === null ? "" : Ae(f.value);
541
- },
542
- set(t) {
543
- t ? f.value = /* @__PURE__ */ new Date(`${t} ${v.value}`) : f.value = null;
544
- }
545
- }), v = T({
546
- get() {
547
- return f.value === null ? "" : rt(f.value);
548
- },
549
- set(t) {
550
- t ? f.value = /* @__PURE__ */ new Date(`${n.value} ${t}`) : f.value = null;
551
- }
552
- });
553
- return {
554
- backdatePo: f,
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 (f, r) => (P(), A("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" }, Gt = { class: "flex items-start gap-8" }, Jt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Xt = { 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: f }) {
611
- const r = f, n = L(!1), v = L(7), t = ft(), l = $e(), x = Ve(), { t: p } = 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: p("inventory.transfer.form.items.forecastStock.notAvailable"),
620
- type: "info"
621
- });
622
- return;
623
- }
624
- const y = t.purchaseOrderForecast.skus.reduce((u, c) => {
625
- const C = x.skus.find((w) => w._id === c.id);
626
- if (u.find((w) => w.sku._id === c.id) || !C)
627
- return u;
628
- const h = {
629
- sku: C,
630
- code: C.code,
631
- name: C.name,
632
- quantity: {
633
- amount: c.amount,
634
- precision: 0
635
- }
636
- };
637
- return u.push(h), u;
638
- }, a);
639
- r("update:poItems", y);
640
- }
641
- return (a, y) => {
642
- const u = I("FmButton"), c = I("FmIcon"), C = I("FmStepperField"), b = I("FmPopover");
643
- return P(), j(b, {
644
- disabled: a.disabled,
645
- class: "flex",
646
- "show-popover": n.value,
647
- onPopoverChanged: y[3] || (y[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, D(e(p)("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, D(e(p)("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: y[0] || (y[0] = (h) => n.value = !1)
686
- })
687
- ]),
688
- k(C, {
689
- modelValue: v.value,
690
- "onUpdate:modelValue": y[1] || (y[1] = (h) => v.value = h),
691
- label: e(p)("inventory.transfer.form.items.forecastStock.days"),
692
- rules: [e(ke)(1)]
693
- }, {
694
- "helper-text": V(() => [
695
- d("div", Gt, [
696
- k(c, {
697
- name: "warning",
698
- size: "sm",
699
- class: "text-fm-color-system-warning-300"
700
- }),
701
- d("div", Jt, D(e(p)("inventory.transfer.form.items.forecastStock.replace")), 1)
702
- ])
703
- ]),
704
- _: 1
705
- }, 8, ["modelValue", "label", "rules"]),
706
- d("div", Xt, [
707
- y[4] || (y[4] = d("div", { class: "grow" }, null, -1)),
708
- k(u, {
709
- label: e(p)("common.cancel"),
710
- variant: "tertiary",
711
- onClick: y[2] || (y[2] = (h) => n.value = !1)
712
- }, null, 8, ["label"]),
713
- k(u, {
714
- label: e(p)("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 = $e(), f = 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 f.getPurchaseOrders({ start: l, end: x })).filter(
735
- (y) => {
736
- var u, c;
737
- return y.status === ut.enum.COMPLETE && ((u = y.supplier) == null ? void 0 : u.internal) !== "warehouse" && ((c = y.supplier) == null ? void 0 : c.internal) !== "restaurant";
738
- }
739
- ).reduce((y, u) => {
740
- const c = new Date(dt(u._id)), C = u.supplier._id;
741
- for (const b of u.items) {
742
- if (!b.totalCost) continue;
743
- const h = y[b.sku._id] ?? {}, w = h[C] ?? [];
744
- w.push({
745
- date: c.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, y[b.sku._id] = h;
752
- }
753
- return y;
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 f(r) {
779
- return r.column.columnDef.meta;
780
- }
781
- return (r, n) => {
782
- var v, t;
783
- return P(), A(ve, null, [
784
- d("tr", {
785
- class: Ie(["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), A(ve, null, Te(r.row.getVisibleCells(), (l) => {
790
- var x, p, s, a;
791
- return P(), A("td", {
792
- key: l.id,
793
- class: Ie([
794
- "h-[52px] px-16 text-fm-color-typo-primary",
795
- ((x = f(l)) == null ? void 0 : x.cellClass) ?? "px-16"
796
- ]),
797
- style: Ye({
798
- width: (p = f(l)) == null ? void 0 : p.width,
799
- maxWidth: (s = f(l)) == null ? void 0 : s.maxWidth,
800
- textAlign: ((a = f(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(), A("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
- ])) : z("", !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: f, emit: r }) {
847
- const n = o, v = r, t = yt(), { t: l } = de(), x = De(), p = Ve(), s = he(), a = Le(), y = Je(), u = T(
848
- () => y.templates.value.find((i) => i._id === t.template)
849
- ), c = T(() => t.status === "DRAFT" || !t._rev);
850
- Ue(async () => {
851
- var i;
852
- try {
853
- if (!t.template) return;
854
- await y.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 = T(
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 = T({
871
- get() {
872
- var i;
873
- return typeof ((i = t == null ? void 0 : t.supplier) == null ? void 0 : i.internal) == "string" ? $.TRANSFER : $.PURCHASE;
874
- },
875
- set(i) {
876
- var q;
877
- const m = typeof ((q = t == null ? void 0 : t.supplier) == null ? void 0 : q.internal) == "string" ? $.TRANSFER : $.PURCHASE;
878
- i !== m && (t.supplier = i === $.PURCHASE ? h.locationOptionsTypePurchase.value[0] : h.locationOptionsTypeTransfer.value[0]);
879
- }
880
- }), O = T(() => h.transferLocationOptions.value), B = T({
881
- get() {
882
- return t.supplier._id;
883
- },
884
- set(i) {
885
- h.transferLocationModel.value = i;
886
- }
887
- }), J = T({
888
- get() {
889
- return t.remark ?? void 0;
890
- },
891
- set(i) {
892
- t.remark = i;
893
- }
894
- }), { backdatePo: U, backdateSwitch: Y, backdateModel: K, backdateTimeModel: N } = Mt({
895
- getEffectiveAt() {
896
- return t.effectiveAt;
897
- },
898
- setEffectiveAt(i) {
899
- t.effectiveAt = i;
900
- }
901
- }), { comparePricesToggle: H, comparePriceFetching: G, comparePriceBySku: _ } = es(), g = L();
902
- f({
903
- validateInputs: () => {
904
- var i, m;
905
- (m = (i = g.value) == null ? void 0 : i.validateInputs) == null || m.call(i);
906
- },
907
- resetInputsValidation: () => {
908
- var i, m;
909
- (m = (i = g.value) == null ? void 0 : i.resetInputsValidation) == null || m.call(i);
910
- },
911
- resetInputs: () => {
912
- var i, m;
913
- (m = (i = g.value) == null ? void 0 : i.resetInputs) == null || m.call(i);
914
- }
915
- });
916
- const M = gt({
917
- updateItem: (i) => {
918
- t.items = t.items.map((m) => m.sku._id !== i.sku._id ? m : i);
919
- },
920
- deleteItem: (i) => {
921
- t.items = t.items.filter((m) => m.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 = T(() => M.columnDefs.value);
939
- function Z() {
940
- var be, pe, _e;
941
- let i;
942
- ((F) => {
943
- F.IsInTemplate = "IsInTemplate", F.IsOutsideTemplate = "IsOutsideTemplate";
944
- })(i || (i = {}));
945
- const m = [
946
- {
947
- id: "IsInTemplate",
948
- label: l("inventory.transfer.form.items.fromTemplate.title")
949
- },
950
- {
951
- id: "IsOutsideTemplate",
952
- label: l("inventory.transfer.form.items.other.title"),
953
- sublabel: "These options are not selectable, and the items are managed in template.",
954
- collapse: !0,
955
- disabled: !0
956
- }
957
- ], q = new Set((_e = (pe = (be = u.value) == null ? void 0 : be.purchaseOrder) == null ? void 0 : pe.items) == null ? void 0 : _e.map((F) => F.sku._id)), ce = p.skus.map(
958
- (F) => ({
959
- label: F.name,
960
- sublabel: F.code,
961
- value: F,
962
- disabled: !!(q.size && !q.has(F._id)),
963
- groupId: q.has(F._id) ? "IsInTemplate" : "IsOutsideTemplate"
964
- /* IsOutsideTemplate */
965
- })
966
- ), xe = ce.filter((F) => {
967
- var X;
968
- return (X = t.items) == null ? void 0 : X.find((ne) => ne.sku._id === F.value._id);
969
- }).map((F) => F.value);
970
- b.open({
971
- title: l("inventory.transfer.form.items.selectItem"),
972
- closeButton: !0,
973
- contentComponent: mt,
974
- contentComponentProps: {
975
- modelValue: xe,
976
- items: ce,
977
- groups: q.size ? m : void 0
978
- },
979
- primaryActions: {
980
- text: l("common.confirm"),
981
- close: !0
982
- },
983
- secondaryActions: {
984
- text: l("common.close"),
985
- close: !0,
986
- variant: "tertiary"
987
- }
988
- }).onPrimary((F) => {
989
- const X = t.items ?? [], ne = F.map((Q) => {
990
- var ge, me;
991
- const ae = X.find((le) => le.sku._id === Q._id);
992
- if (ae)
993
- return ae;
994
- const ee = ((me = (ge = u.value) == null ? void 0 : ge.purchaseOrder.items) == null ? void 0 : me.find(
995
- (le) => le.sku._id === Q._id
996
- )) ?? {
997
- sku: Q,
998
- code: Q.code,
999
- name: Q.name,
1000
- quantity: {
1001
- amount: 1,
1002
- precision: 0
1003
- }
1004
- };
1005
- return w.value == $.PURCHASE && (ee.totalCost = te(
1006
- ee.sku,
1007
- ee.quantity,
1008
- ee.measurement,
1009
- {
1010
- supplier: t.supplier
1011
- }
1012
- )), ee;
1013
- });
1014
- ne.sort((Q, ae) => Q.sku.code.localeCompare(ae.sku.code)), t.items = ne;
1015
- });
1016
- }
1017
- function we(i) {
1018
- return i;
1019
- }
1020
- return (i, m) => {
1021
- var me, le;
1022
- const q = I("FmChip"), ce = I("FmSelect"), xe = I("FmTextField"), be = I("FmTextarea"), pe = I("FmSwitch"), _e = I("FmDatePicker"), F = I("FmTimePicker"), X = I("FmFormGroup"), ne = I("FmIcon"), Q = I("FmButton"), ae = I("FmTooltip"), ee = I("FmTable"), ge = I("FmForm");
1023
- return P(), A("div", as, [
1024
- d("div", ls, [
1025
- (me = n.modelValue) != null && me.template ? (P(), j(q, {
1026
- key: 0,
1027
- variant: i.disabled ? "warning" : void 0,
1028
- label: `${e(l)("inventory.transfer.template.title")}: ${((le = u.value) == null ? void 0 : le.name) ?? e(l)("inventory.transfer.form.loading")}`,
1029
- icon: "summarize",
1030
- compact: ""
1031
- }, null, 8, ["variant", "label"])) : z("", !0),
1032
- k(q, {
1033
- label: e(x).currentLocation.name,
1034
- icon: "storefront",
1035
- compact: ""
1036
- }, null, 8, ["label"]),
1037
- i.lastClosingDate ? (P(), j(q, {
1038
- key: 1,
1039
- label: `${e(l)("inventory.transfer.form.lastClosing")}: ${e(Ae)(i.lastClosingDate)} ${e(ct)(i.lastClosingDate)}`,
1040
- icon: "calendar_month",
1041
- compact: ""
1042
- }, null, 8, ["label"])) : z("", !0)
1043
- ]),
1044
- k(ge, {
1045
- ref_key: "formRef",
1046
- ref: g,
1047
- class: "flex flex-col gap-32",
1048
- disabled: i.disabled,
1049
- onValidationFailed: console.log,
1050
- onValidationSuccess: m[12] || (m[12] = (Se) => v("validation-success"))
1051
- }, {
1052
- default: V(() => {
1053
- var Se;
1054
- return [
1055
- d("div", rs, [
1056
- d("div", is, [
1057
- k(ce, {
1058
- label: e(l)("inventory.transfer.form.type.title"),
1059
- "model-value": w.value,
1060
- "onUpdate:modelValue": m[0] || (m[0] = (S) => w.value = S),
1061
- items: [
1062
- {
1063
- label: e(l)("inventory.transfer.form.type.purchase"),
1064
- value: e($).PURCHASE,
1065
- disabled: !e(h).locationOptionsTypePurchase.value.length,
1066
- sublabel: e(h).locationOptionsTypePurchase.value.length ? void 0 : e(l)("inventory.transfer.form.noSupplierAvailable")
1067
- },
1068
- {
1069
- label: e(l)("inventory.transfer.form.type.transfer"),
1070
- value: e($).TRANSFER,
1071
- disabled: !e(h).locationOptionsTypeTransfer.value.length,
1072
- sublabel: e(h).locationOptionsTypeTransfer.value.length ? void 0 : e(l)("inventory.transfer.form.noLocationAvailable")
1073
- }
1074
- ],
1075
- rules: [e(ke)(1)(O.value)]
1076
- }, null, 8, ["label", "model-value", "items", "rules"]),
1077
- k(ce, {
1078
- label: w.value === e($).PURCHASE ? e(l)("inventory.transfer.form.purchaseFrom") : e(l)("inventory.transfer.form.transferFrom"),
1079
- modelValue: B.value,
1080
- "onUpdate:modelValue": m[1] || (m[1] = (S) => B.value = S),
1081
- items: O.value
1082
- }, null, 8, ["label", "modelValue", "items"]),
1083
- k(xe, {
1084
- label: e(l)("inventory.transfer.form.reference"),
1085
- "label-mark": "optional",
1086
- modelValue: e(t).ref,
1087
- "onUpdate:modelValue": m[2] || (m[2] = (S) => e(t).ref = S)
1088
- }, null, 8, ["label", "modelValue"]),
1089
- k(be, {
1090
- label: e(l)("inventory.transfer.form.remark"),
1091
- "label-mark": "optional",
1092
- "max-length": 240,
1093
- modelValue: J.value,
1094
- "onUpdate:modelValue": m[3] || (m[3] = (S) => J.value = S),
1095
- class: Ie([i.disabled ? "text-fm-color-typo-disabled " : ""])
1096
- }, null, 8, ["label", "modelValue", "class"]),
1097
- e(a).enableBackdatePo ? (P(), A("div", us, [
1098
- d("div", ds, [
1099
- k(pe, {
1100
- modelValue: e(Y),
1101
- "onUpdate:modelValue": m[4] || (m[4] = (S) => ie(Y) ? Y.value = S : null),
1102
- label: e(l)("inventory.transfer.form.backdate.title"),
1103
- sublabel: e(l)("inventory.transfer.form.backdate.subtitle"),
1104
- "label-placement": "right",
1105
- disabled: C.value && !i.lastClosingDate || i.disabled
1106
- }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1107
- m[13] || (m[13] = d("div", { class: "xs:hidden sm:hidden h-48 lg:w-16 md:w-16" }, null, -1)),
1108
- e(Y) ? (P(), A("div", cs, [
1109
- d("div", ps, [
1110
- k(_e, {
1111
- modelValue: e(K),
1112
- "onUpdate:modelValue": m[5] || (m[5] = (S) => ie(K) ? K.value = S : null)
1113
- }, null, 8, ["modelValue"])
1114
- ]),
1115
- d("div", ms, [
1116
- k(F, {
1117
- modelValue: e(N),
1118
- "onUpdate:modelValue": m[6] || (m[6] = (S) => ie(N) ? N.value = S : null)
1119
- }, null, 8, ["modelValue"])
1120
- ])
1121
- ])) : z("", !0)
1122
- ]),
1123
- e(U) ? (P(), j(X, {
1124
- key: 0,
1125
- modelValue: e(U),
1126
- "onUpdate:modelValue": m[7] || (m[7] = (S) => ie(U) ? U.value = S : null),
1127
- rules: [e(pt)(new Date(i.lastClosingDate), /* @__PURE__ */ new Date())]
1128
- }, null, 8, ["modelValue", "rules"])) : z("", !0),
1129
- C.value && !i.lastClosingDate ? (P(), A("div", fs, [
1130
- k(ne, {
1131
- name: "error",
1132
- size: "sm",
1133
- class: "text-fm-color-typo-warning"
1134
- }),
1135
- d("span", ys, D(e(l)("inventory.transfer.form.backdate.error")), 1)
1136
- ])) : z("", !0)
1137
- ])) : z("", !0)
1138
- ])
1139
- ]),
1140
- d("div", vs, [
1141
- k(X, {
1142
- "model-value": e(t).items,
1143
- rules: [e(ke)(1)]
1144
- }, null, 8, ["model-value", "rules"]),
1145
- d("div", bs, [
1146
- d("div", _s, D(e(l)("inventory.transfer.form.items.title")), 1),
1147
- d("div", gs, [
1148
- k(Q, {
1149
- disabled: i.disabled,
1150
- label: e(l)("inventory.transfer.form.items.addItem"),
1151
- "prepend-icon": "add",
1152
- variant: "secondary",
1153
- "text-color": "primary",
1154
- "bg-color": "transparent",
1155
- "border-color": "primary",
1156
- onClick: m[8] || (m[8] = (S) => Z()),
1157
- size: "md"
1158
- }, null, 8, ["disabled", "label"]),
1159
- e(t).template ? (P(), j(ae, {
1160
- key: 0,
1161
- "z-index": 50
1162
- }, {
1163
- content: V(() => [
1164
- d("div", null, D(e(l)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1165
- ]),
1166
- default: V(() => [
1167
- k(Be, {
1168
- "onUpdate:poItems": m[9] || (m[9] = (S) => e(t).items = S),
1169
- disabled: ""
1170
- })
1171
- ]),
1172
- _: 1
1173
- })) : (P(), j(Be, {
1174
- key: 1,
1175
- "onUpdate:poItems": m[10] || (m[10] = (S) => e(t).items = S),
1176
- disabled: i.disabled || !!e(t).template
1177
- }, null, 8, ["disabled"]))
1178
- ])
1179
- ]),
1180
- w.value === e($).PURCHASE && c.value && e(a).enableTotalCost && ((Se = i.modelValue) != null && Se.items.length) ? (P(), A("div", Cs, [
1181
- k(pe, {
1182
- label: e(G) ? e(l)("inventory.transfer.form.items.fetchingData") : e(l)("inventory.transfer.form.items.comparePriceHistory"),
1183
- "prepend-icon": "compare_arrows",
1184
- "label-placement": "right",
1185
- "model-value": e(H),
1186
- "onUpdate:modelValue": m[11] || (m[11] = (S) => ie(H) ? H.value = S : null),
1187
- disabled: e(G) || i.disabled
1188
- }, null, 8, ["label", "model-value", "disabled"])
1189
- ])) : z("", !0),
1190
- (P(), j(ee, {
1191
- "column-defs": oe.value,
1192
- "row-data": e(t).items,
1193
- key: e(t).items.map((S) => S.sku._id).join("."),
1194
- "hide-footer": "",
1195
- "page-size": e(t).items.length
1196
- }, {
1197
- "table-row": V((S) => [
1198
- k(ns, {
1199
- "compare-price-by-sku": e(_),
1200
- "show-compare-price": w.value === e($).PURCHASE && e(H),
1201
- row: S
1202
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row"])
1203
- ]),
1204
- "list-row": V((S) => [
1205
- (P(), j(vt, {
1206
- row: S,
1207
- key: e(t).items.map((Pe) => Pe.sku._id).join(".")
1208
- }, {
1209
- default: V((Pe) => [
1210
- k(Bt, {
1211
- "compare-price-by-sku": e(_),
1212
- "show-compare-price": w.value === e($).PURCHASE && e(H),
1213
- row: S,
1214
- "cell-by-col-id": Pe
1215
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1216
- ]),
1217
- _: 2
1218
- }, 1032, ["row"]))
1219
- ]),
1220
- _: 1
1221
- }, 8, ["column-defs", "row-data", "page-size"]))
1222
- ])
1223
- ];
1224
- }),
1225
- _: 1
1226
- }, 8, ["disabled", "onValidationFailed"])
1227
- ]);
1228
- };
1229
- }
1230
- }), hs = { class: "flex items-center" }, ws = { class: "fm-typo-en-title-md-800" }, xs = { class: "flex gap-4" }, Us = /* @__PURE__ */ se({
1231
- __name: "TransferDialog",
1232
- props: {
1233
- mode: {},
1234
- modelValue: {},
1235
- templateId: {},
1236
- show: { type: Boolean },
1237
- lastClosingDate: {}
1238
- },
1239
- emits: ["update:show", "submitted"],
1240
- setup(o, { expose: f, emit: r }) {
1241
- var G;
1242
- const n = o, v = r, t = Ee(), l = $e(), x = he(), p = Ve(), s = De(), { t: a } = de(), y = L(!1), u = L(!1), c = L(!1);
1243
- async function C(_) {
1244
- if (_) {
1245
- u.value = !1;
1246
- try {
1247
- await x.readSuppliers(), u.value = !0;
1248
- } catch {
1249
- l.open({
1250
- title: a("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1251
- message: a("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1252
- type: "error"
1253
- });
1254
- }
1255
- }
1256
- }
1257
- s.watchLocation(C);
1258
- function b() {
1259
- return {
1260
- remark: void 0,
1261
- ref: void 0,
1262
- stockSnapshotId: void 0,
1263
- effectiveAt: void 0,
1264
- items: [],
1265
- supplier: {
1266
- _rev: void 0,
1267
- email: void 0,
1268
- internal: void 0,
1269
- contactName: void 0,
1270
- phoneNumber: void 0,
1271
- registrationNumber: void 0,
1272
- supplyItems: void 0,
1273
- _id: "",
1274
- name: "",
1275
- address: {
1276
- line2: void 0,
1277
- line1: "",
1278
- state: "",
1279
- city: "",
1280
- postcode: "",
1281
- country: ""
1282
- }
1283
- },
1284
- status: "DRAFT",
1285
- _id: "",
1286
- seqNumber: 0,
1287
- deliveryOrder: [],
1288
- template: n.templateId
1289
- };
1290
- }
1291
- const h = Ge(n, "show"), w = L(n.modelValue ?? b()), O = L(((G = n.modelValue) == null ? void 0 : G._id) ?? `${Math.random()}`);
1292
- Me(
1293
- () => n.show,
1294
- (_) => {
1295
- var g;
1296
- _ && (c.value = !1, w.value = n.modelValue ?? b(), O.value = ((g = n.modelValue) == null ? void 0 : g._id) ?? `${Math.random()}`);
1297
- }
1298
- );
1299
- const B = T(() => !u.value || !c.value), J = T(() => {
1300
- switch (n.mode) {
1301
- case fe.READ:
1302
- return "View transfer";
1303
- case fe.CREATE:
1304
- return a("inventory.transfer.receiveRequest.create.title");
1305
- case fe.UPDATE:
1306
- return a("inventory.transfer.receiveRequest.update.title");
1307
- }
1308
- return "";
1309
- }), U = L();
1310
- f({
1311
- validateInputs: () => {
1312
- var _, g;
1313
- (g = (_ = U.value) == null ? void 0 : _.validateInputs) == null || g.call(_);
1314
- },
1315
- resetInputsValidation: () => {
1316
- var _, g;
1317
- (g = (_ = U.value) == null ? void 0 : _.resetInputsValidation) == null || g.call(_);
1318
- },
1319
- resetInputs: () => {
1320
- var _, g;
1321
- (g = (_ = U.value) == null ? void 0 : _.resetInputs) == null || g.call(_);
1322
- }
1323
- });
1324
- async function Y() {
1325
- const _ = w.value;
1326
- y.value = !0, (_.supplier.internal === "warehouse" || _.supplier.internal === "restaurant") && (_.items = _.items.map(({ totalCost: g, ...M }) => M));
1327
- try {
1328
- await t.createPurchaseOrder(_), await new Promise((g) => setTimeout(g, 1e3)), l.open({
1329
- title: a("inventory.transfer.receiveRequest.create.success"),
1330
- message: a("inventory.transfer.receiveRequest.create.successMessage"),
1331
- type: "success"
1332
- }), v("update:show", !1), v("submitted");
1333
- } catch (g) {
1334
- l.open({
1335
- title: a("inventory.transfer.receiveRequest.create.error.title"),
1336
- message: a("inventory.transfer.receiveRequest.create.error.message"),
1337
- type: "error"
1338
- }), console.error("Error in creating purchase order", g);
1339
- } finally {
1340
- y.value = !1;
1341
- }
1342
- }
1343
- async function K() {
1344
- const _ = w.value;
1345
- y.value = !0, (_.supplier.internal === "warehouse" || _.supplier.internal === "restaurant") && (_.items = _.items.map(({ totalCost: g, ...M }) => M));
1346
- try {
1347
- await t.updatePurchaseOrder(_), await new Promise((g) => setTimeout(g, 1e3)), l.open({
1348
- title: a("inventory.transfer.receiveRequest.update.success"),
1349
- message: a("inventory.transfer.receiveRequest.update.successMessage"),
1350
- type: "success"
1351
- }), v("update:show", !1), v("submitted");
1352
- } catch (g) {
1353
- l.open({
1354
- title: a("inventory.transfer.receiveRequest.update.error.title"),
1355
- message: a("inventory.transfer.receiveRequest.update.error.message"),
1356
- type: "error"
1357
- }), console.error("Error in updating purchase order", g);
1358
- } finally {
1359
- y.value = !1;
1360
- }
1361
- }
1362
- function N() {
1363
- switch (n.mode) {
1364
- case fe.CREATE:
1365
- return Y();
1366
- case fe.UPDATE:
1367
- return K();
1368
- }
1369
- }
1370
- function H() {
1371
- var _, g;
1372
- (g = (_ = U.value) == null ? void 0 : _.validateInputs) == null || g.call(_);
1373
- }
1374
- return (_, g) => {
1375
- const M = I("FmButton"), oe = I("FmSideSheet");
1376
- return P(), j(oe, {
1377
- modelValue: e(h),
1378
- "onUpdate:modelValue": g[3] || (g[3] = (Z) => ie(h) ? h.value = Z : null),
1379
- "dismiss-away": "",
1380
- "close-button": "",
1381
- "max-width": 900
1382
- }, {
1383
- "side-sheet-header": V(() => [
1384
- d("div", hs, [
1385
- d("div", ws, D(J.value), 1)
1386
- ])
1387
- ]),
1388
- default: V(() => [
1389
- (P(), j(ks, {
1390
- class: "w-full",
1391
- ref_key: "formRef",
1392
- ref: U,
1393
- "onForm:ready": g[0] || (g[0] = () => c.value = !0),
1394
- onValidationSuccess: N,
1395
- modelValue: w.value,
1396
- "onUpdate:modelValue": g[1] || (g[1] = (Z) => w.value = Z),
1397
- disabled: y.value || B.value,
1398
- suppliers: e(x).suppliers,
1399
- skus: e(p).skus,
1400
- key: O.value,
1401
- "last-closing-date": _.lastClosingDate
1402
- }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1403
- ]),
1404
- "side-sheet-footer": V(() => [
1405
- d("div", xs, [
1406
- k(M, {
1407
- loading: y.value,
1408
- disabled: B.value,
1409
- label: e(a)("common.save"),
1410
- onClick: H
1411
- }, null, 8, ["loading", "disabled", "label"]),
1412
- k(M, {
1413
- disabled: B.value,
1414
- variant: "tertiary",
1415
- label: e(a)("common.close"),
1416
- onClick: g[2] || (g[2] = (Z) => v("update:show", !1))
1417
- }, null, 8, ["disabled", "label"])
1418
- ])
1419
- ]),
1420
- _: 1
1421
- }, 8, ["modelValue"]);
1422
- };
1423
- }
1424
- });
1425
- export {
1426
- Us as _,
1427
- te as c
1428
- };