Skip to content

Commit

Permalink
add logic to show average revenue
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhinegi2 committed Feb 29, 2024
1 parent 1ee04ab commit d815670
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Modules/Report/Resources/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function clientWiseRevenueTrendsReport(reportsData) {
const canvasElementId = "clientWiseReportRevenueTrends";
const labels = reportsData.labels;
const currentPeriodTotalRevenue = reportsData.data.total_amount;
const averageRevenue = reportsData.data.average_amount;
const chartData = {
labels: labels,
datasets: [
Expand All @@ -129,7 +130,7 @@ function clientWiseRevenueTrendsReport(reportsData) {
responsive: true,
title: {
display: true,
text: "Total revenue: Rs. " + currentPeriodTotalRevenue
text: "Total Revenue: Rs. " + currentPeriodTotalRevenue + " | Average Revenue: Rs. " + averageRevenue,
},
scales: {
yAxes: [
Expand Down
2 changes: 2 additions & 0 deletions Modules/Report/Services/Finance/RevenueReportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ public static function getRevenueReportDataForClient($filters, $client)
$amountMonthWise = $data['amountMonthWise'];
}
}
$averageAmount = $totalAmount / count($amountMonthWise);

return [
'months' => array_keys($amountMonthWise),
'amount' => array_values($amountMonthWise),
'total_amount' => round($totalAmount, 2),
'average_amount' => round($averageAmount, 2),
];
}

Expand Down

0 comments on commit d815670

Please sign in to comment.