@feedmepos/mf-inventory-portal 0.0.25-dev.34 → 0.0.25-dev.36

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