This commit is contained in:
James Cole
2025-02-16 07:23:03 +01:00
parent dfcd5d79be
commit 6c38b87ec5

View File

@@ -102,7 +102,7 @@ class BasicController extends Controller
$balanceData = $this->getBalanceInformation($start, $end); $balanceData = $this->getBalanceInformation($start, $end);
$billData = $this->getBillInformation($start, $end); $billData = $this->getBillInformation($start, $end);
$spentData = $this->getLeftToSpendInfo($start, $end); $spentData = $this->getLeftToSpendInfo($start, $end);
$netWorthData = $this->getNetWorthInfo($start, $end); $netWorthData = $this->getNetWorthInfo($end);
// $balanceData = []; // $balanceData = [];
// $billData = []; // $billData = [];
// $spentData = []; // $spentData = [];
@@ -319,18 +319,12 @@ class BasicController extends Controller
return $return; return $return;
} }
private function getNetWorthInfo(Carbon $start, Carbon $end): array private function getNetWorthInfo(Carbon $end): array
{ {
$end->endOfDay();
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$date = now(config('app.timezone')); Log::debug(sprintf('getNetWorthInfo up until "%s".', $end->format('Y-m-d H:i:s')));
// start and end in the future? use $end
if ($this->notInDateRange($date, $start, $end)) {
/** @var Carbon $date */
$date = session('end', today(config('app.timezone'))->endOfMonth());
}
Log::debug(sprintf('getNetWorthInfo up until "%s".', $date->format('Y-m-d H:i:s')));
/** @var NetWorthInterface $netWorthHelper */ /** @var NetWorthInterface $netWorthHelper */
$netWorthHelper = app(NetWorthInterface::class); $netWorthHelper = app(NetWorthInterface::class);
@@ -346,7 +340,7 @@ class BasicController extends Controller
} }
); );
$netWorthSet = $netWorthHelper->byAccounts($filtered, $date); $netWorthSet = $netWorthHelper->byAccounts($filtered, $end);
$return = []; $return = [];
foreach ($netWorthSet as $key => $data) { foreach ($netWorthSet as $key => $data) {
if ('native' === $key) { if ('native' === $key) {