This commit is contained in:
James Cole
2019-08-02 05:24:51 +02:00
parent 04bf92d946
commit 4bd8e1b11e
3 changed files with 38 additions and 0 deletions

View File

@@ -172,6 +172,7 @@ class ReportController extends Controller
$carbon = new Carbon($date); $carbon = new Carbon($date);
$label = $carbon->formatLocalized($format); $label = $carbon->formatLocalized($format);
$earned = $chartData[0]['entries'][$label] ?? '0'; $earned = $chartData[0]['entries'][$label] ?? '0';
$amount = bcmul($amount, '-1');
$chartData[0]['entries'][$label] = bcadd($earned, $amount); $chartData[0]['entries'][$label] = bcadd($earned, $amount);
} }
foreach ($source['spent'] as $date => $amount) { foreach ($source['spent'] as $date => $amount) {
@@ -223,6 +224,7 @@ class ReportController extends Controller
'count_spent' => 0, 'count_spent' => 0,
]; ];
foreach ($source['earned'] as $amount) { foreach ($source['earned'] as $amount) {
$amount = bcmul($amount,'-1');
$numbers['sum_earned'] = bcadd($amount, $numbers['sum_earned']); $numbers['sum_earned'] = bcadd($amount, $numbers['sum_earned']);
++$numbers['count_earned']; ++$numbers['count_earned'];
} }

View File

@@ -102,6 +102,18 @@ class BudgetController extends Controller
$data = $repository->getBudgetPeriodReport($budgets, $accounts, $start, $end); $data = $repository->getBudgetPeriodReport($budgets, $accounts, $start, $end);
$data[0] = $repository->getNoBudgetPeriodReport($accounts, $start, $end); // append report data for "no budget" $data[0] = $repository->getNoBudgetPeriodReport($accounts, $start, $end); // append report data for "no budget"
$report = $this->filterPeriodReport($data); $report = $this->filterPeriodReport($data);
// depending on the carbon format (a reliable way to determine the general date difference)
// change the "listOfPeriods" call so the entire period gets included correctly.
$range = app('navigation')->preferredCarbonFormat($start, $end);
if ('Y' === $range) {
$start->startOfYear();
}
if ('Y-m' === $range) {
$start->startOfMonth();
}
$periods = app('navigation')->listOfPeriods($start, $end); $periods = app('navigation')->listOfPeriods($start, $end);
try { try {
$result = view('reports.partials.budget-period', compact('report', 'periods'))->render(); $result = view('reports.partials.budget-period', compact('report', 'periods'))->render();

View File

@@ -64,6 +64,18 @@ class CategoryController extends Controller
$data = $repository->periodExpenses($categories, $accounts, $start, $end); $data = $repository->periodExpenses($categories, $accounts, $start, $end);
$data[0] = $repository->periodExpensesNoCategory($accounts, $start, $end); $data[0] = $repository->periodExpensesNoCategory($accounts, $start, $end);
$report = $this->filterPeriodReport($data); $report = $this->filterPeriodReport($data);
// depending on the carbon format (a reliable way to determine the general date difference)
// change the "listOfPeriods" call so the entire period gets included correctly.
$range = app('navigation')->preferredCarbonFormat($start, $end);
if ('Y' === $range) {
$start->startOfYear();
}
if ('Y-m' === $range) {
$start->startOfMonth();
}
$periods = app('navigation')->listOfPeriods($start, $end); $periods = app('navigation')->listOfPeriods($start, $end);
try { try {
$result = view('reports.partials.category-period', compact('report', 'periods'))->render(); $result = view('reports.partials.category-period', compact('report', 'periods'))->render();
@@ -106,6 +118,18 @@ class CategoryController extends Controller
$data = $repository->periodIncome($categories, $accounts, $start, $end); $data = $repository->periodIncome($categories, $accounts, $start, $end);
$data[0] = $repository->periodIncomeNoCategory($accounts, $start, $end); $data[0] = $repository->periodIncomeNoCategory($accounts, $start, $end);
$report = $this->filterPeriodReport($data); $report = $this->filterPeriodReport($data);
// depending on the carbon format (a reliable way to determine the general date difference)
// change the "listOfPeriods" call so the entire period gets included correctly.
$range = app('navigation')->preferredCarbonFormat($start, $end);
if ('Y' === $range) {
$start->startOfYear();
}
if ('Y-m' === $range) {
$start->startOfMonth();
}
$periods = app('navigation')->listOfPeriods($start, $end); $periods = app('navigation')->listOfPeriods($start, $end);
try { try {
$result = view('reports.partials.category-period', compact('report', 'periods'))->render(); $result = view('reports.partials.category-period', compact('report', 'periods'))->render();