@feedmepos/mf-inventory-portal 0.0.22-dev.3 → 0.0.22-dev.31

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 (79) hide show
  1. package/dist/App.vue.d.ts +2 -0
  2. package/dist/{ApprovalView-BnkFRJgX.js → ApprovalView-DURCoP6_.js} +26 -26
  3. package/dist/{BindingsDialog-BDzmf8Wr.js → BindingsDialog-Cgf5MuLY.js} +1 -1
  4. package/dist/{BindingsPicker-CRGFd-d8.js → BindingsPicker-DvcjRma9.js} +8 -8
  5. package/dist/{BindingsTable-BnHju77G.js → BindingsTable-BPrs04hn.js} +1 -1
  6. package/dist/ClosingTemplateView-DU_OX_KS.js +1072 -0
  7. package/dist/Entry.vue.d.ts +0 -2
  8. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BRV9dZhu.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BNhYJdT-.js} +8 -8
  9. package/dist/IngredientsView-BGB-So1n.js +1817 -0
  10. package/dist/{IntegrationView-UySDEAnh.js → IntegrationView-tOw9GGXr.js} +120 -120
  11. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Cxy6vo9D.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CWz2vOzD.js} +1 -1
  12. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-ChrCZc0C.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Qqp3wJ2n.js} +1 -1
  13. package/dist/{PurchaseOrderPrintPreview-CGxMILW0.js → PurchaseOrderPrintPreview-PnIeMMrq.js} +1 -1
  14. package/dist/{ReceiveRequestView-BHOC-ZLV.js → ReceiveRequestView-WjoI68r_.js} +20 -21
  15. package/dist/RecipeView-B2KynG4H.js +590 -0
  16. package/dist/{StockView-BcXcQZpl.js → StockView-DsutlmVn.js} +602 -585
  17. package/dist/{SupplierView-Bl13ZM-9.js → SupplierView-BuyFY-tF.js} +108 -108
  18. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BoGGbhJi.js +858 -0
  19. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-8yMFTCo1.js +1678 -0
  20. package/dist/TransferTemplateView-BSn-HKWr.js +1232 -0
  21. package/dist/{UnitView-DG8PGv5Y.js → UnitView-Bx-dS9Nv.js} +6 -6
  22. package/dist/{WarehouseView-CeS8jrgw.js → WarehouseView-DpMvmi_A.js} +17 -17
  23. package/dist/api/inventory.d.ts +72 -85
  24. package/dist/api/netsuite.d.ts +47 -0
  25. package/dist/api/purchase-order-template.d.ts +0 -4
  26. package/dist/{app-DYhspC_r.js → app-B6CTWYqZ.js} +21877 -20978
  27. package/dist/app.d.ts +7 -0
  28. package/dist/app.js +3 -3
  29. package/dist/components/FmFilterableMenuOptions.vue.d.ts +54 -0
  30. package/dist/components/FmMinMaxInputRules.d.ts +2 -0
  31. package/dist/components/FmUnitInputRules.d.ts +2 -0
  32. package/dist/{decimal-DwEh3AcZ.js → decimal-DDNJiEl8.js} +1 -1
  33. package/dist/{defineDeepModel-htf7zxRR.js → defineDeepModel-CjoZrLbV.js} +3 -3
  34. package/dist/{format-time-from-id-1BxShIsX.js → format-time-from-id-CNRJtPZY.js} +3 -3
  35. package/dist/helper/rules.d.ts +7 -0
  36. package/dist/helper/rules.spec.d.ts +1 -0
  37. package/dist/{id-to-date-CzSDsYm2.js → id-to-date-DJcRYNGy.js} +1 -1
  38. package/dist/purchase-order-transaction-type-Cew6w60I.js +678 -0
  39. package/dist/stores/api.d.ts +1 -0
  40. package/dist/stores/feature.d.ts +0 -1
  41. package/dist/stores/helper/core-store-proxy.d.ts +3 -0
  42. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  43. package/dist/stores/inventory.d.ts +22 -0
  44. package/dist/stores/location.d.ts +420 -504
  45. package/dist/stores/netsuite.d.ts +68 -0
  46. package/dist/stores/route.d.ts +0 -5
  47. package/dist/stores/warehouse.d.ts +4 -7
  48. package/dist/style.css +1 -1
  49. package/dist/{supplier-DegAxD_n.js → supplier-bvsRMnxk.js} +1 -1
  50. package/dist/tsconfig.app.tsbuildinfo +1 -1
  51. package/dist/use-template-enabled-locations-2-DSlNJ-VP.js +85 -0
  52. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +1080 -1020
  53. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +1080 -1020
  54. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
  55. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +1854 -0
  56. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -0
  57. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +2329 -286
  58. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +2213 -170
  59. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +13 -0
  60. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +71 -85
  61. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +39 -2
  62. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1253 -1457
  63. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +420 -1474
  64. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +230 -0
  65. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -14
  66. package/dist/{xlsx-CSS2klUs.js → xlsx-CnMhXCRI.js} +1 -1
  67. package/dist/{xlsx.util-CeY18XxV.js → xlsx.util-CV-IkG_3.js} +2 -2
  68. package/package.json +7 -7
  69. package/dist/ClosingTemplateView-D2EIa9YG.js +0 -1030
  70. package/dist/IngredientsView-CiUpjKmC.js +0 -1759
  71. package/dist/RecipeView-lgrm1J9x.js +0 -581
  72. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-SXFiNrtm.js +0 -740
  73. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DSBEn-Mt.js +0 -1409
  74. package/dist/TransferTemplateView-C_eqQ9a8.js +0 -1230
  75. package/dist/array-ClJzD_Lt.js +0 -30
  76. package/dist/layout/InventoryLayout.vue.d.ts +0 -2
  77. package/dist/layout/layout-routes.d.ts +0 -6
  78. package/dist/purchase-order-transaction-type-lwIoC03T.js +0 -712
  79. package/dist/use-template-enabled-locations-B2ZtZAoX.js +0 -57
@@ -0,0 +1,1678 @@
1
+ import { reactive as lt, onMounted as je, computed as I, h as N, defineComponent as oe, openBlock as w, createElementBlock as V, Fragment as se, renderList as Ie, createElementVNode as d, toDisplayString as R, unref as t, resolveComponent as T, createVNode as b, withCtx as D, createCommentVNode as H, ref as j, createBlock as q, watch as Re, normalizeClass as z, normalizeStyle as Qe, mergeModels as nt, useModel as at, mergeProps as rt, isRef as ye } from "vue";
2
+ import { useBreakpoints as We, components as fe, FmButtonVariant as it, useSnackbar as Me, useDialog as ut, useProxiedModel as dt } from "@feedmepos/ui-library";
3
+ import { F as ke } from "./row-action.enum-PMKMRrZR.js";
4
+ import { P as O, d as Ye, c as ct } from "./purchase-order-transaction-type-Cew6w60I.js";
5
+ import { a as Z, t as pt, ab as Oe, E as mt, b as Ze, R as He, a5 as ft, a7 as yt, s as vt, a8 as qe, a6 as bt, H as Ke, m as gt, A as Te, M as ht, ac as Je, P as Be, Q as Xe, ad as _t, j as Ue, ae as kt, u as Ee, af as Ct, ag as xt, ah as wt, ai as De, G as St, aj as Ft, ak as Pt, z as It } from "./app-B6CTWYqZ.js";
6
+ import { _ as Ge, u as Tt } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-Qqp3wJ2n.js";
7
+ import { useI18n as ge } from "@feedmepos/mf-common";
8
+ import "vue-router";
9
+ import { u as $e } from "./supplier-bvsRMnxk.js";
10
+ import { d as Vt } from "./defineDeepModel-CjoZrLbV.js";
11
+ import { F as ve, _ as $t } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
12
+ import { _ as At } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
13
+ function de(i, p, o, n) {
14
+ var _, F, y;
15
+ if (n != null && n.manualTotalCost)
16
+ return n == null ? void 0 : n.manualTotalCost;
17
+ const a = (y = (F = (_ = n == null ? void 0 : n.supplier) == null ? void 0 : _.supplyItems) == null ? void 0 : F.find(
18
+ (f) => f.skuId === i._id
19
+ )) == null ? void 0 : y.defaultCost, e = i.defaultCost, s = a ?? e, m = s == null ? void 0 : s.costPerUnit, c = m ? s != null && s.measurement ? +Z(m) / +Z(s == null ? void 0 : s.measurement.conversion) : +Z(m) : void 0, l = c ? o ? c * +Z(o.conversion) : c : void 0, r = l ? +Z(p) * l : void 0;
20
+ return r ? {
21
+ ...pt(r ?? 0, 2),
22
+ currency: Oe()
23
+ } : {
24
+ amount: 0,
25
+ precision: 0,
26
+ currency: Oe()
27
+ };
28
+ }
29
+ var E = /* @__PURE__ */ ((i) => (i.Code = "Code", i.Name = "Name", i.Amount = "Amount", i.Cost = "Cost", i.Delete = "Delete", i))(E || {});
30
+ const Dt = () => {
31
+ const { t: i } = ge();
32
+ return N(
33
+ Ge,
34
+ {
35
+ zIndex: 50,
36
+ class: "whitespace-nowrap"
37
+ },
38
+ i("inventory.transfer.form.items.table.Cost", [Je()])
39
+ );
40
+ };
41
+ function Ot(i) {
42
+ const { t: p } = ge(), o = lt({}), { breakpoints: n } = We(), a = Ze();
43
+ je(() => {
44
+ for (const c of i.items) {
45
+ if (!c.totalCost)
46
+ continue;
47
+ const l = de(c.sku, c.quantity, c.measurement, {
48
+ supplier: i.supplier
49
+ }), r = c.totalCost ?? mt.reset();
50
+ l ? o[c.sku._id] = l.amount !== r.amount || l.precision !== r.precision : o[c.sku._id] = !0;
51
+ }
52
+ });
53
+ function e(c) {
54
+ var r, v, _, F, y, f, S;
55
+ return !!(((v = (r = c.defaultCost) == null ? void 0 : r.costPerUnit) == null ? void 0 : v.amount) ?? ((S = (f = (y = (F = (_ = i.supplier) == null ? void 0 : _.supplyItems) == null ? void 0 : F.find((C) => C.skuId === c._id)) == null ? void 0 : y.defaultCost) == null ? void 0 : f.costPerUnit) == null ? void 0 : S.amount));
56
+ }
57
+ const s = [
58
+ {
59
+ id: "Code",
60
+ header: () => p("inventory.transfer.form.items.table.Code"),
61
+ accessorKey: "code",
62
+ size: 96,
63
+ cell(c) {
64
+ const l = c.row.original;
65
+ return N(fe.FmTextField, {
66
+ modelValue: l.code,
67
+ "onUpdate:modelValue": (r) => {
68
+ i.updateItem({
69
+ ...l,
70
+ code: r
71
+ });
72
+ },
73
+ key: l.sku._id,
74
+ rules: [He()],
75
+ labelMark: "required"
76
+ });
77
+ },
78
+ enableSorting: !1
79
+ },
80
+ {
81
+ id: "Name",
82
+ header: () => p("inventory.transfer.form.items.table.Name"),
83
+ minSize: 300,
84
+ cell(c) {
85
+ const l = c.row.original;
86
+ return N(fe.FmTextField, {
87
+ modelValue: l.name,
88
+ "onUpdate:modelValue": (r) => {
89
+ i.updateItem({
90
+ ...l,
91
+ name: r
92
+ });
93
+ },
94
+ key: l.sku._id,
95
+ rules: [He()],
96
+ labelMark: "required"
97
+ });
98
+ },
99
+ enableSorting: !1
100
+ },
101
+ {
102
+ id: "Amount",
103
+ header: () => p("inventory.transfer.form.items.table.Amount"),
104
+ minSize: 200,
105
+ cell(c) {
106
+ var v, _, F;
107
+ const l = c.row.original, r = (F = (_ = (v = i.template) == null ? void 0 : v.purchaseOrder) == null ? void 0 : _.items) == null ? void 0 : F.find(
108
+ (y) => y.sku._id === l.sku._id
109
+ );
110
+ return N(ft, {
111
+ style: {
112
+ flex: "1 1 0%"
113
+ },
114
+ modelValue: {
115
+ amount: l.quantity ?? { amount: 1, precision: 0 },
116
+ measurement: l.measurement ?? null
117
+ },
118
+ key: l.sku._id,
119
+ unit: l.sku.unit,
120
+ "onUpdate:modelValue": (y) => {
121
+ const f = {
122
+ ...l,
123
+ quantity: y.amount,
124
+ measurement: y.measurement
125
+ };
126
+ a.enableTotalCost && (f.totalCost = de(l.sku, l.quantity, l.measurement, {
127
+ supplier: i.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: o[l.sku._id] ? f.totalCost : void 0
131
+ })), i.updateItem(f);
132
+ },
133
+ stepper: r == null ? void 0 : r.quantityStep,
134
+ disableUnit: !!r,
135
+ disabled: i.disabled,
136
+ rules: [
137
+ yt(
138
+ +Z(
139
+ (r == null ? void 0 : r.minimumQuantity) ?? {
140
+ amount: 1,
141
+ precision: vt(l.sku.unit, l.measurement)
142
+ }
143
+ )
144
+ ),
145
+ r != null && r.maximumQuantity ? qe(
146
+ +Z(r == null ? void 0 : r.maximumQuantity)
147
+ ) : qe(1 / 0),
148
+ ...r != null && r.quantityStep ? [bt(r.quantityStep)] : []
149
+ ],
150
+ applyDefaultRules: !0
151
+ });
152
+ },
153
+ enableSorting: !1
154
+ },
155
+ {
156
+ id: "Cost",
157
+ header: Dt,
158
+ size: 180,
159
+ cell(c) {
160
+ const l = c.row.original, r = e(l.sku), v = n.value.xs || n.value.sm;
161
+ return !o[l.sku._id] && r ? N(
162
+ "div",
163
+ {
164
+ class: [
165
+ "flex gap-4 fm-typo-en-body-md-400 items-center",
166
+ i.disabled ? "text-fm-color-typo-disabled" : ""
167
+ ],
168
+ key: l.sku._id
169
+ },
170
+ [
171
+ N(fe.FmButton, {
172
+ prependIcon: "edit",
173
+ variant: it.Tertiary,
174
+ disabled: i.disabled,
175
+ onClick() {
176
+ i.updateItem({
177
+ ...l,
178
+ totalCost: de(l.sku, l.quantity, l.measurement, {
179
+ supplier: i.supplier
180
+ })
181
+ }), o[l.sku._id] = !0;
182
+ }
183
+ }),
184
+ N(
185
+ "div",
186
+ {
187
+ class: "flex flex-col"
188
+ },
189
+ [
190
+ N(
191
+ "span",
192
+ v ? Ke(
193
+ de(l.sku, l.quantity, l.measurement, {
194
+ supplier: i.supplier
195
+ })
196
+ ) : Z(
197
+ de(l.sku, l.quantity, l.measurement, {
198
+ supplier: i.supplier
199
+ })
200
+ )
201
+ ),
202
+ N(
203
+ "span",
204
+ {
205
+ class: [
206
+ "fm-typo-en-body-sm-400",
207
+ i.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
208
+ ]
209
+ },
210
+ p("inventory.transfer.form.items.autoCalculated")
211
+ )
212
+ ]
213
+ )
214
+ ]
215
+ ) : N(
216
+ fe.FmTextField,
217
+ {
218
+ modelValue: Z(l.totalCost ?? { amount: 0, precision: 0 }),
219
+ key: l.sku._id,
220
+ "onUpdate:modelValue": (_) => {
221
+ i.updateItem({
222
+ ...l,
223
+ totalCost: {
224
+ ...gt(+_),
225
+ currency: Oe()
226
+ }
227
+ });
228
+ },
229
+ rules: [Te(0), ht(2)]
230
+ },
231
+ {
232
+ prepend() {
233
+ return v ? N(
234
+ "div",
235
+ {
236
+ class: [
237
+ "text-fm-typo-en-body-lg-400",
238
+ i.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
239
+ ]
240
+ },
241
+ Je()
242
+ ) : null;
243
+ },
244
+ append() {
245
+ return r ? N(fe.FmButton, {
246
+ prependIcon: "close",
247
+ variant: "tertiary",
248
+ disabled: i.disabled,
249
+ onClick() {
250
+ i.updateItem({
251
+ ...l,
252
+ // NOTE: different from PO template, if a default cost is reenabled,
253
+ // the total cost will automatically assigned
254
+ totalCost: de(l.sku, l.quantity, l.measurement, {
255
+ supplier: i.supplier
256
+ })
257
+ }), o[l.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 l = c.row.original;
271
+ return N(fe.FmButton, {
272
+ key: l.sku._id,
273
+ class: "delete-button",
274
+ type: "button",
275
+ icon: "delete",
276
+ variant: "tertiary",
277
+ size: "md",
278
+ disabled: i.disabled,
279
+ onClick: () => {
280
+ i.deleteItem(l);
281
+ }
282
+ });
283
+ },
284
+ enableSorting: !1,
285
+ size: 40,
286
+ meta: {
287
+ cellClass: "",
288
+ headerClass: ""
289
+ }
290
+ }
291
+ ];
292
+ return {
293
+ columnDefs: I(() => a.enableTotalCost && i.transferType === O.PURCHASE ? s : s.filter(
294
+ (c) => c.id !== "Cost"
295
+ /* Cost */
296
+ ))
297
+ };
298
+ }
299
+ const Rt = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Mt = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, Bt = { class: "w-[450px] xs:w-full flex" }, Ut = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Et = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, et = /* @__PURE__ */ oe({
300
+ __name: "SupplierPriceHistory",
301
+ props: {
302
+ prices: {}
303
+ },
304
+ setup(i) {
305
+ const p = $e();
306
+ function o(n) {
307
+ return p.suppliers.find((a) => a._id === n);
308
+ }
309
+ return (n, a) => (w(), V("div", Rt, [
310
+ (w(!0), V(se, null, Ie(Object.keys(n.prices), (e) => {
311
+ var s;
312
+ return w(), V("div", {
313
+ key: e,
314
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
315
+ }, [
316
+ d("div", Mt, R((s = o(e)) == null ? void 0 : s.name), 1),
317
+ d("div", Bt, [
318
+ (w(!0), V(se, null, Ie(n.prices[e].slice(0, 3), (m) => {
319
+ var c;
320
+ return w(), V("div", {
321
+ key: m.date,
322
+ class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
323
+ }, [
324
+ d("div", Ut, [
325
+ d("span", null, R(m.totalCost ? t(Ke)(m.totalCost) : "No data"), 1),
326
+ a[0] || (a[0] = d("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
327
+ d("span", null, R(t(Z)(m.totalUnit, !1)), 1),
328
+ d("span", null, R(((c = m.measurement) == null ? void 0 : c.abbrev) ?? m.unit.abbrev), 1)
329
+ ]),
330
+ d("div", Et, [
331
+ d("span", null, "(#" + R(m.seqNumber) + ")", 1),
332
+ a[1] || (a[1] = d("span", null, R(" "), -1)),
333
+ d("span", null, R(t(Be)(new Date(m.date))), 1)
334
+ ])
335
+ ]);
336
+ }), 128))
337
+ ])
338
+ ]);
339
+ }), 128))
340
+ ]));
341
+ }
342
+ }), Lt = { class: "flex flex-col gap-8 py-16" }, Nt = { class: "flex items-center" }, Ht = { class: "flex-1 flex gap-1 items-center" }, qt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, zt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, jt = { class: "flex gap-8 w-full" }, Qt = { class: "flex-1 flex flex-col gap-4" }, Wt = { class: "flex-1 flex flex-col gap-4" }, Yt = { class: "flex gap-8 w-full" }, Zt = { class: "flex-1 flex flex-col gap-4" }, Kt = {
343
+ key: 0,
344
+ class: "flex-1 flex flex-col gap-4"
345
+ }, Jt = /* @__PURE__ */ oe({
346
+ __name: "TransferItem",
347
+ props: {
348
+ cellByColId: {},
349
+ comparePriceBySku: {},
350
+ showComparePrice: { type: Boolean },
351
+ row: {}
352
+ },
353
+ setup(i) {
354
+ const { t: p } = ge();
355
+ return (o, n) => {
356
+ var s, m, c, l, r, v, _, F, y, f, S, C, B, P, A, U, X, le, G, K, Q, h, k, M, ne, W, ae;
357
+ const a = T("FmLabel"), e = T("FmSpacer");
358
+ return w(), V("div", Lt, [
359
+ d("div", Nt, [
360
+ d("div", Ht, [
361
+ d("span", qt, " (" + R(o.row.original.sku.code) + ") ", 1),
362
+ d("span", zt, R(o.row.original.sku.name), 1)
363
+ ]),
364
+ d("div", null, [
365
+ b(t(ve), {
366
+ render: (c = (m = (s = o.cellByColId.Delete) == null ? void 0 : s.column) == null ? void 0 : m.columnDef) == null ? void 0 : c.cell,
367
+ props: (r = (l = o.cellByColId.Delete) == null ? void 0 : l.getContext) == null ? void 0 : r.call(l)
368
+ }, null, 8, ["render", "props"])
369
+ ])
370
+ ]),
371
+ d("div", jt, [
372
+ d("div", Qt, [
373
+ b(a, {
374
+ label: t(p)(`inventory.transfer.form.items.table.${t(E).Code}`)
375
+ }, null, 8, ["label"]),
376
+ b(t(ve), {
377
+ render: (F = (_ = (v = o.cellByColId[t(E).Code]) == null ? void 0 : v.column) == null ? void 0 : _.columnDef) == null ? void 0 : F.cell,
378
+ props: (f = (y = o.cellByColId[t(E).Code]) == null ? void 0 : y.getContext) == null ? void 0 : f.call(y)
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", Wt, [
383
+ b(a, {
384
+ label: t(p)(`inventory.transfer.form.items.table.${t(E).Name}`)
385
+ }, null, 8, ["label"]),
386
+ b(t(ve), {
387
+ render: (B = (C = (S = o.cellByColId[t(E).Name]) == null ? void 0 : S.column) == null ? void 0 : C.columnDef) == null ? void 0 : B.cell,
388
+ props: (A = (P = o.cellByColId[t(E).Name]) == null ? void 0 : P.getContext) == null ? void 0 : A.call(P)
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", Yt, [
394
+ d("div", Zt, [
395
+ b(a, {
396
+ label: t(p)(`inventory.transfer.form.items.table.${t(E).Amount}`)
397
+ }, null, 8, ["label"]),
398
+ b(t(ve), {
399
+ render: (le = (X = (U = o.cellByColId[t(E).Amount]) == null ? void 0 : U.column) == null ? void 0 : X.columnDef) == null ? void 0 : le.cell,
400
+ props: (K = (G = o.cellByColId[t(E).Amount]) == null ? void 0 : G.getContext) == null ? void 0 : K.call(G)
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
+ o.cellByColId[t(E).Cost] ? (w(), V("div", Kt, [
405
+ b(Ge, { "z-index": 50 }, {
406
+ default: D(() => [
407
+ b(a, {
408
+ label: t(p)(`inventory.transfer.form.items.table.${t(E).Cost}2`)
409
+ }, null, 8, ["label"])
410
+ ]),
411
+ _: 1
412
+ }),
413
+ b(t(ve), {
414
+ render: (k = (h = (Q = o.cellByColId[t(E).Cost]) == null ? void 0 : Q.column) == null ? void 0 : h.columnDef) == null ? void 0 : k.cell,
415
+ props: (ne = (M = o.cellByColId[t(E).Cost]) == null ? void 0 : M.getContext) == null ? void 0 : ne.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
+ o.showComparePrice && Object.keys(o.comparePriceBySku[(W = o.row.original.sku) == null ? void 0 : W._id] ?? {}).length > 0 ? (w(), V(se, { key: 0 }, [
421
+ b(e, { class: "h-8" }),
422
+ b(et, {
423
+ prices: o.comparePriceBySku[(ae = o.row.original.sku) == null ? void 0 : ae._id]
424
+ }, null, 8, ["prices"])
425
+ ], 64)) : H("", !0)
426
+ ]);
427
+ };
428
+ }
429
+ });
430
+ function Ce(i) {
431
+ return _t.parse(i);
432
+ }
433
+ function Pe(i) {
434
+ return {
435
+ _id: i.doc._id,
436
+ internal: i.type,
437
+ contactName: i.doc.profile.name,
438
+ name: i.doc.profile.name ?? "",
439
+ email: i.doc.profile.email,
440
+ phoneNumber: i.doc.profile.phoneNo,
441
+ registrationNumber: i.doc.profile.regNo,
442
+ address: i.doc.profile.address ?? {
443
+ line1: "",
444
+ state: "",
445
+ city: "",
446
+ postcode: "",
447
+ country: ""
448
+ }
449
+ };
450
+ }
451
+ function Xt(i, p, o = !1, n = !1) {
452
+ const a = $e(), e = Ue();
453
+ e.watchLocation(async () => {
454
+ var B;
455
+ await a.readSuppliers();
456
+ const y = i();
457
+ if ((B = y.supplier) != null && B._id) return;
458
+ const f = n ? a.suppliers[0] : a.businessSuppliers[0], C = (o ? e.locations.filter((P) => P.doc._id !== e.currentLocation.doc._id) : e.locations)[0];
459
+ p({
460
+ ...y,
461
+ supplier: f ? Ce(f) : C ? Pe(C) : y.supplier
462
+ });
463
+ });
464
+ const s = I(
465
+ () => {
466
+ var y, f;
467
+ return typeof ((f = (y = i()) == null ? void 0 : y.supplier) == null ? void 0 : f.internal) == "string" ? O.TRANSFER : O.PURCHASE;
468
+ }
469
+ ), m = I({
470
+ get() {
471
+ var y, f;
472
+ return (f = (y = i()) == null ? void 0 : y.supplier) == null ? void 0 : f._id;
473
+ },
474
+ set(y) {
475
+ const f = i() ?? {};
476
+ if (s.value === O.PURCHASE) {
477
+ const A = (n ? a.suppliers : a.businessSuppliers).find((U) => U._id === y);
478
+ p({
479
+ ...f,
480
+ supplier: A ? Ce(A) : f.supplier
481
+ });
482
+ return;
483
+ }
484
+ const B = (o ? e.locations.filter((P) => P.doc._id !== e.currentLocation.doc._id) : e.locations).find((P) => P.doc._id === y);
485
+ p({
486
+ ...f,
487
+ supplier: B ? Pe(B) : f.supplier
488
+ });
489
+ }
490
+ }), c = I(() => a.locationSuppliers.map(Ce)), l = I(() => a.businessSuppliers.map(Ce)), r = I(() => {
491
+ const y = [...c.value], f = [...l.value];
492
+ return n ? [...f, ...y] : f;
493
+ }), v = I(() => {
494
+ var S;
495
+ const y = ((S = e._currentLocation) == null ? void 0 : S.type) === Xe.warehouse;
496
+ return (o ? e.locations.filter((C) => C.doc._id !== e.currentLocation.doc._id) : e.locations).filter((C) => y || C.acceptRequest).map(Pe);
497
+ }), _ = I(() => {
498
+ if (s.value === O.PURCHASE) {
499
+ const f = c.value.map((C) => ({
500
+ label: C.name,
501
+ value: C._id
502
+ })), S = l.value.map((C) => ({
503
+ label: C.name,
504
+ sublabel: "Business supplier",
505
+ value: C._id
506
+ }));
507
+ return n ? [...f, ...S] : S;
508
+ }
509
+ return v.value.map((f) => ({
510
+ label: f.name,
511
+ sublabel: f.internal ? `${f.internal}` : void 0,
512
+ value: f._id
513
+ }));
514
+ }), F = I(() => {
515
+ var C, B;
516
+ const y = (B = (C = i()) == null ? void 0 : C.supplier) == null ? void 0 : B._id;
517
+ if (s.value === O.PURCHASE) {
518
+ const P = a.suppliers.find((A) => A._id === y);
519
+ return P ? Ce(P) : null;
520
+ }
521
+ const S = e.locations.find((P) => P.doc._id);
522
+ return S ? Pe(S) : null;
523
+ });
524
+ return {
525
+ transferLocationModel: m,
526
+ transferLocationOptions: _,
527
+ locationOptionsTypePurchase: r,
528
+ locationOptionsTypePurchaseLocationLevel: c,
529
+ locationOptionsTypeTransfer: v,
530
+ selectedLocation: F
531
+ };
532
+ }
533
+ function Gt(i) {
534
+ const p = I({
535
+ get() {
536
+ const e = i.getEffectiveAt();
537
+ return e ? new Date(e) : null;
538
+ },
539
+ set(e) {
540
+ i.setEffectiveAt((e == null ? void 0 : e.toISOString()) ?? null);
541
+ }
542
+ }), o = I({
543
+ get() {
544
+ return !!p.value;
545
+ },
546
+ set(e) {
547
+ e ? p.value = /* @__PURE__ */ new Date() : p.value = null;
548
+ }
549
+ }), n = I({
550
+ get() {
551
+ return p.value === null ? "" : Be(p.value);
552
+ },
553
+ set(e) {
554
+ e ? p.value = /* @__PURE__ */ new Date(`${e} ${a.value}`) : p.value = null;
555
+ }
556
+ }), a = I({
557
+ get() {
558
+ return p.value === null ? "" : kt(p.value);
559
+ },
560
+ set(e) {
561
+ e ? p.value = /* @__PURE__ */ new Date(`${n.value} ${e}`) : p.value = null;
562
+ }
563
+ });
564
+ return {
565
+ backdatePo: p,
566
+ backdateSwitch: o,
567
+ backdateModel: n,
568
+ backdateTimeModel: a
569
+ };
570
+ }
571
+ const es = {
572
+ width: "24",
573
+ height: "24",
574
+ viewBox: "0 0 24 24",
575
+ fill: "none",
576
+ xmlns: "http://www.w3.org/2000/svg"
577
+ }, ts = ["fill"], ss = ["fill"], os = ["stroke"], ls = ["stroke"], ns = /* @__PURE__ */ oe({
578
+ __name: "SparkIcon",
579
+ props: {
580
+ size: {
581
+ type: Number,
582
+ default: 24
583
+ },
584
+ color: {
585
+ type: String,
586
+ default: "#c7c7cc"
587
+ }
588
+ },
589
+ setup(i) {
590
+ return (p, o) => (w(), V("svg", es, [
591
+ d("path", {
592
+ 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",
593
+ fill: i.color
594
+ }, null, 8, ts),
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
+ fill: i.color
598
+ }, null, 8, ss),
599
+ d("path", {
600
+ 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",
601
+ stroke: i.color,
602
+ "stroke-width": "1.5",
603
+ "stroke-linecap": "round",
604
+ "stroke-linejoin": "round"
605
+ }, null, 8, os),
606
+ d("path", {
607
+ 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",
608
+ stroke: i.color,
609
+ "stroke-width": "1.5",
610
+ "stroke-linecap": "round",
611
+ "stroke-linejoin": "round"
612
+ }, null, 8, ls)
613
+ ]));
614
+ }
615
+ }), as = { class: "flex gap-8 items-center" }, rs = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, is = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, us = { class: "flex items-center w-full" }, ds = { class: "flex-1" }, cs = { class: "fm-typo-en-title-sm-800" }, ps = { class: "flex items-start gap-8" }, ms = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, fs = { class: "flex gap-1" }, ze = /* @__PURE__ */ oe({
616
+ __name: "ForecastStock",
617
+ props: {
618
+ disabled: { type: Boolean }
619
+ },
620
+ emits: ["update:poItems"],
621
+ setup(i, { emit: p }) {
622
+ const o = p, n = j(!1), a = j(7), e = Tt(), s = Me(), m = Ee(), { t: c } = ge();
623
+ async function l() {
624
+ if (a.value < 1)
625
+ return;
626
+ n.value = !1, await e.readPurchaseOrder(a.value);
627
+ const r = [];
628
+ if (e.purchaseOrderForecast.skus.length <= 0) {
629
+ s.open({
630
+ message: c("inventory.transfer.form.items.forecastStock.notAvailable"),
631
+ type: "info"
632
+ });
633
+ return;
634
+ }
635
+ const v = e.purchaseOrderForecast.skus.reduce((_, F) => {
636
+ const y = m.skus.find((C) => C._id === F.id);
637
+ if (_.find((C) => C.sku._id === F.id) || !y)
638
+ return _;
639
+ const S = {
640
+ sku: y,
641
+ code: y.code,
642
+ name: y.name,
643
+ quantity: {
644
+ amount: F.amount,
645
+ precision: 0
646
+ }
647
+ };
648
+ return _.push(S), _;
649
+ }, r);
650
+ o("update:poItems", v);
651
+ }
652
+ return (r, v) => {
653
+ const _ = T("FmButton"), F = T("FmIcon"), y = T("FmStepperField"), f = T("FmPopover");
654
+ return w(), q(f, {
655
+ disabled: r.disabled,
656
+ class: "flex",
657
+ "show-popover": n.value,
658
+ onPopoverChanged: v[3] || (v[3] = (S) => n.value = S)
659
+ }, {
660
+ "popover-button": D(() => [
661
+ b(_, {
662
+ label: "unused",
663
+ variant: "secondary",
664
+ "text-color": r.disabled ? "disabled" : "primary",
665
+ "bg-color": "transparent",
666
+ "border-color": r.disabled ? "disabled" : "primary",
667
+ disabled: r.disabled
668
+ }, {
669
+ default: D(() => [
670
+ d("div", as, [
671
+ b(ns, {
672
+ size: 24,
673
+ color: r.disabled ? "#c7c7cc" : "#ff7823"
674
+ }, null, 8, ["color"]),
675
+ d("div", rs, R(t(c)("inventory.transfer.form.items.forecastStock.title")), 1)
676
+ ])
677
+ ]),
678
+ _: 1
679
+ }, 8, ["text-color", "border-color", "disabled"])
680
+ ]),
681
+ default: D(() => [
682
+ d("div", is, [
683
+ d("div", us, [
684
+ d("div", ds, [
685
+ b(At, { "z-index": 99 }, {
686
+ default: D(() => [
687
+ d("p", cs, R(t(c)("inventory.transfer.form.items.forecastStock.title")), 1)
688
+ ]),
689
+ _: 1
690
+ })
691
+ ]),
692
+ b(_, {
693
+ icon: "close",
694
+ size: "md",
695
+ variant: "tertiary",
696
+ onClick: v[0] || (v[0] = (S) => n.value = !1)
697
+ })
698
+ ]),
699
+ b(y, {
700
+ modelValue: a.value,
701
+ "onUpdate:modelValue": v[1] || (v[1] = (S) => a.value = S),
702
+ label: t(c)("inventory.transfer.form.items.forecastStock.days"),
703
+ rules: [t(Te)(1)]
704
+ }, {
705
+ "helper-text": D(() => [
706
+ d("div", ps, [
707
+ b(F, {
708
+ name: "warning",
709
+ size: "sm",
710
+ class: "text-fm-color-system-warning-300"
711
+ }),
712
+ d("div", ms, R(t(c)("inventory.transfer.form.items.forecastStock.replace")), 1)
713
+ ])
714
+ ]),
715
+ _: 1
716
+ }, 8, ["modelValue", "label", "rules"]),
717
+ d("div", fs, [
718
+ v[4] || (v[4] = d("div", { class: "grow" }, null, -1)),
719
+ b(_, {
720
+ label: t(c)("common.cancel"),
721
+ variant: "tertiary",
722
+ onClick: v[2] || (v[2] = (S) => n.value = !1)
723
+ }, null, 8, ["label"]),
724
+ b(_, {
725
+ label: t(c)("inventory.transfer.form.items.forecastStock.generate"),
726
+ onClick: l
727
+ }, null, 8, ["label"])
728
+ ])
729
+ ])
730
+ ]),
731
+ _: 1
732
+ }, 8, ["disabled", "show-popover"]);
733
+ };
734
+ }
735
+ });
736
+ function ys() {
737
+ const i = Me(), p = Ye(), o = j(!1);
738
+ Re(o, (s) => {
739
+ s && (a.value = !0, n().finally(() => {
740
+ a.value = !1;
741
+ }));
742
+ });
743
+ async function n() {
744
+ try {
745
+ const { startDate: s, endDate: m } = Ct(6), r = (await p.getPurchaseOrders({ start: s, end: m })).filter(
746
+ (v) => {
747
+ var _, F;
748
+ return v.status === xt.enum.COMPLETE && ((_ = v.supplier) == null ? void 0 : _.internal) !== "warehouse" && ((F = v.supplier) == null ? void 0 : F.internal) !== "restaurant";
749
+ }
750
+ ).reduce((v, _) => {
751
+ const F = new Date(wt(_._id)), y = _.supplier._id;
752
+ for (const f of _.items) {
753
+ if (!f.totalCost) continue;
754
+ const S = v[f.sku._id] ?? {}, C = S[y] ?? [];
755
+ C.push({
756
+ date: F.toISOString(),
757
+ totalUnit: f.quantity,
758
+ totalCost: f.totalCost,
759
+ unit: f.sku.unit,
760
+ measurement: f.measurement,
761
+ seqNumber: _.seqNumber
762
+ }), S[y] = C, v[f.sku._id] = S;
763
+ }
764
+ return v;
765
+ }, {});
766
+ e.value = r;
767
+ } catch {
768
+ i.open({
769
+ title: "Something went wrong",
770
+ message: "Cannot retrieve supplier purchase history. Please try again."
771
+ }), o.value = !1;
772
+ }
773
+ }
774
+ const a = j(!1), e = j({});
775
+ return {
776
+ comparePricesToggle: o,
777
+ comparePriceFetching: a,
778
+ comparePriceBySku: e
779
+ };
780
+ }
781
+ const vs = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, bs = { key: 0 }, gs = ["colspan"], hs = /* @__PURE__ */ oe({
782
+ __name: "TransferItemTable",
783
+ props: {
784
+ row: {},
785
+ comparePriceBySku: {},
786
+ showComparePrice: { type: Boolean }
787
+ },
788
+ setup(i) {
789
+ function p(o) {
790
+ return o.column.columnDef.meta;
791
+ }
792
+ return (o, n) => {
793
+ var a, e;
794
+ return w(), V(se, null, [
795
+ d("tr", {
796
+ class: z(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
797
+ "bg-fm-color-neutral-gray-100": o.row.getIsSelected()
798
+ }])
799
+ }, [
800
+ (w(!0), V(se, null, Ie(o.row.getVisibleCells(), (s) => {
801
+ var m, c, l, r;
802
+ return w(), V("td", {
803
+ key: s.id,
804
+ class: z([
805
+ "h-[52px] px-16 text-fm-color-typo-primary",
806
+ ((m = p(s)) == null ? void 0 : m.cellClass) ?? "px-16"
807
+ ]),
808
+ style: Qe({
809
+ width: (c = p(s)) == null ? void 0 : c.width,
810
+ maxWidth: (l = p(s)) == null ? void 0 : l.maxWidth,
811
+ textAlign: ((r = p(s)) == null ? void 0 : r.textAlign) ?? "left"
812
+ })
813
+ }, [
814
+ d("span", vs, [
815
+ b(t(ve), {
816
+ render: s.column.columnDef.cell,
817
+ props: s.getContext()
818
+ }, null, 8, ["render", "props"])
819
+ ])
820
+ ], 6);
821
+ }), 128))
822
+ ], 2),
823
+ o.showComparePrice && Object.keys(o.comparePriceBySku[(a = o.row.original.sku) == null ? void 0 : a._id] ?? {}).length > 0 ? (w(), V("tr", bs, [
824
+ d("td", {
825
+ colspan: o.row.getVisibleCells().length
826
+ }, [
827
+ b(et, {
828
+ prices: o.comparePriceBySku[(e = o.row.original.sku) == null ? void 0 : e._id]
829
+ }, null, 8, ["prices"])
830
+ ], 8, gs)
831
+ ])) : H("", !0)
832
+ ], 64);
833
+ };
834
+ }
835
+ });
836
+ class Ve {
837
+ static getDescendantProperty(p, o, n = []) {
838
+ let a, e, s, m, c, l;
839
+ if (o) {
840
+ if (s = o.indexOf("."), s === -1 ? a = o : (a = o.slice(0, s), e = o.slice(s + 1)), m = p[a], m !== null && typeof m < "u")
841
+ if (!e && (typeof m == "string" || typeof m == "number"))
842
+ n.push(m);
843
+ else if (Object.prototype.toString.call(m) === "[object Array]")
844
+ for (c = 0, l = m.length; c < l; c++)
845
+ Ve.getDescendantProperty(m[c], e, n);
846
+ else e && Ve.getDescendantProperty(m, e, n);
847
+ } else
848
+ n.push(p);
849
+ return n;
850
+ }
851
+ }
852
+ class be {
853
+ constructor(p = [], o = [], n = {}) {
854
+ Array.isArray(o) || (n = o, o = []), this.haystack = p, this.keys = o, this.options = Object.assign({
855
+ caseSensitive: !1,
856
+ sort: !1
857
+ }, n);
858
+ }
859
+ search(p = "") {
860
+ if (p === "")
861
+ return this.haystack;
862
+ const o = [];
863
+ for (let n = 0; n < this.haystack.length; n++) {
864
+ const a = this.haystack[n];
865
+ if (this.keys.length === 0) {
866
+ const e = be.isMatch(a, p, this.options.caseSensitive);
867
+ e && o.push({ item: a, score: e });
868
+ } else
869
+ for (let e = 0; e < this.keys.length; e++) {
870
+ const s = Ve.getDescendantProperty(a, this.keys[e]);
871
+ let m = !1;
872
+ for (let c = 0; c < s.length; c++) {
873
+ const l = be.isMatch(s[c], p, this.options.caseSensitive);
874
+ if (l) {
875
+ m = !0, o.push({ item: a, score: l });
876
+ break;
877
+ }
878
+ }
879
+ if (m)
880
+ break;
881
+ }
882
+ }
883
+ return this.options.sort && o.sort((n, a) => n.score - a.score), o.map((n) => n.item);
884
+ }
885
+ static isMatch(p, o, n) {
886
+ p = String(p), o = String(o), n || (p = p.toLocaleLowerCase(), o = o.toLocaleLowerCase());
887
+ const a = be.nearestIndexesFor(p, o);
888
+ return a ? p === o ? 1 : a.length > 1 ? 2 + (a[a.length - 1] - a[0]) : 2 + a[0] : !1;
889
+ }
890
+ static nearestIndexesFor(p, o) {
891
+ const n = o.split("");
892
+ let a = [];
893
+ return be.indexesOfFirstLetter(p, o).forEach((s, m) => {
894
+ let c = s + 1;
895
+ a[m] = [s];
896
+ for (let l = 1; l < n.length; l++) {
897
+ const r = n[l];
898
+ if (c = p.indexOf(r, c), c === -1) {
899
+ a[m] = !1;
900
+ break;
901
+ }
902
+ a[m].push(c), c++;
903
+ }
904
+ }), a = a.filter((s) => s !== !1), a.length ? a.sort((s, m) => s.length === 1 ? s[0] - m[0] : (s = s[s.length - 1] - s[0], m = m[m.length - 1] - m[0], s - m))[0] : !1;
905
+ }
906
+ static indexesOfFirstLetter(p, o) {
907
+ const n = o[0];
908
+ return p.split("").map((a, e) => a !== n ? !1 : e).filter((a) => a !== !1);
909
+ }
910
+ }
911
+ const _s = { class: "sticky top-0 bg-white mb-8" }, ks = { class: "overflow-y-auto pb-8" }, Cs = /* @__PURE__ */ oe({
912
+ __name: "FmFilterableMenuOptions",
913
+ props: /* @__PURE__ */ nt({
914
+ modelValue: {},
915
+ maxHeight: {},
916
+ width: {},
917
+ handleItemChange: { type: Function },
918
+ items: {},
919
+ options: {}
920
+ }, {
921
+ search: {},
922
+ searchModifiers: {}
923
+ }),
924
+ emits: ["update:search"],
925
+ setup(i) {
926
+ const p = i, o = at(i, "search"), n = I(
927
+ () => new be(p.items, ["label", "sublabel"], p.options)
928
+ ), a = I(() => n.value.search(o.value));
929
+ return (e, s) => {
930
+ const m = T("FmButton"), c = T("FmTextField"), l = T("FmMenuItem");
931
+ return w(), V("div", {
932
+ class: "relative",
933
+ style: Qe({ maxHeight: `${e.maxHeight}px`, width: e.width })
934
+ }, [
935
+ d("div", _s, [
936
+ b(c, {
937
+ modelValue: o.value,
938
+ "onUpdate:modelValue": s[1] || (s[1] = (r) => o.value = r),
939
+ placeholder: "Filter options"
940
+ }, {
941
+ append: D(() => [
942
+ o.value ? (w(), q(m, {
943
+ key: 0,
944
+ variant: "tertiary",
945
+ "prepend-icon": "close",
946
+ onClick: s[0] || (s[0] = (r) => o.value = "")
947
+ })) : H("", !0)
948
+ ]),
949
+ _: 1
950
+ }, 8, ["modelValue"])
951
+ ]),
952
+ d("div", ks, [
953
+ (w(!0), V(se, null, Ie(a.value, (r, v) => (w(), q(l, {
954
+ key: v,
955
+ label: r.label,
956
+ sublabel: r.sublabel,
957
+ "model-value": t(De)(e.modelValue, r.value),
958
+ onClick: () => e.handleItemChange(t(De)(e.modelValue, r.value), r),
959
+ onVnodeMounted: (_) => {
960
+ var F;
961
+ return t(De)(e.modelValue, r.value) && ((F = _.el) == null || F.scrollIntoView({ behavior: "smooth" }), console.log("scrollTo", _.el)), void 0;
962
+ }
963
+ }, null, 8, ["label", "sublabel", "model-value", "onClick", "onVnodeMounted"]))), 128)),
964
+ a.value.length ? H("", !0) : (w(), q(l, {
965
+ key: 0,
966
+ disabled: "",
967
+ label: "No options available"
968
+ }))
969
+ ])
970
+ ], 4);
971
+ };
972
+ }
973
+ }), xs = { class: "flex flex-col gap-4" }, ws = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, Ss = { class: "flex flex-col gap-16" }, Fs = { class: "flex flex-col gap-24" }, Ps = { class: "flex flex-col gap-8" }, Is = { class: "flex flex-col gap-4" }, Ts = { class: "flex flex-col gap-8" }, Vs = { class: "flex flex-col gap-4" }, $s = {
974
+ key: 2,
975
+ class: "flex flex-col gap-8"
976
+ }, As = { class: "flex flex-col gap-4" }, Ds = {
977
+ key: 3,
978
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
979
+ }, Os = {
980
+ key: 0,
981
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
982
+ }, Rs = { class: "flex-1" }, Ms = { class: "flex-1" }, Bs = {
983
+ key: 1,
984
+ class: "flex items-center gap-4"
985
+ }, Us = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Es = { class: "flex flex-col gap-16" }, Ls = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Ns = { class: "flex gap-8" }, Hs = { key: 0 }, qs = /* @__PURE__ */ oe({
986
+ __name: "TransferForm2",
987
+ props: {
988
+ modelValue: {},
989
+ request: {},
990
+ disabled: { type: Boolean },
991
+ suppliers: {},
992
+ skus: {},
993
+ lastClosingDate: {}
994
+ },
995
+ emits: ["validation-success", "form:ready"],
996
+ setup(i, { expose: p, emit: o }) {
997
+ const n = i, a = o, e = Vt(), { t: s } = ge(), m = Ue(), c = Ee(), l = Pt(), r = $e(), v = Ze(), _ = ct(), { breakpoints: F } = We(), y = I(() => F.value.xs || F.value.sm), f = I(
998
+ () => _.templates.value.find((u) => u._id === e.template)
999
+ ), S = I(() => e.status === "DRAFT" || !e._rev);
1000
+ Re(f, (u) => {
1001
+ u && S.value && (e.supplier = (u == null ? void 0 : u.purchaseOrder.supplier) ?? e.supplier);
1002
+ }), je(async () => {
1003
+ var u, g;
1004
+ try {
1005
+ if (!e.template) return;
1006
+ if (await _.loadTemplate(e.template), !e.items.length) {
1007
+ e.items = ((u = f.value) == null ? void 0 : u.purchaseOrder.items) ?? [];
1008
+ const L = l.currentLocationSubsidiary();
1009
+ e.netSuite = {
1010
+ ...e.netSuite,
1011
+ subsidiary: {
1012
+ id: L.id,
1013
+ name: L.name
1014
+ }
1015
+ };
1016
+ const re = l.getAvailableItems((g = e.netSuite) == null ? void 0 : g.subsidiary.id), ee = e.items.map((Y) => Y.sku._id).filter((Y) => re.includes(Y));
1017
+ e.items = e.items.filter((Y) => ee.includes(Y.sku._id));
1018
+ }
1019
+ } finally {
1020
+ a("form:ready");
1021
+ }
1022
+ });
1023
+ const C = I(
1024
+ () => m.currentLocation.type === Xe.restaurant
1025
+ );
1026
+ m.watchLocation(async () => {
1027
+ location && (e.supplier || (e.supplier = r.suppliers.find((u) => u) ?? e.supplier));
1028
+ });
1029
+ const B = ut(), P = Xt(
1030
+ () => e,
1031
+ (u) => {
1032
+ Object.assign(e, u);
1033
+ },
1034
+ !0,
1035
+ !0
1036
+ ), A = I({
1037
+ get() {
1038
+ var u;
1039
+ return typeof ((u = e == null ? void 0 : e.supplier) == null ? void 0 : u.internal) == "string" ? O.TRANSFER : O.PURCHASE;
1040
+ },
1041
+ set(u) {
1042
+ var L;
1043
+ const g = typeof ((L = e == null ? void 0 : e.supplier) == null ? void 0 : L.internal) == "string" ? O.TRANSFER : O.PURCHASE;
1044
+ u !== g && (e.supplier = u === O.PURCHASE ? P.locationOptionsTypePurchase.value[0] : P.locationOptionsTypeTransfer.value[0]);
1045
+ }
1046
+ }), U = I(() => P.transferLocationOptions.value), X = I({
1047
+ get() {
1048
+ return e.supplier._id;
1049
+ },
1050
+ set(u) {
1051
+ P.transferLocationModel.value = u;
1052
+ }
1053
+ }), le = I({
1054
+ get() {
1055
+ return e.remark ?? void 0;
1056
+ },
1057
+ set(u) {
1058
+ e.remark = u;
1059
+ }
1060
+ }), G = I(() => l.currentLocationSubsidiary()), { backdatePo: K, backdateSwitch: Q, backdateModel: h, backdateTimeModel: k } = Gt({
1061
+ getEffectiveAt() {
1062
+ return e.effectiveAt;
1063
+ },
1064
+ setEffectiveAt(u) {
1065
+ e.effectiveAt = u;
1066
+ }
1067
+ }), { comparePricesToggle: M, comparePriceFetching: ne, comparePriceBySku: W } = ys(), ae = j();
1068
+ p({
1069
+ validateInputs: () => {
1070
+ var u, g;
1071
+ (g = (u = ae.value) == null ? void 0 : u.validateInputs) == null || g.call(u);
1072
+ },
1073
+ resetInputsValidation: () => {
1074
+ var u, g;
1075
+ (g = (u = ae.value) == null ? void 0 : u.resetInputsValidation) == null || g.call(u);
1076
+ },
1077
+ resetInputs: () => {
1078
+ var u, g;
1079
+ (g = (u = ae.value) == null ? void 0 : u.resetInputs) == null || g.call(u);
1080
+ }
1081
+ });
1082
+ const tt = Ot({
1083
+ updateItem: (u) => {
1084
+ e.items = e.items.map((g) => g.sku._id !== u.sku._id ? g : u);
1085
+ },
1086
+ deleteItem: (u) => {
1087
+ e.items = e.items.filter((g) => g.sku._id !== u.sku._id);
1088
+ },
1089
+ get supplier() {
1090
+ return e.supplier;
1091
+ },
1092
+ get items() {
1093
+ return e.items;
1094
+ },
1095
+ get transferType() {
1096
+ return A.value;
1097
+ },
1098
+ get template() {
1099
+ return f.value;
1100
+ },
1101
+ get disabled() {
1102
+ return n.disabled;
1103
+ }
1104
+ }), st = I(() => tt.columnDefs.value);
1105
+ function ot() {
1106
+ var xe, we, he, Se;
1107
+ const u = new Set((he = (we = (xe = f.value) == null ? void 0 : xe.purchaseOrder) == null ? void 0 : we.items) == null ? void 0 : he.map(($) => $.sku._id)), g = l.getAvailableItems((Se = e.netSuite) == null ? void 0 : Se.subsidiary.id), L = u.size ? c.skus.filter(($) => u.has($._id)) : c.skus, re = l.isEnabled ? L.map(($) => $._id).filter(($) => g.includes($)) : L.map(($) => $._id), ee = L.map(
1108
+ ($) => ({
1109
+ label: $.name,
1110
+ sublabel: $.code,
1111
+ value: $,
1112
+ disabled: !re.includes($._id)
1113
+ })
1114
+ ), Y = ee.filter(($) => {
1115
+ var ie;
1116
+ return (ie = e.items) == null ? void 0 : ie.find((ce) => ce.sku._id === $.value._id);
1117
+ }).map(($) => $.value);
1118
+ B.open({
1119
+ title: s("inventory.transfer.form.items.selectItem"),
1120
+ closeButton: !0,
1121
+ contentComponent: It,
1122
+ contentComponentProps: {
1123
+ modelValue: Y,
1124
+ items: ee,
1125
+ virtualScroll: !0
1126
+ },
1127
+ primaryActions: {
1128
+ text: s("common.confirm"),
1129
+ close: !0
1130
+ },
1131
+ secondaryActions: {
1132
+ text: s("common.close"),
1133
+ close: !0,
1134
+ variant: "tertiary"
1135
+ }
1136
+ }).onPrimary(($) => {
1137
+ const ie = e.items ?? [], ce = $.map((J) => {
1138
+ var Fe, _e;
1139
+ const pe = ie.find((me) => me.sku._id === J._id);
1140
+ if (pe)
1141
+ return pe;
1142
+ const ue = ((_e = (Fe = f.value) == null ? void 0 : Fe.purchaseOrder.items) == null ? void 0 : _e.find(
1143
+ (me) => me.sku._id === J._id
1144
+ )) ?? {
1145
+ sku: J,
1146
+ code: J.code,
1147
+ name: J.name,
1148
+ quantity: {
1149
+ amount: 1,
1150
+ precision: 0
1151
+ }
1152
+ };
1153
+ return A.value == O.PURCHASE && (ue.totalCost = de(
1154
+ ue.sku,
1155
+ ue.quantity,
1156
+ ue.measurement,
1157
+ {
1158
+ supplier: e.supplier
1159
+ }
1160
+ )), ue;
1161
+ });
1162
+ ce.sort((J, pe) => J.sku.code.localeCompare(pe.sku.code)), e.items = ce;
1163
+ });
1164
+ }
1165
+ function Ws(u) {
1166
+ return u;
1167
+ }
1168
+ return (u, g) => {
1169
+ var _e, me;
1170
+ const L = T("FmChip"), re = T("FmLabel"), ee = T("FmField"), Y = T("FmSelect"), xe = T("FmTextField"), we = T("FmTextarea"), he = T("FmSwitch"), Se = T("FmDatePicker"), $ = T("FmTimePicker"), ie = T("FmFormGroup"), ce = T("FmIcon"), J = T("FmButton"), pe = T("FmTooltip"), ue = T("FmTable"), Fe = T("FmForm");
1171
+ return w(), V("div", xs, [
1172
+ d("div", ws, [
1173
+ (_e = n.modelValue) != null && _e.template ? (w(), q(L, {
1174
+ key: 0,
1175
+ variant: u.disabled ? "warning" : void 0,
1176
+ label: `${t(s)("inventory.transfer.template.title")}: ${((me = f.value) == null ? void 0 : me.name) ?? t(s)("inventory.transfer.form.loading")}`,
1177
+ icon: "summarize",
1178
+ compact: ""
1179
+ }, null, 8, ["variant", "label"])) : H("", !0),
1180
+ b(L, {
1181
+ label: t(m).currentLocation.name,
1182
+ icon: "storefront",
1183
+ compact: ""
1184
+ }, null, 8, ["label"]),
1185
+ u.lastClosingDate ? (w(), q(L, {
1186
+ key: 1,
1187
+ label: `${t(s)("inventory.transfer.form.lastClosing")}: ${t(Be)(u.lastClosingDate)} ${t(St)(u.lastClosingDate)}`,
1188
+ icon: "calendar_month",
1189
+ compact: ""
1190
+ }, null, 8, ["label"])) : H("", !0)
1191
+ ]),
1192
+ b(Fe, {
1193
+ ref_key: "formRef",
1194
+ ref: ae,
1195
+ class: "flex flex-col gap-32",
1196
+ disabled: u.disabled,
1197
+ onValidationFailed: console.log,
1198
+ onValidationSuccess: g[12] || (g[12] = (Ae) => a("validation-success"))
1199
+ }, {
1200
+ default: D(() => {
1201
+ var Ae, Le;
1202
+ return [
1203
+ d("div", Ss, [
1204
+ d("div", Fs, [
1205
+ (Ae = n.modelValue) != null && Ae.template ? (w(), V(se, { key: 0 }, [
1206
+ d("div", Ps, [
1207
+ b(re, {
1208
+ label: t(s)("inventory.transfer.form.type.title")
1209
+ }, null, 8, ["label"]),
1210
+ d("div", Is, [
1211
+ b(ee, null, {
1212
+ default: D(() => [
1213
+ d("span", {
1214
+ class: z({ "text-fm-color-typo-disabled": u.disabled })
1215
+ }, R(t(s)(`inventory.transfer.form.type.${A.value.toLocaleLowerCase("en-us")}`)), 3)
1216
+ ]),
1217
+ _: 1
1218
+ }),
1219
+ d("div", {
1220
+ class: z([
1221
+ "fm-typo-en-body-sm-400",
1222
+ u.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1223
+ ])
1224
+ }, " This field is locked from template. ", 2)
1225
+ ])
1226
+ ]),
1227
+ d("div", Ts, [
1228
+ b(re, {
1229
+ label: A.value === t(O).PURCHASE ? t(s)("inventory.transfer.form.purchaseFrom") : t(s)("inventory.transfer.form.transferFrom")
1230
+ }, null, 8, ["label"]),
1231
+ d("div", Vs, [
1232
+ b(ee, null, {
1233
+ default: D(() => {
1234
+ var x;
1235
+ return [
1236
+ d("span", {
1237
+ class: z({ "text-fm-color-typo-disabled": u.disabled })
1238
+ }, R((x = U.value.find((te) => te.value === X.value)) == null ? void 0 : x.label), 3)
1239
+ ];
1240
+ }),
1241
+ _: 1
1242
+ }),
1243
+ d("div", {
1244
+ class: z([
1245
+ "fm-typo-en-body-sm-400",
1246
+ u.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1247
+ ])
1248
+ }, " This field is locked from template. ", 2)
1249
+ ])
1250
+ ])
1251
+ ], 64)) : (w(), V(se, { key: 1 }, [
1252
+ b(Y, {
1253
+ label: t(s)("inventory.transfer.form.type.title"),
1254
+ "model-value": A.value,
1255
+ "onUpdate:modelValue": g[0] || (g[0] = (x) => A.value = x),
1256
+ items: [
1257
+ {
1258
+ label: t(s)("inventory.transfer.form.type.purchase"),
1259
+ value: t(O).PURCHASE,
1260
+ disabled: !t(P).locationOptionsTypePurchase.value.length,
1261
+ sublabel: t(P).locationOptionsTypePurchase.value.length ? void 0 : t(s)("inventory.transfer.form.noSupplierAvailable")
1262
+ },
1263
+ {
1264
+ label: t(s)("inventory.transfer.form.type.transfer"),
1265
+ value: t(O).TRANSFER,
1266
+ disabled: !t(P).locationOptionsTypeTransfer.value.length,
1267
+ sublabel: t(P).locationOptionsTypeTransfer.value.length ? void 0 : t(s)("inventory.transfer.form.noLocationAvailable")
1268
+ }
1269
+ ],
1270
+ rules: [t(Te)(1)(U.value)]
1271
+ }, null, 8, ["label", "model-value", "items", "rules"]),
1272
+ b(Y, {
1273
+ label: A.value === t(O).PURCHASE ? t(s)("inventory.transfer.form.purchaseFrom") : t(s)("inventory.transfer.form.transferFrom"),
1274
+ modelValue: X.value,
1275
+ "onUpdate:modelValue": g[1] || (g[1] = (x) => X.value = x),
1276
+ items: U.value
1277
+ }, {
1278
+ "menu-wrapper": D((x) => {
1279
+ var te, Ne;
1280
+ return [
1281
+ b(Cs, rt(x, {
1282
+ items: U.value,
1283
+ "model-value": (Ne = (te = u.modelValue) == null ? void 0 : te.supplier) == null ? void 0 : Ne._id
1284
+ }), null, 16, ["items", "model-value"])
1285
+ ];
1286
+ }),
1287
+ _: 1
1288
+ }, 8, ["label", "modelValue", "items"])
1289
+ ], 64)),
1290
+ b(xe, {
1291
+ label: t(s)("inventory.transfer.form.reference"),
1292
+ "label-mark": "optional",
1293
+ modelValue: t(e).ref,
1294
+ "onUpdate:modelValue": g[2] || (g[2] = (x) => t(e).ref = x)
1295
+ }, null, 8, ["label", "modelValue"]),
1296
+ b(we, {
1297
+ label: t(s)("inventory.transfer.form.remark"),
1298
+ "label-mark": "optional",
1299
+ "max-length": 240,
1300
+ modelValue: le.value,
1301
+ "onUpdate:modelValue": g[3] || (g[3] = (x) => le.value = x),
1302
+ class: z([u.disabled ? "text-fm-color-typo-disabled " : ""])
1303
+ }, null, 8, ["label", "modelValue", "class"]),
1304
+ t(l).isEnabled ? (w(), V("div", $s, [
1305
+ b(re, {
1306
+ label: `NetSuite ${t(s)("inventory.transfer.form.netsuite.subsidiary")}`
1307
+ }, null, 8, ["label"]),
1308
+ d("div", As, [
1309
+ b(ee, null, {
1310
+ default: D(() => {
1311
+ var x;
1312
+ return [
1313
+ d("span", {
1314
+ class: z({ "text-fm-color-typo-disabled": u.disabled })
1315
+ }, R((x = G.value) == null ? void 0 : x.fullName), 3)
1316
+ ];
1317
+ }),
1318
+ _: 1
1319
+ }),
1320
+ d("div", {
1321
+ class: z([
1322
+ "fm-typo-en-body-sm-400",
1323
+ u.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1324
+ ])
1325
+ }, " This field is based on selected location. ", 2)
1326
+ ])
1327
+ ])) : H("", !0),
1328
+ t(v).enableBackdatePo ? (w(), V("div", Ds, [
1329
+ d("div", {
1330
+ class: z([
1331
+ "flex",
1332
+ {
1333
+ "flex-col": y.value
1334
+ }
1335
+ ])
1336
+ }, [
1337
+ b(he, {
1338
+ modelValue: t(Q),
1339
+ "onUpdate:modelValue": g[4] || (g[4] = (x) => ye(Q) ? Q.value = x : null),
1340
+ label: t(s)("inventory.transfer.form.backdate.title"),
1341
+ sublabel: t(s)("inventory.transfer.form.backdate.subtitle"),
1342
+ "label-placement": "right",
1343
+ disabled: C.value && !u.lastClosingDate || u.disabled
1344
+ }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1345
+ d("div", {
1346
+ class: z({ hidden: y.value, "w-16": !y.value })
1347
+ }, null, 2),
1348
+ t(Q) ? (w(), V("div", Os, [
1349
+ d("div", Rs, [
1350
+ b(Se, {
1351
+ modelValue: t(h),
1352
+ "onUpdate:modelValue": g[5] || (g[5] = (x) => ye(h) ? h.value = x : null)
1353
+ }, null, 8, ["modelValue"])
1354
+ ]),
1355
+ d("div", Ms, [
1356
+ b($, {
1357
+ modelValue: t(k),
1358
+ "onUpdate:modelValue": g[6] || (g[6] = (x) => ye(k) ? k.value = x : null)
1359
+ }, null, 8, ["modelValue"])
1360
+ ])
1361
+ ])) : H("", !0)
1362
+ ], 2),
1363
+ t(K) ? (w(), q(ie, {
1364
+ key: 0,
1365
+ modelValue: t(K),
1366
+ "onUpdate:modelValue": g[7] || (g[7] = (x) => ye(K) ? K.value = x : null),
1367
+ rules: [t(Ft)(new Date(u.lastClosingDate), /* @__PURE__ */ new Date())]
1368
+ }, null, 8, ["modelValue", "rules"])) : H("", !0),
1369
+ C.value && !u.lastClosingDate ? (w(), V("div", Bs, [
1370
+ b(ce, {
1371
+ name: "error",
1372
+ size: "sm",
1373
+ class: "text-fm-color-typo-warning"
1374
+ }),
1375
+ d("span", Us, R(t(s)("inventory.transfer.form.backdate.error")), 1)
1376
+ ])) : H("", !0)
1377
+ ])) : H("", !0)
1378
+ ])
1379
+ ]),
1380
+ d("div", Es, [
1381
+ b(ie, {
1382
+ "model-value": t(e).items,
1383
+ rules: [t(Te)(1)]
1384
+ }, null, 8, ["model-value", "rules"]),
1385
+ d("div", {
1386
+ class: z([
1387
+ "flex gap-16",
1388
+ {
1389
+ "flex-col items-start": y.value,
1390
+ "items-center": !y.value
1391
+ }
1392
+ ])
1393
+ }, [
1394
+ d("div", Ls, R(t(s)("inventory.transfer.form.items.title")), 1),
1395
+ d("div", Ns, [
1396
+ b(J, {
1397
+ disabled: u.disabled,
1398
+ label: t(s)("inventory.transfer.form.items.addItem"),
1399
+ "prepend-icon": "add",
1400
+ variant: "secondary",
1401
+ "text-color": "primary",
1402
+ "bg-color": "transparent",
1403
+ "border-color": "primary",
1404
+ onClick: g[8] || (g[8] = (x) => ot()),
1405
+ size: "md"
1406
+ }, null, 8, ["disabled", "label"]),
1407
+ t(e).template ? (w(), q(pe, {
1408
+ key: 0,
1409
+ "z-index": 50
1410
+ }, {
1411
+ content: D(() => [
1412
+ d("div", null, R(t(s)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1413
+ ]),
1414
+ default: D(() => [
1415
+ b(ze, {
1416
+ "onUpdate:poItems": g[9] || (g[9] = (x) => t(e).items = x),
1417
+ disabled: ""
1418
+ })
1419
+ ]),
1420
+ _: 1
1421
+ })) : (w(), q(ze, {
1422
+ key: 1,
1423
+ "onUpdate:poItems": g[10] || (g[10] = (x) => t(e).items = x),
1424
+ disabled: u.disabled || !!t(e).template
1425
+ }, null, 8, ["disabled"]))
1426
+ ])
1427
+ ], 2),
1428
+ A.value === t(O).PURCHASE && S.value && t(v).enableTotalCost && ((Le = u.modelValue) != null && Le.items.length) ? (w(), V("div", Hs, [
1429
+ b(he, {
1430
+ label: t(ne) ? t(s)("inventory.transfer.form.items.fetchingData") : t(s)("inventory.transfer.form.items.comparePriceHistory"),
1431
+ "prepend-icon": "compare_arrows",
1432
+ "label-placement": "right",
1433
+ "model-value": t(M),
1434
+ "onUpdate:modelValue": g[11] || (g[11] = (x) => ye(M) ? M.value = x : null),
1435
+ disabled: t(ne) || u.disabled
1436
+ }, null, 8, ["label", "model-value", "disabled"])
1437
+ ])) : H("", !0),
1438
+ (w(), q(ue, {
1439
+ "column-defs": st.value,
1440
+ "row-data": t(e).items,
1441
+ key: t(e).items.map((x) => x.sku._id).join("."),
1442
+ "hide-footer": "",
1443
+ "page-size": t(e).items.length
1444
+ }, {
1445
+ "table-row": D((x) => [
1446
+ b(hs, {
1447
+ "compare-price-by-sku": t(W),
1448
+ "show-compare-price": A.value === t(O).PURCHASE && t(M),
1449
+ row: x
1450
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row"])
1451
+ ]),
1452
+ "list-row": D((x) => [
1453
+ (w(), q($t, {
1454
+ row: x,
1455
+ key: t(e).items.map((te) => te.sku._id).join(".")
1456
+ }, {
1457
+ default: D((te) => [
1458
+ b(Jt, {
1459
+ "compare-price-by-sku": t(W),
1460
+ "show-compare-price": A.value === t(O).PURCHASE && t(M),
1461
+ row: x,
1462
+ "cell-by-col-id": te
1463
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1464
+ ]),
1465
+ _: 2
1466
+ }, 1032, ["row"]))
1467
+ ]),
1468
+ _: 1
1469
+ }, 8, ["column-defs", "row-data", "page-size"]))
1470
+ ])
1471
+ ];
1472
+ }),
1473
+ _: 1
1474
+ }, 8, ["disabled", "onValidationFailed"])
1475
+ ]);
1476
+ };
1477
+ }
1478
+ }), zs = { class: "flex items-center" }, js = { class: "fm-typo-en-title-md-800" }, Qs = { class: "flex gap-4" }, ao = /* @__PURE__ */ oe({
1479
+ __name: "TransferDialog",
1480
+ props: {
1481
+ mode: {},
1482
+ modelValue: {},
1483
+ templateId: {},
1484
+ show: { type: Boolean },
1485
+ lastClosingDate: {}
1486
+ },
1487
+ emits: ["update:show", "submitted"],
1488
+ setup(i, { expose: p, emit: o }) {
1489
+ var Q;
1490
+ const n = i, a = o, e = Ye(), s = Me(), m = $e(), c = Ee(), l = Ue(), { t: r } = ge(), v = j(!1), _ = j(!1), F = j(!1);
1491
+ async function y(h) {
1492
+ if (h) {
1493
+ _.value = !1;
1494
+ try {
1495
+ await m.readSuppliers(), _.value = !0;
1496
+ } catch {
1497
+ s.open({
1498
+ title: r("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1499
+ message: r("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1500
+ type: "error"
1501
+ });
1502
+ }
1503
+ }
1504
+ }
1505
+ l.watchLocation(y);
1506
+ function f() {
1507
+ return {
1508
+ remark: void 0,
1509
+ ref: void 0,
1510
+ stockSnapshotId: void 0,
1511
+ effectiveAt: void 0,
1512
+ items: [],
1513
+ supplier: {
1514
+ _rev: void 0,
1515
+ email: void 0,
1516
+ internal: void 0,
1517
+ contactName: void 0,
1518
+ phoneNumber: void 0,
1519
+ registrationNumber: void 0,
1520
+ supplyItems: void 0,
1521
+ _id: "",
1522
+ name: "",
1523
+ address: {
1524
+ line2: void 0,
1525
+ line1: "",
1526
+ state: "",
1527
+ city: "",
1528
+ postcode: "",
1529
+ country: ""
1530
+ }
1531
+ },
1532
+ status: "DRAFT",
1533
+ _id: "",
1534
+ seqNumber: 0,
1535
+ deliveryOrder: [],
1536
+ template: n.templateId
1537
+ };
1538
+ }
1539
+ const S = dt(n, "show"), C = j(n.modelValue ?? f()), B = j(((Q = n.modelValue) == null ? void 0 : Q._id) ?? `${Math.random()}`);
1540
+ Re(
1541
+ () => n.show,
1542
+ (h) => {
1543
+ var k;
1544
+ h && (F.value = !1, C.value = n.modelValue ?? f(), B.value = ((k = n.modelValue) == null ? void 0 : k._id) ?? `${Math.random()}`);
1545
+ }
1546
+ );
1547
+ const P = I(() => !_.value || !F.value), A = I(() => {
1548
+ switch (n.mode) {
1549
+ case ke.READ:
1550
+ return "View transfer";
1551
+ case ke.CREATE:
1552
+ return r("inventory.transfer.receiveRequest.create.title");
1553
+ case ke.UPDATE:
1554
+ return r("inventory.transfer.receiveRequest.update.title");
1555
+ }
1556
+ return "";
1557
+ }), U = j();
1558
+ p({
1559
+ validateInputs: () => {
1560
+ var h, k;
1561
+ (k = (h = U.value) == null ? void 0 : h.validateInputs) == null || k.call(h);
1562
+ },
1563
+ resetInputsValidation: () => {
1564
+ var h, k;
1565
+ (k = (h = U.value) == null ? void 0 : h.resetInputsValidation) == null || k.call(h);
1566
+ },
1567
+ resetInputs: () => {
1568
+ var h, k;
1569
+ (k = (h = U.value) == null ? void 0 : h.resetInputs) == null || k.call(h);
1570
+ }
1571
+ });
1572
+ async function X() {
1573
+ const h = C.value;
1574
+ v.value = !0, (h.supplier.internal === "warehouse" || h.supplier.internal === "restaurant") && (h.items = h.items.map(({ totalCost: k, ...M }) => M));
1575
+ try {
1576
+ await e.createPurchaseOrder(h), await new Promise((k) => setTimeout(k, 1e3)), s.open({
1577
+ title: r("inventory.transfer.receiveRequest.create.success"),
1578
+ message: r("inventory.transfer.receiveRequest.create.successMessage"),
1579
+ type: "success"
1580
+ }), a("update:show", !1), a("submitted");
1581
+ } catch (k) {
1582
+ s.open({
1583
+ title: r("inventory.transfer.receiveRequest.create.error.title"),
1584
+ message: r("inventory.transfer.receiveRequest.create.error.message"),
1585
+ type: "error"
1586
+ }), console.error("Error in creating purchase order", k);
1587
+ } finally {
1588
+ v.value = !1;
1589
+ }
1590
+ }
1591
+ async function le() {
1592
+ const h = C.value;
1593
+ v.value = !0, (h.supplier.internal === "warehouse" || h.supplier.internal === "restaurant") && (h.items = h.items.map(({ totalCost: k, ...M }) => M));
1594
+ try {
1595
+ await e.updatePurchaseOrder(h), await new Promise((k) => setTimeout(k, 1e3)), s.open({
1596
+ title: r("inventory.transfer.receiveRequest.update.success"),
1597
+ message: r("inventory.transfer.receiveRequest.update.successMessage"),
1598
+ type: "success"
1599
+ }), a("update:show", !1), a("submitted");
1600
+ } catch (k) {
1601
+ s.open({
1602
+ title: r("inventory.transfer.receiveRequest.update.error.title"),
1603
+ message: r("inventory.transfer.receiveRequest.update.error.message"),
1604
+ type: "error"
1605
+ }), console.error("Error in updating purchase order", k);
1606
+ } finally {
1607
+ v.value = !1;
1608
+ }
1609
+ }
1610
+ function G() {
1611
+ switch (n.mode) {
1612
+ case ke.CREATE:
1613
+ return X();
1614
+ case ke.UPDATE:
1615
+ return le();
1616
+ }
1617
+ }
1618
+ function K() {
1619
+ var h, k;
1620
+ (k = (h = U.value) == null ? void 0 : h.validateInputs) == null || k.call(h);
1621
+ }
1622
+ return (h, k) => {
1623
+ const M = T("FmButton"), ne = T("FmSideSheet");
1624
+ return w(), q(ne, {
1625
+ modelValue: t(S),
1626
+ "onUpdate:modelValue": k[3] || (k[3] = (W) => ye(S) ? S.value = W : null),
1627
+ "dismiss-away": "",
1628
+ "close-button": "",
1629
+ "max-width": 900
1630
+ }, {
1631
+ "side-sheet-header": D(() => [
1632
+ d("div", zs, [
1633
+ d("div", js, R(A.value), 1)
1634
+ ])
1635
+ ]),
1636
+ default: D(() => [
1637
+ (w(), q(qs, {
1638
+ class: "w-full",
1639
+ ref_key: "formRef",
1640
+ ref: U,
1641
+ "onForm:ready": k[0] || (k[0] = () => F.value = !0),
1642
+ onValidationSuccess: G,
1643
+ modelValue: C.value,
1644
+ "onUpdate:modelValue": k[1] || (k[1] = (W) => C.value = W),
1645
+ disabled: v.value || P.value,
1646
+ suppliers: t(m).suppliers,
1647
+ skus: t(c).skus,
1648
+ key: B.value,
1649
+ "last-closing-date": h.lastClosingDate
1650
+ }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1651
+ ]),
1652
+ "side-sheet-footer": D(() => [
1653
+ d("div", Qs, [
1654
+ b(M, {
1655
+ loading: v.value,
1656
+ disabled: P.value,
1657
+ label: t(r)("common.save"),
1658
+ onClick: K
1659
+ }, null, 8, ["loading", "disabled", "label"]),
1660
+ b(M, {
1661
+ disabled: P.value,
1662
+ variant: "tertiary",
1663
+ label: t(r)("common.close"),
1664
+ onClick: k[2] || (k[2] = (W) => a("update:show", !1))
1665
+ }, null, 8, ["disabled", "label"])
1666
+ ])
1667
+ ]),
1668
+ _: 1
1669
+ }, 8, ["modelValue"]);
1670
+ };
1671
+ }
1672
+ });
1673
+ export {
1674
+ ao as _,
1675
+ Cs as a,
1676
+ de as c,
1677
+ Xt as u
1678
+ };