Some cleaning up [skip ci]

This commit is contained in:
James Cole
2015-06-14 08:22:02 +02:00
parent 8bd445ab19
commit 0de1242c83
5 changed files with 22 additions and 33 deletions
+9 -9
View File
@@ -16,19 +16,19 @@ class BillLine
/** @var bool */ /** @var bool */
protected $active; protected $active;
/** @var float */ /** @var string */
protected $amount; protected $amount;
/** @var BillModel */ /** @var BillModel */
protected $bill; protected $bill;
/** @var bool */ /** @var bool */
protected $hit; protected $hit;
/** @var float */ /** @var string */
protected $max; protected $max;
/** @var float */ /** @var string */
protected $min; protected $min;
/** /**
* @return float * @return string
*/ */
public function getAmount() public function getAmount()
{ {
@@ -36,7 +36,7 @@ class BillLine
} }
/** /**
* @param float $amount * @param string $amount
*/ */
public function setAmount($amount) public function setAmount($amount)
{ {
@@ -60,7 +60,7 @@ class BillLine
} }
/** /**
* @return float * @return string
*/ */
public function getMax() public function getMax()
{ {
@@ -68,7 +68,7 @@ class BillLine
} }
/** /**
* @param float $max * @param string $max
*/ */
public function setMax($max) public function setMax($max)
{ {
@@ -76,7 +76,7 @@ class BillLine
} }
/** /**
* @return float * @return string
*/ */
public function getMin() public function getMin()
{ {
@@ -84,7 +84,7 @@ class BillLine
} }
/** /**
* @param float $min * @param string $min
*/ */
public function setMin($min) public function setMin($min)
{ {
+5 -4
View File
@@ -217,18 +217,19 @@ class ReportHelper implements ReportHelperInterface
$billLine = new BillLine; $billLine = new BillLine;
$billLine->setBill($bill); $billLine->setBill($bill);
$billLine->setActive(intval($bill->active) == 1); $billLine->setActive(intval($bill->active) == 1);
$billLine->setMin(floatval($bill->amount_min)); $billLine->setMin($bill->amount_min);
$billLine->setMax(floatval($bill->amount_max)); $billLine->setMax($bill->amount_max);
// is hit in period? // is hit in period?
bcscale(2);
$set = $repository->getJournalsInRange($bill, $start, $end); $set = $repository->getJournalsInRange($bill, $start, $end);
if ($set->count() == 0) { if ($set->count() == 0) {
$billLine->setHit(false); $billLine->setHit(false);
} else { } else {
$billLine->setHit(true); $billLine->setHit(true);
$amount = 0; $amount = '0';
foreach ($set as $entry) { foreach ($set as $entry) {
$amount += $entry->amount; $amount = bcadd($amount, $entry->amount);
} }
$billLine->setAmount($amount); $billLine->setAmount($amount);
} }
-1
View File
@@ -99,7 +99,6 @@ class ReportQuery implements ReportQueryInterface
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole'); $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
} }
) )
->orderBy('accounts.name', 'ASC')
->where( ->where(
function (Builder $query) { function (Builder $query) {
+5 -3
View File
@@ -183,11 +183,13 @@ Route::controllers(
] ]
); );
/**
* Home Controller
*/
Route::group( Route::group(
['middleware' => ['auth', 'range', 'reminders']], function () { ['middleware' => ['auth', 'range', 'reminders']], function () {
/**
* Home Controller
*/
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']); Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']); Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']);
Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']); Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']);
+3 -16
View File
@@ -33,24 +33,11 @@ class Steam
return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
} }
// find the first known transaction on this account:
$firstDateObject = $account
->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->orderBy('transaction_journals.date', 'ASC')->first(['transaction_journals.date']);
$firstDate = is_null($firstDateObject) ? clone $date : new Carbon($firstDateObject->date);
$date = $date < $firstDate ? $firstDate : $date;
bcscale(2); bcscale(2);
$set = $account->transactions()->leftJoin(
$balance = $account->transactions()->leftJoin(
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id' 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->get(['transactions.*']); )->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount');
$balance = '0';
foreach ($set as $entry) {
$balance = bcadd($balance, $entry->amount);
}
if (!$ignoreVirtualBalance) { if (!$ignoreVirtualBalance) {
$balance = bcadd($balance, $account->virtual_balance); $balance = bcadd($balance, $account->virtual_balance);