mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 22:21:42 +00:00
More cleanup for budgets.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php namespace FireflyIII\Models;
|
||||
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
@@ -59,6 +61,28 @@ class LimitRepetition extends Model
|
||||
return $this->belongsTo('FireflyIII\Models\BudgetLimit');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
*/
|
||||
public function scopeAfter(Builder $query, Carbon $date)
|
||||
{
|
||||
$query->where('limit_repetitions.startdate', '>=', $date->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
*/
|
||||
public function scopeBefore(Builder $query, Carbon $date)
|
||||
{
|
||||
$query->where('limit_repetitions.enddate', '<=', $date->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
|
||||
@@ -338,6 +338,10 @@ class TransactionJournal extends TransactionJournalSupport
|
||||
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0);
|
||||
}
|
||||
);
|
||||
|
||||
// order
|
||||
$query->orderBy('transaction_journals.date', 'DESC')->orderBy('transaction_journals.order', 'ASC')->orderBy('transaction_journals.id', 'DESC');
|
||||
|
||||
$query->groupBy('transaction_journals.id');
|
||||
$query->with(['categories', 'budgets', 'attachments', 'bill','transactions']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user