@feedmepos/mf-inventory-portal 1.0.21 → 1.0.22-dev.1

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 (50) hide show
  1. package/dist/{App-Dm1dub7v.js → App-DKpBoETt.js} +2 -2
  2. package/dist/{ApprovalView-DZK5guKS.js → ApprovalView-DUELMVOt.js} +2 -2
  3. package/dist/{BindingsDialog-BL2jOxN4.js → BindingsDialog-BbwaoH1V.js} +2 -2
  4. package/dist/{BindingsPicker-G1SdBXsq.js → BindingsPicker-Co91nBu5.js} +1 -1
  5. package/dist/{BindingsTable-Coy6_ryj.js → BindingsTable-CfGpcJbV.js} +1 -1
  6. package/dist/{ClosingDraftView-RTjmn1uK.js → ClosingDraftView-CtDu4gYg.js} +2 -2
  7. package/dist/{ClosingTemplateView-DkX8edyP.js → ClosingTemplateView-9ugr-E5Y.js} +2 -2
  8. package/dist/{DeliveryOrderPrintPreview-j-DgrDiv.js → DeliveryOrderPrintPreview-D4wDJKJM.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BL8MG9yR.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C6_Ua9qb.js} +3 -3
  10. package/dist/{FmMultiselectDialog-C2FfQXZp.js → FmMultiselectDialog-fRcvT8PM.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-D4dnq4rA.js → FmUnitInput.vue_vue_type_script_setup_true_lang-4xfely-0.js} +1 -1
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DXbFhLpK.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DCLepeXM.js} +1 -1
  13. package/dist/{IngredientGroupView-DHbQCRy_.js → IngredientGroupView-BKMbP_tk.js} +2 -2
  14. package/dist/{IngredientsView-CF-wb-6-.js → IngredientsView-DZ6GaNmh.js} +5 -5
  15. package/dist/{IntegrationView-X5yvur-x.js → IntegrationView-Cdxe3ek6.js} +5 -5
  16. package/dist/{InventoryBindingForm-CeJZHDY0.js → InventoryBindingForm-Df2xDcAe.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-9hirHThb.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-uEO5JKUW.js} +3 -3
  18. package/dist/{InventoryBindingSummary-CBg7KhPi.js → InventoryBindingSummary-tR7tgq-a.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BSVs7T4a.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CPk_7mxH.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-ChZwsyJM.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DV0sQIh_.js} +37 -37
  21. package/dist/{PublishView-BjvKb7f-.js → PublishView-CZKgIE-X.js} +2 -2
  22. package/dist/{PurchaseOrderPrintPreview-CbAMXMPU.js → PurchaseOrderPrintPreview-DSluQZDi.js} +1 -1
  23. package/dist/ReceiveRequestView-Ldz7vr1u.js +2644 -0
  24. package/dist/{RecipeView-BoR36rGq.js → RecipeView-CUJIeaWu.js} +4 -4
  25. package/dist/{StockView-DcHopPZO.js → StockView-CBtAZjjj.js} +7 -7
  26. package/dist/{SupplierView-V67QXaLX.js → SupplierView-Bjb0ygav.js} +4 -4
  27. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-eeL8-QuF.js → TransferDetails.vue_vue_type_script_setup_true_lang-B0tt7ir6.js} +6 -6
  28. package/dist/{TransferTemplateView-DKDeo49Q.js → TransferTemplateView-DN8G_xl8.js} +7 -7
  29. package/dist/{UnitView-BRVRLheN.js → UnitView-C2hi87bo.js} +3 -3
  30. package/dist/{WarehouseView-tRg5Hn4L.js → WarehouseView-DSpjmL-N.js} +1 -1
  31. package/dist/api/stock-estimate.d.ts +1 -1
  32. package/dist/{app-82JEull2.js → app-OXMxNgrT.js} +215 -215
  33. package/dist/app.js +1 -1
  34. package/dist/{decimal-D-zH_vXe.js → decimal-BHadyOEY.js} +1 -1
  35. package/dist/{feature-UG6T1t8f.js → feature-B9uo-iYZ.js} +2 -2
  36. package/dist/{format-unit-display-CIPAWL-6.js → format-unit-display-Cji-r-K6.js} +2 -2
  37. package/dist/{index-BDC93VCL.js → index-B5xhf4x0.js} +1 -1
  38. package/dist/{index-B7w4ky-g.js → index-B72H3Oxs.js} +2 -2
  39. package/dist/{stock-Bq9xHemt.js → stock-BpE4s385.js} +1 -1
  40. package/dist/stores/stock-estimate.d.ts +1 -1
  41. package/dist/{supplier-BrZdgPMN.js → supplier-CB_uu-6p.js} +2 -2
  42. package/dist/tsconfig.app.tsbuildinfo +1 -1
  43. package/dist/types/forecast.d.ts +6 -0
  44. package/dist/{use-ingredient-select-dialog-Dzy7PO1j.js → use-ingredient-select-dialog-C9dRsaoW.js} +1 -1
  45. package/dist/{use-inventory-binding-dialog-DT4t22Eb.js → use-inventory-binding-dialog-BNHELUOB.js} +1 -1
  46. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +9 -0
  47. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +2 -0
  48. package/dist/{vue-i18n-D5ETg5F3.js → vue-i18n-DsGf7G_F.js} +527 -527
  49. package/package.json +3 -3
  50. package/dist/ReceiveRequestView-ihHtocTf.js +0 -2578
@@ -1,2578 +0,0 @@
1
- import { reactive as vt, onMounted as Be, watch as be, computed as q, h as j, defineComponent as re, openBlock as k, createElementBlock as T, Fragment as ne, renderList as De, createElementVNode as l, toDisplayString as R, unref as s, resolveComponent as D, createVNode as c, withCtx as P, createCommentVNode as B, ref as U, createBlock as Q, normalizeClass as Y, normalizeStyle as yt, createTextVNode as Te, nextTick as wt, mergeProps as Qe, isRef as $e, createSlots as Ft, Teleport as $t, normalizeProps as It, guardReactiveProps as Dt } from "vue";
2
- import { b as Ue, P as bt, l as Oe, i as Ie, a6 as Ke, Q as Tt, at as Vt, A as qe, M as Pt, m as gt, ad as Xe, E as de, ak as Rt, a as Le, au as Et, av as At, aw as Ot, J as _t, u as Ze, ax as qt, ay as Ut, a5 as Mt, $ as Nt, az as zt, C as ht, a1 as Bt, d as Ae, w as Lt, x as Ht, y as jt, aA as ze, a7 as dt, z as Yt, N as Qt, H as Kt, _ as Xt, B as Zt, V as ct } from "./app-82JEull2.js";
3
- import { u as Je, a as Jt, P as Ye, b as Wt, _ as Gt, g as es } from "./TransferDetails.vue_vue_type_script_setup_true_lang-eeL8-QuF.js";
4
- import { _ as kt, u as ts, i as ss, e as as } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-ChZwsyJM.js";
5
- import { u as os } from "./useTabStorage-BkIVScW_.js";
6
- import { useBreakpoints as We, components as ye, FmButtonVariant as ls, useSnackbar as Ve, useDialog as ns, useProxiedModel as xt } from "@feedmepos/ui-library";
7
- import { P as se, u as Ct } from "./format-unit-display-CIPAWL-6.js";
8
- import { _ as rs, F as is, a as us, b as ds } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-D4dnq4rA.js";
9
- import { u as Ge } from "./feature-UG6T1t8f.js";
10
- import { c as he, u as cs, _ as ms } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BL8MG9yR.js";
11
- import { useI18n as ge } from "@feedmepos/mf-common";
12
- import "./FmMultiselectDialog-C2FfQXZp.js";
13
- import { u as et } from "./supplier-BrZdgPMN.js";
14
- import { _ as ps } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
15
- import { u as fs } from "./vue-i18n-D5ETg5F3.js";
16
- import "./array-Ca8T3f_G.js";
17
- var X = /* @__PURE__ */ ((g) => (g.Code = "Code", g.Name = "Name", g.TemplateName = "TemplateName", g.Amount = "Amount", g.Cost = "Cost", g.TotalCost = "TotalCost", g.Delete = "Delete", g))(X || {});
18
- const vs = () => (ge(), j(
19
- kt,
20
- {
21
- zIndex: 50,
22
- class: "whitespace-nowrap"
23
- },
24
- `Total (${gt()})`
25
- ));
26
- function ys(g) {
27
- const { t: x } = ge(), n = vt({}), { breakpoints: i } = We(), _ = Ge(), t = Ue();
28
- Be(() => {
29
- for (const m of g.items) {
30
- if (!m.totalCost)
31
- continue;
32
- const e = he(m.sku, m.quantity, m.measurement, {
33
- supplier: g.supplier
34
- }), o = m.totalCost ?? bt.reset();
35
- e ? n[m.sku._id] = e.amount !== o.amount || e.precision !== o.precision : n[m.sku._id] = !0;
36
- }
37
- }), be([() => g.supplier], ([m]) => {
38
- for (const e of g.items) {
39
- if (!e.totalCost || n[e.sku._id] || !d(e.sku))
40
- continue;
41
- const o = he(e.sku, e.quantity, e.measurement, {
42
- supplier: m
43
- });
44
- g.updateItem({ ...e, totalCost: o });
45
- }
46
- });
47
- function d(m) {
48
- var o, p, f, v, S, h, F;
49
- return !!(((p = (o = m.defaultCost) == null ? void 0 : o.costPerUnit) == null ? void 0 : p.amount) ?? ((F = (h = (S = (v = (f = g.supplier) == null ? void 0 : f.supplyItems) == null ? void 0 : v.find((y) => y.skuId === m._id)) == null ? void 0 : S.defaultCost) == null ? void 0 : h.costPerUnit) == null ? void 0 : F.amount));
50
- }
51
- const C = [
52
- {
53
- id: "Code",
54
- header: () => x("inventory.transfer.form.items.table.Code"),
55
- accessorKey: "code",
56
- size: 200,
57
- cell(m) {
58
- const e = m.row.original;
59
- return t.isEnabled ? j(
60
- ye.FmTooltip,
61
- {
62
- content: e.code,
63
- placement: "top",
64
- variant: "plain",
65
- zIndex: 50
66
- },
67
- j(
68
- "span",
69
- {
70
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
71
- },
72
- e.code
73
- )
74
- ) : j(ye.FmTextField, {
75
- modelValue: e.code,
76
- "onUpdate:modelValue": (o) => {
77
- g.updateItem({
78
- ...e,
79
- code: o
80
- });
81
- },
82
- key: e.sku._id,
83
- rules: [Oe()],
84
- labelMark: "required"
85
- });
86
- },
87
- enableSorting: !1
88
- },
89
- {
90
- id: "Name",
91
- header: () => x("inventory.transfer.form.items.table.Name"),
92
- minSize: 300,
93
- cell(m) {
94
- const e = m.row.original;
95
- return t.isEnabled ? j(
96
- ye.FmTooltip,
97
- {
98
- content: e.name,
99
- placement: "top",
100
- variant: "plain",
101
- zIndex: 50
102
- },
103
- j(
104
- "span",
105
- {
106
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
107
- },
108
- e.name
109
- )
110
- ) : j(ye.FmTextField, {
111
- modelValue: e.name,
112
- "onUpdate:modelValue": (o) => {
113
- g.updateItem({
114
- ...e,
115
- name: o
116
- });
117
- },
118
- key: e.sku._id,
119
- rules: [Oe()],
120
- labelMark: "required"
121
- });
122
- },
123
- enableSorting: !1
124
- },
125
- {
126
- id: "TemplateName",
127
- header: () => x("inventory.transfer.form.items.table.Name"),
128
- minSize: 300,
129
- enableSorting: !1,
130
- cell(m) {
131
- const e = m.row.original, o = e.code, p = e.name;
132
- return j(
133
- ye.FmTooltip,
134
- { zIndex: 50 },
135
- {
136
- default() {
137
- return j("div", { class: "flex flex-col w-full" }, [
138
- j(
139
- "div",
140
- { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
141
- p
142
- ),
143
- j(
144
- "div",
145
- {
146
- class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary"
147
- },
148
- o
149
- )
150
- ]);
151
- },
152
- content() {
153
- return p;
154
- }
155
- }
156
- );
157
- }
158
- },
159
- {
160
- id: "Amount",
161
- header: () => x("inventory.transfer.form.items.table.Amount"),
162
- minSize: 200,
163
- cell(m) {
164
- var p, f, v, S;
165
- const e = m.row.original, o = (v = (f = (p = g.template) == null ? void 0 : p.purchaseOrder) == null ? void 0 : f.items) == null ? void 0 : v.find(
166
- (h) => h.sku._id === e.sku._id
167
- );
168
- return j(rs, {
169
- style: {
170
- flex: "1 1 0%"
171
- },
172
- modelValue: {
173
- amount: e.quantity ?? { amount: 1, precision: 0 },
174
- measurement: e.measurement ?? null
175
- },
176
- key: e.sku._id,
177
- unit: e.sku.unit,
178
- "onUpdate:modelValue": (h) => {
179
- if (!h) return;
180
- const F = {
181
- ...e,
182
- quantity: h.amount,
183
- measurement: h.measurement
184
- };
185
- _.enableTotalCost && (F.totalCost = he(
186
- F.sku,
187
- F.quantity,
188
- F.measurement,
189
- {
190
- supplier: g.supplier,
191
- // NOTE: set undefined here if `manualTotalCost[updatedRow.sku._id] = false`, so that the function
192
- // will return the auto calculated default cost instead of the manual total cost
193
- manualTotalCost: n[F.sku._id] ? F.totalCost : void 0
194
- }
195
- )), g.updateItem(F);
196
- },
197
- stepper: o == null ? void 0 : o.quantityStep,
198
- disableUnit: !!o,
199
- disabled: g.disabled,
200
- rules: [
201
- is(
202
- +Ie(
203
- ((S = e.quantity) == null ? void 0 : S.amount) === 0 ? { amount: 0, precision: 0 } : (o == null ? void 0 : o.minimumQuantity) ?? { amount: 0, precision: 0 }
204
- )
205
- ),
206
- us(
207
- o != null && o.maximumQuantity ? +Ie(o == null ? void 0 : o.maximumQuantity) : 1 / 0
208
- ),
209
- ...o != null && o.quantityStep ? [ds(o.quantityStep)] : []
210
- ],
211
- applyDefaultRules: !0
212
- });
213
- },
214
- enableSorting: !1
215
- },
216
- {
217
- id: "Cost",
218
- header: vs,
219
- size: 180,
220
- cell(m) {
221
- const e = m.row.original, o = d(e.sku), p = i.value.xs || i.value.sm;
222
- return !n[e.sku._id] && o ? j(
223
- "div",
224
- {
225
- class: [
226
- "flex gap-4 fm-typo-en-body-md-400 items-center",
227
- g.disabled ? "text-fm-color-typo-disabled" : ""
228
- ],
229
- key: e.sku._id
230
- },
231
- [
232
- j(ye.FmButton, {
233
- prependIcon: "edit",
234
- variant: ls.Tertiary,
235
- disabled: g.disabled,
236
- onClick() {
237
- g.updateItem({
238
- ...e,
239
- totalCost: he(e.sku, e.quantity, e.measurement, {
240
- supplier: g.supplier
241
- })
242
- }), n[e.sku._id] = !0;
243
- }
244
- }),
245
- j(
246
- "div",
247
- {
248
- class: "flex flex-col"
249
- },
250
- [
251
- j(
252
- "span",
253
- p ? Ke(
254
- he(e.sku, e.quantity, e.measurement, {
255
- supplier: g.supplier
256
- })
257
- ) : Ie(
258
- he(e.sku, e.quantity, e.measurement, {
259
- supplier: g.supplier
260
- })
261
- )
262
- ),
263
- j(
264
- "span",
265
- {
266
- class: [
267
- "fm-typo-en-body-sm-400",
268
- g.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
269
- ]
270
- },
271
- x("inventory.transfer.form.items.autoCalculated")
272
- )
273
- ]
274
- )
275
- ]
276
- ) : j(
277
- ye.FmTextField,
278
- {
279
- modelValue: Ie(e.totalCost ?? { amount: 0, precision: 0 }),
280
- key: e.sku._id,
281
- "onUpdate:modelValue": (f) => {
282
- g.updateItem({
283
- ...e,
284
- totalCost: {
285
- ...Tt(+f),
286
- currency: Vt()
287
- }
288
- });
289
- },
290
- rules: [qe(0), Pt(2)]
291
- },
292
- {
293
- prepend() {
294
- return p ? j(
295
- "div",
296
- {
297
- class: [
298
- "text-fm-typo-en-body-lg-400",
299
- g.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
300
- ]
301
- },
302
- gt()
303
- ) : null;
304
- },
305
- append() {
306
- return o ? j(ye.FmButton, {
307
- prependIcon: "close",
308
- variant: "tertiary",
309
- disabled: g.disabled,
310
- onClick() {
311
- g.updateItem({
312
- ...e,
313
- // NOTE: different from PO template, if a default cost is reenabled,
314
- // the total cost will automatically assigned
315
- totalCost: he(e.sku, e.quantity, e.measurement, {
316
- supplier: g.supplier
317
- })
318
- }), n[e.sku._id] = !1;
319
- }
320
- }) : null;
321
- }
322
- }
323
- );
324
- },
325
- enableSorting: !1
326
- },
327
- {
328
- id: "Delete",
329
- header: "",
330
- cell(m) {
331
- const e = m.row.original;
332
- return j("div", { class: "flex justify-end" }, [
333
- j(ye.FmButton, {
334
- key: e.sku._id,
335
- class: "delete-button",
336
- type: "button",
337
- icon: "delete",
338
- variant: "tertiary",
339
- size: "md",
340
- disabled: g.disabled,
341
- onClick: () => {
342
- g.deleteItem(e);
343
- }
344
- })
345
- ]);
346
- },
347
- enableSorting: !1,
348
- size: 40,
349
- meta: {
350
- cellClass: "",
351
- headerClass: ""
352
- }
353
- }
354
- ];
355
- return {
356
- columnDefs: q(() => _.enableTotalCost && g.transferType === se.PURCHASE ? C : C.filter(
357
- (m) => m.id !== "Cost"
358
- /* Cost */
359
- ))
360
- };
361
- }
362
- const bs = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, gs = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, _s = { class: "w-[450px] xs:w-full flex" }, hs = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, ks = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, St = /* @__PURE__ */ re({
363
- __name: "SupplierPriceHistory",
364
- props: {
365
- prices: {}
366
- },
367
- setup(g) {
368
- const x = et();
369
- function n(i) {
370
- return x.suppliers.find((_) => _._id === i);
371
- }
372
- return (i, _) => (k(), T("div", bs, [
373
- (k(!0), T(ne, null, De(Object.keys(i.prices), (t) => {
374
- var d;
375
- return k(), T("div", {
376
- key: t,
377
- class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
378
- }, [
379
- l("div", gs, R((d = n(t)) == null ? void 0 : d.name), 1),
380
- l("div", _s, [
381
- (k(!0), T(ne, null, De(i.prices[t].slice(0, 3), (C) => {
382
- var $;
383
- return k(), T("div", {
384
- key: C.date,
385
- class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
386
- }, [
387
- l("div", hs, [
388
- l("span", null, R(C.totalCost ? s(Ke)(C.totalCost) : "No data"), 1),
389
- _[0] || (_[0] = l("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
390
- l("span", null, R(s(Ie)(C.totalUnit, !1)), 1),
391
- l("span", null, R((($ = C.measurement) == null ? void 0 : $.abbrev) ?? C.unit.abbrev), 1)
392
- ]),
393
- l("div", ks, [
394
- l("span", null, "(#" + R(C.seqNumber) + ")", 1),
395
- _[1] || (_[1] = l("span", null, R(" "), -1)),
396
- l("span", null, R(s(Xe)(new Date(C.date))), 1)
397
- ])
398
- ]);
399
- }), 128))
400
- ])
401
- ]);
402
- }), 128))
403
- ]));
404
- }
405
- }), xs = { class: "flex flex-col gap-8 py-16" }, Cs = { class: "flex items-center" }, Ss = { class: "flex-1 flex gap-1 items-center" }, ws = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Fs = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, $s = { class: "flex gap-8 w-full" }, Is = { class: "flex-1 flex flex-col gap-4" }, Ds = { class: "flex-1 flex flex-col gap-4" }, Ts = { class: "flex gap-8 w-full" }, Vs = { class: "flex-1 flex flex-col gap-4" }, Ps = {
406
- key: 0,
407
- class: "flex-1 flex flex-col gap-4"
408
- }, Rs = /* @__PURE__ */ re({
409
- __name: "TransferItem",
410
- props: {
411
- cellByColId: {},
412
- comparePriceBySku: {},
413
- showComparePrice: { type: Boolean },
414
- row: {}
415
- },
416
- setup(g) {
417
- const { t: x } = ge();
418
- return (n, i) => {
419
- var d, C, $, m, e, o, p, f, v, S, h, F, y, w, L, H, N, K, Z, A, E, V, r, u, O, oe, J;
420
- const _ = D("FmLabel"), t = D("FmSpacer");
421
- return k(), T("div", xs, [
422
- l("div", Cs, [
423
- l("div", Ss, [
424
- l("span", ws, " (" + R(n.row.original.sku.code) + ") ", 1),
425
- l("span", Fs, R(n.row.original.sku.name), 1)
426
- ]),
427
- l("div", null, [
428
- c(s(de), {
429
- render: ($ = (C = (d = n.cellByColId.Delete) == null ? void 0 : d.column) == null ? void 0 : C.columnDef) == null ? void 0 : $.cell,
430
- props: (e = (m = n.cellByColId.Delete) == null ? void 0 : m.getContext) == null ? void 0 : e.call(m)
431
- }, null, 8, ["render", "props"])
432
- ])
433
- ]),
434
- l("div", $s, [
435
- l("div", Is, [
436
- c(_, {
437
- label: s(x)(`inventory.transfer.form.items.table.${s(X).Code}`)
438
- }, null, 8, ["label"]),
439
- c(s(de), {
440
- render: (f = (p = (o = n.cellByColId[s(X).Code]) == null ? void 0 : o.column) == null ? void 0 : p.columnDef) == null ? void 0 : f.cell,
441
- props: (S = (v = n.cellByColId[s(X).Code]) == null ? void 0 : v.getContext) == null ? void 0 : S.call(v)
442
- }, null, 8, ["render", "props"]),
443
- i[0] || (i[0] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
444
- ]),
445
- l("div", Ds, [
446
- c(_, {
447
- label: s(x)(`inventory.transfer.form.items.table.${s(X).Name}`)
448
- }, null, 8, ["label"]),
449
- c(s(de), {
450
- render: (y = (F = (h = n.cellByColId[s(X).Name]) == null ? void 0 : h.column) == null ? void 0 : F.columnDef) == null ? void 0 : y.cell,
451
- props: (L = (w = n.cellByColId[s(X).Name]) == null ? void 0 : w.getContext) == null ? void 0 : L.call(w)
452
- }, null, 8, ["render", "props"]),
453
- i[1] || (i[1] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
454
- ])
455
- ]),
456
- l("div", Ts, [
457
- l("div", Vs, [
458
- c(_, {
459
- label: s(x)(`inventory.transfer.form.items.table.${s(X).Amount}`)
460
- }, null, 8, ["label"]),
461
- c(s(de), {
462
- render: (K = (N = (H = n.cellByColId[s(X).Amount]) == null ? void 0 : H.column) == null ? void 0 : N.columnDef) == null ? void 0 : K.cell,
463
- props: (A = (Z = n.cellByColId[s(X).Amount]) == null ? void 0 : Z.getContext) == null ? void 0 : A.call(Z)
464
- }, null, 8, ["render", "props"]),
465
- i[2] || (i[2] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
466
- ]),
467
- n.cellByColId[s(X).Cost] ? (k(), T("div", Ps, [
468
- c(kt, { "z-index": 50 }, {
469
- default: P(() => [
470
- c(_, {
471
- label: s(x)(`inventory.transfer.form.items.table.${s(X).Cost}2`)
472
- }, null, 8, ["label"])
473
- ]),
474
- _: 1
475
- }),
476
- c(s(de), {
477
- render: (r = (V = (E = n.cellByColId[s(X).Cost]) == null ? void 0 : E.column) == null ? void 0 : V.columnDef) == null ? void 0 : r.cell,
478
- props: (O = (u = n.cellByColId[s(X).Cost]) == null ? void 0 : u.getContext) == null ? void 0 : O.call(u)
479
- }, null, 8, ["render", "props"]),
480
- i[3] || (i[3] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
481
- ])) : B("", !0)
482
- ]),
483
- n.showComparePrice && Object.keys(n.comparePriceBySku[(oe = n.row.original.sku) == null ? void 0 : oe._id] ?? {}).length > 0 ? (k(), T(ne, { key: 0 }, [
484
- c(t, { class: "h-8" }),
485
- c(St, {
486
- prices: n.comparePriceBySku[(J = n.row.original.sku) == null ? void 0 : J._id]
487
- }, null, 8, ["prices"])
488
- ], 64)) : B("", !0)
489
- ]);
490
- };
491
- }
492
- });
493
- function Es(g) {
494
- const x = q({
495
- get() {
496
- const t = g.getEffectiveAt();
497
- return t ? new Date(t) : null;
498
- },
499
- set(t) {
500
- g.setEffectiveAt((t == null ? void 0 : t.toISOString()) ?? null);
501
- }
502
- }), n = q({
503
- get() {
504
- return !!x.value;
505
- },
506
- set(t) {
507
- t ? x.value = /* @__PURE__ */ new Date() : x.value = null;
508
- }
509
- }), i = q({
510
- get() {
511
- return x.value === null ? "" : Xe(x.value);
512
- },
513
- set(t) {
514
- t ? x.value = /* @__PURE__ */ new Date(`${t} ${_.value}`) : x.value = null;
515
- }
516
- }), _ = q({
517
- get() {
518
- return x.value === null ? "" : Rt(x.value);
519
- },
520
- set(t) {
521
- t ? x.value = /* @__PURE__ */ new Date(`${i.value} ${t}`) : x.value = null;
522
- }
523
- });
524
- return {
525
- backdatePo: x,
526
- backdateSwitch: n,
527
- backdateModel: i,
528
- backdateTimeModel: _
529
- };
530
- }
531
- const As = {
532
- width: "24",
533
- height: "24",
534
- viewBox: "0 0 24 24",
535
- fill: "none",
536
- xmlns: "http://www.w3.org/2000/svg"
537
- }, Os = ["fill"], qs = ["fill"], Us = ["stroke"], Ms = ["stroke"], Ns = /* @__PURE__ */ re({
538
- __name: "SparkIcon",
539
- props: {
540
- size: {
541
- type: Number,
542
- default: 24
543
- },
544
- color: {
545
- type: String,
546
- default: "#c7c7cc"
547
- }
548
- },
549
- setup(g) {
550
- return (x, n) => (k(), T("svg", As, [
551
- l("path", {
552
- 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",
553
- fill: g.color
554
- }, null, 8, Os),
555
- l("path", {
556
- 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",
557
- fill: g.color
558
- }, null, 8, qs),
559
- l("path", {
560
- 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",
561
- stroke: g.color,
562
- "stroke-width": "1.5",
563
- "stroke-linecap": "round",
564
- "stroke-linejoin": "round"
565
- }, null, 8, Us),
566
- l("path", {
567
- 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",
568
- stroke: g.color,
569
- "stroke-width": "1.5",
570
- "stroke-linecap": "round",
571
- "stroke-linejoin": "round"
572
- }, null, 8, Ms)
573
- ]));
574
- }
575
- }), zs = { class: "flex gap-8 items-center" }, Bs = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, Ls = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, Hs = { class: "flex items-center w-full" }, js = { class: "flex-1" }, Ys = { class: "fm-typo-en-title-sm-800" }, Qs = { class: "flex items-start gap-8" }, Ks = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Xs = { class: "flex gap-1" }, mt = /* @__PURE__ */ re({
576
- __name: "ForecastStock",
577
- props: {
578
- disabled: { type: Boolean }
579
- },
580
- emits: ["update:poItems"],
581
- setup(g, { emit: x }) {
582
- const n = x, i = U(!1), _ = U(7), t = ts(), d = Ve(), C = Le(), { t: $ } = ge();
583
- async function m() {
584
- if (_.value < 1)
585
- return;
586
- i.value = !1, await t.readPurchaseOrder(_.value);
587
- const e = [];
588
- if (t.purchaseOrderForecast.skus.length <= 0) {
589
- d.open({
590
- message: $("inventory.transfer.form.items.forecastStock.notAvailable"),
591
- type: "info"
592
- });
593
- return;
594
- }
595
- const o = t.purchaseOrderForecast.skus.reduce((p, f) => {
596
- const v = C.skus.find((F) => F._id === f.id);
597
- if (p.find((F) => F.sku._id === f.id) || !v)
598
- return p;
599
- const h = {
600
- sku: v,
601
- code: v.code,
602
- name: v.name,
603
- quantity: {
604
- amount: f.amount,
605
- precision: 0
606
- }
607
- };
608
- return p.push(h), p;
609
- }, e);
610
- n("update:poItems", o);
611
- }
612
- return (e, o) => {
613
- const p = D("FmButton"), f = D("FmIcon"), v = D("FmStepperField"), S = D("FmPopover");
614
- return k(), Q(S, {
615
- disabled: e.disabled,
616
- class: "flex",
617
- "show-popover": i.value,
618
- onPopoverChanged: o[3] || (o[3] = (h) => i.value = h)
619
- }, {
620
- "popover-button": P(() => [
621
- c(p, {
622
- label: "unused",
623
- variant: "secondary",
624
- "text-color": e.disabled ? "disabled" : "primary",
625
- "bg-color": "transparent",
626
- "border-color": e.disabled ? "disabled" : "primary",
627
- disabled: e.disabled
628
- }, {
629
- default: P(() => [
630
- l("div", zs, [
631
- c(Ns, {
632
- size: 24,
633
- color: e.disabled ? "#c7c7cc" : "#ff7823"
634
- }, null, 8, ["color"]),
635
- l("div", Bs, R(s($)("inventory.transfer.form.items.forecastStock.title")), 1)
636
- ])
637
- ]),
638
- _: 1
639
- }, 8, ["text-color", "border-color", "disabled"])
640
- ]),
641
- default: P(() => [
642
- l("div", Ls, [
643
- l("div", Hs, [
644
- l("div", js, [
645
- c(ps, { "z-index": 99 }, {
646
- default: P(() => [
647
- l("p", Ys, R(s($)("inventory.transfer.form.items.forecastStock.title")), 1)
648
- ]),
649
- _: 1
650
- })
651
- ]),
652
- c(p, {
653
- icon: "close",
654
- size: "md",
655
- variant: "tertiary",
656
- onClick: o[0] || (o[0] = (h) => i.value = !1)
657
- })
658
- ]),
659
- c(v, {
660
- modelValue: _.value,
661
- "onUpdate:modelValue": o[1] || (o[1] = (h) => _.value = h),
662
- label: s($)("inventory.transfer.form.items.forecastStock.days"),
663
- rules: [s(qe)(1)]
664
- }, {
665
- "helper-text": P(() => [
666
- l("div", Qs, [
667
- c(f, {
668
- name: "warning",
669
- size: "sm",
670
- class: "text-fm-color-system-warning-300"
671
- }),
672
- l("div", Ks, R(s($)("inventory.transfer.form.items.forecastStock.replace")), 1)
673
- ])
674
- ]),
675
- _: 1
676
- }, 8, ["modelValue", "label", "rules"]),
677
- l("div", Xs, [
678
- o[4] || (o[4] = l("div", { class: "grow" }, null, -1)),
679
- c(p, {
680
- label: s($)("common.cancel"),
681
- variant: "tertiary",
682
- onClick: o[2] || (o[2] = (h) => i.value = !1)
683
- }, null, 8, ["label"]),
684
- c(p, {
685
- label: s($)("inventory.transfer.form.items.forecastStock.generate"),
686
- onClick: m
687
- }, null, 8, ["label"])
688
- ])
689
- ])
690
- ]),
691
- _: 1
692
- }, 8, ["disabled", "show-popover"]);
693
- };
694
- }
695
- });
696
- function Zs() {
697
- const g = Ve(), x = Je(), n = U(!1);
698
- be(n, (d) => {
699
- d && (_.value = !0, i().finally(() => {
700
- _.value = !1;
701
- }));
702
- });
703
- async function i() {
704
- try {
705
- const { startDate: d, endDate: C } = Et(6), e = (await x.getPurchaseOrders({ start: d, end: C })).filter(
706
- (o) => {
707
- var p, f;
708
- return o.status === At.enum.COMPLETE && ((p = o.supplier) == null ? void 0 : p.internal) !== "warehouse" && ((f = o.supplier) == null ? void 0 : f.internal) !== "restaurant";
709
- }
710
- ).reduce((o, p) => {
711
- const f = new Date(Ot(p._id)), v = p.supplier._id;
712
- for (const S of p.items) {
713
- if (!S.totalCost) continue;
714
- const h = o[S.sku._id] ?? {}, F = h[v] ?? [];
715
- F.push({
716
- date: f.toISOString(),
717
- totalUnit: S.quantity,
718
- totalCost: S.totalCost,
719
- unit: S.sku.unit,
720
- measurement: S.measurement,
721
- seqNumber: p.seqNumber
722
- }), h[v] = F, o[S.sku._id] = h;
723
- }
724
- return o;
725
- }, {});
726
- t.value = e;
727
- } catch {
728
- g.open({
729
- title: "Something went wrong",
730
- message: "Cannot retrieve supplier purchase history. Please try again."
731
- }), n.value = !1;
732
- }
733
- }
734
- const _ = U(!1), t = U({});
735
- return {
736
- comparePricesToggle: n,
737
- comparePriceFetching: _,
738
- comparePriceBySku: t
739
- };
740
- }
741
- const Js = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, Ws = { key: 0 }, Gs = ["colspan"], ea = /* @__PURE__ */ re({
742
- __name: "TransferItemTable",
743
- props: {
744
- templateItem: {},
745
- row: {},
746
- comparePriceBySku: {},
747
- showComparePrice: { type: Boolean },
748
- disabled: { type: Boolean }
749
- },
750
- emits: ["update:item"],
751
- setup(g) {
752
- function x(n) {
753
- return n.column.columnDef.meta;
754
- }
755
- return (n, i) => {
756
- var _, t;
757
- return k(), T(ne, null, [
758
- l("tr", {
759
- class: Y(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
760
- "bg-fm-color-neutral-gray-100": n.row.getIsSelected()
761
- }])
762
- }, [
763
- (k(!0), T(ne, null, De(n.row.getVisibleCells(), (d) => {
764
- var C, $, m, e;
765
- return k(), T("td", {
766
- key: d.id,
767
- class: Y(["h-[56px] text-fm-color-typo-primary", ((C = x(d)) == null ? void 0 : C.cellClass) ?? "px-16"]),
768
- style: yt({
769
- width: ($ = x(d)) == null ? void 0 : $.width,
770
- maxWidth: (m = x(d)) == null ? void 0 : m.maxWidth,
771
- textAlign: ((e = x(d)) == null ? void 0 : e.textAlign) ?? "left"
772
- })
773
- }, [
774
- l("span", Js, [
775
- c(s(de), {
776
- render: d.column.columnDef.cell,
777
- props: d.getContext()
778
- }, null, 8, ["render", "props"])
779
- ])
780
- ], 6);
781
- }), 128))
782
- ], 2),
783
- n.showComparePrice && Object.keys(n.comparePriceBySku[(_ = n.row.original.sku) == null ? void 0 : _._id] ?? {}).length > 0 ? (k(), T("tr", Ws, [
784
- l("td", {
785
- colspan: n.row.getVisibleCells().length
786
- }, [
787
- c(St, {
788
- prices: n.comparePriceBySku[(t = n.row.original.sku) == null ? void 0 : t._id]
789
- }, null, 8, ["prices"])
790
- ], 8, Gs)
791
- ])) : B("", !0)
792
- ], 64);
793
- };
794
- }
795
- }), ta = {
796
- key: 0,
797
- class: "flex flex-col gap-8"
798
- }, sa = { class: "flex flex-col gap-4" }, aa = { class: "flex items-center gap-4" }, oa = {
799
- key: 0,
800
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
801
- }, la = /* @__PURE__ */ re({
802
- __name: "NetSuiteField",
803
- props: {
804
- required: { type: Boolean },
805
- disabled: { type: Boolean },
806
- supplier: {},
807
- setting: {},
808
- items: {},
809
- onChange: { type: Function }
810
- },
811
- emits: ["netsuite:ready"],
812
- setup(g, { emit: x }) {
813
- const n = Ue(), i = g, _ = x, { t } = fs(), d = U(!1), C = U();
814
- Be(() => {
815
- var o, p, f, v;
816
- let e = {
817
- id: "",
818
- subsidiary: { id: "", name: "" },
819
- errors: []
820
- };
821
- if (!n.isEnabled || !i.required) {
822
- _("netsuite:ready", e);
823
- return;
824
- }
825
- try {
826
- const S = n.currentLocationSubsidiary();
827
- i.setting ? e = {
828
- ...i.setting,
829
- subsidiary: {
830
- id: S.id || "",
831
- name: S.name
832
- }
833
- } : e = {
834
- ...e,
835
- subsidiary: {
836
- id: S.id || "",
837
- name: S.name
838
- }
839
- };
840
- const h = n.getAvailableItems(S.id), F = i.items.filter((y) => {
841
- if (y.measurement != null) {
842
- const w = n.getAvailableMeasurements(
843
- y.sku._id,
844
- S.id
845
- );
846
- return h.includes(y.sku._id) && w.includes(y.measurement.id);
847
- }
848
- return h.includes(y.sku._id);
849
- }).map((y) => y.sku._id);
850
- i.onChange(
851
- i.items.filter((y) => F.includes(y.sku._id)),
852
- e
853
- );
854
- } finally {
855
- i.supplier.internal ? C.value = n.getNetSuiteLocation(
856
- `${i.supplier.internal}_${i.supplier._id}`
857
- ) : C.value = n.getNetSuiteVendor(i.supplier._id);
858
- const S = i.supplier.internal ? n.getLocationSubsidiary((o = C.value) == null ? void 0 : o.netSuiteId).id : (p = C.value) == null ? void 0 : p.subsidiaryId, h = i.supplier.internal ? (f = n.currentLocationSubsidiary()) == null ? void 0 : f.id : (v = n.currentVendorSubsidiary(i.supplier._id)) == null ? void 0 : v.id;
859
- !n.isEnabled || S && n.isEnabled && S == h ? _("netsuite:ready", e) : d.value = !0;
860
- }
861
- });
862
- const $ = q(
863
- () => i.supplier.internal ? n.currentLocationSubsidiary() : n.currentVendorSubsidiary(i.supplier._id)
864
- ), m = q(() => {
865
- var e, o;
866
- return C.value == null ? `Cannot find the NetSuite location for "${i.supplier.name}"` : `The subsidiary of the request
867
- location is ${(o = n.getLocationSubsidiary((e = C.value) == null ? void 0 : e.netSuiteId)) == null ? void 0 : o.fullName}`;
868
- });
869
- return (e, o) => {
870
- const p = D("FmLabel"), f = D("FmIcon"), v = D("FmField"), S = D("FmTooltip");
871
- return s(n).isEnabled && i.required ? (k(), T("div", ta, [
872
- c(p, {
873
- label: `NetSuite ${s(t)("inventory.transfer.form.netsuite.subsidiary")}`
874
- }, null, 8, ["label"]),
875
- l("div", sa, [
876
- c(S, {
877
- "z-index": 51,
878
- placement: "left",
879
- disabled: e.disabled
880
- }, {
881
- content: P(() => o[0] || (o[0] = [
882
- Te("This field is locked and based on the location of the request.")
883
- ])),
884
- default: P(() => [
885
- c(v, null, {
886
- default: P(() => {
887
- var h;
888
- return [
889
- l("div", aa, [
890
- c(f, {
891
- name: "lock_outline",
892
- size: "sm",
893
- color: e.disabled ? "neutral-gray-200" : "neutral-gray-400"
894
- }, null, 8, ["color"]),
895
- l("div", {
896
- class: Y([e.disabled ? "text-fm-color-typo-disabled" : ""])
897
- }, R((h = $.value) == null ? void 0 : h.fullName), 3)
898
- ])
899
- ];
900
- }),
901
- _: 1
902
- })
903
- ]),
904
- _: 1
905
- }, 8, ["disabled"]),
906
- d.value ? (k(), T("div", oa, R(m.value), 1)) : B("", !0)
907
- ])
908
- ])) : B("", !0);
909
- };
910
- }
911
- }), na = { class: "flex flex-col gap-4" }, ra = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, ia = { class: "flex flex-col gap-16" }, ua = { class: "flex flex-col gap-24" }, da = { class: "flex flex-col gap-8" }, ca = { class: "flex flex-col gap-4" }, ma = { class: "flex items-center gap-4" }, pa = { class: "flex flex-col gap-8" }, fa = { class: "flex flex-col gap-4" }, va = { class: "flex items-center gap-4" }, ya = {
912
- key: 3,
913
- class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
914
- }, ba = {
915
- key: 0,
916
- class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
917
- }, ga = { class: "flex-1" }, _a = { class: "flex-1" }, ha = {
918
- key: 1,
919
- class: "flex items-center gap-4"
920
- }, ka = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, xa = { class: "flex flex-col gap-16" }, Ca = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Sa = { class: "flex gap-8" }, wa = { key: 0 }, Fa = /* @__PURE__ */ re({
921
- __name: "TransferForm2",
922
- props: {
923
- modelValue: {},
924
- request: {},
925
- disabled: { type: Boolean },
926
- suppliers: {},
927
- skus: {},
928
- lastClosingDate: {}
929
- },
930
- emits: ["validation-success", "form:ready"],
931
- setup(g, { expose: x, emit: n }) {
932
- const i = g, _ = n, t = _t(), { t: d } = ge(), C = Ze(), $ = Le(), m = Ue(), e = et(), o = Ge(), p = Ct(), { breakpoints: f } = We(), v = q(() => f.value.xs || f.value.sm), S = vt({
933
- value: !1
934
- }), h = U(!1), F = q(
935
- () => {
936
- var a;
937
- return ((a = i.modelValue) == null ? void 0 : a.templateDoc) ?? p.templates.find((b) => b._id === t.template);
938
- }
939
- ), y = q(() => t.status === "DRAFT" || !t._rev);
940
- be(F, (a) => {
941
- a && y.value && (t.supplier = (a == null ? void 0 : a.purchaseOrder.supplier) ?? t.supplier);
942
- }), Be(() => {
943
- var a;
944
- try {
945
- if (t.items = t.items.map((b) => ({ ...b, id: b.id ?? b.sku._id })), !t.template) return;
946
- t.items.length || (t.items = ((a = F.value) == null ? void 0 : a.purchaseOrder.items) ?? []);
947
- } finally {
948
- h.value = !0;
949
- }
950
- }), be([h, S], ([a, b], [M, ae]) => {
951
- b.value && ae.value && _("form:ready");
952
- });
953
- const w = q(
954
- () => C.currentLocation.type === qt.restaurant
955
- );
956
- C.watchLocation(async () => {
957
- location && (t.supplier || (t.supplier = e.suppliers.find((a) => a) ?? t.supplier));
958
- });
959
- const L = ns(), H = cs(
960
- () => t,
961
- (a) => {
962
- Object.assign(t, a);
963
- },
964
- !0,
965
- !0
966
- ), N = q({
967
- get() {
968
- var a;
969
- return typeof ((a = t == null ? void 0 : t.supplier) == null ? void 0 : a.internal) == "string" ? se.TRANSFER : se.PURCHASE;
970
- },
971
- set(a) {
972
- var M;
973
- const b = typeof ((M = t == null ? void 0 : t.supplier) == null ? void 0 : M.internal) == "string" ? se.TRANSFER : se.PURCHASE;
974
- a !== b && (t.supplier = a === se.PURCHASE ? H.locationOptionsTypePurchase.value[0] : H.locationOptionsTypeTransfer.value[0]);
975
- }
976
- });
977
- be(
978
- () => {
979
- var a;
980
- return (a = i.modelValue) == null ? void 0 : a.template;
981
- },
982
- (a) => {
983
- o.mustUsePoTemplate && !a && wt(() => {
984
- var b, M;
985
- t.supplier = ((M = (b = H.locationOptionsTypeTransfer.value) == null ? void 0 : b.filter(
986
- (ae) => ae.internal === "restaurant"
987
- )) == null ? void 0 : M[0]) ?? t.supplier;
988
- });
989
- },
990
- { immediate: !0 }
991
- );
992
- const K = q(() => {
993
- let a = H.transferLocationOptions.value;
994
- return o.mustUsePoTemplate && !t.template && (a = a.filter((b) => {
995
- var M;
996
- return (M = b.sublabel) == null ? void 0 : M.startsWith("restaurant");
997
- })), a;
998
- }), Z = q({
999
- get() {
1000
- var a;
1001
- return (a = t.supplier) == null ? void 0 : a._id;
1002
- },
1003
- set(a) {
1004
- H.transferLocationModel.value = a;
1005
- }
1006
- }), A = q({
1007
- get() {
1008
- return t.remark ?? void 0;
1009
- },
1010
- set(a) {
1011
- t.remark = a;
1012
- }
1013
- }), { backdatePo: E, backdateSwitch: V, backdateModel: r, backdateTimeModel: u } = Es({
1014
- getEffectiveAt() {
1015
- return t.effectiveAt;
1016
- },
1017
- setEffectiveAt(a) {
1018
- t.effectiveAt = a;
1019
- }
1020
- }), { comparePricesToggle: O, comparePriceFetching: oe, comparePriceBySku: J } = Zs(), ce = U();
1021
- x({
1022
- validateInputs: () => {
1023
- var a, b;
1024
- (b = (a = ce.value) == null ? void 0 : a.validateInputs) == null || b.call(a);
1025
- },
1026
- resetInputsValidation: () => {
1027
- var a, b;
1028
- (b = (a = ce.value) == null ? void 0 : a.resetInputsValidation) == null || b.call(a);
1029
- },
1030
- resetInputs: () => {
1031
- var a, b;
1032
- (b = (a = ce.value) == null ? void 0 : a.resetInputs) == null || b.call(a);
1033
- }
1034
- });
1035
- const ie = q(() => ({
1036
- updateItem: (a) => {
1037
- const b = Ut.parse(a);
1038
- t.items = t.items.map((M) => M.id && M.id !== a.id || !M.id && M.sku._id !== a.sku._id ? M : b);
1039
- },
1040
- deleteItem: (a) => {
1041
- t.items = t.items.filter(
1042
- (b) => b.id ? b.id !== a.id : b.sku._id !== a.sku._id
1043
- );
1044
- }
1045
- })), ke = ys({
1046
- updateItem: (a) => ie.value.updateItem(a),
1047
- deleteItem: (a) => ie.value.deleteItem(a),
1048
- get supplier() {
1049
- return t.supplier;
1050
- },
1051
- get items() {
1052
- return t.items;
1053
- },
1054
- get transferType() {
1055
- return N.value;
1056
- },
1057
- get template() {
1058
- return F.value;
1059
- },
1060
- get disabled() {
1061
- return i.disabled;
1062
- }
1063
- }), Me = q(() => ke.columnDefs.value);
1064
- function Ne() {
1065
- var pe, _e, fe, Se, we;
1066
- const a = (fe = (_e = (pe = F.value) == null ? void 0 : pe.purchaseOrder) == null ? void 0 : _e.items) == null ? void 0 : fe.groupBy((z) => z.sku._id), b = m.isEnabled ? m.getAvailableItems((we = (Se = t.netSuite) == null ? void 0 : Se.subsidiary) == null ? void 0 : we.id) : [], M = a != null && a.size ? $.skus.filter((z) => a.has(z._id)) : $.skus, ae = m.isEnabled ? M.filter((z) => {
1067
- var te, G, le, ue;
1068
- const W = (G = (te = F.value) == null ? void 0 : te.purchaseOrder) == null ? void 0 : G.items.find(
1069
- (ve) => ve.sku._id === z._id
1070
- );
1071
- if (W != null && W.measurement != null) {
1072
- const ve = m.getAvailableMeasurements(
1073
- W.sku._id,
1074
- (ue = (le = t.netSuite) == null ? void 0 : le.subsidiary) == null ? void 0 : ue.id
1075
- );
1076
- return b.includes(W.sku._id) && ve.includes(W.measurement.id);
1077
- }
1078
- return b.includes(z._id);
1079
- }).map((z) => z._id) : M.map((z) => z._id), me = M.map(
1080
- (z) => {
1081
- var W, te, G, le;
1082
- return {
1083
- label: ((te = (W = a == null ? void 0 : a.get(z._id)) == null ? void 0 : W[0]) == null ? void 0 : te.name) ?? z.name,
1084
- sublabel: ((le = (G = a == null ? void 0 : a.get(z._id)) == null ? void 0 : G[0]) == null ? void 0 : le.code) ?? z.code,
1085
- value: z,
1086
- disabled: !ae.includes(z._id)
1087
- };
1088
- }
1089
- ), Ce = me.filter((z) => {
1090
- var W;
1091
- return (W = t.items) == null ? void 0 : W.find((te) => te.sku._id === z.value._id);
1092
- }).map((z) => z.value);
1093
- L.open({
1094
- title: d("inventory.transfer.form.items.selectItem"),
1095
- closeButton: !0,
1096
- contentComponent: Bt,
1097
- contentComponentProps: {
1098
- modelValue: Ce,
1099
- items: me,
1100
- virtualScroll: !0
1101
- },
1102
- primaryActions: {
1103
- text: d("common.confirm"),
1104
- close: !0
1105
- },
1106
- secondaryActions: {
1107
- text: d("common.close"),
1108
- close: !0,
1109
- variant: "tertiary"
1110
- }
1111
- }).onPrimary((z) => {
1112
- const W = t.items ?? [], te = z.map((G) => {
1113
- var ve, Re;
1114
- const le = W.find((Fe) => Fe.sku._id === G._id);
1115
- if (le)
1116
- return le;
1117
- const ue = ((Re = (ve = F.value) == null ? void 0 : ve.purchaseOrder.items) == null ? void 0 : Re.find(
1118
- (Fe) => Fe.sku._id === G._id
1119
- )) ?? {
1120
- sku: G,
1121
- code: G.code,
1122
- name: G.name,
1123
- quantity: {
1124
- amount: 1,
1125
- precision: 0
1126
- }
1127
- };
1128
- return N.value == se.PURCHASE && (ue.totalCost = he(
1129
- ue.sku,
1130
- ue.quantity,
1131
- ue.measurement,
1132
- {
1133
- supplier: t.supplier
1134
- }
1135
- )), ue;
1136
- });
1137
- te.sort((G, le) => G.sku.code.localeCompare(le.sku.code)), t.items = te;
1138
- });
1139
- }
1140
- function He(a) {
1141
- return a;
1142
- }
1143
- const xe = q(() => {
1144
- const a = [];
1145
- return (!o.mustUsePoTemplate || o.mustUsePoTemplate && t.template) && a.push({
1146
- label: d("inventory.transfer.form.type.purchase"),
1147
- value: se.PURCHASE
1148
- }), a.push({
1149
- label: d("inventory.transfer.form.type.transfer"),
1150
- value: se.TRANSFER
1151
- }), a;
1152
- }), Pe = q(() => {
1153
- var a;
1154
- return (a = i.modelValue) == null ? void 0 : a.items.every((b) => b.quantity.amount <= 0);
1155
- });
1156
- return (a, b) => {
1157
- var ve, Re;
1158
- const M = D("FmChip"), ae = D("FmLabel"), me = D("FmIcon"), Ce = D("FmField"), pe = D("FmTooltip"), _e = D("FmSelect"), fe = D("FmTextField"), Se = D("FmTextarea"), we = D("FmSwitch"), z = D("FmDatePicker"), W = D("FmTimePicker"), te = D("FmFormGroup"), G = D("FmButton"), le = D("FmTable"), ue = D("FmForm");
1159
- return k(), T("div", na, [
1160
- l("div", ra, [
1161
- (ve = i.modelValue) != null && ve.template ? (k(), Q(M, {
1162
- key: 0,
1163
- variant: a.disabled ? "warning" : void 0,
1164
- label: `${s(d)("inventory.transfer.template.title")}: ${((Re = F.value) == null ? void 0 : Re.name) ?? s(d)("inventory.transfer.form.loading")}`,
1165
- icon: "summarize",
1166
- compact: ""
1167
- }, null, 8, ["variant", "label"])) : B("", !0),
1168
- c(M, {
1169
- label: s(C).currentLocation.name,
1170
- icon: "storefront",
1171
- compact: ""
1172
- }, null, 8, ["label"]),
1173
- a.lastClosingDate ? (k(), Q(M, {
1174
- key: 1,
1175
- label: `${s(d)("inventory.transfer.form.lastClosing")}: ${s(Xe)(a.lastClosingDate)} ${s(Mt)(a.lastClosingDate)}`,
1176
- icon: "calendar_month",
1177
- compact: ""
1178
- }, null, 8, ["label"])) : B("", !0)
1179
- ]),
1180
- c(ue, {
1181
- ref_key: "formRef",
1182
- ref: ce,
1183
- class: "flex flex-col gap-32",
1184
- disabled: a.disabled,
1185
- onValidationFailed: console.log,
1186
- onValidationSuccess: b[14] || (b[14] = (Fe) => _("validation-success"))
1187
- }, {
1188
- default: P(() => {
1189
- var Fe, tt, st, at, ot, lt, nt, rt;
1190
- return [
1191
- l("div", ia, [
1192
- l("div", ua, [
1193
- (Fe = i.modelValue) != null && Fe.template ? (k(), T(ne, { key: 0 }, [
1194
- l("div", da, [
1195
- c(ae, {
1196
- label: s(d)("inventory.transfer.form.type.title")
1197
- }, null, 8, ["label"]),
1198
- l("div", ca, [
1199
- c(pe, {
1200
- "z-index": 51,
1201
- placement: "left",
1202
- disabled: a.disabled
1203
- }, {
1204
- content: P(() => b[15] || (b[15] = [
1205
- Te("This field is locked from template.")
1206
- ])),
1207
- default: P(() => [
1208
- c(Ce, null, {
1209
- default: P(() => [
1210
- l("div", ma, [
1211
- c(me, {
1212
- name: "lock_outline",
1213
- size: "sm",
1214
- color: a.disabled ? "neutral-gray-200" : "neutral-gray-400"
1215
- }, null, 8, ["color"]),
1216
- l("div", {
1217
- class: Y({ "text-fm-color-typo-disabled": a.disabled })
1218
- }, R(s(d)(`inventory.transfer.form.type.${N.value.toLocaleLowerCase("en-us")}`)), 3)
1219
- ])
1220
- ]),
1221
- _: 1
1222
- })
1223
- ]),
1224
- _: 1
1225
- }, 8, ["disabled"]),
1226
- l("div", {
1227
- class: Y([
1228
- "fm-typo-en-body-sm-400",
1229
- a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1230
- ])
1231
- }, null, 2)
1232
- ])
1233
- ]),
1234
- l("div", pa, [
1235
- c(ae, {
1236
- label: N.value === s(se).PURCHASE ? s(d)("inventory.transfer.form.purchaseFrom") : s(d)("inventory.transfer.form.transferFrom")
1237
- }, null, 8, ["label"]),
1238
- l("div", fa, [
1239
- c(pe, {
1240
- "z-index": 51,
1241
- placement: "left",
1242
- disabled: a.disabled
1243
- }, {
1244
- content: P(() => b[16] || (b[16] = [
1245
- Te("This field is locked from template.")
1246
- ])),
1247
- default: P(() => [
1248
- c(Ce, null, {
1249
- default: P(() => {
1250
- var I;
1251
- return [
1252
- l("div", va, [
1253
- c(me, {
1254
- name: "lock_outline",
1255
- size: "sm",
1256
- color: a.disabled ? "neutral-gray-200" : "neutral-gray-400"
1257
- }, null, 8, ["color"]),
1258
- l("div", {
1259
- class: Y({ "text-fm-color-typo-disabled": a.disabled })
1260
- }, R((I = K.value.find((ee) => ee.value === Z.value)) == null ? void 0 : I.label), 3)
1261
- ])
1262
- ];
1263
- }),
1264
- _: 1
1265
- })
1266
- ]),
1267
- _: 1
1268
- }, 8, ["disabled"])
1269
- ])
1270
- ])
1271
- ], 64)) : (k(), T(ne, { key: 1 }, [
1272
- c(_e, {
1273
- label: s(d)("inventory.transfer.form.type.title"),
1274
- "label-mark": "required",
1275
- modelValue: N.value,
1276
- "onUpdate:modelValue": b[0] || (b[0] = (I) => N.value = I),
1277
- items: xe.value,
1278
- rules: [s(qe)(1)(xe.value)]
1279
- }, {
1280
- default: P(() => [
1281
- l("span", {
1282
- class: Y([
1283
- "line-clamp-1 fm-typo-en-body-lg-400",
1284
- a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1285
- ])
1286
- }, R(s(Nt)(N.value)), 3)
1287
- ]),
1288
- _: 1
1289
- }, 8, ["label", "modelValue", "items", "rules"]),
1290
- c(_e, {
1291
- label: N.value === s(se).PURCHASE ? s(d)("inventory.transfer.form.purchaseFrom") : s(d)("inventory.transfer.form.transferFrom"),
1292
- "label-mark": "required",
1293
- modelValue: Z.value,
1294
- "onUpdate:modelValue": b[1] || (b[1] = (I) => Z.value = I),
1295
- items: K.value,
1296
- rules: [s(qe)(1)(K.value)]
1297
- }, {
1298
- "menu-wrapper": P((I) => {
1299
- var ee, Ee;
1300
- return [
1301
- c(ms, Qe(I, {
1302
- items: K.value,
1303
- "model-value": (Ee = (ee = a.modelValue) == null ? void 0 : ee.supplier) == null ? void 0 : Ee._id
1304
- }), null, 16, ["items", "model-value"])
1305
- ];
1306
- }),
1307
- default: P(() => {
1308
- var I;
1309
- return [
1310
- l("span", {
1311
- class: Y([
1312
- "line-clamp-1 fm-typo-en-body-lg-400",
1313
- a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1314
- ])
1315
- }, R((I = K.value.find((ee) => ee.value === Z.value)) == null ? void 0 : I.label), 3)
1316
- ];
1317
- }),
1318
- _: 1
1319
- }, 8, ["label", "modelValue", "items", "rules"])
1320
- ], 64)),
1321
- c(fe, {
1322
- label: s(d)("inventory.transfer.form.reference"),
1323
- "label-mark": "optional",
1324
- modelValue: s(t).ref,
1325
- "onUpdate:modelValue": b[2] || (b[2] = (I) => s(t).ref = I)
1326
- }, null, 8, ["label", "modelValue"]),
1327
- c(Se, {
1328
- label: s(d)("inventory.transfer.form.remark"),
1329
- "label-mark": "optional",
1330
- "max-length": 240,
1331
- modelValue: A.value,
1332
- "onUpdate:modelValue": b[3] || (b[3] = (I) => A.value = I),
1333
- class: Y([a.disabled ? "text-fm-color-typo-disabled " : ""])
1334
- }, null, 8, ["label", "modelValue", "class"]),
1335
- h.value ? (k(), Q(la, {
1336
- key: 2,
1337
- required: s(t).template != null,
1338
- disabled: a.disabled,
1339
- supplier: s(t).supplier,
1340
- setting: s(t).netSuite,
1341
- items: s(t).items,
1342
- onChange: (I, ee) => {
1343
- s(t).items = I, s(t).netSuite = ee;
1344
- },
1345
- "onNetsuite:ready": b[4] || (b[4] = (I) => {
1346
- S.value = !0;
1347
- })
1348
- }, null, 8, ["required", "disabled", "supplier", "setting", "items", "onChange"])) : B("", !0),
1349
- s(o).enableBackdatePo ? (k(), T("div", ya, [
1350
- l("div", {
1351
- class: Y([
1352
- "flex",
1353
- {
1354
- "flex-col": v.value
1355
- }
1356
- ])
1357
- }, [
1358
- c(we, {
1359
- modelValue: s(V),
1360
- "onUpdate:modelValue": b[5] || (b[5] = (I) => $e(V) ? V.value = I : null),
1361
- label: s(d)("inventory.transfer.form.backdate.title"),
1362
- sublabel: s(d)("inventory.transfer.form.backdate.subtitle"),
1363
- "label-placement": "right",
1364
- disabled: w.value && !a.lastClosingDate || a.disabled
1365
- }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1366
- l("div", {
1367
- class: Y({ hidden: v.value, "w-16": !v.value })
1368
- }, null, 2),
1369
- s(V) ? (k(), T("div", ba, [
1370
- l("div", ga, [
1371
- c(z, {
1372
- modelValue: s(r),
1373
- "onUpdate:modelValue": b[6] || (b[6] = (I) => $e(r) ? r.value = I : null)
1374
- }, null, 8, ["modelValue"])
1375
- ]),
1376
- l("div", _a, [
1377
- c(W, {
1378
- modelValue: s(u),
1379
- "onUpdate:modelValue": b[7] || (b[7] = (I) => $e(u) ? u.value = I : null)
1380
- }, null, 8, ["modelValue"])
1381
- ])
1382
- ])) : B("", !0)
1383
- ], 2),
1384
- s(E) ? (k(), Q(te, {
1385
- key: 0,
1386
- modelValue: s(E),
1387
- "onUpdate:modelValue": b[8] || (b[8] = (I) => $e(E) ? E.value = I : null),
1388
- rules: [s(zt)(new Date(a.lastClosingDate), /* @__PURE__ */ new Date())]
1389
- }, null, 8, ["modelValue", "rules"])) : B("", !0),
1390
- w.value && !a.lastClosingDate ? (k(), T("div", ha, [
1391
- c(me, {
1392
- name: "error",
1393
- size: "sm",
1394
- class: "text-fm-color-typo-warning"
1395
- }),
1396
- l("span", ka, R(s(d)("inventory.transfer.form.backdate.error")), 1)
1397
- ])) : B("", !0)
1398
- ])) : B("", !0)
1399
- ])
1400
- ]),
1401
- l("div", xa, [
1402
- c(te, {
1403
- "model-value": s(t).items,
1404
- rules: [s(qe)(1)]
1405
- }, null, 8, ["model-value", "rules"]),
1406
- l("div", {
1407
- class: Y([
1408
- "flex gap-16",
1409
- {
1410
- "flex-col items-start": v.value,
1411
- "items-center": !v.value
1412
- }
1413
- ])
1414
- }, [
1415
- l("div", Ca, R(s(d)("inventory.transfer.form.items.title")), 1),
1416
- l("div", Sa, [
1417
- c(G, {
1418
- disabled: a.disabled,
1419
- label: s(d)("inventory.transfer.form.items.addItem"),
1420
- "prepend-icon": "add",
1421
- variant: "secondary",
1422
- "text-color": "primary",
1423
- "bg-color": "transparent",
1424
- "border-color": "primary",
1425
- onClick: b[9] || (b[9] = (I) => Ne()),
1426
- size: "md"
1427
- }, null, 8, ["disabled", "label"]),
1428
- s(t).template ? (k(), Q(pe, {
1429
- key: 0,
1430
- "z-index": 50
1431
- }, {
1432
- content: P(() => [
1433
- l("div", null, R(s(d)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1434
- ]),
1435
- default: P(() => [
1436
- c(mt, {
1437
- "onUpdate:poItems": b[10] || (b[10] = (I) => s(t).items = I),
1438
- disabled: ""
1439
- })
1440
- ]),
1441
- _: 1
1442
- })) : (k(), Q(mt, {
1443
- key: 1,
1444
- "onUpdate:poItems": b[11] || (b[11] = (I) => s(t).items = I),
1445
- disabled: a.disabled || !!s(t).template
1446
- }, null, 8, ["disabled"]))
1447
- ])
1448
- ], 2),
1449
- N.value === s(se).PURCHASE && y.value && s(o).enableTotalCost && ((tt = a.modelValue) != null && tt.items.length) ? (k(), T("div", wa, [
1450
- c(we, {
1451
- label: s(oe) ? s(d)("inventory.transfer.form.items.fetchingData") : s(d)("inventory.transfer.form.items.comparePriceHistory"),
1452
- "prepend-icon": "compare_arrows",
1453
- "label-placement": "right",
1454
- "model-value": s(O),
1455
- "onUpdate:modelValue": b[12] || (b[12] = (I) => $e(O) ? O.value = I : null),
1456
- disabled: s(oe) || a.disabled
1457
- }, null, 8, ["label", "model-value", "disabled"])
1458
- ])) : B("", !0),
1459
- c(te, {
1460
- "model-value": Pe.value,
1461
- rules: [() => Pe.value ? "Must have at least one non-zero item" : !0]
1462
- }, null, 8, ["model-value", "rules"]),
1463
- (k(), Q(le, {
1464
- "column-defs": Me.value,
1465
- "column-visibility": {
1466
- [s(X).Code]: !(((st = a.modelValue) == null ? void 0 : st.template) ?? ((at = a.modelValue) == null ? void 0 : at.templateDoc)),
1467
- [s(X).Name]: !(((ot = a.modelValue) == null ? void 0 : ot.template) ?? ((lt = a.modelValue) == null ? void 0 : lt.templateDoc)),
1468
- [s(X).TemplateName]: !!(((nt = a.modelValue) == null ? void 0 : nt.template) ?? ((rt = a.modelValue) == null ? void 0 : rt.templateDoc))
1469
- },
1470
- "row-data": s(t).items,
1471
- key: s(t).items.map((I) => I.sku._id).join("."),
1472
- "hide-footer": "",
1473
- "page-size": s(t).items.length
1474
- }, {
1475
- "table-row": P((I) => {
1476
- var ee, Ee, it, ut;
1477
- return [
1478
- c(ea, {
1479
- "compare-price-by-sku": s(J),
1480
- "show-compare-price": N.value === s(se).PURCHASE && s(O),
1481
- row: I,
1482
- "template-item": (ut = (it = (Ee = (ee = a.modelValue) == null ? void 0 : ee.templateDoc) == null ? void 0 : Ee.purchaseOrder) == null ? void 0 : it.items) == null ? void 0 : ut.find(
1483
- (je) => je.sku._id === I.original.sku._id
1484
- ),
1485
- "onUpdate:item": b[13] || (b[13] = (je) => ie.value.updateItem(je)),
1486
- disabled: a.disabled
1487
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "template-item", "disabled"])
1488
- ];
1489
- }),
1490
- "list-row": P((I) => [
1491
- (k(), Q(ht, {
1492
- row: I,
1493
- key: s(t).items.map((ee) => ee.sku._id).join(".")
1494
- }, {
1495
- default: P((ee) => [
1496
- c(Rs, {
1497
- "compare-price-by-sku": s(J),
1498
- "show-compare-price": N.value === s(se).PURCHASE && s(O),
1499
- row: I,
1500
- "cell-by-col-id": ee
1501
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1502
- ]),
1503
- _: 2
1504
- }, 1032, ["row"]))
1505
- ]),
1506
- _: 1
1507
- }, 8, ["column-defs", "column-visibility", "row-data", "page-size"]))
1508
- ])
1509
- ];
1510
- }),
1511
- _: 1
1512
- }, 8, ["disabled", "onValidationFailed"])
1513
- ]);
1514
- };
1515
- }
1516
- }), $a = { class: "flex items-center" }, Ia = { class: "fm-typo-en-title-md-800" }, Da = { class: "flex gap-4" }, Ta = /* @__PURE__ */ re({
1517
- __name: "TransferDialog",
1518
- props: {
1519
- mode: {},
1520
- modelValue: {},
1521
- templateId: {},
1522
- show: { type: Boolean },
1523
- lastClosingDate: {}
1524
- },
1525
- emits: ["update:show", "submitted"],
1526
- setup(g, { expose: x, emit: n }) {
1527
- var V;
1528
- const i = g, _ = n, t = Je(), d = Ct(), C = Ve(), $ = et(), m = Le(), e = Ze(), { t: o } = ge(), p = U(!1), f = U(!1), v = U(!1);
1529
- async function S(r) {
1530
- if (r) {
1531
- f.value = !1;
1532
- try {
1533
- await $.readSuppliers(), f.value = !0;
1534
- } catch {
1535
- C.open({
1536
- title: o("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1537
- message: o("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1538
- type: "error"
1539
- });
1540
- }
1541
- }
1542
- }
1543
- e.watchLocation(S);
1544
- function h() {
1545
- return {
1546
- remark: void 0,
1547
- ref: void 0,
1548
- stockSnapshotId: void 0,
1549
- effectiveAt: void 0,
1550
- items: [],
1551
- supplier: {
1552
- _rev: void 0,
1553
- email: void 0,
1554
- internal: void 0,
1555
- contactName: void 0,
1556
- phoneNumber: void 0,
1557
- registrationNumber: void 0,
1558
- supplyItems: void 0,
1559
- _id: "",
1560
- name: "",
1561
- address: {
1562
- line2: void 0,
1563
- line1: "",
1564
- state: "",
1565
- city: "",
1566
- postcode: "",
1567
- country: ""
1568
- }
1569
- },
1570
- status: "DRAFT",
1571
- _id: "",
1572
- seqNumber: 0,
1573
- deliveryOrder: [],
1574
- template: i.templateId,
1575
- templateDoc: d.templates.find((u) => u._id === i.templateId)
1576
- };
1577
- }
1578
- const F = xt(i, "show"), y = U(i.modelValue ?? h()), w = U(((V = i.modelValue) == null ? void 0 : V._id) ?? `${Math.random()}`);
1579
- be(
1580
- () => i.show,
1581
- (r) => {
1582
- var u;
1583
- r && (v.value = !1, y.value = i.modelValue ?? h(), w.value = ((u = i.modelValue) == null ? void 0 : u._id) ?? `${Math.random()}`);
1584
- }
1585
- );
1586
- const L = q(() => !f.value || !v.value), H = q(() => {
1587
- switch (i.mode) {
1588
- case Ae.READ:
1589
- return "View transfer";
1590
- case Ae.CREATE:
1591
- return o("inventory.transfer.receiveRequest.create.title");
1592
- case Ae.UPDATE:
1593
- return o("inventory.transfer.receiveRequest.update.title");
1594
- }
1595
- return "";
1596
- }), N = U();
1597
- x({
1598
- validateInputs: () => {
1599
- var r, u;
1600
- (u = (r = N.value) == null ? void 0 : r.validateInputs) == null || u.call(r);
1601
- },
1602
- resetInputsValidation: () => {
1603
- var r, u;
1604
- (u = (r = N.value) == null ? void 0 : r.resetInputsValidation) == null || u.call(r);
1605
- },
1606
- resetInputs: () => {
1607
- var r, u;
1608
- (u = (r = N.value) == null ? void 0 : r.resetInputs) == null || u.call(r);
1609
- }
1610
- });
1611
- async function K() {
1612
- const r = y.value;
1613
- if (p.value = !0, r.items = r.items.filter((u) => u.quantity.amount > 0), !r.items.length) {
1614
- C.open({
1615
- title: "Cannot create order",
1616
- message: "There are no items with non-zero amount in your request.",
1617
- type: "error"
1618
- });
1619
- return;
1620
- }
1621
- (r.supplier.internal === "warehouse" || r.supplier.internal === "restaurant") && (r.items = r.items.map(({ totalCost: u, ...O }) => O));
1622
- try {
1623
- await t.createPurchaseOrder(r), await new Promise((u) => setTimeout(u, 1e3)), C.open({
1624
- title: o("inventory.transfer.receiveRequest.create.success"),
1625
- message: o("inventory.transfer.receiveRequest.create.successMessage"),
1626
- type: "success"
1627
- }), _("update:show", !1), _("submitted");
1628
- } catch (u) {
1629
- C.open({
1630
- title: o("inventory.transfer.receiveRequest.create.error.title"),
1631
- message: o("inventory.transfer.receiveRequest.create.error.message"),
1632
- type: "error"
1633
- }), console.error("Error in creating purchase order", u);
1634
- } finally {
1635
- p.value = !1;
1636
- }
1637
- }
1638
- async function Z() {
1639
- const r = y.value;
1640
- if (p.value = !0, r.items = r.items.filter((u) => u.quantity.amount > 0), !r.items.length) {
1641
- C.open({
1642
- title: "Cannot create order",
1643
- message: "There are no items with non-zero amount in your request.",
1644
- type: "error"
1645
- });
1646
- return;
1647
- }
1648
- (r.supplier.internal === "warehouse" || r.supplier.internal === "restaurant") && (r.items = r.items.map(({ totalCost: u, ...O }) => O));
1649
- try {
1650
- await t.updatePurchaseOrder(r), await new Promise((u) => setTimeout(u, 1e3)), C.open({
1651
- title: o("inventory.transfer.receiveRequest.update.success"),
1652
- message: o("inventory.transfer.receiveRequest.update.successMessage"),
1653
- type: "success"
1654
- }), _("update:show", !1), _("submitted");
1655
- } catch (u) {
1656
- C.open({
1657
- title: o("inventory.transfer.receiveRequest.update.error.title"),
1658
- message: o("inventory.transfer.receiveRequest.update.error.message"),
1659
- type: "error"
1660
- }), console.error("Error in updating purchase order", u);
1661
- } finally {
1662
- p.value = !1;
1663
- }
1664
- }
1665
- function A() {
1666
- switch (i.mode) {
1667
- case Ae.CREATE:
1668
- return K();
1669
- case Ae.UPDATE:
1670
- return Z();
1671
- }
1672
- }
1673
- function E() {
1674
- var r, u;
1675
- (u = (r = N.value) == null ? void 0 : r.validateInputs) == null || u.call(r);
1676
- }
1677
- return (r, u) => {
1678
- const O = D("FmButton"), oe = D("FmSideSheet");
1679
- return k(), Q(oe, {
1680
- modelValue: s(F),
1681
- "onUpdate:modelValue": u[3] || (u[3] = (J) => $e(F) ? F.value = J : null),
1682
- "dismiss-away": "",
1683
- "close-button": "",
1684
- "max-width": 900
1685
- }, {
1686
- "side-sheet-header": P(() => [
1687
- l("div", $a, [
1688
- l("div", Ia, R(H.value), 1)
1689
- ])
1690
- ]),
1691
- default: P(() => [
1692
- (k(), Q(Fa, {
1693
- class: "w-full",
1694
- ref_key: "formRef",
1695
- ref: N,
1696
- "onForm:ready": u[0] || (u[0] = () => v.value = !0),
1697
- onValidationSuccess: A,
1698
- modelValue: y.value,
1699
- "onUpdate:modelValue": u[1] || (u[1] = (J) => y.value = J),
1700
- disabled: p.value || L.value,
1701
- suppliers: s($).suppliers,
1702
- skus: s(m).skus,
1703
- key: w.value,
1704
- "last-closing-date": r.lastClosingDate
1705
- }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1706
- ]),
1707
- "side-sheet-footer": P(() => [
1708
- l("div", Da, [
1709
- c(O, {
1710
- loading: p.value,
1711
- disabled: L.value,
1712
- label: s(o)("common.save"),
1713
- onClick: E
1714
- }, null, 8, ["loading", "disabled", "label"]),
1715
- c(O, {
1716
- disabled: L.value,
1717
- variant: "tertiary",
1718
- label: s(o)("common.close"),
1719
- onClick: u[2] || (u[2] = (J) => _("update:show", !1))
1720
- }, null, 8, ["disabled", "label"])
1721
- ])
1722
- ]),
1723
- _: 1
1724
- }, 8, ["modelValue"]);
1725
- };
1726
- }
1727
- });
1728
- function Va(g) {
1729
- const [x, n, i, ..._] = Lt(g), t = i.map((m) => m.toLowerCase().trim().replace(/ /g, "_")), C = ["item_name", "transfer_quantity(uom)", "uom", "scanned_code"].filter((m) => !t.includes(m));
1730
- if (C.length)
1731
- throw new Error(
1732
- `Missing headers (${C.join()}). Excel file does not come from the template.`
1733
- );
1734
- return _.map((m, e) => {
1735
- const o = {};
1736
- for (const p in t) {
1737
- const f = t[p];
1738
- Object.assign(o, { [f]: m[p] });
1739
- }
1740
- return {
1741
- index: e,
1742
- data: o
1743
- };
1744
- });
1745
- }
1746
- function Pa(g) {
1747
- const x = g.SheetNames;
1748
- try {
1749
- return x.reduce(
1750
- (i, _) => {
1751
- const t = new Array(), d = g.Sheets[_], C = Le(), $ = Va(d), m = [];
1752
- for (const { index: o, data: p } of $) {
1753
- p.scanned_code === "" && t.push(`Row ${o + 1}: Scanned code is empty`), p.item_name === "" && t.push(`Row ${o + 1}: Item name is empty`), p.uom === "" && t.push(`Row ${o + 1}: UOM is empty`), p["transfer_quantity(uom)"] === "" && t.push(`Row ${o + 1}: Transfer quantity is empty`);
1754
- const f = C.skus.find((h) => h.code === p.scanned_code);
1755
- if (!f) {
1756
- t.push(`Row ${o + 1}: SKU not found`);
1757
- continue;
1758
- }
1759
- const v = f.unit.abbrev === p.uom;
1760
- let S = null;
1761
- if (!v) {
1762
- const h = f.unit.measurements.find((F) => F.abbrev === p.uom);
1763
- if (!h) {
1764
- t.push(`Row ${o + 1}: Measurement not found`);
1765
- continue;
1766
- }
1767
- S = h;
1768
- }
1769
- m.push({
1770
- sku: f,
1771
- code: p.scanned_code,
1772
- name: p.item_name,
1773
- quantity: bt.fromNumber(Number(p["transfer_quantity(uom)"])),
1774
- measurement: S
1775
- });
1776
- }
1777
- const e = {
1778
- type: "create",
1779
- poItems: m,
1780
- excelSheetName: _,
1781
- errors: t
1782
- };
1783
- return i.importCreateResult.push(e), i;
1784
- },
1785
- {
1786
- invalidExcel: !1,
1787
- importCreateResult: new Array()
1788
- }
1789
- );
1790
- } catch (n) {
1791
- return {
1792
- invalidExcel: !0,
1793
- invalidExcelMessage: (n == null ? void 0 : n.message) ?? "Invalid excel",
1794
- importCreateResult: []
1795
- };
1796
- }
1797
- }
1798
- const Ra = exports.FfCalculator, Ea = { class: "flex flex-col flex-1" }, Aa = { class: "flex flex-col" }, Oa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, qa = {
1799
- key: 0,
1800
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1801
- }, Ua = { key: 0 }, Ma = {
1802
- class: /* @__PURE__ */ Y(["fm-typo-en-body-lg-600"])
1803
- }, Na = { class: "flex-1" }, za = { class: "flex-auto line-clamp-2 text-ellipsis break-all fm-typo-en-body-sm-400" }, Ba = { class: "flex-auto line-clamp-2 text-ellipsis break-all" }, La = { class: "text-fm-color-typo-primary" }, Ha = { class: "ml-auto" }, ja = { key: 0 }, Ya = /* @__PURE__ */ re({
1804
- __name: "XilnexResult",
1805
- props: {
1806
- type: {},
1807
- name: {},
1808
- items: {},
1809
- errors: {}
1810
- },
1811
- setup(g) {
1812
- const x = g, { t: n } = ge(), i = U(!1), _ = () => {
1813
- x.errors.length && (i.value = !i.value);
1814
- };
1815
- return (t, d) => {
1816
- var m;
1817
- const C = D("FmIcon"), $ = D("FmTooltip");
1818
- return k(), T("div", Ea, [
1819
- l("div", {
1820
- onClick: _,
1821
- class: Y({
1822
- "cursor-pointer": t.errors.length
1823
- })
1824
- }, [
1825
- l("div", Aa, [
1826
- l("div", Oa, [
1827
- l("div", {
1828
- class: Y({
1829
- "text-fm-color-system-error-300": t.errors.length
1830
- })
1831
- }, [
1832
- Te(R(t.name) + " ", 1),
1833
- t.type === "create" ? (k(), T("span", qa, "(" + R(s(n)("inventory.closing.template.import.new")) + ")", 1)) : B("", !0)
1834
- ], 2),
1835
- t.errors.length ? (k(), T("div", Ua, [
1836
- c(C, {
1837
- name: "error",
1838
- size: "sm",
1839
- color: "system-error-300"
1840
- })
1841
- ])) : B("", !0)
1842
- ]),
1843
- d[0] || (d[0] = l("hr", { class: "my-2" }, null, -1)),
1844
- l("div", Ma, [
1845
- (m = t.items) != null && m.length ? (k(!0), T(ne, { key: 0 }, De(t.items, (e, o) => (k(), T("div", {
1846
- key: o,
1847
- class: "flex gap-4 mt-2 items-center"
1848
- }, [
1849
- l("div", Na, [
1850
- c($, {
1851
- content: e.code,
1852
- placement: "top",
1853
- "z-index": 51
1854
- }, {
1855
- default: P(() => [
1856
- l("span", za, R(e.code), 1)
1857
- ]),
1858
- _: 2
1859
- }, 1032, ["content"]),
1860
- c($, {
1861
- content: e.name,
1862
- placement: "top",
1863
- "z-index": 51
1864
- }, {
1865
- default: P(() => [
1866
- l("span", Ba, R(e.name), 1)
1867
- ]),
1868
- _: 2
1869
- }, 1032, ["content"])
1870
- ]),
1871
- l("div", null, [
1872
- l("span", La, R(s(Ra).toFormatString({
1873
- value: e.quantity
1874
- })), 1),
1875
- Te(" " + R(e.measurement ? e.measurement.abbrev : e.sku.unit.abbrev), 1)
1876
- ])
1877
- ]))), 128)) : B("", !0)
1878
- ])
1879
- ]),
1880
- l("div", Ha, [
1881
- t.errors.length ? (k(), Q(C, {
1882
- key: 0,
1883
- name: i.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
1884
- size: "md"
1885
- }, null, 8, ["name"])) : B("", !0)
1886
- ])
1887
- ], 2),
1888
- i.value ? (k(), T("div", {
1889
- key: 0,
1890
- class: Y(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
1891
- "text-fm-color-typo-secondary": !t.errors.length,
1892
- "text-fm-color-system-error-300": t.errors.length
1893
- }])
1894
- }, [
1895
- t.errors.length ? (k(), T("div", ja, [
1896
- l("ol", null, [
1897
- (k(!0), T(ne, null, De(t.errors, (e, o) => (k(), T("li", { key: o }, R(e), 1))), 128))
1898
- ])
1899
- ])) : B("", !0)
1900
- ], 2)) : B("", !0)
1901
- ]);
1902
- };
1903
- }
1904
- }), Qa = { class: "flex flex-col gap-24" }, Ka = {
1905
- key: 0,
1906
- class: "flex items-center gap-8"
1907
- }, Xa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Za = { class: "flex flex-col gap-8" }, Ja = { class: "line-clamp-2 text-ellipsis break-all" }, Wa = {
1908
- key: 2,
1909
- class: "shrink-0"
1910
- }, Ga = {
1911
- key: 0,
1912
- class: "flex flex-col"
1913
- }, eo = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, to = {
1914
- key: 0,
1915
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1916
- }, so = { class: "fm-typo-en-body-lg-600" }, pt = "Transfer note", ao = /* @__PURE__ */ re({
1917
- __name: "XilnexImportForm",
1918
- setup(g, { expose: x }) {
1919
- const n = U(null), i = Ve(), _ = U(!1), t = U(!1), d = _t(), C = U(!1), $ = Ue();
1920
- U([]);
1921
- const m = q({
1922
- get() {
1923
- var y;
1924
- return ((y = d.supplier) == null ? void 0 : y.name) ?? "";
1925
- },
1926
- set(y) {
1927
- y && (d.supplier = {
1928
- name: y,
1929
- registrationNumber: "",
1930
- _id: "xilnex",
1931
- internal: "restaurant",
1932
- address: {
1933
- line1: "",
1934
- line2: "",
1935
- city: "",
1936
- state: "",
1937
- country: "",
1938
- postcode: ""
1939
- }
1940
- });
1941
- }
1942
- });
1943
- Be(async () => {
1944
- const y = await $.getNetSuiteLocations();
1945
- console.log(y), C.value = !0;
1946
- });
1947
- const e = q({
1948
- get() {
1949
- return "";
1950
- },
1951
- set(y) {
1952
- if (y) {
1953
- const w = d.effectiveAt ? new Date(d.effectiveAt) : /* @__PURE__ */ new Date(), [L, H, N] = y.split("-");
1954
- w.setFullYear(parseInt(L)), w.setMonth(parseInt(H) - 1), w.setDate(parseInt(N)), d.effectiveAt = w.toISOString();
1955
- }
1956
- }
1957
- }), o = q({
1958
- get() {
1959
- return null;
1960
- },
1961
- set(y) {
1962
- if (y) {
1963
- const w = d.effectiveAt ? new Date(d.effectiveAt) : /* @__PURE__ */ new Date(), [L, H] = y.split(":");
1964
- w.setMinutes(parseInt(L)), w.setSeconds(parseInt(H)), d.effectiveAt = w.toISOString();
1965
- }
1966
- }
1967
- }), p = U(new Array()), f = U([]), v = q(
1968
- () => !!p.value.length || f.value.some((y) => y.errors.length)
1969
- ), S = U();
1970
- x({
1971
- validateInputs: () => {
1972
- var y, w;
1973
- (w = (y = S.value) == null ? void 0 : y.validateInputs) == null || w.call(y);
1974
- },
1975
- resetInputsValidation: () => {
1976
- var y, w;
1977
- (w = (y = S.value) == null ? void 0 : y.resetInputsValidation) == null || w.call(y);
1978
- },
1979
- resetInputs: () => {
1980
- var y, w;
1981
- (w = (y = S.value) == null ? void 0 : y.resetInputs) == null || w.call(y);
1982
- }
1983
- });
1984
- const { t: h } = ge();
1985
- async function F(y) {
1986
- p.value = [], f.value = [];
1987
- try {
1988
- _.value = !0;
1989
- const [w] = await Promise.all([
1990
- jt(y),
1991
- // fake buffer
1992
- new Promise((H) => setTimeout(H, 1e3))
1993
- ]), L = Pa(w);
1994
- if (L.invalidExcel) {
1995
- p.value.push(
1996
- L.invalidExcelMessage ?? h("inventory.ingredient.import.fileError.invalidExcel")
1997
- );
1998
- return;
1999
- }
2000
- if (f.value = L.importCreateResult, !f.value.length) {
2001
- p.value.push(h("inventory.ingredient.import.fileError.noData"));
2002
- return;
2003
- }
2004
- d.items = f.value.map((H) => H.poItems).flat();
2005
- } catch (w) {
2006
- i.open({
2007
- title: h("inventory.ingredient.import.fileError.unableToRead"),
2008
- message: w == null ? void 0 : w.message,
2009
- type: "error"
2010
- }), console.error("Error in reading file", w);
2011
- } finally {
2012
- p.value.length && i.open({
2013
- title: h("inventory.ingredient.import.fileError.invalidExcel"),
2014
- type: "error"
2015
- }), _.value = !1;
2016
- }
2017
- }
2018
- return be(n, (y) => {
2019
- y && F(y);
2020
- }), (y, w) => {
2021
- const L = D("FmSelect"), H = D("FmDatePicker"), N = D("FmTimePicker"), K = D("FmCircularProgress"), Z = D("FmLabel"), A = D("FmIcon"), E = D("FmButton"), V = D("FmForm");
2022
- return k(), Q(V, {
2023
- ref_key: "formRef",
2024
- ref: S
2025
- }, {
2026
- default: P(() => [
2027
- l("div", Qa, [
2028
- c(L, {
2029
- modelValue: m.value,
2030
- "onUpdate:modelValue": w[0] || (w[0] = (r) => m.value = r),
2031
- label: "Transfer from",
2032
- searchable: "",
2033
- searchTarget: "label",
2034
- items: [
2035
- { label: "Object", value: null },
2036
- { label: "Array", value: ["array", "1"] },
2037
- { label: "Number", value: 3 },
2038
- { label: "String", value: "4" },
2039
- { label: "1", value: "5" },
2040
- { label: "2", value: "6" }
2041
- ],
2042
- "helper-text": "Helper",
2043
- rules: [s(Oe)()]
2044
- }, null, 8, ["modelValue", "rules"]),
2045
- c(H, {
2046
- modelValue: e.value,
2047
- "onUpdate:modelValue": w[1] || (w[1] = (r) => e.value = r),
2048
- label: "Transfer date",
2049
- rules: [s(Oe)()]
2050
- }, null, 8, ["modelValue", "rules"]),
2051
- c(N, {
2052
- modelValue: o.value,
2053
- "onUpdate:modelValue": w[2] || (w[2] = (r) => o.value = r),
2054
- label: "Transfer time",
2055
- rules: [s(Oe)()]
2056
- }, null, 8, ["modelValue", "rules"]),
2057
- t.value ? (k(), T("div", Ka, [
2058
- l("div", null, [
2059
- c(K, {
2060
- size: "md",
2061
- color: "neutral-gray-200"
2062
- })
2063
- ]),
2064
- l("div", Xa, R(s(h)("inventory.formField.loading")), 1)
2065
- ])) : (k(), T(ne, { key: 1 }, [
2066
- c(Ht, {
2067
- "max-file-size": 5,
2068
- class: Y({
2069
- "w-full": !0,
2070
- "h-[200px]": !n.value
2071
- }),
2072
- accept: ".xlsx,.xls",
2073
- label: pt,
2074
- onFileUpload: w[3] || (w[3] = (r) => n.value = r),
2075
- "button-label": s(h)("inventory.ingredient.import.selectFile")
2076
- }, Ft({ _: 2 }, [
2077
- n.value ? {
2078
- name: "default",
2079
- fn: P(({ openFileDialog: r }) => [
2080
- c(Z, null, {
2081
- default: P(() => [
2082
- Te(R(pt))
2083
- ]),
2084
- _: 1
2085
- }),
2086
- l("div", Za, [
2087
- l("div", {
2088
- class: Y([
2089
- "fm-corner-radius-md p-16 flex items-center gap-16",
2090
- {
2091
- "border border-fm-color-neutral-gray-100": _.value,
2092
- "border border-fm-color-neutral-gray-200": !_.value && !v.value,
2093
- "border border-fm-color-system-error-200": v.value
2094
- }
2095
- ])
2096
- }, [
2097
- _.value ? (k(), Q(K, {
2098
- key: 0,
2099
- size: "md",
2100
- color: "neutral-gray-200"
2101
- })) : (k(), Q(A, {
2102
- key: 1,
2103
- name: v.value ? "error" : "attach_file",
2104
- outline: "",
2105
- color: v.value ? "system-error-300" : void 0
2106
- }, null, 8, ["name", "color"])),
2107
- l("div", {
2108
- class: Y([
2109
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
2110
- {
2111
- "text-fm-color-typo-disabled": _.value,
2112
- "text-fm-color-typo-primary": !_.value
2113
- }
2114
- ])
2115
- }, [
2116
- l("div", Ja, R(n.value.name), 1)
2117
- ], 2),
2118
- _.value ? B("", !0) : (k(), T("div", Wa, [
2119
- c(E, {
2120
- label: s(h)("inventory.ingredient.import.replaceFile"),
2121
- variant: v.value ? "destructive" : "secondary",
2122
- "prepend-icon": v.value ? void 0 : "autorenew",
2123
- onClick: r
2124
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
2125
- ]))
2126
- ], 2),
2127
- p.value.length ? (k(), T("div", Ga, [
2128
- (k(!0), T(ne, null, De(p.value, (u, O) => (k(), T("div", {
2129
- key: O,
2130
- class: "flex gap-8 items-center"
2131
- }, [
2132
- c(A, {
2133
- name: "error",
2134
- size: "sm",
2135
- color: "system-error-300"
2136
- }),
2137
- l("div", eo, R(u), 1)
2138
- ]))), 128))
2139
- ])) : B("", !0)
2140
- ])
2141
- ]),
2142
- key: "0"
2143
- } : void 0
2144
- ]), 1032, ["class", "button-label"]),
2145
- n.value ? (k(), T("div", to, [
2146
- l("div", so, R(s(h)("inventory.ingredient.import.summary")), 1),
2147
- (k(!0), T(ne, null, De(f.value, (r, u) => (k(), Q(Ya, {
2148
- key: u,
2149
- name: `Transfer Note ${u + 1}`,
2150
- items: r.poItems,
2151
- errors: r.errors,
2152
- type: "create"
2153
- }, null, 8, ["name", "items", "errors"]))), 128))
2154
- ])) : B("", !0)
2155
- ], 64))
2156
- ])
2157
- ]),
2158
- _: 1
2159
- }, 512);
2160
- };
2161
- }
2162
- }), oo = { class: "w-[480px]" }, lo = /* @__PURE__ */ re({
2163
- __name: "XilnexImportDialog",
2164
- props: {
2165
- show: { type: Boolean }
2166
- },
2167
- emits: ["update:show", "submitted"],
2168
- setup(g, { expose: x, emit: n }) {
2169
- const i = n, t = xt(g, "show"), d = Ve(), C = Je(), $ = U(!1), m = U(), e = U();
2170
- x({
2171
- validateInputs: () => {
2172
- var f, v;
2173
- (v = (f = m.value) == null ? void 0 : f.validateInputs) == null || v.call(f);
2174
- },
2175
- resetInputsValidation: () => {
2176
- var f, v;
2177
- (v = (f = m.value) == null ? void 0 : f.resetInputsValidation) == null || v.call(f);
2178
- },
2179
- resetInputs: () => {
2180
- var f, v;
2181
- (v = (f = m.value) == null ? void 0 : f.resetInputs) == null || v.call(f);
2182
- }
2183
- });
2184
- function o() {
2185
- var f, v;
2186
- (v = (f = m.value) == null ? void 0 : f.validateInputs) == null || v.call(f);
2187
- }
2188
- async function p() {
2189
- var v, S, h, F, y;
2190
- if (!((S = (v = e.value) == null ? void 0 : v.supplier) != null && S.name)) {
2191
- d.open({
2192
- title: "Upload failed",
2193
- message: "Location is required",
2194
- type: "error"
2195
- });
2196
- return;
2197
- }
2198
- if (!((h = e.value) != null && h.items) || ((y = (F = e.value) == null ? void 0 : F.items) == null ? void 0 : y.length) === 0) {
2199
- d.open({
2200
- title: "Upload failed",
2201
- message: "No data to upload",
2202
- type: "error"
2203
- });
2204
- return;
2205
- }
2206
- const f = e.value.effectiveAt ? new Date(e.value.effectiveAt) : null;
2207
- if (!f) {
2208
- d.open({
2209
- title: "Invalid date",
2210
- message: "Transfer date is required",
2211
- type: "error"
2212
- });
2213
- return;
2214
- }
2215
- if (f.getTime() > (/* @__PURE__ */ new Date()).getTime()) {
2216
- d.open({
2217
- title: "Invalid date",
2218
- message: "Transfer date cannot be in the future",
2219
- type: "error"
2220
- });
2221
- return;
2222
- }
2223
- $.value = !0;
2224
- try {
2225
- await C.importFromXilnex(e.value), i("update:show", !1);
2226
- } catch (w) {
2227
- await new Promise((L) => setTimeout(L, 1e3)), d.open({
2228
- title: "Upload failed",
2229
- message: w == null ? void 0 : w.message,
2230
- type: "error"
2231
- });
2232
- } finally {
2233
- $.value = !1;
2234
- }
2235
- }
2236
- return (f, v) => {
2237
- const S = D("FmSpacer"), h = D("FmButton"), F = D("FmDialog");
2238
- return k(), Q(F, {
2239
- modelValue: s(t),
2240
- "onUpdate:modelValue": v[2] || (v[2] = (y) => $e(t) ? t.value = y : null),
2241
- overlay: !0,
2242
- "close-button": !1
2243
- }, {
2244
- "dialog-header": P(() => v[3] || (v[3] = [
2245
- l("div", null, "Xilnex transfer order", -1)
2246
- ])),
2247
- "dialog-footer": P(() => [
2248
- c(S, { class: "sm:hidden xs:hidden" }),
2249
- c(h, {
2250
- disabled: $.value,
2251
- class: "sm:w-full xs:w-full",
2252
- label: "Cancel",
2253
- size: "md",
2254
- variant: "tertiary",
2255
- onClick: v[1] || (v[1] = (y) => i("update:show", !1))
2256
- }, null, 8, ["disabled"]),
2257
- c(h, {
2258
- disabled: $.value,
2259
- loading: $.value,
2260
- class: "sm:w-full xs:w-full",
2261
- label: "Upload",
2262
- size: "md",
2263
- variant: "primary",
2264
- onClick: o
2265
- }, null, 8, ["disabled", "loading"])
2266
- ]),
2267
- default: P(() => [
2268
- l("div", oo, [
2269
- c(ao, {
2270
- ref_key: "formRef",
2271
- ref: m,
2272
- onValidationSuccess: p,
2273
- modelValue: e.value,
2274
- "onUpdate:modelValue": v[0] || (v[0] = (y) => e.value = y)
2275
- }, null, 8, ["modelValue"])
2276
- ])
2277
- ]),
2278
- _: 1
2279
- }, 8, ["modelValue"]);
2280
- };
2281
- }
2282
- }), no = { class: "flex flex-col py-8" }, ro = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, io = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, uo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, co = {
2283
- key: 0,
2284
- class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
2285
- }, mo = { class: "pt-8" }, ft = "ReceiveRequestViewSearchCriteria", Do = /* @__PURE__ */ re({
2286
- __name: "ReceiveRequestView",
2287
- setup(g) {
2288
- const { t: x } = ge(), n = Ve();
2289
- ze.object({
2290
- name: ze.string().optional().nullable(),
2291
- startDate: ze.string().optional().nullable(),
2292
- endDate: ze.string().optional().nullable()
2293
- });
2294
- const i = q(
2295
- () => !p._currentLocation || e.loading.value
2296
- ), _ = os(), t = Ge(), d = Ue();
2297
- function C() {
2298
- const A = {
2299
- name: "",
2300
- ...dt()
2301
- }, E = _.getItem(ft);
2302
- if (!E)
2303
- return A;
2304
- try {
2305
- return JSON.parse(E);
2306
- } catch {
2307
- return A;
2308
- }
2309
- }
2310
- function $() {
2311
- _.setItem(ft, JSON.stringify(m.value));
2312
- }
2313
- const m = U(C()), e = Jt(
2314
- Ye.RECEIVE_REQUEST,
2315
- m.value
2316
- ), { columnDefs: o } = Wt(
2317
- Ye.RECEIVE_REQUEST,
2318
- e
2319
- ), p = Ze();
2320
- async function f() {
2321
- const A = `inventory-record_${ct(m.value.startDate).format("DD-MM-YYYY_HH-mm")}-${ct(m.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, E = e.purchaseOrders.value.flatMap(
2322
- (r) => r.items.map((u) => {
2323
- var ke;
2324
- const O = new Date(ss(r._id) ?? ""), oe = r.effectiveAt ? new Date(r.effectiveAt) : void 0, J = Ie(
2325
- es(u.sku, r.deliveryOrder || [])
2326
- ), ce = Ie(u.quantity), ie = ((ke = u == null ? void 0 : u.measurement) == null ? void 0 : ke.abbrev) || u.sku.unit.abbrev;
2327
- return {
2328
- "SKU code": u.code,
2329
- "SKU name": u.name,
2330
- "PO #": r.seqNumber,
2331
- "Effective at": oe,
2332
- Date: O,
2333
- Status: r.status,
2334
- Reference: r.ref ?? "",
2335
- "Received quantity": J,
2336
- "Ordered quantity": ce,
2337
- Unit: ie,
2338
- "Total cost": u.totalCost ? Ke(u.totalCost) : null
2339
- };
2340
- })
2341
- ), V = [
2342
- "SKU code",
2343
- "SKU name",
2344
- "PO #",
2345
- "Date",
2346
- "Status",
2347
- "Reference",
2348
- "Received quantity",
2349
- "Ordered quantity",
2350
- "Unit"
2351
- ];
2352
- t.enableBackdatePo && V.insert("Effective at", 4), t.enableTotalCost && V.push("Total cost"), await as(
2353
- [
2354
- {
2355
- name: "purchases",
2356
- data: E,
2357
- columns: V
2358
- }
2359
- ],
2360
- A
2361
- ), n.open({
2362
- title: x("inventory.transfer.receiveRequest.export.success"),
2363
- message: x("inventory.transfer.receiveRequest.export.message", [A]),
2364
- type: "success"
2365
- });
2366
- }
2367
- const v = U(dt()), S = U("");
2368
- be([() => v.value], ([A]) => {
2369
- !A.startDate || !A.endDate || (m.value.startDate = A.startDate, m.value.endDate = A.endDate, e.updateDateRange(
2370
- m.value.startDate,
2371
- m.value.endDate
2372
- ), $());
2373
- }), be([() => S.value], () => {
2374
- $();
2375
- });
2376
- function h(A) {
2377
- if (A === "create") {
2378
- if (i.value) {
2379
- n.open({
2380
- title: "Loading data...",
2381
- message: "Please wait.",
2382
- type: "info"
2383
- });
2384
- return;
2385
- }
2386
- return e.promptCreateTransferDialog();
2387
- }
2388
- if (A === "upload" && t.enableXilnexTransferNote)
2389
- return e.promptUploadTransferDialog();
2390
- if (A === "refresh")
2391
- return e.fetchData();
2392
- if (A === "export")
2393
- return f();
2394
- }
2395
- const { breakpoints: F } = We(), y = q(() => F.value.xs || F.value.sm), w = q(() => y.value ? 10 : 20), L = Yt(), H = q(() => [
2396
- {
2397
- label: x("inventory.transfer.receiveRequest.actions.create"),
2398
- value: "create",
2399
- isPrimary: !0,
2400
- prependIcon: "add"
2401
- },
2402
- ...t.enableXilnexTransferNote ? [
2403
- {
2404
- label: "Upload",
2405
- value: "upload"
2406
- }
2407
- ] : [],
2408
- {
2409
- label: x("inventory.common.refresh"),
2410
- value: "refresh"
2411
- },
2412
- {
2413
- label: x("inventory.common.export"),
2414
- value: "export"
2415
- }
2416
- ]), N = q(() => {
2417
- const A = [
2418
- {
2419
- type: "string",
2420
- key: "status",
2421
- entity: "purchaseOrder",
2422
- values: Array.from(
2423
- new Set(e.purchaseOrders.value.map((V) => V.status))
2424
- )
2425
- }
2426
- ], E = [
2427
- {
2428
- type: "string",
2429
- key: "netsuiteTransactionNumber",
2430
- entity: "purchaseOrder",
2431
- values: e.purchaseOrders.value.map((V) => {
2432
- var r, u;
2433
- return (u = (r = V.netSuite) == null ? void 0 : r.additionalInfo) == null ? void 0 : u.transactionnumber;
2434
- }).filter((V) => V != null)
2435
- },
2436
- {
2437
- type: "string",
2438
- key: "netsuiteOrderNo",
2439
- entity: "purchaseOrder",
2440
- values: e.purchaseOrders.value.map((V) => {
2441
- var r;
2442
- return (r = V.netSuite) == null ? void 0 : r.refNo;
2443
- }).filter((V) => V != null)
2444
- },
2445
- {
2446
- type: "string",
2447
- key: "netsuiteOrderId",
2448
- entity: "purchaseOrder",
2449
- values: e.purchaseOrders.value.map((V) => {
2450
- var r;
2451
- return (r = V.netSuite) == null ? void 0 : r.id;
2452
- }).filter((V) => V != null)
2453
- }
2454
- ];
2455
- return [...A, ...d.isEnabled ? E : []];
2456
- }), K = U(null), Z = q(() => {
2457
- if (!K.value)
2458
- return e.purchaseOrders.value;
2459
- const A = Qt.build(K.value);
2460
- return e.purchaseOrders.value.filter((E) => {
2461
- var V, r, u, O;
2462
- return Kt(
2463
- {
2464
- netsuiteTransactionNumber: (r = (V = E.netSuite) == null ? void 0 : V.additionalInfo) == null ? void 0 : r.transactionnumber,
2465
- netsuiteOrderNo: (u = E.netSuite) == null ? void 0 : u.refNo,
2466
- netsuiteOrderId: (O = E.netSuite) == null ? void 0 : O.id,
2467
- status: E.status
2468
- },
2469
- A
2470
- );
2471
- });
2472
- });
2473
- return (A, E) => {
2474
- const V = D("FmTable");
2475
- return k(), Q(Xt, {
2476
- title: s(x)("inventory.transfer.receiveRequest.title2"),
2477
- actions: H.value,
2478
- "onClick:action": h
2479
- }, {
2480
- default: P(() => {
2481
- var r;
2482
- return [
2483
- l("div", {
2484
- class: Y([
2485
- "flex flex-col gap-8 max-h-full",
2486
- {
2487
- "p-0": y.value,
2488
- "px-24 ": !y.value
2489
- }
2490
- ])
2491
- }, [
2492
- c(Zt, {
2493
- "date-range-query": "",
2494
- "date-range": v.value,
2495
- "onUpdate:dateRange": E[0] || (E[0] = (u) => v.value = u),
2496
- searchable: "",
2497
- "change-location": "",
2498
- search: S.value,
2499
- "onUpdate:search": E[1] || (E[1] = (u) => S.value = u),
2500
- filterable: "",
2501
- "filter-attributes": N.value,
2502
- filter: K.value,
2503
- "onUpdate:filter": E[2] || (E[2] = (u) => K.value = u)
2504
- }, null, 8, ["date-range", "search", "filter-attributes", "filter"]),
2505
- (k(), Q(V, {
2506
- style: yt(s(L).tableHeight),
2507
- "column-defs": s(o),
2508
- "row-data": Z.value,
2509
- "search-value": S.value,
2510
- loading: i.value,
2511
- onRowClick: E[3] || (E[3] = (u) => s(e).promptShowTransferDetails(u.original)),
2512
- key: (r = s(p)._currentLocation) == null ? void 0 : r.dbName,
2513
- "page-size": w.value
2514
- }, {
2515
- "list-row": P((u) => [
2516
- c(ht, {
2517
- row: u,
2518
- onRowClick: s(e).promptShowTransferDetails
2519
- }, {
2520
- default: P((O) => {
2521
- var oe, J, ce, ie, ke, Me, Ne, He, xe, Pe, a, b, M, ae, me, Ce, pe, _e, fe, Se;
2522
- return [
2523
- l("div", no, [
2524
- l("div", ro, [
2525
- c(s(de), {
2526
- render: (ce = (J = (oe = O._id) == null ? void 0 : oe.column) == null ? void 0 : J.columnDef) == null ? void 0 : ce.cell,
2527
- props: (ke = (ie = O._id) == null ? void 0 : ie.getContext) == null ? void 0 : ke.call(ie)
2528
- }, null, 8, ["render", "props"])
2529
- ]),
2530
- l("div", io, [
2531
- c(s(de), {
2532
- render: (He = (Ne = (Me = O.supplier_name) == null ? void 0 : Me.column) == null ? void 0 : Ne.columnDef) == null ? void 0 : He.cell,
2533
- props: (Pe = (xe = O.supplier_name) == null ? void 0 : xe.getContext) == null ? void 0 : Pe.call(xe)
2534
- }, null, 8, ["render", "props"])
2535
- ]),
2536
- l("div", uo, R(u.original.items.map((we) => `${we.name}`).join(", ")), 1),
2537
- u.original.ref ? (k(), T("div", co, [
2538
- c(s(de), {
2539
- render: (M = (b = (a = O.ref) == null ? void 0 : a.column) == null ? void 0 : b.columnDef) == null ? void 0 : M.cell,
2540
- props: (me = (ae = O.ref) == null ? void 0 : ae.getContext) == null ? void 0 : me.call(ae)
2541
- }, null, 8, ["render", "props"])
2542
- ])) : B("", !0),
2543
- l("div", mo, [
2544
- c(s(de), {
2545
- render: (_e = (pe = (Ce = O.status) == null ? void 0 : Ce.column) == null ? void 0 : pe.columnDef) == null ? void 0 : _e.cell,
2546
- props: (Se = (fe = O.status) == null ? void 0 : fe.getContext) == null ? void 0 : Se.call(fe)
2547
- }, null, 8, ["render", "props"])
2548
- ])
2549
- ])
2550
- ];
2551
- }),
2552
- _: 2
2553
- }, 1032, ["row", "onRowClick"])
2554
- ]),
2555
- _: 1
2556
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2557
- ], 2),
2558
- (k(), Q($t, { to: "body" }, [
2559
- c(Ta, Qe(s(e).transferDialogProps.value, {
2560
- onSubmitted: s(e).fetchData
2561
- }), null, 16, ["onSubmitted"]),
2562
- c(Gt, Qe({
2563
- scope: s(Ye).RECEIVE_REQUEST
2564
- }, s(e).transferDetailsProps.value, {
2565
- onSubmitted: s(e).fetchData
2566
- }), null, 16, ["scope", "onSubmitted"]),
2567
- c(lo, It(Dt(s(e).xilnexImportDialogProps.value)), null, 16)
2568
- ]))
2569
- ];
2570
- }),
2571
- _: 1
2572
- }, 8, ["title", "actions"]);
2573
- };
2574
- }
2575
- });
2576
- export {
2577
- Do as default
2578
- };