@feedmepos/mf-inventory-portal 0.0.25-dev.17 → 0.0.25-dev.19

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