итого в отчете

This commit is contained in:
dasha 2023-12-22 15:18:00 +04:00
parent c4c941c0c9
commit f11ebc82f5
2 changed files with 8 additions and 4 deletions

View File

@ -134,6 +134,7 @@ fun CardScreen(report: ReportRemote?) {
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
} }
Text(text = "Итого: ") Text(text = "Итого: ")
Spacer(modifier = Modifier.height(16.dp))
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()

View File

@ -20,6 +20,9 @@ module.exports = (req, res, next) => {
sessionDate.setHours(4, 0, 0, 0); sessionDate.setHours(4, 0, 0, 0);
return sessionDate >= start && sessionDate <= end; return sessionDate >= start && sessionDate <= end;
}); });
const report = { "report_data": [],
"total_revenue": 0.0,
"total_purchased_tickets": 0 }
// Обрабатываем отфильтрованные сеансы для аналитики // Обрабатываем отфильтрованные сеансы для аналитики
const reportData = filteredSessions.map(session => { const reportData = filteredSessions.map(session => {
@ -43,6 +46,8 @@ module.exports = (req, res, next) => {
}, { totalTicketsSold: 0, revenue: 0 }); }, { totalTicketsSold: 0, revenue: 0 });
const cinema = cinemas.find(cinema => cinema.id === session.cinemaId) const cinema = cinemas.find(cinema => cinema.id === session.cinemaId)
report.total_revenue += revenue
report.total_purchased_tickets += totalTicketsSold
return { return {
cinema_name: cinema ? cinema.name : "Неизвестно", cinema_name: cinema ? cinema.name : "Неизвестно",
current_ticket_date_time: session.dateTime, 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); report.report_data = 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) }
res.json(report); res.json(report);
} catch (error) { } catch (error) {
console.error('Error processing report: ', error); console.error('Error processing report: ', error);