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

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