<%- include('../partials/header') %>

Expense Reports

Filter expenses by employee and timeline, approve/reject pending submissions, and export reports to PDF or Excel.

<% if (error) { %>
<%= decodeURIComponent(error) %>
<% } %> <% if (success) { %>
<%= decodeURIComponent(success) %>
<% } %>

Select Employee & Billing Cycle

<% if (selectedUser) { %> <% const reimbursementExpenses = expenses.filter(e => e.payment_type !== 'Company Card'); const companyCardExpenses = expenses.filter(e => e.payment_type === 'Company Card'); const reimbTotal = reimbursementExpenses.reduce((sum, e) => sum + parseFloat(e.total_amount || 0), 0); const cardTotal = companyCardExpenses.reduce((sum, e) => sum + parseFloat(e.total_amount || 0), 0); %>

Expenses for <%= selectedUser.first_name %> <%= selectedUser.last_name %>

Cycle: <%= startDate %> to <%= endDate %>

<% if ((expenses && expenses.length > 0) || (gasExpenses && gasExpenses.length > 0)) { %>
Export Combined PDF Export Combined Excel
<% } %>

Employee Reimbursement Claims

Total Reimbursable: $<%= reimbTotal.toFixed(2) %>  ·  <%= reimbursementExpenses.length %> expense(s) <% if (reimbursementExpenses.length > 0) { %> PDF Excel <% } %>
<% if (reimbursementExpenses.length > 0) { %> <%- include('partials/reports_table', { tableExpenses: reimbursementExpenses }) %> <% } else { %>

No reimbursement claims found for this timeline.

<% } %>

Company Credit Card Expenses

Total Company Card Cost: $<%= cardTotal.toFixed(2) %>  ·  <%= companyCardExpenses.length %> expense(s) <% if (companyCardExpenses.length > 0) { %> PDF Excel <% } %>
<% if (companyCardExpenses.length > 0) { %> <%- include('partials/reports_table', { tableExpenses: companyCardExpenses }) %> <% } else { %>

No company credit card expenses found for this timeline.

<% } %>
<% const gasTotal = gasExpenses.reduce((sum, e) => sum + parseFloat(e.total_amount || 0), 0); %>

Gas Card Expenses

Total Gas Cost: $<%= gasTotal.toFixed(2) %>  ·  <%= gasExpenses.length %> expense(s) <% if (gasExpenses.length > 0) { %> PDF Excel <% } %>
<% if (gasExpenses.length > 0) { %>
<% gasExpenses.forEach(exp => { %> <% }) %>
Date Store/Merchant Card Number Job # Liters Net ($) GST ($) Total ($)
<%= typeof exp.date === 'string' ? exp.date.split('T')[0] : '' %> <%= exp.store_name %> ****<%= exp.card_number ? exp.card_number.slice(-4) : 'N/A' %> <%= exp.job_number || 'N/A' %> <% if (exp.job_number && typeof pendingJobsMap !== 'undefined' && pendingJobsMap[exp.job_number.trim().toUpperCase()]) { %>
<% } %>
<%= exp.liters_in_tank %>L $<%= parseFloat(exp.net_amount).toFixed(2) %> $<%= parseFloat(exp.tax_amount).toFixed(2) %> $<%= parseFloat(exp.total_amount).toFixed(2) %>
<% } else { %>

No gas card expenses found for this timeline.

<% } %>
<% } else { %>

No employee selected

Please select an employee and billing cycle date range from the filter bar above to load their reports.

<% } %> <%- include('../partials/footer') %>