mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup [skip ci]
This commit is contained in:
parent
ff3c9676b5
commit
7a20835571
@ -31,27 +31,6 @@ class LimitRepetition extends Model
|
||||
return ['created_at', 'updated_at', 'startdate', 'enddate'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function spentInRepetition()
|
||||
{
|
||||
$sum = DB::table('transactions')
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')
|
||||
->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
|
||||
->where('transaction_journals.date', '>=', $this->startdate->format('Y-m-d'))
|
||||
->where('transaction_journals.date', '<=', $this->enddate->format('Y-m-d'))
|
||||
->where('transaction_journals.user_id', Auth::user()->id)
|
||||
->whereNull('transactions.deleted_at')
|
||||
->where('transactions.amount', '>', 0)
|
||||
->where('limit_repetitions.id', '=', $this->id)
|
||||
->sum('transactions.amount');
|
||||
|
||||
return floatval($sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
|
@ -250,9 +250,8 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
)
|
||||
->after($start)
|
||||
->before($end)
|
||||
->lessThan(0)
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->sum('transactions.amount');
|
||||
->get(['transaction_journals.*'])->sum('amount');
|
||||
|
||||
return floatval($noBudgetSet) * -1;
|
||||
}
|
||||
@ -269,13 +268,12 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
if ($shared === true) {
|
||||
// get everything:
|
||||
$sum = floatval($budget->transactionjournals()->before($end)->after($start)->lessThan(0)->get(['transaction_journals.*'])->sum('amount'));
|
||||
$sum = floatval($budget->transactionjournals()->before($end)->after($start)->get(['transaction_journals.*'])->sum('amount'));
|
||||
} else {
|
||||
// get all journals in this month where the asset account is NOT shared.
|
||||
$sum = $budget->transactionjournals()
|
||||
->before($end)
|
||||
->after($start)
|
||||
->lessThan(0)
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||
->leftJoin(
|
||||
'account_meta', function (JoinClause $join) {
|
||||
|
Loading…
Reference in New Issue
Block a user