feat: reconcile ETC overview totals

This commit is contained in:
kkfluous
2026-08-07 17:15:52 +08:00
parent 5ea788e565
commit d786b984bb
6 changed files with 190 additions and 4 deletions
+2
View File
@@ -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,