@feedmepos/mf-inventory-portal 1.7.2-dev.3 → 1.7.2-dev.4

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 (93) hide show
  1. package/dist/{App-ByQsWsux.js → App-DiF4c1Pl.js} +4 -4
  2. package/dist/{ApprovalView-B8IHv-MP.js → ApprovalView-JAFPOcnS.js} +8 -8
  3. package/dist/{BindingsDialog-BWFYy018.js → BindingsDialog-DWpPZeWQ.js} +2 -2
  4. package/dist/{BindingsPicker-BTrQKndU.js → BindingsPicker-DWMyAS2_.js} +2 -2
  5. package/dist/{BindingsTable-CUswvy2T.js → BindingsTable-Cbw9E-XB.js} +3 -3
  6. package/dist/{BulkReceiveRequestView-r8C2SPMH.js → BulkReceiveRequestView-j09ZhvlW.js} +19 -19
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DZHlmTL9.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CPHH05yH.js} +1 -1
  8. package/dist/{ClosingDraftView-CIfZLApY.js → ClosingDraftView-Bpm0GgHT.js} +19 -19
  9. package/dist/{ClosingHistoryView-CaD1xhmM.js → ClosingHistoryView-BrrVi3wb.js} +5 -5
  10. package/dist/{ClosingTemplateView-C0OvsmJ4.js → ClosingTemplateView-Bz9ykdHd.js} +16 -16
  11. package/dist/{DefaultView-l0-z0i7P.js → DefaultView-CNneufCx.js} +2 -2
  12. package/dist/{DeliveryOrderPrintPreview-BhqqbNbz.js → DeliveryOrderPrintPreview-B6MFsb5t.js} +2 -2
  13. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-DAp4el8X.js → EmailDialog.vue_vue_type_script_setup_true_lang-DX2LuUAx.js} +23 -23
  14. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-D3eXBcWj.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-D5-SkMBv.js} +1 -1
  15. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C9GpwdRQ.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DfmAPISD.js} +2 -2
  16. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BOedO11b.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Cw1Z7af8.js} +2 -2
  17. package/dist/{FmMultiselectDialog-CXtK2ZsB.js → FmMultiselectDialog-4GVBOBvP.js} +2 -2
  18. package/dist/{FmMultiselectDialog-D9oGXLFE.js → FmMultiselectDialog-Cqi87K9H.js} +1 -1
  19. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CzZ70aMc.js → FmUnitInput.vue_vue_type_script_setup_true_lang-OBtdTVHl.js} +5 -5
  20. package/dist/{ImportView-ANrHmifJ.js → ImportView-C7YYBgeJ.js} +6 -6
  21. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CXM8rPZC.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BZm96iYr.js} +1 -1
  22. package/dist/{IngredientGroupView-DCi5Qd1w.js → IngredientGroupView-DLfhlHlQ.js} +5 -5
  23. package/dist/{IngredientsView-DRPxANKi.js → IngredientsView-BgJORcI2.js} +15 -15
  24. package/dist/{IntegrationExplorerView-DBoqKSj4.js → IntegrationExplorerView-D8bPwLab.js} +4 -4
  25. package/dist/{IntegrationView-agoanWWf.js → IntegrationView-20s4aS3T.js} +2250 -2138
  26. package/dist/{InventoryBindingForm-w1kjkywV.js → InventoryBindingForm-BHa6zXRI.js} +1 -1
  27. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-C8pIbAJN.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CnvNx2VS.js} +5 -5
  28. package/dist/{InventoryBindingSummary-DOc7osOY.js → InventoryBindingSummary-DQjlXzWK.js} +1 -1
  29. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BtdI0HiI.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CpuBqVq9.js} +1 -1
  30. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DB7XfTRW.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BJzBe9KZ.js} +1 -1
  31. package/dist/{ProductionView-xNl142Fq.js → ProductionView-CeAXbgm0.js} +7 -7
  32. package/dist/{PublishView-BkYY1dbq.js → PublishView-BJZmy8OM.js} +3 -3
  33. package/dist/{PurchaseOrderPrintPreview-Cy5LC5G8.js → PurchaseOrderPrintPreview-C9WMm_3l.js} +2 -2
  34. package/dist/{ReceiveRequestView-C9Ge3dBk.js → ReceiveRequestView-BVUNDl05.js} +13 -13
  35. package/dist/{RecipeView-DHkXKjMW.js → RecipeView-D0BBuYdo.js} +17 -17
  36. package/dist/{SettingsView-Eedo-gm4.js → SettingsView-C3eyQlAb.js} +4 -4
  37. package/dist/{StockView-CTloP4Oy.js → StockView-eBZya8kq.js} +21 -21
  38. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DQ_ZgiFI.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BHEXI6qV.js} +1 -1
  39. package/dist/{SupplierView-DEfd3W5T.js → SupplierView-DT3rdkF6.js} +12 -12
  40. package/dist/{SurchargeView-fvvvzM2f.js → SurchargeView-BieCgpkV.js} +6 -6
  41. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-DfLOGQWO.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-lTTnxxuy.js} +2 -2
  42. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CqJIt_pF.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BpABqvC4.js} +1 -1
  43. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-Cs6FiHqS.js +4682 -0
  44. package/dist/{TransferTemplateView-BfSI7X8j.js → TransferTemplateView-DvAnCJ3n.js} +20 -20
  45. package/dist/{UnitCostHistoryView-BFce-XiD.js → UnitCostHistoryView-fJYWQV24.js} +4 -4
  46. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-DBbzawh6.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-CqcnSS8K.js} +4 -4
  47. package/dist/{UnitView-eDezcmmU.js → UnitView-BcYABxfz.js} +7 -7
  48. package/dist/{WarehouseView-WqYXomci.js → WarehouseView-DZqd6Eje.js} +5 -5
  49. package/dist/{WastageTemplateView-dHB1_9wS.js → WastageTemplateView-Cm3Kxsrb.js} +14 -14
  50. package/dist/api/codemax.d.ts +2 -0
  51. package/dist/{app-BkI7JOut.js → app-DmTX7X-m.js} +259 -251
  52. package/dist/app.js +1 -1
  53. package/dist/{closing-template-Wt20QIwL.js → closing-template-DmDxzDXS.js} +1 -1
  54. package/dist/{date2-CrQebr0O.js → date2-Bd2UQ1xw.js} +1 -1
  55. package/dist/{dayjs.min-Dm5Jl29E.js → dayjs.min-F_Uyq1c-.js} +1 -1
  56. package/dist/{decimal-oFnzK0l5.js → decimal-eJ-sJu54.js} +2 -2
  57. package/dist/{defineDeepModel-DhQwyn5A.js → defineDeepModel-CId2ET8s.js} +1 -1
  58. package/dist/{duplicate-template-BGxc36Vo.js → duplicate-template-D8R9k-y3.js} +1 -1
  59. package/dist/{feature-OSSn5heM.js → feature-DddwwADd.js} +2 -2
  60. package/dist/{format-time-from-id-BPGeqy_q.js → format-time-from-id-DOSli3Ar.js} +1 -1
  61. package/dist/{format-unit-display-B4Z1I9Zr.js → format-unit-display-BCABLh5x.js} +12 -12
  62. package/dist/{import-export.helper-B1aP4IVt.js → import-export.helper-Ccdq7_dv.js} +6 -6
  63. package/dist/{index-BOX713UW.js → index-CX-lMWO9.js} +62 -54
  64. package/dist/{index-t3KRi2bz.js → index-Cfqr4xj8.js} +1 -1
  65. package/dist/{index-CwCsZdsF.js → index-Dkqy1Ac2.js} +1 -1
  66. package/dist/{inventory-core-dart.default-DpFGa4FK.js → inventory-core-dart.default-DHytwZG9.js} +1 -1
  67. package/dist/{jszip.min-SYQ9tNfS.js → jszip.min-C8Gqyuj1.js} +2 -2
  68. package/dist/{lz-string-DOfeReOs.js → lz-string-CBzWRYQ0.js} +1 -1
  69. package/dist/{netsuite-DkR3T1Jo.js → netsuite-Rc6Awh_Q.js} +2 -2
  70. package/dist/{number-M0fTNQZX.js → number-Bs1CtQ0c.js} +3 -3
  71. package/dist/{predefined-templates-BT-JaWkO.js → predefined-templates-DhGdZhm4.js} +1 -1
  72. package/dist/{purchase-order-template-CsuMKskZ.js → purchase-order-template-DeEAMSYE.js} +1 -1
  73. package/dist/{recalculationUtils-Z_4CmpRM.js → recalculationUtils-BGO8rgXY.js} +1 -1
  74. package/dist/{rules-eDovZZt4.js → rules-DSxhClg6.js} +2 -2
  75. package/dist/{stock-DN2CnjyS.js → stock-D8BZYq3I.js} +1 -1
  76. package/dist/{stock-Cr6BUVXY.js → stock-VMsVCN0k.js} +3 -3
  77. package/dist/{supplier-pEZ0UFf8.js → supplier-_O-QAlUI.js} +2 -2
  78. package/dist/{surcharge-BBlPpII9.js → surcharge-C44-agPa.js} +1 -1
  79. package/dist/tsconfig.app.tsbuildinfo +1 -1
  80. package/dist/{uom-rules-DS7RjEO9.js → uom-rules-Ce-drFDk.js} +1 -1
  81. package/dist/{use-ingredient-select-dialog-B2UpzYAg.js → use-ingredient-select-dialog-DQMydzDs.js} +2 -2
  82. package/dist/{use-inventory-binding-dialog-Dj4vt0Iw.js → use-inventory-binding-dialog-BbPTjV2e.js} +2 -2
  83. package/dist/{use-template-enabled-locations-vtVTL9Wg.js → use-template-enabled-locations-CAzmyDz4.js} +2 -2
  84. package/dist/{use-transfer-locations-jovUkrWP.js → use-transfer-locations--mX23ycc.js} +2 -2
  85. package/dist/{useHrmPermission-Bqa_CJkq.js → useHrmPermission-DFWt_8cx.js} +1 -1
  86. package/dist/{useNavigationMenu-DJrl-u99.js → useNavigationMenu-B7lJT5jE.js} +2 -2
  87. package/dist/{useSseClient-C4prtQ7f.js → useSseClient-DnTLcycQ.js} +1 -1
  88. package/dist/views/receive-request/helper/resolve-po-item-cost.d.ts +12 -0
  89. package/dist/views/receive-request/helper/resolve-po-item-cost.spec.d.ts +1 -0
  90. package/dist/{vue-i18n-Ynah-A_3.js → vue-i18n-GIX6puKF.js} +158 -158
  91. package/dist/{xlsx.util-dU4t7hoK.js → xlsx.util-v75Y4vgZ.js} +2 -2
  92. package/package.json +3 -3
  93. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-Ei4Dj1lb.js +0 -4660
@@ -0,0 +1,4682 @@
1
+ import { defineComponent as Fe, ref as Y, watch as Qe, nextTick as bs, createBlock as ue, openBlock as n, Teleport as gs, createElementBlock as f, createCommentVNode as A, withModifiers as _s, createElementVNode as e, normalizeClass as Be, toDisplayString as b, withDirectives as xs, unref as y, vModelText as Ss, toRaw as ks, shallowRef as ct, onUnmounted as es, triggerRef as Os, computed as B, readonly as ws, h as X, resolveComponent as Z, createVNode as C, Fragment as Oe, renderList as Pe, reactive as $s, onMounted as ts, withCtx as ne, createTextVNode as Ge, renderSlot as Cs, isRef as Ds, resolveDynamicComponent as As } from "vue";
2
+ import { f as Rs, h as Ns, r as Ps, s as ss } from "./predefined-templates-DhGdZhm4.js";
3
+ import { f as at, p as Ts } from "./format-time-from-id-DOSli3Ar.js";
4
+ import { c as Bt } from "./component-kqxARxvM.js";
5
+ import { D as Ee, R as Ce } from "./row-action.enum-DQ9bJ_uv.js";
6
+ import { q as we, H as st, m as Fs, u as ze, V as U, _ as ft, T as ge, a as $t, $ as zt, a0 as Is, a1 as Es, G as qs, s as Ct, c as rs, M as Kt, a2 as os, r as nt, C as Ve, w as Te, B as ut } from "./app-DmTX7X-m.js";
7
+ import { h as Dt, d as Vs, t as Ls, a as Ze } from "./date2-Bd2UQ1xw.js";
8
+ import { j as js, c as Us, a as xe, t as We, d as lt } from "./number-Bs1CtQ0c.js";
9
+ import { F as et, a as Ms, b as Ht, d as gt } from "./inventory-core-dart.default-DHytwZG9.js";
10
+ import { L as Bs } from "./lz-string-CBzWRYQ0.js";
11
+ import { useI18n as vt, useCoreStore as yt } from "@feedmepos/mf-common";
12
+ import { u as ht, a as At, S as Me } from "./netsuite-Rc6Awh_Q.js";
13
+ import { useDialog as bt, useSnackbar as Je, components as dt, FmButtonVariant as Ue, useProxiedModel as zs } from "@feedmepos/ui-library";
14
+ import { F as tt } from "./FmAdminBadge-DlplQOHb.js";
15
+ import { u as Ye } from "./feature-DddwwADd.js";
16
+ import { _ as Gt } from "./empty-placeholder-B0QU467o.js";
17
+ import { a as Ks, b as Hs, f as mt } from "./format-unit-display-BCABLh5x.js";
18
+ import { u as Xe, _ as Gs } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-lTTnxxuy.js";
19
+ import { _ as Ws, a as Qs, b as Ys } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-OBtdTVHl.js";
20
+ import { u as Js, R as Wt } from "./usePromise-CbVUCxhj.js";
21
+ import { e as Xs } from "./index-CX-lMWO9.js";
22
+ import { i as Zs } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-D5-SkMBv.js";
23
+ import { F as Qt } from "./form-mode.enum-BKiNVH6A.js";
24
+ import { u as ns } from "./supplier-_O-QAlUI.js";
25
+ import { u as er } from "./surcharge-C44-agPa.js";
26
+ import { F as tr } from "./decimal-eJ-sJu54.js";
27
+ import { d as as } from "./defineDeepModel-CId2ET8s.js";
28
+ import { u as sr } from "./vue-i18n-GIX6puKF.js";
29
+ import { u as rr } from "./useHrmPermission-DFWt_8cx.js";
30
+ function ls(p, t) {
31
+ return t.reduce(
32
+ (l, m) => {
33
+ const u = m.received.find((c) => c.sku._id === p._id);
34
+ return u && (l = js(l, u.amount)), l;
35
+ },
36
+ tr.toPrecision(Us(0), p.unit.precision)
37
+ );
38
+ }
39
+ function is(p) {
40
+ var l;
41
+ const t = we(), r = (l = p.supplier.supplyItems) != null && l.length ? { ...p.supplier, registrationNumber: p.supplier.registrationNumber ?? "" } : void 0;
42
+ return (m) => {
43
+ var u, c;
44
+ if ((u = m.totalCost) != null && u.amount) return m.totalCost;
45
+ if (!m.isCustomCost)
46
+ try {
47
+ const { cost: s } = et.calculateDefaultCost({
48
+ item: m.sku,
49
+ amount: m.quantity,
50
+ measurement: m.measurement,
51
+ overrides: r ? { supplier: r } : void 0,
52
+ defaultCurrency: t
53
+ });
54
+ return s.amount ? s : void 0;
55
+ } catch (s) {
56
+ console.warn("[print] cost auto-calculation failed for item", (c = m.sku) == null ? void 0 : c._id, s);
57
+ return;
58
+ }
59
+ };
60
+ }
61
+ function or(p) {
62
+ var ve, N, re, k, F, G, K;
63
+ const { po: t, currentLocation: r, business: l, fulfilling: m, por: u } = p, c = r.doc.profile || {}, { name: s, address: o, regNo: d, legalName: g } = c, S = {
64
+ name: s || r.name || "",
65
+ legalName: g || void 0,
66
+ registrationNumber: d || void 0,
67
+ line1: (o == null ? void 0 : o.line1) || "",
68
+ line2: (o == null ? void 0 : o.line2) || void 0,
69
+ postcode: (o == null ? void 0 : o.postcode) || "",
70
+ city: (o == null ? void 0 : o.city) || "",
71
+ state: (o == null ? void 0 : o.state) || "",
72
+ country: (o == null ? void 0 : o.country) || ""
73
+ }, R = {
74
+ name: t.supplier.name,
75
+ phoneNumber: t.supplier.phoneNumber || void 0,
76
+ registrationNumber: t.supplier.registrationNumber || void 0,
77
+ line1: ((ve = t.supplier.address) == null ? void 0 : ve.line1) || "",
78
+ line2: ((N = t.supplier.address) == null ? void 0 : N.line2) || void 0,
79
+ postcode: ((re = t.supplier.address) == null ? void 0 : re.postcode) || "",
80
+ city: ((k = t.supplier.address) == null ? void 0 : k.city) || "",
81
+ state: ((F = t.supplier.address) == null ? void 0 : F.state) || "",
82
+ country: ((G = t.supplier.address) == null ? void 0 : G.country) || ""
83
+ }, $ = is(t), _ = t.items.filter((W) => W.sku).map((W) => {
84
+ var q;
85
+ const { sku: ye, measurement: me } = W, he = xe(
86
+ ls(W.sku, t.deliveryOrder || []),
87
+ !1
88
+ ), de = $(W);
89
+ return {
90
+ code: ye.code,
91
+ description: ye.name,
92
+ quantity: xe(W.quantity, !1),
93
+ unit: (me == null ? void 0 : me.abbrev) || ((q = ye.unit) == null ? void 0 : q.abbrev) || "",
94
+ received: he,
95
+ unitCost: de ? `${de.currency} ${et.toFormatString({
96
+ value: W.quantity.amount === 0 ? et.fromNumber(0) : et.divide([de, W.quantity])
97
+ })}` : void 0,
98
+ cost: de ? `${de.currency} ${et.toFormatString({
99
+ value: de
100
+ })}` : void 0
101
+ };
102
+ }), M = (t.deliveryOrder || []).map((W) => ({
103
+ createdAt: Dt(new Date(W.createdAt)),
104
+ ref: W.deliveryOrderNumber,
105
+ remark: W.remark || "",
106
+ items: (W.received || []).map((ye) => {
107
+ var me, he, de, q, T;
108
+ return {
109
+ code: ((me = ye.sku) == null ? void 0 : me.code) || "",
110
+ description: ((he = ye.sku) == null ? void 0 : he.name) || "",
111
+ quantity: xe(ye.amount),
112
+ unit: ((de = ye.measurement) == null ? void 0 : de.abbrev) || ((T = (q = ye.sku) == null ? void 0 : q.unit) == null ? void 0 : T.abbrev) || ""
113
+ };
114
+ })
115
+ }));
116
+ let P = st.Enum.purchaseOrder, Q = "Inventory Receive Note";
117
+ if (t.supplier.internal ? (Q = "Inventory Transfer Note", P = st.Enum.transferOrder) : (Q = "Purchase Order", P = st.Enum.purchaseOrder), (K = u == null ? void 0 : u.from) != null && K.dbName) {
118
+ const W = u.from.dbName;
119
+ r.dbName === W || (Q = "Inventory Receive Note", P = st.Enum.goodsReceivedNote);
120
+ }
121
+ const le = {
122
+ title: Q,
123
+ businessName: l == null ? void 0 : l.name,
124
+ logo: l == null ? void 0 : l.thumbnail,
125
+ orderNumber: t.seqNumber.toString(),
126
+ createdAt: at(t._id),
127
+ ref: t.ref || "",
128
+ remark: t.remark || "",
129
+ buyer: S,
130
+ supplier: R,
131
+ items: _,
132
+ status: t.status,
133
+ deliveryOrders: M
134
+ }, _e = m && (t.deliveryFullfillment || []).length > 0;
135
+ return _e && (P = st.Enum.deliveryOrder), { printData: le, templateType: P, isDeliveryPrint: _e };
136
+ }
137
+ function cs(p) {
138
+ var g;
139
+ const { printData: t, templateType: r } = or(p), m = Rs().getTemplateByType(r), u = !!((g = m == null ? void 0 : m.blocks) != null && g.length), c = Ns(r), s = u ? m.blocks : c.blocks, o = u ? m.name : c.name, d = !u;
140
+ try {
141
+ const S = Ps(s, t), R = S.match(/<style>([\s\S]*?)<\/style>/), $ = R ? `<style>${R[1]}</style>` : "", _ = S.replace(/<style>[\s\S]*?<\/style>/, "");
142
+ return {
143
+ html: `<!DOCTYPE html>
144
+ <html>
145
+ <head>
146
+ <meta charset="utf-8">
147
+ <title>Print Preview</title>
148
+ <style>
149
+ @page { margin: 0; }
150
+ @media print {
151
+ body { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
152
+ }
153
+ * { box-sizing: border-box; margin: 0; padding: 0; }
154
+ </style>
155
+ ${$}
156
+ </head>
157
+ <body>${_}</body>
158
+ </html>`,
159
+ templateName: o,
160
+ isDefault: d
161
+ };
162
+ } catch {
163
+ return alert("Failed to render print template. Please try recreating the template."), null;
164
+ }
165
+ }
166
+ const nr = { class: "w-[95vw] h-[95vh] bg-white rounded-lg flex flex-col shadow-2xl overflow-hidden" }, ar = { class: "flex justify-between items-center px-16 py-3 border-b border-gray-200 bg-gray-50" }, lr = { class: "flex items-center gap-2.5" }, ir = {
167
+ key: 1,
168
+ class: "text-xs text-gray-100 bg-gray-500 px-2 py-0.5 rounded font-medium"
169
+ }, cr = { class: "flex-1 overflow-auto bg-gray-100" }, _i = /* @__PURE__ */ Fe({
170
+ __name: "CustomPrintTemplatePreview",
171
+ props: {
172
+ html: {},
173
+ modelValue: { type: Boolean },
174
+ templateName: {},
175
+ isDefault: { type: Boolean }
176
+ },
177
+ emits: ["update:modelValue"],
178
+ setup(p, { emit: t }) {
179
+ const r = p, l = t, m = Y(null);
180
+ function u() {
181
+ l("update:modelValue", !1);
182
+ }
183
+ function c() {
184
+ var o, d;
185
+ try {
186
+ (d = (o = m.value) == null ? void 0 : o.contentWindow) == null || d.print();
187
+ } catch {
188
+ alert("Failed to trigger print.");
189
+ }
190
+ }
191
+ Qe(
192
+ () => r.modelValue,
193
+ async (o) => {
194
+ o && (await bs(), s(), setTimeout(() => {
195
+ c();
196
+ }, 300));
197
+ }
198
+ );
199
+ function s() {
200
+ var S;
201
+ const o = m.value;
202
+ if (!o) return;
203
+ const d = ss(r.html), g = o.contentDocument || ((S = o.contentWindow) == null ? void 0 : S.document);
204
+ g && (g.open(), g.write(`
205
+ <!DOCTYPE html>
206
+ <html>
207
+ <head>
208
+ <meta charset="utf-8">
209
+ <meta http-equiv="Content-Security-Policy" content="
210
+ default-src 'none';
211
+ style-src 'unsafe-inline';
212
+ img-src 'self' data: https:;
213
+ font-src 'self' data:;
214
+ script-src 'none';
215
+ object-src 'none';
216
+ frame-src 'none';
217
+ base-uri 'none';
218
+ form-action 'none';
219
+ ">
220
+ <style>
221
+ * {
222
+ box-sizing: border-box;
223
+ }
224
+ body {
225
+ margin: 0;
226
+ padding: 40px 20px;
227
+ background: #f0f0f0;
228
+ min-height: 100vh;
229
+ }
230
+ .print-container {
231
+ max-width: 800px;
232
+ margin: 0 auto;
233
+ padding: 30px;
234
+ border: 1px solid #ddd;
235
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
236
+ background: #ffffff;
237
+ font-size: 16px;
238
+ line-height: 1.5;
239
+ font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
240
+ color: #555;
241
+ }
242
+ @media print {
243
+ body {
244
+ background: white !important;
245
+ padding: 0 !important;
246
+ margin: 0 !important;
247
+ }
248
+ .print-container {
249
+ border: none !important;
250
+ box-shadow: none !important;
251
+ padding: 0 !important;
252
+ margin: 0 !important;
253
+ max-width: none !important;
254
+ }
255
+ }
256
+ </style>
257
+ </head>
258
+ <body>
259
+ <div class="print-container">
260
+ ${d}
261
+ </div>
262
+ </body>
263
+ </html>
264
+ `), g.close());
265
+ }
266
+ return (o, d) => (n(), ue(gs, { to: "body" }, [
267
+ o.modelValue ? (n(), f("div", {
268
+ key: 0,
269
+ class: "fixed inset-0 z-[9999] bg-black/50 flex justify-center items-center",
270
+ onClick: _s(u, ["self"])
271
+ }, [
272
+ e("div", nr, [
273
+ e("div", ar, [
274
+ e("div", lr, [
275
+ d[0] || (d[0] = e("span", { class: "text-base font-semibold text-gray-700" }, "Print Preview", -1)),
276
+ o.templateName ? (n(), f("span", {
277
+ key: 0,
278
+ class: Be(["text-xs font-medium px-2 py-0.5 rounded", o.isDefault ? "text-gray-500 bg-gray-100" : "text-blue-700 bg-blue-50"])
279
+ }, b(o.templateName), 3)) : A("", !0),
280
+ o.isDefault ? (n(), f("span", ir, "Default")) : A("", !0)
281
+ ]),
282
+ e("div", { class: "flex gap-2 items-center" }, [
283
+ e("button", {
284
+ class: "px-8 py-1.5 bg-blue-500 text-white border-none rounded text-sm cursor-pointer hover:bg-blue-700",
285
+ onClick: c
286
+ }, " Print "),
287
+ e("button", {
288
+ class: "px-2.5 py-1 bg-transparent border border-gray-300 rounded text-xl leading-none cursor-pointer text-gray-500 hover:bg-gray-100",
289
+ onClick: u
290
+ }, " × ")
291
+ ])
292
+ ]),
293
+ e("div", cr, [
294
+ e("iframe", {
295
+ ref_key: "iframeRef",
296
+ ref: m,
297
+ class: "w-full h-full border-none",
298
+ sandbox: "allow-same-origin allow-modals"
299
+ }, null, 512)
300
+ ])
301
+ ])
302
+ ])) : A("", !0)
303
+ ]));
304
+ }
305
+ }), ur = Fs((p, t) => {
306
+ const r = ze();
307
+ return {
308
+ async getShipments({
309
+ start: l,
310
+ end: m
311
+ }) {
312
+ const u = r.currentLocationDBName, c = `${p.inventoryBackendUrl}/${u}/shipments`;
313
+ return await t.get(`${c}?start=${l}&end=${m}`);
314
+ },
315
+ async getShipmentsByIds(l) {
316
+ if (l.length === 0)
317
+ return [];
318
+ const m = r.currentLocationDBName, u = `${p.inventoryBackendUrl}/${m}/shipments/get`;
319
+ return await t.post(u, { shipmentIds: l });
320
+ }
321
+ };
322
+ }), us = {
323
+ [U.enum.confirmDraft]: {
324
+ primaryActions: {
325
+ text: "Confirm draft",
326
+ close: !0
327
+ },
328
+ title: "Confirm draft?",
329
+ message: "Purchase order cannot be changed after confirm draft.",
330
+ successMessage: "Purchase order draft has been confirmed"
331
+ },
332
+ [U.enum.cancelDraft]: {
333
+ primaryActions: {
334
+ text: "Cancel draft",
335
+ close: !0,
336
+ variant: "destructive"
337
+ },
338
+ title: "Cancel draft?",
339
+ message: "Purchase order cannot be changed after cancelled draft.",
340
+ successMessage: "Purchase order draft has been cancelled"
341
+ },
342
+ [U.enum.approveDraft]: {
343
+ primaryActions: {
344
+ text: "Approve draft",
345
+ close: !0
346
+ },
347
+ title: "Approve draft?",
348
+ message: "Purchase order request will be accepted.",
349
+ successMessage: "Purchase order has been approved"
350
+ },
351
+ [U.enum.rejectDraft]: {
352
+ primaryActions: {
353
+ text: "Reject draft",
354
+ close: !0
355
+ },
356
+ title: "Reject draft?",
357
+ message: "Purchase order request will be rejected. You may provide an optional reason for rejection.",
358
+ successMessage: "Purchase order has been rejected"
359
+ },
360
+ [U.enum.submitRequest]: {
361
+ primaryActions: {
362
+ text: "Submit request",
363
+ close: !0
364
+ },
365
+ title: "Confirm draft?",
366
+ message: "Purchase order cannot be changed after confirm draft.",
367
+ successMessage: "Purchase order draft has been submitted"
368
+ },
369
+ [U.enum.completeReceive]: {
370
+ primaryActions: {
371
+ text: "Mark received",
372
+ close: !0
373
+ },
374
+ title: "Mark as received",
375
+ message: "Purchase order cannot be changed after it has complete receiving.",
376
+ successMessage: "Purchase order has been marked as received"
377
+ },
378
+ [U.enum.approveRequest]: {
379
+ primaryActions: {
380
+ text: "Accept request",
381
+ close: !0
382
+ },
383
+ title: "Accept request?",
384
+ message: "Transfer out request will be accepted.",
385
+ successMessage: "Transfer out request has been approved"
386
+ },
387
+ [U.enum.rejectRequest]: {
388
+ primaryActions: {
389
+ text: "Reject request",
390
+ close: !0,
391
+ variant: "destructive"
392
+ },
393
+ title: "Reject request?",
394
+ message: "Purchase order will be rejected.",
395
+ successMessage: "Purchase order has been rejected"
396
+ },
397
+ [U.enum.processRequest]: {
398
+ primaryActions: {
399
+ text: "Process request",
400
+ close: !0,
401
+ variant: "destructive"
402
+ },
403
+ title: "Process request?",
404
+ message: "Purchase order will be processed.",
405
+ successMessage: "Purchase order has been processed"
406
+ }
407
+ }, dr = { class: "p-4" }, mr = {
408
+ key: 0,
409
+ class: "fm-typo-en-body-md-400 mb-3"
410
+ }, pr = { class: "fm-typo-en-body-md-400" }, ds = /* @__PURE__ */ Fe({
411
+ __name: "RejectDraftForm",
412
+ props: {
413
+ message: {},
414
+ confirm: { type: Function },
415
+ onChange: { type: Function }
416
+ },
417
+ setup(p) {
418
+ const t = p, { t: r } = vt(), l = Y("");
419
+ Qe(l, (u) => {
420
+ var c;
421
+ (c = t.onChange) == null || c.call(t, u ?? "");
422
+ });
423
+ function m() {
424
+ l.value = "";
425
+ }
426
+ return (u, c) => (n(), f("div", dr, [
427
+ t.message ? (n(), f("div", mr, b(t.message), 1)) : A("", !0),
428
+ e("label", pr, b(y(r)("inventory.transfer.receiveRequest.details.rejectionReason")) + " (" + b(y(r)("inventory.common.optional")) + ")", 1),
429
+ xs(e("textarea", {
430
+ "onUpdate:modelValue": c[0] || (c[0] = (s) => l.value = s),
431
+ rows: "4",
432
+ class: "w-full mt-2 p-2 border rounded"
433
+ }, null, 512), [
434
+ [Ss, l.value]
435
+ ]),
436
+ e("div", { class: "mt-3 flex gap-2" }, [
437
+ e("button", {
438
+ type: "button",
439
+ class: "fm-btn fm-btn-tertiary",
440
+ onClick: m
441
+ }, "Clear")
442
+ ])
443
+ ]));
444
+ }
445
+ });
446
+ function pt(p) {
447
+ return ft.generatedPOReceivedMap({
448
+ purchaseOrder: p
449
+ });
450
+ }
451
+ function fr(p) {
452
+ return ft.validatePOItemReceivedStatus({
453
+ dto: p
454
+ });
455
+ }
456
+ function kt(p) {
457
+ return ft.validatePOReceivedStatus({
458
+ receivedMap: p
459
+ });
460
+ }
461
+ function Ot(p, t, r) {
462
+ if (!ge.safeParse(p).success)
463
+ throw new Error(`Invalid purchase order status: ${p}`);
464
+ const l = ge.parse(p);
465
+ return ft.orderStatusCombination({
466
+ status: l,
467
+ isPOPartialReceive: t,
468
+ isPOOverReceive: r
469
+ });
470
+ }
471
+ function ms() {
472
+ const p = ze(), t = Xe(), r = Ye();
473
+ async function l(u, c) {
474
+ const s = p.currentLocationDBName;
475
+ return u.doc.supplier.internal && u.operation === U.enum.confirmDraft && (u.operation = U.enum.submitRequest), await t.processPurchaseOrder(u, c || s);
476
+ }
477
+ async function m(u, c) {
478
+ const s = p.currentLocationDBName;
479
+ return await t.processPurchaseOrderV2(u, c || s);
480
+ }
481
+ return (u) => r.useOperatePurchaseOrderV2 ? m(u.operateV2, u.transferTo) : l(u.operate, u.transferTo);
482
+ }
483
+ function He(p) {
484
+ const t = ks(p);
485
+ if (Array.isArray(t))
486
+ return t.map(He);
487
+ if (t !== null && typeof t == "object") {
488
+ const r = {};
489
+ for (const l in t)
490
+ Object.prototype.hasOwnProperty.call(t, l) && (r[l] = He(t[l]));
491
+ return r;
492
+ }
493
+ return t;
494
+ }
495
+ const _t = {
496
+ set: "set",
497
+ add: "add",
498
+ delete: "delete"
499
+ };
500
+ function Yt(p) {
501
+ return {
502
+ dbName: p.dbName,
503
+ type: p.type,
504
+ name: p.name,
505
+ acceptRequest: p.acceptRequest ?? !1,
506
+ doc: p.doc
507
+ };
508
+ }
509
+ function Jt(p, t, r, l, m) {
510
+ const u = He(p.suppliers ?? []), c = He(t.allLocations ?? []).map(Yt), s = t._currentLocation ? Yt(He(t._currentLocation)) : null, o = r.inventory ? [He(r.inventory)] : [], d = l.state.setting ? He(l.state.setting) : null, g = He(m.surcharges ?? []);
511
+ return {
512
+ suppliers: u,
513
+ locations: c,
514
+ currentLocation: s,
515
+ inventoryDoc: o,
516
+ netSuiteSetting: d,
517
+ surcharges: g
518
+ };
519
+ }
520
+ function ps() {
521
+ const p = ns(), t = ze(), r = $t(), l = ht(), m = er(), u = Jt(
522
+ p,
523
+ t,
524
+ r,
525
+ l,
526
+ m
527
+ ), c = ct(Ms({ env: u }));
528
+ c.value.setUsePartialUpdates(!0);
529
+ const s = ct(c.value.state()), o = (R) => {
530
+ s.value = c.value.state();
531
+ };
532
+ c.value.addListener(o);
533
+ const d = (R, $, _) => {
534
+ switch (R) {
535
+ case _t.set:
536
+ zt(s.value, $, _);
537
+ break;
538
+ case _t.add:
539
+ Es(s.value, $, _);
540
+ break;
541
+ case _t.delete:
542
+ Is(s.value, $);
543
+ break;
544
+ default:
545
+ console.warn(`Unknown partial update operation: ${R}, falling back to 'set'`), zt(s.value, $, _);
546
+ }
547
+ $ !== "remark" && $ !== "ref" && Os(s);
548
+ };
549
+ c.value.addPartialListener(d);
550
+ function g() {
551
+ const R = Jt(
552
+ p,
553
+ t,
554
+ r,
555
+ l,
556
+ m
557
+ );
558
+ c.value.updateFullEnv(R), s.value = c.value.state();
559
+ }
560
+ Qe(
561
+ [
562
+ () => p.suppliers,
563
+ () => t.allLocations,
564
+ () => t._currentLocation,
565
+ () => r.inventory,
566
+ () => l.state.setting,
567
+ () => m.surcharges
568
+ ],
569
+ () => {
570
+ g();
571
+ },
572
+ { deep: !0 }
573
+ ), es(() => {
574
+ c.value.removeListener(o), c.value.removePartialListener(d);
575
+ });
576
+ function S(R) {
577
+ var $;
578
+ if (R != null && R._id) {
579
+ c.value.loadPurchaseOrder(R);
580
+ return;
581
+ }
582
+ if (!Ye().mustUsePoTemplate) {
583
+ c.value.init();
584
+ return;
585
+ }
586
+ R != null && R.template && (($ = R.templateDoc) != null && $.purchaseOrder) ? (R.items = R.templateDoc.purchaseOrder.items, c.value.initFromTemplate(R)) : c.value.initOutletToOutlet();
587
+ }
588
+ return {
589
+ controller: c,
590
+ state: s,
591
+ init: S
592
+ };
593
+ }
594
+ var wt = /* @__PURE__ */ ((p) => (p.RECEIVE_REQUEST = "receive/request", p.APPROVAL = "approval", p))(wt || {});
595
+ const rt = Y(), xt = Y(), St = Y();
596
+ function xi(p, t) {
597
+ const r = bt(), l = ze(), m = Ye(), u = ns(), c = yt(), s = Ks(), o = Hs(), d = Y(!1), g = Je(), S = Xe(), R = ur(), $ = Y(new Array()), _ = Y(new Array()), M = Y(
598
+ t != null && t.startDate && (t != null && t.endDate) ? t : Zs()
599
+ ), P = B(() => {
600
+ const q = new Date(M.value.startDate), T = new Date(M.value.endDate);
601
+ return {
602
+ start: Ls(q).toISOString(),
603
+ end: Vs(T).toISOString()
604
+ };
605
+ }), Q = Y(new Array()), se = qs(), le = Y(null);
606
+ async function _e(q) {
607
+ function T(j) {
608
+ const O = {
609
+ mode: Qt.CREATE,
610
+ modelValue: q || void 0,
611
+ show: !0,
612
+ "onUpdate:show"(I) {
613
+ rt.value.show = I;
614
+ },
615
+ templateId: j,
616
+ lastClosingDate: le.value
617
+ };
618
+ rt.value = O;
619
+ }
620
+ let oe;
621
+ m.mustUsePoTemplate && !(q != null && q.template) ? r.open({
622
+ title: "Create transfer",
623
+ message: "",
624
+ primaryActions: {
625
+ text: "Select a template",
626
+ close: !0
627
+ },
628
+ secondaryActions: {
629
+ text: "Outlet to Outlet",
630
+ variant: "secondary",
631
+ close: !0
632
+ }
633
+ }).onPrimary(async () => {
634
+ oe = await s.getTemplateId(), oe && T(oe);
635
+ }).onSecondary(() => {
636
+ T(void 0);
637
+ }) : T(oe);
638
+ }
639
+ function ve(q) {
640
+ const T = {
641
+ mode: Qt.UPDATE,
642
+ modelValue: rs(q),
643
+ show: !0,
644
+ "onUpdate:show"(oe) {
645
+ rt.value.show = oe;
646
+ },
647
+ lastClosingDate: le.value
648
+ };
649
+ rt.value = T;
650
+ }
651
+ function N(q) {
652
+ if (!c.currentBusiness.value) return;
653
+ const T = l.currentLocation;
654
+ if (T.type === "restaurant") {
655
+ const L = l.locationRestaurantFromCore(T.doc._id);
656
+ L !== null && (T.doc = L);
657
+ }
658
+ const oe = cs({
659
+ po: q,
660
+ currentLocation: T,
661
+ business: c.currentBusiness.value,
662
+ fulfilling: p === "approval",
663
+ por: q.request
664
+ });
665
+ if (!oe) return;
666
+ const j = ss(oe.html), O = u.supplierById[q.supplier._id], I = {
667
+ recipientName: O.name,
668
+ email: (O == null ? void 0 : O.email) ?? "",
669
+ business: c.currentBusiness.value,
670
+ modelValue: j,
671
+ show: !0,
672
+ "onUpdate:show"(L) {
673
+ xt.value.show = L;
674
+ }
675
+ };
676
+ xt.value = I;
677
+ }
678
+ async function re() {
679
+ $.value = [], _.value = [], d.value = !0;
680
+ try {
681
+ const q = await S.getPurchaseOrders(P.value);
682
+ $.value = q.sort((L, ae) => ae._id.localeCompare(L._id));
683
+ const T = q.flatMap((L) => L.shipmentIds || []).filter(Boolean), oe = T.length > 0 ? await R.getShipmentsByIds(T) : [];
684
+ _.value = oe;
685
+ const j = await se.readCurrentLocationLastClosing(!0), O = j == null ? void 0 : j._id;
686
+ O && (le.value = Ts(O)), await m.awaitFeatureLoaded(() => m.mustUsePoTemplate) && await o.fetchTemplates();
687
+ const I = $.value.map((L) => {
688
+ var ae;
689
+ return ((ae = L.request) == null ? void 0 : ae.id) ?? "";
690
+ }).filter((L) => L);
691
+ Q.value = await S.readRequestByIds(I);
692
+ } catch {
693
+ g.open({
694
+ title: "Something went wrong",
695
+ message: "Error at fetching purchase orders",
696
+ type: "error"
697
+ });
698
+ } finally {
699
+ d.value = !1;
700
+ }
701
+ }
702
+ async function k() {
703
+ Q.value = [], d.value = !0;
704
+ try {
705
+ Q.value = await S.readRequests(
706
+ void 0,
707
+ P.value.start,
708
+ P.value.end
709
+ ).then((q) => q.reverse());
710
+ } catch {
711
+ g.open({
712
+ title: "Something went wrong",
713
+ message: "Error at fetching purchase requests",
714
+ type: "error"
715
+ });
716
+ } finally {
717
+ d.value = !1;
718
+ }
719
+ }
720
+ function F() {
721
+ switch (p) {
722
+ case "receive/request":
723
+ return re();
724
+ case "approval":
725
+ return k();
726
+ }
727
+ }
728
+ function G(q, T) {
729
+ M.value = {
730
+ startDate: q,
731
+ endDate: T
732
+ }, F();
733
+ }
734
+ l.watchLocation(async (q) => {
735
+ if (!q) {
736
+ $.value = [];
737
+ return;
738
+ }
739
+ await F();
740
+ });
741
+ const K = Y(), W = Y(Math.random().toString());
742
+ async function ye(q, T) {
743
+ const oe = Math.random().toString();
744
+ W.value = oe, T ?? (T = Q.value.computeFirst(
745
+ (L) => L.purchaseOrderId === q._id ? L : null
746
+ ) ?? void 0);
747
+ const j = p === "receive/request" ? l.currentLocation : T == null ? void 0 : T.to, O = p === "approval", I = {
748
+ poRequest: T,
749
+ purchaseOrder: {
750
+ ...q,
751
+ status: O && (T != null && T.rejectedAt) ? ge.Enum.REJECT : q.status
752
+ },
753
+ transferTo: j == null ? void 0 : j.name,
754
+ transferToDbName: j == null ? void 0 : j.dbName,
755
+ show: !0,
756
+ canResubmit: !1,
757
+ canApprove: O,
758
+ "onUpdate:show"(L) {
759
+ K.value.show = L;
760
+ },
761
+ scope: p,
762
+ receivedMap: pt(q) ?? {},
763
+ shipments: _.value
764
+ };
765
+ K.value = I;
766
+ }
767
+ async function me(q, T, oe, j, O) {
768
+ const I = ms();
769
+ d.value = !0;
770
+ try {
771
+ await I({
772
+ operate: {
773
+ operation: T,
774
+ doc: q,
775
+ options: (
776
+ // auto receive for supplier to warehouse
777
+ (T === U.enum.confirmDraft || // auto receive for warehouse to warehouse
778
+ T === U.enum.completeReceive) && m.autoReceiveWarehouse ? {
779
+ autoReceive: !0
780
+ } : void 0
781
+ )
782
+ },
783
+ operateV2: {
784
+ _id: q._id,
785
+ _rev: q._rev ?? "",
786
+ action: T === U.enum.submitRequest ? U.enum.confirmDraft : T,
787
+ payloads: O ?? []
788
+ },
789
+ transferTo: j
790
+ }), await new Promise((De) => setTimeout(De, 1e3));
791
+ const ae = ze().currentLocationDBName.startsWith("restaurant_");
792
+ T === U.enum.confirmDraft && q.effectiveAt && ae ? g.open({
793
+ title: "Success",
794
+ message: `${oe}. The backdate will be reflected once your POS has received this change.`,
795
+ type: "success"
796
+ }) : g.open({
797
+ title: "Success",
798
+ message: oe,
799
+ type: "success"
800
+ });
801
+ } catch (L) {
802
+ g.open({
803
+ title: "Something went wrong",
804
+ message: L instanceof Error ? L.message : "Please try again.",
805
+ type: "error"
806
+ }), console.error("Error when submitting PO operation", T, q, L);
807
+ } finally {
808
+ d.value = !1, F();
809
+ }
810
+ }
811
+ async function he(q, T, oe) {
812
+ const j = us[T];
813
+ if (!j) {
814
+ g.open({
815
+ title: "Something went wrong",
816
+ message: `Cannot process order: ${Ct(T)}`,
817
+ type: "error"
818
+ });
819
+ return;
820
+ }
821
+ const { successMessage: O, ...I } = j;
822
+ if (T === U.enum.rejectDraft) {
823
+ let De = "";
824
+ r.open({
825
+ title: I.title,
826
+ message: I.message,
827
+ primaryActions: I.primaryActions,
828
+ contentComponent: ds,
829
+ contentComponentProps: {
830
+ message: I.message,
831
+ onChange: (Ae) => De = Ae
832
+ }
833
+ }).onPrimary(() => {
834
+ const Ae = [];
835
+ Ae.push({
836
+ action: "rejectDraft",
837
+ payload: {
838
+ rejectReason: De
839
+ }
840
+ }), me(q, T, O, oe, Ae);
841
+ });
842
+ return;
843
+ }
844
+ const L = [], ae = ps();
845
+ ae.init(q), (T === U.enum.confirmDraft || T === U.enum.submitRequest) && L.push({
846
+ action: "confirmDraft",
847
+ payload: ae.controller.value.toConfirmDraftData(we())
848
+ }), r.open({
849
+ title: I.title,
850
+ message: I.message,
851
+ primaryActions: I.primaryActions
852
+ }).onPrimary(() => {
853
+ me(q, T, O, oe, L);
854
+ });
855
+ }
856
+ async function de() {
857
+ r.open({
858
+ title: "Upload Transfer",
859
+ primaryActions: {
860
+ text: "Xilnex transfer note",
861
+ close: !0
862
+ },
863
+ secondaryActions: {
864
+ text: "Cancel",
865
+ close: !0
866
+ }
867
+ }).onPrimary(() => {
868
+ const q = {
869
+ show: !0,
870
+ "onUpdate:show"(T) {
871
+ St.value.show = T;
872
+ }
873
+ };
874
+ St.value = q;
875
+ });
876
+ }
877
+ return {
878
+ purchaseOrders: $,
879
+ shipments: _,
880
+ purchaseRequests: Q,
881
+ updateDateRange: G,
882
+ fetchData: F,
883
+ loading: d,
884
+ transferDialogProps: rt,
885
+ promptCreateTransferDialog: _e,
886
+ promptUpdateTransferDialog: ve,
887
+ transferDetailsProps: K,
888
+ promptShowTransferDetails: ye,
889
+ submitAction: he,
890
+ xilnexImportDialogProps: St,
891
+ promptUploadTransferDialog: de,
892
+ emailDialogProps: xt,
893
+ promptEmailDialog: N
894
+ };
895
+ }
896
+ function vr(p) {
897
+ const { po: t, currentLocation: r, business: l, fulfilling: m, por: u } = p, { name: c, address: s, regNo: o, legalName: d } = r.doc.profile, g = {
898
+ name: c,
899
+ legalName: d,
900
+ registrationNumber: o,
901
+ line1: s == null ? void 0 : s.line1,
902
+ line2: s == null ? void 0 : s.line2,
903
+ postcode: s == null ? void 0 : s.postcode,
904
+ city: s == null ? void 0 : s.city,
905
+ state: s == null ? void 0 : s.state,
906
+ country: s == null ? void 0 : s.country
907
+ }, S = {
908
+ name: t.supplier.name,
909
+ phoneNumber: t.supplier.phoneNumber,
910
+ registrationNumber: t.supplier.registrationNumber,
911
+ line1: t.supplier.address.line1,
912
+ line2: t.supplier.address.line2,
913
+ postcode: t.supplier.address.postcode,
914
+ city: t.supplier.address.city,
915
+ state: t.supplier.address.state,
916
+ country: t.supplier.address.country
917
+ }, R = is(t), $ = t.items.map((N) => {
918
+ const { sku: re, measurement: k } = N, F = xe(
919
+ ls(N.sku, t.deliveryOrder || []),
920
+ !1
921
+ ), G = R(N);
922
+ return {
923
+ code: re.code,
924
+ description: re.name,
925
+ quantity: xe(N.quantity, !1),
926
+ unit: (k == null ? void 0 : k.abbrev) || re.unit.abbrev,
927
+ received: F,
928
+ cost: G ? `${G.currency} ${et.toFormatString({
929
+ value: G
930
+ })}` : void 0
931
+ };
932
+ }), _ = t.deliveryOrder.map((N) => ({
933
+ createdAt: Dt(new Date(N.createdAt)),
934
+ ref: N.deliveryOrderNumber,
935
+ remark: N.remark || "",
936
+ items: N.received.map((re) => {
937
+ var k;
938
+ return {
939
+ code: re.sku.code,
940
+ description: re.sku.name,
941
+ quantity: xe(re.amount),
942
+ unit: ((k = re.measurement) == null ? void 0 : k.abbrev) || re.sku.unit.abbrev
943
+ };
944
+ })
945
+ })), M = [
946
+ // Production
947
+ "67ca5d2c80bd0e001c5bf5bc",
948
+ // Dev
949
+ "6880b36a3054c5001db19218"
950
+ ];
951
+ let P = "Inventory Receive Note";
952
+ if (t.supplier.internal ? (P = "Inventory Transfer Note", M.includes((l == null ? void 0 : l._id) || "") && (P = "Stock Request")) : P = "Purchase Order", u) {
953
+ const N = u.from.dbName;
954
+ r.dbName === N || (P = "Inventory Receive Note");
955
+ }
956
+ const se = {
957
+ title: P,
958
+ businessName: l == null ? void 0 : l.name,
959
+ logo: l == null ? void 0 : l.thumbnail,
960
+ orderNumber: t.seqNumber.toString(),
961
+ createdAt: at(t._id),
962
+ ref: t.ref || "",
963
+ remark: t.remark || "",
964
+ buyer: g,
965
+ supplier: S,
966
+ items: $,
967
+ status: t.status,
968
+ deliveryOrders: _
969
+ }, le = new URL(window.location.href), _e = m && (t.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
970
+ le.pathname = le.hostname.includes("portal.feedme") ? `/inventory/${_e}` : `/${_e}`;
971
+ const ve = Bs.compressToEncodedURIComponent(JSON.stringify(se));
972
+ le.searchParams.append("data", ve), window.open(le.href, "_blank", "noreferrer");
973
+ }
974
+ const Ke = {
975
+ submitRequest: {
976
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
977
+ color: "text-fm-color-typo-primary",
978
+ value: U.enum.submitRequest
979
+ },
980
+ confirmDraft: {
981
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
982
+ color: "text-fm-color-typo-primary",
983
+ value: U.enum.confirmDraft
984
+ },
985
+ cancelDraft: {
986
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
987
+ color: "text-fm-color-typo-error",
988
+ value: U.enum.cancelDraft
989
+ },
990
+ approveRequest: {
991
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
992
+ color: "text-fm-color-typo-primary",
993
+ value: U.enum.approveRequest
994
+ },
995
+ rejectRequest: {
996
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
997
+ color: "text-fm-color-typo-error",
998
+ value: U.enum.rejectRequest
999
+ },
1000
+ processRequest: {
1001
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1002
+ color: "text-fm-color-typo-primary",
1003
+ value: U.enum.processRequest
1004
+ },
1005
+ receiveStock: {
1006
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1007
+ color: "text-fm-color-typo-primary",
1008
+ value: U.enum.receiveStock
1009
+ },
1010
+ completeReceive: {
1011
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1012
+ color: "text-fm-color-typo-primary",
1013
+ value: U.enum.completeReceive
1014
+ },
1015
+ closeRequest: {
1016
+ translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1017
+ color: "system-error-300",
1018
+ value: U.enum.closeRequest
1019
+ },
1020
+ approveDraft: {
1021
+ translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1022
+ color: "text-fm-color-typo-primary",
1023
+ value: U.enum.approveDraft
1024
+ },
1025
+ rejectDraft: {
1026
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1027
+ color: "text-fm-color-typo-error",
1028
+ value: U.enum.rejectDraft
1029
+ },
1030
+ returnStock: {
1031
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1032
+ color: "text-fm-color-typo-primary",
1033
+ value: U.enum.returnStock
1034
+ }
1035
+ };
1036
+ function fs() {
1037
+ const p = Ye();
1038
+ return {
1039
+ ableToMarkReceived(t) {
1040
+ if (!t || t.status !== ge.enum.RECEIVING || p.useOperatePurchaseOrderV2) return !1;
1041
+ const l = ze().currentLocationDBName;
1042
+ return `${t.supplier.internal}_${t.supplier._id}` !== l;
1043
+ },
1044
+ ableToMarkApproved(t) {
1045
+ return !(!t || (t == null ? void 0 : t.status) !== ge.enum.REQUESTING);
1046
+ },
1047
+ ableToCreateFulfillment(t, r) {
1048
+ var u, c;
1049
+ if (!p.acceptRequireFulfillment || !t || !r || t.status !== ge.enum.PROCESSING || !r.processedAt)
1050
+ return !1;
1051
+ const l = (u = r == null ? void 0 : r.from) == null ? void 0 : u.dbName, m = (c = r == null ? void 0 : r.to) == null ? void 0 : c.dbName;
1052
+ return !(l.startsWith("restaurant_") && m.startsWith("restaurant_"));
1053
+ }
1054
+ };
1055
+ }
1056
+ function vs() {
1057
+ const p = B(() => [
1058
+ {
1059
+ action: Kt.Action.manage,
1060
+ subject: Kt.Subject.Business.inventory_orderDraftApproval
1061
+ }
1062
+ ]), { hasPermission: t } = rr(p);
1063
+ return {
1064
+ hasOrderDraftPermission: ws(t)
1065
+ };
1066
+ }
1067
+ function Si(p, t, r) {
1068
+ const l = ze(), m = ht(), u = yt(), c = fs(), { t: s } = vt(), { hasOrderDraftPermission: o } = vs(), d = Ye(), g = B(
1069
+ () => d.enablePrintTemplate ? [Ee[Ce.PrintCustom]] : []
1070
+ ), S = B(
1071
+ () => d.enablePurchaseOrderEmail ? [Ee[Ce.Email]] : []
1072
+ );
1073
+ function R(N) {
1074
+ switch (N.status) {
1075
+ case "DRAFT":
1076
+ return [
1077
+ Ee[Ce.Update],
1078
+ Ee[Ce.Details],
1079
+ N.supplier.internal === "restaurant" || N.supplier.internal === "warehouse" ? Ke[U.enum.submitRequest] : Ke[U.enum.confirmDraft],
1080
+ Ke[U.enum.cancelDraft]
1081
+ ];
1082
+ case "RECEIVING":
1083
+ return [
1084
+ ...c.ableToMarkReceived(N) ? [Ke[U.enum.completeReceive]] : [],
1085
+ Ee[Ce.Details],
1086
+ Ee[Ce.Print],
1087
+ ...g.value,
1088
+ ...S.value
1089
+ ];
1090
+ case "PENDING_APPROVAL": {
1091
+ const k = [Ee[Ce.Details]];
1092
+ return o.value && k.push(
1093
+ Ee[Ce.Update],
1094
+ Ke[U.enum.approveDraft],
1095
+ Ke[U.enum.rejectDraft]
1096
+ ), k;
1097
+ }
1098
+ case "REQUESTING":
1099
+ return p === "receive/request" ? [
1100
+ Ee[Ce.Details],
1101
+ Ee[Ce.Print],
1102
+ ...g.value
1103
+ ] : [
1104
+ Ke[U.enum.approveRequest],
1105
+ Ke[U.enum.rejectRequest],
1106
+ Ee[Ce.Details]
1107
+ // DefaultRowActions[RowActionEnum.Print]
1108
+ ];
1109
+ case "PROCESSING":
1110
+ return [
1111
+ Ee[Ce.Details],
1112
+ Ee[Ce.Print],
1113
+ ...g.value
1114
+ ];
1115
+ case "COMPLETE":
1116
+ case "CANCEL":
1117
+ default:
1118
+ return [
1119
+ Ee[Ce.Details],
1120
+ Ee[Ce.Print],
1121
+ ...g.value
1122
+ ];
1123
+ }
1124
+ }
1125
+ function $(N) {
1126
+ return Object.values(U.enum).includes(N);
1127
+ }
1128
+ async function _(N, re, k) {
1129
+ var G, K, W, ye, me, he, de;
1130
+ const F = rs(re);
1131
+ if (N === Ce.Print || N === Ce.PrintCustom) {
1132
+ const q = (k == null ? void 0 : k.toInventoryLocation) ?? l.currentLocation;
1133
+ if (q.type === "restaurant") {
1134
+ const oe = l.locationRestaurantFromCore(q.doc._id);
1135
+ oe !== null && (q.doc = oe);
1136
+ }
1137
+ ((G = k == null ? void 0 : k.netSuite) != null && G.refNo || (K = F.netSuite) != null && K.refNo) && (F.ref = [((W = k == null ? void 0 : k.netSuite) == null ? void 0 : W.refNo) || ((ye = F.netSuite) == null ? void 0 : ye.refNo)].filter((oe) => oe).join(" "));
1138
+ const T = {
1139
+ po: F,
1140
+ currentLocation: q,
1141
+ business: u.currentBusiness.value,
1142
+ fulfilling: p === "approval",
1143
+ por: k
1144
+ };
1145
+ if (N === Ce.PrintCustom) {
1146
+ const oe = cs(T);
1147
+ oe && (le.value = oe.html, _e.value = oe.templateName, ve.value = oe.isDefault, se.value = !0);
1148
+ } else
1149
+ vr(T);
1150
+ return;
1151
+ }
1152
+ if (N === Ce.Details) {
1153
+ t.promptShowTransferDetails(F, k);
1154
+ return;
1155
+ }
1156
+ if (N === Ce.Update) {
1157
+ (me = t.promptUpdateTransferDialog) == null || me.call(t, F);
1158
+ return;
1159
+ }
1160
+ if (N === Ce.Email) {
1161
+ (he = t.promptEmailDialog) == null || he.call(t, F);
1162
+ return;
1163
+ }
1164
+ if ($(N)) {
1165
+ t.submitAction(re, N, (de = k == null ? void 0 : k.to) == null ? void 0 : de.dbName);
1166
+ return;
1167
+ }
1168
+ }
1169
+ function M() {
1170
+ var re;
1171
+ const N = [
1172
+ {
1173
+ accessorKey: "seqNumber",
1174
+ header: () => s("inventory.transfer.table.seqNo"),
1175
+ enableSorting: !0,
1176
+ size: 80,
1177
+ sortUndefined: "last"
1178
+ },
1179
+ {
1180
+ accessorKey: "_id",
1181
+ header: () => s("inventory.transfer.table.createdAt"),
1182
+ cell(k) {
1183
+ return at(`${k.getValue()}`);
1184
+ },
1185
+ enableSorting: !0
1186
+ },
1187
+ {
1188
+ accessorKey: "supplier.name",
1189
+ header: () => s("inventory.transfer.table.transferFrom"),
1190
+ enableSorting: !0,
1191
+ size: 200
1192
+ },
1193
+ {
1194
+ accessorKey: "items.length",
1195
+ header: () => s("inventory.transfer.table.noOfItems"),
1196
+ cell: (k) => {
1197
+ const F = k.row.original.version || "1", G = k.getValue();
1198
+ return X("div", { class: "flex items-center gap-2" }, [
1199
+ G,
1200
+ F !== "1" ? X(
1201
+ "div",
1202
+ { class: "py-3" },
1203
+ X(
1204
+ tt,
1205
+ X(
1206
+ "div",
1207
+ {
1208
+ class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
1209
+ },
1210
+ `v${F}`
1211
+ )
1212
+ )
1213
+ ) : null
1214
+ ]);
1215
+ },
1216
+ enableSorting: !1,
1217
+ meta: {
1218
+ width: "10rem"
1219
+ }
1220
+ },
1221
+ {
1222
+ accessorKey: "ref",
1223
+ header: () => s("inventory.transfer.table.reference"),
1224
+ enableSorting: !1,
1225
+ size: "auto"
1226
+ },
1227
+ ...(re = u.sessionUser.value) != null && re.role.isAdmin ? [
1228
+ {
1229
+ id: "statusForAdmin",
1230
+ header: () => X(tt, {}, () => `${s("inventory.transfer.table.status")}`),
1231
+ cell(k) {
1232
+ return k.row.original.status;
1233
+ },
1234
+ enableSorting: !0,
1235
+ size: 200
1236
+ }
1237
+ ] : [],
1238
+ {
1239
+ accessorKey: "status",
1240
+ header: () => s("inventory.transfer.table.status"),
1241
+ cell(k) {
1242
+ const F = k.getValue(), G = pt(k.row.original), { partial: K, over: W } = kt(G), ye = Ot(F ?? "", K, W);
1243
+ let me = s(`inventory.transfer.status.${ye}`), he = `${F ?? ""}`.toLocaleLowerCase("en-us");
1244
+ ye === ge.enum.CLOSE && (me = `${s(`inventory.transfer.status.${ge.enum.COMPLETE}`)}`), ye === "PARTIAL_RECEIVED" && he === ge.enum.PROCESSING.toLocaleLowerCase("en-us") && (he = ge.enum.RECEIVING.toLocaleLowerCase("en-us"));
1245
+ let de = null;
1246
+ const q = r.value.find((T) => T.ref === k.row.original._id);
1247
+ if (q != null && q.milestones && q.milestones.length > 0) {
1248
+ const T = q.milestones[q.milestones.length - 1];
1249
+ if (T.estimatedTime) {
1250
+ const oe = new Date(T.estimatedTime), j = oe.getDate().toString().padStart(2, "0");
1251
+ de = `${oe.toLocaleString("en-US", { month: "short" })} ${j}`;
1252
+ }
1253
+ }
1254
+ return X(
1255
+ "div",
1256
+ {
1257
+ class: "flex"
1258
+ },
1259
+ [
1260
+ X(
1261
+ "div",
1262
+ { class: "flex items-center" },
1263
+ X(
1264
+ "div",
1265
+ {
1266
+ class: [
1267
+ "fm-status-badge",
1268
+ `fm-status-badge-${he}`,
1269
+ W && "fm-status-badge-error"
1270
+ ].filter(Boolean).join(" ")
1271
+ },
1272
+ `${me}`
1273
+ )
1274
+ ),
1275
+ ...de ? [
1276
+ X(
1277
+ "div",
1278
+ {
1279
+ class: "flex items-center gap-1 ml-2"
1280
+ },
1281
+ [
1282
+ X(dt.FmIcon, {
1283
+ name: "local_shipping",
1284
+ size: "md",
1285
+ color: "neutral-gray-400"
1286
+ }),
1287
+ X(
1288
+ "span",
1289
+ { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
1290
+ de
1291
+ )
1292
+ ]
1293
+ )
1294
+ ] : []
1295
+ ]
1296
+ );
1297
+ },
1298
+ enableSorting: !0,
1299
+ size: 150
1300
+ },
1301
+ {
1302
+ id: "action",
1303
+ cell(k) {
1304
+ const F = k.row.original, G = R(F);
1305
+ return Bt(G, (K) => _(K, F));
1306
+ },
1307
+ enableSorting: !1,
1308
+ size: 40,
1309
+ meta: {
1310
+ cellClass: "",
1311
+ headerClass: ""
1312
+ }
1313
+ }
1314
+ ];
1315
+ if (m.isEnabled) {
1316
+ const k = [
1317
+ {
1318
+ id: "netsuiteTransferOrder",
1319
+ accessorFn: (F) => {
1320
+ var G;
1321
+ return (G = F.netSuite) != null && G.id ? `${F.netSuite.refNo} (${F.netSuite.id})` : "N/A";
1322
+ },
1323
+ header: () => "NetSuite Order (ID)",
1324
+ cell(F) {
1325
+ var K;
1326
+ const G = F.row.original;
1327
+ return (K = G.netSuite) != null && K.id ? `${G.netSuite.refNo} (${G.netSuite.id})` : "N/A";
1328
+ },
1329
+ enableSorting: !1,
1330
+ size: 200,
1331
+ meta: {
1332
+ cellClass: "",
1333
+ headerClass: ""
1334
+ }
1335
+ },
1336
+ {
1337
+ id: "netsuiteTransactionNumber",
1338
+ accessorFn: (F) => {
1339
+ var G, K;
1340
+ return ((K = (G = F.netSuite) == null ? void 0 : G.additionalInfo) == null ? void 0 : K.transactionnumber) ?? "N/A";
1341
+ },
1342
+ header: () => "NetSuite Transaction No.",
1343
+ cell(F) {
1344
+ var K, W;
1345
+ return ((W = (K = F.row.original.netSuite) == null ? void 0 : K.additionalInfo) == null ? void 0 : W.transactionnumber) ?? "N/A";
1346
+ },
1347
+ enableSorting: !1,
1348
+ size: 200,
1349
+ meta: {
1350
+ cellClass: "",
1351
+ headerClass: ""
1352
+ }
1353
+ }
1354
+ ];
1355
+ N.splice(N.length - 1, 0, ...k);
1356
+ }
1357
+ return N;
1358
+ }
1359
+ function P() {
1360
+ var re;
1361
+ const N = [
1362
+ {
1363
+ accessorKey: "purchaseOrder.seqNumber",
1364
+ header: () => s("inventory.transfer.table.seqNo"),
1365
+ enableSorting: !0,
1366
+ size: 80,
1367
+ sortUndefined: "last"
1368
+ },
1369
+ {
1370
+ accessorKey: "purchaseOrder._id",
1371
+ header: () => s("inventory.transfer.table.createdAt"),
1372
+ cell(k) {
1373
+ return at(`${k.getValue()}`);
1374
+ },
1375
+ enableSorting: !0
1376
+ },
1377
+ {
1378
+ accessorKey: "to.name",
1379
+ header: () => s("inventory.transfer.table.transferTo"),
1380
+ enableSorting: !1,
1381
+ size: 200
1382
+ },
1383
+ {
1384
+ accessorKey: "purchaseOrder.items.length",
1385
+ header: () => s("inventory.transfer.table.noOfItems"),
1386
+ enableSorting: !1
1387
+ },
1388
+ {
1389
+ accessorKey: "purchaseOrder.ref",
1390
+ header: () => s("inventory.transfer.table.reference"),
1391
+ enableSorting: !1,
1392
+ size: "auto"
1393
+ },
1394
+ ...(re = u.sessionUser.value) != null && re.role.isAdmin ? [
1395
+ {
1396
+ id: "statusForAdmin",
1397
+ header: () => X(tt, {}, () => `${s("inventory.transfer.table.status")}`),
1398
+ cell(k) {
1399
+ return k.row.original.status;
1400
+ },
1401
+ enableSorting: !0,
1402
+ size: 200
1403
+ }
1404
+ ] : [],
1405
+ {
1406
+ accessorKey: "purchaseOrder.status",
1407
+ header: () => s("inventory.transfer.table.status"),
1408
+ cell(k) {
1409
+ const F = k.row.original, G = k.getValue();
1410
+ if (!F.purchaseOrder)
1411
+ return X(dt.FmChip, {
1412
+ label: "N/A",
1413
+ compact: !0
1414
+ });
1415
+ const K = pt(F.purchaseOrder), { partial: W, over: ye } = kt(K), me = Ot(G ?? "", W, ye);
1416
+ let he = s(`inventory.transfer.status.${me}`), de = `${G ?? ""}`.toLocaleLowerCase("en-us");
1417
+ return me === ge.enum.CLOSE && (he = `${s(`inventory.transfer.status.${ge.enum.COMPLETE}`)}`), me === "PARTIAL_RECEIVED" && de === ge.enum.PROCESSING.toLocaleLowerCase("en-us") && (de = ge.enum.RECEIVING.toLocaleLowerCase("en-us")), F.rejectedAt && (he = s("inventory.transfer.status.REJECT"), de = ge.enum.REJECT.toLocaleLowerCase("en-us")), X(
1418
+ "div",
1419
+ {
1420
+ class: "flex"
1421
+ },
1422
+ X(
1423
+ "div",
1424
+ {
1425
+ class: [
1426
+ "fm-status-badge",
1427
+ `fm-status-badge-${de}`,
1428
+ ye && "fm-status-badge-error"
1429
+ ].filter(Boolean).join(" ")
1430
+ },
1431
+ `${he}`
1432
+ )
1433
+ );
1434
+ },
1435
+ enableSorting: !0
1436
+ },
1437
+ {
1438
+ id: "action",
1439
+ cell(k) {
1440
+ const F = k.row.original, K = (F.purchaseOrder ? R(F.purchaseOrder) : []).map((W) => W.value === Ce.Print ? {
1441
+ ...W,
1442
+ translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
1443
+ } : W);
1444
+ return Bt(
1445
+ K,
1446
+ (W) => F.purchaseOrder ? _(W, F.purchaseOrder, F) : void 0
1447
+ );
1448
+ },
1449
+ enableSorting: !1,
1450
+ size: 40,
1451
+ meta: {
1452
+ cellClass: "",
1453
+ headerClass: ""
1454
+ }
1455
+ }
1456
+ ];
1457
+ if (m.isEnabled) {
1458
+ const k = [
1459
+ {
1460
+ id: "netsuiteTransferOrder",
1461
+ accessorFn: (F) => {
1462
+ var G;
1463
+ return (G = F.netSuite) != null && G.id ? `${F.netSuite.refNo} (${F.netSuite.id})` : "N/A";
1464
+ },
1465
+ header: () => "NetSuite Order (ID)",
1466
+ cell(F) {
1467
+ var K;
1468
+ const G = F.row.original;
1469
+ return (K = G.netSuite) != null && K.id ? `${G.netSuite.refNo} (${G.netSuite.id})` : "N/A";
1470
+ },
1471
+ enableSorting: !1,
1472
+ size: 200,
1473
+ meta: {
1474
+ cellClass: "",
1475
+ headerClass: ""
1476
+ }
1477
+ },
1478
+ {
1479
+ id: "netsuiteTransactionNumber",
1480
+ accessorFn: (F) => {
1481
+ var G, K;
1482
+ return ((K = (G = F.netSuite) == null ? void 0 : G.additionalInfo) == null ? void 0 : K.transactionnumber) ?? "N/A";
1483
+ },
1484
+ header: () => "NetSuite Transaction No.",
1485
+ cell(F) {
1486
+ var K, W;
1487
+ return ((W = (K = F.row.original.netSuite) == null ? void 0 : K.additionalInfo) == null ? void 0 : W.transactionnumber) ?? "N/A";
1488
+ },
1489
+ enableSorting: !1,
1490
+ size: 200,
1491
+ meta: {
1492
+ cellClass: "",
1493
+ headerClass: ""
1494
+ }
1495
+ }
1496
+ ];
1497
+ N.splice(N.length - 2, 0, ...k);
1498
+ }
1499
+ return N;
1500
+ }
1501
+ const Q = B(() => p === "receive/request" ? M() : P()), se = Y(!1), le = Y(""), _e = Y(""), ve = Y(!1);
1502
+ return {
1503
+ columnDefs: Q,
1504
+ showCustomPrintDialog: se,
1505
+ customPrintHtml: le,
1506
+ customPrintTemplateName: _e,
1507
+ customPrintIsDefault: ve
1508
+ };
1509
+ }
1510
+ const yr = { class: "flex flex-col gap-4 border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, hr = { class: "flex items-center justify-between" }, br = {
1511
+ key: 0,
1512
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
1513
+ }, gr = { class: "flex justify-between items-start py-1 gap-4" }, _r = { class: "flex-1 min-w-0 flex flex-col gap-2" }, xr = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Sr = {
1514
+ key: 0,
1515
+ class: "border-b border-fm-color-stroke-secondary"
1516
+ }, Rt = /* @__PURE__ */ Fe({
1517
+ __name: "PriceAdjustmentEditor",
1518
+ props: {
1519
+ controller: {},
1520
+ state: {}
1521
+ },
1522
+ setup(p) {
1523
+ const t = p, r = B(() => t.state.adjustments ?? []);
1524
+ function l(o) {
1525
+ return +xe(o.dinero);
1526
+ }
1527
+ function m() {
1528
+ t.controller.addAdjustment();
1529
+ }
1530
+ function u(o, d) {
1531
+ t.controller.updateAdjustment(o, d);
1532
+ }
1533
+ function c(o, d) {
1534
+ t.controller.updateAdjustment(o, null, d);
1535
+ }
1536
+ function s(o) {
1537
+ t.controller.removeAdjustment(o);
1538
+ }
1539
+ return (o, d) => {
1540
+ const g = Z("FmButton"), S = Z("FmTextField"), R = Z("FmStepperField");
1541
+ return n(), f("div", yr, [
1542
+ e("div", hr, [
1543
+ d[0] || (d[0] = e("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-secondary" }, "Price adjustments", -1)),
1544
+ C(g, {
1545
+ variant: "tertiary",
1546
+ label: "Add adjustment",
1547
+ "prepend-icon": "add",
1548
+ size: "md",
1549
+ onClick: m
1550
+ })
1551
+ ]),
1552
+ r.value.length === 0 ? (n(), f("div", br, " No price adjustments ")) : A("", !0),
1553
+ (n(!0), f(Oe, null, Pe(r.value, ($, _) => (n(), f("div", {
1554
+ key: $.id
1555
+ }, [
1556
+ e("div", gr, [
1557
+ e("div", _r, [
1558
+ C(S, {
1559
+ "model-value": $.name,
1560
+ "onUpdate:modelValue": (M) => u($.id, M),
1561
+ label: "Name",
1562
+ placeholder: "e.g. Freight, Discount",
1563
+ size: "md"
1564
+ }, null, 8, ["model-value", "onUpdate:modelValue"])
1565
+ ]),
1566
+ e("div", xr, [
1567
+ C(R, {
1568
+ "model-value": l($),
1569
+ "onUpdate:modelValue": (M) => c($.id, M),
1570
+ label: "Amount (+/-)",
1571
+ step: 0.01,
1572
+ placeholder: "0.00",
1573
+ size: "md",
1574
+ "append-text": y(we)()
1575
+ }, null, 8, ["model-value", "onUpdate:modelValue", "append-text"])
1576
+ ]),
1577
+ C(g, {
1578
+ variant: "tertiary",
1579
+ "prepend-icon": "delete",
1580
+ size: "md",
1581
+ class: "mt-6",
1582
+ onClick: (M) => s($.id)
1583
+ }, null, 8, ["onClick"])
1584
+ ]),
1585
+ _ < r.value.length - 1 ? (n(), f("div", Sr)) : A("", !0)
1586
+ ]))), 128))
1587
+ ]);
1588
+ };
1589
+ }
1590
+ });
1591
+ function Nt(p) {
1592
+ const t = ct(
1593
+ Ht({
1594
+ currency: p.currency,
1595
+ adjustments: p.adjustments ?? []
1596
+ })
1597
+ ), r = ct(t.value.state());
1598
+ function l(c) {
1599
+ const s = () => {
1600
+ r.value = c.state();
1601
+ };
1602
+ return c.addListener(s), () => c.removeListener(s);
1603
+ }
1604
+ let m = l(t.value);
1605
+ function u(c) {
1606
+ m(), t.value = Ht({
1607
+ currency: p.currency,
1608
+ adjustments: c ?? []
1609
+ }), m = l(t.value), r.value = t.value.state();
1610
+ }
1611
+ return es(() => m()), { controller: t, state: r, reset: u };
1612
+ }
1613
+ const kr = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Or = { class: "flex flex-col gap-8" }, wr = { class: "flex w-full justify-end gap-16" }, $r = /* @__PURE__ */ Fe({
1614
+ __name: "FulfillmentForm",
1615
+ props: {
1616
+ purchaseOrder: {},
1617
+ confirm: { type: Function }
1618
+ },
1619
+ emits: ["update:show"],
1620
+ setup(p, { emit: t }) {
1621
+ const r = p, l = $s({
1622
+ id: "",
1623
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1624
+ items: []
1625
+ }), m = Y(), u = t, c = (o) => o != null && o !== "";
1626
+ ts(() => {
1627
+ r.purchaseOrder && (l.items = r.purchaseOrder.items.map((o) => ({
1628
+ id: o.id,
1629
+ sku: o.sku,
1630
+ measurement: o.measurement,
1631
+ amount: o.quantity ?? { amount: 1, precision: 0 }
1632
+ })));
1633
+ });
1634
+ const s = B(() => l.items.length <= 10);
1635
+ return (o, d) => {
1636
+ const g = Z("FmTable"), S = Z("FmButton"), R = Z("FmForm");
1637
+ return n(), ue(R, {
1638
+ ref_key: "formRef",
1639
+ ref: m,
1640
+ class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
1641
+ onValidationFailed: console.log,
1642
+ onValidationSuccess: d[1] || (d[1] = () => r.confirm(l))
1643
+ }, {
1644
+ default: ne(() => [
1645
+ d[2] || (d[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
1646
+ e("div", kr, [
1647
+ e("div", Or, [
1648
+ C(g, {
1649
+ "column-defs": [
1650
+ {
1651
+ header: "Code",
1652
+ cell: ($) => {
1653
+ const _ = r.purchaseOrder.items.find((M) => c($.row.original.id) ? M.id === $.row.original.id : M.sku._id === $.row.original.sku._id);
1654
+ return X(
1655
+ y(dt).FmTooltip,
1656
+ {
1657
+ content: _.code,
1658
+ placement: "top",
1659
+ variant: "plain",
1660
+ zIndex: 50
1661
+ },
1662
+ X(
1663
+ "span",
1664
+ {
1665
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
1666
+ },
1667
+ _.code
1668
+ )
1669
+ );
1670
+ }
1671
+ },
1672
+ {
1673
+ header: "Name",
1674
+ cell: ($) => {
1675
+ const _ = r.purchaseOrder.items.find((M) => c($.row.original.id) ? M.id === $.row.original.id : M.sku._id === $.row.original.sku._id);
1676
+ return X(
1677
+ y(dt).FmTooltip,
1678
+ {
1679
+ content: _.name,
1680
+ placement: "top",
1681
+ variant: "plain",
1682
+ zIndex: 50
1683
+ },
1684
+ X(
1685
+ "span",
1686
+ {
1687
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
1688
+ },
1689
+ _.name
1690
+ )
1691
+ );
1692
+ }
1693
+ },
1694
+ {
1695
+ header: "Amount",
1696
+ cell: ($) => {
1697
+ const _ = $.row.original, M = r.purchaseOrder.items.find((Q) => c(_.id) ? Q.id === _.id : Q.sku._id === _.sku._id), P = _.amount ?? {
1698
+ amount: 1,
1699
+ precision: 0
1700
+ };
1701
+ return X(Ws, {
1702
+ style: {
1703
+ flex: "1 1 0%"
1704
+ },
1705
+ modelValue: {
1706
+ amount: P,
1707
+ measurement: _.measurement ?? null
1708
+ },
1709
+ key: c(_.id) ? _.id : _.sku._id,
1710
+ unit: _.sku.unit,
1711
+ "onUpdate:modelValue": (Q) => {
1712
+ if (!Q) return;
1713
+ const se = l.items.find((le) => c(_.id) ? le.id === _.id : le.sku._id === _.sku._id);
1714
+ se && (se.amount = Q.amount);
1715
+ },
1716
+ disableUnit: !0,
1717
+ rules: [
1718
+ y(Qs)(
1719
+ +y(xe)({ amount: 0, precision: 0 })
1720
+ ),
1721
+ y(Ys)(+y(xe)(M.quantity))
1722
+ ],
1723
+ applyDefaultRules: !0
1724
+ });
1725
+ }
1726
+ }
1727
+ ],
1728
+ "row-data": l.items,
1729
+ "hide-footer": s.value
1730
+ }, null, 8, ["column-defs", "row-data", "hide-footer"])
1731
+ ])
1732
+ ]),
1733
+ e("div", wr, [
1734
+ C(S, {
1735
+ class: "px-16",
1736
+ label: "Confirm",
1737
+ size: "md",
1738
+ variant: "primary",
1739
+ type: "submit"
1740
+ }),
1741
+ C(S, {
1742
+ class: "px-16",
1743
+ label: "Cancel",
1744
+ size: "md",
1745
+ variant: "secondary",
1746
+ onClick: d[0] || (d[0] = () => u("update:show", !1))
1747
+ })
1748
+ ])
1749
+ ]),
1750
+ _: 1
1751
+ }, 8, ["onValidationFailed"]);
1752
+ };
1753
+ }
1754
+ }), ot = {
1755
+ submitRequest: {
1756
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1757
+ color: "primary",
1758
+ buttonVariant: Ue.Primary
1759
+ },
1760
+ confirmDraft: {
1761
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1762
+ color: "primary",
1763
+ buttonVariant: Ue.Primary
1764
+ },
1765
+ cancelDraft: {
1766
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1767
+ color: "system-error-300",
1768
+ buttonVariant: Ue.Destructive
1769
+ },
1770
+ approveDraft: {
1771
+ translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1772
+ color: "primary",
1773
+ buttonVariant: Ue.Primary
1774
+ },
1775
+ rejectDraft: {
1776
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1777
+ color: "system-error-300",
1778
+ buttonVariant: Ue.Destructive
1779
+ },
1780
+ approveRequest: {
1781
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1782
+ color: "primary",
1783
+ buttonVariant: Ue.Primary
1784
+ },
1785
+ processRequest: {
1786
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1787
+ color: "primary",
1788
+ buttonVariant: Ue.Primary
1789
+ },
1790
+ receiveStock: {
1791
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1792
+ color: "primary",
1793
+ buttonVariant: Ue.Primary,
1794
+ available: !1
1795
+ },
1796
+ completeReceive: {
1797
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1798
+ color: "primary",
1799
+ buttonVariant: Ue.Plain
1800
+ },
1801
+ rejectRequest: {
1802
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1803
+ color: "system-error-300",
1804
+ buttonVariant: Ue.Destructive
1805
+ },
1806
+ closeRequest: {
1807
+ translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1808
+ color: "system-error-300",
1809
+ buttonVariant: Ue.Destructive,
1810
+ available: !1
1811
+ },
1812
+ returnStock: {
1813
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1814
+ color: "primary",
1815
+ buttonVariant: Ue.Primary,
1816
+ available: !1
1817
+ }
1818
+ }, Cr = { class: "flex flex-row-reverse" }, Dr = /* @__PURE__ */ Fe({
1819
+ __name: "NetSuiteSync",
1820
+ props: {
1821
+ poRequest: {},
1822
+ purchaseOrder: {},
1823
+ isTransferBetweenOutlets: { type: Boolean },
1824
+ scope: {}
1825
+ },
1826
+ setup(p) {
1827
+ const t = p, r = ht(), l = Je(), m = bt(), u = Y(!1);
1828
+ B(() => {
1829
+ var g, S, R, $;
1830
+ let s = !0;
1831
+ r.isEnabled || (s = !1);
1832
+ const o = t.purchaseOrder, d = t.poRequest;
1833
+ return o && ((g = o == null ? void 0 : o.supplier) != null && g.internal ? (!d && o.status == ge.enum.DRAFT && (s = !1), d && !((S = d == null ? void 0 : d.netSuite) != null && S.id) && (s = !1), t.isTransferBetweenOutlets && (s = !1)) : ((o == null ? void 0 : o.status) !== ge.enum.REQUESTING && o.supplier.internal && (s = !1), !d && !((R = o == null ? void 0 : o.netSuite) != null && R.id) && (s = !1), !d && (($ = o == null ? void 0 : o.netSuite) != null && $.id) && (o == null ? void 0 : o.status) == ge.enum.REQUESTING && (s = !1))), s;
1834
+ });
1835
+ async function c() {
1836
+ u.value || m.open({
1837
+ title: "Sync with NetSuite",
1838
+ contentComponent: X("div", [
1839
+ X("p", "Are you sure you want to sync now?"),
1840
+ X("br"),
1841
+ X(
1842
+ "p",
1843
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1844
+ "Please wait a moment before syncing manually to avoid unnecessary actions."
1845
+ )
1846
+ ]),
1847
+ primaryActions: {
1848
+ text: "Sync",
1849
+ close: !0,
1850
+ variant: "destructive"
1851
+ },
1852
+ secondaryActions: { text: "Not now", close: !0 }
1853
+ }).onPrimary(async () => {
1854
+ var s, o, d, g, S, R, $;
1855
+ try {
1856
+ u.value = !0;
1857
+ const _ = ((s = t.purchaseOrder) == null ? void 0 : s._id) || ((o = t.poRequest) == null ? void 0 : o.purchaseOrderId) || "", M = (d = t.poRequest) == null ? void 0 : d.to.dbName;
1858
+ await r.syncPurchaseOrder({
1859
+ purchaseOrderId: _,
1860
+ locationId: t.scope === "approval" ? M : void 0,
1861
+ netsuiteId: ((S = (g = t.purchaseOrder) == null ? void 0 : g.netSuite) == null ? void 0 : S.id) || (($ = (R = t.poRequest) == null ? void 0 : R.netSuite) == null ? void 0 : $.id)
1862
+ }), l.open({
1863
+ title: "Sync with NetSuite",
1864
+ message: "Requested to sync with NetSuite. Please wait a moment.",
1865
+ type: "success"
1866
+ }), await new Promise((P) => setTimeout(P, 5e3)), u.value = !1;
1867
+ } catch (_) {
1868
+ console.log("Failed to sync with NetSuite", _), l.open({
1869
+ title: "Error",
1870
+ message: "Failed to sync with NetSuite",
1871
+ type: "error"
1872
+ }), u.value = !1;
1873
+ }
1874
+ });
1875
+ }
1876
+ return (s, o) => {
1877
+ const d = Z("FmButton");
1878
+ return n(), f("div", Cr, [
1879
+ C(d, {
1880
+ "prepend-icon": "sync",
1881
+ variant: "secondary",
1882
+ label: "Sync",
1883
+ loading: u.value,
1884
+ onClick: c,
1885
+ "text-color": "primary",
1886
+ "bg-color": "transparent",
1887
+ "border-color": "primary"
1888
+ }, null, 8, ["loading"])
1889
+ ]);
1890
+ };
1891
+ }
1892
+ }), Ar = {
1893
+ key: 0,
1894
+ class: "flex flex-col gap-8"
1895
+ }, Rr = { class: "flex flex-col gap-4" }, Nr = { class: "fm-typo-en-body-lg-600" }, Pr = {
1896
+ key: 0,
1897
+ class: "flex flex-col gap-4"
1898
+ }, Tr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fr = { class: "fm-typo-en-body-lg-600" }, Ir = { key: 0 }, Er = { key: 1 }, qr = {
1899
+ key: 1,
1900
+ class: "flex flex-col gap-4"
1901
+ }, Vr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Lr = { class: "fm-typo-en-body-lg-600" }, jr = { key: 0 }, Ur = { key: 1 }, Mr = {
1902
+ key: 2,
1903
+ class: "flex flex-col gap-4"
1904
+ }, Br = { class: "fm-typo-en-body-lg-600" }, zr = {
1905
+ key: 3,
1906
+ class: "flex flex-col gap-4"
1907
+ }, Kr = { class: "fm-typo-en-body-lg-600" }, Hr = /* @__PURE__ */ Fe({
1908
+ __name: "NetSuiteInfo",
1909
+ props: {
1910
+ transferType: {},
1911
+ transferToDbName: {},
1912
+ poRequest: {},
1913
+ purchaseOrder: {},
1914
+ isTransferBetweenOutlets: { type: Boolean },
1915
+ scope: {}
1916
+ },
1917
+ setup(p) {
1918
+ const t = p, r = ht(), l = Xe(), m = Y(t.poRequest);
1919
+ ts(async () => {
1920
+ var o;
1921
+ if (!t.poRequest && ((o = t.purchaseOrder) != null && o._id)) {
1922
+ const d = await l.getLatestPurchaseOrderRequest(t.purchaseOrder._id);
1923
+ m.value = d;
1924
+ }
1925
+ });
1926
+ const u = B(
1927
+ () => {
1928
+ var o, d, g, S, R, $;
1929
+ return r.getSubsidiaryFullName(
1930
+ ((g = (d = (o = t.purchaseOrder) == null ? void 0 : o.netSuite) == null ? void 0 : d.subsidiary) == null ? void 0 : g.id) || (($ = (R = (S = t.poRequest) == null ? void 0 : S.netSuite) == null ? void 0 : R.subsidiary) == null ? void 0 : $.id)
1931
+ ).fullName;
1932
+ }
1933
+ ), c = B(() => {
1934
+ var o, d, g, S, R, $, _, M, P, Q, se, le;
1935
+ return (g = (d = (o = t.purchaseOrder) == null ? void 0 : o.netSuite) == null ? void 0 : d.additionalInfo) != null && g.transactionnumber ? ($ = (R = (S = t.purchaseOrder) == null ? void 0 : S.netSuite) == null ? void 0 : R.additionalInfo) == null ? void 0 : $.transactionnumber : (P = (M = (_ = m.value) == null ? void 0 : _.netSuite) == null ? void 0 : M.additionalInfo) != null && P.transactionnumber ? (le = (se = (Q = m.value) == null ? void 0 : Q.netSuite) == null ? void 0 : se.additionalInfo) == null ? void 0 : le.transactionnumber : null;
1936
+ }), s = B(() => {
1937
+ var o, d, g, S, R, $;
1938
+ return (d = (o = t.purchaseOrder) == null ? void 0 : o.deliveryFullfillment) != null && d.length && ((S = (g = t.purchaseOrder) == null ? void 0 : g.deliveryFullfillment) == null ? void 0 : S.length) > 0 ? ($ = (R = t.purchaseOrder) == null ? void 0 : R.deliveryFullfillment) == null ? void 0 : $.map((_) => {
1939
+ var M;
1940
+ return (M = _.netSuite) == null ? void 0 : M.refNo;
1941
+ }).join(", ") : "N/A";
1942
+ });
1943
+ return (o, d) => {
1944
+ var g, S, R, $, _, M, P, Q, se, le, _e, ve, N, re, k, F;
1945
+ return y(r).isEnabled ? (n(), f("div", Ar, [
1946
+ e("div", Rr, [
1947
+ d[0] || (d[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1948
+ e("div", Nr, b(u.value || "N/A"), 1)
1949
+ ]),
1950
+ !o.isTransferBetweenOutlets && o.scope === y(wt).RECEIVE_REQUEST ? (n(), f("div", Pr, [
1951
+ e("div", Tr, " NetSuite " + b((S = (g = o.purchaseOrder) == null ? void 0 : g.netSuite) != null && S.recordType ? y(os)(($ = (R = o.purchaseOrder) == null ? void 0 : R.netSuite) == null ? void 0 : $.recordType) : o.transferType === y(nt).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1952
+ e("div", Fr, [
1953
+ (M = (_ = o.purchaseOrder) == null ? void 0 : _.netSuite) != null && M.id ? (n(), f("span", Ir, b((Q = (P = o.purchaseOrder) == null ? void 0 : P.netSuite) == null ? void 0 : Q.refNo) + " (" + b((le = (se = o.purchaseOrder) == null ? void 0 : se.netSuite) == null ? void 0 : le.id) + ") ", 1)) : (n(), f("span", Er, "N/A"))
1954
+ ])
1955
+ ])) : A("", !0),
1956
+ !o.isTransferBetweenOutlets && m.value || o.scope === y(wt).APPROVAL ? (n(), f("div", qr, [
1957
+ e("div", Vr, " (Request) NetSuite " + b(o.transferType === y(nt).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1958
+ e("div", Lr, [
1959
+ (ve = (_e = m.value) == null ? void 0 : _e.netSuite) != null && ve.id ? (n(), f("span", jr, b((re = (N = m.value) == null ? void 0 : N.netSuite) == null ? void 0 : re.refNo) + " (" + b((F = (k = m.value) == null ? void 0 : k.netSuite) == null ? void 0 : F.id) + ") ", 1)) : (n(), f("span", Ur, "N/A"))
1960
+ ])
1961
+ ])) : A("", !0),
1962
+ c.value ? (n(), f("div", Mr, [
1963
+ d[1] || (d[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1964
+ e("div", Br, b(c.value), 1)
1965
+ ])) : A("", !0),
1966
+ y(r).isEnabled && o.transferType === y(nt).enum.transfer && !o.isTransferBetweenOutlets ? (n(), f("div", zr, [
1967
+ d[2] || (d[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1968
+ e("div", Kr, b(s.value), 1)
1969
+ ])) : A("", !0)
1970
+ ])) : A("", !0);
1971
+ };
1972
+ }
1973
+ }), Gr = { class: "flex flex-row-reverse" }, Wr = /* @__PURE__ */ Fe({
1974
+ __name: "NetSuiteLog",
1975
+ props: {
1976
+ netsuiteId: {},
1977
+ purchaseOrderId: {}
1978
+ },
1979
+ setup(p) {
1980
+ const t = Je(), r = At();
1981
+ async function l(m, u) {
1982
+ const c = [];
1983
+ if (m && c.push(`body.message:*${m}*`), u) {
1984
+ const g = u.replace(/:/g, "\\:");
1985
+ c.push(`${g}`);
1986
+ }
1987
+ if (c.length === 0) {
1988
+ t.open({
1989
+ message: "Cannot open logs without valid filters.",
1990
+ type: "error"
1991
+ });
1992
+ return;
1993
+ }
1994
+ const o = `attributes.pod:netsuite* AND (${c.join(" OR ")})`, { url: d } = await r.getSyncLogs(o);
1995
+ t.open(
1996
+ {
1997
+ message: "Opening NetSuite logs...",
1998
+ type: "info"
1999
+ },
2000
+ 800
2001
+ ), await new Promise((g) => setTimeout(g, 800)), window.open(d, "_blank");
2002
+ }
2003
+ return (m, u) => {
2004
+ const c = Z("FmButton");
2005
+ return n(), f("div", Gr, [
2006
+ C(c, {
2007
+ "prepend-icon": "history",
2008
+ variant: "secondary",
2009
+ label: "Logs",
2010
+ onClick: u[0] || (u[0] = (s) => l(m.netsuiteId, m.purchaseOrderId)),
2011
+ "text-color": "primary",
2012
+ "bg-color": "transparent",
2013
+ "border-color": "primary"
2014
+ })
2015
+ ]);
2016
+ };
2017
+ }
2018
+ }), Qr = { class: "flex flex-row-reverse" }, Yr = { key: 0 }, Jr = { key: 1 }, Xr = { class: "mb-6" }, Zr = { class: "fm-typo-en-body-md-400" }, eo = { key: 0 }, to = { key: 1 }, so = {
2019
+ key: 0,
2020
+ class: "flex"
2021
+ }, ro = {
2022
+ key: 1,
2023
+ class: "border-t pt-6"
2024
+ }, oo = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, no = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, ao = { class: "w-full" }, lo = {
2025
+ class: "p-3 fm-typo-en-body-sm-600",
2026
+ style: { "min-width": "130px" }
2027
+ }, io = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, co = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, uo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, mo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, po = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, fo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, vo = { class: "p-3 fm-typo-en-body-sm-600" }, yo = { key: 2 }, ho = { key: 1 }, bo = /* @__PURE__ */ Fe({
2028
+ __name: "NetSuiteLatestInfo",
2029
+ props: {
2030
+ netsuiteId: {},
2031
+ purchaseOrderId: {}
2032
+ },
2033
+ setup(p) {
2034
+ const t = p, r = At(), l = Y(!1), m = ze(), u = Y(!0), c = Y(!1), s = Y(!1), o = Y(!1), d = Y(null), g = Y([]);
2035
+ async function S() {
2036
+ if (!d.value) {
2037
+ l.value = !0;
2038
+ try {
2039
+ u.value = !0;
2040
+ const M = await r.getMoreInfo(
2041
+ m.currentLocation.dbName,
2042
+ t.purchaseOrderId
2043
+ );
2044
+ d.value = M, c.value = !1;
2045
+ } catch {
2046
+ c.value = !0;
2047
+ } finally {
2048
+ u.value = !1;
2049
+ }
2050
+ await R();
2051
+ }
2052
+ }
2053
+ async function R() {
2054
+ if (!(g.value.length > 0))
2055
+ try {
2056
+ s.value = !0;
2057
+ const M = await r.getChangeLogs(t.netsuiteId);
2058
+ g.value = M, o.value = !1;
2059
+ } catch {
2060
+ o.value = !0;
2061
+ } finally {
2062
+ s.value = !1;
2063
+ }
2064
+ }
2065
+ function $(M) {
2066
+ switch (M) {
2067
+ case Me.Create:
2068
+ return "text-green-600 bg-green-100";
2069
+ case Me.Set:
2070
+ return "text-blue-600 bg-blue-100";
2071
+ case Me.Change:
2072
+ return "text-yellow-600 bg-yellow-100";
2073
+ case Me.Unset:
2074
+ return "text-red-600 bg-red-100";
2075
+ default:
2076
+ return "text-gray-600 bg-gray-100";
2077
+ }
2078
+ }
2079
+ function _(M) {
2080
+ return new Date(M).toLocaleDateString("en-US", {
2081
+ year: "numeric",
2082
+ month: "short",
2083
+ day: "numeric",
2084
+ hour: "2-digit",
2085
+ minute: "2-digit"
2086
+ });
2087
+ }
2088
+ return (M, P) => {
2089
+ const Q = Z("FmButton"), se = Z("FmLabel"), le = Z("FmCircularProgress"), _e = Z("FmIcon"), ve = Z("FmDialog");
2090
+ return n(), f("div", Qr, [
2091
+ C(ve, {
2092
+ modelValue: l.value,
2093
+ "onUpdate:modelValue": P[2] || (P[2] = (N) => l.value = N),
2094
+ overlay: !0,
2095
+ "max-width": 800
2096
+ }, {
2097
+ "dialog-button": ne(() => [
2098
+ C(Q, {
2099
+ "prepend-icon": "info",
2100
+ variant: "secondary",
2101
+ label: "Latest Info",
2102
+ onClick: P[0] || (P[0] = (N) => S()),
2103
+ "text-color": "primary",
2104
+ "bg-color": "transparent",
2105
+ "border-color": "primary"
2106
+ })
2107
+ ]),
2108
+ "dialog-header": ne(() => P[3] || (P[3] = [
2109
+ e("div", null, "NetSuite latest info", -1)
2110
+ ])),
2111
+ default: ne(() => [
2112
+ u.value ? (n(), f("div", Yr, "Loading...")) : (n(), f("div", Jr, [
2113
+ c.value ? (n(), f("p", ho, "Something went wrong.")) : (n(), f(Oe, { key: 0 }, [
2114
+ e("div", Xr, [
2115
+ P[4] || (P[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
2116
+ (n(!0), f(Oe, null, Pe(d.value, (N, re) => (n(), f("div", {
2117
+ key: re,
2118
+ class: "mb-2"
2119
+ }, [
2120
+ e("div", null, [
2121
+ C(se, {
2122
+ label: y(Ct)(re)
2123
+ }, null, 8, ["label"]),
2124
+ e("div", Zr, [
2125
+ Array.isArray(N) ? (n(), f("span", eo, b(N.length > 0 ? N.join(", ") : "N/A"), 1)) : (n(), f("span", to, b(N), 1))
2126
+ ])
2127
+ ])
2128
+ ]))), 128))
2129
+ ]),
2130
+ s.value ? (n(), f("div", so, [
2131
+ P[5] || (P[5] = e("span", null, "Change Log Loading...", -1)),
2132
+ C(le, { size: "md" })
2133
+ ])) : A("", !0),
2134
+ !s.value && g.value.length > 0 ? (n(), f("div", ro, [
2135
+ e("h3", oo, [
2136
+ C(_e, {
2137
+ name: "error",
2138
+ color: "#ff9500",
2139
+ size: "sm"
2140
+ }),
2141
+ P[6] || (P[6] = Ge(" Change Logs "))
2142
+ ]),
2143
+ e("div", no, [
2144
+ e("table", ao, [
2145
+ P[7] || (P[7] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
2146
+ e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
2147
+ e("th", {
2148
+ class: "text-left p-3 fm-typo-en-body-md-600",
2149
+ style: { "min-width": "130px" }
2150
+ }, " Date "),
2151
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
2152
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
2153
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
2154
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
2155
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
2156
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
2157
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
2158
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
2159
+ ])
2160
+ ], -1)),
2161
+ e("tbody", null, [
2162
+ (n(!0), f(Oe, null, Pe(g.value, (N, re) => (n(), f("tr", {
2163
+ key: re,
2164
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
2165
+ }, [
2166
+ e("td", lo, b(_(N._dateiso8601)), 1),
2167
+ e("td", io, b(N._rolename), 1),
2168
+ e("td", co, b(N._employeename), 1),
2169
+ e("td", uo, b(N._contextname), 1),
2170
+ e("td", {
2171
+ class: Be(`p-3 fm-typo-en-body-sm-600 ${$(Number(N.type) - 1)}`)
2172
+ }, b(y(Me)[Number(N.type) - 1]), 3),
2173
+ e("td", mo, b(N.lineid || ""), 1),
2174
+ e("td", po, b(N._fieldname), 1),
2175
+ e("td", fo, b(N.oldvalue || ""), 1),
2176
+ e("td", vo, b(N.newvalue || ""), 1)
2177
+ ]))), 128))
2178
+ ])
2179
+ ])
2180
+ ])
2181
+ ])) : (n(), f("div", yo, P[8] || (P[8] = [
2182
+ e("p", null, "No change logs available.", -1)
2183
+ ])))
2184
+ ], 64))
2185
+ ]))
2186
+ ]),
2187
+ "dialog-footer": ne(() => [
2188
+ C(Q, {
2189
+ class: "ml-auto sm:w-full xs:w-full",
2190
+ label: "Close",
2191
+ size: "md",
2192
+ variant: "primary",
2193
+ onClick: P[1] || (P[1] = (N) => l.value = !1)
2194
+ })
2195
+ ]),
2196
+ _: 1
2197
+ }, 8, ["modelValue"])
2198
+ ]);
2199
+ };
2200
+ }
2201
+ }), go = {
2202
+ key: 0,
2203
+ class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
2204
+ }, _o = { class: "flex gap-8 items-center" }, xo = { class: "ml-auto" }, So = { class: "flex gap-3" }, ko = /* @__PURE__ */ Fe({
2205
+ __name: "NetSuitePanel",
2206
+ props: {
2207
+ poRequest: {},
2208
+ purchaseOrder: {},
2209
+ transferType: {},
2210
+ transferToDbName: {},
2211
+ scope: {}
2212
+ },
2213
+ setup(p) {
2214
+ const t = p, r = Xs(), l = B(() => r.isNetSuiteEnabled);
2215
+ return (m, u) => {
2216
+ var s, o;
2217
+ const c = Z("FmMenuDivider");
2218
+ return l.value ? (n(), f("div", go, [
2219
+ e("div", _o, [
2220
+ u[0] || (u[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
2221
+ e("div", xo, [
2222
+ e("div", So, [
2223
+ (o = (s = t.purchaseOrder) == null ? void 0 : s.netSuite) != null && o.id ? (n(), ue(tt, { key: 0 }, {
2224
+ default: ne(() => {
2225
+ var d, g, S;
2226
+ return [
2227
+ C(bo, {
2228
+ "netsuite-id": (g = (d = m.purchaseOrder) == null ? void 0 : d.netSuite) == null ? void 0 : g.id,
2229
+ "purchase-order-id": (S = m.purchaseOrder) == null ? void 0 : S._id
2230
+ }, null, 8, ["netsuite-id", "purchase-order-id"])
2231
+ ];
2232
+ }),
2233
+ _: 1
2234
+ })) : A("", !0),
2235
+ C(tt, null, {
2236
+ default: ne(() => {
2237
+ var d, g, S;
2238
+ return [
2239
+ C(Wr, {
2240
+ "netsuite-id": (g = (d = m.purchaseOrder) == null ? void 0 : d.netSuite) == null ? void 0 : g.id,
2241
+ "purchase-order-id": (S = m.purchaseOrder) == null ? void 0 : S._id
2242
+ }, null, 8, ["netsuite-id", "purchase-order-id"])
2243
+ ];
2244
+ }),
2245
+ _: 1
2246
+ }),
2247
+ C(Dr, {
2248
+ "po-request": m.poRequest,
2249
+ "purchase-order": m.purchaseOrder,
2250
+ "is-transfer-between-outlets": !l.value,
2251
+ scope: m.scope
2252
+ }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
2253
+ ])
2254
+ ])
2255
+ ]),
2256
+ C(c),
2257
+ C(Hr, {
2258
+ "po-request": m.poRequest,
2259
+ "purchase-order": m.purchaseOrder,
2260
+ "transfer-type": m.transferType,
2261
+ "transfer-to-db-name": m.transferToDbName,
2262
+ "is-transfer-between-outlets": !l.value,
2263
+ scope: m.scope
2264
+ }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
2265
+ ])) : A("", !0);
2266
+ };
2267
+ }
2268
+ }), Oo = ["open"], wo = { class: "fm-typo-en-body-sm-600 cursor-pointer select-none" }, Xt = /* @__PURE__ */ Fe({
2269
+ __name: "FmAdminCollapsiblePanel",
2270
+ props: {
2271
+ title: { default: "Admin" },
2272
+ open: { type: Boolean, default: !1 },
2273
+ selectable: { type: Boolean, default: !0 },
2274
+ class: { default: void 0 },
2275
+ contentClass: { default: void 0 }
2276
+ },
2277
+ setup(p) {
2278
+ const t = p;
2279
+ return (r, l) => (n(), ue(tt, {
2280
+ selectable: t.selectable,
2281
+ class: Be(t.class)
2282
+ }, {
2283
+ default: ne(() => [
2284
+ e("details", {
2285
+ open: t.open,
2286
+ class: "w-full"
2287
+ }, [
2288
+ e("summary", wo, b(t.title), 1),
2289
+ e("div", {
2290
+ class: Be(["mt-4 flex flex-col gap-2", t.contentClass])
2291
+ }, [
2292
+ Cs(r.$slots, "default")
2293
+ ], 2)
2294
+ ], 8, Oo)
2295
+ ]),
2296
+ _: 3
2297
+ }, 8, ["selectable", "class"]));
2298
+ }
2299
+ });
2300
+ function ys(p) {
2301
+ if (!(p != null && p.itemsAtSubmission)) return [];
2302
+ const t = p.version === Ve.enum[2], r = new Set(p.itemsAtSubmission.map((l) => t ? l.id : l.sku._id));
2303
+ return p.items.filter((l) => {
2304
+ const m = t ? l.id : l.sku._id;
2305
+ return !r.has(m);
2306
+ });
2307
+ }
2308
+ function hs(p, t) {
2309
+ var u;
2310
+ if (!p || t.length === 0) return {};
2311
+ const r = p.version === Ve.enum[2], l = new Set(t.map((c) => r ? c.id : c.sku._id)), m = {};
2312
+ for (const c of p.deliveryOrder ?? [])
2313
+ for (const s of c.received ?? []) {
2314
+ const o = r ? s.id : s.sku._id;
2315
+ o && l.has(o) && (m[o] = (m[o] ?? 0) + (((u = s.amount) == null ? void 0 : u.amount) ?? 0));
2316
+ }
2317
+ return t.reduce(
2318
+ (c, s) => {
2319
+ var R, $;
2320
+ const o = (r ? s.id : s.sku._id) ?? "", d = ((R = s.quantity) == null ? void 0 : R.amount) ?? 0, g = m[o] ?? 0, S = (($ = s.quantity) == null ? void 0 : $.precision) ?? 0;
2321
+ return c[o] = {
2322
+ key: o,
2323
+ total: { amount: d, precision: S },
2324
+ received: { amount: g, precision: S },
2325
+ remaining: { amount: d - g, precision: S }
2326
+ }, c;
2327
+ },
2328
+ {}
2329
+ );
2330
+ }
2331
+ const $o = { class: "flex flex-col gap-3" }, Co = { class: "flex flex-col gap-4" }, Do = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Ao = { class: "flex flex-col gap-4" }, Ro = { class: "flex justify-between items-start py-1 gap-4" }, No = { class: "flex flex-col flex-1 min-w-0" }, Po = { class: "fm-typo-en-body-lg-600 truncate" }, To = { class: "fm-typo-en-body-md-400 truncate" }, Fo = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Io = {
2332
+ key: 0,
2333
+ class: "flex items-center gap-2"
2334
+ }, Eo = {
2335
+ key: 0,
2336
+ class: "border-b border-fm-color-stroke-secondary"
2337
+ }, qo = { class: "flex flex-col gap-4" }, Vo = { class: "flex items-center justify-between" }, Lo = {
2338
+ key: 0,
2339
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
2340
+ }, jo = { class: "flex justify-between items-start py-1 gap-4" }, Uo = { class: "flex-1 min-w-0 flex flex-col gap-2" }, Mo = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Bo = {
2341
+ key: 0,
2342
+ class: "flex items-center gap-2"
2343
+ }, zo = {
2344
+ key: 0,
2345
+ class: "border-b border-fm-color-stroke-secondary"
2346
+ }, Ko = { class: "flex flex-col gap-4" }, Ho = { class: "flex flex-col gap-4" }, Go = { class: "flex flex-col gap-4" }, Wo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Qo = {
2347
+ key: 1,
2348
+ class: "flex flex-col gap-4"
2349
+ }, Yo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, it = "Will be ignored on save (zero or negative quantity)", Jo = /* @__PURE__ */ Fe({
2350
+ __name: "EditForm",
2351
+ props: {
2352
+ purchaseOrder: {},
2353
+ deliveryOrder: {},
2354
+ receivedInfoMap: {}
2355
+ },
2356
+ emits: ["submitted"],
2357
+ setup(p, { emit: t }) {
2358
+ const { t: r } = sr(), l = Ye(), m = Je(), u = Y(!1), c = $t(), s = p, o = t, d = as("deliveryOrder"), g = Xe(), {
2359
+ controller: S,
2360
+ state: R,
2361
+ reset: $
2362
+ } = Nt({
2363
+ currency: we(),
2364
+ adjustments: s.deliveryOrder.priceAdjustments
2365
+ }), _ = B(
2366
+ () => {
2367
+ var j;
2368
+ return ((j = s.purchaseOrder.deliveryFullfillment) == null ? void 0 : j.findIndex(
2369
+ (O) => s.deliveryOrder.fullfillmentId && O.id === s.deliveryOrder.fullfillmentId
2370
+ )) ?? -1;
2371
+ }
2372
+ ), M = l.enablePurchaseOrderReceiveWithCustomCost, P = l.enablePortalDeliveryOrderWrite, Q = Y({}), se = B(
2373
+ () => (s.purchaseOrder.itemsAtSubmission ?? s.purchaseOrder.items).length
2374
+ ), le = B(() => ys(s.purchaseOrder)), _e = B(
2375
+ () => hs(s.purchaseOrder, le.value)
2376
+ ), ve = B(
2377
+ () => s.purchaseOrder.items.map(
2378
+ (j, O) => B({
2379
+ get: () => {
2380
+ var L;
2381
+ const I = (L = d.received[O]) == null ? void 0 : L.amount;
2382
+ return I ? +xe(I) : 0;
2383
+ },
2384
+ set: (I) => {
2385
+ d.received[O].amount = We(I, 2);
2386
+ }
2387
+ })
2388
+ )
2389
+ ), N = B(
2390
+ () => s.purchaseOrder.items.map(
2391
+ (j, O) => B({
2392
+ get: () => {
2393
+ var L;
2394
+ const I = (L = d.received[O]) == null ? void 0 : L.cost;
2395
+ return I ? +xe(I) : 0;
2396
+ },
2397
+ set: (I) => {
2398
+ d.received[O].cost = {
2399
+ currency: we(),
2400
+ ...We(I, 4)
2401
+ };
2402
+ }
2403
+ })
2404
+ )
2405
+ );
2406
+ function re(j) {
2407
+ var I;
2408
+ const O = !Q.value[j];
2409
+ if (Q.value[j] = O, O) {
2410
+ const L = (I = d.received[j]) == null ? void 0 : I.cost;
2411
+ d.received[j].cost = L ? { ...L, precision: 4 } : { currency: we(), amount: 0, precision: 4 };
2412
+ } else
2413
+ delete d.received[j].cost;
2414
+ }
2415
+ const k = Y([]), F = B(
2416
+ () => c.skus.filter((j) => !j.isInactive).map((j) => ({ label: `${j.name} (${j.code})`, value: j._id }))
2417
+ );
2418
+ function G() {
2419
+ k.value.push({ skuId: null, costEnabled: !1 }), d.received.push({
2420
+ sku: null,
2421
+ amount: Te.fromNumber(0),
2422
+ measurement: null
2423
+ });
2424
+ }
2425
+ function K(j) {
2426
+ k.value.splice(j, 1), d.received.splice(se.value + j, 1);
2427
+ }
2428
+ function W(j, O) {
2429
+ k.value[j].skuId = O;
2430
+ const I = O ? c.skuById[O] : null;
2431
+ d.received[se.value + j].sku = I;
2432
+ }
2433
+ function ye(j, O) {
2434
+ var De, Ae;
2435
+ const I = (De = s.receivedInfoMap) == null ? void 0 : De[O.sku._id], L = I ? `${r("inventory.transfer.receiveRequest.details.received")} ${Te.toFormatString({ value: I.received })} / ${mt(O.quantity, O.sku.unit, O.measurement)}` : void 0;
2436
+ return (((Ae = ve.value[j]) == null ? void 0 : Ae.value) ?? 0) > 0 ? L : L ? `${L} · ${it}` : it;
2437
+ }
2438
+ function me(j, O) {
2439
+ var De;
2440
+ const L = (((De = he.value[O]) == null ? void 0 : De.value) ?? 0) <= 0;
2441
+ let ae;
2442
+ if (j.skuId && _e.value[j.skuId]) {
2443
+ const Ae = _e.value[j.skuId], a = Te.toFormatString({ value: Ae.received });
2444
+ ae = `${r("inventory.transfer.receiveRequest.details.received")} ${a}`;
2445
+ }
2446
+ return L ? ae ? `${ae} · ${it}` : it : ae;
2447
+ }
2448
+ const he = B(
2449
+ () => k.value.map((j, O) => {
2450
+ const I = se.value + O;
2451
+ return B({
2452
+ get: () => {
2453
+ var ae;
2454
+ const L = (ae = d.received[I]) == null ? void 0 : ae.amount;
2455
+ return L ? +xe(L) : 0;
2456
+ },
2457
+ set: (L) => {
2458
+ d.received[I].amount = We(L, 2);
2459
+ }
2460
+ });
2461
+ })
2462
+ ), de = B(
2463
+ () => k.value.map((j, O) => {
2464
+ const I = se.value + O;
2465
+ return B({
2466
+ get: () => {
2467
+ var ae;
2468
+ const L = (ae = d.received[I]) == null ? void 0 : ae.cost;
2469
+ return L ? +xe(L) : 0;
2470
+ },
2471
+ set: (L) => {
2472
+ d.received[I].cost = {
2473
+ currency: we(),
2474
+ ...We(L, 4)
2475
+ };
2476
+ }
2477
+ });
2478
+ })
2479
+ );
2480
+ function q(j) {
2481
+ const O = k.value[j], I = se.value + j;
2482
+ O.costEnabled = !O.costEnabled, O.costEnabled ? d.received[I].cost = { currency: we(), amount: 0, precision: 4 } : delete d.received[I].cost;
2483
+ }
2484
+ Qe(
2485
+ () => u.value,
2486
+ (j) => {
2487
+ var a, i, x;
2488
+ if (!j) {
2489
+ k.value = [], Q.value = {};
2490
+ return;
2491
+ }
2492
+ $(s.deliveryOrder.priceAdjustments);
2493
+ const O = s.purchaseOrder.itemsAtSubmission ?? s.purchaseOrder.items, I = new Set(O.map((w) => w.sku._id)), L = {}, ae = [];
2494
+ for (const w of s.deliveryOrder.received ?? []) {
2495
+ const V = (a = w.sku) == null ? void 0 : a._id;
2496
+ V && (I.has(V) ? L[V] = w : ae.push(w));
2497
+ }
2498
+ d.received = O.map((w) => {
2499
+ const V = L[w.sku._id];
2500
+ return V ? { ...V } : {
2501
+ sku: w.sku,
2502
+ amount: Te.fromNumber(0),
2503
+ measurement: w.measurement ?? null
2504
+ };
2505
+ });
2506
+ const De = {};
2507
+ for (let w = 0; w < O.length; w++)
2508
+ (i = L[O[w].sku._id]) != null && i.cost && (De[w] = !0);
2509
+ Q.value = De, k.value = [];
2510
+ const Ae = le.value;
2511
+ for (const w of ae) {
2512
+ const V = Ae.find((z) => {
2513
+ var ee;
2514
+ return z.sku._id === ((ee = w.sku) == null ? void 0 : ee._id);
2515
+ });
2516
+ k.value.push({
2517
+ skuId: ((x = w.sku) == null ? void 0 : x._id) ?? null,
2518
+ costEnabled: !!w.cost,
2519
+ locked: !0,
2520
+ quantityLocked: !0,
2521
+ historyItem: V
2522
+ }), d.received.push({ ...w });
2523
+ }
2524
+ if (Ae.length) {
2525
+ const w = new Set(ae.map((V) => {
2526
+ var z;
2527
+ return (z = V.sku) == null ? void 0 : z._id;
2528
+ }));
2529
+ for (const V of Ae)
2530
+ w.has(V.sku._id) || (k.value.push({
2531
+ skuId: V.sku._id,
2532
+ costEnabled: !1,
2533
+ locked: !0,
2534
+ historyItem: V
2535
+ }), d.received.push({
2536
+ sku: V.sku,
2537
+ amount: Te.fromNumber(0),
2538
+ measurement: V.measurement ?? null
2539
+ }));
2540
+ }
2541
+ }
2542
+ );
2543
+ const T = Y(!1);
2544
+ function oe() {
2545
+ T.value = !0, g.updateDeliveryOrder({
2546
+ deliveryOrder: {
2547
+ ...s.deliveryOrder,
2548
+ ...d,
2549
+ priceAdjustments: S.value.state().adjustments
2550
+ },
2551
+ purchaseOrderId: s.purchaseOrder._id,
2552
+ purchaseOrderRev: s.purchaseOrder._rev
2553
+ }).then(() => {
2554
+ m.open(
2555
+ {
2556
+ title: "Success",
2557
+ message: `PO# ${s.purchaseOrder.seqNumber} Changes have been saved`,
2558
+ type: "success"
2559
+ },
2560
+ 1e4
2561
+ ), u.value = !1, o("submitted");
2562
+ }).finally(() => {
2563
+ T.value = !1;
2564
+ });
2565
+ }
2566
+ return (j, O) => {
2567
+ const I = Z("FmButton"), L = Z("FmStepperField"), ae = Z("FmSwitch"), De = Z("FmSelect"), Ae = Z("FmTextField"), a = Z("FmDialog");
2568
+ return n(), ue(a, {
2569
+ modelValue: u.value,
2570
+ "onUpdate:modelValue": O[1] || (O[1] = (i) => u.value = i),
2571
+ overlay: !0,
2572
+ "min-width": 800
2573
+ }, {
2574
+ "dialog-button": ne(() => [
2575
+ y(P) ? (n(), ue(I, {
2576
+ key: 0,
2577
+ variant: "plain",
2578
+ label: "Edit",
2579
+ size: "md",
2580
+ "prepend-icon": "edit"
2581
+ })) : A("", !0)
2582
+ ]),
2583
+ "dialog-header": ne(() => [
2584
+ e("div", null, "Received on " + b(y(Ze)(s.deliveryOrder.createdAt)), 1)
2585
+ ]),
2586
+ "dialog-footer": ne(() => [
2587
+ C(I, {
2588
+ class: "ml-auto",
2589
+ label: "Apply changes",
2590
+ size: "md",
2591
+ variant: "destructive",
2592
+ disabled: T.value,
2593
+ loading: T.value,
2594
+ onClick: oe
2595
+ }, null, 8, ["disabled", "loading"])
2596
+ ]),
2597
+ default: ne(() => [
2598
+ e("div", $o, [
2599
+ e("div", Co, [
2600
+ O[2] || (O[2] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Adjustment date", -1)),
2601
+ e("div", Do, b(s.deliveryOrder.adjustment ? y(Ze)(new Date(y(ut)(s.deliveryOrder.adjustment))) : "-"), 1)
2602
+ ]),
2603
+ e("div", Ao, [
2604
+ O[4] || (O[4] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
2605
+ (n(!0), f(Oe, null, Pe(s.purchaseOrder.items, (i, x) => {
2606
+ var w;
2607
+ return n(), f("div", { key: x }, [
2608
+ e("div", Ro, [
2609
+ e("div", No, [
2610
+ e("span", Po, b(i.sku.name), 1),
2611
+ e("span", To, b(i.sku.code), 1)
2612
+ ]),
2613
+ e("div", Fo, [
2614
+ C(L, {
2615
+ label: "Receive Quantity",
2616
+ modelValue: ve.value[x].value,
2617
+ "onUpdate:modelValue": (V) => ve.value[x].value = V,
2618
+ "append-text": ((w = i.measurement) == null ? void 0 : w.abbrev) ?? i.sku.unit.abbrev,
2619
+ "helper-text": ye(x, i)
2620
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text"]),
2621
+ y(M) ? (n(), f("div", Io, [
2622
+ C(ae, {
2623
+ "model-value": Q.value[x],
2624
+ "onUpdate:modelValue": (V) => re(x),
2625
+ size: "sm"
2626
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2627
+ O[3] || (O[3] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2628
+ ])) : A("", !0),
2629
+ y(M) && Q.value[x] ? (n(), ue(L, {
2630
+ key: 1,
2631
+ modelValue: N.value[x].value,
2632
+ "onUpdate:modelValue": (V) => N.value[x].value = V,
2633
+ label: "Total Cost",
2634
+ step: 1e-4,
2635
+ min: 0,
2636
+ placeholder: "0.0000",
2637
+ size: "sm",
2638
+ "append-text": y(we)()
2639
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : A("", !0)
2640
+ ])
2641
+ ]),
2642
+ x < s.purchaseOrder.items.length - 1 ? (n(), f("div", Eo)) : A("", !0)
2643
+ ]);
2644
+ }), 128))
2645
+ ]),
2646
+ e("div", qo, [
2647
+ e("div", Vo, [
2648
+ O[5] || (O[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Extra items", -1)),
2649
+ C(I, {
2650
+ variant: "tertiary",
2651
+ label: "Add item",
2652
+ "prepend-icon": "add",
2653
+ size: "md",
2654
+ onClick: G
2655
+ })
2656
+ ]),
2657
+ k.value.length === 0 ? (n(), f("div", Lo, " No extra items added ")) : A("", !0),
2658
+ (n(!0), f(Oe, null, Pe(k.value, (i, x) => {
2659
+ var w, V;
2660
+ return n(), f("div", { key: x }, [
2661
+ e("div", jo, [
2662
+ e("div", Uo, [
2663
+ C(De, {
2664
+ "model-value": i.skuId,
2665
+ "onUpdate:modelValue": (z) => W(x, z),
2666
+ label: "Ingredient",
2667
+ items: F.value,
2668
+ searchable: "",
2669
+ searchTarget: "label",
2670
+ placeholder: "Select ingredient",
2671
+ disabled: i.locked
2672
+ }, null, 8, ["model-value", "onUpdate:modelValue", "items", "disabled"])
2673
+ ]),
2674
+ e("div", Mo, [
2675
+ C(L, {
2676
+ label: "Receive Quantity",
2677
+ modelValue: he.value[x].value,
2678
+ "onUpdate:modelValue": (z) => he.value[x].value = z,
2679
+ "append-text": i.skuId ? ((V = (w = y(c).skuById[i.skuId]) == null ? void 0 : w.unit) == null ? void 0 : V.abbrev) ?? "" : "",
2680
+ "helper-text": me(i, x),
2681
+ disabled: i.quantityLocked || !i.skuId
2682
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text", "disabled"]),
2683
+ y(M) ? (n(), f("div", Bo, [
2684
+ C(ae, {
2685
+ "model-value": i.costEnabled,
2686
+ "onUpdate:modelValue": (z) => q(x),
2687
+ size: "sm"
2688
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2689
+ O[6] || (O[6] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2690
+ ])) : A("", !0),
2691
+ y(M) && i.costEnabled ? (n(), ue(L, {
2692
+ key: 1,
2693
+ modelValue: de.value[x].value,
2694
+ "onUpdate:modelValue": (z) => de.value[x].value = z,
2695
+ label: "Total Cost",
2696
+ step: 1e-4,
2697
+ min: 0,
2698
+ placeholder: "0.0000",
2699
+ size: "sm",
2700
+ "append-text": y(we)()
2701
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : A("", !0)
2702
+ ]),
2703
+ i.locked ? A("", !0) : (n(), ue(I, {
2704
+ key: 0,
2705
+ variant: "tertiary",
2706
+ "prepend-icon": "delete",
2707
+ size: "md",
2708
+ class: "mt-6",
2709
+ onClick: (z) => K(x)
2710
+ }, null, 8, ["onClick"]))
2711
+ ]),
2712
+ x < k.value.length - 1 ? (n(), f("div", zo)) : A("", !0)
2713
+ ]);
2714
+ }), 128))
2715
+ ]),
2716
+ e("div", Ko, [
2717
+ O[7] || (O[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2718
+ e("div", Ho, [
2719
+ C(Ae, {
2720
+ modelValue: y(d).deliveryOrderNumber,
2721
+ "onUpdate:modelValue": O[0] || (O[0] = (i) => y(d).deliveryOrderNumber = i),
2722
+ size: "md",
2723
+ placeholder: s.deliveryOrder.deliveryOrderNumber
2724
+ }, null, 8, ["modelValue", "placeholder"])
2725
+ ])
2726
+ ]),
2727
+ e("div", Go, [
2728
+ O[8] || (O[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2729
+ e("div", Wo, b(s.deliveryOrder.remark || "N/A"), 1)
2730
+ ]),
2731
+ y(l).enablePurchaseOrderPriceAdjustment ? (n(), ue(Rt, {
2732
+ key: 0,
2733
+ controller: y(S),
2734
+ state: y(R)
2735
+ }, null, 8, ["controller", "state"])) : A("", !0),
2736
+ _.value >= 0 ? (n(), f("div", Qo, [
2737
+ O[9] || (O[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Fulfilment's sequence", -1)),
2738
+ e("div", Yo, b(_.value + 1), 1)
2739
+ ])) : A("", !0)
2740
+ ])
2741
+ ]),
2742
+ _: 1
2743
+ }, 8, ["modelValue"]);
2744
+ };
2745
+ }
2746
+ }), Xo = { class: "flex flex-col gap-3" }, Zo = { class: "flex flex-col gap-4" }, en = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, tn = {
2747
+ key: 0,
2748
+ class: "flex flex-col gap-4"
2749
+ }, sn = { class: "flex items-center justify-between" }, rn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, on = {
2750
+ key: 0,
2751
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
2752
+ }, nn = { class: "flex gap-4" }, an = { class: "flex-1" }, ln = { class: "flex-1" }, cn = {
2753
+ key: 0,
2754
+ class: "flex items-center text-fm-color-system-error-300"
2755
+ }, un = { class: "fm-typo-en-body-md-400" }, dn = { class: "flex flex-col gap-4" }, mn = { class: "flex justify-between items-start py-1 gap-4" }, pn = { class: "flex flex-col flex-1 min-w-0" }, fn = { class: "fm-typo-en-body-lg-600 truncate" }, vn = { class: "fm-typo-en-body-md-400 truncate" }, yn = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, hn = {
2756
+ key: 0,
2757
+ class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 self-end text-right"
2758
+ }, bn = {
2759
+ key: 1,
2760
+ class: "flex items-center gap-2"
2761
+ }, gn = {
2762
+ key: 0,
2763
+ class: "border-b border-fm-color-stroke-secondary"
2764
+ }, _n = { class: "flex flex-col gap-4" }, xn = { class: "flex items-center justify-between" }, Sn = {
2765
+ key: 0,
2766
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
2767
+ }, kn = { class: "flex justify-between items-start py-1 gap-4" }, On = { class: "flex-1 min-w-0 flex flex-col gap-2" }, wn = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, $n = {
2768
+ key: 0,
2769
+ class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 self-end text-right"
2770
+ }, Cn = {
2771
+ key: 1,
2772
+ class: "flex items-center gap-2"
2773
+ }, Dn = {
2774
+ key: 0,
2775
+ class: "border-b border-fm-color-stroke-secondary"
2776
+ }, An = { class: "flex flex-col gap-4" }, Rn = { class: "flex flex-col gap-4" }, Nn = { class: "flex flex-col gap-4" }, Pn = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Zt = "Will be ignored on save (zero or negative quantity)", Tn = /* @__PURE__ */ Fe({
2777
+ __name: "CreateForm",
2778
+ props: {
2779
+ purchaseOrder: {},
2780
+ receivedInfoMap: {},
2781
+ receivedMap: {}
2782
+ },
2783
+ emits: ["submitted"],
2784
+ setup(p, { emit: t }) {
2785
+ var pe, ie, Se;
2786
+ const { t: r } = vt(), l = Y(!1), m = yt(), u = p, c = t, s = as("", {
2787
+ default: {
2788
+ deliveryOrderNumber: "",
2789
+ remark: "",
2790
+ received: (u.purchaseOrder.itemsAtSubmission ?? u.purchaseOrder.items).map((h) => ({
2791
+ sku: h.sku,
2792
+ amount: Te.fromNumber(0),
2793
+ measurement: h.measurement
2794
+ })),
2795
+ createdBy: {
2796
+ id: ((pe = m.sessionUser.value) == null ? void 0 : pe.id) || "",
2797
+ name: ((ie = m.sessionUser.value) == null ? void 0 : ie.displayName) || ""
2798
+ },
2799
+ createdAt: ""
2800
+ }
2801
+ }), o = Xe(), d = bt(), g = Ye(), S = $t(), {
2802
+ controller: R,
2803
+ state: $,
2804
+ reset: _
2805
+ } = Nt({ currency: we() }), M = ((Se = u.purchaseOrder) == null ? void 0 : Se.supplier.internal) != null, P = M && g.enablePOSTransferRequireFulfillment, Q = g.enablePortalDeliveryOrderWrite && (u.purchaseOrder.status === ge.Enum.RECEIVING || u.purchaseOrder.status === ge.Enum.COMPLETE) && (M ? !P : !0), se = g.enablePurchaseOrderReceiveWithCustomCost, le = g.enableBackdateReceive, _e = Y({}), ve = B(
2806
+ () => u.purchaseOrder.itemsAtSubmission ?? u.purchaseOrder.items
2807
+ ), N = B(() => ys(u.purchaseOrder)), re = B(
2808
+ () => hs(u.purchaseOrder, N.value)
2809
+ ), k = B(
2810
+ () => {
2811
+ var h;
2812
+ return (((h = u.purchaseOrder) == null ? void 0 : h.version) ?? Ve.enum[1]) === Ve.enum[2];
2813
+ }
2814
+ );
2815
+ function F(h) {
2816
+ return (k.value ? h.id : h.sku._id) ?? null;
2817
+ }
2818
+ const G = Je(), K = B({
2819
+ get() {
2820
+ if (!s.createdAt) return "";
2821
+ const h = new Date(s.createdAt), v = h.getFullYear(), D = String(h.getMonth() + 1).padStart(2, "0"), J = String(h.getDate()).padStart(2, "0");
2822
+ return `${v}-${D}-${J}`;
2823
+ },
2824
+ set(h) {
2825
+ if (h) {
2826
+ const v = s.createdAt ? new Date(s.createdAt) : /* @__PURE__ */ new Date(), [D, J, te] = h.split("-");
2827
+ v.setFullYear(parseInt(D)), v.setMonth(parseInt(J) - 1), v.setDate(parseInt(te)), s.createdAt = v.toISOString();
2828
+ }
2829
+ }
2830
+ }), W = B({
2831
+ get() {
2832
+ if (!s.createdAt) return "";
2833
+ const h = new Date(s.createdAt), v = String(h.getHours()).padStart(2, "0"), D = String(h.getMinutes()).padStart(2, "0");
2834
+ return `${v}:${D}`;
2835
+ },
2836
+ set(h) {
2837
+ if (h) {
2838
+ const v = s.createdAt ? new Date(s.createdAt) : /* @__PURE__ */ new Date(), [D, J] = h.split(":");
2839
+ v.setHours(parseInt(D)), v.setMinutes(parseInt(J)), s.createdAt = v.toISOString();
2840
+ }
2841
+ }
2842
+ }), ye = B(() => {
2843
+ const h = ut(u.purchaseOrder._id);
2844
+ if (!h) return "";
2845
+ const v = new Date(h), D = v.getFullYear(), J = String(v.getMonth() + 1).padStart(2, "0"), te = String(v.getDate()).padStart(2, "0");
2846
+ return `${D}-${J}-${te}`;
2847
+ }), me = B(() => {
2848
+ const h = ut(u.purchaseOrder._id);
2849
+ return h ? new Date(h) : null;
2850
+ }), he = B(() => {
2851
+ if (!K.value || !W.value || !me.value) return null;
2852
+ if (/* @__PURE__ */ new Date(`${K.value}T${W.value}:00`) < me.value) {
2853
+ const v = ye.value, D = me.value.getHours(), J = me.value.getMinutes(), te = D >= 12 ? "PM" : "AM", Re = D % 12 || 12, H = `${String(Re).padStart(2, "0")}:${String(J).padStart(2, "0")} ${te}`;
2854
+ return `Delivery date & time cannot be earlier than order creation (${v} ${H})`;
2855
+ }
2856
+ return null;
2857
+ }), de = B(() => he.value || I.value.some((v) => !v.skuId) ? !1 : s.received.some((v) => {
2858
+ const D = v.amount;
2859
+ return D ? +xe(D) > 0 : !1;
2860
+ }));
2861
+ function q(h) {
2862
+ var D;
2863
+ const v = (D = u.receivedInfoMap[h.sku._id]) == null ? void 0 : D.received;
2864
+ return `${r("inventory.transfer.receiveRequest.details.received")} ${Te.toFormatString({ value: v })} / ${mt(h.quantity, h.sku.unit, h.measurement)}`;
2865
+ }
2866
+ function T() {
2867
+ s.createdAt = "";
2868
+ }
2869
+ const oe = B(() => ve.value.map((h, v) => B({
2870
+ get: () => {
2871
+ var J;
2872
+ const D = (J = s.received[v]) == null ? void 0 : J.amount;
2873
+ return D ? +xe(D) : 0;
2874
+ },
2875
+ set: (D) => {
2876
+ s.received[v].amount = We(D, 2);
2877
+ }
2878
+ })));
2879
+ function j(h) {
2880
+ const v = !_e.value[h];
2881
+ if (_e.value[h] = v, v) {
2882
+ const D = ve.value[h];
2883
+ D.totalCost ? s.received[h].cost = {
2884
+ currency: D.totalCost.currency,
2885
+ amount: D.totalCost.amount,
2886
+ precision: 4
2887
+ // Standardize to 4 decimals
2888
+ } : s.received[h].cost = {
2889
+ currency: we(),
2890
+ amount: 0,
2891
+ precision: 4
2892
+ };
2893
+ } else
2894
+ delete s.received[h].cost;
2895
+ }
2896
+ const O = B(() => ve.value.map((h, v) => B({
2897
+ get: () => {
2898
+ var J;
2899
+ const D = (J = s.received[v]) == null ? void 0 : J.cost;
2900
+ return D ? +xe(D) : 0;
2901
+ },
2902
+ set: (D) => {
2903
+ s.received[v].cost = {
2904
+ currency: we(),
2905
+ ...We(D, 4)
2906
+ };
2907
+ }
2908
+ }))), I = Y([]), L = B(
2909
+ () => S.skus.filter((h) => !h.isInactive).map((h) => ({ label: `${h.name} (${h.code})`, value: h._id }))
2910
+ ), ae = B(() => ve.value.length);
2911
+ function De() {
2912
+ I.value.push({ skuId: null, stableKey: null, costEnabled: !1 }), s.received.push({
2913
+ sku: null,
2914
+ amount: Te.fromNumber(0),
2915
+ measurement: null
2916
+ });
2917
+ }
2918
+ function Ae(h) {
2919
+ I.value.splice(h, 1), s.received.splice(ae.value + h, 1);
2920
+ }
2921
+ function a(h, v) {
2922
+ I.value[h].skuId = v;
2923
+ const D = v ? S.skuById[v] : null;
2924
+ s.received[ae.value + h].sku = D;
2925
+ }
2926
+ function i(h) {
2927
+ const v = h.stableKey;
2928
+ if (v && re.value[v]) {
2929
+ const D = re.value[v], J = Te.toFormatString({ value: D.received });
2930
+ return `${r("inventory.transfer.receiveRequest.details.received")} ${J}`;
2931
+ }
2932
+ }
2933
+ const x = B(
2934
+ () => I.value.map((h, v) => {
2935
+ const D = ae.value + v;
2936
+ return B({
2937
+ get: () => {
2938
+ var te;
2939
+ const J = (te = s.received[D]) == null ? void 0 : te.amount;
2940
+ return J ? +xe(J) : 0;
2941
+ },
2942
+ set: (J) => {
2943
+ s.received[D].amount = We(J, 2);
2944
+ }
2945
+ });
2946
+ })
2947
+ ), w = B(
2948
+ () => I.value.map((h, v) => {
2949
+ const D = ae.value + v;
2950
+ return B({
2951
+ get: () => {
2952
+ var te;
2953
+ const J = (te = s.received[D]) == null ? void 0 : te.cost;
2954
+ return J ? +xe(J) : 0;
2955
+ },
2956
+ set: (J) => {
2957
+ s.received[D].cost = {
2958
+ currency: we(),
2959
+ ...We(J, 4)
2960
+ };
2961
+ }
2962
+ });
2963
+ })
2964
+ );
2965
+ function V(h) {
2966
+ const v = I.value[h], D = ae.value + h;
2967
+ v.costEnabled = !v.costEnabled, v.costEnabled ? s.received[D].cost = { currency: we(), amount: 0, precision: 4 } : delete s.received[D].cost;
2968
+ }
2969
+ function z() {
2970
+ d.open({
2971
+ title: "Confirm Create Delivery Order",
2972
+ message: `Are you sure you want to create delivery order for PO# ${u.purchaseOrder.seqNumber}?`,
2973
+ primaryActions: {
2974
+ text: "Create",
2975
+ close: !0,
2976
+ variant: "primary"
2977
+ },
2978
+ secondaryActions: {
2979
+ text: "Cancel",
2980
+ close: !0
2981
+ }
2982
+ }).onPrimary(() => E());
2983
+ }
2984
+ const ee = Y(!1);
2985
+ function E() {
2986
+ ee.value = !0, o.createDeliveryOrder({
2987
+ deliveryOrder: {
2988
+ ...s,
2989
+ priceAdjustments: R.value.state().adjustments
2990
+ },
2991
+ purchaseOrderId: u.purchaseOrder._id,
2992
+ purchaseOrderRev: u.purchaseOrder._rev,
2993
+ currency: we()
2994
+ }).then(() => {
2995
+ G.open(
2996
+ {
2997
+ title: "Success",
2998
+ message: `New delivery order created for PO# ${u.purchaseOrder.seqNumber}`,
2999
+ type: "success"
3000
+ },
3001
+ 1e4
3002
+ ), l.value = !1, c("submitted");
3003
+ }).finally(() => {
3004
+ ee.value = !1;
3005
+ });
3006
+ }
3007
+ return Qe(
3008
+ () => l.value,
3009
+ (h) => {
3010
+ var J;
3011
+ if (!h) {
3012
+ I.value = [], _([]), s.received = ve.value.map((te) => ({
3013
+ sku: te.sku,
3014
+ amount: Te.fromNumber(0),
3015
+ measurement: te.measurement
3016
+ }));
3017
+ return;
3018
+ }
3019
+ const v = ve.value;
3020
+ for (let te = 0; te < v.length; te++) {
3021
+ const Re = v[te], be = (((J = u.purchaseOrder) == null ? void 0 : J.version) ?? Ve.enum[1]) === Ve.enum[2] ? Re.id : Re.sku._id, ke = u.receivedMap[be], Ne = +xe(Re.quantity), Ie = ke ? +xe(ke.received) : 0;
3022
+ oe.value[te].value = Math.max(0, Ne - Ie);
3023
+ }
3024
+ const D = N.value;
3025
+ if (D.length) {
3026
+ for (const te of D) {
3027
+ const Re = F(te);
3028
+ I.value.push({
3029
+ skuId: te.sku._id,
3030
+ stableKey: Re,
3031
+ costEnabled: !1,
3032
+ historyItem: te
3033
+ }), s.received.push({
3034
+ // Propagate the stable id so V2 submissions align with the existing PO line.
3035
+ ...k.value && te.id ? { id: te.id } : {},
3036
+ sku: te.sku,
3037
+ amount: Te.fromNumber(0),
3038
+ measurement: te.measurement ?? null
3039
+ });
3040
+ }
3041
+ for (let te = 0; te < D.length; te++) {
3042
+ const Re = F(D[te]), H = Re ? re.value[Re] : void 0;
3043
+ if (H) {
3044
+ const be = Math.pow(10, H.remaining.precision ?? 2);
3045
+ x.value[te].value = Math.max(0, H.remaining.amount / be);
3046
+ }
3047
+ }
3048
+ }
3049
+ }
3050
+ ), (h, v) => {
3051
+ const D = Z("FmButton"), J = Z("FmDatePicker"), te = Z("FmTimePicker"), Re = Z("FmIcon"), H = Z("FmStepperField"), be = Z("FmSwitch"), ke = Z("FmSelect"), Ne = Z("FmTextField"), Ie = Z("FmDialog");
3052
+ return n(), ue(Ie, {
3053
+ modelValue: l.value,
3054
+ "onUpdate:modelValue": v[4] || (v[4] = ($e) => l.value = $e),
3055
+ overlay: !0,
3056
+ "min-width": 800
3057
+ }, {
3058
+ "dialog-button": ne(() => [
3059
+ y(Q) ? (n(), ue(D, {
3060
+ key: 0,
3061
+ variant: "primary",
3062
+ label: "Create",
3063
+ size: "md",
3064
+ "prepend-icon": "add",
3065
+ class: "w-full"
3066
+ })) : A("", !0)
3067
+ ]),
3068
+ "dialog-header": ne(() => [
3069
+ e("div", null, "Order #" + b(u.purchaseOrder.seqNumber) + " (New Delivery Order)", 1)
3070
+ ]),
3071
+ "dialog-footer": ne(() => [
3072
+ C(D, {
3073
+ class: "ml-auto",
3074
+ label: "Create",
3075
+ size: "md",
3076
+ variant: "destructive",
3077
+ disabled: !de.value || ee.value,
3078
+ loading: ee.value,
3079
+ onClick: z
3080
+ }, null, 8, ["disabled", "loading"])
3081
+ ]),
3082
+ default: ne(() => {
3083
+ var $e;
3084
+ return [
3085
+ e("div", Xo, [
3086
+ e("div", Zo, [
3087
+ v[5] || (v[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
3088
+ e("div", en, b(($e = y(m).sessionUser.value) == null ? void 0 : $e.displayName), 1)
3089
+ ]),
3090
+ y(le) ? (n(), f("div", tn, [
3091
+ e("div", sn, [
3092
+ e("div", rn, [
3093
+ v[6] || (v[6] = Ge(" Delivery Date & Time ")),
3094
+ !K.value && !W.value ? (n(), f("div", on, " Leave blank to use current date & time ")) : A("", !0)
3095
+ ]),
3096
+ K.value || W.value ? (n(), ue(D, {
3097
+ key: 0,
3098
+ variant: "tertiary",
3099
+ label: "Clear",
3100
+ "prepend-icon": "close",
3101
+ onClick: T
3102
+ })) : A("", !0)
3103
+ ]),
3104
+ e("div", nn, [
3105
+ e("div", an, [
3106
+ C(J, {
3107
+ modelValue: K.value,
3108
+ "onUpdate:modelValue": v[0] || (v[0] = (fe) => K.value = fe)
3109
+ }, null, 8, ["modelValue"])
3110
+ ]),
3111
+ e("div", ln, [
3112
+ C(te, {
3113
+ modelValue: W.value,
3114
+ "onUpdate:modelValue": v[1] || (v[1] = (fe) => W.value = fe)
3115
+ }, null, 8, ["modelValue"])
3116
+ ])
3117
+ ]),
3118
+ he.value ? (n(), f("div", cn, [
3119
+ C(Re, {
3120
+ name: "error",
3121
+ class: "inline-block mr-1",
3122
+ size: "sm"
3123
+ }),
3124
+ e("div", un, b(he.value), 1)
3125
+ ])) : A("", !0)
3126
+ ])) : A("", !0),
3127
+ e("div", dn, [
3128
+ v[8] || (v[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
3129
+ (n(!0), f(Oe, null, Pe(ve.value, (fe, ce) => {
3130
+ var Le;
3131
+ return n(), f("div", { key: ce }, [
3132
+ e("div", mn, [
3133
+ e("div", pn, [
3134
+ e("span", fn, b(fe.sku.name), 1),
3135
+ e("span", vn, b(fe.sku.code), 1)
3136
+ ]),
3137
+ e("div", yn, [
3138
+ C(H, {
3139
+ label: "Receive Quantity",
3140
+ modelValue: oe.value[ce].value,
3141
+ "onUpdate:modelValue": (qe) => oe.value[ce].value = qe,
3142
+ "helper-text": q(fe),
3143
+ "append-text": ((Le = fe.measurement) == null ? void 0 : Le.abbrev) ?? fe.sku.unit.abbrev
3144
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "helper-text", "append-text"]),
3145
+ oe.value[ce].value <= 0 ? (n(), f("div", hn, b(Zt))) : A("", !0),
3146
+ y(se) ? (n(), f("div", bn, [
3147
+ C(be, {
3148
+ "model-value": _e.value[ce],
3149
+ "onUpdate:modelValue": (qe) => j(ce),
3150
+ size: "sm"
3151
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
3152
+ v[7] || (v[7] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
3153
+ ])) : A("", !0),
3154
+ y(se) && _e.value[ce] ? (n(), ue(H, {
3155
+ key: 2,
3156
+ modelValue: O.value[ce].value,
3157
+ "onUpdate:modelValue": (qe) => O.value[ce].value = qe,
3158
+ label: "Total Cost",
3159
+ step: 1e-4,
3160
+ min: 0,
3161
+ placeholder: "0.0000",
3162
+ size: "sm",
3163
+ "append-text": y(we)()
3164
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : A("", !0)
3165
+ ])
3166
+ ]),
3167
+ ce < ve.value.length - 1 ? (n(), f("div", gn)) : A("", !0)
3168
+ ]);
3169
+ }), 128))
3170
+ ]),
3171
+ e("div", _n, [
3172
+ e("div", xn, [
3173
+ v[9] || (v[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Extra items", -1)),
3174
+ C(D, {
3175
+ variant: "tertiary",
3176
+ label: "Add item",
3177
+ "prepend-icon": "add",
3178
+ size: "md",
3179
+ onClick: De
3180
+ })
3181
+ ]),
3182
+ I.value.length === 0 ? (n(), f("div", Sn, " No extra items added ")) : A("", !0),
3183
+ (n(!0), f(Oe, null, Pe(I.value, (fe, ce) => {
3184
+ var Le, qe;
3185
+ return n(), f("div", { key: ce }, [
3186
+ e("div", kn, [
3187
+ e("div", On, [
3188
+ C(ke, {
3189
+ "model-value": fe.skuId,
3190
+ "onUpdate:modelValue": (je) => a(ce, je),
3191
+ label: "Ingredient",
3192
+ items: L.value,
3193
+ searchable: "",
3194
+ searchTarget: "label",
3195
+ placeholder: "Select ingredient",
3196
+ disabled: !!fe.historyItem
3197
+ }, null, 8, ["model-value", "onUpdate:modelValue", "items", "disabled"])
3198
+ ]),
3199
+ e("div", wn, [
3200
+ C(H, {
3201
+ label: "Receive Quantity",
3202
+ modelValue: x.value[ce].value,
3203
+ "onUpdate:modelValue": (je) => x.value[ce].value = je,
3204
+ "append-text": fe.skuId ? ((qe = (Le = y(S).skuById[fe.skuId]) == null ? void 0 : Le.unit) == null ? void 0 : qe.abbrev) ?? "" : "",
3205
+ "helper-text": i(fe)
3206
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text"]),
3207
+ x.value[ce].value <= 0 ? (n(), f("div", $n, b(Zt))) : A("", !0),
3208
+ y(se) ? (n(), f("div", Cn, [
3209
+ C(be, {
3210
+ "model-value": fe.costEnabled,
3211
+ "onUpdate:modelValue": (je) => V(ce),
3212
+ size: "sm"
3213
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
3214
+ v[10] || (v[10] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
3215
+ ])) : A("", !0),
3216
+ y(se) && fe.costEnabled ? (n(), ue(H, {
3217
+ key: 2,
3218
+ modelValue: w.value[ce].value,
3219
+ "onUpdate:modelValue": (je) => w.value[ce].value = je,
3220
+ label: "Total Cost",
3221
+ step: 1e-4,
3222
+ min: 0,
3223
+ placeholder: "0.0000",
3224
+ size: "sm",
3225
+ "append-text": y(we)()
3226
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : A("", !0)
3227
+ ]),
3228
+ fe.historyItem ? A("", !0) : (n(), ue(D, {
3229
+ key: 0,
3230
+ variant: "tertiary",
3231
+ "prepend-icon": "delete",
3232
+ size: "md",
3233
+ class: "mt-6",
3234
+ onClick: (je) => Ae(ce)
3235
+ }, null, 8, ["onClick"]))
3236
+ ]),
3237
+ ce < I.value.length - 1 ? (n(), f("div", Dn)) : A("", !0)
3238
+ ]);
3239
+ }), 128))
3240
+ ]),
3241
+ e("div", An, [
3242
+ v[11] || (v[11] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
3243
+ e("div", Rn, [
3244
+ C(Ne, {
3245
+ modelValue: y(s).deliveryOrderNumber,
3246
+ "onUpdate:modelValue": v[2] || (v[2] = (fe) => y(s).deliveryOrderNumber = fe),
3247
+ size: "md"
3248
+ }, null, 8, ["modelValue"])
3249
+ ])
3250
+ ]),
3251
+ e("div", Nn, [
3252
+ v[12] || (v[12] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
3253
+ e("div", Pn, [
3254
+ C(Ne, {
3255
+ modelValue: y(s).remark,
3256
+ "onUpdate:modelValue": v[3] || (v[3] = (fe) => y(s).remark = fe),
3257
+ size: "md"
3258
+ }, null, 8, ["modelValue"])
3259
+ ])
3260
+ ]),
3261
+ y(g).enablePurchaseOrderPriceAdjustment ? (n(), ue(Rt, {
3262
+ key: 1,
3263
+ controller: y(R),
3264
+ state: y($)
3265
+ }, null, 8, ["controller", "state"])) : A("", !0)
3266
+ ])
3267
+ ];
3268
+ }),
3269
+ _: 1
3270
+ }, 8, ["modelValue"]);
3271
+ };
3272
+ }
3273
+ }), Fn = {
3274
+ key: 0,
3275
+ class: "flex flex-col gap-1"
3276
+ }, In = { class: "truncate" }, En = { class: "shrink-0" }, qn = /* @__PURE__ */ Fe({
3277
+ __name: "PriceAdjustmentList",
3278
+ props: {
3279
+ adjustments: {}
3280
+ },
3281
+ setup(p) {
3282
+ const t = p, r = B(() => t.adjustments ?? []);
3283
+ function l(m) {
3284
+ const u = m.amount < 0 ? "-" : "+", c = xe({ ...m, amount: Math.abs(m.amount) });
3285
+ return `${u}${m.currency} ${c}`;
3286
+ }
3287
+ return (m, u) => r.value.length ? (n(), f("div", Fn, [
3288
+ (n(!0), f(Oe, null, Pe(r.value, (c) => (n(), f("div", {
3289
+ key: c.id,
3290
+ class: "flex justify-between gap-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
3291
+ }, [
3292
+ e("span", In, b(c.name), 1),
3293
+ e("span", En, b(l(c.dinero)), 1)
3294
+ ]))), 128))
3295
+ ])) : A("", !0);
3296
+ }
3297
+ }), Vn = { class: "flex flex-col gap-3" }, Ln = /* @__PURE__ */ Fe({
3298
+ __name: "PriceAdjustmentEditForm",
3299
+ props: {
3300
+ purchaseOrder: {}
3301
+ },
3302
+ emits: ["submitted"],
3303
+ setup(p, { emit: t }) {
3304
+ const r = p, l = t, m = Xe(), u = Je(), c = Y(!1), s = Y(!1), { controller: o, state: d, reset: g } = Nt({
3305
+ currency: we(),
3306
+ adjustments: r.purchaseOrder.priceAdjustments
3307
+ });
3308
+ Qe(
3309
+ () => c.value,
3310
+ (R) => {
3311
+ R && g(r.purchaseOrder.priceAdjustments);
3312
+ }
3313
+ );
3314
+ function S() {
3315
+ s.value = !0, m.updatePurchaseOrder({
3316
+ ...r.purchaseOrder,
3317
+ priceAdjustments: o.value.state().adjustments
3318
+ }).then(() => {
3319
+ u.open(
3320
+ {
3321
+ title: "Success",
3322
+ message: `PO# ${r.purchaseOrder.seqNumber} price adjustments saved`,
3323
+ type: "success"
3324
+ },
3325
+ 1e4
3326
+ ), c.value = !1, l("submitted");
3327
+ }).finally(() => {
3328
+ s.value = !1;
3329
+ });
3330
+ }
3331
+ return (R, $) => {
3332
+ const _ = Z("FmButton"), M = Z("FmDialog");
3333
+ return n(), ue(M, {
3334
+ modelValue: c.value,
3335
+ "onUpdate:modelValue": $[0] || ($[0] = (P) => c.value = P),
3336
+ overlay: !0,
3337
+ "min-width": 600
3338
+ }, {
3339
+ "dialog-button": ne(() => [
3340
+ C(_, {
3341
+ variant: "plain",
3342
+ label: "Edit price adjustments",
3343
+ size: "md",
3344
+ "prepend-icon": "edit"
3345
+ })
3346
+ ]),
3347
+ "dialog-header": ne(() => [
3348
+ e("div", null, "Price adjustments — PO# " + b(r.purchaseOrder.seqNumber), 1)
3349
+ ]),
3350
+ "dialog-footer": ne(() => [
3351
+ C(_, {
3352
+ class: "ml-auto",
3353
+ label: "Apply changes",
3354
+ size: "md",
3355
+ variant: "destructive",
3356
+ disabled: s.value,
3357
+ loading: s.value,
3358
+ onClick: S
3359
+ }, null, 8, ["disabled", "loading"])
3360
+ ]),
3361
+ default: ne(() => [
3362
+ e("div", Vn, [
3363
+ C(Rt, {
3364
+ controller: y(o),
3365
+ state: y(d)
3366
+ }, null, 8, ["controller", "state"])
3367
+ ])
3368
+ ]),
3369
+ _: 1
3370
+ }, 8, ["modelValue"]);
3371
+ };
3372
+ }
3373
+ }), jn = { class: "flex flex-row-reverse" }, Un = {
3374
+ key: 0,
3375
+ class: "flex"
3376
+ }, Mn = {
3377
+ key: 1,
3378
+ class: "border-t pt-6"
3379
+ }, Bn = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, zn = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Kn = { class: "w-full" }, Hn = {
3380
+ class: "p-3 fm-typo-en-body-sm-600",
3381
+ style: { "min-width": "130px" }
3382
+ }, Gn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Wn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Qn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Yn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Jn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Xn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Zn = { class: "p-3 fm-typo-en-body-sm-600" }, ea = { key: 2 }, ta = /* @__PURE__ */ Fe({
3383
+ __name: "NetSuiteTransactionChangeLog",
3384
+ props: {
3385
+ netsuiteId: {}
3386
+ },
3387
+ setup(p) {
3388
+ const t = p, r = At(), l = Y(!1), m = Y(!1), u = Y(!1), c = Y([]);
3389
+ async function s() {
3390
+ if (!(c.value.length > 0))
3391
+ try {
3392
+ m.value = !0;
3393
+ const g = await r.getChangeLogs(t.netsuiteId);
3394
+ c.value = g, u.value = !1;
3395
+ } catch {
3396
+ u.value = !0;
3397
+ } finally {
3398
+ m.value = !1;
3399
+ }
3400
+ }
3401
+ function o(g) {
3402
+ switch (g) {
3403
+ case Me.Create:
3404
+ return "text-green-600 bg-green-100";
3405
+ case Me.Set:
3406
+ return "text-blue-600 bg-blue-100";
3407
+ case Me.Change:
3408
+ return "text-yellow-600 bg-yellow-100";
3409
+ case Me.Unset:
3410
+ return "text-red-600 bg-red-100";
3411
+ default:
3412
+ return "text-gray-600 bg-gray-100";
3413
+ }
3414
+ }
3415
+ function d(g) {
3416
+ return new Date(g).toLocaleDateString("en-US", {
3417
+ year: "numeric",
3418
+ month: "short",
3419
+ day: "numeric",
3420
+ hour: "2-digit",
3421
+ minute: "2-digit"
3422
+ });
3423
+ }
3424
+ return (g, S) => {
3425
+ const R = Z("FmButton"), $ = Z("FmCircularProgress"), _ = Z("FmIcon"), M = Z("FmDialog");
3426
+ return n(), f("div", jn, [
3427
+ C(M, {
3428
+ modelValue: l.value,
3429
+ "onUpdate:modelValue": S[2] || (S[2] = (P) => l.value = P),
3430
+ overlay: !0,
3431
+ "max-width": 800
3432
+ }, {
3433
+ "dialog-button": ne(() => [
3434
+ C(R, {
3435
+ "prepend-icon": "info",
3436
+ variant: "secondary",
3437
+ label: "NetSuite",
3438
+ onClick: S[0] || (S[0] = (P) => s()),
3439
+ "text-color": "primary",
3440
+ "bg-color": "transparent",
3441
+ "border-color": "primary"
3442
+ })
3443
+ ]),
3444
+ "dialog-header": ne(() => S[3] || (S[3] = [
3445
+ e("div", null, "NetSuite info", -1)
3446
+ ])),
3447
+ default: ne(() => [
3448
+ m.value ? (n(), f("div", Un, [
3449
+ S[4] || (S[4] = e("span", null, "Change Log Loading...", -1)),
3450
+ C($, { size: "md" })
3451
+ ])) : A("", !0),
3452
+ !m.value && c.value.length > 0 ? (n(), f("div", Mn, [
3453
+ e("h3", Bn, [
3454
+ C(_, {
3455
+ name: "error",
3456
+ color: "#ff9500",
3457
+ size: "sm"
3458
+ }),
3459
+ S[5] || (S[5] = Ge(" Change Logs "))
3460
+ ]),
3461
+ e("div", zn, [
3462
+ e("table", Kn, [
3463
+ S[6] || (S[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
3464
+ e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
3465
+ e("th", {
3466
+ class: "text-left p-3 fm-typo-en-body-md-600",
3467
+ style: { "min-width": "130px" }
3468
+ }, " Date "),
3469
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
3470
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
3471
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
3472
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
3473
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
3474
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
3475
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
3476
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
3477
+ ])
3478
+ ], -1)),
3479
+ e("tbody", null, [
3480
+ (n(!0), f(Oe, null, Pe(c.value, (P, Q) => (n(), f("tr", {
3481
+ key: Q,
3482
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
3483
+ }, [
3484
+ e("td", Hn, b(d(P._dateiso8601)), 1),
3485
+ e("td", Gn, b(P._rolename), 1),
3486
+ e("td", Wn, b(P._employeename), 1),
3487
+ e("td", Qn, b(P._contextname), 1),
3488
+ e("td", {
3489
+ class: Be(`p-3 fm-typo-en-body-sm-600 ${o(Number(P.type) - 1)}`)
3490
+ }, b(y(Me)[Number(P.type) - 1]), 3),
3491
+ e("td", Yn, b(P.lineid || ""), 1),
3492
+ e("td", Jn, b(P._fieldname), 1),
3493
+ e("td", Xn, b(P.oldvalue || ""), 1),
3494
+ e("td", Zn, b(P.newvalue || ""), 1)
3495
+ ]))), 128))
3496
+ ])
3497
+ ])
3498
+ ])
3499
+ ])) : (n(), f("div", ea, S[7] || (S[7] = [
3500
+ e("p", null, "No change logs available.", -1)
3501
+ ])))
3502
+ ]),
3503
+ "dialog-footer": ne(() => [
3504
+ C(R, {
3505
+ class: "ml-auto sm:w-full xs:w-full",
3506
+ label: "Close",
3507
+ size: "md",
3508
+ variant: "primary",
3509
+ onClick: S[1] || (S[1] = (P) => l.value = !1)
3510
+ })
3511
+ ]),
3512
+ _: 1
3513
+ }, 8, ["modelValue"])
3514
+ ]);
3515
+ };
3516
+ }
3517
+ }), sa = { class: "flex flex-col w-full gap-3" }, ra = { class: "flex" }, oa = { class: "fm-typo-en-title-md-600 text-fm-color-typo-primary" }, na = { class: "flex flex-col gap-16 w-full h-full" }, aa = { class: "flex justify-between" }, la = { class: "fm-typo-en-body-lg-600" }, ia = { class: "flex gap-2" }, ca = {
3518
+ key: 0,
3519
+ class: "flex items-center gap-1"
3520
+ }, ua = { class: "fm-typo-en-body-md-400" }, da = { class: "flex flex-col gap-8" }, ma = {
3521
+ key: 0,
3522
+ class: "flex items-start justify-between gap-6"
3523
+ }, pa = { class: "text-xs font-mono text-right break-all" }, fa = {
3524
+ key: 1,
3525
+ class: "flex items-start justify-between gap-6"
3526
+ }, va = { class: "fm-typo-en-body-sm-600" }, ya = {
3527
+ key: 2,
3528
+ class: "flex items-start justify-between gap-6"
3529
+ }, ha = { class: "text-xs font-mono text-right break-all" }, ba = {
3530
+ key: 3,
3531
+ class: "flex items-start justify-between gap-6"
3532
+ }, ga = { class: "text-xs font-mono text-right break-all" }, _a = { class: "flex flex-col gap-4" }, xa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Sa = { class: "flex gap-1" }, ka = { class: "fm-typo-en-body-lg-600" }, Oa = {
3533
+ key: 0,
3534
+ class: "flex flex-col gap-4"
3535
+ }, wa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, $a = { class: "fm-typo-en-body-lg-600" }, Ca = { class: "flex flex-col gap-4" }, Da = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Aa = { class: "fm-typo-en-body-lg-600" }, Ra = {
3536
+ key: 1,
3537
+ class: "flex flex-col gap-4"
3538
+ }, Na = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pa = { class: "fm-typo-en-body-lg-600" }, Ta = {
3539
+ key: 2,
3540
+ class: "flex flex-col gap-4"
3541
+ }, Fa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ia = { class: "fm-typo-en-body-lg-600" }, Ea = {
3542
+ key: 3,
3543
+ class: "flex flex-col gap-4"
3544
+ }, qa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Va = { class: "fm-typo-en-body-lg-600" }, La = {
3545
+ key: 4,
3546
+ class: "flex flex-col gap-4"
3547
+ }, ja = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ua = { class: "fm-typo-en-body-lg-600" }, Ma = {
3548
+ key: 5,
3549
+ class: "flex flex-col gap-4"
3550
+ }, Ba = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, za = { class: "fm-typo-en-body-lg-600" }, Ka = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Ha = { class: "flex flex-col gap-8" }, Ga = { class: "flex gap-8 items-center" }, Wa = { class: "flex-1 fm-typo-en-body-lg-600" }, Qa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Ya = { class: "flex w-full gap-4" }, Ja = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Xa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, Za = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, el = ["innerHTML"], tl = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, sl = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, rl = {
3551
+ key: 0,
3552
+ class: "flex items-center gap-4"
3553
+ }, ol = { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, nl = {
3554
+ key: 0,
3555
+ class: "inline-flex items-center gap-1 text-xs font-medium text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full"
3556
+ }, al = { class: "py-8" }, ll = { class: "flex justify-end gap-4 items-center" }, il = { class: "fm-typo-en-body-lg-600" }, cl = {
3557
+ key: 0,
3558
+ class: "flex justify-end"
3559
+ }, ul = {
3560
+ key: 1,
3561
+ class: "flex-1 xs:w-screen xs:max-w-full"
3562
+ }, dl = {
3563
+ key: 0,
3564
+ class: "flex flex-col items-center gap-8 h-full"
3565
+ }, ml = ["src"], pl = { class: "fm-typo-en-body-lg-600" }, fl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, vl = {
3566
+ key: 1,
3567
+ class: "px-4 flex flex-col"
3568
+ }, yl = { class: "flex gap-12 content-stretch" }, hl = {
3569
+ class: "flex flex-col w-40",
3570
+ name: "circles"
3571
+ }, bl = { class: "flex-1 flex flex-col items-center" }, gl = { class: "h-40 w-40 bg-fm-color-primary rounded-full flex items-center justify-center" }, _l = { class: "flex-1 flex flex-col items-center" }, xl = { class: "flex w-full items-center gap-4" }, Sl = {
3572
+ class: "py-12 flex flex-col gap-4",
3573
+ name: "received-at header"
3574
+ }, kl = { class: "fm-typo-en-body-lg-400" }, Ol = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, wl = { class: "ml-auto flex gap-1" }, $l = { class: "flex gap-12 content-stretch" }, Cl = {
3575
+ class: "flex flex-col w-40",
3576
+ name: "circles"
3577
+ }, Dl = { class: "flex-1 flex flex-col items-center" }, Al = {
3578
+ class: "py-12 flex flex-col gap-4 flex-1",
3579
+ name: "delivery details"
3580
+ }, Rl = { class: "flex flex-col gap-8" }, Nl = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Pl = { class: "flex flex-col gap-4" }, Tl = {
3581
+ key: 2,
3582
+ class: "flex-1 xs:w-screen xs:max-w-full"
3583
+ }, Fl = {
3584
+ key: 0,
3585
+ class: "flex flex-col items-center gap-8 h-full"
3586
+ }, Il = ["src"], El = { class: "fm-typo-en-body-lg-600" }, ql = {
3587
+ key: 1,
3588
+ class: "px-4 flex flex-col gap-12"
3589
+ }, Vl = { class: "flex flex-col gap-4" }, Ll = { class: "flex justify-between gap-8" }, jl = { class: "fm-typo-en-body-lg-600" }, Ul = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary whitespace-nowrap" }, Ml = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bl = {
3590
+ key: 0,
3591
+ class: "fm-typo-en-body-md-400"
3592
+ }, zl = { class: "flex gap-8 xs:flex-col" }, ki = /* @__PURE__ */ Fe({
3593
+ __name: "TransferDetails",
3594
+ props: {
3595
+ poRequest: {},
3596
+ purchaseOrder: {},
3597
+ transferTo: {},
3598
+ transferToDbName: {},
3599
+ show: { type: Boolean },
3600
+ canResubmit: { type: Boolean },
3601
+ canApprove: { type: Boolean },
3602
+ scope: {},
3603
+ receivedMap: {},
3604
+ shipments: {}
3605
+ },
3606
+ emits: ["update:show", "submitted"],
3607
+ setup(p, { emit: t }) {
3608
+ const r = p, l = t, m = bt(), u = Je(), c = Ye(), s = ze(), o = yt(), { hasOrderDraftPermission: d } = vs(), g = ps();
3609
+ function S(a) {
3610
+ const i = a.isCustomCost, x = a.totalCost;
3611
+ return i != null ? i === !0 : x != null;
3612
+ }
3613
+ Qe(
3614
+ () => r.purchaseOrder,
3615
+ (a) => {
3616
+ g.init(a);
3617
+ },
3618
+ { immediate: !0 }
3619
+ );
3620
+ const R = B(
3621
+ () => {
3622
+ var a, i;
3623
+ return {
3624
+ id: ((a = o.sessionUser.value) == null ? void 0 : a.id) ?? "",
3625
+ name: ((i = o.sessionUser.value) == null ? void 0 : i.displayName) ?? ""
3626
+ };
3627
+ }
3628
+ ), $ = fs(), { t: _ } = vt(), M = B(
3629
+ () => {
3630
+ var a, i, x, w;
3631
+ return ((i = (a = r.purchaseOrder) == null ? void 0 : a.supplier) == null ? void 0 : i.internal) === "restaurant" || ((w = (x = r.purchaseOrder) == null ? void 0 : x.supplier) == null ? void 0 : w.internal) === "warehouse" ? nt.enum.transfer : nt.enum.purchase;
3632
+ }
3633
+ ), P = B(() => {
3634
+ var x;
3635
+ const a = (x = r.shipments) == null ? void 0 : x.find((w) => {
3636
+ var V;
3637
+ return w.ref === ((V = r.purchaseOrder) == null ? void 0 : V._id);
3638
+ });
3639
+ let i = null;
3640
+ if (a != null && a.milestones && a.milestones.length > 0) {
3641
+ const w = a.milestones[a.milestones.length - 1];
3642
+ if (w.estimatedTime) {
3643
+ const V = new Date(w.estimatedTime), z = V.getDate().toString().padStart(2, "0");
3644
+ i = `${V.toLocaleString("en-US", { month: "short" })} ${z}`;
3645
+ }
3646
+ }
3647
+ return i;
3648
+ }), Q = Y(!1), se = Y(""), le = Y(!0), _e = Xe(), ve = Js(_e.getWorkflowConfig), N = ms(), re = [
3649
+ U.enum.receiveStock,
3650
+ U.enum.processRequest,
3651
+ U.enum.closeRequest
3652
+ ], k = B(() => {
3653
+ if (!r.purchaseOrder)
3654
+ return [];
3655
+ const a = ve.result.value;
3656
+ if (a.state === Wt.loading)
3657
+ return [];
3658
+ const i = {
3659
+ user: R.value,
3660
+ executedAt: s.locations.computeFirst(
3661
+ (ee) => {
3662
+ var E;
3663
+ return ee.dbName === ((E = s._currentLocation) == null ? void 0 : E.dbName) ? ee : null;
3664
+ }
3665
+ ),
3666
+ purchaseOrderRequest: r.poRequest,
3667
+ purchaseOrder: r.purchaseOrder
3668
+ }, x = c.useOperatePurchaseOrderV2, w = c.poWorkflowAllowToMarkCompleted, V = [...re];
3669
+ x && !w && V.push(U.enum.completeReceive);
3670
+ let z = [];
3671
+ try {
3672
+ a.state === Wt.error ? (console.error("Error fetching workflow config:", a.error), z = gt.getAvailableActions({
3673
+ ...i,
3674
+ orderConfig: gt.getDefaultConfig()
3675
+ }).actions.filter((ee) => !V.includes(ee))) : z = gt.getAvailableActions({
3676
+ ...i,
3677
+ orderConfig: a.data
3678
+ }).actions.filter((ee) => !V.includes(ee));
3679
+ } catch (ee) {
3680
+ console.error("Error getting available actions:", ee);
3681
+ }
3682
+ return r.scope === "approval" && (z = z.filter((ee) => ee !== U.enum.completeReceive)), d.value || (z = z.filter(
3683
+ (ee) => ee !== U.enum.approveDraft && ee !== U.enum.rejectDraft
3684
+ )), z;
3685
+ }), F = zs(r, "show"), G = B(() => [
3686
+ {
3687
+ label: _("inventory.transfer.receiveRequest.details.overview"),
3688
+ value: "overview"
3689
+ },
3690
+ {
3691
+ label: _("inventory.transfer.receiveRequest.details.deliveryHistory"),
3692
+ value: "deliveryHistory"
3693
+ },
3694
+ {
3695
+ label: _("inventory.transfer.receiveRequest.details.actionLogs"),
3696
+ value: "actionLogs"
3697
+ }
3698
+ ]), K = Y(G.value[0]);
3699
+ Qe(
3700
+ () => r.show,
3701
+ (a) => {
3702
+ a && (K.value = G.value[0]);
3703
+ }
3704
+ );
3705
+ function W(a) {
3706
+ return a.map((i) => ({
3707
+ ...i,
3708
+ amount: {
3709
+ ...i.amount,
3710
+ amount: -Math.abs(i.amount.amount)
3711
+ }
3712
+ }));
3713
+ }
3714
+ async function ye(a, i, x, w, V) {
3715
+ return new Promise((z, ee) => {
3716
+ const E = {
3717
+ closeButton: !1,
3718
+ title: w.title,
3719
+ message: w.message,
3720
+ primaryActions: w.primaryActions,
3721
+ secondaryActions: { text: "No", close: !1 }
3722
+ };
3723
+ let pe = i.rejectReason ?? "";
3724
+ x === U.enum.rejectDraft && (E.contentComponent = ds, E.contentComponentProps = {
3725
+ message: w.message,
3726
+ onChange: (ie) => {
3727
+ pe = ie ?? "";
3728
+ }
3729
+ }), m.open(E).onPrimary(async () => {
3730
+ var Se, h, v, D;
3731
+ const ie = [];
3732
+ x === U.enum.confirmDraft || x === U.enum.submitRequest ? ie.push({
3733
+ action: "confirmDraft",
3734
+ payload: g.controller.value.toConfirmDraftData(we())
3735
+ }) : x === U.enum.approveRequest ? (ie.push({
3736
+ action: "approveRequest",
3737
+ payload: null
3738
+ }), i.fulfillment && ie.push({
3739
+ action: "processRequest",
3740
+ payload: {
3741
+ fulfillmentId: "",
3742
+ deliveryOrderNumber: "",
3743
+ deliveryRemark: null,
3744
+ items: W(i.fulfillment.items),
3745
+ createdBy: R.value
3746
+ }
3747
+ })) : x === U.enum.processRequest ? i.fulfillment && ie.push({
3748
+ action: "processRequest",
3749
+ payload: {
3750
+ fulfillmentId: "",
3751
+ deliveryOrderNumber: "",
3752
+ deliveryRemark: null,
3753
+ items: W(i.fulfillment.items),
3754
+ createdBy: R.value
3755
+ }
3756
+ }) : x === U.enum.rejectRequest ? ie.push({
3757
+ action: "rejectRequest",
3758
+ payload: null
3759
+ }) : x === U.enum.closeRequest ? ie.push({
3760
+ action: "closeRequest",
3761
+ payload: null
3762
+ }) : x === U.enum.rejectDraft && ie.push({
3763
+ action: "rejectDraft",
3764
+ payload: {
3765
+ rejectReason: pe ?? ""
3766
+ }
3767
+ });
3768
+ try {
3769
+ await N({
3770
+ operate: {
3771
+ operation: x,
3772
+ doc: a,
3773
+ options: i
3774
+ },
3775
+ operateV2: {
3776
+ _id: ((Se = r.purchaseOrder) == null ? void 0 : Se._id) ?? "",
3777
+ _rev: ((h = r.purchaseOrder) == null ? void 0 : h._rev) ?? "",
3778
+ action: x === U.enum.submitRequest ? U.enum.confirmDraft : x,
3779
+ payloads: ie
3780
+ // add payload if action is receiveStock or processRequest
3781
+ },
3782
+ transferTo: (D = (v = r.poRequest) == null ? void 0 : v.to) == null ? void 0 : D.dbName
3783
+ }).delayed(1e3), z("submitted");
3784
+ } catch (J) {
3785
+ ee(J);
3786
+ }
3787
+ }).onSecondary(() => {
3788
+ z("cancelled");
3789
+ for (let ie = 0; ie < V + 2; ie++)
3790
+ m.close();
3791
+ }).onClose(() => {
3792
+ });
3793
+ });
3794
+ }
3795
+ async function me(a) {
3796
+ var V, z, ee, E;
3797
+ if (a === U.enum.receiveStock)
3798
+ return;
3799
+ const i = us[a];
3800
+ if (!i) {
3801
+ u.open({
3802
+ title: "Something went wrong",
3803
+ message: `Cannot process order: ${Ct(a)}`,
3804
+ type: "error"
3805
+ });
3806
+ return;
3807
+ }
3808
+ const { successMessage: x, ...w } = i;
3809
+ if (r.purchaseOrder) {
3810
+ se.value = `${a}`, Q.value = !0, le.value = !1;
3811
+ const pe = {};
3812
+ let ie = 0;
3813
+ if ((a === U.enum.confirmDraft || // auto receive for warehouse to warehouse
3814
+ a === U.enum.completeReceive) && c.autoReceiveWarehouse)
3815
+ pe.autoReceive = !0;
3816
+ else if ((a === U.enum.approveRequest || a === U.enum.processRequest) && c.acceptRequireFulfillment) {
3817
+ const Se = (z = (V = r.poRequest) == null ? void 0 : V.from) == null ? void 0 : z.dbName, h = (E = (ee = r.poRequest) == null ? void 0 : ee.to) == null ? void 0 : E.dbName;
3818
+ if (Se && h && (Se.startsWith("warehouse_") || h.startsWith("warehouse_"))) {
3819
+ const v = await new Promise((D, J) => {
3820
+ m.open({
3821
+ closeButton: !1,
3822
+ title: "Confirm transfer amount",
3823
+ dialogComponent: $r,
3824
+ dialogComponentProps: {
3825
+ purchaseOrder: r.purchaseOrder,
3826
+ confirm: D,
3827
+ "onUpdate:show": (te) => {
3828
+ te || (se.value = "", Q.value = !1, le.value = !0, ie++, m.close()), J("cancelled");
3829
+ }
3830
+ }
3831
+ });
3832
+ });
3833
+ pe.fulfillment = v;
3834
+ }
3835
+ }
3836
+ try {
3837
+ await ye(
3838
+ r.purchaseOrder,
3839
+ pe,
3840
+ a,
3841
+ i,
3842
+ ie
3843
+ ) === "submitted" && (u.open({
3844
+ title: "Success",
3845
+ message: x,
3846
+ type: "success"
3847
+ }), l("update:show", !1), l("submitted"));
3848
+ } catch (Se) {
3849
+ u.open({
3850
+ title: "Something went wrong",
3851
+ message: Se instanceof Error ? Se.message : "Please try again.",
3852
+ type: "error"
3853
+ }), console.error("Error when submitting PO operation", a, r.purchaseOrder, Se);
3854
+ } finally {
3855
+ se.value = "", Q.value = !1, le.value = !0;
3856
+ }
3857
+ }
3858
+ }
3859
+ const he = B(() => {
3860
+ var a, i;
3861
+ return ((a = r.purchaseOrder) == null ? void 0 : a.status) === ge.enum.RECEIVING || ((i = r.purchaseOrder) == null ? void 0 : i.status) === ge.enum.COMPLETE;
3862
+ }), de = B(() => r.purchaseOrder ? pt(r.purchaseOrder) : {}), q = B(() => {
3863
+ const a = r.purchaseOrder;
3864
+ if (!a) return { status: "", statusClass: "" };
3865
+ const { partial: i, over: x } = kt(de.value), w = Ot(a.status, i, x);
3866
+ let V = _(`inventory.transfer.status.${w}`), z = `${a.status}`.toLocaleLowerCase("en-us");
3867
+ return w === ge.enum.CLOSE && (V = `${_(`inventory.transfer.status.${ge.enum.COMPLETE}`)}`), w === "PARTIAL_RECEIVED" && z === ge.enum.PROCESSING.toLocaleLowerCase("en-us") && (z = ge.enum.RECEIVING.toLocaleLowerCase("en-us")), {
3868
+ status: V,
3869
+ statusClass: `fm-status-badge fm-status-badge-${z}`
3870
+ };
3871
+ }), T = B(() => {
3872
+ var z, ee;
3873
+ const a = ((z = r.purchaseOrder) == null ? void 0 : z.deliveryOrder) ?? [], i = ((ee = r.purchaseOrder) == null ? void 0 : ee.deliveryFullfillment) ?? [], x = [
3874
+ ...a.map((E) => ({
3875
+ createdAt: E.createdAt,
3876
+ type: "grn",
3877
+ doc: E
3878
+ })),
3879
+ ...i.map((E) => ({
3880
+ createdAt: E.createdAt,
3881
+ type: "fulfillment",
3882
+ doc: E
3883
+ }))
3884
+ ];
3885
+ x.reverse().sort((E, pe) => E.createdAt.localeCompare(pe.createdAt));
3886
+ function w(E) {
3887
+ var Se, h, v, D, J, te, Re, H, be, ke, Ne, Ie;
3888
+ const pe = i.findIndex(($e) => $e.id === E.fullfillmentId), ie = [
3889
+ (h = (Se = i[pe]) == null ? void 0 : Se.netSuite) != null && h.id ? {
3890
+ label: "Fulfillment's ref no. (Netsuite)",
3891
+ values: [
3892
+ `${((D = (v = i[pe]) == null ? void 0 : v.netSuite) == null ? void 0 : D.refNo) ?? "N/A"} (${((te = (J = i[pe]) == null ? void 0 : J.netSuite) == null ? void 0 : te.id) ?? "-"})`
3893
+ ]
3894
+ } : null,
3895
+ (Re = E == null ? void 0 : E.netSuite) != null && Re.id ? {
3896
+ label: "Netsuite ref no.",
3897
+ values: [`${((H = E == null ? void 0 : E.netSuite) == null ? void 0 : H.refNo) ?? "N/A"} (${((be = E == null ? void 0 : E.netSuite) == null ? void 0 : be.id) ?? "-"})`]
3898
+ } : null,
3899
+ (ke = E == null ? void 0 : E.netSuite) != null && ke.recordType ? {
3900
+ label: "Netsuite Type",
3901
+ values: [os((Ne = E == null ? void 0 : E.netSuite) == null ? void 0 : Ne.recordType)]
3902
+ } : null
3903
+ ];
3904
+ return {
3905
+ header: "Received",
3906
+ deliveryOrder: E,
3907
+ date: Ze(new Date(E.createdAt)),
3908
+ info: [
3909
+ {
3910
+ label: "Adjustment date",
3911
+ values: [
3912
+ E.adjustment ? Ze(new Date(ut(E.adjustment))) : "-"
3913
+ ]
3914
+ },
3915
+ {
3916
+ label: "Received by",
3917
+ values: [(Ie = E.createdBy) == null ? void 0 : Ie.name]
3918
+ },
3919
+ {
3920
+ label: "Received items",
3921
+ values: E.received.map(($e) => {
3922
+ var fe;
3923
+ return X("div", [
3924
+ X(
3925
+ "div",
3926
+ {
3927
+ class: "flex gap-4"
3928
+ },
3929
+ [
3930
+ X(
3931
+ "div",
3932
+ {
3933
+ class: "flex flex-col"
3934
+ },
3935
+ [
3936
+ X(
3937
+ "span",
3938
+ {
3939
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
3940
+ },
3941
+ `${$e.sku.name}`
3942
+ ),
3943
+ X(
3944
+ "span",
3945
+ {
3946
+ class: "fm-typo-en-body-md-400"
3947
+ },
3948
+ `${$e.sku.code} `
3949
+ )
3950
+ ]
3951
+ ),
3952
+ X(
3953
+ "div",
3954
+ {
3955
+ class: "ml-auto flex flex-col"
3956
+ },
3957
+ [
3958
+ X(
3959
+ "div",
3960
+ {
3961
+ class: "ml-auto flex gap-1"
3962
+ },
3963
+ [
3964
+ X(
3965
+ "span",
3966
+ {
3967
+ class: "fm-typo-en-body-lg-600 self-end"
3968
+ },
3969
+ xe($e.amount, !1)
3970
+ ),
3971
+ X(
3972
+ "span",
3973
+ {
3974
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
3975
+ },
3976
+ ((fe = $e.measurement) == null ? void 0 : fe.abbrev) ?? $e.sku.unit.abbrev
3977
+ )
3978
+ ]
3979
+ ),
3980
+ X(
3981
+ "div",
3982
+ {
3983
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
3984
+ },
3985
+ `${$e.cost ? `(${lt($e.cost)})` : ""}`
3986
+ )
3987
+ ]
3988
+ )
3989
+ ]
3990
+ )
3991
+ ]);
3992
+ })
3993
+ },
3994
+ {
3995
+ label: "Delivery order no.",
3996
+ values: [E.deliveryOrderNumber || "N/A"]
3997
+ },
3998
+ {
3999
+ label: "Remark",
4000
+ values: [E.remark || "N/A"]
4001
+ },
4002
+ pe > -1 ? {
4003
+ label: "Fulfilment's sequence",
4004
+ values: [`${pe + 1}`]
4005
+ } : null,
4006
+ ...ie
4007
+ ].filter(($e) => !!$e)
4008
+ };
4009
+ }
4010
+ function V(E) {
4011
+ var ie, Se, h;
4012
+ const pe = i.findIndex((v) => v.id === E.id);
4013
+ return {
4014
+ header: "Fulfillment",
4015
+ date: Ze(new Date(E.createdAt)),
4016
+ info: [
4017
+ {
4018
+ label: "Sequence",
4019
+ values: [String(pe + 1)]
4020
+ },
4021
+ {
4022
+ label: "Receiveable items",
4023
+ values: E.items.map((v) => {
4024
+ var D;
4025
+ return X("div", [
4026
+ X(
4027
+ "div",
4028
+ {
4029
+ class: "flex gap-4"
4030
+ },
4031
+ [
4032
+ X(
4033
+ "div",
4034
+ {
4035
+ class: "flex flex-col"
4036
+ },
4037
+ [
4038
+ X(
4039
+ "span",
4040
+ {
4041
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
4042
+ },
4043
+ `${v.sku.name}`
4044
+ ),
4045
+ X(
4046
+ "span",
4047
+ {
4048
+ class: "fm-typo-en-body-md-400"
4049
+ },
4050
+ `${v.sku.code} `
4051
+ )
4052
+ ]
4053
+ ),
4054
+ X(
4055
+ "div",
4056
+ {
4057
+ class: "ml-auto flex flex-col"
4058
+ },
4059
+ [
4060
+ X(
4061
+ "div",
4062
+ {
4063
+ class: "ml-auto flex gap-1"
4064
+ },
4065
+ [
4066
+ X(
4067
+ "span",
4068
+ {
4069
+ class: "fm-typo-en-body-lg-600 self-end"
4070
+ },
4071
+ xe(v.amount, !1)
4072
+ ),
4073
+ X(
4074
+ "span",
4075
+ {
4076
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
4077
+ },
4078
+ ((D = v.measurement) == null ? void 0 : D.abbrev) ?? v.sku.unit.abbrev
4079
+ )
4080
+ ]
4081
+ ),
4082
+ X(
4083
+ "div",
4084
+ {
4085
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
4086
+ },
4087
+ `${v.cost ? `(${lt(v.cost)})` : ""}`
4088
+ )
4089
+ ]
4090
+ )
4091
+ ]
4092
+ )
4093
+ ]);
4094
+ })
4095
+ },
4096
+ (ie = E.netSuite) != null && ie.refNo ? {
4097
+ label: "Netsuite Ref no. (ID)",
4098
+ values: [`${(Se = E.netSuite) == null ? void 0 : Se.refNo} (${((h = E.netSuite) == null ? void 0 : h.id) ?? "-"})`]
4099
+ } : null
4100
+ ].filter((v) => !!v)
4101
+ };
4102
+ }
4103
+ return x.map(
4104
+ (E) => E.type === "grn" ? w(E.doc) : V(E.doc)
4105
+ );
4106
+ });
4107
+ function oe(a) {
4108
+ var z;
4109
+ const x = (((z = r.purchaseOrder) == null ? void 0 : z.version) ?? Ve.enum[1]) === Ve.enum[2] ? a.id : a.sku._id, w = r.receivedMap[x], V = O(a);
4110
+ return w ? `<span class="${V} fm-typo-en-body-lg-600">${Te.toFormatString({ value: w.received })}</span>/${mt(a.quantity, a.sku.unit, a.measurement)}` : `<span class="fm-typo-en-body-lg-600">-</span>/${mt(a.quantity, a.sku.unit, a.measurement)}`;
4111
+ }
4112
+ function j(a) {
4113
+ const i = r.purchaseOrder;
4114
+ if (!(i != null && i.itemsAtSubmission)) return !1;
4115
+ const x = i.version === Ve.enum[2], w = x ? a.id : a.sku._id;
4116
+ return w == null ? !1 : !i.itemsAtSubmission.some((V) => (x ? V.id : V.sku._id) === w);
4117
+ }
4118
+ function O(a) {
4119
+ var pe;
4120
+ const x = (((pe = r.purchaseOrder) == null ? void 0 : pe.version) ?? Ve.enum[1]) === Ve.enum[2] ? a.id : a.sku._id, w = r.receivedMap[x], { isPartialReceive: V, isNoReceive: z, isOverReceive: ee, isFullReceive: E } = fr(w);
4121
+ return z ? "text-fm-color-typo-tertiary" : V ? "text-fm-color-system-warning-300" : ee ? "text-fm-color-system-error-300" : E ? "text-fm-color-system-success-300" : "";
4122
+ }
4123
+ const I = B(() => {
4124
+ var a, i, x;
4125
+ return (a = r.purchaseOrder) != null && a.itemsAtSubmission ? ((i = r.purchaseOrder) == null ? void 0 : i.version) === Ve.enum[2] ? r.purchaseOrder.items.reduce((w, V) => {
4126
+ var ee, E;
4127
+ const z = (E = (ee = r.purchaseOrder) == null ? void 0 : ee.itemsAtSubmission) == null ? void 0 : E.find(
4128
+ (pe) => pe.id === V.id
4129
+ );
4130
+ return z && z.quantity !== V.quantity && w.set(V.sku.code, {
4131
+ originalAmount: Number(Te.toFormatString({ value: z.quantity })),
4132
+ newAmount: Number(Te.toFormatString({ value: V.quantity }))
4133
+ }), w;
4134
+ }, /* @__PURE__ */ new Map()) : (x = r.purchaseOrder) == null ? void 0 : x.items.reduce((w, V) => {
4135
+ var pe, ie;
4136
+ const z = (ie = (pe = r.purchaseOrder) == null ? void 0 : pe.itemsAtSubmission) == null ? void 0 : ie.find(
4137
+ (Se) => Se.sku._id === V.sku._id
4138
+ ), ee = z ? Number(Te.toFormatString({ value: z.quantity })) : 0, E = Number(Te.toFormatString({ value: V.quantity }));
4139
+ return z && ee !== E && w.set(V.sku.code, {
4140
+ originalAmount: ee,
4141
+ newAmount: E
4142
+ }), w;
4143
+ }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
4144
+ }), L = (a) => {
4145
+ var x, w;
4146
+ const i = I.value;
4147
+ return ((x = r.purchaseOrder) == null ? void 0 : x.version) === Ve.enum[2] ? i.has(a.id) : i.has((w = a.sku) == null ? void 0 : w.code);
4148
+ }, ae = (a) => {
4149
+ var x, w;
4150
+ const i = I.value;
4151
+ return ((x = r.purchaseOrder) == null ? void 0 : x.version) === Ve.enum[2] ? i.get(a.id) : i.get((w = a.sku) == null ? void 0 : w.code);
4152
+ }, De = B(() => {
4153
+ const a = r.purchaseOrder;
4154
+ if (!a) return "";
4155
+ const i = a.actionChangelogs ?? [], x = i.length ? i[i.length - 1] : null;
4156
+ if (x && x.action === "rejectDraft") {
4157
+ const w = x.remarks ?? "";
4158
+ return w && w.toString().trim() !== "" ? w.toString() : "-";
4159
+ }
4160
+ return "";
4161
+ }), Ae = B(() => {
4162
+ const a = r.purchaseOrder;
4163
+ return a ? [...a.actionChangelogs ?? []].reverse() : [];
4164
+ });
4165
+ return (a, i) => {
4166
+ const x = Z("FmButton"), w = Z("FmButtonGroup"), V = Z("FmChip"), z = Z("FmIcon"), ee = Z("FmMenuDivider"), E = Z("FmCard"), pe = Z("FmTooltip"), ie = Z("FmSpacer"), Se = Z("FmSideSheet");
4167
+ return n(), ue(Se, {
4168
+ modelValue: y(F),
4169
+ "onUpdate:modelValue": i[9] || (i[9] = (h) => Ds(F) ? F.value = h : null),
4170
+ "dismiss-away": le.value,
4171
+ "max-width": 600,
4172
+ "close-button": !1
4173
+ }, {
4174
+ "side-sheet-header": ne(() => {
4175
+ var h, v;
4176
+ return [
4177
+ e("div", sa, [
4178
+ e("div", ra, [
4179
+ e("div", oa, b(y(_)("inventory.transfer.receiveRequest.details.title") + ((h = a.purchaseOrder) != null && h.seqNumber ? ` #${(v = a.purchaseOrder) == null ? void 0 : v.seqNumber}` : "")), 1),
4180
+ C(x, {
4181
+ class: "ml-auto -m-2",
4182
+ variant: "tertiary",
4183
+ "prepend-icon": "close",
4184
+ onClick: i[0] || (i[0] = (D) => l("update:show", !1))
4185
+ })
4186
+ ]),
4187
+ C(w, {
4188
+ items: G.value,
4189
+ modelValue: K.value,
4190
+ "onUpdate:modelValue": i[1] || (i[1] = (D) => K.value = D)
4191
+ }, null, 8, ["items", "modelValue"]),
4192
+ a.purchaseOrder && K.value.value === "deliveryHistory" ? (n(), ue(Tn, {
4193
+ key: 0,
4194
+ "purchase-order": a.purchaseOrder,
4195
+ "received-info-map": de.value,
4196
+ "received-map": a.receivedMap,
4197
+ onSubmitted: i[2] || (i[2] = () => {
4198
+ l("update:show", !1), l("submitted");
4199
+ })
4200
+ }, null, 8, ["purchase-order", "received-info-map", "received-map"])) : A("", !0)
4201
+ ])
4202
+ ];
4203
+ }),
4204
+ default: ne(() => {
4205
+ var h, v, D, J, te, Re;
4206
+ return [
4207
+ e("div", na, [
4208
+ K.value.value === "overview" ? (n(), f(Oe, { key: 0 }, [
4209
+ e("div", null, [
4210
+ C(E, {
4211
+ variant: "outlined",
4212
+ class: "flex flex-col gap-8 px-12 py-16"
4213
+ }, {
4214
+ default: ne(() => {
4215
+ var H, be, ke, Ne, Ie, $e, fe, ce, Le, qe;
4216
+ return [
4217
+ e("div", aa, [
4218
+ e("div", la, b(y(_)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
4219
+ e("div", ia, [
4220
+ C(V, {
4221
+ label: q.value.status,
4222
+ class: Be(q.value.statusClass),
4223
+ compact: ""
4224
+ }, null, 8, ["label", "class"]),
4225
+ P.value ? (n(), f("div", ca, [
4226
+ C(z, {
4227
+ name: "local_shipping",
4228
+ color: "#666666"
4229
+ }),
4230
+ e("span", ua, b(P.value), 1)
4231
+ ])) : A("", !0)
4232
+ ])
4233
+ ]),
4234
+ C(ee),
4235
+ e("div", da, [
4236
+ C(Xt, { title: "Debug Info" }, {
4237
+ default: ne(() => {
4238
+ var je, Pt, Tt, Ft, It, Et, qt, Vt, Lt, jt, Ut, Mt;
4239
+ return [
4240
+ (je = a.purchaseOrder) != null && je._id ? (n(), f("div", ma, [
4241
+ i[10] || (i[10] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Purchase Order ID ", -1)),
4242
+ e("span", pa, b((Pt = a.purchaseOrder) == null ? void 0 : Pt._id), 1)
4243
+ ])) : A("", !0),
4244
+ (Tt = a.purchaseOrder) != null && Tt.status ? (n(), f("div", fa, [
4245
+ i[11] || (i[11] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Purchase Order Status ", -1)),
4246
+ e("span", va, b((Ft = a.purchaseOrder) == null ? void 0 : Ft.status), 1)
4247
+ ])) : A("", !0),
4248
+ (Et = (It = a.purchaseOrder) == null ? void 0 : It.supplier) != null && Et._id ? (n(), f("div", ya, [
4249
+ i[12] || (i[12] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Source Location ID ", -1)),
4250
+ e("span", ha, b(((Vt = (qt = a.purchaseOrder) == null ? void 0 : qt.supplier) == null ? void 0 : Vt.internal) != null ? `${(jt = (Lt = a.purchaseOrder) == null ? void 0 : Lt.supplier) == null ? void 0 : jt.internal}_` : "") + b((Mt = (Ut = a.purchaseOrder) == null ? void 0 : Ut.supplier) == null ? void 0 : Mt._id), 1)
4251
+ ])) : A("", !0),
4252
+ a.transferToDbName ? (n(), f("div", ba, [
4253
+ i[13] || (i[13] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Destination Location ID ", -1)),
4254
+ e("span", ga, b(a.transferToDbName), 1)
4255
+ ])) : A("", !0)
4256
+ ];
4257
+ }),
4258
+ _: 1
4259
+ }),
4260
+ e("div", _a, [
4261
+ e("div", xa, [
4262
+ e("div", Sa, b(y(_)("inventory.transfer.receiveRequest.details.createdAt")), 1)
4263
+ ]),
4264
+ e("div", ka, b(y(at)(((H = a.purchaseOrder) == null ? void 0 : H._id) ?? "")), 1)
4265
+ ]),
4266
+ (be = a.purchaseOrder) != null && be.effectiveAt ? (n(), f("div", Oa, [
4267
+ e("div", wa, b(y(_)("inventory.transfer.receiveRequest.details.date")), 1),
4268
+ e("div", $a, b(y(Dt)(new Date((ke = a.purchaseOrder) == null ? void 0 : ke.effectiveAt))), 1)
4269
+ ])) : A("", !0),
4270
+ e("div", Ca, [
4271
+ e("div", Da, b(y(_)("inventory.transfer.receiveRequest.details.type.title")), 1),
4272
+ e("div", Aa, b(y(_)(
4273
+ `inventory.transfer.receiveRequest.details.type.${M.value.toLocaleLowerCase("en-US")}`
4274
+ )), 1)
4275
+ ]),
4276
+ (Ie = (Ne = a.purchaseOrder) == null ? void 0 : Ne.supplier) != null && Ie.name ? (n(), f("div", Ra, [
4277
+ e("div", Na, b(y(_)("inventory.transfer.receiveRequest.details.from")), 1),
4278
+ e("div", Pa, b((fe = ($e = a.purchaseOrder) == null ? void 0 : $e.supplier) == null ? void 0 : fe.name), 1)
4279
+ ])) : A("", !0),
4280
+ a.transferTo ? (n(), f("div", Ta, [
4281
+ e("div", Fa, b(y(_)("inventory.transfer.receiveRequest.details.to")), 1),
4282
+ e("div", Ia, b(a.transferTo), 1)
4283
+ ])) : A("", !0),
4284
+ (ce = a.purchaseOrder) != null && ce.ref ? (n(), f("div", Ea, [
4285
+ e("div", qa, b(y(_)("inventory.transfer.receiveRequest.details.reference")), 1),
4286
+ e("div", Va, b(a.purchaseOrder.ref), 1)
4287
+ ])) : A("", !0),
4288
+ (Le = a.purchaseOrder) != null && Le.remark ? (n(), f("div", La, [
4289
+ e("div", ja, b(y(_)("inventory.transfer.receiveRequest.details.remark")), 1),
4290
+ e("div", Ua, b(a.purchaseOrder.remark), 1)
4291
+ ])) : A("", !0),
4292
+ ((qe = a.purchaseOrder) == null ? void 0 : qe.status) === y(ge).enum.DRAFT && De.value ? (n(), f("div", Ma, [
4293
+ e("div", Ba, b(y(_)("inventory.transfer.receiveRequest.details.rejectionReason")), 1),
4294
+ e("div", za, b(De.value !== "" ? De.value : "-"), 1)
4295
+ ])) : A("", !0)
4296
+ ])
4297
+ ];
4298
+ }),
4299
+ _: 1
4300
+ })
4301
+ ]),
4302
+ C(ko, {
4303
+ "po-request": a.poRequest,
4304
+ purchaseOrder: a.purchaseOrder,
4305
+ transferType: M.value,
4306
+ transferToDbName: a.transferToDbName,
4307
+ scope: a.scope
4308
+ }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
4309
+ e("div", Ka, [
4310
+ e("div", Ha, [
4311
+ e("div", Ga, [
4312
+ e("span", Wa, [
4313
+ Ge(b(he.value ? y(_)("inventory.transfer.receiveRequest.details.receivedItems") : y(_)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
4314
+ (v = (h = a.purchaseOrder) == null ? void 0 : h.netSuite) != null && v.missingItems && ((J = (D = a.purchaseOrder) == null ? void 0 : D.netSuite) == null ? void 0 : J.missingItems.length) > 0 ? (n(), ue(pe, {
4315
+ key: 0,
4316
+ variant: "rich",
4317
+ placement: "top",
4318
+ "z-index": 51
4319
+ }, {
4320
+ content: ne(() => {
4321
+ var H, be;
4322
+ return [
4323
+ e("div", Qa, [
4324
+ (n(!0), f(Oe, null, Pe((be = (H = a.purchaseOrder) == null ? void 0 : H.netSuite) == null ? void 0 : be.missingItems, (ke, Ne) => (n(), f("div", {
4325
+ class: "flex justify-center align-middle",
4326
+ key: Ne
4327
+ }, [
4328
+ C(z, {
4329
+ name: "arrow_right",
4330
+ size: "sm"
4331
+ }),
4332
+ Ge(" " + b(`(${ke.netSuiteId}) ${ke.name}: ${ke.reason}`), 1)
4333
+ ]))), 128))
4334
+ ])
4335
+ ];
4336
+ }),
4337
+ default: ne(() => [
4338
+ C(z, {
4339
+ name: "error",
4340
+ color: "#ff2c2c",
4341
+ size: "sm"
4342
+ })
4343
+ ]),
4344
+ _: 1
4345
+ })) : A("", !0)
4346
+ ])
4347
+ ]),
4348
+ C(ee),
4349
+ (n(!0), f(Oe, null, Pe(((te = a.purchaseOrder) == null ? void 0 : te.items) ?? [], (H, be) => {
4350
+ var ke;
4351
+ return n(), f("div", {
4352
+ key: be,
4353
+ class: "flex flex-col"
4354
+ }, [
4355
+ e("div", Ya, [
4356
+ e("div", Ja, [
4357
+ Ge(b(H.name) + " ", 1),
4358
+ j(H) ? (n(), ue(pe, {
4359
+ key: 0,
4360
+ variant: "rich",
4361
+ placement: "top",
4362
+ "z-index": 51
4363
+ }, {
4364
+ content: ne(() => i[14] || (i[14] = [
4365
+ e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Extra item (added during delivery) ", -1)
4366
+ ])),
4367
+ default: ne(() => [
4368
+ C(z, {
4369
+ name: "add_circle",
4370
+ color: "#6b7280",
4371
+ size: "sm"
4372
+ })
4373
+ ]),
4374
+ _: 1
4375
+ })) : A("", !0),
4376
+ L(H) ? (n(), ue(pe, {
4377
+ key: 1,
4378
+ variant: "rich",
4379
+ placement: "top",
4380
+ "z-index": 51
4381
+ }, {
4382
+ content: ne(() => {
4383
+ var Ne, Ie;
4384
+ return [
4385
+ e("div", Xa, [
4386
+ i[15] || (i[15] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
4387
+ e("div", null, "Original Amount: " + b((Ne = ae(H)) == null ? void 0 : Ne.originalAmount), 1),
4388
+ e("div", null, " New Amount: " + b((Ie = ae(H)) == null ? void 0 : Ie.newAmount), 1)
4389
+ ])
4390
+ ];
4391
+ }),
4392
+ default: ne(() => [
4393
+ C(z, {
4394
+ name: "error",
4395
+ color: "#ff9500",
4396
+ size: "sm"
4397
+ })
4398
+ ]),
4399
+ _: 2
4400
+ }, 1024)) : A("", !0)
4401
+ ]),
4402
+ e("div", Za, [
4403
+ e("span", {
4404
+ innerHTML: oe(H)
4405
+ }, null, 8, el)
4406
+ ])
4407
+ ]),
4408
+ e("div", tl, [
4409
+ e("div", sl, b(H.code), 1),
4410
+ y(c).enableTotalCost ? (n(), f("div", rl, [
4411
+ e("span", ol, b(y(lt)(
4412
+ (ke = H.totalCost) != null && ke.amount ? H.totalCost : y(g).controller.value.getItemCost(H, y(we)()).cost
4413
+ )), 1),
4414
+ S(H) ? A("", !0) : (n(), f("span", nl, [
4415
+ i[16] || (i[16] = e("span", { class: "w-1.5 h-1.5 rounded-full bg-gray-400" }, null, -1)),
4416
+ Ge(" " + b(y(_)("inventory.transfer.form.items.autoCalculated")), 1)
4417
+ ]))
4418
+ ])) : A("", !0)
4419
+ ])
4420
+ ]);
4421
+ }), 128)),
4422
+ +y(xe)(y(g).controller.value.getTotalCosts()) ? (n(), f(Oe, { key: 0 }, [
4423
+ e("div", al, [
4424
+ C(ee)
4425
+ ]),
4426
+ e("div", ll, [
4427
+ i[17] || (i[17] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
4428
+ e("div", il, b(y(we)()) + " " + b(y(lt)({
4429
+ ...y(g).controller.value.getTotalCosts(),
4430
+ currency: y(we)()
4431
+ }).replace(/[^0-9.,]/g, "")), 1)
4432
+ ])
4433
+ ], 64)) : A("", !0),
4434
+ y(c).enablePurchaseOrderPriceAdjustment ? (n(), f(Oe, { key: 1 }, [
4435
+ C(qn, {
4436
+ adjustments: (Re = a.purchaseOrder) == null ? void 0 : Re.priceAdjustments
4437
+ }, null, 8, ["adjustments"]),
4438
+ a.purchaseOrder ? (n(), f("div", cl, [
4439
+ C(Ln, {
4440
+ "purchase-order": a.purchaseOrder,
4441
+ onSubmitted: i[3] || (i[3] = () => {
4442
+ l("update:show", !1), l("submitted");
4443
+ })
4444
+ }, null, 8, ["purchase-order"])
4445
+ ])) : A("", !0)
4446
+ ], 64)) : A("", !0)
4447
+ ])
4448
+ ])
4449
+ ], 64)) : K.value.value === "deliveryHistory" ? (n(), f("div", ul, [
4450
+ T.value.length ? (n(), f("div", vl, [
4451
+ (n(!0), f(Oe, null, Pe(T.value, (H, be) => {
4452
+ var ke, Ne, Ie, $e, fe;
4453
+ return n(), f(Oe, { key: be }, [
4454
+ e("div", yl, [
4455
+ e("div", hl, [
4456
+ e("div", bl, [
4457
+ e("div", {
4458
+ class: Be([
4459
+ {
4460
+ "bg-fm-color-primary": be !== 0,
4461
+ "bg-white": be === 0
4462
+ },
4463
+ "w-[2px] h-full"
4464
+ ])
4465
+ }, null, 2)
4466
+ ]),
4467
+ e("div", gl, [
4468
+ H.header === "Received" ? (n(), ue(z, {
4469
+ key: 0,
4470
+ name: "local_shipping",
4471
+ outline: "",
4472
+ color: "#ffffff"
4473
+ })) : A("", !0)
4474
+ ]),
4475
+ e("div", _l, [
4476
+ e("div", {
4477
+ class: Be([
4478
+ {
4479
+ "bg-fm-color-primary": be < T.value.length - 1,
4480
+ "bg-white": be >= T.value.length - 1
4481
+ },
4482
+ "w-[2px] h-full"
4483
+ ])
4484
+ }, null, 2)
4485
+ ])
4486
+ ]),
4487
+ e("div", xl, [
4488
+ e("div", Sl, [
4489
+ e("div", kl, b(H.header), 1),
4490
+ e("div", Ol, b(H.date), 1)
4491
+ ]),
4492
+ e("div", wl, [
4493
+ H.header === "Received" && H.deliveryOrder && a.purchaseOrder ? (n(), ue(Jo, {
4494
+ key: 0,
4495
+ deliveryOrder: H.deliveryOrder,
4496
+ purchaseOrder: a.purchaseOrder,
4497
+ "received-info-map": de.value,
4498
+ onSubmitted: i[4] || (i[4] = () => {
4499
+ l("update:show", !1), l("submitted");
4500
+ })
4501
+ }, null, 8, ["deliveryOrder", "purchaseOrder", "received-info-map"])) : A("", !0),
4502
+ (Ne = (ke = H.deliveryOrder) == null ? void 0 : ke.netSuite) != null && Ne.id ? (n(), ue(Xt, {
4503
+ key: 1,
4504
+ title: "Admin",
4505
+ class: "min-w-[140px]"
4506
+ }, {
4507
+ default: ne(() => {
4508
+ var ce, Le;
4509
+ return [
4510
+ C(ta, {
4511
+ "netsuite-id": (Le = (ce = H.deliveryOrder) == null ? void 0 : ce.netSuite) == null ? void 0 : Le.id
4512
+ }, null, 8, ["netsuite-id"])
4513
+ ];
4514
+ }),
4515
+ _: 2
4516
+ }, 1024)) : A("", !0),
4517
+ a.purchaseOrder && ((Ie = H.deliveryOrder) != null && Ie.id) ? (n(), ue(Gs, {
4518
+ key: 2,
4519
+ "purchase-order-id": ($e = a.purchaseOrder) == null ? void 0 : $e._id,
4520
+ "delivery-order-id": (fe = H.deliveryOrder) == null ? void 0 : fe.id
4521
+ }, null, 8, ["purchase-order-id", "delivery-order-id"])) : A("", !0)
4522
+ ])
4523
+ ])
4524
+ ]),
4525
+ e("div", $l, [
4526
+ e("div", Cl, [
4527
+ e("div", Dl, [
4528
+ e("div", {
4529
+ class: Be([
4530
+ {
4531
+ "bg-fm-color-primary": be < T.value.length - 1,
4532
+ "bg-white": be >= T.value.length - 1
4533
+ },
4534
+ "w-[2px] h-full"
4535
+ ])
4536
+ }, null, 2)
4537
+ ])
4538
+ ]),
4539
+ e("div", Al, [
4540
+ C(E, {
4541
+ variant: "outlined",
4542
+ class: "py-12 px-16"
4543
+ }, {
4544
+ default: ne(() => [
4545
+ e("div", Rl, [
4546
+ (n(!0), f(Oe, null, Pe(H.info, (ce, Le) => (n(), f("div", {
4547
+ key: Le,
4548
+ class: "flex flex-col gap-4"
4549
+ }, [
4550
+ e("div", Nl, b(ce == null ? void 0 : ce.label), 1),
4551
+ e("div", Pl, [
4552
+ (n(!0), f(Oe, null, Pe(ce == null ? void 0 : ce.values, (qe, je) => (n(), f("div", {
4553
+ key: je,
4554
+ class: "fm-typo-en-body-lg-600"
4555
+ }, [
4556
+ typeof qe == "string" ? (n(), f(Oe, { key: 0 }, [
4557
+ Ge(b(qe), 1)
4558
+ ], 64)) : (n(), ue(As(qe), { key: 1 }))
4559
+ ]))), 128))
4560
+ ])
4561
+ ]))), 128))
4562
+ ])
4563
+ ]),
4564
+ _: 2
4565
+ }, 1024)
4566
+ ])
4567
+ ])
4568
+ ], 64);
4569
+ }), 128))
4570
+ ])) : (n(), f("div", dl, [
4571
+ C(ie),
4572
+ e("div", null, [
4573
+ e("img", {
4574
+ src: y(Gt),
4575
+ alt: "List is empty"
4576
+ }, null, 8, ml)
4577
+ ]),
4578
+ e("div", pl, b(y(_)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
4579
+ e("div", fl, b(y(_)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
4580
+ C(ie),
4581
+ C(ie)
4582
+ ]))
4583
+ ])) : K.value.value === "actionLogs" ? (n(), f("div", Tl, [
4584
+ Ae.value.length ? (n(), f("div", ql, [
4585
+ (n(!0), f(Oe, null, Pe(Ae.value, (H, be) => (n(), ue(E, {
4586
+ key: be,
4587
+ variant: "outlined",
4588
+ class: "py-12 px-16"
4589
+ }, {
4590
+ default: ne(() => {
4591
+ var ke;
4592
+ return [
4593
+ e("div", Vl, [
4594
+ e("div", Ll, [
4595
+ e("div", jl, b(y(ot)[H.action] ? y(_)(y(ot)[H.action].translationKey) : H.action), 1),
4596
+ e("div", Ul, b(y(Ze)(H.changedAt)), 1)
4597
+ ]),
4598
+ e("div", Ml, b((ke = H.changedBy) == null ? void 0 : ke.name), 1),
4599
+ H.remarks ? (n(), f("div", Bl, b(H.remarks), 1)) : A("", !0)
4600
+ ])
4601
+ ];
4602
+ }),
4603
+ _: 2
4604
+ }, 1024))), 128))
4605
+ ])) : (n(), f("div", Fl, [
4606
+ C(ie),
4607
+ e("div", null, [
4608
+ e("img", {
4609
+ src: y(Gt),
4610
+ alt: "List is empty"
4611
+ }, null, 8, Il)
4612
+ ]),
4613
+ e("div", El, b(y(_)("inventory.transfer.receiveRequest.details.noActionLogs")), 1),
4614
+ C(ie),
4615
+ C(ie)
4616
+ ]))
4617
+ ])) : A("", !0)
4618
+ ])
4619
+ ];
4620
+ }),
4621
+ "side-sheet-footer": ne(() => [
4622
+ e("div", zl, [
4623
+ (n(!0), f(Oe, null, Pe(k.value, (h) => (n(), f(Oe, null, [
4624
+ y(ot)[h].available != !1 ? (n(), ue(x, {
4625
+ key: h,
4626
+ label: y(_)(y(ot)[h].translationKey),
4627
+ onClick: (v) => me(h),
4628
+ loading: se.value === h,
4629
+ disabled: se.value !== h && Q.value,
4630
+ variant: y(ot)[h].buttonVariant
4631
+ }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : A("", !0)
4632
+ ], 64))), 256)),
4633
+ y($).ableToMarkReceived(a.purchaseOrder) && !k.value.includes("completeReceive") ? (n(), ue(x, {
4634
+ key: 0,
4635
+ label: y(_)("inventory.transfer.receiveRequest.actions.completeReceive"),
4636
+ onClick: i[5] || (i[5] = (h) => me("completeReceive")),
4637
+ loading: se.value === "completeReceive",
4638
+ disabled: se.value !== "completeReceive" && Q.value
4639
+ }, null, 8, ["label", "loading", "disabled"])) : A("", !0),
4640
+ y($).ableToMarkApproved(a.purchaseOrder) && a.canApprove && !k.value.includes("approveRequest") ? (n(), ue(x, {
4641
+ key: 1,
4642
+ label: y(_)("inventory.transfer.approval.actions.approveRequest"),
4643
+ onClick: i[6] || (i[6] = (h) => me("approveRequest")),
4644
+ loading: se.value === "approveRequest",
4645
+ disabled: se.value !== "approveRequest" && Q.value
4646
+ }, null, 8, ["label", "loading", "disabled"])) : A("", !0),
4647
+ y($).ableToCreateFulfillment(a.purchaseOrder, a.poRequest) && r.scope === "approval" ? (n(), ue(x, {
4648
+ key: 2,
4649
+ label: y(_)("inventory.transfer.receiveRequest.actions.processRequest"),
4650
+ onClick: i[7] || (i[7] = (h) => me("processRequest")),
4651
+ loading: se.value === "processRequest",
4652
+ disabled: se.value !== "processRequest" && Q.value
4653
+ }, null, 8, ["label", "loading", "disabled"])) : A("", !0),
4654
+ C(x, {
4655
+ label: y(_)("common.close"),
4656
+ variant: "tertiary",
4657
+ onClick: i[8] || (i[8] = (h) => l("update:show", !1))
4658
+ }, null, 8, ["label"])
4659
+ ])
4660
+ ]),
4661
+ _: 1
4662
+ }, 8, ["modelValue", "dismiss-away"]);
4663
+ };
4664
+ }
4665
+ });
4666
+ export {
4667
+ wt as P,
4668
+ ki as _,
4669
+ Si as a,
4670
+ _i as b,
4671
+ ur as c,
4672
+ cs as d,
4673
+ us as e,
4674
+ ds as f,
4675
+ ls as g,
4676
+ ps as h,
4677
+ pt as i,
4678
+ ms as j,
4679
+ Nt as k,
4680
+ Rt as l,
4681
+ xi as u
4682
+ };