@feedmepos/mf-inventory-portal 0.0.23-dev.40 → 0.0.23-dev.41

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 (43) hide show
  1. package/dist/{App-D8DXxTIq.js → App-DW2K97Bb.js} +2 -2
  2. package/dist/{ApprovalView-BWGXkHV6.js → ApprovalView-BgSxdrwt.js} +2 -2
  3. package/dist/{BindingsDialog-D7WypDot.js → BindingsDialog-CQtusdvp.js} +2 -2
  4. package/dist/{BindingsPicker-DUlGwkwM.js → BindingsPicker-BnEjRAah.js} +1 -1
  5. package/dist/{BindingsTable-BjeZYCaJ.js → BindingsTable-DpTPAef_.js} +1 -1
  6. package/dist/{ClosingDraftView-o2LEUfo8.js → ClosingDraftView-CXKYLCZS.js} +2 -2
  7. package/dist/{ClosingTemplateView-Dt983Cg4.js → ClosingTemplateView-CMTJHywt.js} +1 -1
  8. package/dist/{FmCustomAttribute.vue_vue_type_script_setup_true_lang-Dc_7IyBG.js → FmCustomAttribute.vue_vue_type_script_setup_true_lang-zOmcCdDR.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-wocPyZls.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-mAPA5_sB.js} +3 -3
  10. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DzoEp-Pg.js → FmUnitInput.vue_vue_type_script_setup_true_lang-BjNpfucZ.js} +1 -1
  11. package/dist/{IngredientGroupView-CIPpIpv1.js → IngredientGroupView-CrEfiZvn.js} +1 -1
  12. package/dist/{IngredientsView-CFV3kX7Q.js → IngredientsView-BB8LQlU9.js} +4 -4
  13. package/dist/{IntegrationView-DkW32m-t.js → IntegrationView-D2wTkDyX.js} +1 -1
  14. package/dist/{InventoryBindingForm-B4CBet9W.js → InventoryBindingForm-DW7rJDc1.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DpdDVf6O.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-Ci8UI1eQ.js} +3 -3
  16. package/dist/{InventoryBindingSummary-75ImZtqK.js → InventoryBindingSummary-B40KofiI.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DfpG3Fy8.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DD7VT9MS.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-B4d0c3nk.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BGuXTfn6.js} +1 -1
  19. package/dist/{PurchaseOrderPrintPreview-BYO0JcQW.js → PurchaseOrderPrintPreview-DQmx28Be.js} +1 -1
  20. package/dist/{ReceiveRequestView-cFLNExw9.js → ReceiveRequestView-CJknzKfd.js} +1424 -1413
  21. package/dist/{RecipeView-CjfpaHaT.js → RecipeView-D5oWQ9Yd.js} +3 -3
  22. package/dist/{StockView-HMtD9qar.js → StockView-U59PHCy2.js} +8 -8
  23. package/dist/{SupplierView-Cidfe-Xm.js → SupplierView-CLjjpTNZ.js} +4 -4
  24. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DLDDXnyG.js +1327 -0
  25. package/dist/{TransferTemplateView-Doxr1fXP.js → TransferTemplateView-CFoVrPIX.js} +6 -6
  26. package/dist/{UnitView-C1af71aM.js → UnitView-CAopphN_.js} +3 -3
  27. package/dist/{WarehouseView-CviOLXfX.js → WarehouseView-DUZku5U6.js} +1 -1
  28. package/dist/{app-BE8SgDqI.js → app-0klJzLit.js} +2929 -2868
  29. package/dist/app.js +1 -1
  30. package/dist/{decimal-xj3kVOP6.js → decimal-Cu4rlnvU.js} +1 -1
  31. package/dist/{feature-CWpNYcWJ.js → feature-C1wCaXKQ.js} +1 -1
  32. package/dist/{format-unit-display-CZ835oaL.js → format-unit-display-CMa5UhY1.js} +2 -2
  33. package/dist/{index-C6SzYqK7.js → index-BJaMpEVJ.js} +1 -1
  34. package/dist/{index-B8IWDKYv.js → index-HTBqkVVr.js} +3 -3
  35. package/dist/{stock-C2xyYnS7.js → stock-CB4yNRMO.js} +1 -1
  36. package/dist/{supplier-B-7o9hg1.js → supplier-biIIXGyr.js} +1 -1
  37. package/dist/{use-inventory-binding-dialog-Dm8Ky1MH.js → use-inventory-binding-dialog-BopoOOxB.js} +1 -1
  38. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +11 -0
  39. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +30 -0
  40. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +45 -0
  41. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +45 -0
  42. package/package.json +3 -3
  43. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CdU3HPBC.js +0 -1275
@@ -0,0 +1,1327 @@
1
+ import { ref as K, computed as Y, h as oe, defineComponent as _e, unref as i, openBlock as g, createElementBlock as D, createElementVNode as e, toDisplayString as S, createCommentVNode as T, resolveComponent as Z, createVNode as U, createBlock as W, isRef as Ge, withCtx as de, Fragment as ne, normalizeClass as ye, createTextVNode as Te, renderList as pe } from "vue";
2
+ import { X as He, u as be, aF as k, a2 as ze, a4 as Ye, a5 as Qe, ah as We, d as xe, e as Ie, aq as B, V as Fe, aG as Ze, Z as Se, L as he, i as fe, aH as Be, a9 as ge, f as Pe, D as V, h as F, b as Me, a3 as Je, an as Ce, a1 as $e, ad as Ee } from "./app-0klJzLit.js";
3
+ import { useDialog as we, useSnackbar as Re, useProxiedModel as Xe } from "@feedmepos/ui-library";
4
+ import { u as Ue } from "./feature-C1wCaXKQ.js";
5
+ import { b as et, u as tt, f as Le, P as ie } from "./format-unit-display-CMa5UhY1.js";
6
+ import { F as rt } from "./decimal-Cu4rlnvU.js";
7
+ import { useI18n as je } from "@feedmepos/mf-common";
8
+ import { E as st } from "./empty-placeholder-wf6-BWE8.js";
9
+ const Ve = He((v, y) => {
10
+ const b = be();
11
+ return {
12
+ async readRequests(r) {
13
+ const O = r ?? b.currentLocationDBName, c = `${v.inventoryBackendUrl}/${O}/purchase-request`;
14
+ return await y.get(c);
15
+ },
16
+ async getPurchaseOrders({
17
+ start: r,
18
+ end: O
19
+ }) {
20
+ const c = b.currentLocationDBName, R = `${v.inventoryBackendUrl}/${c}/purchase-order`;
21
+ return await y.get(`${R}?start=${r}&end=${O}`);
22
+ },
23
+ async getPurchaseOrderById(r) {
24
+ const O = b.currentLocationDBName, c = `${v.inventoryBackendUrl}/${O}/purchase-order`;
25
+ return await y.get(`${c}/${r}`);
26
+ },
27
+ async processPurchaseOrder(r, O) {
28
+ const c = b.currentLocationDBName, R = O || c, l = `${v.inventoryBackendUrl}/${R}/purchase-order/run-operation`;
29
+ return await y.put(l, r);
30
+ },
31
+ async createPurchaseOrder(r) {
32
+ const O = b.currentLocationDBName, c = `${v.inventoryBackendUrl}/${O}/purchase-order`;
33
+ return await y.post(c, r);
34
+ },
35
+ async updatePurchaseOrder(r) {
36
+ const O = b.currentLocationDBName, c = `${v.inventoryBackendUrl}/${O}/purchase-order`;
37
+ return await y.put(c, r);
38
+ }
39
+ };
40
+ }), Ke = {
41
+ [k.enum.confirmDraft]: {
42
+ primaryActions: {
43
+ text: "Confirm draft",
44
+ close: !0
45
+ },
46
+ title: "Confirm draft?",
47
+ message: "Purchase order cannot be changed after confirm draft.",
48
+ successMessage: "Purchase order draft has been confirmed"
49
+ },
50
+ [k.enum.cancelDraft]: {
51
+ primaryActions: {
52
+ text: "Cancel draft",
53
+ close: !0,
54
+ variant: "destructive"
55
+ },
56
+ title: "Cancel draft?",
57
+ message: "Purchase order cannot be changed after cancelled draft.",
58
+ successMessage: "Purchase order draft has been cancelled"
59
+ },
60
+ [k.enum.submitRequest]: {
61
+ primaryActions: {
62
+ text: "Submit request",
63
+ close: !0
64
+ },
65
+ title: "Confirm draft?",
66
+ message: "Purchase order cannot be changed after confirm draft.",
67
+ successMessage: "Purchase order draft has been submitted"
68
+ },
69
+ [k.enum.completeReceive]: {
70
+ primaryActions: {
71
+ text: "Mark received",
72
+ close: !0
73
+ },
74
+ title: "Mark as received",
75
+ message: "Purchase order cannot be changed after it has complete receiving.",
76
+ successMessage: "Purchase order has been marked as received"
77
+ },
78
+ [k.enum.approveRequest]: {
79
+ primaryActions: {
80
+ text: "Approve request",
81
+ close: !0
82
+ },
83
+ title: "Approve request?",
84
+ message: "Purchase order will be approved.",
85
+ successMessage: "Purchase order has been approved"
86
+ },
87
+ [k.enum.rejectRequest]: {
88
+ primaryActions: {
89
+ text: "Reject request",
90
+ close: !0,
91
+ variant: "destructive"
92
+ },
93
+ title: "Reject request?",
94
+ message: "Purchase order will be rejected.",
95
+ successMessage: "Purchase order has been rejected"
96
+ }
97
+ }, ve = K();
98
+ function $r(v, y) {
99
+ const b = we(), r = be(), O = Ue(), c = et(), R = tt(), l = K(!1), h = Re(), o = Ve(), s = K(new Array()), u = K(
100
+ y != null && y.startDate && (y != null && y.endDate) ? y : ze()
101
+ ), m = Y(() => {
102
+ const p = new Date(u.value.startDate), d = new Date(u.value.endDate);
103
+ return {
104
+ start: Ye(p).toISOString(),
105
+ end: Qe(d).toISOString()
106
+ };
107
+ }), f = K(new Array()), C = We(), z = K(null);
108
+ async function te(p) {
109
+ function d(n) {
110
+ const _ = {
111
+ mode: xe.CREATE,
112
+ modelValue: p || void 0,
113
+ show: !0,
114
+ "onUpdate:show"(w) {
115
+ ve.value.show = w;
116
+ },
117
+ templateId: n,
118
+ lastClosingDate: z.value
119
+ };
120
+ ve.value = _;
121
+ }
122
+ let q;
123
+ O.mustUsePoTemplate && !(p != null && p.template) ? b.open({
124
+ title: "Create Purchase Order",
125
+ message: "",
126
+ primaryActions: {
127
+ text: "Select a Template",
128
+ close: !0
129
+ },
130
+ secondaryActions: {
131
+ text: "Without Template",
132
+ close: !0
133
+ }
134
+ }).onPrimary(async () => {
135
+ q = await c.getTemplateId(), q && d(q);
136
+ }).onSecondary(() => {
137
+ d(void 0);
138
+ }) : d(q);
139
+ }
140
+ function ce(p) {
141
+ const d = {
142
+ mode: xe.UPDATE,
143
+ modelValue: Ie(p),
144
+ show: !0,
145
+ "onUpdate:show"(q) {
146
+ ve.value.show = q;
147
+ },
148
+ lastClosingDate: z.value
149
+ };
150
+ ve.value = d;
151
+ }
152
+ async function G() {
153
+ s.value = [], l.value = !0;
154
+ try {
155
+ s.value = await o.getPurchaseOrders(m.value).then((q) => q.sort((n, _) => _._id.localeCompare(n._id)));
156
+ const p = await C.readLastClosing(!0), d = p == null ? void 0 : p._id;
157
+ d && (z.value = Ze(d)), O.mustUsePoTemplate && await R.fetchTemplates();
158
+ } catch {
159
+ h.open({
160
+ title: "Something went wrong",
161
+ message: "Error at fetching purchase orders",
162
+ type: "error"
163
+ });
164
+ } finally {
165
+ l.value = !1;
166
+ }
167
+ }
168
+ async function ue() {
169
+ f.value = [], l.value = !0;
170
+ try {
171
+ f.value = await o.readRequests().then((p) => p.reverse());
172
+ } catch {
173
+ h.open({
174
+ title: "Something went wrong",
175
+ message: "Error at fetching purchase requests",
176
+ type: "error"
177
+ });
178
+ } finally {
179
+ l.value = !1;
180
+ }
181
+ }
182
+ function J() {
183
+ switch (v) {
184
+ case "receive/request":
185
+ return G();
186
+ case "approval":
187
+ return ue();
188
+ }
189
+ }
190
+ function re(p, d) {
191
+ u.value = {
192
+ startDate: p,
193
+ endDate: d
194
+ }, J();
195
+ }
196
+ r.watchLocation(async (p) => {
197
+ if (!p) {
198
+ s.value = [];
199
+ return;
200
+ }
201
+ await J();
202
+ });
203
+ const X = K(), t = K(Math.random().toString());
204
+ async function a(p, d) {
205
+ var w, $;
206
+ const q = Math.random().toString();
207
+ t.value = q;
208
+ const n = v === "receive/request" ? r.currentLocation : d == null ? void 0 : d.to, _ = {
209
+ poRequest: d,
210
+ purchaseOrder: p,
211
+ transferTo: n == null ? void 0 : n.name,
212
+ transferToDbName: n == null ? void 0 : n.dbName,
213
+ show: !0,
214
+ canResubmit: !1,
215
+ canApprove: v === "approval",
216
+ "onUpdate:show"(x) {
217
+ X.value.show = x;
218
+ }
219
+ };
220
+ if (X.value = _, !(d || p.status !== B.enum.REQUESTING)) {
221
+ try {
222
+ d = (await o.readRequests(
223
+ `${p.supplier.internal}_${p.supplier._id}`
224
+ )).find((L) => L.purchaseOrderId === p._id);
225
+ } catch {
226
+ console.error("Error at fetching po request to check");
227
+ }
228
+ q === t.value && (X.value.canResubmit = !d, X.value.transferTo = (w = d == null ? void 0 : d.to) == null ? void 0 : w.name, X.value.transferToDbName = ($ = d == null ? void 0 : d.to) == null ? void 0 : $.dbName);
229
+ }
230
+ }
231
+ async function P(p, d, q, n) {
232
+ l.value = !0;
233
+ try {
234
+ await o.processPurchaseOrder(
235
+ {
236
+ operation: d,
237
+ doc: p,
238
+ options: (
239
+ // auto receive for supplier to warehouse
240
+ (d === k.enum.confirmDraft || // auto receive for warehouse to warehouse
241
+ d === k.enum.completeReceive) && O.autoReceiveWarehouse ? {
242
+ autoReceive: !0
243
+ } : void 0
244
+ )
245
+ },
246
+ n
247
+ ), await new Promise(($) => setTimeout($, 1e3));
248
+ const w = be().currentLocationDBName.startsWith("restaurant_");
249
+ d === k.enum.confirmDraft && p.effectiveAt && w ? h.open({
250
+ title: "Success",
251
+ message: `${q}. The backdate will be reflected once your POS has received this change.`,
252
+ type: "success"
253
+ }) : h.open({
254
+ title: "Success",
255
+ message: q,
256
+ type: "success"
257
+ });
258
+ } catch (_) {
259
+ h.open({
260
+ title: "Something went wrong",
261
+ message: "Please try again.",
262
+ type: "error"
263
+ }), console.error("Error when submitting PO operation", d, p, _);
264
+ } finally {
265
+ l.value = !1, J();
266
+ }
267
+ }
268
+ async function N(p, d, q) {
269
+ const n = Ke[d];
270
+ if (!n) {
271
+ h.open({
272
+ title: "Something went wrong",
273
+ message: `Cannot process order: ${Fe(d)}`,
274
+ type: "error"
275
+ });
276
+ return;
277
+ }
278
+ const { successMessage: _, ...w } = n;
279
+ b.open({
280
+ title: w.title,
281
+ message: w.message,
282
+ primaryActions: w.primaryActions
283
+ }).onPrimary(() => {
284
+ P(p, d, _, q);
285
+ });
286
+ }
287
+ return {
288
+ purchaseOrders: s,
289
+ purchaseRequests: f,
290
+ updateDateRange: re,
291
+ fetchData: J,
292
+ loading: l,
293
+ transferDialogProps: ve,
294
+ promptCreateTransferDialog: te,
295
+ promptUpdateTransferDialog: ce,
296
+ transferDetailsProps: X,
297
+ promptShowTransferDetails: a,
298
+ submitAction: N
299
+ };
300
+ }
301
+ function at(v, y) {
302
+ return y.reduce(
303
+ (r, O) => {
304
+ const c = O.received.find((R) => R.sku._id === v._id);
305
+ return c && (r = Se(r, c.amount)), r;
306
+ },
307
+ rt.toPrecision(he(0), v.unit.precision)
308
+ );
309
+ }
310
+ function nt(v, y) {
311
+ const { name: b, address: r, regNo: O } = y.doc.profile, c = {
312
+ name: b,
313
+ registrationNumber: O,
314
+ line1: r == null ? void 0 : r.line1,
315
+ line2: r == null ? void 0 : r.line2,
316
+ postcode: r == null ? void 0 : r.postcode,
317
+ city: r == null ? void 0 : r.city,
318
+ state: r == null ? void 0 : r.state,
319
+ country: r == null ? void 0 : r.country
320
+ }, R = {
321
+ name: v.supplier.name,
322
+ registrationNumber: v.supplier.registrationNumber,
323
+ line1: v.supplier.address.line1,
324
+ line2: v.supplier.address.line2,
325
+ postcode: v.supplier.address.postcode,
326
+ city: v.supplier.address.city,
327
+ state: v.supplier.address.state,
328
+ country: v.supplier.address.country
329
+ }, l = v.items.map((u) => {
330
+ const { sku: m, measurement: f } = u, C = fe(
331
+ at(u.sku, v.deliveryOrder || []),
332
+ !1
333
+ );
334
+ return {
335
+ code: m.code,
336
+ description: m.name,
337
+ quantity: Le(u.quantity, m.unit, u.measurement),
338
+ unit: (f == null ? void 0 : f.abbrev) || m.unit.abbrev,
339
+ received: C
340
+ };
341
+ }), h = v.deliveryOrder.map((u) => ({
342
+ createdAt: Be(new Date(u.createdAt)),
343
+ ref: u.deliveryOrderNumber,
344
+ remark: u.remark || "",
345
+ items: u.received.map((m) => {
346
+ var f;
347
+ return {
348
+ code: m.sku.code,
349
+ description: m.sku.name,
350
+ quantity: fe(m.amount),
351
+ unit: ((f = m.measurement) == null ? void 0 : f.abbrev) || m.sku.unit.abbrev
352
+ };
353
+ })
354
+ })), o = {
355
+ orderNumber: v.seqNumber.toString(),
356
+ createdAt: ge(v._id),
357
+ ref: v.ref || "",
358
+ remark: v.remark || "",
359
+ buyer: c,
360
+ supplier: R,
361
+ items: l,
362
+ status: v.status,
363
+ deliveryOrders: h
364
+ }, s = new URL(window.location.href);
365
+ s.pathname = s.hostname.includes("inventory.feedme") ? "/receive-request/print-preview" : "/inventory/receive-request/print-preview", s.searchParams.append("data", JSON.stringify(o)), window.open(s.href, "_blank", "noreferrer");
366
+ }
367
+ const me = {
368
+ submitRequest: {
369
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
370
+ color: "text-fm-color-typo-primary",
371
+ value: k.enum.submitRequest
372
+ },
373
+ confirmDraft: {
374
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
375
+ color: "text-fm-color-typo-primary",
376
+ value: k.enum.confirmDraft
377
+ },
378
+ cancelDraft: {
379
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
380
+ color: "text-fm-color-typo-error",
381
+ value: k.enum.cancelDraft
382
+ },
383
+ approveRequest: {
384
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
385
+ color: "text-fm-color-typo-primary",
386
+ value: k.enum.approveRequest
387
+ },
388
+ rejectRequest: {
389
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
390
+ color: "text-fm-color-typo-error",
391
+ value: k.enum.rejectRequest
392
+ },
393
+ processRequest: {
394
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
395
+ color: "text-fm-color-typo-primary",
396
+ value: k.enum.processRequest
397
+ },
398
+ receiveStock: {
399
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
400
+ color: "text-fm-color-typo-primary",
401
+ value: k.enum.receiveStock
402
+ },
403
+ completeReceive: {
404
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
405
+ color: "text-fm-color-typo-primary",
406
+ value: k.enum.completeReceive
407
+ }
408
+ };
409
+ function Er(v, y) {
410
+ const b = be(), { t: r } = je();
411
+ function O(s) {
412
+ switch (s.status) {
413
+ case "DRAFT":
414
+ return [
415
+ V[F.Update],
416
+ V[F.Details],
417
+ s.supplier.internal === "restaurant" || s.supplier.internal === "warehouse" ? me[k.enum.submitRequest] : me[k.enum.confirmDraft],
418
+ me[k.enum.cancelDraft],
419
+ V[F.Print]
420
+ ];
421
+ case "RECEIVING":
422
+ return [
423
+ me[k.enum.completeReceive],
424
+ V[F.Details],
425
+ V[F.Print]
426
+ ];
427
+ case "REQUESTING":
428
+ return v === "receive/request" ? [V[F.Details], V[F.Print]] : [
429
+ me[k.enum.approveRequest],
430
+ me[k.enum.rejectRequest],
431
+ V[F.Details],
432
+ V[F.Print]
433
+ ];
434
+ case "PROCESSING":
435
+ return [V[F.Details], V[F.Print]];
436
+ case "COMPLETE":
437
+ case "CANCEL":
438
+ default:
439
+ return [V[F.Details], V[F.Print]];
440
+ }
441
+ }
442
+ function c(s) {
443
+ return Object.values(k.enum).includes(s);
444
+ }
445
+ async function R(s, u, m) {
446
+ var C, z;
447
+ const f = Ie(u);
448
+ if (s === F.Print) {
449
+ nt(f, b.currentLocation);
450
+ return;
451
+ }
452
+ if (s === F.Details) {
453
+ y.promptShowTransferDetails(f, m);
454
+ return;
455
+ }
456
+ if (s === F.Update) {
457
+ (C = y.promptUpdateTransferDialog) == null || C.call(y, f);
458
+ return;
459
+ }
460
+ if (c(s)) {
461
+ y.submitAction(u, s, (z = m == null ? void 0 : m.to) == null ? void 0 : z.dbName);
462
+ return;
463
+ }
464
+ }
465
+ function l() {
466
+ return [
467
+ {
468
+ accessorKey: "seqNumber",
469
+ header: () => r("inventory.transfer.table.seqNo"),
470
+ enableSorting: !0,
471
+ size: 80,
472
+ sortUndefined: "last"
473
+ },
474
+ {
475
+ accessorKey: "_id",
476
+ header: () => r("inventory.transfer.table.createdAt"),
477
+ cell(s) {
478
+ return ge(`${s.getValue()}`);
479
+ },
480
+ enableSorting: !0
481
+ },
482
+ {
483
+ accessorKey: "supplier.name",
484
+ header: () => r("inventory.transfer.table.transferFrom"),
485
+ enableSorting: !0,
486
+ size: 200
487
+ },
488
+ {
489
+ accessorKey: "items.length",
490
+ header: () => r("inventory.transfer.table.noOfItems"),
491
+ enableSorting: !1,
492
+ meta: {
493
+ width: "10rem"
494
+ }
495
+ },
496
+ {
497
+ accessorKey: "ref",
498
+ header: () => r("inventory.transfer.table.reference"),
499
+ enableSorting: !1,
500
+ size: "auto"
501
+ },
502
+ {
503
+ accessorKey: "status",
504
+ header: () => r("inventory.transfer.table.status"),
505
+ cell(s) {
506
+ const u = r(`inventory.transfer.status.${s.getValue() ?? ""}`), m = `${s.getValue() ?? ""}`.toLocaleLowerCase("en-us");
507
+ return oe(
508
+ "div",
509
+ {
510
+ class: "flex"
511
+ },
512
+ oe(
513
+ "div",
514
+ {
515
+ class: `fm-status-badge fm-status-badge-${m}`
516
+ },
517
+ u
518
+ )
519
+ );
520
+ },
521
+ enableSorting: !0,
522
+ size: 200
523
+ },
524
+ {
525
+ id: "action",
526
+ cell(s) {
527
+ const u = s.row.original, m = O(u);
528
+ return Pe(m, (f) => R(f, u));
529
+ },
530
+ enableSorting: !1,
531
+ size: 40,
532
+ meta: {
533
+ cellClass: "",
534
+ headerClass: ""
535
+ }
536
+ }
537
+ ];
538
+ }
539
+ function h() {
540
+ return [
541
+ {
542
+ accessorKey: "purchaseOrder.seqNumber",
543
+ header: () => r("inventory.transfer.table.seqNo"),
544
+ enableSorting: !0,
545
+ size: 80,
546
+ sortUndefined: "last"
547
+ },
548
+ {
549
+ accessorKey: "purchaseOrder._id",
550
+ header: () => r("inventory.transfer.table.createdAt"),
551
+ cell(s) {
552
+ return ge(`${s.getValue()}`);
553
+ },
554
+ enableSorting: !0
555
+ },
556
+ {
557
+ accessorKey: "to.name",
558
+ header: () => r("inventory.transfer.table.transferTo"),
559
+ enableSorting: !1,
560
+ size: 200
561
+ },
562
+ {
563
+ accessorKey: "purchaseOrder.items.length",
564
+ header: () => r("inventory.transfer.table.noOfItems"),
565
+ enableSorting: !1
566
+ },
567
+ {
568
+ accessorKey: "purchaseOrder.ref",
569
+ header: () => r("inventory.transfer.table.reference"),
570
+ enableSorting: !1,
571
+ size: "auto"
572
+ },
573
+ {
574
+ accessorKey: "purchaseOrder.status",
575
+ header: () => r("inventory.transfer.table.status"),
576
+ cell(s) {
577
+ const u = r(`inventory.transfer.status.${s.getValue() ?? ""}`), m = `${s.getValue() ?? ""}`.toLocaleLowerCase("en-us");
578
+ return oe(
579
+ "div",
580
+ {
581
+ class: "flex"
582
+ },
583
+ oe(
584
+ "div",
585
+ {
586
+ class: `fm-status-badge fm-status-badge-${m}`
587
+ },
588
+ u
589
+ )
590
+ );
591
+ },
592
+ enableSorting: !0
593
+ },
594
+ {
595
+ id: "action",
596
+ cell(s) {
597
+ const u = s.row.original, m = u.purchaseOrder ? O(u.purchaseOrder) : [];
598
+ return Pe(
599
+ m,
600
+ (f) => u.purchaseOrder ? R(f, u.purchaseOrder, u) : void 0
601
+ );
602
+ },
603
+ enableSorting: !1,
604
+ size: 40,
605
+ meta: {
606
+ cellClass: "",
607
+ headerClass: ""
608
+ }
609
+ }
610
+ ];
611
+ }
612
+ const o = Y(() => v === "receive/request" ? l() : h());
613
+ return {
614
+ get columnDefs() {
615
+ return o.value;
616
+ }
617
+ };
618
+ }
619
+ const ot = {
620
+ key: 0,
621
+ class: "flex flex-col gap-8"
622
+ }, lt = { class: "flex flex-col gap-4" }, it = { class: "fm-typo-en-body-lg-600" }, ct = {
623
+ key: 0,
624
+ class: "flex flex-col gap-4"
625
+ }, ut = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, dt = { class: "fm-typo-en-body-lg-600" }, mt = {
626
+ key: 1,
627
+ class: "flex flex-col gap-4"
628
+ }, ft = { class: "fm-typo-en-body-lg-600" }, pt = {
629
+ key: 2,
630
+ class: "flex flex-col gap-4"
631
+ }, vt = { class: "fm-typo-en-body-lg-600" }, yt = /* @__PURE__ */ _e({
632
+ __name: "NetSuiteInfo",
633
+ props: {
634
+ transferType: {},
635
+ transferToDbName: {},
636
+ poRequest: {},
637
+ purchaseOrder: {},
638
+ isTransferBetweenOutlets: { type: Boolean }
639
+ },
640
+ setup(v) {
641
+ const y = v, b = Me(), r = Y(
642
+ () => {
643
+ var c, R, l, h, o, s;
644
+ return b.getLocationSubsidiary(
645
+ ((l = (R = (c = y.purchaseOrder) == null ? void 0 : c.netSuite) == null ? void 0 : R.subsidiary) == null ? void 0 : l.id) || ((s = (o = (h = y.poRequest) == null ? void 0 : h.netSuite) == null ? void 0 : o.subsidiary) == null ? void 0 : s.id)
646
+ ).fullName;
647
+ }
648
+ ), O = Y(() => {
649
+ var c, R, l, h, o, s;
650
+ return (R = (c = y.purchaseOrder) == null ? void 0 : c.deliveryFullfillment) != null && R.length && ((h = (l = y.purchaseOrder) == null ? void 0 : l.deliveryFullfillment) == null ? void 0 : h.length) > 0 ? (s = (o = y.purchaseOrder) == null ? void 0 : o.deliveryFullfillment) == null ? void 0 : s.map((u) => {
651
+ var m;
652
+ return (m = u.netSuite) == null ? void 0 : m.refNo;
653
+ }).join(", ") : "-";
654
+ });
655
+ return (c, R) => {
656
+ var l, h, o, s, u, m, f, C, z, te, ce, G, ue, J;
657
+ return i(b).isEnabled ? (g(), D("div", ot, [
658
+ e("div", lt, [
659
+ R[0] || (R[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
660
+ e("div", it, S(r.value || "-"), 1)
661
+ ]),
662
+ c.isTransferBetweenOutlets ? T("", !0) : (g(), D("div", ct, [
663
+ e("div", ut, " NetSuite " + S(c.transferType === i(ie).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
664
+ e("div", dt, S(c.poRequest ? (h = (l = c.poRequest) == null ? void 0 : l.netSuite) == null ? void 0 : h.refNo : (s = (o = c.purchaseOrder) == null ? void 0 : o.netSuite) == null ? void 0 : s.refNo) + " (" + S(c.poRequest ? (m = (u = c.poRequest) == null ? void 0 : u.netSuite) == null ? void 0 : m.id : (C = (f = c.purchaseOrder) == null ? void 0 : f.netSuite) == null ? void 0 : C.id) + ") ", 1)
665
+ ])),
666
+ (ce = (te = (z = c.purchaseOrder) == null ? void 0 : z.netSuite) == null ? void 0 : te.additionalInfo) != null && ce.transactionnumber ? (g(), D("div", mt, [
667
+ R[1] || (R[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
668
+ e("div", ft, S((J = (ue = (G = c.purchaseOrder) == null ? void 0 : G.netSuite) == null ? void 0 : ue.additionalInfo) == null ? void 0 : J.transactionnumber), 1)
669
+ ])) : T("", !0),
670
+ i(b).isEnabled && c.transferType === i(ie).TRANSFER && !c.isTransferBetweenOutlets ? (g(), D("div", pt, [
671
+ R[2] || (R[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
672
+ e("div", vt, S(O.value), 1)
673
+ ])) : T("", !0)
674
+ ])) : T("", !0);
675
+ };
676
+ }
677
+ }), ht = {
678
+ key: 0,
679
+ class: "flex flex-row-reverse"
680
+ }, bt = /* @__PURE__ */ _e({
681
+ __name: "NetSuiteSync",
682
+ props: {
683
+ poRequest: {},
684
+ purchaseOrder: {},
685
+ isTransferBetweenOutlets: { type: Boolean }
686
+ },
687
+ setup(v) {
688
+ const y = v, b = Me(), r = Re(), O = we(), c = K(!1), R = Y(() => {
689
+ var u, m, f, C;
690
+ let h = !0;
691
+ b.isEnabled || (h = !1);
692
+ const o = y.purchaseOrder, s = y.poRequest;
693
+ return o && ((u = o == null ? void 0 : o.supplier) != null && u.internal ? (!s && o.status == B.enum.DRAFT && (h = !1), s && !((m = s == null ? void 0 : s.netSuite) != null && m.id) && (h = !1), y.isTransferBetweenOutlets && (h = !1)) : ((o == null ? void 0 : o.status) !== B.enum.REQUESTING && o.supplier.internal && (h = !1), !s && !((f = o == null ? void 0 : o.netSuite) != null && f.id) && (h = !1), !s && ((C = o == null ? void 0 : o.netSuite) != null && C.id) && (o == null ? void 0 : o.status) == B.enum.REQUESTING && (h = !1))), h;
694
+ });
695
+ async function l() {
696
+ c.value || O.open({
697
+ title: "Sync with NetSuite",
698
+ contentComponent: oe("div", [
699
+ oe("p", "Are you sure you want to sync now?"),
700
+ oe("br"),
701
+ oe(
702
+ "p",
703
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
704
+ "Please wait a moment before syncing manually to avoid unnecessary actions."
705
+ )
706
+ ]),
707
+ primaryActions: {
708
+ text: "Sync",
709
+ close: !0,
710
+ variant: "destructive"
711
+ },
712
+ secondaryActions: { text: "Not now", close: !0 }
713
+ }).onPrimary(async () => {
714
+ var h;
715
+ try {
716
+ c.value = !0;
717
+ const o = y.purchaseOrder, s = y.poRequest;
718
+ let u = "purchaseOrder";
719
+ if ((h = o == null ? void 0 : o.supplier) != null && h.internal && (u = "purchaseOrderRequest"), !(o != null && o._id)) {
720
+ r.open({
721
+ title: "Error",
722
+ message: "Invalid sync ID",
723
+ type: "error"
724
+ });
725
+ return;
726
+ }
727
+ await b.syncTransferOrder(u, o == null ? void 0 : o._id, s == null ? void 0 : s._id), r.open({
728
+ title: "Sync with NetSuite",
729
+ message: "Requested to sync with NetSuite. Please wait a moment.",
730
+ type: "success"
731
+ });
732
+ } catch {
733
+ r.open({
734
+ title: "Error",
735
+ message: "Failed to sync with NetSuite",
736
+ type: "error"
737
+ });
738
+ }
739
+ setTimeout(() => {
740
+ c.value = !1;
741
+ }, 5e3);
742
+ });
743
+ }
744
+ return (h, o) => {
745
+ const s = Z("FmButton");
746
+ return R.value ? (g(), D("div", ht, [
747
+ U(s, {
748
+ "prepend-icon": "sync",
749
+ variant: "primary",
750
+ label: "NetSuite",
751
+ loading: c.value,
752
+ onClick: l
753
+ }, null, 8, ["loading"])
754
+ ])) : T("", !0);
755
+ };
756
+ }
757
+ }), gt = { class: "flex flex-col gap-16 w-full h-full" }, St = { class: "flex justify-between" }, _t = { class: "fm-typo-en-body-lg-600" }, wt = { class: "flex flex-col gap-8" }, Rt = { class: "flex flex-col gap-4" }, Ot = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Dt = { class: "flex gap-1" }, kt = { class: "fm-typo-en-body-lg-600" }, qt = {
758
+ key: 0,
759
+ class: "flex flex-col gap-4"
760
+ }, At = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Nt = { class: "fm-typo-en-body-lg-600" }, Tt = { class: "flex flex-col gap-4" }, xt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pt = { class: "fm-typo-en-body-lg-600" }, Ct = {
761
+ key: 1,
762
+ class: "flex flex-col gap-4"
763
+ }, $t = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Et = { class: "fm-typo-en-body-lg-600" }, It = {
764
+ key: 2,
765
+ class: "flex flex-col gap-4"
766
+ }, Ft = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bt = { class: "fm-typo-en-body-lg-600" }, Mt = {
767
+ key: 3,
768
+ class: "flex flex-col gap-4"
769
+ }, Ut = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Lt = { class: "fm-typo-en-body-lg-600" }, jt = {
770
+ key: 4,
771
+ class: "flex flex-col gap-4"
772
+ }, Vt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Kt = { class: "fm-typo-en-body-lg-600" }, Gt = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Ht = { class: "flex flex-col gap-8" }, zt = { class: "fm-typo-en-body-lg-600" }, Yt = { class: "flex gap-8" }, Qt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Wt = { class: "flex w-full gap-4" }, Zt = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2" }, Jt = { class: "fm-typo-en-body-lg-600 line-clamp-2" }, Xt = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, er = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, tr = {
773
+ key: 0,
774
+ class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
775
+ }, rr = { class: "py-8" }, sr = { class: "flex justify-end gap-4 items-center" }, ar = { class: "fm-typo-en-body-lg-600" }, nr = {
776
+ key: 1,
777
+ class: "flex-1 xs:w-screen xs:max-w-full"
778
+ }, or = {
779
+ key: 0,
780
+ class: "flex flex-col items-center gap-8 h-full"
781
+ }, lr = ["src"], ir = { class: "fm-typo-en-body-lg-600" }, cr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, ur = {
782
+ key: 1,
783
+ class: "px-4 flex flex-col"
784
+ }, dr = { class: "flex gap-12 content-stretch" }, mr = {
785
+ class: "flex flex-col w-24",
786
+ name: "circles"
787
+ }, fr = { class: "flex-1 flex flex-col items-center" }, pr = { class: "flex-1 flex flex-col items-center" }, vr = {
788
+ class: "py-12 flex flex-col gap-4",
789
+ name: "received-at header"
790
+ }, yr = { class: "fm-typo-en-body-lg-400" }, hr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, br = { class: "flex gap-12 content-stretch" }, gr = {
791
+ class: "flex flex-col w-24",
792
+ name: "circles"
793
+ }, Sr = { class: "flex-1 flex flex-col items-center" }, _r = {
794
+ class: "py-12 flex flex-col gap-4 flex-1",
795
+ name: "delivery details"
796
+ }, wr = { class: "flex flex-col gap-8" }, Rr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Or = { class: "flex flex-col gap-4" }, Dr = { class: "flex gap-8 xs:flex-col" }, Ir = /* @__PURE__ */ _e({
797
+ __name: "TransferDetails",
798
+ props: {
799
+ poRequest: {},
800
+ purchaseOrder: {},
801
+ transferTo: {},
802
+ transferToDbName: {},
803
+ show: { type: Boolean },
804
+ canResubmit: { type: Boolean },
805
+ canApprove: { type: Boolean }
806
+ },
807
+ emits: ["update:show", "submitted"],
808
+ setup(v, { emit: y }) {
809
+ const b = v, r = y, O = we(), c = Re(), R = Ue(), { t: l } = je(), h = Y(
810
+ () => {
811
+ var t, a, P, N;
812
+ return ((a = (t = b.purchaseOrder) == null ? void 0 : t.supplier) == null ? void 0 : a.internal) === "restaurant" || ((N = (P = b.purchaseOrder) == null ? void 0 : P.supplier) == null ? void 0 : N.internal) === "warehouse" ? ie.TRANSFER : ie.PURCHASE;
813
+ }
814
+ ), o = Y(() => {
815
+ var t, a, P;
816
+ return h.value === ie.TRANSFER && ((t = b.transferToDbName) == null ? void 0 : t.startsWith("restaurant")) && ((P = (a = b.purchaseOrder) == null ? void 0 : a.supplier) == null ? void 0 : P.internal) === "restaurant";
817
+ }), s = [
818
+ {
819
+ label: l("inventory.transfer.receiveRequest.details.overview"),
820
+ value: "overview"
821
+ },
822
+ {
823
+ label: l("inventory.transfer.receiveRequest.details.deliveryHistory"),
824
+ value: "deliveryHistory"
825
+ }
826
+ ], u = K(s[0]), m = K(!1), f = K(""), C = K(!0), z = Ve(), te = Xe(b, "show");
827
+ async function ce(t, a, P) {
828
+ f.value = a, m.value = !0, C.value = !1;
829
+ try {
830
+ await z.processPurchaseOrder(
831
+ {
832
+ operation: a,
833
+ doc: t,
834
+ options: (
835
+ // auto receive for supplier to warehouse
836
+ (a === k.enum.confirmDraft || // auto receive for warehouse to warehouse
837
+ a === k.enum.completeReceive) && R.autoReceiveWarehouse ? {
838
+ autoReceive: !0
839
+ } : void 0
840
+ )
841
+ },
842
+ b.transferToDbName
843
+ ), await new Promise((N) => setTimeout(N, 1e3)), c.open({
844
+ title: "Success",
845
+ message: P,
846
+ type: "success"
847
+ }), r("update:show", !1), r("submitted");
848
+ } catch (N) {
849
+ c.open({
850
+ title: "Something went wrong",
851
+ message: "Please try again.",
852
+ type: "error"
853
+ }), console.error("Error when submitting PO operation", a, t, N);
854
+ } finally {
855
+ f.value = "", m.value = !1, C.value = !0;
856
+ }
857
+ }
858
+ async function G(t) {
859
+ const a = Ke[t];
860
+ if (!a) {
861
+ c.open({
862
+ title: "Something went wrong",
863
+ message: `Cannot process order: ${Fe(t)}`,
864
+ type: "error"
865
+ });
866
+ return;
867
+ }
868
+ const { successMessage: P, ...N } = a;
869
+ O.open({
870
+ title: N.title,
871
+ message: N.message,
872
+ primaryActions: N.primaryActions
873
+ }).onPrimary(() => {
874
+ b.purchaseOrder && ce(b.purchaseOrder, t, P);
875
+ });
876
+ }
877
+ const ue = Y(() => {
878
+ var t, a;
879
+ return ((t = b.purchaseOrder) == null ? void 0 : t.status) === B.enum.RECEIVING || ((a = b.purchaseOrder) == null ? void 0 : a.status) === B.enum.COMPLETE;
880
+ }), J = Y(() => {
881
+ var d, q, n;
882
+ const P = (((d = b.purchaseOrder) == null ? void 0 : d.deliveryOrder) ?? []).flatMap((_) => _.received ?? []).reduce(
883
+ (_, w) => {
884
+ const $ = _[w.sku._id] ?? [];
885
+ return _[w.sku._id] = [...$, w], _;
886
+ },
887
+ {}
888
+ ), N = Object.entries(P).reduce(
889
+ (_, [w, $]) => {
890
+ const x = $.reduce((L, j) => {
891
+ const Q = Je(
892
+ L,
893
+ Math.max(L.precision, j.amount.precision)
894
+ );
895
+ return Se(Q, j.amount);
896
+ }, he(0));
897
+ return _[w] = x, _;
898
+ },
899
+ {}
900
+ ), p = ((q = b.purchaseOrder) == null ? void 0 : q.items) ?? [];
901
+ for (const _ of p)
902
+ N[n = _.sku._id] ?? (N[n] = he(0));
903
+ return N;
904
+ }), re = Y(() => {
905
+ var d, q;
906
+ const t = ((d = b.purchaseOrder) == null ? void 0 : d.deliveryOrder) ?? [], a = ((q = b.purchaseOrder) == null ? void 0 : q.deliveryFullfillment) ?? [], P = [
907
+ ...t.map((n) => ({
908
+ createdAt: n.createdAt,
909
+ type: "grn",
910
+ doc: n
911
+ })),
912
+ ...a.map((n) => ({
913
+ createdAt: n.createdAt,
914
+ type: "fulfillment",
915
+ doc: n
916
+ }))
917
+ ];
918
+ P.reverse().sort((n, _) => n.createdAt.localeCompare(_.createdAt));
919
+ function N(n) {
920
+ var w, $, x, L, j, Q, se;
921
+ const _ = a.findIndex((M) => M.id === n.fullfillmentId);
922
+ return {
923
+ header: "Received",
924
+ date: Ee(new Date(n.createdAt)),
925
+ info: [
926
+ {
927
+ label: "Received by",
928
+ values: [(w = n.createdBy) == null ? void 0 : w.name]
929
+ },
930
+ {
931
+ label: "Received items",
932
+ values: n.received.map((M) => {
933
+ var ae;
934
+ return `(${M.sku.code}) ${M.sku.name}: ${fe(M.amount, !1)} ${((ae = M.measurement) == null ? void 0 : ae.abbrev) ?? M.sku.unit.abbrev}`;
935
+ })
936
+ },
937
+ n.deliveryOrderNumber ? {
938
+ label: "Delivery order no.",
939
+ values: [n.deliveryOrderNumber]
940
+ } : null,
941
+ n.remark ? {
942
+ label: "Remark",
943
+ values: [n.remark]
944
+ } : null,
945
+ _ > -1 ? {
946
+ label: "Fulfilment's sequence",
947
+ values: [`${_ + 1}`]
948
+ } : null,
949
+ (x = ($ = a[_]) == null ? void 0 : $.netSuite) != null && x.refNo ? {
950
+ label: "Fulfillment's ref no. (Netsuite)",
951
+ values: [(j = (L = a[_]) == null ? void 0 : L.netSuite) == null ? void 0 : j.refNo]
952
+ } : null,
953
+ (Q = n == null ? void 0 : n.netSuite) != null && Q.refNo ? {
954
+ label: "Item receipt (Netsuite)",
955
+ values: [(se = n == null ? void 0 : n.netSuite) == null ? void 0 : se.refNo]
956
+ } : null
957
+ ].filter((M) => M)
958
+ };
959
+ }
960
+ function p(n) {
961
+ var w, $;
962
+ const _ = a.findIndex((x) => x.id === n.id);
963
+ return {
964
+ header: "Fulfillment",
965
+ date: Ee(new Date(n.createdAt)),
966
+ info: [
967
+ {
968
+ label: "Sequence",
969
+ values: [String(_ + 1)]
970
+ },
971
+ {
972
+ label: "Receiveable items",
973
+ values: n.items.map((x) => {
974
+ var L;
975
+ return `(${x.sku.code}) ${x.sku.name}: ${fe(x.amount, !1)} ${((L = x.measurement) == null ? void 0 : L.abbrev) ?? x.sku.unit.abbrev}`;
976
+ })
977
+ },
978
+ (w = n.netSuite) != null && w.refNo ? {
979
+ label: "Ref no. (Netsuite)",
980
+ values: [($ = n.netSuite) == null ? void 0 : $.refNo]
981
+ } : null
982
+ ].filter((x) => x)
983
+ };
984
+ }
985
+ return P.map((n) => {
986
+ switch (n.type) {
987
+ case "grn":
988
+ return N(n.doc);
989
+ case "fulfillment":
990
+ return p(n.doc);
991
+ }
992
+ });
993
+ }), X = Y(() => {
994
+ var a;
995
+ const t = {
996
+ ...he(0),
997
+ currency: Ce()
998
+ };
999
+ return ((a = b.purchaseOrder) == null ? void 0 : a.items.reduce((P, N) => ({
1000
+ ...Se(P, N.totalCost ?? t),
1001
+ currency: Ce()
1002
+ }), t)) ?? t;
1003
+ });
1004
+ return (t, a) => {
1005
+ var x, L;
1006
+ const P = Z("FmButtonGroup"), N = Z("FmChip"), p = Z("FmMenuDivider"), d = Z("FmCard"), q = Z("FmIcon"), n = Z("FmTooltip"), _ = Z("FmSpacer"), w = Z("FmButton"), $ = Z("FmSideSheet");
1007
+ return g(), W($, {
1008
+ header: i(l)("inventory.transfer.receiveRequest.details.title") + ((x = t.purchaseOrder) != null && x.seqNumber ? ` #${(L = t.purchaseOrder) == null ? void 0 : L.seqNumber}` : ""),
1009
+ modelValue: i(te),
1010
+ "onUpdate:modelValue": a[9] || (a[9] = (j) => Ge(te) ? te.value = j : null),
1011
+ "dismiss-away": C.value,
1012
+ "close-button": "",
1013
+ "max-width": 600
1014
+ }, {
1015
+ default: de(() => {
1016
+ var j, Q, se, M, ae;
1017
+ return [
1018
+ e("div", gt, [
1019
+ U(bt, {
1020
+ "po-request": t.poRequest,
1021
+ "purchase-order": t.purchaseOrder,
1022
+ "is-transfer-between-outlets": o.value
1023
+ }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets"]),
1024
+ e("div", null, [
1025
+ U(P, {
1026
+ items: s,
1027
+ modelValue: u.value,
1028
+ "onUpdate:modelValue": a[0] || (a[0] = (A) => u.value = A)
1029
+ }, null, 8, ["modelValue"])
1030
+ ]),
1031
+ u.value.value === "overview" ? (g(), D(ne, { key: 0 }, [
1032
+ e("div", null, [
1033
+ U(d, {
1034
+ variant: "outlined",
1035
+ class: "flex flex-col gap-8 px-12 py-16"
1036
+ }, {
1037
+ default: de(() => {
1038
+ var A, E, I, ee, le, H, Oe, De, ke, qe, Ae, Ne;
1039
+ return [
1040
+ e("div", St, [
1041
+ e("div", _t, S(i(l)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
1042
+ e("div", null, [
1043
+ U(N, {
1044
+ label: i(l)(`inventory.transfer.status.${(A = t.purchaseOrder) == null ? void 0 : A.status}`),
1045
+ class: ye(`fm-status-badge fm-status-badge-${(I = (E = t.purchaseOrder) == null ? void 0 : E.status) == null ? void 0 : I.toLocaleLowerCase("en-us")}`),
1046
+ compact: ""
1047
+ }, null, 8, ["label", "class"])
1048
+ ])
1049
+ ]),
1050
+ U(p),
1051
+ e("div", wt, [
1052
+ e("div", Rt, [
1053
+ e("div", Ot, [
1054
+ e("div", Dt, S(i(l)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1055
+ ]),
1056
+ e("div", kt, S(i(ge)(((ee = t.purchaseOrder) == null ? void 0 : ee._id) ?? "")), 1)
1057
+ ]),
1058
+ (le = t.purchaseOrder) != null && le.effectiveAt ? (g(), D("div", qt, [
1059
+ e("div", At, S(i(l)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
1060
+ e("div", Nt, S(i(Be)(new Date((H = t.purchaseOrder) == null ? void 0 : H.effectiveAt))), 1)
1061
+ ])) : T("", !0),
1062
+ e("div", Tt, [
1063
+ e("div", xt, S(i(l)("inventory.transfer.receiveRequest.details.type.title")), 1),
1064
+ e("div", Pt, S(i(l)(
1065
+ `inventory.transfer.receiveRequest.details.type.${h.value.toLocaleLowerCase("en-US")}`
1066
+ )), 1)
1067
+ ]),
1068
+ (De = (Oe = t.purchaseOrder) == null ? void 0 : Oe.supplier) != null && De.name ? (g(), D("div", Ct, [
1069
+ e("div", $t, S(i(l)("inventory.transfer.receiveRequest.details.from")), 1),
1070
+ e("div", Et, S((qe = (ke = t.purchaseOrder) == null ? void 0 : ke.supplier) == null ? void 0 : qe.name), 1)
1071
+ ])) : T("", !0),
1072
+ t.transferTo ? (g(), D("div", It, [
1073
+ e("div", Ft, S(i(l)("inventory.transfer.receiveRequest.details.to")), 1),
1074
+ e("div", Bt, S(t.transferTo), 1)
1075
+ ])) : T("", !0),
1076
+ U(yt, {
1077
+ "po-request": t.poRequest,
1078
+ "purchase-order": t.purchaseOrder,
1079
+ "transfer-type": h.value,
1080
+ "transfer-to-db-name": t.transferToDbName,
1081
+ "is-transfer-between-outlets": o.value
1082
+ }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets"]),
1083
+ (Ae = t.purchaseOrder) != null && Ae.ref ? (g(), D("div", Mt, [
1084
+ e("div", Ut, S(i(l)("inventory.transfer.receiveRequest.details.reference")), 1),
1085
+ e("div", Lt, S(t.purchaseOrder.ref), 1)
1086
+ ])) : T("", !0),
1087
+ (Ne = t.purchaseOrder) != null && Ne.remark ? (g(), D("div", jt, [
1088
+ e("div", Vt, S(i(l)("inventory.transfer.receiveRequest.details.remark")), 1),
1089
+ e("div", Kt, S(t.purchaseOrder.remark), 1)
1090
+ ])) : T("", !0)
1091
+ ])
1092
+ ];
1093
+ }),
1094
+ _: 1
1095
+ })
1096
+ ]),
1097
+ e("div", Gt, [
1098
+ e("div", Ht, [
1099
+ e("div", zt, [
1100
+ e("div", Yt, [
1101
+ Te(S(ue.value ? i(l)("inventory.transfer.receiveRequest.details.receivedItems") : i(l)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
1102
+ (Q = (j = t.purchaseOrder) == null ? void 0 : j.netSuite) != null && Q.missingItems && ((M = (se = t.purchaseOrder) == null ? void 0 : se.netSuite) == null ? void 0 : M.missingItems.length) > 0 ? (g(), W(n, {
1103
+ key: 0,
1104
+ variant: "rich",
1105
+ placement: "top",
1106
+ "z-index": 51
1107
+ }, {
1108
+ content: de(() => {
1109
+ var A, E;
1110
+ return [
1111
+ e("div", Qt, [
1112
+ (g(!0), D(ne, null, pe((E = (A = t.purchaseOrder) == null ? void 0 : A.netSuite) == null ? void 0 : E.missingItems, (I, ee) => (g(), D("div", {
1113
+ class: "flex justify-center align-middle",
1114
+ key: ee
1115
+ }, [
1116
+ U(q, {
1117
+ name: "arrow_right",
1118
+ size: "sm"
1119
+ }),
1120
+ Te(" " + S(`(${I.netSuiteId}) ${I.name}: ${I.reason}`), 1)
1121
+ ]))), 128))
1122
+ ])
1123
+ ];
1124
+ }),
1125
+ default: de(() => [
1126
+ U(q, {
1127
+ name: "error",
1128
+ color: "#ff2c2c",
1129
+ size: "sm"
1130
+ })
1131
+ ]),
1132
+ _: 1
1133
+ })) : T("", !0)
1134
+ ])
1135
+ ]),
1136
+ (g(!0), D(ne, null, pe(((ae = t.purchaseOrder) == null ? void 0 : ae.items) ?? [], (A) => (g(), D("div", {
1137
+ key: A.code,
1138
+ class: "flex flex-col"
1139
+ }, [
1140
+ e("div", Wt, [
1141
+ e("div", Zt, S(A.name), 1),
1142
+ e("div", Jt, S(i(fe)(J.value[A.sku._id], !1)) + "/" + S(i(Le)(A.quantity, A.sku.unit, A.measurement)), 1)
1143
+ ]),
1144
+ e("div", Xt, [
1145
+ e("div", er, S(A.code), 1),
1146
+ A.totalCost && i(R).enableTotalCost ? (g(), D("div", tr, " (" + S(i($e)(A.totalCost)) + ") ", 1)) : T("", !0)
1147
+ ])
1148
+ ]))), 128)),
1149
+ +i(fe)(X.value) ? (g(), D(ne, { key: 0 }, [
1150
+ e("div", rr, [
1151
+ U(p)
1152
+ ]),
1153
+ e("div", sr, [
1154
+ a[10] || (a[10] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
1155
+ e("div", ar, S(i($e)(X.value)), 1)
1156
+ ])
1157
+ ], 64)) : T("", !0)
1158
+ ])
1159
+ ])
1160
+ ], 64)) : T("", !0),
1161
+ u.value.value === "deliveryHistory" ? (g(), D("div", nr, [
1162
+ re.value.length ? (g(), D("div", ur, [
1163
+ (g(!0), D(ne, null, pe(re.value, (A, E) => (g(), D(ne, { key: E }, [
1164
+ e("div", dr, [
1165
+ e("div", mr, [
1166
+ e("div", fr, [
1167
+ e("div", {
1168
+ class: ye([
1169
+ {
1170
+ "bg-fm-color-primary": E !== 0,
1171
+ "bg-white": E === 0
1172
+ },
1173
+ "w-[2px] h-full"
1174
+ ])
1175
+ }, null, 2)
1176
+ ]),
1177
+ a[11] || (a[11] = e("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1178
+ e("div", pr, [
1179
+ e("div", {
1180
+ class: ye([
1181
+ {
1182
+ "bg-fm-color-primary": E < re.value.length - 1,
1183
+ "bg-white": E >= re.value.length - 1
1184
+ },
1185
+ "w-[2px] h-full"
1186
+ ])
1187
+ }, null, 2)
1188
+ ])
1189
+ ]),
1190
+ e("div", vr, [
1191
+ e("div", yr, S(A.header), 1),
1192
+ e("div", hr, S(A.date), 1)
1193
+ ])
1194
+ ]),
1195
+ e("div", br, [
1196
+ e("div", gr, [
1197
+ e("div", Sr, [
1198
+ e("div", {
1199
+ class: ye([
1200
+ {
1201
+ "bg-fm-color-primary": E < re.value.length - 1,
1202
+ "bg-white": E >= re.value.length - 1
1203
+ },
1204
+ "w-[2px] h-full"
1205
+ ])
1206
+ }, null, 2)
1207
+ ])
1208
+ ]),
1209
+ e("div", _r, [
1210
+ U(d, {
1211
+ variant: "outlined",
1212
+ class: "py-12 px-16"
1213
+ }, {
1214
+ default: de(() => [
1215
+ e("div", wr, [
1216
+ (g(!0), D(ne, null, pe(A.info, (I, ee) => (g(), D("div", {
1217
+ key: ee,
1218
+ class: "flex flex-col gap-4"
1219
+ }, [
1220
+ e("div", Rr, S(I == null ? void 0 : I.label), 1),
1221
+ e("div", Or, [
1222
+ (g(!0), D(ne, null, pe(I == null ? void 0 : I.values, (le, H) => (g(), D("div", {
1223
+ key: H,
1224
+ class: "fm-typo-en-body-lg-600"
1225
+ }, S(le), 1))), 128))
1226
+ ])
1227
+ ]))), 128))
1228
+ ])
1229
+ ]),
1230
+ _: 2
1231
+ }, 1024)
1232
+ ])
1233
+ ])
1234
+ ], 64))), 128))
1235
+ ])) : (g(), D("div", or, [
1236
+ U(_),
1237
+ e("div", null, [
1238
+ e("img", {
1239
+ src: i(st),
1240
+ alt: "List is empty"
1241
+ }, null, 8, lr)
1242
+ ]),
1243
+ e("div", ir, S(i(l)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
1244
+ e("div", cr, S(i(l)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
1245
+ U(_),
1246
+ U(_)
1247
+ ]))
1248
+ ])) : T("", !0)
1249
+ ])
1250
+ ];
1251
+ }),
1252
+ "side-sheet-footer": de(() => {
1253
+ var j, Q, se, M, ae, A, E, I, ee, le;
1254
+ return [
1255
+ e("div", Dr, [
1256
+ ((j = t.purchaseOrder) == null ? void 0 : j.status) === i(B).enum.DRAFT && h.value === i(ie).PURCHASE ? (g(), W(w, {
1257
+ key: 0,
1258
+ label: i(l)("inventory.transfer.receiveRequest.actions.confirmDraft"),
1259
+ onClick: a[1] || (a[1] = (H) => G("confirmDraft")),
1260
+ loading: f.value === "confirmDraft",
1261
+ disabled: f.value !== "confirmDraft" && m.value
1262
+ }, null, 8, ["label", "loading", "disabled"])) : T("", !0),
1263
+ ((Q = t.purchaseOrder) == null ? void 0 : Q.status) === i(B).enum.DRAFT && h.value === i(ie).TRANSFER ? (g(), W(w, {
1264
+ key: 1,
1265
+ label: i(l)("inventory.transfer.receiveRequest.actions.submitRequest"),
1266
+ onClick: a[2] || (a[2] = (H) => G("submitRequest")),
1267
+ loading: f.value === "submitRequest",
1268
+ disabled: f.value !== "submitRequest" && m.value
1269
+ }, null, 8, ["label", "loading", "disabled"])) : T("", !0),
1270
+ ((se = t.purchaseOrder) == null ? void 0 : se.status) === i(B).enum.DRAFT ? (g(), W(w, {
1271
+ key: 2,
1272
+ label: i(l)("inventory.transfer.receiveRequest.actions.cancelDraft"),
1273
+ onClick: a[3] || (a[3] = (H) => G("cancelDraft")),
1274
+ loading: f.value === "cancelDraft",
1275
+ disabled: f.value !== "cancelDraft" && m.value,
1276
+ variant: "destructive"
1277
+ }, null, 8, ["label", "loading", "disabled"])) : T("", !0),
1278
+ ((M = t.purchaseOrder) == null ? void 0 : M.status) === i(B).enum.RECEIVING ? (g(), W(w, {
1279
+ key: 3,
1280
+ label: i(l)("inventory.transfer.receiveRequest.actions.completeReceive"),
1281
+ onClick: a[4] || (a[4] = (H) => G("completeReceive")),
1282
+ loading: f.value === "completeReceive",
1283
+ disabled: f.value !== "completeReceive" && m.value
1284
+ }, null, 8, ["label", "loading", "disabled"])) : T("", !0),
1285
+ t.canResubmit ? (g(), W(w, {
1286
+ key: 4,
1287
+ label: i(l)("inventory.transfer.receiveRequest.actions.resubmitRequest"),
1288
+ onClick: a[5] || (a[5] = (H) => G("submitRequest")),
1289
+ loading: f.value === "submitRequest",
1290
+ disabled: f.value !== "submitRequest" && m.value
1291
+ }, null, 8, ["label", "loading", "disabled"])) : T("", !0),
1292
+ (((ae = t.purchaseOrder) == null ? void 0 : ae.status) === i(B).enum.REQUESTING || ((A = t.purchaseOrder) == null ? void 0 : A.status) === i(B).enum.PROCESSING) && t.canApprove ? (g(), W(w, {
1293
+ key: 5,
1294
+ label: i(l)("inventory.transfer.approval.actions.approveRequest"),
1295
+ onClick: a[6] || (a[6] = (H) => G("approveRequest")),
1296
+ loading: f.value === "approveRequest",
1297
+ disabled: f.value !== "approveRequest" && m.value
1298
+ }, null, 8, ["label", "loading", "disabled"])) : T("", !0),
1299
+ ((E = t.purchaseOrder) == null ? void 0 : E.status) === i(B).enum.REQUESTING && t.canApprove ? (g(), W(w, {
1300
+ key: 6,
1301
+ label: i(l)("inventory.transfer.approval.actions.rejectRequest"),
1302
+ onClick: a[7] || (a[7] = (H) => G("rejectRequest")),
1303
+ loading: f.value === "rejectRequest",
1304
+ disabled: f.value !== "rejectRequest" && m.value,
1305
+ variant: "destructive"
1306
+ }, null, 8, ["label", "loading", "disabled"])) : T("", !0),
1307
+ ((I = t.purchaseOrder) == null ? void 0 : I.status) !== i(B).enum.COMPLETE && ((ee = t.purchaseOrder) == null ? void 0 : ee.status) !== i(B).enum.CANCEL && (((le = t.purchaseOrder) == null ? void 0 : le.status) !== i(B).enum.REQUESTING || t.canApprove) ? (g(), W(w, {
1308
+ key: 7,
1309
+ label: i(l)("common.close"),
1310
+ variant: "tertiary",
1311
+ onClick: a[8] || (a[8] = (H) => r("update:show", !1))
1312
+ }, null, 8, ["label"])) : T("", !0)
1313
+ ])
1314
+ ];
1315
+ }),
1316
+ _: 1
1317
+ }, 8, ["header", "modelValue", "dismiss-away"]);
1318
+ };
1319
+ }
1320
+ });
1321
+ export {
1322
+ Ir as _,
1323
+ $r as a,
1324
+ Er as b,
1325
+ at as g,
1326
+ Ve as u
1327
+ };