Large commit to get rid of a lot of static methods.

This commit is contained in:
James Cole 2017-03-04 07:26:03 +01:00
parent d9aa074330
commit 45f4395f26
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
10 changed files with 11 additions and 11 deletions

View File

@ -141,7 +141,7 @@ class StoredJournalEventHandler
private function getExactAmount(TransactionJournal $journal, PiggyBank $piggyBank, PiggyBankRepetition $repetition): string private function getExactAmount(TransactionJournal $journal, PiggyBank $piggyBank, PiggyBankRepetition $repetition): string
{ {
$amount = $journal->amountPositive(); $amount = $journal->amountPositive();
$sources = TransactionJournal::sourceAccountList($journal)->pluck('id')->toArray(); $sources = $journal->sourceAccountList()->pluck('id')->toArray();
$room = bcsub(strval($piggyBank->targetamount), strval($repetition->currentamount)); $room = bcsub(strval($piggyBank->targetamount), strval($repetition->currentamount));
$compare = bcmul($repetition->currentamount, '-1'); $compare = bcmul($repetition->currentamount, '-1');

View File

@ -100,7 +100,7 @@ class Controller extends BaseController
*/ */
protected function isOpeningBalance(TransactionJournal $journal): bool protected function isOpeningBalance(TransactionJournal $journal): bool
{ {
return TransactionJournal::transactionTypeStr($journal) === TransactionType::OPENING_BALANCE; return $journal->transactionTypeStr() === TransactionType::OPENING_BALANCE;
} }
/** /**

View File

@ -239,7 +239,7 @@ class ReportController extends Controller
$journals = $journals->filter( $journals = $journals->filter(
function (Transaction $transaction) use ($report) { function (Transaction $transaction) use ($report) {
// get the destinations: // get the destinations:
$sources = TransactionJournal::sourceAccountList($transaction->transactionJournal)->pluck('id')->toArray(); $sources = $transaction->transactionJournal->sourceAccountList()->pluck('id')->toArray();
// do these intersect with the current list? // do these intersect with the current list?
return !empty(array_intersect($report, $sources)); return !empty(array_intersect($report, $sources));
@ -275,7 +275,7 @@ class ReportController extends Controller
$journals = $journals->filter( $journals = $journals->filter(
function (Transaction $transaction) use ($report) { function (Transaction $transaction) use ($report) {
// get the destinations: // get the destinations:
$destinations = $transaction->transactionJournal->destinationAccountList()->pluck('id')->toArray(); $destinations = $transaction->destinationAccountList($transaction->transactionJournal)->pluck('id')->toArray();
// do these intersect with the current list? // do these intersect with the current list?
return !empty(array_intersect($report, $destinations)); return !empty(array_intersect($report, $destinations));

View File

@ -195,7 +195,7 @@ class MassController extends Controller
$journal = $repository->find(intval($journalId)); $journal = $repository->find(intval($journalId));
if ($journal) { if ($journal) {
// get optional fields: // get optional fields:
$what = strtolower(TransactionJournal::transactionTypeStr($journal)); $what = strtolower($journal->transactionTypeStr());
$sourceAccountId = $request->get('source_account_id')[$journal->id] ?? 0; $sourceAccountId = $request->get('source_account_id')[$journal->id] ?? 0;
$sourceAccountName = $request->get('source_account_name')[$journal->id] ?? ''; $sourceAccountName = $request->get('source_account_name')[$journal->id] ?? '';
$destAccountId = $request->get('destination_account_id')[$journal->id] ?? 0; $destAccountId = $request->get('destination_account_id')[$journal->id] ?? 0;

View File

@ -150,7 +150,7 @@ class SplitController extends Controller
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
$type = strtolower(TransactionJournal::transactionTypeStr($journal)); $type = strtolower($journal->transactionTypeStr());
Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => e($data['journal_description'])]))); Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => e($data['journal_description'])])));
Preferences::mark(); Preferences::mark();

View File

@ -66,7 +66,7 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf
$fromAccountName = ''; $fromAccountName = '';
/** @var Account $account */ /** @var Account $account */
foreach (TransactionJournal::sourceAccountList($journal) as $account) { foreach ($journal->sourceAccountList() as $account) {
$fromAccountName .= strtolower($account->name); $fromAccountName .= strtolower($account->name);
} }

View File

@ -66,7 +66,7 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface
$name = ''; $name = '';
/** @var Account $account */ /** @var Account $account */
foreach (TransactionJournal::sourceAccountList($journal) as $account) { foreach ($journal->sourceAccountList() as $account) {
$name .= strtolower($account->name); $name .= strtolower($account->name);
} }

View File

@ -61,7 +61,7 @@ final class FromAccountIs extends AbstractTrigger implements TriggerInterface
$name = ''; $name = '';
/** @var Account $account */ /** @var Account $account */
foreach (TransactionJournal::sourceAccountList($journal) as $account) { foreach ($journal->sourceAccountList() as $account) {
$name .= strtolower($account->name); $name .= strtolower($account->name);
} }

View File

@ -66,7 +66,7 @@ final class FromAccountStarts extends AbstractTrigger implements TriggerInterfac
$name = ''; $name = '';
/** @var Account $account */ /** @var Account $account */
foreach (TransactionJournal::sourceAccountList($journal) as $account) { foreach ($journal->sourceAccountList() as $account) {
$name .= strtolower($account->name); $name .= strtolower($account->name);
} }

View File

@ -119,7 +119,7 @@ class Journal extends Twig_Extension
return $cache->get(); return $cache->get();
} }
$list = TransactionJournal::sourceAccountList($journal); $list = $journal->sourceAccountList();
$array = []; $array = [];
/** @var Account $entry */ /** @var Account $entry */
foreach ($list as $entry) { foreach ($list as $entry) {