diff --git a/app/src/main/java/com/example/myapplication/composeui/Report.kt b/app/src/main/java/com/example/myapplication/composeui/Report.kt index b96288f..e7cc3ab 100644 --- a/app/src/main/java/com/example/myapplication/composeui/Report.kt +++ b/app/src/main/java/com/example/myapplication/composeui/Report.kt @@ -134,6 +134,7 @@ fun CardScreen(report: ReportRemote?) { Spacer(modifier = Modifier.height(16.dp)) } Text(text = "Итого: ") + Spacer(modifier = Modifier.height(16.dp)) Row( modifier = Modifier .fillMaxWidth() diff --git a/server/reportRouter.js b/server/reportRouter.js index 1fea4b3..06268ed 100644 --- a/server/reportRouter.js +++ b/server/reportRouter.js @@ -20,6 +20,9 @@ module.exports = (req, res, next) => { sessionDate.setHours(4, 0, 0, 0); return sessionDate >= start && sessionDate <= end; }); + const report = { "report_data": [], + "total_revenue": 0.0, + "total_purchased_tickets": 0 } // Обрабатываем отфильтрованные сеансы для аналитики const reportData = filteredSessions.map(session => { @@ -43,6 +46,8 @@ module.exports = (req, res, next) => { }, { totalTicketsSold: 0, revenue: 0 }); const cinema = cinemas.find(cinema => cinema.id === session.cinemaId) + report.total_revenue += revenue + report.total_purchased_tickets += totalTicketsSold return { cinema_name: cinema ? cinema.name : "Неизвестно", current_ticket_date_time: session.dateTime, @@ -53,10 +58,8 @@ module.exports = (req, res, next) => { }; }); - const sortedReportData = reportData.sort((a, b) => b.revenue - a.revenue); - const report = { "sortedReportData": sortedReportData, - "total_revenue": sortedReportData.reduce((a, b) => a + b.revenue, 0), - "total_purchased_tickets": sortedReportData.reduce((a, b) => a + b.purchased_tickets, 0) } + report.report_data = reportData.sort((a, b) => b.revenue - a.revenue) + res.json(report); } catch (error) { console.error('Error processing report: ', error);