mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-25 21:16:47 +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) {
|
while ($start <= $end) {
|
||||||
$row = [clone $start];
|
$row = [clone $start];
|
||||||
foreach ($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
$spent = $repository->spentInMonth($budget, $start);
|
$spent = $repository->spentInMonth($budget, $start, $shared);
|
||||||
$row[] = $spent;
|
$row[] = $spent;
|
||||||
}
|
}
|
||||||
$chart->addRowArray($row);
|
$chart->addRowArray($row);
|
||||||
|
|||||||
@@ -256,17 +256,26 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
|
* @param boolean $shared
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function spentInMonth(Budget $budget, Carbon $date)
|
public function spentInMonth(Budget $budget, Carbon $date, $shared)
|
||||||
{
|
{
|
||||||
$end = clone $date;
|
$end = clone $date;
|
||||||
|
$sum = 0;
|
||||||
$date->startOfMonth();
|
$date->startOfMonth();
|
||||||
$end->endOfMonth();
|
$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;
|
return $sum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,10 +125,11 @@ interface BudgetRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
|
* @param boolean $shared
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function spentInMonth(Budget $budget, Carbon $date);
|
public function spentInMonth(Budget $budget, Carbon $date, $shared);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
|||||||
Reference in New Issue
Block a user