@feedmepos/mf-inventory-portal 0.0.25-dev.23 → 0.0.25-dev.24

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