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

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