mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Some issues fixed for scrutiniser.
This commit is contained in:
@@ -183,7 +183,7 @@ class CategoryController extends Controller
|
|||||||
$journals->setPath('categories/show/' . $category->id);
|
$journals->setPath('categories/show/' . $category->id);
|
||||||
|
|
||||||
// oldest transaction in category:
|
// oldest transaction in category:
|
||||||
$start = $repository->firstUseDate($category, new Collection);
|
$start = $repository->firstUseDate($category);
|
||||||
if ($start->year == 1900) {
|
if ($start->year == 1900) {
|
||||||
$start = new Carbon;
|
$start = new Carbon;
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ class CategoryController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function all(CRI $repository, AccountCrudInterface $crud, Category $category)
|
public function all(CRI $repository, AccountCrudInterface $crud, Category $category)
|
||||||
{
|
{
|
||||||
$start = $repository->firstUseDate($category, new Collection);
|
$start = $repository->firstUseDate($category);
|
||||||
$range = Preferences::get('viewRange', '1M')->data;
|
$range = Preferences::get('viewRange', '1M')->data;
|
||||||
$start = Navigation::startOfPeriod($start, $range);
|
$start = Navigation::startOfPeriod($start, $range);
|
||||||
$categoryCollection = new Collection([$category]);
|
$categoryCollection = new Collection([$category]);
|
||||||
|
@@ -121,26 +121,17 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
*
|
||||||
* @return Carbon
|
* @return Carbon
|
||||||
*/
|
*/
|
||||||
public function firstUseDate(Category $category, Collection $accounts): Carbon
|
public function firstUseDate(Category $category): Carbon
|
||||||
{
|
{
|
||||||
$first = null;
|
$first = null;
|
||||||
|
|
||||||
|
|
||||||
/** @var TransactionJournal $first */
|
/** @var TransactionJournal $first */
|
||||||
$firstJournalQuery = $category->transactionJournals()->orderBy('date', 'ASC');
|
$firstJournal = $category->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.date']);
|
||||||
|
|
||||||
if ($accounts->count() > 0) {
|
|
||||||
// filter journals:
|
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
|
||||||
$firstJournalQuery->leftJoin('transactions as t', 't.transaction_journal_id', '=', 'transaction_journals.id');
|
|
||||||
$firstJournalQuery->whereIn('t.account_id', $ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
$firstJournal = $firstJournalQuery->first(['transaction_journals.date']);
|
|
||||||
|
|
||||||
if ($firstJournal) {
|
if ($firstJournal) {
|
||||||
$first = $firstJournal->date;
|
$first = $firstJournal->date;
|
||||||
@@ -148,16 +139,9 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
|
|
||||||
// check transactions:
|
// check transactions:
|
||||||
|
|
||||||
$firstTransactionQuery = $category->transactions()
|
$firstTransaction = $category->transactions()
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->orderBy('transaction_journals.date', 'ASC');
|
->orderBy('transaction_journals.date', 'ASC')->first(['transaction_journals.date']);
|
||||||
if ($accounts->count() > 0) {
|
|
||||||
// filter journals:
|
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
|
||||||
$firstTransactionQuery->whereIn('transactions.account_id', $ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
$firstTransaction = $firstTransactionQuery->first(['transaction_journals.date']);
|
|
||||||
|
|
||||||
if (!is_null($firstTransaction) && ((!is_null($first) && $firstTransaction->date < $first) || is_null($first))) {
|
if (!is_null($firstTransaction) && ((!is_null($first) && $firstTransaction->date < $first) || is_null($first))) {
|
||||||
$first = new Carbon($firstTransaction->date);
|
$first = new Carbon($firstTransaction->date);
|
||||||
|
@@ -70,11 +70,10 @@ interface CategoryRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
*
|
||||||
* @return Carbon
|
* @return Carbon
|
||||||
*/
|
*/
|
||||||
public function firstUseDate(Category $category, Collection $accounts): Carbon;
|
public function firstUseDate(Category $category): Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all the categories belonging to a user.
|
* Returns a list of all the categories belonging to a user.
|
||||||
|
Reference in New Issue
Block a user