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

This commit is contained in:
James Cole
2017-03-04 07:18:35 +01:00
parent 33c20c8dc4
commit d9aa074330
25 changed files with 144 additions and 169 deletions

View File

@@ -83,8 +83,8 @@ class SingleController extends Controller
public function cloneTransaction(TransactionJournal $journal)
{
$source = TransactionJournal::sourceAccountList($journal)->first();
$destination = TransactionJournal::destinationAccountList($journal)->first();
$source = $journal->sourceAccountList()->first();
$destination = $journal->destinationAccountList()->first();
$budget = $journal->budgets()->first();
$budgetId = is_null($budget) ? 0 : $budget->id;
$category = $journal->categories()->first();
@@ -98,7 +98,7 @@ class SingleController extends Controller
'source_account_name' => $source->name,
'destination_account_id' => $destination->id,
'destination_account_name' => $destination->name,
'amount' => TransactionJournal::amountPositive($journal),
'amount' => $journal->amountPositive(),
'date' => $journal->date->format('Y-m-d'),
'budget_id' => $budgetId,
'category' => $categoryName,
@@ -195,7 +195,7 @@ class SingleController extends Controller
return $this->redirectToAccount($transactionJournal);
}
// @codeCoverageIgnoreEnd
$type = TransactionJournal::transactionTypeStr($transactionJournal);
$type = $transactionJournal->transactionTypeStr();
Session::flash('success', strval(trans('firefly.deleted_' . strtolower($type), ['description' => e($transactionJournal->description)])));
$repository->delete($transactionJournal);
@@ -224,7 +224,7 @@ class SingleController extends Controller
return redirect(route('transactions.split.edit', [$journal->id]));
}
$what = strtolower(TransactionJournal::transactionTypeStr($journal));
$what = strtolower($journal->transactionTypeStr());
$assetAccounts = ExpandedForm::makeSelectList($this->accounts->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]));
$budgetList = ExpandedForm::makeSelectListWithEmpty($this->budgets->getBudgets());
@@ -233,27 +233,27 @@ class SingleController extends Controller
// journal related code
$sourceAccounts = TransactionJournal::sourceAccountList($journal);
$destinationAccounts = TransactionJournal::destinationAccountList($journal);
$sourceAccounts = $journal->sourceAccountList();
$destinationAccounts = $journal->destinationAccountList();
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$preFilled = [
'date' => TransactionJournal::dateAsString($journal),
'interest_date' => TransactionJournal::dateAsString($journal, 'interest_date'),
'book_date' => TransactionJournal::dateAsString($journal, 'book_date'),
'process_date' => TransactionJournal::dateAsString($journal, 'process_date'),
'category' => TransactionJournal::categoryAsString($journal),
'budget_id' => TransactionJournal::budgetId($journal),
'date' => $journal->dateAsString(),
'interest_date' => $journal->dateAsString( 'interest_date'),
'book_date' => $journal->dateAsString('book_date'),
'process_date' => $journal->dateAsString('process_date'),
'category' => $journal->categoryAsString(),
'budget_id' => $journal->budgetId(),
'tags' => join(',', $journal->tags->pluck('tag')->toArray()),
'source_account_id' => $sourceAccounts->first()->id,
'source_account_name' => $sourceAccounts->first()->edit_name,
'destination_account_id' => $destinationAccounts->first()->id,
'destination_account_name' => $destinationAccounts->first()->edit_name,
'amount' => TransactionJournal::amountPositive($journal),
'amount' => $journal->amountPositive(),
// new custom fields:
'due_date' => TransactionJournal::dateAsString($journal, 'due_date'),
'payment_date' => TransactionJournal::dateAsString($journal, 'payment_date'),
'invoice_date' => TransactionJournal::dateAsString($journal, 'invoice_date'),
'due_date' => $journal->dateAsString('due_date'),
'payment_date' => $journal->dateAsString('payment_date'),
'invoice_date' => $journal->dateAsString('invoice_date'),
'interal_reference' => $journal->getMeta('internal_reference'),
'notes' => $journal->getMeta('notes'),
];
@@ -369,7 +369,7 @@ class SingleController extends Controller
event(new UpdatedTransactionJournal($journal));
// update, get events by date and sort DESC
$type = strtolower(TransactionJournal::transactionTypeStr($journal));
$type = strtolower($journal->transactionTypeStr());
Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => e($data['description'])])));
Preferences::mark();