Some refactoring.

This commit is contained in:
James Cole
2014-12-30 18:44:58 +01:00
parent 94fcfacec4
commit 8c3ae40de1
26 changed files with 327 additions and 329 deletions

View File

@@ -58,18 +58,18 @@ class Chart implements ChartInterface
->where('transaction_journals.date', '<=', $end->format('Y-m-d'));
}
)
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '>', 0);
}
)
->where('active', 1)
->groupBy('bills.id')
->get(
['bills.id', 'bills.name', 'transaction_journals.description',
'transaction_journals.id as journalId',
\DB::Raw('SUM(`bills`.`amount_min` + `bills`.`amount_max`) / 2 as `averageAmount`'),
'transactions.amount AS actualAmount']
);
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '>', 0);
}
)
->where('active', 1)
->groupBy('bills.id')
->get(
['bills.id', 'bills.name', 'transaction_journals.description',
'transaction_journals.id as journalId',
\DB::Raw('SUM(`bills`.`amount_min` + `bills`.`amount_max`) / 2 as `averageAmount`'),
'transactions.amount AS actualAmount']
);
}
}

View File

@@ -65,7 +65,7 @@ class Bill implements CUD, CommonDatabaseCalls, BillInterface
/*
* Jump to the start of the period.
*/
$date = \DateKit::startOfPeriod($date, $data['repeat_freq']);
$date = \DateKit::startOfPeriod($date, $data['repeat_freq']);
$bill->date = $date;
$bill->skip = intval($data['skip']);
@@ -193,9 +193,9 @@ class Bill implements CUD, CommonDatabaseCalls, BillInterface
}
/**
* @param \Bill $bill
* @param Carbon $start
* @param Carbon $end
* @param \Bill $bill
* @param Carbon $start
* @param Carbon $end
*
* @return \TransactionJournal|null
*/
@@ -206,8 +206,8 @@ class Bill implements CUD, CommonDatabaseCalls, BillInterface
}
/**
* @param \Bill $bill
* @param \TransactionJournal $journal
* @param \Bill $bill
* @param \TransactionJournal $journal
*
* @return bool
*/

View File

@@ -238,6 +238,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
/**
* This method includes the time because otherwise, SQLite doesn't understand it.
*
* @param \Budget $budget
* @param Carbon $date
*
@@ -369,6 +370,5 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
return $budget->budgetLimits()->where('startdate', $date->format('Y-m-d 00:00:00'))->first();
}
}

View File

@@ -6,7 +6,6 @@ use FireflyIII\Database\CommonDatabaseCalls;
use FireflyIII\Database\CUD;
use FireflyIII\Exception\FireflyException;
use FireflyIII\Exception\NotImplementedException;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Support\Collection;
/**

View File

@@ -2,7 +2,6 @@
namespace FireflyIII\Database\PiggyBank;
use Carbon\Carbon;
use FireflyIII\Database\SwitchUser;
use FireflyIII\Exception\NotImplementedException;
use Illuminate\Database\Eloquent\Model as Eloquent;

View File

@@ -6,9 +6,6 @@ namespace FireflyIII\Database\PiggyBank;
use FireflyIII\Collection\PiggyBankPart;
use FireflyIII\Database\CommonDatabaseCalls;
use FireflyIII\Database\CUD;
use FireflyIII\Database\SwitchUser;
use FireflyIII\Exception\NotImplementedException;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Support\Collection;
/**

View File

@@ -44,8 +44,8 @@ class TransactionJournal
public function update(\TransactionJournal $journal)
{
/** @var \FireflyIII\Database\Bill\Bill $repository */
$repository = \App::make('FireflyIII\Database\Bill\Bill');
$set = $repository->get();
$repository = \App::make('FireflyIII\Database\Bill\Bill');
$set = $repository->get();
$journal->bill_id = null;
$journal->save();

View File

@@ -123,7 +123,7 @@ class Form
$html .= \Form::input('text', $name, $value, $options);
break;
case 'amount':
$html .= '<div class="input-group"><div class="input-group-addon">'.getCurrencySymbol().'</div>';
$html .= '<div class="input-group"><div class="input-group-addon">' . getCurrencySymbol() . '</div>';
$html .= \Form::input('number', $name, $value, $options);
$html .= '</div>';
break;

View File

@@ -95,6 +95,29 @@ class ReportHelper implements ReportHelperInterface
return $one;
}
/**
* Sort an array where all 'amount' keys are positive floats.
*
* @param array $array
*
* @return array
*/
public function sortArray(array $array)
{
uasort(
$array, function ($left, $right) {
if ($left['amount'] == $right['amount']) {
return 0;
}
return ($left['amount'] < $right['amount']) ? 1 : -1;
}
);
return $array;
}
/**
* Sort an array where all 'amount' keys are negative floats.
*
@@ -116,25 +139,4 @@ class ReportHelper implements ReportHelperInterface
return $array;
}
/**
* Sort an array where all 'amount' keys are positive floats.
*
* @param array $array
*
* @return array
*/
public function sortArray(array $array) {
uasort(
$array, function ($left, $right) {
if ($left['amount'] == $right['amount']) {
return 0;
}
return ($left['amount'] < $right['amount']) ? 1 : -1;
}
);
return $array;
}
}

View File

@@ -43,15 +43,6 @@ interface ReportHelperInterface
*/
public function mergeArrays(array $one, array $two);
/**
* Sort an array where all 'amount' keys are negative floats.
*
* @param array $array
*
* @return array
*/
public function sortNegativeArray(array $array);
/**
* Sort an array where all 'amount' keys are positive floats.
*
@@ -61,4 +52,13 @@ interface ReportHelperInterface
*/
public function sortArray(array $array);
/**
* Sort an array where all 'amount' keys are negative floats.
*
* @param array $array
*
* @return array
*/
public function sortNegativeArray(array $array);
}

View File

@@ -44,8 +44,8 @@ class ReportQuery implements ReportQueryInterface
* and are balanced by a transfer to make up for it.
*
* @param \Account $account
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
@@ -97,8 +97,8 @@ class ReportQuery implements ReportQueryInterface
* and are balanced by a transfer to make up for it.
*
* @param \Account $account
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return float
*/

View File

@@ -47,8 +47,8 @@ interface ReportQueryInterface
* and are balanced by a transfer to make up for it.
*
* @param \Account $account
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return float
*/
@@ -59,8 +59,8 @@ interface ReportQueryInterface
* and are balanced by a transfer to make up for it.
*
* @param \Account $account
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/

View File

@@ -24,6 +24,7 @@ class Preferences implements PreferencesInterface
if (!is_null($pref)) {
return $pref;
}
return $this->set($name, $default);
}

View File

@@ -1,6 +1,7 @@
<?php
namespace FireflyIII\Shared\Toolkit;
use Carbon\Carbon;
use FireflyIII\Exception\FireflyException;

View File

@@ -23,7 +23,7 @@ class Steam
*/
public function balance(\Account $account, Carbon $date = null)
{
\Log::debug('Now in Steam::balance() for account #' . $account->id.' ('.$account->name.')');
\Log::debug('Now in Steam::balance() for account #' . $account->id . ' (' . $account->name . ')');
if (is_null($date)) {
$key = 'account.' . $account->id . '.latestBalance';
} else {
@@ -33,7 +33,7 @@ class Steam
// TODO find a way to reliably remove cache entries for accounts.
#return \Cache::get($key);
}
$date = is_null($date) ? Carbon::now() : $date;
$date = is_null($date) ? Carbon::now() : $date;
\Log::debug('Now reached the moment we fire the query.');
$balance = floatval(
$account->transactions()->leftJoin(

View File

@@ -10,7 +10,7 @@
<i class="fa fa-repeat"></i> Transactions ({{$result['transactions']->count()}})
</div>
<div class="panel-body">
@include('...lists.old.journals-small-noaccount',['transactions' => $result['transactions']])
@include('list.journals-small',['journals' => $result['transactions']])
</div>
</div>
</div>