%
const userCanManage =
typeof canManage !== "undefined" &&
canManage === true;
const expenseList =
Array.isArray(expenses)
? expenses
: [];
const projectData =
typeof project !== "undefined" &&
project
? project
: {};
const expenseTotals =
typeof totals !== "undefined" &&
totals
? totals
: {};
const company =
typeof companySettings !== "undefined" &&
companySettings
? companySettings
: {};
const displayMoney =
typeof formatMoney === "function"
? formatMoney
: function (value) {
const convertedValue = Number(value);
const safeValue =
Number.isFinite(convertedValue)
? convertedValue
: 0;
const formattedValue =
new Intl.NumberFormat(
"en-US",
{
minimumFractionDigits: 2,
maximumFractionDigits: 2
}
).format(safeValue);
const currency =
company.currency_symbol ||
company.currency_code ||
"";
return currency
? currency + " " + formattedValue
: formattedValue;
};
const formatExpenseDate = (value) => {
if (!value) {
return "—";
}
return String(value).substring(0, 10);
};
%>
← Back to Projects
Total Expenses
<%= displayMoney(
expenseTotals.total_expenses
) %>
Site Expenses
<%= displayMoney(
expenseTotals.site_expenses
) %>
Main Office Expenses
<%= displayMoney(
expenseTotals.office_expenses
) %>
Expense Records
<%=
Number(
expenseTotals.total_records ??
expenseList.length
)
%>
| ID |
Category |
Code |
Amount |
Date |
Location |
Remark |
<%= userCanManage
? "Actions"
: "Access"
%>
|
<% if (expenseList.length === 0) { %>
|
No expenses found for this project.
|
<% } else { %>
<% expenseList.forEach((expense) => { %>
|
<%= expense.id %>
|
<%=
expense.category_name ||
"No category"
%>
|
<%=
expense.category_code ||
"—"
%>
|
<%= displayMoney(
expense.amount
) %>
|
<%=
formatExpenseDate(
expense.expense_date
)
%>
|
<%=
expense.expense_location ||
"—"
%>
|
<%= expense.remark || "—" %>
|
<% if (userCanManage) { %>
Edit
<% } else { %>
View only
<% } %>
|
<% }); %>
<% } %>