mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #933
This commit is contained in:
parent
95c3f52144
commit
783f587a8a
@ -19,6 +19,7 @@ use FireflyIII\Exceptions\FireflyException;
|
|||||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Routing\Route;
|
use Illuminate\Routing\Route;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@ -132,6 +133,12 @@ class HomeController extends Controller
|
|||||||
$accounts = $repository->getAccountsById($frontPage->data);
|
$accounts = $repository->getAccountsById($frontPage->data);
|
||||||
$showDeps = Preferences::get('showDepositsFrontpage', false)->data;
|
$showDeps = Preferences::get('showDepositsFrontpage', false)->data;
|
||||||
|
|
||||||
|
// zero bills? Hide some elements from view.
|
||||||
|
/** @var BillRepositoryInterface $billRepository */
|
||||||
|
$billRepository = app(BillRepositoryInterface::class);
|
||||||
|
$billCount = $billRepository->getBills()->count();
|
||||||
|
|
||||||
|
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$collector = app(JournalCollectorInterface::class);
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit(10)->setPage(1);
|
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit(10)->setPage(1);
|
||||||
@ -140,7 +147,7 @@ class HomeController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'index', compact('count', 'subTitle', 'transactions', 'showDeps')
|
'index', compact('count', 'subTitle', 'transactions', 'showDeps','billCount')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,16 +166,30 @@ class BoxController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function netWorth(AccountRepositoryInterface $repository)
|
public function netWorth(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$today = new Carbon(date('Y-m-d')); // needed so its per day.
|
$date = new Carbon(date('Y-m-d')); // needed so its per day.
|
||||||
|
/** @var Carbon $start */
|
||||||
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
|
/** @var Carbon $end */
|
||||||
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
|
|
||||||
|
// start and end in the future? use $end
|
||||||
|
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
|
||||||
|
$date = $end;
|
||||||
|
}
|
||||||
|
// start and end in the past? use $end
|
||||||
|
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
|
||||||
|
$date = $end;
|
||||||
|
}
|
||||||
|
// start in the past, end in the future? use $date
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($today);
|
$cache->addProperty($date);
|
||||||
$cache->addProperty('box-net-worth');
|
$cache->addProperty('box-net-worth');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
$currency = app('amount')->getDefaultCurrency();
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
$balances = app('steam')->balancesByAccounts($accounts, $today);
|
$balances = app('steam')->balancesByAccounts($accounts, $date);
|
||||||
$sum = '0';
|
$sum = '0';
|
||||||
foreach ($balances as $entry) {
|
foreach ($balances as $entry) {
|
||||||
$sum = bcadd($sum, $entry);
|
$sum = bcadd($sum, $entry);
|
||||||
|
Loading…
Reference in New Issue
Block a user