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

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 (42) hide show
  1. package/dist/{App-D6WBVERc.js → App-BpouQv6g.js} +36 -34
  2. package/dist/{ApprovalView-BIBoagE8.js → ApprovalView-zKceWuqg.js} +2 -2
  3. package/dist/{BindingsDialog-DHRRkK1Z.js → BindingsDialog-8cCHlgzr.js} +2 -2
  4. package/dist/{BindingsPicker-DohvMDDF.js → BindingsPicker-Dh4Hv3td.js} +1 -1
  5. package/dist/{BindingsTable-C_JwU9ei.js → BindingsTable-DakosyVV.js} +1 -1
  6. package/dist/{ClosingDraftView-BBebhUj-.js → ClosingDraftView-BrX8I8MB.js} +2 -2
  7. package/dist/{ClosingTemplateView-CXRN19-D.js → ClosingTemplateView-Ca3J-qQ-.js} +2 -2
  8. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BJufUQNE.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BO2YZ2VJ.js} +3 -3
  9. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-C5Xk19jY.js → FmUnitInput.vue_vue_type_script_setup_true_lang-SWTCOnJ9.js} +1 -1
  10. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-7HNI82u-.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-B7n03ova.js} +1 -1
  11. package/dist/{IngredientGroupView-l2bAc1Kj.js → IngredientGroupView-BaWnW5iB.js} +1 -1
  12. package/dist/{IngredientsView-zDXt7KEx.js → IngredientsView-Dk1fRrJS.js} +4 -4
  13. package/dist/{IntegrationView-BYnlAPrP.js → IntegrationView-f95k4Sro.js} +1 -1
  14. package/dist/{InventoryBindingForm-BuweG4Vl.js → InventoryBindingForm-CQ_hf--f.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DgxN0U4N.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-D2njCVwo.js} +3 -3
  16. package/dist/{InventoryBindingSummary-BpEo0JsK.js → InventoryBindingSummary-DpyGu-QA.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CcjzkzCt.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DWA0FZIF.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-Ej20iSHA.js → PremiumBadge.vue_vue_type_script_setup_true_lang-C1rp-t32.js} +1 -1
  19. package/dist/{PublishView-DCZ0zIaP.js → PublishView-BEmw7Cvg.js} +2 -2
  20. package/dist/{PurchaseOrderPrintPreview-Cag7UEvz.js → PurchaseOrderPrintPreview-DgRHyUbj.js} +1 -1
  21. package/dist/{ReceiveRequestView-ChIJGA98.js → ReceiveRequestView-CD04SJNf.js} +162 -166
  22. package/dist/{RecipeView-bBshe0eF.js → RecipeView-BBTNekLY.js} +3 -3
  23. package/dist/{StockView-D6-oKpAC.js → StockView-BDp38gwV.js} +7 -7
  24. package/dist/{SupplierView-dyIcGp9Q.js → SupplierView-DPuo3-Ai.js} +4 -4
  25. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DE4xQTOV.js +1795 -0
  26. package/dist/{TransferTemplateView-D2rxV0k_.js → TransferTemplateView-7KZ-ITn_.js} +7 -7
  27. package/dist/{UnitView-DVS5Az5c.js → UnitView-BZ4dsN0S.js} +3 -3
  28. package/dist/{WarehouseView-CR03TpnA.js → WarehouseView-BzMsepvq.js} +1 -1
  29. package/dist/api/purchase-order.d.ts +1 -1
  30. package/dist/{app-oV9ISfFL.js → app-Bk7jf9eq.js} +186 -186
  31. package/dist/app.js +1 -1
  32. package/dist/{decimal-C7zgfr5G.js → decimal-dztcLRIl.js} +1 -1
  33. package/dist/{feature-CDQQ-mV9.js → feature-CA2bkHM2.js} +1 -1
  34. package/dist/{format-unit-display-CVBzrNQ4.js → format-unit-display-Dk23-Lk4.js} +2 -2
  35. package/dist/{index-0VS4cuk3.js → index-DHWNJM3r.js} +2 -2
  36. package/dist/{stock-BIP_NIK_.js → stock-DxWRUKuk.js} +1 -1
  37. package/dist/{supplier-DUQ2VSMg.js → supplier-kP0mKbdR.js} +1 -1
  38. package/dist/{use-ingredient-select-dialog-VkU5_Aaj.js → use-ingredient-select-dialog-CcowSH0B.js} +1 -1
  39. package/dist/{use-inventory-binding-dialog-BXp0z3v_.js → use-inventory-binding-dialog-BuTRDGfP.js} +1 -1
  40. package/dist/{vue-i18n-CCd5_SRR.js → vue-i18n-D8QaqjU5.js} +250 -250
  41. package/package.json +3 -3
  42. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-C_7wbQow.js +0 -1771
@@ -0,0 +1,1795 @@
1
+ import { W as nt, u as $e, aK as k, a5 as ot, a7 as lt, a8 as ct, am as it, d as Le, e as Je, av as U, T as Ze, aL as ut, Y as Me, K as Ce, i as Re, aM as Xe, ac as Ee, f as Qe, D as Y, h as K, b as et, a6 as dt, as as Ye, a0 as Te, ai as Ue, aw as ft } from "./app-Bk7jf9eq.js";
2
+ import { ref as j, computed as G, h as A, defineComponent as Ke, onMounted as mt, unref as o, openBlock as c, createElementBlock as h, createElementVNode as t, toDisplayString as u, createCommentVNode as N, resolveComponent as ne, createVNode as F, watch as pt, createBlock as W, isRef as vt, withCtx as be, Fragment as J, normalizeClass as he, createTextVNode as Be, renderList as _e, resolveDynamicComponent as yt } from "vue";
3
+ import { useI18n as tt } from "@feedmepos/mf-common";
4
+ import { b as ht, u as gt, f as je, P as ge } from "./format-unit-display-Dk23-Lk4.js";
5
+ import { E as We } from "./empty-placeholder-wf6-BWE8.js";
6
+ import { useDialog as Ge, useSnackbar as He, useProxiedModel as bt } from "@feedmepos/ui-library";
7
+ import { u as st } from "./feature-CA2bkHM2.js";
8
+ import { F as _t } from "./decimal-dztcLRIl.js";
9
+ const ze = nt((f, m) => {
10
+ const d = $e();
11
+ return {
12
+ async readRequests(n) {
13
+ const w = n ?? d.currentLocationDBName, O = `${f.inventoryBackendUrl}/${w}/purchase-request`;
14
+ return await m.get(O);
15
+ },
16
+ async getPurchaseOrders({
17
+ start: n,
18
+ end: w
19
+ }) {
20
+ const O = d.currentLocationDBName, $ = `${f.inventoryBackendUrl}/${O}/purchase-order`;
21
+ return await m.get(`${$}?start=${n}&end=${w}`);
22
+ },
23
+ async getLatestPurchaseOrderRequest(n, w) {
24
+ w ?? (w = d.currentLocationDBName);
25
+ const O = `${f.inventoryBackendUrl}/${w}/purchase-request/find-by-purchase-order-id`;
26
+ return await m.get(`${O}/${n}`);
27
+ },
28
+ async getPurchaseOrderById(n, w) {
29
+ w ?? (w = d.currentLocationDBName);
30
+ const O = `${f.inventoryBackendUrl}/${w}/purchase-order`;
31
+ return await m.get(`${O}/${n}`);
32
+ },
33
+ async processPurchaseOrder(n, w) {
34
+ const O = d.currentLocationDBName, $ = w || O, p = `${f.inventoryBackendUrl}/${$}/purchase-order/run-operation`;
35
+ return await m.put(p, n);
36
+ },
37
+ async createPurchaseOrder(n) {
38
+ const w = d.currentLocationDBName, O = `${f.inventoryBackendUrl}/${w}/purchase-order`;
39
+ return await m.post(O, n);
40
+ },
41
+ async updatePurchaseOrder(n) {
42
+ const w = d.currentLocationDBName, O = `${f.inventoryBackendUrl}/${w}/purchase-order`;
43
+ return await m.put(O, n);
44
+ }
45
+ };
46
+ }), rt = {
47
+ [k.enum.confirmDraft]: {
48
+ primaryActions: {
49
+ text: "Confirm draft",
50
+ close: !0
51
+ },
52
+ title: "Confirm draft?",
53
+ message: "Purchase order cannot be changed after confirm draft.",
54
+ successMessage: "Purchase order draft has been confirmed"
55
+ },
56
+ [k.enum.cancelDraft]: {
57
+ primaryActions: {
58
+ text: "Cancel draft",
59
+ close: !0,
60
+ variant: "destructive"
61
+ },
62
+ title: "Cancel draft?",
63
+ message: "Purchase order cannot be changed after cancelled draft.",
64
+ successMessage: "Purchase order draft has been cancelled"
65
+ },
66
+ [k.enum.submitRequest]: {
67
+ primaryActions: {
68
+ text: "Submit request",
69
+ close: !0
70
+ },
71
+ title: "Confirm draft?",
72
+ message: "Purchase order cannot be changed after confirm draft.",
73
+ successMessage: "Purchase order draft has been submitted"
74
+ },
75
+ [k.enum.completeReceive]: {
76
+ primaryActions: {
77
+ text: "Mark received",
78
+ close: !0
79
+ },
80
+ title: "Mark as received",
81
+ message: "Purchase order cannot be changed after it has complete receiving.",
82
+ successMessage: "Purchase order has been marked as received"
83
+ },
84
+ [k.enum.approveRequest]: {
85
+ primaryActions: {
86
+ text: "Approve request",
87
+ close: !0
88
+ },
89
+ title: "Approve request?",
90
+ message: "Purchase order will be approved.",
91
+ successMessage: "Purchase order has been approved"
92
+ },
93
+ [k.enum.rejectRequest]: {
94
+ primaryActions: {
95
+ text: "Reject request",
96
+ close: !0,
97
+ variant: "destructive"
98
+ },
99
+ title: "Reject request?",
100
+ message: "Purchase order will be rejected.",
101
+ successMessage: "Purchase order has been rejected"
102
+ }
103
+ };
104
+ var Ve = /* @__PURE__ */ ((f) => (f.RECEIVE_REQUEST = "receive/request", f.APPROVAL = "approval", f))(Ve || {});
105
+ const Se = j();
106
+ function Er(f, m) {
107
+ const d = Ge(), n = $e(), w = st(), O = ht(), $ = gt(), p = j(!1), i = He(), l = ze(), r = j(new Array()), a = j(
108
+ m != null && m.startDate && (m != null && m.endDate) ? m : ot()
109
+ ), v = G(() => {
110
+ const _ = new Date(a.value.startDate), e = new Date(a.value.endDate);
111
+ return {
112
+ start: lt(_).toISOString(),
113
+ end: ct(e).toISOString()
114
+ };
115
+ }), x = j(new Array()), E = it(), D = j(null);
116
+ function I(_) {
117
+ const e = {
118
+ mode: Le.CREATE,
119
+ modelValue: void 0,
120
+ returnFrom: _,
121
+ show: !0,
122
+ "onUpdate:show"(s) {
123
+ Se.value.show = s;
124
+ },
125
+ lastClosingDate: D.value
126
+ };
127
+ Se.value = e;
128
+ }
129
+ async function le(_) {
130
+ function e(b) {
131
+ const S = {
132
+ mode: Le.CREATE,
133
+ modelValue: _ || void 0,
134
+ show: !0,
135
+ "onUpdate:show"(C) {
136
+ Se.value.show = C;
137
+ },
138
+ templateId: b,
139
+ lastClosingDate: D.value
140
+ };
141
+ Se.value = S;
142
+ }
143
+ let s;
144
+ w.mustUsePoTemplate && !(_ != null && _.template) ? d.open({
145
+ title: "Create transfer",
146
+ message: "",
147
+ primaryActions: {
148
+ text: "Select a template",
149
+ close: !0
150
+ },
151
+ secondaryActions: {
152
+ text: "Outlet to Outlet",
153
+ variant: "secondary",
154
+ close: !0
155
+ }
156
+ }).onPrimary(async () => {
157
+ s = await O.getTemplateId(), s && e(s);
158
+ }).onSecondary(() => {
159
+ e(void 0);
160
+ }) : e(s);
161
+ }
162
+ function ce(_) {
163
+ const e = {
164
+ mode: Le.UPDATE,
165
+ modelValue: Je(_),
166
+ show: !0,
167
+ "onUpdate:show"(s) {
168
+ Se.value.show = s;
169
+ },
170
+ lastClosingDate: D.value
171
+ };
172
+ Se.value = e;
173
+ }
174
+ async function Z() {
175
+ r.value = [], p.value = !0;
176
+ try {
177
+ r.value = await l.getPurchaseOrders(v.value).then((s) => s.sort((b, S) => S._id.localeCompare(b._id)));
178
+ const _ = await E.readLastClosing(!0), e = _ == null ? void 0 : _._id;
179
+ e && (D.value = ut(e)), w.mustUsePoTemplate && await $.fetchTemplates();
180
+ } catch {
181
+ i.open({
182
+ title: "Something went wrong",
183
+ message: "Error at fetching purchase orders",
184
+ type: "error"
185
+ });
186
+ } finally {
187
+ p.value = !1;
188
+ }
189
+ }
190
+ async function ie() {
191
+ x.value = [], p.value = !0;
192
+ try {
193
+ x.value = await l.readRequests().then((_) => _.reverse());
194
+ } catch {
195
+ i.open({
196
+ title: "Something went wrong",
197
+ message: "Error at fetching purchase requests",
198
+ type: "error"
199
+ });
200
+ } finally {
201
+ p.value = !1;
202
+ }
203
+ }
204
+ function H() {
205
+ switch (f) {
206
+ case "receive/request":
207
+ return Z();
208
+ case "approval":
209
+ return ie();
210
+ }
211
+ }
212
+ function we(_, e) {
213
+ a.value = {
214
+ startDate: _,
215
+ endDate: e
216
+ }, H();
217
+ }
218
+ n.watchLocation(async (_) => {
219
+ if (!_) {
220
+ r.value = [];
221
+ return;
222
+ }
223
+ await H();
224
+ });
225
+ const re = j(), X = j(Math.random().toString());
226
+ async function Ie(_, e) {
227
+ var C, q;
228
+ const s = Math.random().toString();
229
+ X.value = s;
230
+ const b = f === "receive/request" ? n.currentLocation : e == null ? void 0 : e.to, S = {
231
+ poRequest: e,
232
+ purchaseOrder: _,
233
+ transferTo: b == null ? void 0 : b.name,
234
+ transferToDbName: b == null ? void 0 : b.dbName,
235
+ show: !0,
236
+ canResubmit: !1,
237
+ canApprove: f === "approval",
238
+ "onUpdate:show"(V) {
239
+ re.value.show = V;
240
+ },
241
+ scope: f
242
+ };
243
+ if (re.value = S, !(e || _.status !== U.enum.REQUESTING)) {
244
+ try {
245
+ e = (await l.readRequests(
246
+ `${_.supplier.internal}_${_.supplier._id}`
247
+ )).find((g) => g.purchaseOrderId === _._id);
248
+ } catch {
249
+ console.error("Error at fetching po request to check");
250
+ }
251
+ s === X.value && (re.value.canResubmit = !e, re.value.transferTo = (C = e == null ? void 0 : e.to) == null ? void 0 : C.name, re.value.transferToDbName = (q = e == null ? void 0 : e.to) == null ? void 0 : q.dbName);
252
+ }
253
+ }
254
+ async function Pe(_, e, s, b) {
255
+ p.value = !0;
256
+ try {
257
+ await l.processPurchaseOrder(
258
+ {
259
+ operation: e,
260
+ doc: _,
261
+ options: (
262
+ // auto receive for supplier to warehouse
263
+ (e === k.enum.confirmDraft || // auto receive for warehouse to warehouse
264
+ e === k.enum.completeReceive) && w.autoReceiveWarehouse ? {
265
+ autoReceive: !0
266
+ } : void 0
267
+ )
268
+ },
269
+ b
270
+ ), await new Promise((q) => setTimeout(q, 1e3));
271
+ const C = $e().currentLocationDBName.startsWith("restaurant_");
272
+ e === k.enum.confirmDraft && _.effectiveAt && C ? i.open({
273
+ title: "Success",
274
+ message: `${s}. The backdate will be reflected once your POS has received this change.`,
275
+ type: "success"
276
+ }) : i.open({
277
+ title: "Success",
278
+ message: s,
279
+ type: "success"
280
+ });
281
+ } catch (S) {
282
+ i.open({
283
+ title: "Something went wrong",
284
+ message: "Please try again.",
285
+ type: "error"
286
+ }), console.error("Error when submitting PO operation", e, _, S);
287
+ } finally {
288
+ p.value = !1, H();
289
+ }
290
+ }
291
+ async function ue(_, e, s, b) {
292
+ if (e === k.enum.returnStock)
293
+ return b ? Pe(
294
+ {
295
+ returnOrder: _,
296
+ purchaseOrder: b
297
+ },
298
+ e,
299
+ "Transfer order successfully created."
300
+ ) : void 0;
301
+ const S = rt[e];
302
+ if (!S) {
303
+ i.open({
304
+ title: "Something went wrong",
305
+ message: `Cannot process order: ${Ze(e)}`,
306
+ type: "error"
307
+ });
308
+ return;
309
+ }
310
+ const { successMessage: C, ...q } = S;
311
+ d.open({
312
+ title: q.title,
313
+ message: q.message,
314
+ primaryActions: q.primaryActions
315
+ }).onPrimary(() => {
316
+ Pe(_, e, C, s);
317
+ });
318
+ }
319
+ return {
320
+ purchaseOrders: r,
321
+ purchaseRequests: x,
322
+ updateDateRange: we,
323
+ fetchData: H,
324
+ loading: p,
325
+ transferDialogProps: Se,
326
+ promptCreateTransferDialog: le,
327
+ promptUpdateTransferDialog: ce,
328
+ promptReturnTransferDialog: I,
329
+ transferDetailsProps: re,
330
+ promptShowTransferDetails: Ie,
331
+ submitAction: ue
332
+ };
333
+ }
334
+ function St(f, m) {
335
+ return m.reduce(
336
+ (n, w) => {
337
+ const O = w.received.find(($) => $.sku._id === f._id);
338
+ return O && (n = Me(n, O.amount)), n;
339
+ },
340
+ _t.toPrecision(Ce(0), f.unit.precision)
341
+ );
342
+ }
343
+ function at(f, m) {
344
+ const { name: d, address: n, regNo: w } = m.doc.profile, O = {
345
+ name: d,
346
+ registrationNumber: w,
347
+ line1: n == null ? void 0 : n.line1,
348
+ line2: n == null ? void 0 : n.line2,
349
+ postcode: n == null ? void 0 : n.postcode,
350
+ city: n == null ? void 0 : n.city,
351
+ state: n == null ? void 0 : n.state,
352
+ country: n == null ? void 0 : n.country
353
+ }, $ = {
354
+ name: f.supplier.name,
355
+ registrationNumber: f.supplier.registrationNumber,
356
+ line1: f.supplier.address.line1,
357
+ line2: f.supplier.address.line2,
358
+ postcode: f.supplier.address.postcode,
359
+ city: f.supplier.address.city,
360
+ state: f.supplier.address.state,
361
+ country: f.supplier.address.country
362
+ }, p = f.items.map((a) => {
363
+ const { sku: v, measurement: x } = a, E = Re(
364
+ St(a.sku, f.deliveryOrder || []),
365
+ !1
366
+ );
367
+ return {
368
+ code: v.code,
369
+ description: v.name,
370
+ quantity: je(a.quantity, v.unit, a.measurement),
371
+ unit: (x == null ? void 0 : x.abbrev) || v.unit.abbrev,
372
+ received: E
373
+ };
374
+ }), i = f.deliveryOrder.map((a) => ({
375
+ createdAt: Xe(new Date(a.createdAt)),
376
+ ref: a.deliveryOrderNumber,
377
+ remark: a.remark || "",
378
+ items: a.received.map((v) => {
379
+ var x;
380
+ return {
381
+ code: v.sku.code,
382
+ description: v.sku.name,
383
+ quantity: Re(v.amount),
384
+ unit: ((x = v.measurement) == null ? void 0 : x.abbrev) || v.sku.unit.abbrev
385
+ };
386
+ })
387
+ })), l = {
388
+ orderNumber: f.seqNumber.toString(),
389
+ createdAt: Ee(f._id),
390
+ ref: f.ref || "",
391
+ remark: f.remark || "",
392
+ buyer: O,
393
+ supplier: $,
394
+ items: p,
395
+ status: f.status,
396
+ deliveryOrders: i
397
+ }, r = new URL("https://inventory.feedme.cc");
398
+ r.pathname = r.hostname.includes("inventory.feedme") || r.hostname.includes("localhost") ? "/receive-request/print-preview" : "/inventory/receive-request/print-preview", r.searchParams.append("data", JSON.stringify(l)), window.open(r.href, "_blank", "noreferrer");
399
+ }
400
+ const xe = {
401
+ submitRequest: {
402
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
403
+ color: "text-fm-color-typo-primary",
404
+ value: k.enum.submitRequest
405
+ },
406
+ confirmDraft: {
407
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
408
+ color: "text-fm-color-typo-primary",
409
+ value: k.enum.confirmDraft
410
+ },
411
+ cancelDraft: {
412
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
413
+ color: "text-fm-color-typo-error",
414
+ value: k.enum.cancelDraft
415
+ },
416
+ approveRequest: {
417
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
418
+ color: "text-fm-color-typo-primary",
419
+ value: k.enum.approveRequest
420
+ },
421
+ rejectRequest: {
422
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
423
+ color: "text-fm-color-typo-error",
424
+ value: k.enum.rejectRequest
425
+ },
426
+ processRequest: {
427
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
428
+ color: "text-fm-color-typo-primary",
429
+ value: k.enum.processRequest
430
+ },
431
+ receiveStock: {
432
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
433
+ color: "text-fm-color-typo-primary",
434
+ value: k.enum.receiveStock
435
+ },
436
+ completeReceive: {
437
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
438
+ color: "text-fm-color-typo-primary",
439
+ value: k.enum.completeReceive
440
+ },
441
+ returnStock: {
442
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
443
+ color: "text-fm-color-typo-primary",
444
+ value: k.enum.returnStock
445
+ }
446
+ };
447
+ function Ir(f, m) {
448
+ const d = $e(), { t: n } = tt();
449
+ function w(r) {
450
+ switch (r.status) {
451
+ case "DRAFT":
452
+ return [
453
+ Y[K.Update],
454
+ Y[K.Details],
455
+ r.supplier.internal === "restaurant" || r.supplier.internal === "warehouse" ? xe[k.enum.submitRequest] : xe[k.enum.confirmDraft],
456
+ xe[k.enum.cancelDraft],
457
+ Y[K.Print]
458
+ ];
459
+ case "RECEIVING":
460
+ return [
461
+ xe[k.enum.completeReceive],
462
+ Y[K.Details],
463
+ Y[K.Print]
464
+ ];
465
+ case "REQUESTING":
466
+ return f === "receive/request" ? [Y[K.Details], Y[K.Print]] : [
467
+ xe[k.enum.approveRequest],
468
+ xe[k.enum.rejectRequest],
469
+ Y[K.Details],
470
+ Y[K.Print]
471
+ ];
472
+ case "PROCESSING":
473
+ return [Y[K.Details], Y[K.Print]];
474
+ case "COMPLETE":
475
+ case "CANCEL":
476
+ default:
477
+ return [Y[K.Details], Y[K.Print]];
478
+ }
479
+ }
480
+ function O(r) {
481
+ return Object.values(k.enum).includes(r);
482
+ }
483
+ async function $(r, a, v) {
484
+ var E, D;
485
+ const x = Je(a);
486
+ if (r === K.Print) {
487
+ at(x, d.currentLocation);
488
+ return;
489
+ }
490
+ if (r === K.Details) {
491
+ m.promptShowTransferDetails(x, v).catch((I) => {
492
+ console.error("error on promptShowTransferDetails", { error: I, poRequest: v });
493
+ });
494
+ return;
495
+ }
496
+ if (r === K.Update) {
497
+ (E = m.promptUpdateTransferDialog) == null || E.call(m, x);
498
+ return;
499
+ }
500
+ if (O(r) && r != k.enum.returnStock && r != k.enum.receiveStock) {
501
+ m.submitAction(a, r, (D = v == null ? void 0 : v.to) == null ? void 0 : D.dbName).then((I) => {
502
+ console.error("error on po action", { action: r, error: I });
503
+ });
504
+ return;
505
+ }
506
+ }
507
+ function p() {
508
+ return [
509
+ {
510
+ accessorKey: "seqNumber",
511
+ header: () => n("inventory.transfer.table.seqNo"),
512
+ enableSorting: !0,
513
+ size: 80,
514
+ sortUndefined: "last"
515
+ },
516
+ {
517
+ accessorKey: "_id",
518
+ header: () => n("inventory.transfer.table.createdAt"),
519
+ cell(r) {
520
+ return Ee(`${r.getValue()}`);
521
+ },
522
+ enableSorting: !0
523
+ },
524
+ {
525
+ accessorKey: "supplier.name",
526
+ header: () => n("inventory.transfer.table.transferFrom"),
527
+ enableSorting: !0,
528
+ size: 200
529
+ },
530
+ {
531
+ accessorKey: "items.length",
532
+ header: () => n("inventory.transfer.table.noOfItems"),
533
+ enableSorting: !1,
534
+ meta: {
535
+ width: "10rem"
536
+ }
537
+ },
538
+ {
539
+ accessorKey: "ref",
540
+ header: () => n("inventory.transfer.table.reference"),
541
+ enableSorting: !1,
542
+ size: "auto"
543
+ },
544
+ {
545
+ accessorKey: "status",
546
+ header: () => n("inventory.transfer.table.status"),
547
+ cell(r) {
548
+ const a = n(`inventory.transfer.status.${r.getValue() ?? ""}`), v = `${r.getValue() ?? ""}`.toLocaleLowerCase("en-us");
549
+ return A(
550
+ "div",
551
+ {
552
+ class: "flex"
553
+ },
554
+ A(
555
+ "div",
556
+ {
557
+ class: `fm-status-badge fm-status-badge-${v}`
558
+ },
559
+ a
560
+ )
561
+ );
562
+ },
563
+ enableSorting: !0,
564
+ size: 200
565
+ },
566
+ {
567
+ id: "action",
568
+ cell(r) {
569
+ const a = r.row.original, v = w(a);
570
+ return Qe(v, (x) => $(x, a));
571
+ },
572
+ enableSorting: !1,
573
+ size: 40,
574
+ meta: {
575
+ cellClass: "",
576
+ headerClass: ""
577
+ }
578
+ }
579
+ ];
580
+ }
581
+ function i() {
582
+ return [
583
+ {
584
+ accessorKey: "purchaseOrder.seqNumber",
585
+ header: () => n("inventory.transfer.table.seqNo"),
586
+ enableSorting: !0,
587
+ size: 80,
588
+ sortUndefined: "last"
589
+ },
590
+ {
591
+ accessorKey: "purchaseOrder._id",
592
+ header: () => n("inventory.transfer.table.createdAt"),
593
+ cell(r) {
594
+ return Ee(`${r.getValue()}`);
595
+ },
596
+ enableSorting: !0
597
+ },
598
+ {
599
+ accessorKey: "to.name",
600
+ header: () => n("inventory.transfer.table.transferTo"),
601
+ enableSorting: !1,
602
+ size: 200
603
+ },
604
+ {
605
+ accessorKey: "purchaseOrder.items.length",
606
+ header: () => n("inventory.transfer.table.noOfItems"),
607
+ enableSorting: !1
608
+ },
609
+ {
610
+ accessorKey: "purchaseOrder.ref",
611
+ header: () => n("inventory.transfer.table.reference"),
612
+ enableSorting: !1,
613
+ size: "auto"
614
+ },
615
+ {
616
+ accessorKey: "purchaseOrder.status",
617
+ header: () => n("inventory.transfer.table.status"),
618
+ cell(r) {
619
+ const a = n(`inventory.transfer.status.${r.getValue() ?? ""}`), v = `${r.getValue() ?? ""}`.toLocaleLowerCase("en-us");
620
+ return A(
621
+ "div",
622
+ {
623
+ class: "flex"
624
+ },
625
+ A(
626
+ "div",
627
+ {
628
+ class: `fm-status-badge fm-status-badge-${v}`
629
+ },
630
+ a
631
+ )
632
+ );
633
+ },
634
+ enableSorting: !0
635
+ },
636
+ {
637
+ id: "action",
638
+ cell(r) {
639
+ const a = r.row.original, v = a.purchaseOrder ? w(a.purchaseOrder) : [];
640
+ return Qe(
641
+ v,
642
+ (x) => a.purchaseOrder ? $(
643
+ x,
644
+ {
645
+ ...a.purchaseOrder,
646
+ _rev: a.purchaseOrder._rev ?? ""
647
+ },
648
+ a
649
+ ) : void 0
650
+ );
651
+ },
652
+ enableSorting: !1,
653
+ size: 40,
654
+ meta: {
655
+ cellClass: "",
656
+ headerClass: ""
657
+ }
658
+ }
659
+ ];
660
+ }
661
+ const l = G(() => f === "receive/request" ? p() : i());
662
+ return {
663
+ get columnDefs() {
664
+ return l.value;
665
+ }
666
+ };
667
+ }
668
+ const wt = {
669
+ key: 0,
670
+ class: "flex flex-col gap-8"
671
+ }, xt = { class: "flex flex-col gap-4" }, Rt = { class: "fm-typo-en-body-lg-600" }, Ot = {
672
+ key: 0,
673
+ class: "flex flex-col gap-4"
674
+ }, kt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Dt = { class: "fm-typo-en-body-lg-600" }, Nt = { key: 0 }, At = { key: 1 }, qt = {
675
+ key: 1,
676
+ class: "flex flex-col gap-4"
677
+ }, Tt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pt = { class: "fm-typo-en-body-lg-600" }, Ct = { key: 0 }, $t = { key: 1 }, Et = {
678
+ key: 2,
679
+ class: "flex flex-col gap-4"
680
+ }, It = { class: "fm-typo-en-body-lg-600" }, Ft = {
681
+ key: 3,
682
+ class: "flex flex-col gap-4"
683
+ }, Lt = { class: "fm-typo-en-body-lg-600" }, Ut = /* @__PURE__ */ Ke({
684
+ __name: "NetSuiteInfo",
685
+ props: {
686
+ transferType: {},
687
+ transferToDbName: {},
688
+ poRequest: {},
689
+ purchaseOrder: {},
690
+ isTransferBetweenOutlets: { type: Boolean },
691
+ scope: {}
692
+ },
693
+ setup(f) {
694
+ const m = f, d = et(), n = ze(), w = j(m.poRequest);
695
+ mt(async () => {
696
+ var i;
697
+ if (!m.poRequest && ((i = m.purchaseOrder) != null && i._id)) {
698
+ const l = await n.getLatestPurchaseOrderRequest(m.purchaseOrder._id);
699
+ w.value = l;
700
+ }
701
+ });
702
+ const O = G(
703
+ () => {
704
+ var i, l, r, a, v, x;
705
+ return d.getSubsidiaryFullName(
706
+ ((r = (l = (i = m.purchaseOrder) == null ? void 0 : i.netSuite) == null ? void 0 : l.subsidiary) == null ? void 0 : r.id) || ((x = (v = (a = m.poRequest) == null ? void 0 : a.netSuite) == null ? void 0 : v.subsidiary) == null ? void 0 : x.id)
707
+ ).fullName;
708
+ }
709
+ ), $ = G(() => {
710
+ var i, l, r, a, v, x, E, D, I, le, ce, Z;
711
+ return (r = (l = (i = m.purchaseOrder) == null ? void 0 : i.netSuite) == null ? void 0 : l.additionalInfo) != null && r.transactionnumber ? (x = (v = (a = m.purchaseOrder) == null ? void 0 : a.netSuite) == null ? void 0 : v.additionalInfo) == null ? void 0 : x.transactionnumber : (I = (D = (E = w.value) == null ? void 0 : E.netSuite) == null ? void 0 : D.additionalInfo) != null && I.transactionnumber ? (Z = (ce = (le = w.value) == null ? void 0 : le.netSuite) == null ? void 0 : ce.additionalInfo) == null ? void 0 : Z.transactionnumber : null;
712
+ }), p = G(() => {
713
+ var i, l, r, a, v, x;
714
+ return (l = (i = m.purchaseOrder) == null ? void 0 : i.deliveryFullfillment) != null && l.length && ((a = (r = m.purchaseOrder) == null ? void 0 : r.deliveryFullfillment) == null ? void 0 : a.length) > 0 ? (x = (v = m.purchaseOrder) == null ? void 0 : v.deliveryFullfillment) == null ? void 0 : x.map((E) => {
715
+ var D;
716
+ return (D = E.netSuite) == null ? void 0 : D.refNo;
717
+ }).join(", ") : "N/A";
718
+ });
719
+ return (i, l) => {
720
+ var r, a, v, x, E, D, I, le, ce, Z, ie, H, we, re;
721
+ return o(d).isEnabled ? (c(), h("div", wt, [
722
+ t("div", xt, [
723
+ l[0] || (l[0] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
724
+ t("div", Rt, u(O.value || "N/A"), 1)
725
+ ]),
726
+ !i.isTransferBetweenOutlets && ((r = i.purchaseOrder) == null ? void 0 : r.status) !== o(U).Enum.REQUESTING && i.scope === o(Ve).RECEIVE_REQUEST ? (c(), h("div", Ot, [
727
+ t("div", kt, " NetSuite " + u(i.transferType === o(ge).PURCHASE ? "purchase order" : "transfer order") + " (ID) ", 1),
728
+ t("div", Dt, [
729
+ (v = (a = i.purchaseOrder) == null ? void 0 : a.netSuite) != null && v.id ? (c(), h("span", Nt, u((E = (x = i.purchaseOrder) == null ? void 0 : x.netSuite) == null ? void 0 : E.refNo) + " (" + u((I = (D = i.purchaseOrder) == null ? void 0 : D.netSuite) == null ? void 0 : I.id) + ") ", 1)) : (c(), h("span", At, "N/A"))
730
+ ])
731
+ ])) : N("", !0),
732
+ !i.isTransferBetweenOutlets && w.value && ((le = i.purchaseOrder) == null ? void 0 : le.status) === o(U).Enum.REQUESTING || i.scope === o(Ve).APPROVAL ? (c(), h("div", qt, [
733
+ t("div", Tt, " (Request) NetSuite " + u(i.transferType === o(ge).PURCHASE ? "Purchase order" : "Transfer order") + " (ID) ", 1),
734
+ t("div", Pt, [
735
+ (Z = (ce = w.value) == null ? void 0 : ce.netSuite) != null && Z.id ? (c(), h("span", Ct, u((H = (ie = w.value) == null ? void 0 : ie.netSuite) == null ? void 0 : H.refNo) + " (" + u((re = (we = w.value) == null ? void 0 : we.netSuite) == null ? void 0 : re.id) + ") ", 1)) : (c(), h("span", $t, "N/A"))
736
+ ])
737
+ ])) : N("", !0),
738
+ $.value ? (c(), h("div", Et, [
739
+ l[1] || (l[1] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite transaction number ", -1)),
740
+ t("div", It, u($.value), 1)
741
+ ])) : N("", !0),
742
+ o(d).isEnabled && i.transferType === o(ge).TRANSFER && !i.isTransferBetweenOutlets ? (c(), h("div", Ft, [
743
+ l[2] || (l[2] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
744
+ t("div", Lt, u(p.value), 1)
745
+ ])) : N("", !0)
746
+ ])) : N("", !0);
747
+ };
748
+ }
749
+ }), Bt = {
750
+ key: 0,
751
+ class: "flex flex-row-reverse"
752
+ }, Mt = /* @__PURE__ */ Ke({
753
+ __name: "NetSuiteSync",
754
+ props: {
755
+ poRequest: {},
756
+ purchaseOrder: {},
757
+ isTransferBetweenOutlets: { type: Boolean }
758
+ },
759
+ setup(f) {
760
+ const m = f, d = et(), n = He(), w = Ge(), O = j(!1), $ = G(() => {
761
+ var a, v, x, E;
762
+ let i = !0;
763
+ d.isEnabled || (i = !1);
764
+ const l = m.purchaseOrder, r = m.poRequest;
765
+ return l && ((a = l == null ? void 0 : l.supplier) != null && a.internal ? (!r && l.status == U.enum.DRAFT && (i = !1), r && !((v = r == null ? void 0 : r.netSuite) != null && v.id) && (i = !1), m.isTransferBetweenOutlets && (i = !1)) : ((l == null ? void 0 : l.status) !== U.enum.REQUESTING && l.supplier.internal && (i = !1), !r && !((x = l == null ? void 0 : l.netSuite) != null && x.id) && (i = !1), !r && ((E = l == null ? void 0 : l.netSuite) != null && E.id) && (l == null ? void 0 : l.status) == U.enum.REQUESTING && (i = !1))), i;
766
+ });
767
+ async function p() {
768
+ O.value || w.open({
769
+ title: "Sync with NetSuite",
770
+ contentComponent: A("div", [
771
+ A("p", "Are you sure you want to sync now?"),
772
+ A("br"),
773
+ A(
774
+ "p",
775
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
776
+ "Please wait a moment before syncing manually to avoid unnecessary actions."
777
+ )
778
+ ]),
779
+ primaryActions: {
780
+ text: "Sync",
781
+ close: !0,
782
+ variant: "destructive"
783
+ },
784
+ secondaryActions: { text: "Not now", close: !0 }
785
+ }).onPrimary(async () => {
786
+ var i;
787
+ try {
788
+ O.value = !0;
789
+ const l = m.purchaseOrder, r = m.poRequest;
790
+ let a = "purchaseOrder";
791
+ if ((i = l == null ? void 0 : l.supplier) != null && i.internal && (a = "purchaseOrderRequest"), !(l != null && l._id)) {
792
+ n.open({
793
+ title: "Error",
794
+ message: "Invalid sync ID",
795
+ type: "error"
796
+ });
797
+ return;
798
+ }
799
+ await d.syncTransferOrder(a, l == null ? void 0 : l._id, r == null ? void 0 : r._id), n.open({
800
+ title: "Sync with NetSuite",
801
+ message: "Requested to sync with NetSuite. Please wait a moment.",
802
+ type: "success"
803
+ });
804
+ } catch {
805
+ n.open({
806
+ title: "Error",
807
+ message: "Failed to sync with NetSuite",
808
+ type: "error"
809
+ });
810
+ }
811
+ setTimeout(() => {
812
+ O.value = !1;
813
+ }, 5e3);
814
+ });
815
+ }
816
+ return (i, l) => {
817
+ const r = ne("FmButton");
818
+ return $.value ? (c(), h("div", Bt, [
819
+ F(r, {
820
+ "prepend-icon": "sync",
821
+ variant: "secondary",
822
+ label: "Sync",
823
+ loading: O.value,
824
+ onClick: p,
825
+ "text-color": "primary",
826
+ "bg-color": "transparent",
827
+ "border-color": "primary"
828
+ }, null, 8, ["loading"])
829
+ ])) : N("", !0);
830
+ };
831
+ }
832
+ }), jt = { class: "flex flex-col gap-16 w-full h-full" }, Vt = { class: "flex justify-between" }, Kt = { class: "fm-typo-en-body-lg-600" }, Gt = { class: "flex flex-col gap-8" }, Ht = { class: "flex flex-col gap-4" }, zt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Qt = { class: "flex gap-1" }, Yt = { class: "fm-typo-en-body-lg-600" }, Wt = {
833
+ key: 0,
834
+ class: "flex flex-col gap-4"
835
+ }, Jt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Zt = { class: "fm-typo-en-body-lg-600" }, Xt = { class: "flex flex-col gap-4" }, es = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ts = { class: "fm-typo-en-body-lg-600" }, ss = {
836
+ key: 1,
837
+ class: "flex flex-col gap-4"
838
+ }, rs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, as = { class: "fm-typo-en-body-lg-600" }, ns = {
839
+ key: 2,
840
+ class: "flex flex-col gap-4"
841
+ }, os = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ls = { class: "fm-typo-en-body-lg-600" }, cs = {
842
+ key: 3,
843
+ class: "flex flex-col gap-4"
844
+ }, is = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, us = { class: "fm-typo-en-body-lg-600" }, ds = {
845
+ key: 4,
846
+ class: "flex flex-col gap-4"
847
+ }, fs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ms = { class: "fm-typo-en-body-lg-600" }, ps = {
848
+ key: 0,
849
+ class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
850
+ }, vs = { class: "flex gap-8 items-center" }, ys = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, hs = { class: "flex flex-col gap-8" }, gs = { class: "flex gap-8 items-center" }, bs = { class: "flex-1 fm-typo-en-body-lg-600" }, _s = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Ss = { class: "flex w-full gap-4" }, ws = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2" }, xs = { class: "fm-typo-en-body-lg-600 line-clamp-2" }, Rs = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Os = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, ks = {
851
+ key: 0,
852
+ class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
853
+ }, Ds = { class: "py-8" }, Ns = { class: "flex justify-end gap-4 items-center" }, As = { class: "fm-typo-en-body-lg-600" }, qs = {
854
+ key: 1,
855
+ class: "flex-1 xs:w-screen xs:max-w-full"
856
+ }, Ts = {
857
+ key: 0,
858
+ class: "flex flex-col items-center gap-8 h-full"
859
+ }, Ps = ["src"], Cs = { class: "fm-typo-en-body-lg-600" }, $s = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, Es = {
860
+ key: 1,
861
+ class: "px-4 flex flex-col"
862
+ }, Is = { class: "flex gap-12 content-stretch" }, Fs = {
863
+ class: "flex flex-col w-24",
864
+ name: "circles"
865
+ }, Ls = { class: "flex-1 flex flex-col items-center" }, Us = { class: "flex-1 flex flex-col items-center" }, Bs = {
866
+ class: "py-12 flex flex-col gap-4",
867
+ name: "received-at header"
868
+ }, Ms = { class: "fm-typo-en-body-lg-400" }, js = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Vs = { class: "flex gap-12 content-stretch" }, Ks = {
869
+ class: "flex flex-col w-24",
870
+ name: "circles"
871
+ }, Gs = { class: "flex-1 flex flex-col items-center" }, Hs = {
872
+ class: "py-12 flex flex-col gap-4 flex-1",
873
+ name: "delivery details"
874
+ }, zs = { class: "flex flex-col gap-8" }, Qs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Ys = { class: "flex flex-col gap-4" }, Ws = { key: 2 }, Js = {
875
+ key: 0,
876
+ class: "flex flex-col items-center gap-8 h-full"
877
+ }, Zs = {
878
+ key: 1,
879
+ class: "flex flex-col items-center gap-8 h-full"
880
+ }, Xs = ["src"], er = { class: "fm-typo-en-body-lg-600" }, tr = { class: "py-12" }, sr = {
881
+ key: 2,
882
+ class: "px-4 flex flex-col"
883
+ }, rr = { class: "flex gap-12 content-stretch" }, ar = {
884
+ class: "flex flex-col w-24",
885
+ name: "circles"
886
+ }, nr = { class: "flex-1 flex flex-col items-center" }, or = { class: "flex-1 flex flex-col items-center" }, lr = { class: "flex gap-4 w-full" }, cr = {
887
+ class: "flex-1 py-12 flex flex-col gap-4",
888
+ name: "received-at header"
889
+ }, ir = { class: "fm-typo-en-body-lg-400 flex gap-8 items-center" }, ur = { class: "flex" }, dr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, fr = { class: "pt-12" }, mr = { class: "flex gap-12 content-stretch" }, pr = {
890
+ class: "flex flex-col w-24",
891
+ name: "circles"
892
+ }, vr = { class: "flex-1 flex flex-col items-center" }, yr = {
893
+ class: "py-12 flex flex-col gap-4 flex-1",
894
+ name: "delivery details"
895
+ }, hr = { class: "flex flex-col gap-8" }, gr = { class: "flex flex-col gap-4" }, br = { class: "fm-typo-en-body-lg-600" }, _r = { class: "flex w-full gap-4" }, Sr = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2" }, wr = { class: "fm-typo-en-body-lg-600 line-clamp-2" }, xr = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Rr = { class: "grow fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" }, Or = {
896
+ key: 0,
897
+ class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary"
898
+ }, kr = { class: "flex gap-8 xs:flex-col" }, Fr = /* @__PURE__ */ Ke({
899
+ __name: "TransferDetails",
900
+ props: {
901
+ poRequest: {},
902
+ purchaseOrder: {},
903
+ transferTo: {},
904
+ transferToDbName: {},
905
+ show: { type: Boolean },
906
+ canResubmit: { type: Boolean },
907
+ canApprove: { type: Boolean },
908
+ scope: {}
909
+ },
910
+ emits: ["update:show", "submitted", "returnStock"],
911
+ setup(f, { emit: m }) {
912
+ const d = f, n = m, w = Ge(), O = He(), $ = st(), { t: p } = tt(), i = G(
913
+ () => {
914
+ var e, s, b, S;
915
+ return ((s = (e = d.purchaseOrder) == null ? void 0 : e.supplier) == null ? void 0 : s.internal) === "restaurant" || ((S = (b = d.purchaseOrder) == null ? void 0 : b.supplier) == null ? void 0 : S.internal) === "warehouse" ? ge.TRANSFER : ge.PURCHASE;
916
+ }
917
+ ), l = G(() => {
918
+ var e, s, b;
919
+ return i.value === ge.TRANSFER && ((e = d.transferToDbName) == null ? void 0 : e.startsWith("restaurant")) && ((b = (s = d.purchaseOrder) == null ? void 0 : s.supplier) == null ? void 0 : b.internal) === "restaurant";
920
+ }), r = j(!1), a = j(""), v = j(!0), x = ze(), E = bt(d, "show"), D = j(null), I = j({}), le = G(() => D.value === null), ce = j(""), Z = G(() => {
921
+ var e, s, b, S, C;
922
+ return !$.enableReturnStocks || !((s = (e = d.purchaseOrder) == null ? void 0 : e.supplier) != null && s.internal) || ((b = d.purchaseOrder) == null ? void 0 : b.status) !== U.enum.COMPLETE ? !1 : !!((C = (S = d.purchaseOrder) == null ? void 0 : S.deliveryOrder) != null && C.length);
923
+ }), ie = G(() => {
924
+ const e = [
925
+ {
926
+ label: p("inventory.transfer.receiveRequest.details.overview"),
927
+ value: "overview"
928
+ },
929
+ {
930
+ label: p("inventory.transfer.receiveRequest.details.deliveryHistory"),
931
+ value: "deliveryHistory"
932
+ }
933
+ ];
934
+ return Z.value && e.push({
935
+ label: "Returns",
936
+ value: "returns"
937
+ }), e;
938
+ }), H = j(ie.value[0]);
939
+ async function we() {
940
+ var e, s, b, S, C;
941
+ D.value = null, I.value = {};
942
+ try {
943
+ const q = ((e = d.purchaseOrder) == null ? void 0 : e.returnPoIds) ?? [], V = new Array(), g = `${(b = (s = d.purchaseOrder) == null ? void 0 : s.supplier) == null ? void 0 : b.internal}_${(C = (S = d.purchaseOrder) == null ? void 0 : S.supplier) == null ? void 0 : C._id}`;
944
+ for (const R of q) {
945
+ const [L, z] = await Promise.all([
946
+ x.getPurchaseOrderById(R, g),
947
+ x.getLatestPurchaseOrderRequest(R, g)
948
+ ]);
949
+ V.push(L), z && (I.value[R] = z);
950
+ }
951
+ V.sort((R, L) => L._id.localeCompare(R._id)), D.value = V;
952
+ } catch (q) {
953
+ console.error("error on fetching return orders", q), ce.value = `Something went wrong while retrieving returns. ${(q == null ? void 0 : q.message) ?? q}`, D.value = [];
954
+ }
955
+ }
956
+ pt(
957
+ () => d.show,
958
+ (e) => {
959
+ e && (H.value = ie.value[0], we());
960
+ }
961
+ );
962
+ async function re(e, s, b) {
963
+ a.value = `${s}`, r.value = !0, v.value = !1;
964
+ try {
965
+ await x.processPurchaseOrder(
966
+ {
967
+ operation: s,
968
+ doc: e,
969
+ options: (
970
+ // auto receive for supplier to warehouse
971
+ (s === k.enum.confirmDraft || // auto receive for warehouse to warehouse
972
+ s === k.enum.completeReceive) && $.autoReceiveWarehouse ? {
973
+ autoReceive: !0
974
+ } : void 0
975
+ )
976
+ },
977
+ d.transferToDbName
978
+ ), await new Promise((S) => setTimeout(S, 1e3)), O.open({
979
+ title: "Success",
980
+ message: b,
981
+ type: "success"
982
+ }), n("update:show", !1), n("submitted");
983
+ } catch (S) {
984
+ O.open({
985
+ title: "Something went wrong",
986
+ message: "Please try again.",
987
+ type: "error"
988
+ }), console.error("Error when submitting PO operation", s, e, S);
989
+ } finally {
990
+ a.value = "", r.value = !1, v.value = !0;
991
+ }
992
+ }
993
+ async function X(e) {
994
+ if (e === k.enum.returnStock) {
995
+ d.purchaseOrder && n("returnStock", d.purchaseOrder), n("update:show", !1);
996
+ return;
997
+ }
998
+ if (e === k.enum.receiveStock)
999
+ return;
1000
+ const s = rt[e];
1001
+ if (!s) {
1002
+ O.open({
1003
+ title: "Something went wrong",
1004
+ message: `Cannot process order: ${Ze(e)}`,
1005
+ type: "error"
1006
+ });
1007
+ return;
1008
+ }
1009
+ const { successMessage: b, ...S } = s;
1010
+ w.open({
1011
+ title: S.title,
1012
+ message: S.message,
1013
+ primaryActions: S.primaryActions
1014
+ }).onPrimary(() => {
1015
+ d.purchaseOrder && re(d.purchaseOrder, e, b);
1016
+ });
1017
+ }
1018
+ const Ie = G(() => {
1019
+ var e, s;
1020
+ return ((e = d.purchaseOrder) == null ? void 0 : e.status) === U.enum.RECEIVING || ((s = d.purchaseOrder) == null ? void 0 : s.status) === U.enum.COMPLETE;
1021
+ }), Pe = G(() => {
1022
+ var q, V, g;
1023
+ const b = (((q = d.purchaseOrder) == null ? void 0 : q.deliveryOrder) ?? []).flatMap((R) => R.received ?? []).reduce(
1024
+ (R, L) => {
1025
+ const z = R[L.sku._id] ?? [];
1026
+ return R[L.sku._id] = [...z, L], R;
1027
+ },
1028
+ {}
1029
+ ), S = Object.entries(b).reduce(
1030
+ (R, [L, z]) => {
1031
+ const B = z.reduce((ae, de) => {
1032
+ const ee = dt(
1033
+ ae,
1034
+ Math.max(ae.precision, de.amount.precision)
1035
+ );
1036
+ return Me(ee, de.amount);
1037
+ }, Ce(0));
1038
+ return R[L] = B, R;
1039
+ },
1040
+ {}
1041
+ ), C = ((V = d.purchaseOrder) == null ? void 0 : V.items) ?? [];
1042
+ for (const R of C)
1043
+ S[g = R.sku._id] ?? (S[g] = Ce(0));
1044
+ return S;
1045
+ }), ue = G(() => {
1046
+ var q, V;
1047
+ const e = ((q = d.purchaseOrder) == null ? void 0 : q.deliveryOrder) ?? [], s = ((V = d.purchaseOrder) == null ? void 0 : V.deliveryFullfillment) ?? [], b = [
1048
+ ...e.map((g) => ({
1049
+ createdAt: g.createdAt,
1050
+ type: "grn",
1051
+ doc: g
1052
+ })),
1053
+ ...s.map((g) => ({
1054
+ createdAt: g.createdAt,
1055
+ type: "fulfillment",
1056
+ doc: g
1057
+ }))
1058
+ ];
1059
+ b.reverse().sort((g, R) => g.createdAt.localeCompare(R.createdAt));
1060
+ function S(g) {
1061
+ var L, z, B, ae, de, ee, fe;
1062
+ const R = s.findIndex((M) => M.id === g.fullfillmentId);
1063
+ return {
1064
+ header: "Received",
1065
+ date: Ue(new Date(g.createdAt)),
1066
+ info: [
1067
+ {
1068
+ label: "Received by",
1069
+ values: [(L = g.createdBy) == null ? void 0 : L.name]
1070
+ },
1071
+ {
1072
+ label: "Received items",
1073
+ values: g.received.map((M) => {
1074
+ var me;
1075
+ return A("div", [
1076
+ A(
1077
+ "div",
1078
+ {
1079
+ class: "flex gap-4"
1080
+ },
1081
+ [
1082
+ A(
1083
+ "div",
1084
+ {
1085
+ class: "flex flex-col"
1086
+ },
1087
+ [
1088
+ A(
1089
+ "span",
1090
+ {
1091
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1092
+ },
1093
+ `${M.sku.name}`
1094
+ ),
1095
+ A(
1096
+ "span",
1097
+ {
1098
+ class: "fm-typo-en-body-md-400"
1099
+ },
1100
+ `${M.sku.code} `
1101
+ )
1102
+ ]
1103
+ ),
1104
+ A(
1105
+ "div",
1106
+ {
1107
+ class: "ml-auto flex flex-col"
1108
+ },
1109
+ [
1110
+ A(
1111
+ "div",
1112
+ {
1113
+ class: "ml-auto flex gap-1"
1114
+ },
1115
+ [
1116
+ A(
1117
+ "span",
1118
+ {
1119
+ class: "fm-typo-en-body-lg-600 self-end"
1120
+ },
1121
+ Re(M.amount, !1)
1122
+ ),
1123
+ A(
1124
+ "span",
1125
+ {
1126
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1127
+ },
1128
+ ((me = M.measurement) == null ? void 0 : me.abbrev) ?? M.sku.unit.abbrev
1129
+ )
1130
+ ]
1131
+ ),
1132
+ A(
1133
+ "div",
1134
+ {
1135
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1136
+ },
1137
+ `${M.cost ? `(${Te(M.cost)})` : ""}`
1138
+ )
1139
+ ]
1140
+ )
1141
+ ]
1142
+ )
1143
+ ]);
1144
+ })
1145
+ },
1146
+ g.deliveryOrderNumber ? {
1147
+ label: "Delivery order no.",
1148
+ values: [g.deliveryOrderNumber]
1149
+ } : null,
1150
+ g.remark ? {
1151
+ label: "Remark",
1152
+ values: [g.remark]
1153
+ } : null,
1154
+ R > -1 ? {
1155
+ label: "Fulfilment's sequence",
1156
+ values: [`${R + 1}`]
1157
+ } : null,
1158
+ (B = (z = s[R]) == null ? void 0 : z.netSuite) != null && B.refNo ? {
1159
+ label: "Fulfillment's ref no. (Netsuite)",
1160
+ values: [(de = (ae = s[R]) == null ? void 0 : ae.netSuite) == null ? void 0 : de.refNo]
1161
+ } : null,
1162
+ (ee = g == null ? void 0 : g.netSuite) != null && ee.refNo ? {
1163
+ label: "Item receipt (Netsuite)",
1164
+ values: [(fe = g == null ? void 0 : g.netSuite) == null ? void 0 : fe.refNo]
1165
+ } : null
1166
+ ].filter((M) => M)
1167
+ };
1168
+ }
1169
+ function C(g) {
1170
+ var L, z;
1171
+ const R = s.findIndex((B) => B.id === g.id);
1172
+ return {
1173
+ header: "Fulfillment",
1174
+ date: Ue(new Date(g.createdAt)),
1175
+ info: [
1176
+ {
1177
+ label: "Sequence",
1178
+ values: [String(R + 1)]
1179
+ },
1180
+ {
1181
+ label: "Receiveable items",
1182
+ values: g.items.map((B) => {
1183
+ var ae;
1184
+ return A("div", [
1185
+ A(
1186
+ "div",
1187
+ {
1188
+ class: "flex gap-4"
1189
+ },
1190
+ [
1191
+ A(
1192
+ "div",
1193
+ {
1194
+ class: "flex flex-col"
1195
+ },
1196
+ [
1197
+ A(
1198
+ "span",
1199
+ {
1200
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1201
+ },
1202
+ `${B.sku.name}`
1203
+ ),
1204
+ A(
1205
+ "span",
1206
+ {
1207
+ class: "fm-typo-en-body-md-400"
1208
+ },
1209
+ `${B.sku.code} `
1210
+ )
1211
+ ]
1212
+ ),
1213
+ A(
1214
+ "div",
1215
+ {
1216
+ class: "ml-auto flex flex-col"
1217
+ },
1218
+ [
1219
+ A(
1220
+ "div",
1221
+ {
1222
+ class: "ml-auto flex gap-1"
1223
+ },
1224
+ [
1225
+ A(
1226
+ "span",
1227
+ {
1228
+ class: "fm-typo-en-body-lg-600 self-end"
1229
+ },
1230
+ Re(B.amount, !1)
1231
+ ),
1232
+ A(
1233
+ "span",
1234
+ {
1235
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1236
+ },
1237
+ ((ae = B.measurement) == null ? void 0 : ae.abbrev) ?? B.sku.unit.abbrev
1238
+ )
1239
+ ]
1240
+ ),
1241
+ A(
1242
+ "div",
1243
+ {
1244
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1245
+ },
1246
+ `${B.cost ? `(${Te(B.cost)})` : ""}`
1247
+ )
1248
+ ]
1249
+ )
1250
+ ]
1251
+ )
1252
+ ]);
1253
+ })
1254
+ },
1255
+ (L = g.netSuite) != null && L.refNo ? {
1256
+ label: "Ref no. (Netsuite)",
1257
+ values: [(z = g.netSuite) == null ? void 0 : z.refNo]
1258
+ } : null
1259
+ ].filter((B) => B)
1260
+ };
1261
+ }
1262
+ return b.map((g) => {
1263
+ switch (g.type) {
1264
+ case "grn":
1265
+ return S(g.doc);
1266
+ case "fulfillment":
1267
+ return C(g.doc);
1268
+ }
1269
+ });
1270
+ }), _ = G(() => {
1271
+ var s;
1272
+ const e = {
1273
+ ...Ce(0),
1274
+ currency: Ye()
1275
+ };
1276
+ return ((s = d.purchaseOrder) == null ? void 0 : s.items.reduce((b, S) => ({
1277
+ ...Me(b, S.totalCost ?? e),
1278
+ currency: Ye()
1279
+ }), e)) ?? e;
1280
+ });
1281
+ return (e, s) => {
1282
+ var ae, de;
1283
+ const b = ne("FmButtonGroup"), S = ne("FmChip"), C = ne("FmMenuDivider"), q = ne("FmCard"), V = ne("FmIcon"), g = ne("FmTooltip"), R = ne("FmButton"), L = ne("FmSpacer"), z = ne("FmCircularProgress"), B = ne("FmSideSheet");
1284
+ return c(), W(B, {
1285
+ header: o(p)("inventory.transfer.receiveRequest.details.title") + ((ae = e.purchaseOrder) != null && ae.seqNumber ? ` #${(de = e.purchaseOrder) == null ? void 0 : de.seqNumber}` : ""),
1286
+ modelValue: o(E),
1287
+ "onUpdate:modelValue": s[11] || (s[11] = (ee) => vt(E) ? E.value = ee : null),
1288
+ "dismiss-away": v.value,
1289
+ "close-button": "",
1290
+ "max-width": 600
1291
+ }, {
1292
+ default: be(() => {
1293
+ var ee, fe, M, me, Oe, ke, De, Ne;
1294
+ return [
1295
+ t("div", jt, [
1296
+ t("div", null, [
1297
+ F(b, {
1298
+ items: ie.value,
1299
+ modelValue: H.value,
1300
+ "onUpdate:modelValue": s[0] || (s[0] = (y) => H.value = y)
1301
+ }, null, 8, ["items", "modelValue"])
1302
+ ]),
1303
+ H.value.value === "overview" ? (c(), h(J, { key: 0 }, [
1304
+ t("div", null, [
1305
+ F(q, {
1306
+ variant: "outlined",
1307
+ class: "flex flex-col gap-8 px-12 py-16"
1308
+ }, {
1309
+ default: be(() => {
1310
+ var y, T, P, te, se, oe, pe, ve, Q, ye, Ae, qe;
1311
+ return [
1312
+ t("div", Vt, [
1313
+ t("div", Kt, u(o(p)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
1314
+ t("div", null, [
1315
+ F(S, {
1316
+ label: o(p)(`inventory.transfer.status.${(y = e.purchaseOrder) == null ? void 0 : y.status}`),
1317
+ class: he(`fm-status-badge fm-status-badge-${(P = (T = e.purchaseOrder) == null ? void 0 : T.status) == null ? void 0 : P.toLocaleLowerCase("en-us")}`),
1318
+ compact: ""
1319
+ }, null, 8, ["label", "class"])
1320
+ ])
1321
+ ]),
1322
+ F(C),
1323
+ t("div", Gt, [
1324
+ t("div", Ht, [
1325
+ t("div", zt, [
1326
+ t("div", Qt, u(o(p)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1327
+ ]),
1328
+ t("div", Yt, u(o(Ee)(((te = e.purchaseOrder) == null ? void 0 : te._id) ?? "")), 1)
1329
+ ]),
1330
+ (se = e.purchaseOrder) != null && se.effectiveAt ? (c(), h("div", Wt, [
1331
+ t("div", Jt, u(o(p)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
1332
+ t("div", Zt, u(o(Xe)(new Date((oe = e.purchaseOrder) == null ? void 0 : oe.effectiveAt))), 1)
1333
+ ])) : N("", !0),
1334
+ t("div", Xt, [
1335
+ t("div", es, u(o(p)("inventory.transfer.receiveRequest.details.type.title")), 1),
1336
+ t("div", ts, u(o(p)(
1337
+ `inventory.transfer.receiveRequest.details.type.${i.value.toLocaleLowerCase("en-US")}`
1338
+ )), 1)
1339
+ ]),
1340
+ (ve = (pe = e.purchaseOrder) == null ? void 0 : pe.supplier) != null && ve.name ? (c(), h("div", ss, [
1341
+ t("div", rs, u(o(p)("inventory.transfer.receiveRequest.details.from")), 1),
1342
+ t("div", as, u((ye = (Q = e.purchaseOrder) == null ? void 0 : Q.supplier) == null ? void 0 : ye.name), 1)
1343
+ ])) : N("", !0),
1344
+ e.transferTo ? (c(), h("div", ns, [
1345
+ t("div", os, u(o(p)("inventory.transfer.receiveRequest.details.to")), 1),
1346
+ t("div", ls, u(e.transferTo), 1)
1347
+ ])) : N("", !0),
1348
+ (Ae = e.purchaseOrder) != null && Ae.ref ? (c(), h("div", cs, [
1349
+ t("div", is, u(o(p)("inventory.transfer.receiveRequest.details.reference")), 1),
1350
+ t("div", us, u(e.purchaseOrder.ref), 1)
1351
+ ])) : N("", !0),
1352
+ (qe = e.purchaseOrder) != null && qe.remark ? (c(), h("div", ds, [
1353
+ t("div", fs, u(o(p)("inventory.transfer.receiveRequest.details.remark")), 1),
1354
+ t("div", ms, u(e.purchaseOrder.remark), 1)
1355
+ ])) : N("", !0)
1356
+ ])
1357
+ ];
1358
+ }),
1359
+ _: 1
1360
+ })
1361
+ ]),
1362
+ l.value ? N("", !0) : (c(), h("div", ps, [
1363
+ t("div", vs, [
1364
+ s[12] || (s[12] = t("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1365
+ t("div", null, [
1366
+ F(Mt, {
1367
+ "po-request": e.poRequest,
1368
+ "purchase-order": e.purchaseOrder,
1369
+ "is-transfer-between-outlets": l.value
1370
+ }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets"])
1371
+ ])
1372
+ ]),
1373
+ F(C),
1374
+ F(Ut, {
1375
+ "po-request": e.poRequest,
1376
+ "purchase-order": e.purchaseOrder,
1377
+ "transfer-type": i.value,
1378
+ "transfer-to-db-name": e.transferToDbName,
1379
+ "is-transfer-between-outlets": l.value,
1380
+ scope: e.scope
1381
+ }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1382
+ ])),
1383
+ t("div", ys, [
1384
+ t("div", hs, [
1385
+ t("div", gs, [
1386
+ t("span", bs, [
1387
+ Be(u(Ie.value ? o(p)("inventory.transfer.receiveRequest.details.receivedItems") : o(p)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
1388
+ (fe = (ee = e.purchaseOrder) == null ? void 0 : ee.netSuite) != null && fe.missingItems && ((me = (M = e.purchaseOrder) == null ? void 0 : M.netSuite) == null ? void 0 : me.missingItems.length) > 0 ? (c(), W(g, {
1389
+ key: 0,
1390
+ variant: "rich",
1391
+ placement: "top",
1392
+ "z-index": 51
1393
+ }, {
1394
+ content: be(() => {
1395
+ var y, T;
1396
+ return [
1397
+ t("div", _s, [
1398
+ (c(!0), h(J, null, _e((T = (y = e.purchaseOrder) == null ? void 0 : y.netSuite) == null ? void 0 : T.missingItems, (P, te) => (c(), h("div", {
1399
+ class: "flex justify-center align-middle",
1400
+ key: te
1401
+ }, [
1402
+ F(V, {
1403
+ name: "arrow_right",
1404
+ size: "sm"
1405
+ }),
1406
+ Be(" " + u(`(${P.netSuiteId}) ${P.name}: ${P.reason}`), 1)
1407
+ ]))), 128))
1408
+ ])
1409
+ ];
1410
+ }),
1411
+ default: be(() => [
1412
+ F(V, {
1413
+ name: "error",
1414
+ color: "#ff2c2c",
1415
+ size: "sm"
1416
+ })
1417
+ ]),
1418
+ _: 1
1419
+ })) : N("", !0)
1420
+ ]),
1421
+ t("div", null, [
1422
+ Z.value && D.value != null && !((Oe = D.value) != null && Oe.length) ? (c(), W(R, {
1423
+ key: 0,
1424
+ label: "Return",
1425
+ variant: "secondary",
1426
+ onClick: s[1] || (s[1] = (y) => X("returnStock")),
1427
+ loading: a.value === "returnStock",
1428
+ disabled: a.value !== "returnStock" && r.value,
1429
+ "prepend-icon": "undo",
1430
+ "text-color": "primary",
1431
+ "bg-color": "transparent",
1432
+ "border-color": "primary"
1433
+ }, null, 8, ["loading", "disabled"])) : N("", !0)
1434
+ ])
1435
+ ]),
1436
+ F(C),
1437
+ (c(!0), h(J, null, _e(((ke = e.purchaseOrder) == null ? void 0 : ke.items) ?? [], (y) => {
1438
+ var T;
1439
+ return c(), h("div", {
1440
+ key: y.code,
1441
+ class: "flex flex-col"
1442
+ }, [
1443
+ t("div", Ss, [
1444
+ t("div", ws, u(y.name), 1),
1445
+ t("div", xs, u(o(Re)(Pe.value[y.sku._id], !1)) + "/" + u(o(je)(y.quantity, y.sku.unit, y.measurement)), 1)
1446
+ ]),
1447
+ t("div", Rs, [
1448
+ t("div", Os, u(y.code), 1),
1449
+ (T = y.totalCost) != null && T.amount && o($).enableTotalCost ? (c(), h("div", ks, " (" + u(o(Te)(y.totalCost)) + ") ", 1)) : N("", !0)
1450
+ ])
1451
+ ]);
1452
+ }), 128)),
1453
+ +o(Re)(_.value) ? (c(), h(J, { key: 0 }, [
1454
+ t("div", Ds, [
1455
+ F(C)
1456
+ ]),
1457
+ t("div", Ns, [
1458
+ s[13] || (s[13] = t("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
1459
+ t("div", As, u(o(Te)(_.value)), 1)
1460
+ ])
1461
+ ], 64)) : N("", !0)
1462
+ ])
1463
+ ])
1464
+ ], 64)) : H.value.value === "deliveryHistory" ? (c(), h("div", qs, [
1465
+ ue.value.length ? (c(), h("div", Es, [
1466
+ (c(!0), h(J, null, _e(ue.value, (y, T) => (c(), h(J, { key: T }, [
1467
+ t("div", Is, [
1468
+ t("div", Fs, [
1469
+ t("div", Ls, [
1470
+ t("div", {
1471
+ class: he([
1472
+ {
1473
+ "bg-fm-color-primary": T !== 0,
1474
+ "bg-white": T === 0
1475
+ },
1476
+ "w-[2px] h-full"
1477
+ ])
1478
+ }, null, 2)
1479
+ ]),
1480
+ s[14] || (s[14] = t("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1481
+ t("div", Us, [
1482
+ t("div", {
1483
+ class: he([
1484
+ {
1485
+ "bg-fm-color-primary": T < ue.value.length - 1,
1486
+ "bg-white": T >= ue.value.length - 1
1487
+ },
1488
+ "w-[2px] h-full"
1489
+ ])
1490
+ }, null, 2)
1491
+ ])
1492
+ ]),
1493
+ t("div", Bs, [
1494
+ t("div", Ms, u(y.header), 1),
1495
+ t("div", js, u(y.date), 1)
1496
+ ])
1497
+ ]),
1498
+ t("div", Vs, [
1499
+ t("div", Ks, [
1500
+ t("div", Gs, [
1501
+ t("div", {
1502
+ class: he([
1503
+ {
1504
+ "bg-fm-color-primary": T < ue.value.length - 1,
1505
+ "bg-white": T >= ue.value.length - 1
1506
+ },
1507
+ "w-[2px] h-full"
1508
+ ])
1509
+ }, null, 2)
1510
+ ])
1511
+ ]),
1512
+ t("div", Hs, [
1513
+ F(q, {
1514
+ variant: "outlined",
1515
+ class: "py-12 px-16"
1516
+ }, {
1517
+ default: be(() => [
1518
+ t("div", zs, [
1519
+ (c(!0), h(J, null, _e(y.info, (P, te) => (c(), h("div", {
1520
+ key: te,
1521
+ class: "flex flex-col gap-4"
1522
+ }, [
1523
+ t("div", Qs, u(P == null ? void 0 : P.label), 1),
1524
+ t("div", Ys, [
1525
+ (c(!0), h(J, null, _e(P == null ? void 0 : P.values, (se, oe) => (c(), h("div", {
1526
+ key: oe,
1527
+ class: "fm-typo-en-body-lg-600"
1528
+ }, [
1529
+ typeof se == "string" ? (c(), h(J, { key: 0 }, [
1530
+ Be(u(se), 1)
1531
+ ], 64)) : (c(), W(yt(se), { key: 1 }))
1532
+ ]))), 128))
1533
+ ])
1534
+ ]))), 128))
1535
+ ])
1536
+ ]),
1537
+ _: 2
1538
+ }, 1024)
1539
+ ])
1540
+ ])
1541
+ ], 64))), 128))
1542
+ ])) : (c(), h("div", Ts, [
1543
+ F(L),
1544
+ t("div", null, [
1545
+ t("img", {
1546
+ src: o(We),
1547
+ alt: "List is empty"
1548
+ }, null, 8, Ps)
1549
+ ]),
1550
+ t("div", Cs, u(o(p)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
1551
+ t("div", $s, u(o(p)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
1552
+ F(L),
1553
+ F(L)
1554
+ ]))
1555
+ ])) : H.value.value === "returns" && Z.value ? (c(), h("div", Ws, [
1556
+ le.value ? (c(), h("div", Js, [
1557
+ s[15] || (s[15] = t("div", { class: "h-80" }, null, -1)),
1558
+ F(z),
1559
+ s[16] || (s[16] = t("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, "Loading...", -1))
1560
+ ])) : (De = D.value) != null && De.length ? (c(), h("div", sr, [
1561
+ (c(!0), h(J, null, _e(D.value, (y, T) => (c(), h(J, {
1562
+ key: y._id
1563
+ }, [
1564
+ t("div", rr, [
1565
+ t("div", ar, [
1566
+ t("div", nr, [
1567
+ t("div", {
1568
+ class: he([
1569
+ {
1570
+ "bg-fm-color-primary": T !== 0,
1571
+ "bg-white": T === 0
1572
+ },
1573
+ "w-[2px] h-full"
1574
+ ])
1575
+ }, null, 2)
1576
+ ]),
1577
+ s[19] || (s[19] = t("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1578
+ t("div", or, [
1579
+ t("div", {
1580
+ class: he([
1581
+ {
1582
+ "bg-fm-color-primary": T < D.value.length - 1,
1583
+ "bg-white": T >= D.value.length - 1
1584
+ },
1585
+ "w-[2px] h-full"
1586
+ ])
1587
+ }, null, 2)
1588
+ ])
1589
+ ]),
1590
+ t("div", lr, [
1591
+ t("div", cr, [
1592
+ t("div", ir, [
1593
+ t("span", null, " Return #" + u(y.seqNumber), 1),
1594
+ t("span", ur, [
1595
+ t("span", {
1596
+ class: he(`fm-status-badge fm-status-badge-${`${y.status}`.toLocaleLowerCase("en-us")}`)
1597
+ }, u(o(p)(`inventory.transfer.status.${y.status}`)), 3)
1598
+ ])
1599
+ ]),
1600
+ t("div", dr, u(o(Ue)(o(ft)(y._id))), 1)
1601
+ ]),
1602
+ t("div", fr, [
1603
+ F(R, {
1604
+ variant: "secondary",
1605
+ label: "Print",
1606
+ "prepend-icon": "print",
1607
+ "text-color": "primary",
1608
+ "bg-color": "transparent",
1609
+ "border-color": "primary",
1610
+ onClick: (P) => {
1611
+ var te, se, oe, pe, ve, Q, ye, Ae, qe;
1612
+ return o(at)(
1613
+ {
1614
+ ...y,
1615
+ ref: [
1616
+ y.ref,
1617
+ (se = (te = I.value[y._id]) == null ? void 0 : te.netSuite) != null && se.refNo ? `Netsuite ${(pe = (oe = I.value[y._id]) == null ? void 0 : oe.netSuite) == null ? void 0 : pe.refNo} (${(Q = (ve = I.value[y._id]) == null ? void 0 : ve.netSuite) == null ? void 0 : Q.id})` : ""
1618
+ ].filter((Fe) => Fe == null ? void 0 : Fe.trim()).join()
1619
+ },
1620
+ {
1621
+ doc: {
1622
+ profile: {
1623
+ name: (ye = e.purchaseOrder) == null ? void 0 : ye.supplier.name,
1624
+ address: (Ae = e.purchaseOrder) == null ? void 0 : Ae.supplier.address,
1625
+ regNo: (qe = e.purchaseOrder) == null ? void 0 : qe.supplier.registrationNumber
1626
+ }
1627
+ }
1628
+ }
1629
+ );
1630
+ }
1631
+ }, null, 8, ["onClick"])
1632
+ ])
1633
+ ])
1634
+ ]),
1635
+ t("div", mr, [
1636
+ t("div", pr, [
1637
+ t("div", vr, [
1638
+ t("div", {
1639
+ class: he([
1640
+ {
1641
+ "bg-fm-color-primary": T < D.value.length - 1,
1642
+ "bg-white": T >= D.value.length - 1
1643
+ },
1644
+ "w-[2px] h-full"
1645
+ ])
1646
+ }, null, 2)
1647
+ ])
1648
+ ]),
1649
+ t("div", yr, [
1650
+ F(q, {
1651
+ variant: "outlined",
1652
+ class: "py-12 px-16"
1653
+ }, {
1654
+ default: be(() => {
1655
+ var P, te, se, oe, pe, ve;
1656
+ return [
1657
+ t("div", hr, [
1658
+ (te = (P = I.value[y._id]) == null ? void 0 : P.netSuite) != null && te.id ? (c(), h(J, { key: 0 }, [
1659
+ t("div", gr, [
1660
+ s[20] || (s[20] = t("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Netsuite transfer order (ID) ", -1)),
1661
+ t("div", br, u((oe = (se = I.value[y._id]) == null ? void 0 : se.netSuite) == null ? void 0 : oe.refNo) + " (" + u((ve = (pe = I.value[y._id]) == null ? void 0 : pe.netSuite) == null ? void 0 : ve.id) + ") ", 1)
1662
+ ]),
1663
+ F(C)
1664
+ ], 64)) : N("", !0),
1665
+ s[21] || (s[21] = t("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, " Returning items ", -1)),
1666
+ (c(!0), h(J, null, _e((y == null ? void 0 : y.items) ?? [], (Q) => {
1667
+ var ye;
1668
+ return c(), h("div", {
1669
+ key: Q.code,
1670
+ class: "flex flex-col"
1671
+ }, [
1672
+ t("div", _r, [
1673
+ t("div", Sr, u(Q.name), 1),
1674
+ t("div", wr, u(o(je)(Q.quantity, Q.sku.unit, Q.measurement)), 1)
1675
+ ]),
1676
+ t("div", xr, [
1677
+ t("div", Rr, u(Q.code), 1),
1678
+ (ye = Q.totalCost) != null && ye.amount && o($).enableTotalCost ? (c(), h("div", Or, " (" + u(o(Te)(Q.totalCost)) + ") ", 1)) : N("", !0)
1679
+ ])
1680
+ ]);
1681
+ }), 128))
1682
+ ])
1683
+ ];
1684
+ }),
1685
+ _: 2
1686
+ }, 1024)
1687
+ ])
1688
+ ])
1689
+ ], 64))), 128))
1690
+ ])) : (c(), h("div", Zs, [
1691
+ s[17] || (s[17] = t("div", { class: "h-80" }, null, -1)),
1692
+ t("div", null, [
1693
+ t("img", {
1694
+ src: o(We),
1695
+ alt: "List is empty"
1696
+ }, null, 8, Xs)
1697
+ ]),
1698
+ t("div", er, u(o(p)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
1699
+ s[18] || (s[18] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, " You may view return request history here. ", -1)),
1700
+ t("div", tr, [
1701
+ Z.value && D.value != null && !((Ne = D.value) != null && Ne.length) ? (c(), W(R, {
1702
+ key: 0,
1703
+ label: "Create return request",
1704
+ variant: "secondary",
1705
+ onClick: s[2] || (s[2] = (y) => X("returnStock")),
1706
+ loading: a.value === "returnStock",
1707
+ disabled: a.value !== "returnStock" && r.value,
1708
+ "prepend-icon": "undo",
1709
+ "text-color": "primary",
1710
+ "bg-color": "transparent",
1711
+ "border-color": "primary"
1712
+ }, null, 8, ["loading", "disabled"])) : N("", !0)
1713
+ ])
1714
+ ]))
1715
+ ])) : N("", !0)
1716
+ ])
1717
+ ];
1718
+ }),
1719
+ "side-sheet-footer": be(() => {
1720
+ var ee, fe, M, me, Oe, ke, De, Ne, y, T;
1721
+ return [
1722
+ t("div", kr, [
1723
+ ((ee = e.purchaseOrder) == null ? void 0 : ee.status) === o(U).enum.DRAFT && i.value === o(ge).PURCHASE ? (c(), W(R, {
1724
+ key: 0,
1725
+ label: o(p)("inventory.transfer.receiveRequest.actions.confirmDraft"),
1726
+ onClick: s[3] || (s[3] = (P) => X("confirmDraft")),
1727
+ loading: a.value === "confirmDraft",
1728
+ disabled: a.value !== "confirmDraft" && r.value
1729
+ }, null, 8, ["label", "loading", "disabled"])) : N("", !0),
1730
+ ((fe = e.purchaseOrder) == null ? void 0 : fe.status) === o(U).enum.DRAFT && i.value === o(ge).TRANSFER ? (c(), W(R, {
1731
+ key: 1,
1732
+ label: o(p)("inventory.transfer.receiveRequest.actions.submitRequest"),
1733
+ onClick: s[4] || (s[4] = (P) => X("submitRequest")),
1734
+ loading: a.value === "submitRequest",
1735
+ disabled: a.value !== "submitRequest" && r.value
1736
+ }, null, 8, ["label", "loading", "disabled"])) : N("", !0),
1737
+ ((M = e.purchaseOrder) == null ? void 0 : M.status) === o(U).enum.DRAFT ? (c(), W(R, {
1738
+ key: 2,
1739
+ label: o(p)("inventory.transfer.receiveRequest.actions.cancelDraft"),
1740
+ onClick: s[5] || (s[5] = (P) => X("cancelDraft")),
1741
+ loading: a.value === "cancelDraft",
1742
+ disabled: a.value !== "cancelDraft" && r.value,
1743
+ variant: "destructive"
1744
+ }, null, 8, ["label", "loading", "disabled"])) : N("", !0),
1745
+ ((me = e.purchaseOrder) == null ? void 0 : me.status) === o(U).enum.RECEIVING ? (c(), W(R, {
1746
+ key: 3,
1747
+ label: o(p)("inventory.transfer.receiveRequest.actions.completeReceive"),
1748
+ onClick: s[6] || (s[6] = (P) => X("completeReceive")),
1749
+ loading: a.value === "completeReceive",
1750
+ disabled: a.value !== "completeReceive" && r.value
1751
+ }, null, 8, ["label", "loading", "disabled"])) : N("", !0),
1752
+ e.canResubmit ? (c(), W(R, {
1753
+ key: 4,
1754
+ label: o(p)("inventory.transfer.receiveRequest.actions.resubmitRequest"),
1755
+ onClick: s[7] || (s[7] = (P) => X("submitRequest")),
1756
+ loading: a.value === "submitRequest",
1757
+ disabled: a.value !== "submitRequest" && r.value
1758
+ }, null, 8, ["label", "loading", "disabled"])) : N("", !0),
1759
+ (((Oe = e.purchaseOrder) == null ? void 0 : Oe.status) === o(U).enum.REQUESTING || ((ke = e.purchaseOrder) == null ? void 0 : ke.status) === o(U).enum.PROCESSING) && e.canApprove ? (c(), W(R, {
1760
+ key: 5,
1761
+ label: o(p)("inventory.transfer.approval.actions.approveRequest"),
1762
+ onClick: s[8] || (s[8] = (P) => X("approveRequest")),
1763
+ loading: a.value === "approveRequest",
1764
+ disabled: a.value !== "approveRequest" && r.value
1765
+ }, null, 8, ["label", "loading", "disabled"])) : N("", !0),
1766
+ ((De = e.purchaseOrder) == null ? void 0 : De.status) === o(U).enum.REQUESTING && e.canApprove ? (c(), W(R, {
1767
+ key: 6,
1768
+ label: o(p)("inventory.transfer.approval.actions.rejectRequest"),
1769
+ onClick: s[9] || (s[9] = (P) => X("rejectRequest")),
1770
+ loading: a.value === "rejectRequest",
1771
+ disabled: a.value !== "rejectRequest" && r.value,
1772
+ variant: "destructive"
1773
+ }, null, 8, ["label", "loading", "disabled"])) : N("", !0),
1774
+ ((Ne = e.purchaseOrder) == null ? void 0 : Ne.status) !== o(U).enum.COMPLETE && ((y = e.purchaseOrder) == null ? void 0 : y.status) !== o(U).enum.CANCEL && (((T = e.purchaseOrder) == null ? void 0 : T.status) !== o(U).enum.REQUESTING || e.canApprove) ? (c(), W(R, {
1775
+ key: 7,
1776
+ label: o(p)("common.close"),
1777
+ variant: "tertiary",
1778
+ onClick: s[10] || (s[10] = (P) => n("update:show", !1))
1779
+ }, null, 8, ["label"])) : N("", !0)
1780
+ ])
1781
+ ];
1782
+ }),
1783
+ _: 1
1784
+ }, 8, ["header", "modelValue", "dismiss-away"]);
1785
+ };
1786
+ }
1787
+ });
1788
+ export {
1789
+ Ve as P,
1790
+ Fr as _,
1791
+ Er as a,
1792
+ Ir as b,
1793
+ St as g,
1794
+ ze as u
1795
+ };