mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fixed budget.
This commit is contained in:
parent
ae54497efa
commit
bed1adc367
@ -8,6 +8,7 @@ use FireflyIII\Models\Budget;
|
|||||||
use FireflyIII\Models\BudgetLimit;
|
use FireflyIII\Models\BudgetLimit;
|
||||||
use FireflyIII\Models\LimitRepetition;
|
use FireflyIII\Models\LimitRepetition;
|
||||||
use Illuminate\Database\Query\Builder as QueryBuilder;
|
use Illuminate\Database\Query\Builder as QueryBuilder;
|
||||||
|
use Illuminate\Database\Query\JoinClause;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Input;
|
use Input;
|
||||||
@ -262,10 +263,9 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function spentInMonth(Budget $budget, Carbon $date, $shared)
|
public function spentInMonth(Budget $budget, Carbon $date, $shared = true)
|
||||||
{
|
{
|
||||||
$end = clone $date;
|
$end = clone $date;
|
||||||
$sum = 0;
|
|
||||||
$date->startOfMonth();
|
$date->startOfMonth();
|
||||||
$end->endOfMonth();
|
$end->endOfMonth();
|
||||||
|
|
||||||
@ -274,7 +274,19 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
$sum = floatval($budget->transactionjournals()->before($end)->after($date)->lessThan(0)->sum('amount')) * -1;
|
$sum = floatval($budget->transactionjournals()->before($end)->after($date)->lessThan(0)->sum('amount')) * -1;
|
||||||
} else {
|
} else {
|
||||||
// get all journals in this month where the asset account is NOT shared.
|
// get all journals in this month where the asset account is NOT shared.
|
||||||
$sum = rand(1, 100);
|
$sum = $budget->transactionjournals()
|
||||||
|
->before($end)
|
||||||
|
->after($date)
|
||||||
|
->lessThan(0)
|
||||||
|
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||||
|
->leftJoin(
|
||||||
|
'account_meta', function (JoinClause $join) {
|
||||||
|
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('account_meta.data', '!=', '"sharedAsset"')
|
||||||
|
->sum('amount');
|
||||||
|
$sum = floatval($sum) * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sum;
|
return $sum;
|
||||||
|
@ -129,7 +129,7 @@ interface BudgetRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function spentInMonth(Budget $budget, Carbon $date, $shared);
|
public function spentInMonth(Budget $budget, Carbon $date, $shared = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
Loading…
Reference in New Issue
Block a user