@feedmepos/mf-inventory-portal 1.0.15-dev.2 → 1.0.15-dev.3

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