mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
General cleanup and new (incomplete) tests.
This commit is contained in:
@@ -7,6 +7,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Navigation;
|
||||
@@ -33,7 +34,15 @@ class BillRepository implements BillRepositoryInterface
|
||||
*/
|
||||
public function getBills()
|
||||
{
|
||||
return Auth::user()->bills()->orderBy('name', 'ASC')->get();
|
||||
/** @var Collection $set */
|
||||
$set = Auth::user()->bills()->orderBy('name', 'ASC')->get();
|
||||
$set->sort(
|
||||
function (Bill $bill) {
|
||||
return $bill->name;
|
||||
}
|
||||
);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,10 +53,16 @@ class BillRepository implements BillRepositoryInterface
|
||||
public function getJournals(Bill $bill)
|
||||
{
|
||||
return $bill->transactionjournals()->withRelevantData()
|
||||
->leftJoin(
|
||||
'transactions', function (JoinClause $join) {
|
||||
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transactions.amount', '>', 0);
|
||||
}
|
||||
)
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->get();
|
||||
->get(['transaction_journals.*', 'transactions.amount']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,4 +322,20 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
return $bill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getActiveBills()
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = Auth::user()->bills()->orderBy('name', 'ASC')->where('active', 1)->get();
|
||||
$set->sort(
|
||||
function (Bill $bill) {
|
||||
return $bill->name;
|
||||
}
|
||||
);
|
||||
|
||||
return $set;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user