mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Small optimisations.
This commit is contained in:
parent
bd96b2819f
commit
9be05e7e17
@ -1,5 +1,6 @@
|
||||
<?php namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Input;
|
||||
@ -46,6 +47,16 @@ class HomeController extends Controller
|
||||
$accounts = $repository->getFrontpageAccounts($frontPage);
|
||||
$savings = $repository->getSavingsAccounts();
|
||||
|
||||
// check if all books are correct.
|
||||
$sum = floatval(Auth::user()->transactions()->sum('amount'));
|
||||
if ($sum == 0) {
|
||||
Session::flash(
|
||||
'error', 'Your transactions are unbalanced. This means a'
|
||||
. ' withdrawal, deposit or transfer was not stored properly. '
|
||||
. 'Please check your accounts and transactions for errors.'
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$set = $repository->getFrontpageTransactions($account, $start, $end);
|
||||
if (count($set) > 0) {
|
||||
|
@ -16,7 +16,7 @@ class Preferences
|
||||
* @param $name
|
||||
* @param null $default
|
||||
*
|
||||
* @return null|\Preference
|
||||
* @return null|Preference
|
||||
*/
|
||||
public function get($name, $default = null)
|
||||
{
|
||||
@ -37,7 +37,7 @@ class Preferences
|
||||
* @param $name
|
||||
* @param $value
|
||||
*
|
||||
* @return \Preference
|
||||
* @return Preference
|
||||
*/
|
||||
public function set($name, $value)
|
||||
{
|
||||
|
@ -75,6 +75,14 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
return $this->hasManyThrough('FireflyIII\Models\PiggyBank', 'FireflyIII\Models\Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
*/
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasManyThrough('FireflyIII\Models\Transaction', 'FireflyIII\Models\TransactionJournal');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user