Code cleanup [skip-ci]

This commit is contained in:
James Cole
2014-07-15 22:16:29 +02:00
parent 473e0f81c9
commit d280767407
35 changed files with 469 additions and 128 deletions

View File

@@ -38,15 +38,15 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
$amountFrom = $amount * -1;
$amountTo = $amount;
if(round(floatval($amount),2) == 0.00) {
if (round(floatval($amount), 2) == 0.00) {
\Log::error('Transaction will never save: amount = 0');
\Session::flash('error','The amount should not be empty or zero.');
\Session::flash('error', 'The amount should not be empty or zero.');
throw new \Firefly\Exception\FireflyException('Could not figure out transaction type.');
}
// same account:
if($from->id == $to->id) {
if ($from->id == $to->id) {
\Log::error('Accounts cannot be equal');
\Session::flash('error','Select two different accounts.');
\Session::flash('error', 'Select two different accounts.');
throw new \Firefly\Exception\FireflyException('Select two different accounts.');
}
@@ -108,7 +108,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
if (!$journal->save()) {
\Log::error('Cannot create valid journal.');
\Log::error('Errors: ' . print_r($journal->errors()->all(), true));
\Session::flash('error','Could not create journal: ' . $journal->errors()->first());
\Session::flash('error', 'Could not create journal: ' . $journal->errors()->first());
throw new \Firefly\Exception\FireflyException('Cannot create valid journal.');
}
$journal->save();
@@ -173,7 +173,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
}]
)
->after($start)->before($end)
->where('completed',1)
->where('completed', 1)
->whereIn('transaction_type_id', $types)
->get(['transaction_journals.*']);
unset($types);
@@ -182,8 +182,9 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
foreach ($journals as $journal) {
// has to be one:
if(!isset($journal->transactions[0])) {
throw new FireflyException('Journal #'.$journal->id.' has ' . count($journal->transactions).' transactions!');
if (!isset($journal->transactions[0])) {
throw new FireflyException('Journal #' . $journal->id . ' has ' . count($journal->transactions)
. ' transactions!');
}
$transaction = $journal->transactions[0];
$amount = floatval($transaction->amount);

View File

@@ -12,7 +12,9 @@ interface TransactionJournalRepositoryInterface
public function getByAccount(\Account $account, $count = 25);
public function homeBudgetChart(\Carbon\Carbon $start, \Carbon\Carbon $end);
public function homeCategoryChart(\Carbon\Carbon $start, \Carbon\Carbon $end);
public function homeBeneficiaryChart(\Carbon\Carbon $start, \Carbon\Carbon $end);
public function homeComponentChart(\Carbon\Carbon $start, \Carbon\Carbon $end, $chartType);