@feedmepos/mf-inventory-portal 1.2.43-dev.1 → 1.2.43-dev.2

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 (68) hide show
  1. package/dist/{App-CAgJY4dD.js → App-BbyuDs4s.js} +3 -3
  2. package/dist/{ApprovalView-BF3HSGaD.js → ApprovalView-Cz_p_Lsw.js} +5 -5
  3. package/dist/{BindingsDialog-CoBshq0t.js → BindingsDialog-CdzxKfim.js} +2 -2
  4. package/dist/{BindingsPicker-DnKrqVAT.js → BindingsPicker-DjcQepRu.js} +2 -2
  5. package/dist/{BindingsTable-DMk5JeAn.js → BindingsTable-iiKRFs5i.js} +3 -3
  6. package/dist/{ClosingDraftView-DK-ca0Xl.js → ClosingDraftView-D-uXfKco.js} +8 -8
  7. package/dist/{ClosingHistoryView-BfFaW6bf.js → ClosingHistoryView-BfdrQu-A.js} +3 -3
  8. package/dist/{ClosingTemplateView-DG_6F5E8.js → ClosingTemplateView-LwppyZ5b.js} +14 -14
  9. package/dist/{DeliveryOrderPrintPreview-BWDvd1ag.js → DeliveryOrderPrintPreview-WK5TSktz.js} +1 -1
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DcFwCFyP.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-E9wucZOG.js} +4 -4
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CFYeEn9v.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DoxdSsGn.js} +2 -2
  12. package/dist/{FmMultiselectDialog-D-m0TQj0.js → FmMultiselectDialog-BgIQ2r8r.js} +2 -2
  13. package/dist/{FmMultiselectDialog-B6Z6M9IQ.js → FmMultiselectDialog-DvUYz6Ul.js} +1 -1
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DuCYX-18.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CaDJCKdQ.js} +3 -3
  15. package/dist/{ImportView-DNXBYLFV.js → ImportView-CKJIAruz.js} +6 -6
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DZNR-Pef.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DQpWXkc7.js} +1 -1
  17. package/dist/{IngredientGroupView-DKWv1Jpd.js → IngredientGroupView-6VHopHiE.js} +5 -5
  18. package/dist/{IngredientsView-D8f8pCHt.js → IngredientsView-B7UkNty2.js} +14 -14
  19. package/dist/{IntegrationView-B7mGFBoB.js → IntegrationView-CkZ7OjrL.js} +12 -12
  20. package/dist/{InventoryBindingForm-BylPK5mH.js → InventoryBindingForm-Dz6CZw0B.js} +1 -1
  21. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BMGQnFz_.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-BFnuXwP7.js} +4 -4
  22. package/dist/{InventoryBindingSummary-BifiHtYe.js → InventoryBindingSummary-1xTRivY0.js} +1 -1
  23. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BAdPjuiA.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-d4gbhGU-.js} +1 -1
  24. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BpeoDa8l.js → PremiumBadge.vue_vue_type_script_setup_true_lang-B7lTpDiy.js} +2 -2
  25. package/dist/{PublishView-B7O-oC0H.js → PublishView-DRmrmmp2.js} +3 -3
  26. package/dist/{PurchaseOrderPrintPreview-DYfFLzJu.js → PurchaseOrderPrintPreview--zKqcQn3.js} +1 -1
  27. package/dist/{ReceiveRequestView-B4pckmgF.js → ReceiveRequestView-BJBMP8Ar.js} +18 -18
  28. package/dist/{RecipeView-Z1QnjjtC.js → RecipeView-n9sgnYOt.js} +8 -8
  29. package/dist/{StockView--lx2D3cm.js → StockView-liy9NHzK.js} +15 -15
  30. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CZCnQiqp.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-92RCScC2.js} +1 -1
  31. package/dist/{SupplierView-yEnEtF7t.js → SupplierView-Bx1uOxMB.js} +11 -11
  32. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-D-Gt-Hb6.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-BPevvNvn.js} +2 -2
  33. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-C-oHw0RA.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-COwkY-i-.js} +1 -1
  34. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-C4yvTr1c.js +3242 -0
  35. package/dist/{TransferTemplateView-CdjysUdG.js → TransferTemplateView-NPyHN1G4.js} +15 -15
  36. package/dist/{UnitView-BddDvjxm.js → UnitView-BvcR_hw8.js} +6 -6
  37. package/dist/{WarehouseView-BEd47z6V.js → WarehouseView-Db3uvU-3.js} +5 -5
  38. package/dist/{WastageTemplateView-BM19BQjQ.js → WastageTemplateView-HpRjMvfN.js} +14 -14
  39. package/dist/{app-CV2GElsU.js → app-CfvY1AOd.js} +7 -7
  40. package/dist/app.js +1 -1
  41. package/dist/{closing-template-D1-rEABr.js → closing-template-Bbpuo75y.js} +1 -1
  42. package/dist/{date2-DHObOZSx.js → date2-D1gn7jmq.js} +1 -1
  43. package/dist/{dayjs.min-hFGqpphZ.js → dayjs.min-DbsvCLS8.js} +1 -1
  44. package/dist/{decimal-Ik7I41Av.js → decimal-BCDuHTBo.js} +2 -2
  45. package/dist/{defineDeepModel-XxAlsuvf.js → defineDeepModel-CLGS2klM.js} +1 -1
  46. package/dist/{duplicate-template-Dd-njUw4.js → duplicate-template-CXMGnpJz.js} +1 -1
  47. package/dist/{feature-NcfF-luw.js → feature-ChCO3yeg.js} +2 -2
  48. package/dist/{format-time-from-id-Fhlr5Zp9.js → format-time-from-id-xSDapR5o.js} +1 -1
  49. package/dist/{format-unit-display--Mdnpxl5.js → format-unit-display-Cp6WprtD.js} +10 -10
  50. package/dist/{import-export.helper-DvEDTGaS.js → import-export.helper-5P37g041.js} +5 -5
  51. package/dist/{index-BxeDalqQ.js → index-DK-p2yA1.js} +1 -1
  52. package/dist/{index-fABV-n4o.js → index-DMJDBclT.js} +1 -1
  53. package/dist/{index-DfZoJT7b.js → index-JqiUbL75.js} +3 -3
  54. package/dist/{lodash-C6q4A2jZ.js → lodash-BVHTOpPM.js} +1 -1
  55. package/dist/{netsuite-BcBmwB-j.js → netsuite-o-fSOtMC.js} +3 -3
  56. package/dist/{purchase-order-template-pXv3xFwL.js → purchase-order-template-Rrk1HDqX.js} +1 -1
  57. package/dist/{rules-BjxNWV5M.js → rules-DogleRGn.js} +3 -3
  58. package/dist/{stock-DuQzAoHX.js → stock-CT6I1Xuk.js} +1 -1
  59. package/dist/{stock-BXV7w3b9.js → stock-phn4lZeu.js} +3 -3
  60. package/dist/{supplier-olgzbXw1.js → supplier-kX-AFjUa.js} +2 -2
  61. package/dist/{use-ingredient-select-dialog-vpRBfIbI.js → use-ingredient-select-dialog-DrEOPCUZ.js} +2 -2
  62. package/dist/{use-inventory-binding-dialog-qiBfoPVe.js → use-inventory-binding-dialog-B0dwowy5.js} +2 -2
  63. package/dist/{use-template-enabled-locations-2-5neDI-gZ.js → use-template-enabled-locations-2-BY2uc5aF.js} +2 -2
  64. package/dist/{vue-i18n-DsLZ5ft1.js → vue-i18n-S4lpudXL.js} +2 -2
  65. package/dist/{xlsx-DIvoeYqQ.js → xlsx-Doxq0pFC.js} +1 -1
  66. package/dist/{xlsx.util-CLAdPnR2.js → xlsx.util-CUdXfcyP.js} +1 -1
  67. package/package.json +1 -1
  68. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-2XdNXq9k.js +0 -3247
@@ -0,0 +1,3242 @@
1
+ import { p as $t, f as We } from "./format-time-from-id-xSDapR5o.js";
2
+ import { ref as J, computed as Q, h as L, defineComponent as $e, reactive as Ct, onMounted as yt, resolveComponent as H, openBlock as i, createBlock as re, withCtx as Z, createElementVNode as e, createVNode as D, unref as v, createElementBlock as _, toDisplayString as y, createCommentVNode as U, Fragment as ue, renderList as xe, createTextVNode as ke, normalizeClass as Me, watch as Rt, isRef as kt, resolveDynamicComponent as Dt } from "vue";
3
+ import { c as mt } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-cfFHDIwQ.js";
4
+ import { R as ye, D as Se } from "./row-action.enum-BcW_L_nE.js";
5
+ import { o as At, u as De, V as M, W as Ze, L as te, D as Nt, c as vt, v as it, X as ht, t as Ge, I as Ce, A as Qe, s as Ie, B as Te } from "./app-CfvY1AOd.js";
6
+ import { l as bt, d as gt, a as he, t as Ye, e as Ke } from "./rules-DogleRGn.js";
7
+ import { F as Ft } from "./decimal-BCDuHTBo.js";
8
+ import { t as Tt, c as It, h as _t, a as He } from "./date2-D1gn7jmq.js";
9
+ import { u as Ue, F as Pt, a as st } from "./feature-ChCO3yeg.js";
10
+ import { useCoreStore as ct, useI18n as ut } from "@feedmepos/mf-common";
11
+ import { u as et, a as dt, S as we } from "./netsuite-o-fSOtMC.js";
12
+ import { useDialog as tt, useSnackbar as Be, components as Je, FmButtonVariant as be, useProxiedModel as qt } from "@feedmepos/ui-library";
13
+ import { F as Pe } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js";
14
+ import { E as Vt } from "./empty-placeholder-wf6-BWE8.js";
15
+ import { u as Et, a as Lt, f as Mt } from "./format-unit-display-Cp6WprtD.js";
16
+ import { u as je, _ as Ut } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-BPevvNvn.js";
17
+ import { _ as Bt, a as jt, b as zt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-CaDJCKdQ.js";
18
+ import { u as Kt, R as pt } from "./usePromise-CbVUCxhj.js";
19
+ import { c as Gt } from "./index-JqiUbL75.js";
20
+ import { i as Ht } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DoxdSsGn.js";
21
+ import { F as ft } from "./form-mode.enum-BKiNVH6A.js";
22
+ import { d as St } from "./defineDeepModel-CLGS2klM.js";
23
+ import { u as Wt } from "./vue-i18n-S4lpudXL.js";
24
+ const Qt = At((C, a) => {
25
+ const o = De();
26
+ return {
27
+ async getShipments({
28
+ start: f,
29
+ end: h
30
+ }) {
31
+ const n = o.currentLocationDBName, g = `${C.inventoryBackendUrl}/${n}/shipments`;
32
+ return await a.get(`${g}?start=${f}&end=${h}`);
33
+ },
34
+ async getShipmentsByIds(f) {
35
+ if (f.length === 0)
36
+ return [];
37
+ const h = o.currentLocationDBName, n = `${C.inventoryBackendUrl}/${h}/shipments/get`;
38
+ return await a.post(n, { shipmentIds: f });
39
+ }
40
+ };
41
+ }), xt = {
42
+ [M.enum.confirmDraft]: {
43
+ primaryActions: {
44
+ text: "Confirm draft",
45
+ close: !0
46
+ },
47
+ title: "Confirm draft?",
48
+ message: "Purchase order cannot be changed after confirm draft.",
49
+ successMessage: "Purchase order draft has been confirmed"
50
+ },
51
+ [M.enum.cancelDraft]: {
52
+ primaryActions: {
53
+ text: "Cancel draft",
54
+ close: !0,
55
+ variant: "destructive"
56
+ },
57
+ title: "Cancel draft?",
58
+ message: "Purchase order cannot be changed after cancelled draft.",
59
+ successMessage: "Purchase order draft has been cancelled"
60
+ },
61
+ [M.enum.submitRequest]: {
62
+ primaryActions: {
63
+ text: "Submit request",
64
+ close: !0
65
+ },
66
+ title: "Confirm draft?",
67
+ message: "Purchase order cannot be changed after confirm draft.",
68
+ successMessage: "Purchase order draft has been submitted"
69
+ },
70
+ [M.enum.completeReceive]: {
71
+ primaryActions: {
72
+ text: "Mark received",
73
+ close: !0
74
+ },
75
+ title: "Mark as received",
76
+ message: "Purchase order cannot be changed after it has complete receiving.",
77
+ successMessage: "Purchase order has been marked as received"
78
+ },
79
+ [M.enum.approveRequest]: {
80
+ primaryActions: {
81
+ text: "Accept request",
82
+ close: !0
83
+ },
84
+ title: "Accept request?",
85
+ message: "Transfer out request will be accepted.",
86
+ successMessage: "Transfer out request has been approved"
87
+ },
88
+ [M.enum.rejectRequest]: {
89
+ primaryActions: {
90
+ text: "Reject request",
91
+ close: !0,
92
+ variant: "destructive"
93
+ },
94
+ title: "Reject request?",
95
+ message: "Purchase order will be rejected.",
96
+ successMessage: "Purchase order has been rejected"
97
+ },
98
+ [M.enum.processRequest]: {
99
+ primaryActions: {
100
+ text: "Process request",
101
+ close: !0,
102
+ variant: "destructive"
103
+ },
104
+ title: "Process request?",
105
+ message: "Purchase order will be processed.",
106
+ successMessage: "Purchase order has been processed"
107
+ }
108
+ };
109
+ function Xe(C) {
110
+ return Ze.generatedPOReceivedMap({
111
+ purchaseOrder: C
112
+ });
113
+ }
114
+ function Yt(C) {
115
+ return Ze.validatePOItemReceivedStatus({
116
+ dto: C
117
+ });
118
+ }
119
+ function nt(C) {
120
+ return Ze.validatePOReceivedStatus({
121
+ receivedMap: C
122
+ });
123
+ }
124
+ function at(C, a, o) {
125
+ if (!te.safeParse(C).success)
126
+ throw new Error(`Invalid purchase order status: ${C}`);
127
+ const f = te.parse(C);
128
+ return Ze.orderStatusCombination({
129
+ status: f,
130
+ isPOPartialReceive: a,
131
+ isPOOverReceive: o
132
+ });
133
+ }
134
+ function Ot() {
135
+ const C = De(), a = je(), o = Ue();
136
+ async function f(n, g) {
137
+ const s = C.currentLocationDBName;
138
+ return n.doc.supplier.internal && n.operation === M.enum.confirmDraft && (n.operation = M.enum.submitRequest), await a.processPurchaseOrder(n, g || s);
139
+ }
140
+ async function h(n, g) {
141
+ const s = C.currentLocationDBName;
142
+ return await a.processPurchaseOrderV2(n, g || s);
143
+ }
144
+ return (n) => o.useOperatePurchaseOrderV2 ? h(n.operateV2, n.transferTo) : f(n.operate, n.transferTo);
145
+ }
146
+ var lt = /* @__PURE__ */ ((C) => (C.RECEIVE_REQUEST = "receive/request", C.APPROVAL = "approval", C))(lt || {});
147
+ const ze = J(), rt = J();
148
+ function Qn(C, a) {
149
+ const o = tt(), f = De(), h = Ue();
150
+ et();
151
+ const n = Et(), g = Lt(), s = J(!1), c = Be(), O = je(), w = Qt(), d = J(new Array()), T = J(new Array()), S = J(
152
+ a != null && a.startDate && (a != null && a.endDate) ? a : Ht()
153
+ ), A = Q(() => {
154
+ const B = new Date(S.value.startDate), q = new Date(S.value.endDate);
155
+ return {
156
+ start: Tt(B).toISOString(),
157
+ end: It(q).toISOString()
158
+ };
159
+ }), l = J(new Array()), t = Nt(), b = J(null);
160
+ async function u(B) {
161
+ function q(k) {
162
+ const x = {
163
+ mode: ft.CREATE,
164
+ modelValue: B || void 0,
165
+ show: !0,
166
+ "onUpdate:show"(N) {
167
+ ze.value.show = N;
168
+ },
169
+ templateId: k,
170
+ lastClosingDate: b.value
171
+ };
172
+ ze.value = x;
173
+ }
174
+ let oe;
175
+ h.mustUsePoTemplate && !(B != null && B.template) ? o.open({
176
+ title: "Create transfer",
177
+ message: "",
178
+ primaryActions: {
179
+ text: "Select a template",
180
+ close: !0
181
+ },
182
+ secondaryActions: {
183
+ text: "Outlet to Outlet",
184
+ variant: "secondary",
185
+ close: !0
186
+ }
187
+ }).onPrimary(async () => {
188
+ oe = await n.getTemplateId(), oe && q(oe);
189
+ }).onSecondary(() => {
190
+ q(void 0);
191
+ }) : q(oe);
192
+ }
193
+ function $(B) {
194
+ const q = {
195
+ mode: ft.UPDATE,
196
+ modelValue: vt(B),
197
+ show: !0,
198
+ "onUpdate:show"(oe) {
199
+ ze.value.show = oe;
200
+ },
201
+ lastClosingDate: b.value
202
+ };
203
+ ze.value = q;
204
+ }
205
+ async function I() {
206
+ d.value = [], T.value = [], s.value = !0;
207
+ try {
208
+ const B = await O.getPurchaseOrders(A.value);
209
+ d.value = B.sort((W, ie) => ie._id.localeCompare(W._id));
210
+ const q = B.flatMap((W) => W.shipmentIds || []).filter(Boolean), oe = q.length > 0 ? await w.getShipmentsByIds(q) : [];
211
+ T.value = oe;
212
+ const k = await t.readCurrentLocationLastClosing(!0), x = k == null ? void 0 : k._id;
213
+ x && (b.value = $t(x)), await h.awaitFeatureLoaded(() => h.mustUsePoTemplate) && await g.fetchTemplates();
214
+ const N = d.value.map((W) => {
215
+ var ie;
216
+ return ((ie = W.request) == null ? void 0 : ie.id) ?? "";
217
+ }).filter((W) => W);
218
+ l.value = await O.readRequestByIds(N);
219
+ } catch {
220
+ c.open({
221
+ title: "Something went wrong",
222
+ message: "Error at fetching purchase orders",
223
+ type: "error"
224
+ });
225
+ } finally {
226
+ s.value = !1;
227
+ }
228
+ }
229
+ async function z() {
230
+ l.value = [], s.value = !0;
231
+ try {
232
+ l.value = await O.readRequests(
233
+ void 0,
234
+ A.value.start,
235
+ A.value.end
236
+ ).then((B) => B.reverse());
237
+ } catch {
238
+ c.open({
239
+ title: "Something went wrong",
240
+ message: "Error at fetching purchase requests",
241
+ type: "error"
242
+ });
243
+ } finally {
244
+ s.value = !1;
245
+ }
246
+ }
247
+ function R() {
248
+ switch (C) {
249
+ case "receive/request":
250
+ return I();
251
+ case "approval":
252
+ return z();
253
+ }
254
+ }
255
+ function Y(B, q) {
256
+ S.value = {
257
+ startDate: B,
258
+ endDate: q
259
+ }, R();
260
+ }
261
+ f.watchLocation(async (B) => {
262
+ if (!B) {
263
+ d.value = [];
264
+ return;
265
+ }
266
+ await R();
267
+ });
268
+ const K = J(), se = J(Math.random().toString());
269
+ async function ge(B, q) {
270
+ const oe = Math.random().toString();
271
+ se.value = oe, q ?? (q = l.value.computeFirst(
272
+ (W) => W.purchaseOrderId === B._id ? W : null
273
+ ) ?? void 0);
274
+ const k = C === "receive/request" ? f.currentLocation : q == null ? void 0 : q.to, x = C === "approval", N = {
275
+ poRequest: q,
276
+ purchaseOrder: {
277
+ ...B,
278
+ status: x && (q != null && q.rejectedAt) ? te.Enum.REJECT : B.status
279
+ },
280
+ transferTo: k == null ? void 0 : k.name,
281
+ transferToDbName: k == null ? void 0 : k.dbName,
282
+ show: !0,
283
+ canResubmit: !1,
284
+ canApprove: x,
285
+ "onUpdate:show"(W) {
286
+ K.value.show = W;
287
+ },
288
+ scope: C,
289
+ receivedMap: Xe(B) ?? {},
290
+ shipments: T.value
291
+ };
292
+ K.value = N;
293
+ }
294
+ async function de(B, q, oe, k) {
295
+ const x = Ot();
296
+ s.value = !0;
297
+ try {
298
+ await x({
299
+ operate: {
300
+ operation: q,
301
+ doc: B,
302
+ options: (
303
+ // auto receive for supplier to warehouse
304
+ (q === M.enum.confirmDraft || // auto receive for warehouse to warehouse
305
+ q === M.enum.completeReceive) && h.autoReceiveWarehouse ? {
306
+ autoReceive: !0
307
+ } : void 0
308
+ )
309
+ },
310
+ operateV2: {
311
+ _id: B._id,
312
+ _rev: B._rev ?? "",
313
+ action: q,
314
+ payloads: []
315
+ },
316
+ transferTo: k
317
+ }), await new Promise((ie) => setTimeout(ie, 1e3));
318
+ const W = De().currentLocationDBName.startsWith("restaurant_");
319
+ q === M.enum.confirmDraft && B.effectiveAt && W ? c.open({
320
+ title: "Success",
321
+ message: `${oe}. The backdate will be reflected once your POS has received this change.`,
322
+ type: "success"
323
+ }) : c.open({
324
+ title: "Success",
325
+ message: oe,
326
+ type: "success"
327
+ });
328
+ } catch (N) {
329
+ c.open({
330
+ title: "Something went wrong",
331
+ message: "Please try again.",
332
+ type: "error"
333
+ }), console.error("Error when submitting PO operation", q, B, N);
334
+ } finally {
335
+ s.value = !1, R();
336
+ }
337
+ }
338
+ async function qe(B, q, oe) {
339
+ const k = xt[q];
340
+ if (!k) {
341
+ c.open({
342
+ title: "Something went wrong",
343
+ message: `Cannot process order: ${it(q)}`,
344
+ type: "error"
345
+ });
346
+ return;
347
+ }
348
+ const { successMessage: x, ...N } = k;
349
+ o.open({
350
+ title: N.title,
351
+ message: N.message,
352
+ primaryActions: N.primaryActions
353
+ }).onPrimary(() => {
354
+ de(B, q, x, oe);
355
+ });
356
+ }
357
+ async function Ve() {
358
+ o.open({
359
+ title: "Upload Transfer",
360
+ primaryActions: {
361
+ text: "Xilnex transfer note",
362
+ close: !0
363
+ },
364
+ secondaryActions: {
365
+ text: "Cancel",
366
+ close: !0
367
+ }
368
+ }).onPrimary(() => {
369
+ const B = {
370
+ show: !0,
371
+ "onUpdate:show"(q) {
372
+ rt.value.show = q;
373
+ }
374
+ };
375
+ rt.value = B;
376
+ });
377
+ }
378
+ return {
379
+ purchaseOrders: d,
380
+ shipments: T,
381
+ purchaseRequests: l,
382
+ updateDateRange: Y,
383
+ fetchData: R,
384
+ loading: s,
385
+ transferDialogProps: ze,
386
+ promptCreateTransferDialog: u,
387
+ promptUpdateTransferDialog: $,
388
+ transferDetailsProps: K,
389
+ promptShowTransferDetails: ge,
390
+ submitAction: qe,
391
+ xilnexImportDialogProps: rt,
392
+ promptUploadTransferDialog: Ve
393
+ };
394
+ }
395
+ function Jt(C, a) {
396
+ return a.reduce(
397
+ (f, h) => {
398
+ const n = h.received.find((g) => g.sku._id === C._id);
399
+ return n && (f = bt(f, n.amount)), f;
400
+ },
401
+ Ft.toPrecision(gt(0), C.unit.precision)
402
+ );
403
+ }
404
+ function Xt(C) {
405
+ const { po: a, currentLocation: o, business: f, fulfilling: h, por: n } = C, { name: g, address: s, regNo: c, legalName: O } = o.doc.profile, w = {
406
+ name: g,
407
+ legalName: O,
408
+ registrationNumber: c,
409
+ line1: s == null ? void 0 : s.line1,
410
+ line2: s == null ? void 0 : s.line2,
411
+ postcode: s == null ? void 0 : s.postcode,
412
+ city: s == null ? void 0 : s.city,
413
+ state: s == null ? void 0 : s.state,
414
+ country: s == null ? void 0 : s.country
415
+ }, d = {
416
+ name: a.supplier.name,
417
+ phoneNumber: a.supplier.phoneNumber,
418
+ registrationNumber: a.supplier.registrationNumber,
419
+ line1: a.supplier.address.line1,
420
+ line2: a.supplier.address.line2,
421
+ postcode: a.supplier.address.postcode,
422
+ city: a.supplier.address.city,
423
+ state: a.supplier.address.state,
424
+ country: a.supplier.address.country
425
+ }, T = a.items.map((I) => {
426
+ const { sku: z, measurement: R } = I, Y = he(
427
+ Jt(I.sku, a.deliveryOrder || []),
428
+ !1
429
+ );
430
+ return {
431
+ code: z.code,
432
+ description: z.name,
433
+ quantity: he(I.quantity, !1),
434
+ unit: (R == null ? void 0 : R.abbrev) || z.unit.abbrev,
435
+ received: Y,
436
+ cost: I.totalCost ? `${I.totalCost.currency} ${Pt.toFormatString({
437
+ value: I.totalCost
438
+ })}` : void 0
439
+ };
440
+ }), S = a.deliveryOrder.map((I) => ({
441
+ createdAt: _t(new Date(I.createdAt)),
442
+ ref: I.deliveryOrderNumber,
443
+ remark: I.remark || "",
444
+ items: I.received.map((z) => {
445
+ var R;
446
+ return {
447
+ code: z.sku.code,
448
+ description: z.sku.name,
449
+ quantity: he(z.amount),
450
+ unit: ((R = z.measurement) == null ? void 0 : R.abbrev) || z.sku.unit.abbrev
451
+ };
452
+ })
453
+ })), A = [
454
+ // Production
455
+ "67ca5d2c80bd0e001c5bf5bc",
456
+ // Dev
457
+ "6880b36a3054c5001db19218"
458
+ ];
459
+ let l = "Inventory Receive Note";
460
+ if (a.supplier.internal ? (l = "Inventory Transfer Note", A.includes((f == null ? void 0 : f._id) || "") && (l = "Stock Request")) : l = "Purchase Order", n) {
461
+ const I = n.from.dbName;
462
+ o.dbName === I || (l = "Inventory Receive Note");
463
+ }
464
+ const b = {
465
+ title: l,
466
+ businessName: f == null ? void 0 : f.name,
467
+ logo: f == null ? void 0 : f.thumbnail,
468
+ orderNumber: a.seqNumber.toString(),
469
+ createdAt: We(a._id),
470
+ ref: a.ref || "",
471
+ remark: a.remark || "",
472
+ buyer: w,
473
+ supplier: d,
474
+ items: T,
475
+ status: a.status,
476
+ deliveryOrders: S
477
+ }, u = new URL(window.location.href), $ = h && (a.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
478
+ u.pathname = u.hostname.includes("portal.feedme") ? `/inventory/${$}` : `/${$}`, u.searchParams.append("data", JSON.stringify(b)), window.open(u.href, "_blank", "noreferrer");
479
+ }
480
+ const Le = {
481
+ submitRequest: {
482
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
483
+ color: "text-fm-color-typo-primary",
484
+ value: M.enum.submitRequest
485
+ },
486
+ confirmDraft: {
487
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
488
+ color: "text-fm-color-typo-primary",
489
+ value: M.enum.confirmDraft
490
+ },
491
+ cancelDraft: {
492
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
493
+ color: "text-fm-color-typo-error",
494
+ value: M.enum.cancelDraft
495
+ },
496
+ approveRequest: {
497
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
498
+ color: "text-fm-color-typo-primary",
499
+ value: M.enum.approveRequest
500
+ },
501
+ rejectRequest: {
502
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
503
+ color: "text-fm-color-typo-error",
504
+ value: M.enum.rejectRequest
505
+ },
506
+ processRequest: {
507
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
508
+ color: "text-fm-color-typo-primary",
509
+ value: M.enum.processRequest
510
+ },
511
+ receiveStock: {
512
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
513
+ color: "text-fm-color-typo-primary",
514
+ value: M.enum.receiveStock
515
+ },
516
+ completeReceive: {
517
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
518
+ color: "text-fm-color-typo-primary",
519
+ value: M.enum.completeReceive
520
+ },
521
+ closeRequest: {
522
+ translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
523
+ color: "system-error-300",
524
+ value: M.enum.closeRequest
525
+ },
526
+ approveDraft: {
527
+ translationKey: "",
528
+ color: "",
529
+ value: void 0
530
+ },
531
+ rejectDraft: {
532
+ translationKey: "",
533
+ color: "",
534
+ value: void 0
535
+ },
536
+ returnStock: {
537
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
538
+ color: "text-fm-color-typo-primary",
539
+ value: M.enum.returnStock
540
+ }
541
+ };
542
+ function Yn(C, a, o) {
543
+ const f = De(), h = et(), n = ct(), { t: g } = ut();
544
+ function s(S) {
545
+ switch (S.status) {
546
+ case "DRAFT":
547
+ return [
548
+ Se[ye.Update],
549
+ Se[ye.Details],
550
+ S.supplier.internal === "restaurant" || S.supplier.internal === "warehouse" ? Le[M.enum.submitRequest] : Le[M.enum.confirmDraft],
551
+ Le[M.enum.cancelDraft]
552
+ ];
553
+ case "RECEIVING":
554
+ return [
555
+ Le[M.enum.completeReceive],
556
+ Se[ye.Details],
557
+ Se[ye.Print]
558
+ ];
559
+ case "REQUESTING":
560
+ return C === "receive/request" ? [Se[ye.Details], Se[ye.Print]] : [
561
+ Le[M.enum.approveRequest],
562
+ Le[M.enum.rejectRequest],
563
+ Se[ye.Details]
564
+ // DefaultRowActions[RowActionEnum.Print]
565
+ ];
566
+ case "PROCESSING":
567
+ return [Se[ye.Details], Se[ye.Print]];
568
+ case "COMPLETE":
569
+ case "CANCEL":
570
+ default:
571
+ return [Se[ye.Details], Se[ye.Print]];
572
+ }
573
+ }
574
+ function c(S) {
575
+ return Object.values(M.enum).includes(S);
576
+ }
577
+ async function O(S, A, l) {
578
+ var b, u, $, I, z, R;
579
+ const t = vt(A);
580
+ if (S === ye.Print) {
581
+ const Y = (l == null ? void 0 : l.toInventoryLocation) ?? f.currentLocation;
582
+ if (Y.type === "restaurant") {
583
+ const K = f.locationRestaurantFromCore(Y.doc._id);
584
+ K !== null && (Y.doc = K);
585
+ }
586
+ ((b = l == null ? void 0 : l.netSuite) != null && b.refNo || (u = t.netSuite) != null && u.refNo) && (t.ref = [(($ = l == null ? void 0 : l.netSuite) == null ? void 0 : $.refNo) || ((I = t.netSuite) == null ? void 0 : I.refNo)].filter((K) => K).join(" ")), Xt({
587
+ po: t,
588
+ currentLocation: Y,
589
+ business: n.currentBusiness.value,
590
+ fulfilling: C === "approval",
591
+ por: l
592
+ });
593
+ return;
594
+ }
595
+ if (S === ye.Details) {
596
+ a.promptShowTransferDetails(t, l);
597
+ return;
598
+ }
599
+ if (S === ye.Update) {
600
+ (z = a.promptUpdateTransferDialog) == null || z.call(a, t);
601
+ return;
602
+ }
603
+ if (c(S)) {
604
+ a.submitAction(A, S, (R = l == null ? void 0 : l.to) == null ? void 0 : R.dbName);
605
+ return;
606
+ }
607
+ }
608
+ function w() {
609
+ var A;
610
+ const S = [
611
+ {
612
+ accessorKey: "seqNumber",
613
+ header: () => g("inventory.transfer.table.seqNo"),
614
+ enableSorting: !0,
615
+ size: 80,
616
+ sortUndefined: "last"
617
+ },
618
+ {
619
+ accessorKey: "_id",
620
+ header: () => g("inventory.transfer.table.createdAt"),
621
+ cell(l) {
622
+ return We(`${l.getValue()}`);
623
+ },
624
+ enableSorting: !0
625
+ },
626
+ {
627
+ accessorKey: "supplier.name",
628
+ header: () => g("inventory.transfer.table.transferFrom"),
629
+ enableSorting: !0,
630
+ size: 200
631
+ },
632
+ {
633
+ accessorKey: "items.length",
634
+ header: () => g("inventory.transfer.table.noOfItems"),
635
+ cell: (l) => {
636
+ const t = l.row.original.version || "1", b = l.getValue();
637
+ return L("div", { class: "flex items-center gap-2" }, [
638
+ b,
639
+ t !== "1" ? L(
640
+ "div",
641
+ { class: "py-3" },
642
+ L(
643
+ Pe,
644
+ L(
645
+ "div",
646
+ {
647
+ class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
648
+ },
649
+ `v${t}`
650
+ )
651
+ )
652
+ ) : null
653
+ ]);
654
+ },
655
+ enableSorting: !1,
656
+ meta: {
657
+ width: "10rem"
658
+ }
659
+ },
660
+ {
661
+ accessorKey: "ref",
662
+ header: () => g("inventory.transfer.table.reference"),
663
+ enableSorting: !1,
664
+ size: "auto"
665
+ },
666
+ ...(A = n.sessionUser.value) != null && A.role.isAdmin ? [
667
+ {
668
+ id: "statusForAdmin",
669
+ header: () => L(Pe, {}, () => `${g("inventory.transfer.table.status")}`),
670
+ cell(l) {
671
+ return l.row.original.status;
672
+ },
673
+ enableSorting: !0,
674
+ size: 200
675
+ }
676
+ ] : [],
677
+ {
678
+ accessorKey: "status",
679
+ header: () => g("inventory.transfer.table.status"),
680
+ cell(l) {
681
+ const t = l.getValue(), b = Xe(l.row.original), { partial: u, over: $ } = nt(b), I = at(t ?? "", u, $);
682
+ let z = g(`inventory.transfer.status.${I}`), R = `${t ?? ""}`.toLocaleLowerCase("en-us");
683
+ I === te.enum.CLOSE && (z = `${g(`inventory.transfer.status.${te.enum.COMPLETE}`)}`), I === "PARTIAL_RECEIVED" && R === te.enum.PROCESSING.toLocaleLowerCase("en-us") && (R = te.enum.RECEIVING.toLocaleLowerCase("en-us"));
684
+ let Y = null;
685
+ const K = o.value.find((se) => se.ref === l.row.original._id);
686
+ if (K != null && K.milestones && K.milestones.length > 0) {
687
+ const se = K.milestones[K.milestones.length - 1];
688
+ if (se.estimatedTime) {
689
+ const ge = new Date(se.estimatedTime), de = ge.getDate().toString().padStart(2, "0");
690
+ Y = `${ge.toLocaleString("en-US", { month: "short" })} ${de}`;
691
+ }
692
+ }
693
+ return L(
694
+ "div",
695
+ {
696
+ class: "flex"
697
+ },
698
+ [
699
+ L(
700
+ "div",
701
+ { class: "flex items-center" },
702
+ L(
703
+ "div",
704
+ {
705
+ class: [
706
+ "fm-status-badge",
707
+ `fm-status-badge-${R}`,
708
+ $ && "fm-status-badge-error"
709
+ ].filter(Boolean).join(" ")
710
+ },
711
+ `${z}`
712
+ )
713
+ ),
714
+ ...Y ? [
715
+ L(
716
+ "div",
717
+ {
718
+ class: "flex items-center gap-1 ml-2"
719
+ },
720
+ [
721
+ L(Je.FmIcon, {
722
+ name: "local_shipping",
723
+ size: "md",
724
+ color: "neutral-gray-400"
725
+ }),
726
+ L(
727
+ "span",
728
+ { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
729
+ Y
730
+ )
731
+ ]
732
+ )
733
+ ] : []
734
+ ]
735
+ );
736
+ },
737
+ enableSorting: !0,
738
+ size: 150
739
+ },
740
+ {
741
+ id: "action",
742
+ cell(l) {
743
+ const t = l.row.original, b = s(t);
744
+ return mt(b, (u) => O(u, t));
745
+ },
746
+ enableSorting: !1,
747
+ size: 40,
748
+ meta: {
749
+ cellClass: "",
750
+ headerClass: ""
751
+ }
752
+ }
753
+ ];
754
+ if (h.isEnabled) {
755
+ const l = [
756
+ {
757
+ id: "netsuiteTransferOrder",
758
+ accessorFn: (t) => {
759
+ var b;
760
+ return (b = t.netSuite) != null && b.id ? `${t.netSuite.refNo} (${t.netSuite.id})` : "N/A";
761
+ },
762
+ header: () => "NetSuite Order (ID)",
763
+ cell(t) {
764
+ var u;
765
+ const b = t.row.original;
766
+ return (u = b.netSuite) != null && u.id ? `${b.netSuite.refNo} (${b.netSuite.id})` : "N/A";
767
+ },
768
+ enableSorting: !1,
769
+ size: 200,
770
+ meta: {
771
+ cellClass: "",
772
+ headerClass: ""
773
+ }
774
+ },
775
+ {
776
+ id: "netsuiteTransactionNumber",
777
+ accessorFn: (t) => {
778
+ var b, u;
779
+ return ((u = (b = t.netSuite) == null ? void 0 : b.additionalInfo) == null ? void 0 : u.transactionnumber) ?? "N/A";
780
+ },
781
+ header: () => "NetSuite Transaction No.",
782
+ cell(t) {
783
+ var u, $;
784
+ return (($ = (u = t.row.original.netSuite) == null ? void 0 : u.additionalInfo) == null ? void 0 : $.transactionnumber) ?? "N/A";
785
+ },
786
+ enableSorting: !1,
787
+ size: 200,
788
+ meta: {
789
+ cellClass: "",
790
+ headerClass: ""
791
+ }
792
+ }
793
+ ];
794
+ S.splice(S.length - 1, 0, ...l);
795
+ }
796
+ return S;
797
+ }
798
+ function d() {
799
+ var A;
800
+ const S = [
801
+ {
802
+ accessorKey: "purchaseOrder.seqNumber",
803
+ header: () => g("inventory.transfer.table.seqNo"),
804
+ enableSorting: !0,
805
+ size: 80,
806
+ sortUndefined: "last"
807
+ },
808
+ {
809
+ accessorKey: "purchaseOrder._id",
810
+ header: () => g("inventory.transfer.table.createdAt"),
811
+ cell(l) {
812
+ return We(`${l.getValue()}`);
813
+ },
814
+ enableSorting: !0
815
+ },
816
+ {
817
+ accessorKey: "to.name",
818
+ header: () => g("inventory.transfer.table.transferTo"),
819
+ enableSorting: !1,
820
+ size: 200
821
+ },
822
+ {
823
+ accessorKey: "purchaseOrder.items.length",
824
+ header: () => g("inventory.transfer.table.noOfItems"),
825
+ enableSorting: !1
826
+ },
827
+ {
828
+ accessorKey: "purchaseOrder.ref",
829
+ header: () => g("inventory.transfer.table.reference"),
830
+ enableSorting: !1,
831
+ size: "auto"
832
+ },
833
+ ...(A = n.sessionUser.value) != null && A.role.isAdmin ? [
834
+ {
835
+ id: "statusForAdmin",
836
+ header: () => L(Pe, {}, () => `${g("inventory.transfer.table.status")}`),
837
+ cell(l) {
838
+ return l.row.original.status;
839
+ },
840
+ enableSorting: !0,
841
+ size: 200
842
+ }
843
+ ] : [],
844
+ {
845
+ accessorKey: "purchaseOrder.status",
846
+ header: () => g("inventory.transfer.table.status"),
847
+ cell(l) {
848
+ const t = l.row.original, b = l.getValue();
849
+ if (!t.purchaseOrder)
850
+ return L(Je.FmChip, {
851
+ label: "N/A",
852
+ compact: !0
853
+ });
854
+ const u = Xe(t.purchaseOrder), { partial: $, over: I } = nt(u), z = at(b ?? "", $, I);
855
+ let R = g(`inventory.transfer.status.${z}`), Y = `${b ?? ""}`.toLocaleLowerCase("en-us");
856
+ return z === te.enum.CLOSE && (R = `${g(`inventory.transfer.status.${te.enum.COMPLETE}`)}`), z === "PARTIAL_RECEIVED" && Y === te.enum.PROCESSING.toLocaleLowerCase("en-us") && (Y = te.enum.RECEIVING.toLocaleLowerCase("en-us")), t.rejectedAt && (R = g("inventory.transfer.status.REJECT"), Y = te.enum.REJECT.toLocaleLowerCase("en-us")), L(
857
+ "div",
858
+ {
859
+ class: "flex"
860
+ },
861
+ L(
862
+ "div",
863
+ {
864
+ class: [
865
+ "fm-status-badge",
866
+ `fm-status-badge-${Y}`,
867
+ I && "fm-status-badge-error"
868
+ ].filter(Boolean).join(" ")
869
+ },
870
+ `${R}`
871
+ )
872
+ );
873
+ },
874
+ enableSorting: !0
875
+ },
876
+ {
877
+ id: "action",
878
+ cell(l) {
879
+ const t = l.row.original, u = (t.purchaseOrder ? s(t.purchaseOrder) : []).map(($) => $.value === ye.Print ? {
880
+ ...$,
881
+ translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
882
+ } : $);
883
+ return mt(
884
+ u,
885
+ ($) => t.purchaseOrder ? O($, t.purchaseOrder, t) : void 0
886
+ );
887
+ },
888
+ enableSorting: !1,
889
+ size: 40,
890
+ meta: {
891
+ cellClass: "",
892
+ headerClass: ""
893
+ }
894
+ }
895
+ ];
896
+ if (h.isEnabled) {
897
+ const l = [
898
+ {
899
+ id: "netsuiteTransferOrder",
900
+ accessorFn: (t) => {
901
+ var b;
902
+ return (b = t.netSuite) != null && b.id ? `${t.netSuite.refNo} (${t.netSuite.id})` : "N/A";
903
+ },
904
+ header: () => "NetSuite Order (ID)",
905
+ cell(t) {
906
+ var u;
907
+ const b = t.row.original;
908
+ return (u = b.netSuite) != null && u.id ? `${b.netSuite.refNo} (${b.netSuite.id})` : "N/A";
909
+ },
910
+ enableSorting: !1,
911
+ size: 200,
912
+ meta: {
913
+ cellClass: "",
914
+ headerClass: ""
915
+ }
916
+ },
917
+ {
918
+ id: "netsuiteTransactionNumber",
919
+ accessorFn: (t) => {
920
+ var b, u;
921
+ return ((u = (b = t.netSuite) == null ? void 0 : b.additionalInfo) == null ? void 0 : u.transactionnumber) ?? "N/A";
922
+ },
923
+ header: () => "NetSuite Transaction No.",
924
+ cell(t) {
925
+ var u, $;
926
+ return (($ = (u = t.row.original.netSuite) == null ? void 0 : u.additionalInfo) == null ? void 0 : $.transactionnumber) ?? "N/A";
927
+ },
928
+ enableSorting: !1,
929
+ size: 200,
930
+ meta: {
931
+ cellClass: "",
932
+ headerClass: ""
933
+ }
934
+ }
935
+ ];
936
+ S.splice(S.length - 2, 0, ...l);
937
+ }
938
+ return S;
939
+ }
940
+ return {
941
+ columnDefs: Q(() => C === "receive/request" ? w() : d())
942
+ };
943
+ }
944
+ const Zt = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, es = { class: "flex flex-col gap-8" }, ts = { class: "flex w-full justify-end gap-16" }, ss = /* @__PURE__ */ $e({
945
+ __name: "FulfillmentForm",
946
+ props: {
947
+ purchaseOrder: {},
948
+ confirm: { type: Function }
949
+ },
950
+ emits: ["update:show"],
951
+ setup(C, { emit: a }) {
952
+ const o = C, f = Ct({
953
+ id: "",
954
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
955
+ items: []
956
+ }), h = J(), n = a;
957
+ yt(() => {
958
+ o.purchaseOrder && (f.items = o.purchaseOrder.items.map((s) => ({
959
+ id: s.id,
960
+ sku: s.sku,
961
+ measurement: s.measurement,
962
+ amount: s.quantity ?? { amount: 1, precision: 0 }
963
+ })));
964
+ });
965
+ const g = Q(() => f.items.length <= 10);
966
+ return (s, c) => {
967
+ const O = H("FmTable"), w = H("FmButton"), d = H("FmForm");
968
+ return i(), re(d, {
969
+ ref_key: "formRef",
970
+ ref: h,
971
+ class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
972
+ onValidationFailed: console.log,
973
+ onValidationSuccess: c[1] || (c[1] = () => o.confirm(f))
974
+ }, {
975
+ default: Z(() => [
976
+ c[2] || (c[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
977
+ e("div", Zt, [
978
+ e("div", es, [
979
+ D(O, {
980
+ "column-defs": [
981
+ {
982
+ header: "Code",
983
+ cell: (T) => {
984
+ const S = o.purchaseOrder.items.find((A) => A.id === T.row.original.id || A.sku._id === T.row.original.sku._id);
985
+ return L(
986
+ v(Je).FmTooltip,
987
+ {
988
+ content: S.code,
989
+ placement: "top",
990
+ variant: "plain",
991
+ zIndex: 50
992
+ },
993
+ L(
994
+ "span",
995
+ {
996
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
997
+ },
998
+ S.code
999
+ )
1000
+ );
1001
+ }
1002
+ },
1003
+ {
1004
+ header: "Name",
1005
+ cell: (T) => {
1006
+ const S = o.purchaseOrder.items.find((A) => A.id === T.row.original.id || A.sku._id === T.row.original.sku._id);
1007
+ return L(
1008
+ v(Je).FmTooltip,
1009
+ {
1010
+ content: S.name,
1011
+ placement: "top",
1012
+ variant: "plain",
1013
+ zIndex: 50
1014
+ },
1015
+ L(
1016
+ "span",
1017
+ {
1018
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
1019
+ },
1020
+ S.name
1021
+ )
1022
+ );
1023
+ }
1024
+ },
1025
+ {
1026
+ header: "Amount",
1027
+ cell: (T) => {
1028
+ const S = T.row.original, A = o.purchaseOrder.items.find((t) => t.id === S.id || t.sku._id === S.sku._id), l = S.amount ?? {
1029
+ amount: 1,
1030
+ precision: 0
1031
+ };
1032
+ return L(Bt, {
1033
+ style: {
1034
+ flex: "1 1 0%"
1035
+ },
1036
+ modelValue: {
1037
+ amount: l,
1038
+ measurement: S.measurement ?? null
1039
+ },
1040
+ key: S.id ?? S.sku._id,
1041
+ unit: S.sku.unit,
1042
+ "onUpdate:modelValue": (t) => {
1043
+ if (!t) return;
1044
+ const b = f.items.find((u) => u.id === S.id || u.sku._id === S.sku._id);
1045
+ b && (b.amount = t.amount);
1046
+ },
1047
+ disableUnit: !0,
1048
+ rules: [
1049
+ v(jt)(
1050
+ +v(he)({ amount: 0, precision: 0 })
1051
+ ),
1052
+ v(zt)(+v(he)(A.quantity))
1053
+ ],
1054
+ applyDefaultRules: !0
1055
+ });
1056
+ }
1057
+ }
1058
+ ],
1059
+ "row-data": f.items,
1060
+ "hide-footer": g.value
1061
+ }, null, 8, ["column-defs", "row-data", "hide-footer"])
1062
+ ])
1063
+ ]),
1064
+ e("div", ts, [
1065
+ D(w, {
1066
+ class: "px-16",
1067
+ label: "Confirm",
1068
+ size: "md",
1069
+ variant: "primary",
1070
+ type: "submit"
1071
+ }),
1072
+ D(w, {
1073
+ class: "px-16",
1074
+ label: "Cancel",
1075
+ size: "md",
1076
+ variant: "secondary",
1077
+ onClick: c[0] || (c[0] = () => n("update:show", !1))
1078
+ })
1079
+ ])
1080
+ ]),
1081
+ _: 1
1082
+ }, 8, ["onValidationFailed"]);
1083
+ };
1084
+ }
1085
+ }), ot = {
1086
+ submitRequest: {
1087
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1088
+ color: "primary",
1089
+ buttonVariant: be.Primary
1090
+ },
1091
+ confirmDraft: {
1092
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1093
+ color: "primary",
1094
+ buttonVariant: be.Primary
1095
+ },
1096
+ cancelDraft: {
1097
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1098
+ color: "system-error-300",
1099
+ buttonVariant: be.Destructive
1100
+ },
1101
+ approveDraft: {
1102
+ translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1103
+ color: "primary",
1104
+ buttonVariant: be.Primary
1105
+ },
1106
+ rejectDraft: {
1107
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1108
+ color: "system-error-300",
1109
+ buttonVariant: be.Destructive
1110
+ },
1111
+ approveRequest: {
1112
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1113
+ color: "primary",
1114
+ buttonVariant: be.Primary
1115
+ },
1116
+ processRequest: {
1117
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1118
+ color: "primary",
1119
+ buttonVariant: be.Primary
1120
+ },
1121
+ receiveStock: {
1122
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1123
+ color: "primary",
1124
+ buttonVariant: be.Primary,
1125
+ available: !1
1126
+ },
1127
+ completeReceive: {
1128
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1129
+ color: "primary",
1130
+ buttonVariant: be.Plain
1131
+ },
1132
+ rejectRequest: {
1133
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1134
+ color: "system-error-300",
1135
+ buttonVariant: be.Destructive
1136
+ },
1137
+ closeRequest: {
1138
+ translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1139
+ color: "system-error-300",
1140
+ buttonVariant: be.Destructive,
1141
+ available: !1
1142
+ },
1143
+ returnStock: {
1144
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1145
+ color: "primary",
1146
+ buttonVariant: be.Primary,
1147
+ available: !1
1148
+ }
1149
+ };
1150
+ function rs() {
1151
+ const C = Ue();
1152
+ return {
1153
+ ableToMarkReceived(a) {
1154
+ if (!a || a.status !== te.enum.RECEIVING || C.useOperatePurchaseOrderV2) return !1;
1155
+ const f = De().currentLocationDBName;
1156
+ return `${a.supplier.internal}_${a.supplier._id}` !== f;
1157
+ },
1158
+ ableToMarkApproved(a) {
1159
+ return !(!a || (a == null ? void 0 : a.status) !== te.enum.REQUESTING);
1160
+ },
1161
+ ableToCreateFulfillment(a, o) {
1162
+ var n, g;
1163
+ if (!C.acceptRequireFulfillment || !a || !o || a.status !== te.enum.PROCESSING || !o.processedAt)
1164
+ return !1;
1165
+ const f = (n = o == null ? void 0 : o.from) == null ? void 0 : n.dbName, h = (g = o == null ? void 0 : o.to) == null ? void 0 : g.dbName;
1166
+ return !(f.startsWith("restaurant_") && h.startsWith("restaurant_"));
1167
+ }
1168
+ };
1169
+ }
1170
+ const os = { class: "flex flex-row-reverse" }, ns = /* @__PURE__ */ $e({
1171
+ __name: "NetSuiteSync",
1172
+ props: {
1173
+ poRequest: {},
1174
+ purchaseOrder: {},
1175
+ isTransferBetweenOutlets: { type: Boolean },
1176
+ scope: {}
1177
+ },
1178
+ setup(C) {
1179
+ const a = C, o = et(), f = Be(), h = tt(), n = J(!1);
1180
+ Q(() => {
1181
+ var w, d, T, S;
1182
+ let s = !0;
1183
+ o.isEnabled || (s = !1);
1184
+ const c = a.purchaseOrder, O = a.poRequest;
1185
+ return c && ((w = c == null ? void 0 : c.supplier) != null && w.internal ? (!O && c.status == te.enum.DRAFT && (s = !1), O && !((d = O == null ? void 0 : O.netSuite) != null && d.id) && (s = !1), a.isTransferBetweenOutlets && (s = !1)) : ((c == null ? void 0 : c.status) !== te.enum.REQUESTING && c.supplier.internal && (s = !1), !O && !((T = c == null ? void 0 : c.netSuite) != null && T.id) && (s = !1), !O && ((S = c == null ? void 0 : c.netSuite) != null && S.id) && (c == null ? void 0 : c.status) == te.enum.REQUESTING && (s = !1))), s;
1186
+ });
1187
+ async function g() {
1188
+ n.value || h.open({
1189
+ title: "Sync with NetSuite",
1190
+ contentComponent: L("div", [
1191
+ L("p", "Are you sure you want to sync now?"),
1192
+ L("br"),
1193
+ L(
1194
+ "p",
1195
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1196
+ "Please wait a moment before syncing manually to avoid unnecessary actions."
1197
+ )
1198
+ ]),
1199
+ primaryActions: {
1200
+ text: "Sync",
1201
+ close: !0,
1202
+ variant: "destructive"
1203
+ },
1204
+ secondaryActions: { text: "Not now", close: !0 }
1205
+ }).onPrimary(async () => {
1206
+ var s, c, O;
1207
+ try {
1208
+ n.value = !0;
1209
+ const w = ((s = a.purchaseOrder) == null ? void 0 : s._id) || ((c = a.poRequest) == null ? void 0 : c.purchaseOrderId) || "", d = (O = a.poRequest) == null ? void 0 : O.to.dbName;
1210
+ await o.syncPurchaseOrder(
1211
+ w,
1212
+ a.scope === "approval" ? d : void 0
1213
+ ), f.open({
1214
+ title: "Sync with NetSuite",
1215
+ message: "Requested to sync with NetSuite. Please wait a moment.",
1216
+ type: "success"
1217
+ }), await new Promise((T) => setTimeout(T, 5e3)), n.value = !1;
1218
+ } catch {
1219
+ f.open({
1220
+ title: "Error",
1221
+ message: "Failed to sync with NetSuite",
1222
+ type: "error"
1223
+ }), n.value = !1;
1224
+ }
1225
+ });
1226
+ }
1227
+ return (s, c) => {
1228
+ const O = H("FmButton");
1229
+ return i(), _("div", os, [
1230
+ D(O, {
1231
+ "prepend-icon": "sync",
1232
+ variant: "secondary",
1233
+ label: "Sync",
1234
+ loading: n.value,
1235
+ onClick: g,
1236
+ "text-color": "primary",
1237
+ "bg-color": "transparent",
1238
+ "border-color": "primary"
1239
+ }, null, 8, ["loading"])
1240
+ ]);
1241
+ };
1242
+ }
1243
+ }), as = {
1244
+ key: 0,
1245
+ class: "flex flex-col gap-8"
1246
+ }, ls = { class: "flex flex-col gap-4" }, is = { class: "fm-typo-en-body-lg-600" }, cs = {
1247
+ key: 0,
1248
+ class: "flex flex-col gap-4"
1249
+ }, us = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ds = { class: "fm-typo-en-body-lg-600" }, ms = { key: 0 }, ps = { key: 1 }, fs = {
1250
+ key: 1,
1251
+ class: "flex flex-col gap-4"
1252
+ }, ys = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, vs = { class: "fm-typo-en-body-lg-600" }, hs = { key: 0 }, bs = { key: 1 }, gs = {
1253
+ key: 2,
1254
+ class: "flex flex-col gap-4"
1255
+ }, _s = { class: "fm-typo-en-body-lg-600" }, Ss = {
1256
+ key: 3,
1257
+ class: "flex flex-col gap-4"
1258
+ }, xs = { class: "fm-typo-en-body-lg-600" }, Os = /* @__PURE__ */ $e({
1259
+ __name: "NetSuiteInfo",
1260
+ props: {
1261
+ transferType: {},
1262
+ transferToDbName: {},
1263
+ poRequest: {},
1264
+ purchaseOrder: {},
1265
+ isTransferBetweenOutlets: { type: Boolean },
1266
+ scope: {}
1267
+ },
1268
+ setup(C) {
1269
+ const a = C, o = et(), f = je(), h = J(a.poRequest);
1270
+ yt(async () => {
1271
+ var c;
1272
+ if (!a.poRequest && ((c = a.purchaseOrder) != null && c._id)) {
1273
+ const O = await f.getLatestPurchaseOrderRequest(a.purchaseOrder._id);
1274
+ h.value = O;
1275
+ }
1276
+ });
1277
+ const n = Q(
1278
+ () => {
1279
+ var c, O, w, d, T, S;
1280
+ return o.getSubsidiaryFullName(
1281
+ ((w = (O = (c = a.purchaseOrder) == null ? void 0 : c.netSuite) == null ? void 0 : O.subsidiary) == null ? void 0 : w.id) || ((S = (T = (d = a.poRequest) == null ? void 0 : d.netSuite) == null ? void 0 : T.subsidiary) == null ? void 0 : S.id)
1282
+ ).fullName;
1283
+ }
1284
+ ), g = Q(() => {
1285
+ var c, O, w, d, T, S, A, l, t, b, u, $;
1286
+ return (w = (O = (c = a.purchaseOrder) == null ? void 0 : c.netSuite) == null ? void 0 : O.additionalInfo) != null && w.transactionnumber ? (S = (T = (d = a.purchaseOrder) == null ? void 0 : d.netSuite) == null ? void 0 : T.additionalInfo) == null ? void 0 : S.transactionnumber : (t = (l = (A = h.value) == null ? void 0 : A.netSuite) == null ? void 0 : l.additionalInfo) != null && t.transactionnumber ? ($ = (u = (b = h.value) == null ? void 0 : b.netSuite) == null ? void 0 : u.additionalInfo) == null ? void 0 : $.transactionnumber : null;
1287
+ }), s = Q(() => {
1288
+ var c, O, w, d, T, S;
1289
+ return (O = (c = a.purchaseOrder) == null ? void 0 : c.deliveryFullfillment) != null && O.length && ((d = (w = a.purchaseOrder) == null ? void 0 : w.deliveryFullfillment) == null ? void 0 : d.length) > 0 ? (S = (T = a.purchaseOrder) == null ? void 0 : T.deliveryFullfillment) == null ? void 0 : S.map((A) => {
1290
+ var l;
1291
+ return (l = A.netSuite) == null ? void 0 : l.refNo;
1292
+ }).join(", ") : "N/A";
1293
+ });
1294
+ return (c, O) => {
1295
+ var w, d, T, S, A, l, t, b, u, $, I, z, R, Y, K, se;
1296
+ return v(o).isEnabled ? (i(), _("div", as, [
1297
+ e("div", ls, [
1298
+ O[0] || (O[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1299
+ e("div", is, y(n.value || "N/A"), 1)
1300
+ ]),
1301
+ !c.isTransferBetweenOutlets && c.scope === v(lt).RECEIVE_REQUEST ? (i(), _("div", cs, [
1302
+ e("div", us, " NetSuite " + y((d = (w = c.purchaseOrder) == null ? void 0 : w.netSuite) != null && d.recordType ? v(ht)((S = (T = c.purchaseOrder) == null ? void 0 : T.netSuite) == null ? void 0 : S.recordType) : c.transferType === v(Ge).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1303
+ e("div", ds, [
1304
+ (l = (A = c.purchaseOrder) == null ? void 0 : A.netSuite) != null && l.id ? (i(), _("span", ms, y((b = (t = c.purchaseOrder) == null ? void 0 : t.netSuite) == null ? void 0 : b.refNo) + " (" + y(($ = (u = c.purchaseOrder) == null ? void 0 : u.netSuite) == null ? void 0 : $.id) + ") ", 1)) : (i(), _("span", ps, "N/A"))
1305
+ ])
1306
+ ])) : U("", !0),
1307
+ !c.isTransferBetweenOutlets && h.value || c.scope === v(lt).APPROVAL ? (i(), _("div", fs, [
1308
+ e("div", ys, " (Request) NetSuite " + y(c.transferType === v(Ge).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1309
+ e("div", vs, [
1310
+ (z = (I = h.value) == null ? void 0 : I.netSuite) != null && z.id ? (i(), _("span", hs, y((Y = (R = h.value) == null ? void 0 : R.netSuite) == null ? void 0 : Y.refNo) + " (" + y((se = (K = h.value) == null ? void 0 : K.netSuite) == null ? void 0 : se.id) + ") ", 1)) : (i(), _("span", bs, "N/A"))
1311
+ ])
1312
+ ])) : U("", !0),
1313
+ g.value ? (i(), _("div", gs, [
1314
+ O[1] || (O[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1315
+ e("div", _s, y(g.value), 1)
1316
+ ])) : U("", !0),
1317
+ v(o).isEnabled && c.transferType === v(Ge).enum.transfer && !c.isTransferBetweenOutlets ? (i(), _("div", Ss, [
1318
+ O[2] || (O[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1319
+ e("div", xs, y(s.value), 1)
1320
+ ])) : U("", !0)
1321
+ ])) : U("", !0);
1322
+ };
1323
+ }
1324
+ }), ws = { class: "flex flex-row-reverse" }, $s = /* @__PURE__ */ $e({
1325
+ __name: "NetSuiteLog",
1326
+ props: {
1327
+ netsuiteId: {},
1328
+ purchaseOrderId: {}
1329
+ },
1330
+ setup(C) {
1331
+ const a = Be(), o = dt();
1332
+ async function f(h, n) {
1333
+ const g = [];
1334
+ if (h && g.push(`body.message:*${h}*`), n) {
1335
+ const w = n.replace(/:/g, "\\:");
1336
+ g.push(`${w}`);
1337
+ }
1338
+ if (g.length === 0) {
1339
+ a.open({
1340
+ message: "Cannot open logs without valid filters.",
1341
+ type: "error"
1342
+ });
1343
+ return;
1344
+ }
1345
+ const c = `attributes.pod:netsuite* AND (${g.join(" OR ")})`, { url: O } = await o.getSyncLogs(c);
1346
+ a.open(
1347
+ {
1348
+ message: "Opening NetSuite logs...",
1349
+ type: "info"
1350
+ },
1351
+ 800
1352
+ ), await new Promise((w) => setTimeout(w, 800)), window.open(O, "_blank");
1353
+ }
1354
+ return (h, n) => {
1355
+ const g = H("FmButton");
1356
+ return i(), _("div", ws, [
1357
+ D(g, {
1358
+ "prepend-icon": "history",
1359
+ variant: "secondary",
1360
+ label: "Logs",
1361
+ onClick: n[0] || (n[0] = (s) => f(h.netsuiteId, h.purchaseOrderId)),
1362
+ "text-color": "primary",
1363
+ "bg-color": "transparent",
1364
+ "border-color": "primary"
1365
+ })
1366
+ ]);
1367
+ };
1368
+ }
1369
+ }), Cs = { class: "flex flex-row-reverse" }, Rs = { key: 0 }, ks = { key: 1 }, Ds = { class: "mb-6" }, As = { class: "fm-typo-en-body-md-400" }, Ns = { key: 0 }, Fs = { key: 1 }, Ts = {
1370
+ key: 0,
1371
+ class: "flex"
1372
+ }, Is = {
1373
+ key: 1,
1374
+ class: "border-t pt-6"
1375
+ }, Ps = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, qs = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Vs = { class: "w-full" }, Es = {
1376
+ class: "p-3 fm-typo-en-body-sm-600",
1377
+ style: { "min-width": "130px" }
1378
+ }, Ls = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ms = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Us = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Bs = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, js = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, zs = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ks = { class: "p-3 fm-typo-en-body-sm-600" }, Gs = { key: 2 }, Hs = { key: 1 }, Ws = /* @__PURE__ */ $e({
1379
+ __name: "NetSuiteLatestInfo",
1380
+ props: {
1381
+ netsuiteId: {},
1382
+ purchaseOrderId: {}
1383
+ },
1384
+ setup(C) {
1385
+ const a = C, o = dt(), f = J(!1), h = De(), n = J(!0), g = J(!1), s = J(!1), c = J(!1), O = J(null), w = J([]);
1386
+ async function d() {
1387
+ if (!O.value) {
1388
+ f.value = !0;
1389
+ try {
1390
+ n.value = !0;
1391
+ const l = await o.getMoreInfo(
1392
+ h.currentLocation.dbName,
1393
+ a.purchaseOrderId
1394
+ );
1395
+ O.value = l, g.value = !1;
1396
+ } catch {
1397
+ g.value = !0;
1398
+ } finally {
1399
+ n.value = !1;
1400
+ }
1401
+ await T();
1402
+ }
1403
+ }
1404
+ async function T() {
1405
+ if (!(w.value.length > 0))
1406
+ try {
1407
+ s.value = !0;
1408
+ const l = await o.getChangeLogs(a.netsuiteId);
1409
+ w.value = l, c.value = !1;
1410
+ } catch {
1411
+ c.value = !0;
1412
+ } finally {
1413
+ s.value = !1;
1414
+ }
1415
+ }
1416
+ function S(l) {
1417
+ switch (l) {
1418
+ case we.Create:
1419
+ return "text-green-600 bg-green-100";
1420
+ case we.Set:
1421
+ return "text-blue-600 bg-blue-100";
1422
+ case we.Change:
1423
+ return "text-yellow-600 bg-yellow-100";
1424
+ case we.Unset:
1425
+ return "text-red-600 bg-red-100";
1426
+ default:
1427
+ return "text-gray-600 bg-gray-100";
1428
+ }
1429
+ }
1430
+ function A(l) {
1431
+ return new Date(l).toLocaleDateString("en-US", {
1432
+ year: "numeric",
1433
+ month: "short",
1434
+ day: "numeric",
1435
+ hour: "2-digit",
1436
+ minute: "2-digit"
1437
+ });
1438
+ }
1439
+ return (l, t) => {
1440
+ const b = H("FmButton"), u = H("FmLabel"), $ = H("FmCircularProgress"), I = H("FmIcon"), z = H("FmDialog");
1441
+ return i(), _("div", Cs, [
1442
+ D(z, {
1443
+ modelValue: f.value,
1444
+ "onUpdate:modelValue": t[2] || (t[2] = (R) => f.value = R),
1445
+ overlay: !0,
1446
+ "max-width": 800
1447
+ }, {
1448
+ "dialog-button": Z(() => [
1449
+ D(b, {
1450
+ "prepend-icon": "info",
1451
+ variant: "secondary",
1452
+ label: "Latest Info",
1453
+ onClick: t[0] || (t[0] = (R) => d()),
1454
+ "text-color": "primary",
1455
+ "bg-color": "transparent",
1456
+ "border-color": "primary"
1457
+ })
1458
+ ]),
1459
+ "dialog-header": Z(() => t[3] || (t[3] = [
1460
+ e("div", null, "NetSuite latest info", -1)
1461
+ ])),
1462
+ default: Z(() => [
1463
+ n.value ? (i(), _("div", Rs, "Loading...")) : (i(), _("div", ks, [
1464
+ g.value ? (i(), _("p", Hs, "Something went wrong.")) : (i(), _(ue, { key: 0 }, [
1465
+ e("div", Ds, [
1466
+ t[4] || (t[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
1467
+ (i(!0), _(ue, null, xe(O.value, (R, Y) => (i(), _("div", {
1468
+ key: Y,
1469
+ class: "mb-2"
1470
+ }, [
1471
+ e("div", null, [
1472
+ D(u, {
1473
+ label: v(it)(Y)
1474
+ }, null, 8, ["label"]),
1475
+ e("div", As, [
1476
+ Array.isArray(R) ? (i(), _("span", Ns, y(R.length > 0 ? R.join(", ") : "N/A"), 1)) : (i(), _("span", Fs, y(R), 1))
1477
+ ])
1478
+ ])
1479
+ ]))), 128))
1480
+ ]),
1481
+ s.value ? (i(), _("div", Ts, [
1482
+ t[5] || (t[5] = e("span", null, "Change Log Loading...", -1)),
1483
+ D($, { size: "md" })
1484
+ ])) : U("", !0),
1485
+ !s.value && w.value.length > 0 ? (i(), _("div", Is, [
1486
+ e("h3", Ps, [
1487
+ D(I, {
1488
+ name: "error",
1489
+ color: "#ff9500",
1490
+ size: "sm"
1491
+ }),
1492
+ t[6] || (t[6] = ke(" Change Logs "))
1493
+ ]),
1494
+ e("div", qs, [
1495
+ e("table", Vs, [
1496
+ t[7] || (t[7] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
1497
+ e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
1498
+ e("th", {
1499
+ class: "text-left p-3 fm-typo-en-body-md-600",
1500
+ style: { "min-width": "130px" }
1501
+ }, " Date "),
1502
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
1503
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
1504
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
1505
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
1506
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
1507
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
1508
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
1509
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
1510
+ ])
1511
+ ], -1)),
1512
+ e("tbody", null, [
1513
+ (i(!0), _(ue, null, xe(w.value, (R, Y) => (i(), _("tr", {
1514
+ key: Y,
1515
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
1516
+ }, [
1517
+ e("td", Es, y(A(R._dateiso8601)), 1),
1518
+ e("td", Ls, y(R._rolename), 1),
1519
+ e("td", Ms, y(R._employeename), 1),
1520
+ e("td", Us, y(R._contextname), 1),
1521
+ e("td", {
1522
+ class: Me(`p-3 fm-typo-en-body-sm-600 ${S(Number(R.type) - 1)}`)
1523
+ }, y(v(we)[Number(R.type) - 1]), 3),
1524
+ e("td", Bs, y(R.lineid || ""), 1),
1525
+ e("td", js, y(R._fieldname), 1),
1526
+ e("td", zs, y(R.oldvalue || ""), 1),
1527
+ e("td", Ks, y(R.newvalue || ""), 1)
1528
+ ]))), 128))
1529
+ ])
1530
+ ])
1531
+ ])
1532
+ ])) : (i(), _("div", Gs, t[8] || (t[8] = [
1533
+ e("p", null, "No change logs available.", -1)
1534
+ ])))
1535
+ ], 64))
1536
+ ]))
1537
+ ]),
1538
+ "dialog-footer": Z(() => [
1539
+ D(b, {
1540
+ class: "ml-auto sm:w-full xs:w-full",
1541
+ label: "Close",
1542
+ size: "md",
1543
+ variant: "primary",
1544
+ onClick: t[1] || (t[1] = (R) => f.value = !1)
1545
+ })
1546
+ ]),
1547
+ _: 1
1548
+ }, 8, ["modelValue"])
1549
+ ]);
1550
+ };
1551
+ }
1552
+ }), Qs = {
1553
+ key: 0,
1554
+ class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
1555
+ }, Ys = { class: "flex gap-8 items-center" }, Js = { class: "ml-auto" }, Xs = { class: "flex gap-3" }, Zs = /* @__PURE__ */ $e({
1556
+ __name: "NetSuitePanel",
1557
+ props: {
1558
+ poRequest: {},
1559
+ purchaseOrder: {},
1560
+ transferType: {},
1561
+ transferToDbName: {},
1562
+ scope: {}
1563
+ },
1564
+ setup(C) {
1565
+ const a = C, o = Gt(), f = Q(() => o.isNetSuiteEnabled);
1566
+ return (h, n) => {
1567
+ var s, c;
1568
+ const g = H("FmMenuDivider");
1569
+ return f.value ? (i(), _("div", Qs, [
1570
+ e("div", Ys, [
1571
+ n[0] || (n[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1572
+ e("div", Js, [
1573
+ e("div", Xs, [
1574
+ (c = (s = a.purchaseOrder) == null ? void 0 : s.netSuite) != null && c.id ? (i(), re(Pe, { key: 0 }, {
1575
+ default: Z(() => {
1576
+ var O, w, d;
1577
+ return [
1578
+ D(Ws, {
1579
+ "netsuite-id": (w = (O = h.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : w.id,
1580
+ "purchase-order-id": (d = h.purchaseOrder) == null ? void 0 : d._id
1581
+ }, null, 8, ["netsuite-id", "purchase-order-id"])
1582
+ ];
1583
+ }),
1584
+ _: 1
1585
+ })) : U("", !0),
1586
+ D(Pe, null, {
1587
+ default: Z(() => {
1588
+ var O, w, d;
1589
+ return [
1590
+ D($s, {
1591
+ "netsuite-id": (w = (O = h.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : w.id,
1592
+ "purchase-order-id": (d = h.purchaseOrder) == null ? void 0 : d._id
1593
+ }, null, 8, ["netsuite-id", "purchase-order-id"])
1594
+ ];
1595
+ }),
1596
+ _: 1
1597
+ }),
1598
+ D(ns, {
1599
+ "po-request": h.poRequest,
1600
+ "purchase-order": h.purchaseOrder,
1601
+ "is-transfer-between-outlets": !f.value,
1602
+ scope: h.scope
1603
+ }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
1604
+ ])
1605
+ ])
1606
+ ]),
1607
+ D(g),
1608
+ D(Os, {
1609
+ "po-request": h.poRequest,
1610
+ "purchase-order": h.purchaseOrder,
1611
+ "transfer-type": h.transferType,
1612
+ "transfer-to-db-name": h.transferToDbName,
1613
+ "is-transfer-between-outlets": !f.value,
1614
+ scope: h.scope
1615
+ }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1616
+ ])) : U("", !0);
1617
+ };
1618
+ }
1619
+ }), er = { class: "flex flex-col gap-3" }, tr = { class: "flex flex-col gap-4" }, sr = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, rr = { class: "flex flex-col gap-4" }, or = { class: "flex justify-between items-center py-1 gap-4" }, nr = { class: "flex flex-col" }, ar = { class: "fm-typo-en-body-lg-600" }, lr = { class: "fm-typo-en-body-md-400" }, ir = { class: "flex flex-col gap-2 items-end" }, cr = { class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ur = {
1620
+ key: 0,
1621
+ class: "flex items-center gap-2"
1622
+ }, dr = {
1623
+ key: 0,
1624
+ class: "border-b border-fm-color-stroke-secondary"
1625
+ }, mr = { class: "flex flex-col gap-4" }, pr = { class: "flex flex-col gap-4" }, fr = { class: "flex flex-col gap-4" }, yr = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, vr = {
1626
+ key: 0,
1627
+ class: "flex flex-col gap-4"
1628
+ }, hr = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, br = /* @__PURE__ */ $e({
1629
+ __name: "EditForm",
1630
+ props: {
1631
+ purchaseOrder: {},
1632
+ deliveryOrder: {}
1633
+ },
1634
+ emits: ["submitted"],
1635
+ setup(C, { emit: a }) {
1636
+ Wt();
1637
+ const o = Ue(), f = Be(), h = J(!1), n = C, g = a, s = St("deliveryOrder"), c = je(), O = Q(
1638
+ () => {
1639
+ var b;
1640
+ return ((b = n.purchaseOrder.deliveryFullfillment) == null ? void 0 : b.findIndex(
1641
+ (u) => n.deliveryOrder.fullfillmentId && u.id === n.deliveryOrder.fullfillmentId
1642
+ )) ?? -1;
1643
+ }
1644
+ ), w = o.enablePurchaseOrderReceiveWithCustomCost, d = o.enablePortalDeliveryOrderWrite, T = J({}), S = Q(() => n.purchaseOrder.items.map((b, u) => Q({
1645
+ get: () => {
1646
+ var I;
1647
+ const $ = (I = s.received[u]) == null ? void 0 : I.cost;
1648
+ return $ ? +he($) : 0;
1649
+ },
1650
+ set: ($) => {
1651
+ s.received[u].cost = {
1652
+ currency: Ce(),
1653
+ ...Ye($, 4)
1654
+ };
1655
+ }
1656
+ }))), A = Q(() => n.deliveryOrder.received.map((b, u) => Q({
1657
+ get: () => {
1658
+ var I;
1659
+ const $ = (I = s.received[u]) == null ? void 0 : I.amount;
1660
+ return $ ? +he($) : 0;
1661
+ },
1662
+ set: ($) => {
1663
+ s.received[u].amount = Ye($, 2);
1664
+ }
1665
+ })));
1666
+ function l(b) {
1667
+ const u = !T.value[b];
1668
+ if (T.value[b] = u, u) {
1669
+ const $ = n.deliveryOrder.received[b];
1670
+ $.cost ? s.received[b].cost = {
1671
+ currency: $.cost.currency,
1672
+ amount: $.cost.amount,
1673
+ precision: $.cost.precision
1674
+ } : s.received[b].cost = {
1675
+ currency: Ce(),
1676
+ amount: 0,
1677
+ precision: 4
1678
+ };
1679
+ } else
1680
+ delete s.received[b].cost;
1681
+ }
1682
+ function t() {
1683
+ c.updateDeliveryOrder({
1684
+ deliveryOrder: {
1685
+ ...n.deliveryOrder,
1686
+ ...s
1687
+ },
1688
+ purchaseOrderId: n.purchaseOrder._id,
1689
+ purchaseOrderRev: n.purchaseOrder._rev
1690
+ }).then(() => {
1691
+ f.open(
1692
+ {
1693
+ title: "Success",
1694
+ message: `PO# ${n.purchaseOrder.seqNumber} Changes have been saved`,
1695
+ type: "success"
1696
+ },
1697
+ 1e4
1698
+ ), h.value = !1, g("submitted");
1699
+ });
1700
+ }
1701
+ return (b, u) => {
1702
+ const $ = H("FmButton"), I = H("FmStepperField"), z = H("FmSwitch"), R = H("FmTextField"), Y = H("FmDialog");
1703
+ return i(), re(Y, {
1704
+ modelValue: h.value,
1705
+ "onUpdate:modelValue": u[1] || (u[1] = (K) => h.value = K),
1706
+ overlay: !0
1707
+ }, {
1708
+ "dialog-button": Z(() => [
1709
+ v(d) ? (i(), re($, {
1710
+ key: 0,
1711
+ variant: "plain",
1712
+ label: "Edit",
1713
+ size: "md",
1714
+ "prepend-icon": "edit"
1715
+ })) : U("", !0)
1716
+ ]),
1717
+ "dialog-header": Z(() => [
1718
+ e("div", null, "Received on " + y(v(He)(n.deliveryOrder.createdAt)), 1)
1719
+ ]),
1720
+ "dialog-footer": Z(() => [
1721
+ D($, {
1722
+ class: "ml-auto",
1723
+ label: "Apply changes",
1724
+ size: "md",
1725
+ variant: "destructive",
1726
+ onClick: t
1727
+ })
1728
+ ]),
1729
+ default: Z(() => [
1730
+ e("div", null, [
1731
+ e("div", er, [
1732
+ e("div", tr, [
1733
+ u[2] || (u[2] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Adjustment date", -1)),
1734
+ e("div", sr, y(n.deliveryOrder.adjustment ? v(He)(new Date(v(Qe)(n.deliveryOrder.adjustment))) : "-"), 1)
1735
+ ]),
1736
+ e("div", rr, [
1737
+ u[4] || (u[4] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received items", -1)),
1738
+ (i(!0), _(ue, null, xe(n.deliveryOrder.received, (K, se) => {
1739
+ var ge;
1740
+ return i(), _("div", { key: se }, [
1741
+ e("div", or, [
1742
+ e("div", nr, [
1743
+ e("span", ar, y(K.sku.name), 1),
1744
+ e("span", lr, y(K.sku.code), 1)
1745
+ ]),
1746
+ e("div", ir, [
1747
+ D(I, {
1748
+ label: "Receive Quantity",
1749
+ modelValue: A.value[se].value,
1750
+ "onUpdate:modelValue": (de) => A.value[se].value = de,
1751
+ min: 0,
1752
+ "append-text": ((ge = K.measurement) == null ? void 0 : ge.abbrev) ?? K.sku.unit.abbrev
1753
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"]),
1754
+ e("div", cr, y(`${K.cost ? `${v(Ke)(K.cost)}` : ""}`), 1),
1755
+ v(w) ? (i(), _("div", ur, [
1756
+ D(z, {
1757
+ "model-value": T.value[se],
1758
+ "onUpdate:modelValue": (de) => l(se),
1759
+ size: "sm"
1760
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
1761
+ u[3] || (u[3] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
1762
+ ])) : U("", !0),
1763
+ v(w) && T.value[se] ? (i(), re(I, {
1764
+ key: 1,
1765
+ modelValue: S.value[se].value,
1766
+ "onUpdate:modelValue": (de) => S.value[se].value = de,
1767
+ label: "Total Cost",
1768
+ step: 1e-4,
1769
+ min: 0,
1770
+ placeholder: "0.0000",
1771
+ size: "sm",
1772
+ "append-text": v(Ce)()
1773
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : U("", !0)
1774
+ ])
1775
+ ]),
1776
+ se < n.purchaseOrder.items.length - 1 ? (i(), _("div", dr)) : U("", !0)
1777
+ ]);
1778
+ }), 128))
1779
+ ]),
1780
+ e("div", mr, [
1781
+ u[5] || (u[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
1782
+ e("div", pr, [
1783
+ D(R, {
1784
+ modelValue: v(s).deliveryOrderNumber,
1785
+ "onUpdate:modelValue": u[0] || (u[0] = (K) => v(s).deliveryOrderNumber = K),
1786
+ size: "md",
1787
+ placeholder: n.deliveryOrder.deliveryOrderNumber
1788
+ }, null, 8, ["modelValue", "placeholder"])
1789
+ ])
1790
+ ]),
1791
+ e("div", fr, [
1792
+ u[6] || (u[6] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
1793
+ e("div", yr, y(n.deliveryOrder.remark || "N/A"), 1)
1794
+ ]),
1795
+ O.value >= 0 ? (i(), _("div", vr, [
1796
+ u[7] || (u[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fulfilment's sequence ", -1)),
1797
+ e("div", hr, y(O.value + 1), 1)
1798
+ ])) : U("", !0)
1799
+ ])
1800
+ ])
1801
+ ]),
1802
+ _: 1
1803
+ }, 8, ["modelValue"]);
1804
+ };
1805
+ }
1806
+ }), gr = { class: "flex flex-col gap-3" }, _r = { class: "flex flex-col gap-4" }, Sr = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, xr = {
1807
+ key: 0,
1808
+ class: "flex flex-col gap-4"
1809
+ }, Or = { class: "flex items-center justify-between" }, wr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, $r = {
1810
+ key: 0,
1811
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1812
+ }, Cr = { class: "flex gap-4" }, Rr = { class: "flex-1" }, kr = { class: "flex-1" }, Dr = {
1813
+ key: 0,
1814
+ class: "flex items-center text-fm-color-system-error-300"
1815
+ }, Ar = { class: "fm-typo-en-body-md-400" }, Nr = { class: "flex flex-col gap-4" }, Fr = { class: "flex justify-between items-center py-1 gap-4" }, Tr = { class: "flex flex-col" }, Ir = { class: "fm-typo-en-body-lg-600" }, Pr = { class: "fm-typo-en-body-md-400" }, qr = { class: "flex flex-col gap-2 items-end" }, Vr = {
1816
+ key: 0,
1817
+ class: "flex items-center gap-2"
1818
+ }, Er = {
1819
+ key: 0,
1820
+ class: "border-b border-fm-color-stroke-secondary"
1821
+ }, Lr = { class: "flex flex-col gap-4" }, Mr = { class: "flex flex-col gap-4" }, Ur = { class: "flex flex-col gap-4" }, Br = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, jr = /* @__PURE__ */ $e({
1822
+ __name: "CreateForm",
1823
+ props: {
1824
+ purchaseOrder: {},
1825
+ receivedInfoMap: {}
1826
+ },
1827
+ emits: ["submitted"],
1828
+ setup(C, { emit: a }) {
1829
+ var B, q, oe;
1830
+ const { t: o } = ut(), f = J(!1), h = ct(), n = C, g = a, s = St("", {
1831
+ default: {
1832
+ deliveryOrderNumber: "",
1833
+ remark: "",
1834
+ received: n.purchaseOrder.items.map((k) => ({
1835
+ sku: k.sku,
1836
+ amount: Ie.fromNumber(0),
1837
+ measurement: k.measurement
1838
+ })),
1839
+ createdBy: {
1840
+ id: ((B = h.sessionUser.value) == null ? void 0 : B.id) || "",
1841
+ name: ((q = h.sessionUser.value) == null ? void 0 : q.displayName) || ""
1842
+ },
1843
+ createdAt: ""
1844
+ }
1845
+ }), c = je(), O = tt(), w = Ue(), d = ((oe = n.purchaseOrder) == null ? void 0 : oe.supplier.internal) != null, T = d && w.enablePOSTransferRequireFulfillment, S = w.enablePortalDeliveryOrderWrite && (n.purchaseOrder.status === te.Enum.RECEIVING || n.purchaseOrder.status === te.Enum.COMPLETE) && (d ? !T : !0), A = w.enablePurchaseOrderReceiveWithCustomCost, l = w.enableBackdateReceive, t = J({}), b = Be(), u = Q({
1846
+ get() {
1847
+ if (!s.createdAt) return "";
1848
+ const k = new Date(s.createdAt), x = k.getFullYear(), N = String(k.getMonth() + 1).padStart(2, "0"), W = String(k.getDate()).padStart(2, "0");
1849
+ return `${x}-${N}-${W}`;
1850
+ },
1851
+ set(k) {
1852
+ if (k) {
1853
+ const x = s.createdAt ? new Date(s.createdAt) : /* @__PURE__ */ new Date(), [N, W, ie] = k.split("-");
1854
+ x.setFullYear(parseInt(N)), x.setMonth(parseInt(W) - 1), x.setDate(parseInt(ie)), s.createdAt = x.toISOString();
1855
+ }
1856
+ }
1857
+ }), $ = Q({
1858
+ get() {
1859
+ if (!s.createdAt) return "";
1860
+ const k = new Date(s.createdAt), x = String(k.getHours()).padStart(2, "0"), N = String(k.getMinutes()).padStart(2, "0");
1861
+ return `${x}:${N}`;
1862
+ },
1863
+ set(k) {
1864
+ if (k) {
1865
+ const x = s.createdAt ? new Date(s.createdAt) : /* @__PURE__ */ new Date(), [N, W] = k.split(":");
1866
+ x.setHours(parseInt(N)), x.setMinutes(parseInt(W)), s.createdAt = x.toISOString();
1867
+ }
1868
+ }
1869
+ }), I = Q(() => {
1870
+ const k = Qe(n.purchaseOrder._id);
1871
+ if (!k) return "";
1872
+ const x = new Date(k), N = x.getFullYear(), W = String(x.getMonth() + 1).padStart(2, "0"), ie = String(x.getDate()).padStart(2, "0");
1873
+ return `${N}-${W}-${ie}`;
1874
+ }), z = Q(() => {
1875
+ const k = Qe(n.purchaseOrder._id);
1876
+ return k ? new Date(k) : null;
1877
+ }), R = Q(() => {
1878
+ if (!u.value || !$.value || !z.value) return null;
1879
+ if (/* @__PURE__ */ new Date(`${u.value}T${$.value}:00`) < z.value) {
1880
+ const x = I.value, N = z.value.getHours(), W = z.value.getMinutes(), ie = N >= 12 ? "PM" : "AM", r = N % 12 || 12, m = `${String(r).padStart(2, "0")}:${String(W).padStart(2, "0")} ${ie}`;
1881
+ return `Delivery date & time cannot be earlier than order creation (${x} ${m})`;
1882
+ }
1883
+ return null;
1884
+ }), Y = Q(() => R.value ? !1 : s.received.some((x) => {
1885
+ const N = x.amount;
1886
+ return N ? +he(N) > 0 : !1;
1887
+ }));
1888
+ function K() {
1889
+ s.createdAt = "";
1890
+ }
1891
+ const se = Q(() => n.purchaseOrder.items.map((k, x) => Q({
1892
+ get: () => {
1893
+ var W;
1894
+ const N = (W = s.received[x]) == null ? void 0 : W.amount;
1895
+ return N ? +he(N) : 0;
1896
+ },
1897
+ set: (N) => {
1898
+ s.received[x].amount = Ye(N, 2);
1899
+ }
1900
+ })));
1901
+ function ge(k) {
1902
+ const x = !t.value[k];
1903
+ if (t.value[k] = x, x) {
1904
+ const N = n.purchaseOrder.items[k];
1905
+ N.totalCost ? s.received[k].cost = {
1906
+ currency: N.totalCost.currency,
1907
+ amount: N.totalCost.amount,
1908
+ precision: 4
1909
+ // Standardize to 4 decimals
1910
+ } : s.received[k].cost = {
1911
+ currency: Ce(),
1912
+ amount: 0,
1913
+ precision: 4
1914
+ };
1915
+ } else
1916
+ delete s.received[k].cost;
1917
+ }
1918
+ const de = Q(() => n.purchaseOrder.items.map((k, x) => Q({
1919
+ get: () => {
1920
+ var W;
1921
+ const N = (W = s.received[x]) == null ? void 0 : W.cost;
1922
+ return N ? +he(N) : 0;
1923
+ },
1924
+ set: (N) => {
1925
+ s.received[x].cost = {
1926
+ currency: Ce(),
1927
+ ...Ye(N, 4)
1928
+ };
1929
+ }
1930
+ })));
1931
+ function qe() {
1932
+ O.open({
1933
+ title: "Confirm Create Delivery Order",
1934
+ message: `Are you sure you want to create delivery order for PO# ${n.purchaseOrder.seqNumber}?`,
1935
+ primaryActions: {
1936
+ text: "Create",
1937
+ close: !0,
1938
+ variant: "primary"
1939
+ },
1940
+ secondaryActions: {
1941
+ text: "Cancel",
1942
+ close: !0
1943
+ }
1944
+ }).onPrimary(() => Ve());
1945
+ }
1946
+ function Ve() {
1947
+ c.createDeliveryOrder({
1948
+ deliveryOrder: s,
1949
+ purchaseOrderId: n.purchaseOrder._id,
1950
+ purchaseOrderRev: n.purchaseOrder._rev,
1951
+ currency: Ce()
1952
+ }).then(() => {
1953
+ b.open(
1954
+ {
1955
+ title: "Success",
1956
+ message: `New delivery order created for PO# ${n.purchaseOrder.seqNumber}`,
1957
+ type: "success"
1958
+ },
1959
+ 1e4
1960
+ ), f.value = !1, g("submitted");
1961
+ });
1962
+ }
1963
+ return (k, x) => {
1964
+ const N = H("FmButton"), W = H("FmDatePicker"), ie = H("FmTimePicker"), r = H("FmIcon"), m = H("FmStepperField"), V = H("FmSwitch"), E = H("FmTextField"), G = H("FmDialog");
1965
+ return i(), re(G, {
1966
+ modelValue: f.value,
1967
+ "onUpdate:modelValue": x[4] || (x[4] = (F) => f.value = F),
1968
+ overlay: !0,
1969
+ "min-width": 800
1970
+ }, {
1971
+ "dialog-button": Z(() => [
1972
+ v(S) ? (i(), re(N, {
1973
+ key: 0,
1974
+ variant: "primary",
1975
+ label: "Create",
1976
+ size: "md",
1977
+ "prepend-icon": "add",
1978
+ class: "w-full"
1979
+ })) : U("", !0)
1980
+ ]),
1981
+ "dialog-header": Z(() => [
1982
+ e("div", null, "Order #" + y(n.purchaseOrder.seqNumber) + " (New Delivery Order)", 1)
1983
+ ]),
1984
+ "dialog-footer": Z(() => [
1985
+ D(N, {
1986
+ class: "ml-auto",
1987
+ label: "Create",
1988
+ size: "md",
1989
+ variant: "destructive",
1990
+ disabled: !Y.value,
1991
+ onClick: qe
1992
+ }, null, 8, ["disabled"])
1993
+ ]),
1994
+ default: Z(() => {
1995
+ var F;
1996
+ return [
1997
+ e("div", gr, [
1998
+ e("div", _r, [
1999
+ x[5] || (x[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
2000
+ e("div", Sr, y((F = v(h).sessionUser.value) == null ? void 0 : F.displayName), 1)
2001
+ ]),
2002
+ v(l) ? (i(), _("div", xr, [
2003
+ e("div", Or, [
2004
+ e("div", wr, [
2005
+ x[6] || (x[6] = ke(" Delivery Date & Time ")),
2006
+ !u.value && !$.value ? (i(), _("div", $r, " Leave blank to use current date & time ")) : U("", !0)
2007
+ ]),
2008
+ u.value || $.value ? (i(), re(N, {
2009
+ key: 0,
2010
+ variant: "tertiary",
2011
+ label: "Clear",
2012
+ "prepend-icon": "close",
2013
+ onClick: K
2014
+ })) : U("", !0)
2015
+ ]),
2016
+ e("div", Cr, [
2017
+ e("div", Rr, [
2018
+ D(W, {
2019
+ modelValue: u.value,
2020
+ "onUpdate:modelValue": x[0] || (x[0] = (j) => u.value = j)
2021
+ }, null, 8, ["modelValue"])
2022
+ ]),
2023
+ e("div", kr, [
2024
+ D(ie, {
2025
+ modelValue: $.value,
2026
+ "onUpdate:modelValue": x[1] || (x[1] = (j) => $.value = j)
2027
+ }, null, 8, ["modelValue"])
2028
+ ])
2029
+ ]),
2030
+ R.value ? (i(), _("div", Dr, [
2031
+ D(r, {
2032
+ name: "error",
2033
+ class: "inline-block mr-1",
2034
+ size: "sm"
2035
+ }),
2036
+ e("div", Ar, y(R.value), 1)
2037
+ ])) : U("", !0)
2038
+ ])) : U("", !0),
2039
+ e("div", Nr, [
2040
+ x[8] || (x[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
2041
+ (i(!0), _(ue, null, xe(n.purchaseOrder.items, (j, p) => {
2042
+ var X, ae, ne;
2043
+ return i(), _("div", { key: p }, [
2044
+ e("div", Fr, [
2045
+ e("div", Tr, [
2046
+ e("span", Ir, y(j.sku.name), 1),
2047
+ e("span", Pr, y(j.sku.code), 1)
2048
+ ]),
2049
+ e("div", qr, [
2050
+ D(m, {
2051
+ label: "Receive Quantity",
2052
+ modelValue: se.value[p].value,
2053
+ "onUpdate:modelValue": (P) => se.value[p].value = P,
2054
+ "helper-text": `${v(o)("inventory.transfer.receiveRequest.details.received")} ${v(Ie).toFormatString(
2055
+ {
2056
+ value: (X = k.receivedInfoMap[j.sku._id]) == null ? void 0 : X.received
2057
+ }
2058
+ )} ${((ae = j.measurement) == null ? void 0 : ae.abbrev) ?? j.sku.unit.abbrev}`,
2059
+ min: 0,
2060
+ "append-text": ((ne = j.measurement) == null ? void 0 : ne.abbrev) ?? j.sku.unit.abbrev
2061
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "helper-text", "append-text"]),
2062
+ v(A) ? (i(), _("div", Vr, [
2063
+ D(V, {
2064
+ "model-value": t.value[p],
2065
+ "onUpdate:modelValue": (P) => ge(p),
2066
+ size: "sm"
2067
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2068
+ x[7] || (x[7] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2069
+ ])) : U("", !0),
2070
+ v(A) && t.value[p] ? (i(), re(m, {
2071
+ key: 1,
2072
+ modelValue: de.value[p].value,
2073
+ "onUpdate:modelValue": (P) => de.value[p].value = P,
2074
+ label: "Total Cost",
2075
+ step: 1e-4,
2076
+ min: 0,
2077
+ placeholder: "0.0000",
2078
+ size: "sm",
2079
+ "append-text": v(Ce)()
2080
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : U("", !0)
2081
+ ])
2082
+ ]),
2083
+ p < n.purchaseOrder.items.length - 1 ? (i(), _("div", Er)) : U("", !0)
2084
+ ]);
2085
+ }), 128))
2086
+ ]),
2087
+ e("div", Lr, [
2088
+ x[9] || (x[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2089
+ e("div", Mr, [
2090
+ D(E, {
2091
+ modelValue: v(s).deliveryOrderNumber,
2092
+ "onUpdate:modelValue": x[2] || (x[2] = (j) => v(s).deliveryOrderNumber = j),
2093
+ size: "md"
2094
+ }, null, 8, ["modelValue"])
2095
+ ])
2096
+ ]),
2097
+ e("div", Ur, [
2098
+ x[10] || (x[10] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2099
+ e("div", Br, [
2100
+ D(E, {
2101
+ modelValue: v(s).remark,
2102
+ "onUpdate:modelValue": x[3] || (x[3] = (j) => v(s).remark = j),
2103
+ size: "md"
2104
+ }, null, 8, ["modelValue"])
2105
+ ])
2106
+ ])
2107
+ ])
2108
+ ];
2109
+ }),
2110
+ _: 1
2111
+ }, 8, ["modelValue"]);
2112
+ };
2113
+ }
2114
+ }), zr = { class: "flex flex-row-reverse" }, Kr = {
2115
+ key: 0,
2116
+ class: "flex"
2117
+ }, Gr = {
2118
+ key: 1,
2119
+ class: "border-t pt-6"
2120
+ }, Hr = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Wr = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Qr = { class: "w-full" }, Yr = {
2121
+ class: "p-3 fm-typo-en-body-sm-600",
2122
+ style: { "min-width": "130px" }
2123
+ }, Jr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Xr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Zr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, eo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, to = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, so = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ro = { class: "p-3 fm-typo-en-body-sm-600" }, oo = { key: 2 }, no = /* @__PURE__ */ $e({
2124
+ __name: "NetSuiteTransactionChangeLog",
2125
+ props: {
2126
+ netsuiteId: {}
2127
+ },
2128
+ setup(C) {
2129
+ const a = C, o = dt(), f = J(!1), h = J(!1), n = J(!1), g = J([]);
2130
+ async function s() {
2131
+ if (!(g.value.length > 0))
2132
+ try {
2133
+ h.value = !0;
2134
+ const w = await o.getChangeLogs(a.netsuiteId);
2135
+ g.value = w, n.value = !1;
2136
+ } catch {
2137
+ n.value = !0;
2138
+ } finally {
2139
+ h.value = !1;
2140
+ }
2141
+ }
2142
+ function c(w) {
2143
+ switch (w) {
2144
+ case we.Create:
2145
+ return "text-green-600 bg-green-100";
2146
+ case we.Set:
2147
+ return "text-blue-600 bg-blue-100";
2148
+ case we.Change:
2149
+ return "text-yellow-600 bg-yellow-100";
2150
+ case we.Unset:
2151
+ return "text-red-600 bg-red-100";
2152
+ default:
2153
+ return "text-gray-600 bg-gray-100";
2154
+ }
2155
+ }
2156
+ function O(w) {
2157
+ return new Date(w).toLocaleDateString("en-US", {
2158
+ year: "numeric",
2159
+ month: "short",
2160
+ day: "numeric",
2161
+ hour: "2-digit",
2162
+ minute: "2-digit"
2163
+ });
2164
+ }
2165
+ return (w, d) => {
2166
+ const T = H("FmButton"), S = H("FmCircularProgress"), A = H("FmIcon"), l = H("FmDialog");
2167
+ return i(), _("div", zr, [
2168
+ D(l, {
2169
+ modelValue: f.value,
2170
+ "onUpdate:modelValue": d[2] || (d[2] = (t) => f.value = t),
2171
+ overlay: !0,
2172
+ "max-width": 800
2173
+ }, {
2174
+ "dialog-button": Z(() => [
2175
+ D(T, {
2176
+ "prepend-icon": "info",
2177
+ variant: "secondary",
2178
+ label: "NetSuite",
2179
+ onClick: d[0] || (d[0] = (t) => s()),
2180
+ "text-color": "primary",
2181
+ "bg-color": "transparent",
2182
+ "border-color": "primary"
2183
+ })
2184
+ ]),
2185
+ "dialog-header": Z(() => d[3] || (d[3] = [
2186
+ e("div", null, "NetSuite info", -1)
2187
+ ])),
2188
+ default: Z(() => [
2189
+ h.value ? (i(), _("div", Kr, [
2190
+ d[4] || (d[4] = e("span", null, "Change Log Loading...", -1)),
2191
+ D(S, { size: "md" })
2192
+ ])) : U("", !0),
2193
+ !h.value && g.value.length > 0 ? (i(), _("div", Gr, [
2194
+ e("h3", Hr, [
2195
+ D(A, {
2196
+ name: "error",
2197
+ color: "#ff9500",
2198
+ size: "sm"
2199
+ }),
2200
+ d[5] || (d[5] = ke(" Change Logs "))
2201
+ ]),
2202
+ e("div", Wr, [
2203
+ e("table", Qr, [
2204
+ d[6] || (d[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
2205
+ e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
2206
+ e("th", {
2207
+ class: "text-left p-3 fm-typo-en-body-md-600",
2208
+ style: { "min-width": "130px" }
2209
+ }, " Date "),
2210
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
2211
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
2212
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
2213
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
2214
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
2215
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
2216
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
2217
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
2218
+ ])
2219
+ ], -1)),
2220
+ e("tbody", null, [
2221
+ (i(!0), _(ue, null, xe(g.value, (t, b) => (i(), _("tr", {
2222
+ key: b,
2223
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
2224
+ }, [
2225
+ e("td", Yr, y(O(t._dateiso8601)), 1),
2226
+ e("td", Jr, y(t._rolename), 1),
2227
+ e("td", Xr, y(t._employeename), 1),
2228
+ e("td", Zr, y(t._contextname), 1),
2229
+ e("td", {
2230
+ class: Me(`p-3 fm-typo-en-body-sm-600 ${c(Number(t.type) - 1)}`)
2231
+ }, y(v(we)[Number(t.type) - 1]), 3),
2232
+ e("td", eo, y(t.lineid || ""), 1),
2233
+ e("td", to, y(t._fieldname), 1),
2234
+ e("td", so, y(t.oldvalue || ""), 1),
2235
+ e("td", ro, y(t.newvalue || ""), 1)
2236
+ ]))), 128))
2237
+ ])
2238
+ ])
2239
+ ])
2240
+ ])) : (i(), _("div", oo, d[7] || (d[7] = [
2241
+ e("p", null, "No change logs available.", -1)
2242
+ ])))
2243
+ ]),
2244
+ "dialog-footer": Z(() => [
2245
+ D(T, {
2246
+ class: "ml-auto sm:w-full xs:w-full",
2247
+ label: "Close",
2248
+ size: "md",
2249
+ variant: "primary",
2250
+ onClick: d[1] || (d[1] = (t) => f.value = !1)
2251
+ })
2252
+ ]),
2253
+ _: 1
2254
+ }, 8, ["modelValue"])
2255
+ ]);
2256
+ };
2257
+ }
2258
+ }), ao = { class: "flex flex-col w-full gap-3" }, lo = { class: "flex" }, io = { class: "fm-typo-en-title-md-600 text-fm-color-typo-primary" }, co = { class: "flex flex-col gap-16 w-full h-full" }, uo = { class: "flex justify-between" }, mo = { class: "fm-typo-en-body-lg-600" }, po = { class: "flex gap-2" }, fo = {
2259
+ key: 0,
2260
+ class: "flex items-center gap-1"
2261
+ }, yo = { class: "fm-typo-en-body-md-400" }, vo = { class: "flex flex-col gap-8" }, ho = { class: "flex flex-col gap-4" }, bo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, go = { class: "flex gap-1" }, _o = { class: "fm-typo-en-body-lg-600" }, So = {
2262
+ key: 0,
2263
+ class: "flex flex-col gap-4"
2264
+ }, xo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Oo = { class: "fm-typo-en-body-lg-600" }, wo = { class: "flex flex-col gap-4" }, $o = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Co = { class: "fm-typo-en-body-lg-600" }, Ro = {
2265
+ key: 1,
2266
+ class: "flex flex-col gap-4"
2267
+ }, ko = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Do = { class: "fm-typo-en-body-lg-600" }, Ao = {
2268
+ key: 2,
2269
+ class: "flex flex-col gap-4"
2270
+ }, No = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fo = { class: "fm-typo-en-body-lg-600" }, To = {
2271
+ key: 3,
2272
+ class: "flex flex-col gap-4"
2273
+ }, Io = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Po = { class: "fm-typo-en-body-lg-600" }, qo = {
2274
+ key: 4,
2275
+ class: "flex flex-col gap-4"
2276
+ }, Vo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Eo = { class: "fm-typo-en-body-lg-600" }, Lo = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Mo = { class: "flex flex-col gap-8" }, Uo = { class: "flex gap-8 items-center" }, Bo = { class: "flex-1 fm-typo-en-body-lg-600" }, jo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, zo = { class: "flex w-full gap-4" }, Ko = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Go = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, Ho = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Wo = ["innerHTML"], Qo = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Yo = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Jo = {
2277
+ key: 0,
2278
+ class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2279
+ }, Xo = { class: "py-8" }, Zo = { class: "flex justify-end gap-4 items-center" }, en = { class: "fm-typo-en-body-lg-600" }, tn = {
2280
+ key: 1,
2281
+ class: "flex-1 xs:w-screen xs:max-w-full"
2282
+ }, sn = {
2283
+ key: 0,
2284
+ class: "flex flex-col items-center gap-8 h-full"
2285
+ }, rn = ["src"], on = { class: "fm-typo-en-body-lg-600" }, nn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, an = {
2286
+ key: 1,
2287
+ class: "px-4 flex flex-col"
2288
+ }, ln = { class: "flex gap-12 content-stretch" }, cn = {
2289
+ class: "flex flex-col w-40",
2290
+ name: "circles"
2291
+ }, un = { class: "flex-1 flex flex-col items-center" }, dn = { class: "h-40 w-40 bg-fm-color-primary rounded-full flex items-center justify-center" }, mn = { class: "flex-1 flex flex-col items-center" }, pn = { class: "flex w-full items-center gap-4" }, fn = {
2292
+ class: "py-12 flex flex-col gap-4",
2293
+ name: "received-at header"
2294
+ }, yn = { class: "fm-typo-en-body-lg-400" }, vn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, hn = { class: "ml-auto flex gap-1" }, bn = { class: "flex gap-12 content-stretch" }, gn = {
2295
+ class: "flex flex-col w-40",
2296
+ name: "circles"
2297
+ }, _n = { class: "flex-1 flex flex-col items-center" }, Sn = {
2298
+ class: "py-12 flex flex-col gap-4 flex-1",
2299
+ name: "delivery details"
2300
+ }, xn = { class: "flex flex-col gap-8" }, On = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, wn = { class: "flex flex-col gap-4" }, $n = { class: "flex gap-8 xs:flex-col" }, Jn = /* @__PURE__ */ $e({
2301
+ __name: "TransferDetails",
2302
+ props: {
2303
+ poRequest: {},
2304
+ purchaseOrder: {},
2305
+ transferTo: {},
2306
+ transferToDbName: {},
2307
+ show: { type: Boolean },
2308
+ canResubmit: { type: Boolean },
2309
+ canApprove: { type: Boolean },
2310
+ scope: {},
2311
+ receivedMap: {},
2312
+ shipments: {}
2313
+ },
2314
+ emits: ["update:show", "submitted"],
2315
+ setup(C, { emit: a }) {
2316
+ const o = C, f = a, h = tt(), n = Be(), g = Ue(), s = De(), c = ct(), O = Q(
2317
+ () => {
2318
+ var r, m;
2319
+ return {
2320
+ id: ((r = c.sessionUser.value) == null ? void 0 : r.id) ?? "",
2321
+ name: ((m = c.sessionUser.value) == null ? void 0 : m.displayName) ?? ""
2322
+ };
2323
+ }
2324
+ ), w = rs(), { t: d } = ut(), T = Q(
2325
+ () => {
2326
+ var r, m, V, E;
2327
+ return ((m = (r = o.purchaseOrder) == null ? void 0 : r.supplier) == null ? void 0 : m.internal) === "restaurant" || ((E = (V = o.purchaseOrder) == null ? void 0 : V.supplier) == null ? void 0 : E.internal) === "warehouse" ? Ge.enum.transfer : Ge.enum.purchase;
2328
+ }
2329
+ ), S = Q(() => {
2330
+ var V;
2331
+ const r = (V = o.shipments) == null ? void 0 : V.find((E) => {
2332
+ var G;
2333
+ return E.ref === ((G = o.purchaseOrder) == null ? void 0 : G._id);
2334
+ });
2335
+ let m = null;
2336
+ if (r != null && r.milestones && r.milestones.length > 0) {
2337
+ const E = r.milestones[r.milestones.length - 1];
2338
+ if (E.estimatedTime) {
2339
+ const G = new Date(E.estimatedTime), F = G.getDate().toString().padStart(2, "0");
2340
+ m = `${G.toLocaleString("en-US", { month: "short" })} ${F}`;
2341
+ }
2342
+ }
2343
+ return m;
2344
+ }), A = J(!1), l = J(""), t = J(!0), b = je(), u = Kt(b.getWorkflowConfig), $ = Ot(), I = [
2345
+ M.enum.receiveStock,
2346
+ M.enum.processRequest,
2347
+ M.enum.closeRequest
2348
+ ], z = Q(() => {
2349
+ if (!o.purchaseOrder)
2350
+ return [];
2351
+ const r = u.result.value;
2352
+ if (r.state === pt.loading)
2353
+ return [];
2354
+ const m = {
2355
+ user: O.value,
2356
+ executedAt: s.locations.computeFirst(
2357
+ (F) => {
2358
+ var j;
2359
+ return F.dbName === ((j = s._currentLocation) == null ? void 0 : j.dbName) ? F : null;
2360
+ }
2361
+ ),
2362
+ purchaseOrderRequest: o.poRequest,
2363
+ purchaseOrder: o.purchaseOrder
2364
+ }, E = g.useOperatePurchaseOrderV2 ? [...I, M.enum.completeReceive] : I;
2365
+ let G = [];
2366
+ try {
2367
+ r.state === pt.error ? (console.error("Error fetching workflow config:", r.error), G = st.getAvailableActions({
2368
+ ...m,
2369
+ orderConfig: st.getDefaultConfig()
2370
+ }).actions.filter((F) => !E.includes(F))) : G = st.getAvailableActions({
2371
+ ...m,
2372
+ orderConfig: r.data
2373
+ }).actions.filter((F) => !E.includes(F));
2374
+ } catch (F) {
2375
+ console.error("Error getting available actions:", F);
2376
+ }
2377
+ return o.scope === "approval" && (G = G.filter((F) => F !== M.enum.completeReceive)), G;
2378
+ }), R = qt(o, "show"), Y = Q(() => [
2379
+ {
2380
+ label: d("inventory.transfer.receiveRequest.details.overview"),
2381
+ value: "overview"
2382
+ },
2383
+ {
2384
+ label: d("inventory.transfer.receiveRequest.details.deliveryHistory"),
2385
+ value: "deliveryHistory"
2386
+ }
2387
+ ]), K = J(Y.value[0]);
2388
+ Rt(
2389
+ () => o.show,
2390
+ (r) => {
2391
+ r && (K.value = Y.value[0]);
2392
+ }
2393
+ );
2394
+ function se(r) {
2395
+ return r.map((m) => ({
2396
+ ...m,
2397
+ amount: {
2398
+ ...m.amount,
2399
+ amount: -Math.abs(m.amount.amount)
2400
+ }
2401
+ }));
2402
+ }
2403
+ async function ge(r, m, V, E, G) {
2404
+ return new Promise((F, j) => {
2405
+ h.open({
2406
+ closeButton: !1,
2407
+ title: E.title,
2408
+ message: E.message,
2409
+ primaryActions: E.primaryActions,
2410
+ secondaryActions: { text: "No", close: !1 }
2411
+ }).onPrimary(async () => {
2412
+ var X, ae, ne, P;
2413
+ const p = [];
2414
+ V === M.enum.approveRequest ? (p.push({
2415
+ action: "approveRequest",
2416
+ payload: null
2417
+ }), m.fulfillment && p.push({
2418
+ action: "processRequest",
2419
+ payload: {
2420
+ fulfillmentId: "",
2421
+ deliveryOrderNumber: "",
2422
+ deliveryRemark: null,
2423
+ items: se(m.fulfillment.items),
2424
+ createdBy: O.value
2425
+ }
2426
+ })) : V === M.enum.processRequest ? m.fulfillment && p.push({
2427
+ action: "processRequest",
2428
+ payload: {
2429
+ fulfillmentId: "",
2430
+ deliveryOrderNumber: "",
2431
+ deliveryRemark: null,
2432
+ items: se(m.fulfillment.items),
2433
+ createdBy: O.value
2434
+ }
2435
+ }) : V === M.enum.rejectRequest ? p.push({
2436
+ action: "rejectRequest",
2437
+ payload: null
2438
+ }) : V === M.enum.closeRequest && p.push({
2439
+ action: "closeRequest",
2440
+ payload: null
2441
+ });
2442
+ try {
2443
+ await $({
2444
+ operate: {
2445
+ operation: V,
2446
+ doc: r,
2447
+ options: m
2448
+ },
2449
+ operateV2: {
2450
+ _id: ((X = o.purchaseOrder) == null ? void 0 : X._id) ?? "",
2451
+ _rev: ((ae = o.purchaseOrder) == null ? void 0 : ae._rev) ?? "",
2452
+ action: V,
2453
+ payloads: p
2454
+ // add payload if action is receiveStock or processRequest
2455
+ },
2456
+ transferTo: (P = (ne = o.poRequest) == null ? void 0 : ne.to) == null ? void 0 : P.dbName
2457
+ }).delayed(1e3), F("submitted");
2458
+ } catch (me) {
2459
+ j(me);
2460
+ }
2461
+ }).onSecondary(() => {
2462
+ F("cancelled");
2463
+ for (let p = 0; p < G + 2; p++)
2464
+ h.close();
2465
+ }).onClose(() => {
2466
+ });
2467
+ });
2468
+ }
2469
+ async function de(r) {
2470
+ var G, F, j, p;
2471
+ if (r === M.enum.receiveStock)
2472
+ return;
2473
+ const m = xt[r];
2474
+ if (!m) {
2475
+ n.open({
2476
+ title: "Something went wrong",
2477
+ message: `Cannot process order: ${it(r)}`,
2478
+ type: "error"
2479
+ });
2480
+ return;
2481
+ }
2482
+ const { successMessage: V, ...E } = m;
2483
+ if (o.purchaseOrder) {
2484
+ l.value = `${r}`, A.value = !0, t.value = !1;
2485
+ const X = {};
2486
+ let ae = 0;
2487
+ if ((r === M.enum.confirmDraft || // auto receive for warehouse to warehouse
2488
+ r === M.enum.completeReceive) && g.autoReceiveWarehouse)
2489
+ X.autoReceive = !0;
2490
+ else if ((r === M.enum.approveRequest || r === M.enum.processRequest) && g.acceptRequireFulfillment) {
2491
+ const ne = (F = (G = o.poRequest) == null ? void 0 : G.from) == null ? void 0 : F.dbName, P = (p = (j = o.poRequest) == null ? void 0 : j.to) == null ? void 0 : p.dbName;
2492
+ if (ne && P && (ne.startsWith("warehouse_") || P.startsWith("warehouse_"))) {
2493
+ const me = await new Promise((Oe, Ae) => {
2494
+ h.open({
2495
+ closeButton: !1,
2496
+ title: "Confirm transfer amount",
2497
+ dialogComponent: ss,
2498
+ dialogComponentProps: {
2499
+ purchaseOrder: o.purchaseOrder,
2500
+ confirm: Oe,
2501
+ "onUpdate:show": (Ne) => {
2502
+ Ne || (l.value = "", A.value = !1, t.value = !0, ae++, h.close()), Ae("cancelled");
2503
+ }
2504
+ }
2505
+ });
2506
+ });
2507
+ X.fulfillment = me;
2508
+ }
2509
+ }
2510
+ try {
2511
+ await ge(
2512
+ o.purchaseOrder,
2513
+ X,
2514
+ r,
2515
+ m,
2516
+ ae
2517
+ ) === "submitted" && (n.open({
2518
+ title: "Success",
2519
+ message: V,
2520
+ type: "success"
2521
+ }), f("update:show", !1), f("submitted"));
2522
+ } catch (ne) {
2523
+ n.open({
2524
+ title: "Something went wrong",
2525
+ message: "Please try again.",
2526
+ type: "error"
2527
+ }), console.error("Error when submitting PO operation", r, o.purchaseOrder, ne);
2528
+ } finally {
2529
+ l.value = "", A.value = !1, t.value = !0;
2530
+ }
2531
+ }
2532
+ }
2533
+ const qe = Q(() => {
2534
+ var r, m;
2535
+ return ((r = o.purchaseOrder) == null ? void 0 : r.status) === te.enum.RECEIVING || ((m = o.purchaseOrder) == null ? void 0 : m.status) === te.enum.COMPLETE;
2536
+ }), Ve = Q(() => o.purchaseOrder ? Xe(o.purchaseOrder) : {}), B = Q(() => {
2537
+ const r = o.purchaseOrder;
2538
+ if (!r) return { status: "", statusClass: "" };
2539
+ const { partial: m, over: V } = nt(Ve.value), E = at(r.status, m, V);
2540
+ let G = d(`inventory.transfer.status.${E}`), F = `${r.status}`.toLocaleLowerCase("en-us");
2541
+ return E === te.enum.CLOSE && (G = `${d(`inventory.transfer.status.${te.enum.COMPLETE}`)}`), E === "PARTIAL_RECEIVED" && F === te.enum.PROCESSING.toLocaleLowerCase("en-us") && (F = te.enum.RECEIVING.toLocaleLowerCase("en-us")), {
2542
+ status: G,
2543
+ statusClass: `fm-status-badge fm-status-badge-${F}`
2544
+ };
2545
+ }), q = Q(() => {
2546
+ var F, j;
2547
+ const r = ((F = o.purchaseOrder) == null ? void 0 : F.deliveryOrder) ?? [], m = ((j = o.purchaseOrder) == null ? void 0 : j.deliveryFullfillment) ?? [], V = [
2548
+ ...r.map((p) => ({
2549
+ createdAt: p.createdAt,
2550
+ type: "grn",
2551
+ doc: p
2552
+ })),
2553
+ ...m.map((p) => ({
2554
+ createdAt: p.createdAt,
2555
+ type: "fulfillment",
2556
+ doc: p
2557
+ }))
2558
+ ];
2559
+ V.reverse().sort((p, X) => p.createdAt.localeCompare(X.createdAt));
2560
+ function E(p) {
2561
+ var ne, P, me, Oe, Ae, Ne, ee, le, pe, ve, _e, Re;
2562
+ const X = m.findIndex((ce) => ce.id === p.fullfillmentId), ae = [
2563
+ (P = (ne = m[X]) == null ? void 0 : ne.netSuite) != null && P.id ? {
2564
+ label: "Fulfillment's ref no. (Netsuite)",
2565
+ values: [
2566
+ `${((Oe = (me = m[X]) == null ? void 0 : me.netSuite) == null ? void 0 : Oe.refNo) ?? "N/A"} (${((Ne = (Ae = m[X]) == null ? void 0 : Ae.netSuite) == null ? void 0 : Ne.id) ?? "-"})`
2567
+ ]
2568
+ } : null,
2569
+ (ee = p == null ? void 0 : p.netSuite) != null && ee.id ? {
2570
+ label: "Netsuite ref no.",
2571
+ values: [`${((le = p == null ? void 0 : p.netSuite) == null ? void 0 : le.refNo) ?? "N/A"} (${((pe = p == null ? void 0 : p.netSuite) == null ? void 0 : pe.id) ?? "-"})`]
2572
+ } : null,
2573
+ (ve = p == null ? void 0 : p.netSuite) != null && ve.recordType ? {
2574
+ label: "Netsuite Type",
2575
+ values: [ht((_e = p == null ? void 0 : p.netSuite) == null ? void 0 : _e.recordType)]
2576
+ } : null
2577
+ ];
2578
+ return {
2579
+ header: "Received",
2580
+ deliveryOrder: p,
2581
+ date: He(new Date(p.createdAt)),
2582
+ info: [
2583
+ {
2584
+ label: "Adjustment date",
2585
+ values: [
2586
+ p.adjustment ? He(new Date(Qe(p.adjustment))) : "-"
2587
+ ]
2588
+ },
2589
+ {
2590
+ label: "Received by",
2591
+ values: [(Re = p.createdBy) == null ? void 0 : Re.name]
2592
+ },
2593
+ {
2594
+ label: "Received items",
2595
+ values: p.received.map((ce) => {
2596
+ var fe;
2597
+ return L("div", [
2598
+ L(
2599
+ "div",
2600
+ {
2601
+ class: "flex gap-4"
2602
+ },
2603
+ [
2604
+ L(
2605
+ "div",
2606
+ {
2607
+ class: "flex flex-col"
2608
+ },
2609
+ [
2610
+ L(
2611
+ "span",
2612
+ {
2613
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2614
+ },
2615
+ `${ce.sku.name}`
2616
+ ),
2617
+ L(
2618
+ "span",
2619
+ {
2620
+ class: "fm-typo-en-body-md-400"
2621
+ },
2622
+ `${ce.sku.code} `
2623
+ )
2624
+ ]
2625
+ ),
2626
+ L(
2627
+ "div",
2628
+ {
2629
+ class: "ml-auto flex flex-col"
2630
+ },
2631
+ [
2632
+ L(
2633
+ "div",
2634
+ {
2635
+ class: "ml-auto flex gap-1"
2636
+ },
2637
+ [
2638
+ L(
2639
+ "span",
2640
+ {
2641
+ class: "fm-typo-en-body-lg-600 self-end"
2642
+ },
2643
+ he(ce.amount, !1)
2644
+ ),
2645
+ L(
2646
+ "span",
2647
+ {
2648
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2649
+ },
2650
+ ((fe = ce.measurement) == null ? void 0 : fe.abbrev) ?? ce.sku.unit.abbrev
2651
+ )
2652
+ ]
2653
+ ),
2654
+ L(
2655
+ "div",
2656
+ {
2657
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2658
+ },
2659
+ `${ce.cost ? `(${Ke(ce.cost)})` : ""}`
2660
+ )
2661
+ ]
2662
+ )
2663
+ ]
2664
+ )
2665
+ ]);
2666
+ })
2667
+ },
2668
+ {
2669
+ label: "Delivery order no.",
2670
+ values: [p.deliveryOrderNumber || "N/A"]
2671
+ },
2672
+ {
2673
+ label: "Remark",
2674
+ values: [p.remark || "N/A"]
2675
+ },
2676
+ X > -1 ? {
2677
+ label: "Fulfilment's sequence",
2678
+ values: [`${X + 1}`]
2679
+ } : null,
2680
+ ...ae
2681
+ ].filter((ce) => !!ce)
2682
+ };
2683
+ }
2684
+ function G(p) {
2685
+ var ae, ne;
2686
+ const X = m.findIndex((P) => P.id === p.id);
2687
+ return {
2688
+ header: "Fulfillment",
2689
+ date: He(new Date(p.createdAt)),
2690
+ info: [
2691
+ {
2692
+ label: "Sequence",
2693
+ values: [String(X + 1)]
2694
+ },
2695
+ {
2696
+ label: "Receiveable items",
2697
+ values: p.items.map((P) => {
2698
+ var me;
2699
+ return L("div", [
2700
+ L(
2701
+ "div",
2702
+ {
2703
+ class: "flex gap-4"
2704
+ },
2705
+ [
2706
+ L(
2707
+ "div",
2708
+ {
2709
+ class: "flex flex-col"
2710
+ },
2711
+ [
2712
+ L(
2713
+ "span",
2714
+ {
2715
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2716
+ },
2717
+ `${P.sku.name}`
2718
+ ),
2719
+ L(
2720
+ "span",
2721
+ {
2722
+ class: "fm-typo-en-body-md-400"
2723
+ },
2724
+ `${P.sku.code} `
2725
+ )
2726
+ ]
2727
+ ),
2728
+ L(
2729
+ "div",
2730
+ {
2731
+ class: "ml-auto flex flex-col"
2732
+ },
2733
+ [
2734
+ L(
2735
+ "div",
2736
+ {
2737
+ class: "ml-auto flex gap-1"
2738
+ },
2739
+ [
2740
+ L(
2741
+ "span",
2742
+ {
2743
+ class: "fm-typo-en-body-lg-600 self-end"
2744
+ },
2745
+ he(P.amount, !1)
2746
+ ),
2747
+ L(
2748
+ "span",
2749
+ {
2750
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2751
+ },
2752
+ ((me = P.measurement) == null ? void 0 : me.abbrev) ?? P.sku.unit.abbrev
2753
+ )
2754
+ ]
2755
+ ),
2756
+ L(
2757
+ "div",
2758
+ {
2759
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2760
+ },
2761
+ `${P.cost ? `(${Ke(P.cost)})` : ""}`
2762
+ )
2763
+ ]
2764
+ )
2765
+ ]
2766
+ )
2767
+ ]);
2768
+ })
2769
+ },
2770
+ (ae = p.netSuite) != null && ae.refNo ? {
2771
+ label: "Ref no. (Netsuite)",
2772
+ values: [(ne = p.netSuite) == null ? void 0 : ne.refNo]
2773
+ } : null
2774
+ ].filter((P) => !!P)
2775
+ };
2776
+ }
2777
+ return V.map((p) => {
2778
+ switch (p.type) {
2779
+ case "grn":
2780
+ return E(p.doc);
2781
+ case "fulfillment":
2782
+ return G(p.doc);
2783
+ }
2784
+ });
2785
+ }), oe = Q(() => {
2786
+ var m;
2787
+ const r = {
2788
+ ...gt(0),
2789
+ currency: Ce()
2790
+ };
2791
+ return ((m = o.purchaseOrder) == null ? void 0 : m.items.reduce((V, E) => ({
2792
+ ...bt(V, E.totalCost ?? r),
2793
+ currency: Ce()
2794
+ }), r)) ?? r;
2795
+ });
2796
+ function k(r) {
2797
+ var F;
2798
+ const V = (((F = o.purchaseOrder) == null ? void 0 : F.version) ?? Te.enum[1]) === Te.enum[2] ? r.id : r.sku._id, E = o.receivedMap[V];
2799
+ return `<span class="${x(r)} fm-typo-en-body-lg-600">${Ie.toFormatString({ value: E.received })}</span>/${Mt(r.quantity, r.sku.unit, r.measurement)}`;
2800
+ }
2801
+ function x(r) {
2802
+ var X;
2803
+ const V = (((X = o.purchaseOrder) == null ? void 0 : X.version) ?? Te.enum[1]) === Te.enum[2] ? r.id : r.sku._id, E = o.receivedMap[V], { isPartialReceive: G, isNoReceive: F, isOverReceive: j, isFullReceive: p } = Yt(E);
2804
+ return F ? "text-fm-color-typo-tertiary" : G ? "text-fm-color-system-warning-300" : j ? "text-fm-color-system-error-300" : p ? "text-fm-color-system-success-300" : "";
2805
+ }
2806
+ const N = Q(() => {
2807
+ var r, m, V;
2808
+ return (r = o.purchaseOrder) != null && r.itemsAtSubmission ? ((m = o.purchaseOrder) == null ? void 0 : m.version) === Te.enum[2] ? o.purchaseOrder.items.reduce((E, G) => {
2809
+ var j, p;
2810
+ const F = (p = (j = o.purchaseOrder) == null ? void 0 : j.itemsAtSubmission) == null ? void 0 : p.find(
2811
+ (X) => X.id === G.id
2812
+ );
2813
+ return F && F.quantity !== G.quantity && E.set(G.sku.code, {
2814
+ originalAmount: Number(Ie.toFormatString({ value: F.quantity })),
2815
+ newAmount: Number(Ie.toFormatString({ value: G.quantity }))
2816
+ }), E;
2817
+ }, /* @__PURE__ */ new Map()) : (V = o.purchaseOrder) == null ? void 0 : V.items.reduce((E, G) => {
2818
+ var X, ae;
2819
+ const F = (ae = (X = o.purchaseOrder) == null ? void 0 : X.itemsAtSubmission) == null ? void 0 : ae.find(
2820
+ (ne) => ne.sku._id === G.sku._id
2821
+ ), j = F ? Number(Ie.toFormatString({ value: F.quantity })) : 0, p = Number(Ie.toFormatString({ value: G.quantity }));
2822
+ return F && j !== p && E.set(G.sku.code, {
2823
+ originalAmount: j,
2824
+ newAmount: p
2825
+ }), E;
2826
+ }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
2827
+ }), W = (r) => {
2828
+ var V, E;
2829
+ const m = N.value;
2830
+ return ((V = o.purchaseOrder) == null ? void 0 : V.version) === Te.enum[2] ? m.has(r.id) : m.has((E = r.sku) == null ? void 0 : E.code);
2831
+ }, ie = (r) => {
2832
+ var V, E;
2833
+ const m = N.value;
2834
+ return ((V = o.purchaseOrder) == null ? void 0 : V.version) === Te.enum[2] ? m.get(r.id) : m.get((E = r.sku) == null ? void 0 : E.code);
2835
+ };
2836
+ return (r, m) => {
2837
+ const V = H("FmButton"), E = H("FmButtonGroup"), G = H("FmChip"), F = H("FmIcon"), j = H("FmMenuDivider"), p = H("FmCard"), X = H("FmTooltip"), ae = H("FmSpacer"), ne = H("FmSideSheet");
2838
+ return i(), re(ne, {
2839
+ modelValue: v(R),
2840
+ "onUpdate:modelValue": m[8] || (m[8] = (P) => kt(R) ? R.value = P : null),
2841
+ "dismiss-away": t.value,
2842
+ "max-width": 600,
2843
+ "close-button": !1
2844
+ }, {
2845
+ "side-sheet-header": Z(() => {
2846
+ var P, me;
2847
+ return [
2848
+ e("div", ao, [
2849
+ e("div", lo, [
2850
+ e("div", io, y(v(d)("inventory.transfer.receiveRequest.details.title") + ((P = r.purchaseOrder) != null && P.seqNumber ? ` #${(me = r.purchaseOrder) == null ? void 0 : me.seqNumber}` : "")), 1),
2851
+ D(V, {
2852
+ class: "ml-auto -m-2",
2853
+ variant: "tertiary",
2854
+ "prepend-icon": "close",
2855
+ onClick: m[0] || (m[0] = (Oe) => f("update:show", !1))
2856
+ })
2857
+ ]),
2858
+ D(E, {
2859
+ items: Y.value,
2860
+ modelValue: K.value,
2861
+ "onUpdate:modelValue": m[1] || (m[1] = (Oe) => K.value = Oe)
2862
+ }, null, 8, ["items", "modelValue"]),
2863
+ r.purchaseOrder && K.value.value === "deliveryHistory" ? (i(), re(jr, {
2864
+ key: 0,
2865
+ "purchase-order": r.purchaseOrder,
2866
+ "received-info-map": Ve.value,
2867
+ onSubmitted: m[2] || (m[2] = () => {
2868
+ f("update:show", !1), f("submitted");
2869
+ })
2870
+ }, null, 8, ["purchase-order", "received-info-map"])) : U("", !0)
2871
+ ])
2872
+ ];
2873
+ }),
2874
+ default: Z(() => {
2875
+ var P, me, Oe, Ae, Ne;
2876
+ return [
2877
+ e("div", co, [
2878
+ K.value.value === "overview" ? (i(), _(ue, { key: 0 }, [
2879
+ e("div", null, [
2880
+ D(p, {
2881
+ variant: "outlined",
2882
+ class: "flex flex-col gap-8 px-12 py-16"
2883
+ }, {
2884
+ default: Z(() => {
2885
+ var ee, le, pe, ve, _e, Re, ce, fe, Fe;
2886
+ return [
2887
+ e("div", uo, [
2888
+ e("div", mo, y(v(d)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
2889
+ e("div", po, [
2890
+ D(Pe, null, {
2891
+ default: Z(() => {
2892
+ var Ee;
2893
+ return [
2894
+ ke(y((Ee = o.purchaseOrder) == null ? void 0 : Ee.status), 1)
2895
+ ];
2896
+ }),
2897
+ _: 1
2898
+ }),
2899
+ D(G, {
2900
+ label: B.value.status,
2901
+ class: Me(B.value.statusClass),
2902
+ compact: ""
2903
+ }, null, 8, ["label", "class"]),
2904
+ S.value ? (i(), _("div", fo, [
2905
+ D(F, {
2906
+ name: "local_shipping",
2907
+ color: "#666666"
2908
+ }),
2909
+ e("span", yo, y(S.value), 1)
2910
+ ])) : U("", !0)
2911
+ ])
2912
+ ]),
2913
+ D(j),
2914
+ e("div", vo, [
2915
+ e("div", ho, [
2916
+ e("div", bo, [
2917
+ e("div", go, y(v(d)("inventory.transfer.receiveRequest.details.createdAt")), 1)
2918
+ ]),
2919
+ e("div", _o, y(v(We)(((ee = r.purchaseOrder) == null ? void 0 : ee._id) ?? "")), 1)
2920
+ ]),
2921
+ (le = r.purchaseOrder) != null && le.effectiveAt ? (i(), _("div", So, [
2922
+ e("div", xo, y(v(d)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
2923
+ e("div", Oo, y(v(_t)(new Date((pe = r.purchaseOrder) == null ? void 0 : pe.effectiveAt))), 1)
2924
+ ])) : U("", !0),
2925
+ e("div", wo, [
2926
+ e("div", $o, y(v(d)("inventory.transfer.receiveRequest.details.type.title")), 1),
2927
+ e("div", Co, y(v(d)(
2928
+ `inventory.transfer.receiveRequest.details.type.${T.value.toLocaleLowerCase("en-US")}`
2929
+ )), 1)
2930
+ ]),
2931
+ (_e = (ve = r.purchaseOrder) == null ? void 0 : ve.supplier) != null && _e.name ? (i(), _("div", Ro, [
2932
+ e("div", ko, y(v(d)("inventory.transfer.receiveRequest.details.from")), 1),
2933
+ e("div", Do, y((ce = (Re = r.purchaseOrder) == null ? void 0 : Re.supplier) == null ? void 0 : ce.name), 1)
2934
+ ])) : U("", !0),
2935
+ r.transferTo ? (i(), _("div", Ao, [
2936
+ e("div", No, y(v(d)("inventory.transfer.receiveRequest.details.to")), 1),
2937
+ e("div", Fo, y(r.transferTo), 1)
2938
+ ])) : U("", !0),
2939
+ (fe = r.purchaseOrder) != null && fe.ref ? (i(), _("div", To, [
2940
+ e("div", Io, y(v(d)("inventory.transfer.receiveRequest.details.reference")), 1),
2941
+ e("div", Po, y(r.purchaseOrder.ref), 1)
2942
+ ])) : U("", !0),
2943
+ (Fe = r.purchaseOrder) != null && Fe.remark ? (i(), _("div", qo, [
2944
+ e("div", Vo, y(v(d)("inventory.transfer.receiveRequest.details.remark")), 1),
2945
+ e("div", Eo, y(r.purchaseOrder.remark), 1)
2946
+ ])) : U("", !0)
2947
+ ])
2948
+ ];
2949
+ }),
2950
+ _: 1
2951
+ })
2952
+ ]),
2953
+ D(Zs, {
2954
+ "po-request": r.poRequest,
2955
+ purchaseOrder: r.purchaseOrder,
2956
+ transferType: T.value,
2957
+ transferToDbName: r.transferToDbName,
2958
+ scope: r.scope
2959
+ }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
2960
+ e("div", Lo, [
2961
+ e("div", Mo, [
2962
+ e("div", Uo, [
2963
+ e("span", Bo, [
2964
+ ke(y(qe.value ? v(d)("inventory.transfer.receiveRequest.details.receivedItems") : v(d)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
2965
+ (me = (P = r.purchaseOrder) == null ? void 0 : P.netSuite) != null && me.missingItems && ((Ae = (Oe = r.purchaseOrder) == null ? void 0 : Oe.netSuite) == null ? void 0 : Ae.missingItems.length) > 0 ? (i(), re(X, {
2966
+ key: 0,
2967
+ variant: "rich",
2968
+ placement: "top",
2969
+ "z-index": 51
2970
+ }, {
2971
+ content: Z(() => {
2972
+ var ee, le;
2973
+ return [
2974
+ e("div", jo, [
2975
+ (i(!0), _(ue, null, xe((le = (ee = r.purchaseOrder) == null ? void 0 : ee.netSuite) == null ? void 0 : le.missingItems, (pe, ve) => (i(), _("div", {
2976
+ class: "flex justify-center align-middle",
2977
+ key: ve
2978
+ }, [
2979
+ D(F, {
2980
+ name: "arrow_right",
2981
+ size: "sm"
2982
+ }),
2983
+ ke(" " + y(`(${pe.netSuiteId}) ${pe.name}: ${pe.reason}`), 1)
2984
+ ]))), 128))
2985
+ ])
2986
+ ];
2987
+ }),
2988
+ default: Z(() => [
2989
+ D(F, {
2990
+ name: "error",
2991
+ color: "#ff2c2c",
2992
+ size: "sm"
2993
+ })
2994
+ ]),
2995
+ _: 1
2996
+ })) : U("", !0)
2997
+ ])
2998
+ ]),
2999
+ D(j),
3000
+ (i(!0), _(ue, null, xe(((Ne = r.purchaseOrder) == null ? void 0 : Ne.items) ?? [], (ee, le) => {
3001
+ var pe;
3002
+ return i(), _("div", {
3003
+ key: le,
3004
+ class: "flex flex-col"
3005
+ }, [
3006
+ e("div", zo, [
3007
+ e("div", Ko, [
3008
+ ke(y(ee.name) + " ", 1),
3009
+ W(ee) ? (i(), re(X, {
3010
+ key: 0,
3011
+ variant: "rich",
3012
+ placement: "top",
3013
+ "z-index": 51
3014
+ }, {
3015
+ content: Z(() => {
3016
+ var ve, _e;
3017
+ return [
3018
+ e("div", Go, [
3019
+ m[9] || (m[9] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
3020
+ e("div", null, "Original Amount: " + y((ve = ie(ee)) == null ? void 0 : ve.originalAmount), 1),
3021
+ e("div", null, " New Amount: " + y((_e = ie(ee)) == null ? void 0 : _e.newAmount), 1)
3022
+ ])
3023
+ ];
3024
+ }),
3025
+ default: Z(() => [
3026
+ D(F, {
3027
+ name: "error",
3028
+ color: "#ff9500",
3029
+ size: "sm"
3030
+ })
3031
+ ]),
3032
+ _: 2
3033
+ }, 1024)) : U("", !0)
3034
+ ]),
3035
+ e("div", Ho, [
3036
+ e("span", {
3037
+ innerHTML: k(ee)
3038
+ }, null, 8, Wo)
3039
+ ])
3040
+ ]),
3041
+ e("div", Qo, [
3042
+ e("div", Yo, y(ee.code), 1),
3043
+ (pe = ee.totalCost) != null && pe.amount && v(g).enableTotalCost ? (i(), _("div", Jo, " (" + y(v(Ke)(ee.totalCost)) + ") ", 1)) : U("", !0)
3044
+ ])
3045
+ ]);
3046
+ }), 128)),
3047
+ +v(he)(oe.value) ? (i(), _(ue, { key: 0 }, [
3048
+ e("div", Xo, [
3049
+ D(j)
3050
+ ]),
3051
+ e("div", Zo, [
3052
+ m[10] || (m[10] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
3053
+ e("div", en, y(v(Ke)(oe.value)), 1)
3054
+ ])
3055
+ ], 64)) : U("", !0)
3056
+ ])
3057
+ ])
3058
+ ], 64)) : K.value.value === "deliveryHistory" ? (i(), _("div", tn, [
3059
+ q.value.length ? (i(), _("div", an, [
3060
+ (i(!0), _(ue, null, xe(q.value, (ee, le) => {
3061
+ var pe, ve, _e, Re, ce;
3062
+ return i(), _(ue, { key: le }, [
3063
+ e("div", ln, [
3064
+ e("div", cn, [
3065
+ e("div", un, [
3066
+ e("div", {
3067
+ class: Me([
3068
+ {
3069
+ "bg-fm-color-primary": le !== 0,
3070
+ "bg-white": le === 0
3071
+ },
3072
+ "w-[2px] h-full"
3073
+ ])
3074
+ }, null, 2)
3075
+ ]),
3076
+ e("div", dn, [
3077
+ ee.header === "Received" ? (i(), re(F, {
3078
+ key: 0,
3079
+ name: "local_shipping",
3080
+ outline: "",
3081
+ color: "#ffffff"
3082
+ })) : U("", !0)
3083
+ ]),
3084
+ e("div", mn, [
3085
+ e("div", {
3086
+ class: Me([
3087
+ {
3088
+ "bg-fm-color-primary": le < q.value.length - 1,
3089
+ "bg-white": le >= q.value.length - 1
3090
+ },
3091
+ "w-[2px] h-full"
3092
+ ])
3093
+ }, null, 2)
3094
+ ])
3095
+ ]),
3096
+ e("div", pn, [
3097
+ e("div", fn, [
3098
+ e("div", yn, y(ee.header), 1),
3099
+ e("div", vn, y(ee.date), 1)
3100
+ ]),
3101
+ e("div", hn, [
3102
+ ee.header === "Received" && ee.deliveryOrder && r.purchaseOrder ? (i(), re(br, {
3103
+ key: 0,
3104
+ deliveryOrder: ee.deliveryOrder,
3105
+ purchaseOrder: r.purchaseOrder,
3106
+ onSubmitted: m[3] || (m[3] = () => {
3107
+ f("update:show", !1), f("submitted");
3108
+ })
3109
+ }, null, 8, ["deliveryOrder", "purchaseOrder"])) : U("", !0),
3110
+ (ve = (pe = ee.deliveryOrder) == null ? void 0 : pe.netSuite) != null && ve.id ? (i(), re(Pe, { key: 1 }, {
3111
+ default: Z(() => {
3112
+ var fe, Fe;
3113
+ return [
3114
+ D(no, {
3115
+ "netsuite-id": (Fe = (fe = ee.deliveryOrder) == null ? void 0 : fe.netSuite) == null ? void 0 : Fe.id
3116
+ }, null, 8, ["netsuite-id"])
3117
+ ];
3118
+ }),
3119
+ _: 2
3120
+ }, 1024)) : U("", !0),
3121
+ r.purchaseOrder && ((_e = ee.deliveryOrder) != null && _e.id) ? (i(), re(Ut, {
3122
+ key: 2,
3123
+ "purchase-order-id": (Re = r.purchaseOrder) == null ? void 0 : Re._id,
3124
+ "delivery-order-id": (ce = ee.deliveryOrder) == null ? void 0 : ce.id
3125
+ }, null, 8, ["purchase-order-id", "delivery-order-id"])) : U("", !0)
3126
+ ])
3127
+ ])
3128
+ ]),
3129
+ e("div", bn, [
3130
+ e("div", gn, [
3131
+ e("div", _n, [
3132
+ e("div", {
3133
+ class: Me([
3134
+ {
3135
+ "bg-fm-color-primary": le < q.value.length - 1,
3136
+ "bg-white": le >= q.value.length - 1
3137
+ },
3138
+ "w-[2px] h-full"
3139
+ ])
3140
+ }, null, 2)
3141
+ ])
3142
+ ]),
3143
+ e("div", Sn, [
3144
+ D(p, {
3145
+ variant: "outlined",
3146
+ class: "py-12 px-16"
3147
+ }, {
3148
+ default: Z(() => [
3149
+ e("div", xn, [
3150
+ (i(!0), _(ue, null, xe(ee.info, (fe, Fe) => (i(), _("div", {
3151
+ key: Fe,
3152
+ class: "flex flex-col gap-4"
3153
+ }, [
3154
+ e("div", On, y(fe == null ? void 0 : fe.label), 1),
3155
+ e("div", wn, [
3156
+ (i(!0), _(ue, null, xe(fe == null ? void 0 : fe.values, (Ee, wt) => (i(), _("div", {
3157
+ key: wt,
3158
+ class: "fm-typo-en-body-lg-600"
3159
+ }, [
3160
+ typeof Ee == "string" ? (i(), _(ue, { key: 0 }, [
3161
+ ke(y(Ee), 1)
3162
+ ], 64)) : (i(), re(Dt(Ee), { key: 1 }))
3163
+ ]))), 128))
3164
+ ])
3165
+ ]))), 128))
3166
+ ])
3167
+ ]),
3168
+ _: 2
3169
+ }, 1024)
3170
+ ])
3171
+ ])
3172
+ ], 64);
3173
+ }), 128))
3174
+ ])) : (i(), _("div", sn, [
3175
+ D(ae),
3176
+ e("div", null, [
3177
+ e("img", {
3178
+ src: v(Vt),
3179
+ alt: "List is empty"
3180
+ }, null, 8, rn)
3181
+ ]),
3182
+ e("div", on, y(v(d)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
3183
+ e("div", nn, y(v(d)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
3184
+ D(ae),
3185
+ D(ae)
3186
+ ]))
3187
+ ])) : U("", !0)
3188
+ ])
3189
+ ];
3190
+ }),
3191
+ "side-sheet-footer": Z(() => [
3192
+ e("div", $n, [
3193
+ (i(!0), _(ue, null, xe(z.value, (P) => (i(), _(ue, null, [
3194
+ v(ot)[P].available != !1 ? (i(), re(V, {
3195
+ key: P,
3196
+ label: v(d)(v(ot)[P].translationKey),
3197
+ onClick: (me) => de(P),
3198
+ loading: l.value === P,
3199
+ disabled: l.value !== P && A.value,
3200
+ variant: v(ot)[P].buttonVariant
3201
+ }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : U("", !0)
3202
+ ], 64))), 256)),
3203
+ v(w).ableToMarkReceived(r.purchaseOrder) && !z.value.includes("completeReceive") ? (i(), re(V, {
3204
+ key: 0,
3205
+ label: v(d)("inventory.transfer.receiveRequest.actions.completeReceive"),
3206
+ onClick: m[4] || (m[4] = (P) => de("completeReceive")),
3207
+ loading: l.value === "completeReceive",
3208
+ disabled: l.value !== "completeReceive" && A.value
3209
+ }, null, 8, ["label", "loading", "disabled"])) : U("", !0),
3210
+ v(w).ableToMarkApproved(r.purchaseOrder) && r.canApprove && !z.value.includes("approveRequest") ? (i(), re(V, {
3211
+ key: 1,
3212
+ label: v(d)("inventory.transfer.approval.actions.approveRequest"),
3213
+ onClick: m[5] || (m[5] = (P) => de("approveRequest")),
3214
+ loading: l.value === "approveRequest",
3215
+ disabled: l.value !== "approveRequest" && A.value
3216
+ }, null, 8, ["label", "loading", "disabled"])) : U("", !0),
3217
+ v(w).ableToCreateFulfillment(r.purchaseOrder, r.poRequest) && o.scope === "approval" ? (i(), re(V, {
3218
+ key: 2,
3219
+ label: v(d)("inventory.transfer.receiveRequest.actions.processRequest"),
3220
+ onClick: m[6] || (m[6] = (P) => de("processRequest")),
3221
+ loading: l.value === "processRequest",
3222
+ disabled: l.value !== "processRequest" && A.value
3223
+ }, null, 8, ["label", "loading", "disabled"])) : U("", !0),
3224
+ D(V, {
3225
+ label: v(d)("common.close"),
3226
+ variant: "tertiary",
3227
+ onClick: m[7] || (m[7] = (P) => f("update:show", !1))
3228
+ }, null, 8, ["label"])
3229
+ ])
3230
+ ]),
3231
+ _: 1
3232
+ }, 8, ["modelValue", "dismiss-away"]);
3233
+ };
3234
+ }
3235
+ });
3236
+ export {
3237
+ lt as P,
3238
+ Jn as _,
3239
+ Yn as a,
3240
+ Jt as g,
3241
+ Qn as u
3242
+ };