Differ between shared and normal transactions (not build yet).

This commit is contained in:
James Cole
2015-05-16 07:49:02 +02:00
parent 06b747c221
commit ae54497efa
3 changed files with 16 additions and 6 deletions

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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