Skip to content

Firefly III: a personal finances manager

Some cleaning up [skip ci]

James Cole0de1242c83ea
diff --git a/app/Helpers/Collection/BillLine.php b/app/Helpers/Collection/BillLine.php
index 9c225a28e5..5091747577 100644
--- a/app/Helpers/Collection/BillLine.php
+++ b/app/Helpers/Collection/BillLine.php
@@ -16,19 +16,19 @@ class BillLine
/** @var bool */
protected $active;
- /** @var float */
+ /** @var string */
protected $amount;
/** @var BillModel */
protected $bill;
/** @var bool */
protected $hit;
- /** @var float */
+ /** @var string */
protected $max;
- /** @var float */
+ /** @var string */
protected $min;
/**
- * @return float
+ * @return string
*/
public function getAmount()
{
@@ -36,7 +36,7 @@ class BillLine
}
/**
- * @param float $amount
+ * @param string $amount
*/
public function setAmount($amount)
{
@@ -60,7 +60,7 @@ class BillLine
}
/**
- * @return float
+ * @return string
*/
public function getMax()
{
@@ -68,7 +68,7 @@ class BillLine
}
/**
- * @param float $max
+ * @param string $max
*/
public function setMax($max)
{
@@ -76,7 +76,7 @@ class BillLine
}
/**
- * @return float
+ * @return string
*/
public function getMin()
{
@@ -84,7 +84,7 @@ class BillLine
}
/**
- * @param float $min
+ * @param string $min
*/
public function setMin($min)
{
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index 9c24abe6df..d932be04f2 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -217,18 +217,19 @@ class ReportHelper implements ReportHelperInterface
$billLine = new BillLine;
$billLine->setBill($bill);
$billLine->setActive(intval($bill->active) == 1);
- $billLine->setMin(floatval($bill->amount_min));
- $billLine->setMax(floatval($bill->amount_max));
+ $billLine->setMin($bill->amount_min);
+ $billLine->setMax($bill->amount_max);
// is hit in period?
+ bcscale(2);
$set = $repository->getJournalsInRange($bill, $start, $end);
if ($set->count() == 0) {
$billLine->setHit(false);
} else {
$billLine->setHit(true);
- $amount = 0;
+ $amount = '0';
foreach ($set as $entry) {
- $amount += $entry->amount;
+ $amount = bcadd($amount, $entry->amount);
}
$billLine->setAmount($amount);
}
diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php
index e22f663722..b2ac2eb624 100644
--- a/app/Helpers/Report/ReportQuery.php
+++ b/app/Helpers/Report/ReportQuery.php
@@ -99,7 +99,6 @@ class ReportQuery implements ReportQueryInterface
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
}
)
- ->orderBy('accounts.name', 'ASC')
->where(
function (Builder $query) {
diff --git a/app/Http/routes.php b/app/Http/routes.php
index 2b66dac023..361fdd5229 100644
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -183,11 +183,13 @@ Route::controllers(
]
);
-/**
- * Home Controller
- */
+
Route::group(
['middleware' => ['auth', 'range', 'reminders']], function () {
+
+ /**
+ * Home Controller
+ */
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']);
Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']);
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index 627faba6d9..c4043d559d 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -33,24 +33,11 @@ class Steam
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);
- $set = $account->transactions()->leftJoin(
+
+ $balance = $account->transactions()->leftJoin(
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
- )->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->get(['transactions.*']);
- $balance = '0';
- foreach ($set as $entry) {
- $balance = bcadd($balance, $entry->amount);
- }
+ )->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount');
if (!$ignoreVirtualBalance) {
$balance = bcadd($balance, $account->virtual_balance);