@feedmepos/mf-inventory-portal 1.3.14-dev.2 → 1.3.14

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