mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Differ between shared and normal transactions (not build yet).
This commit is contained in:
@@ -126,7 +126,7 @@ class GoogleChartController extends Controller
|
||||
while ($start <= $end) {
|
||||
$row = [clone $start];
|
||||
foreach ($budgets as $budget) {
|
||||
$spent = $repository->spentInMonth($budget, $start);
|
||||
$spent = $repository->spentInMonth($budget, $start, $shared);
|
||||
$row[] = $spent;
|
||||
}
|
||||
$chart->addRowArray($row);
|
||||
|
@@ -256,17 +256,26 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $date
|
||||
* @param Budget $budget
|
||||
* @param Carbon $date
|
||||
* @param boolean $shared
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function spentInMonth(Budget $budget, Carbon $date)
|
||||
public function spentInMonth(Budget $budget, Carbon $date, $shared)
|
||||
{
|
||||
$end = clone $date;
|
||||
$sum = 0;
|
||||
$date->startOfMonth();
|
||||
$end->endOfMonth();
|
||||
$sum = floatval($budget->transactionjournals()->before($end)->after($date)->lessThan(0)->sum('amount')) * -1;
|
||||
|
||||
if ($shared === true) {
|
||||
// get everything:
|
||||
$sum = floatval($budget->transactionjournals()->before($end)->after($date)->lessThan(0)->sum('amount')) * -1;
|
||||
} else {
|
||||
// get all journals in this month where the asset account is NOT shared.
|
||||
$sum = rand(1, 100);
|
||||
}
|
||||
|
||||
return $sum;
|
||||
}
|
||||
|
@@ -125,10 +125,11 @@ interface BudgetRepositoryInterface
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $date
|
||||
* @param boolean $shared
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function spentInMonth(Budget $budget, Carbon $date);
|
||||
public function spentInMonth(Budget $budget, Carbon $date, $shared);
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
|
Reference in New Issue
Block a user