feat: reconcile ETC overview totals
This commit is contained in:
@@ -1020,6 +1020,7 @@ app.get('/etc/records', async (c) => {
|
||||
const [[summaryRows], [detailRows]] = await observeDataSource('etcDatabase', () => Promise.all([
|
||||
pool.query<RowDataPacket[]>(
|
||||
`SELECT COUNT(*) AS total,
|
||||
COUNT(DISTINCT plate_number) AS vehicleCount,
|
||||
SUM(toll_amount) AS tollAmount,
|
||||
SUM(service_fee) AS serviceFee,
|
||||
SUM(total_amount) AS totalAmount
|
||||
@@ -1058,6 +1059,7 @@ app.get('/etc/records', async (c) => {
|
||||
totalPages: Math.max(1, Math.ceil(total / limit)),
|
||||
filters: { startDate: startDate || null, endDate: endDate || null, search },
|
||||
summary: {
|
||||
vehicleCount: Number(summary.vehicleCount) || 0,
|
||||
tollAmount: Math.round((Number(summary.tollAmount) || 0) * 100) / 100,
|
||||
serviceFee: Math.round((Number(summary.serviceFee) || 0) * 100) / 100,
|
||||
totalAmount: Math.round((Number(summary.totalAmount) || 0) * 100) / 100,
|
||||
|
||||
Reference in New Issue
Block a user