@feedmepos/mf-inventory-portal 0.0.23-dev.42 → 0.0.23-dev.44

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