diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php index cf3a781df8..f4fa3d2e6e 100644 --- a/app/Helpers/Collector/JournalCollector.php +++ b/app/Helpers/Collector/JournalCollector.php @@ -595,7 +595,7 @@ class JournalCollector implements JournalCollectorInterface { if ($start <= $end) { $startStr = $start->format('Y-m-d 00:00:00'); - $endStr = $end->format('Y-m-d 00:00:00'); + $endStr = $end->format('Y-m-d 23:59:59'); $this->query->where('transaction_journals.date', '>=', $startStr); $this->query->where('transaction_journals.date', '<=', $endStr); Log::debug(sprintf('JournalCollector range is now %s - %s (inclusive)', $startStr, $endStr)); diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index da9bc727f0..b96bef9e43 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -39,7 +39,6 @@ use Illuminate\Support\Collection; use Log; use Preferences; use Response; -use Steam; /** checked * Class AccountController. @@ -80,8 +79,8 @@ class AccountController extends Controller $start->subDay(); $accounts = $repository->getAccountsByType([AccountType::EXPENSE, AccountType::BENEFICIARY]); - $startBalances = Steam::balancesByAccounts($accounts, $start); - $endBalances = Steam::balancesByAccounts($accounts, $end); + $startBalances = app('steam')->balancesByAccounts($accounts, $start); + $endBalances = app('steam')->balancesByAccounts($accounts, $end); $chartData = []; foreach ($accounts as $account) { @@ -330,7 +329,7 @@ class AccountController extends Controller switch ($step) { case '1D': $format = (string)trans('config.month_and_day'); - $range = Steam::balanceInRange($account, $start, $end); + $range = app('steam')->balanceInRange($account, $start, $end); $previous = array_values($range)[0]; while ($end >= $current) { $theDate = $current->format('Y-m-d'); @@ -345,7 +344,7 @@ class AccountController extends Controller case '1M': // @codeCoverageIgnore case '1Y': // @codeCoverageIgnore while ($end >= $current) { - $balance = floatval(Steam::balance($account, $current)); + $balance = floatval(app('steam')->balance($account, $current)); $label = app('navigation')->periodShow($current, $step); $chartData[$label] = $balance; $current = app('navigation')->addPeriod($current, $step, 1); @@ -394,8 +393,8 @@ class AccountController extends Controller $accounts = $repository->getAccountsByType([AccountType::REVENUE]); $start->subDay(); - $startBalances = Steam::balancesByAccounts($accounts, $start); - $endBalances = Steam::balancesByAccounts($accounts, $end); + $startBalances = app('steam')->balancesByAccounts($accounts, $start); + $endBalances = app('steam')->balancesByAccounts($accounts, $end); foreach ($accounts as $account) { $id = $account->id; @@ -440,14 +439,14 @@ class AccountController extends Controller $chartData = []; foreach ($accounts as $account) { - $currency = $repository->find(intval($account->getMeta('currency_id'))); + $currency = $repository->findNull(intval($account->getMeta('currency_id'))); $currentSet = [ 'label' => $account->name, 'currency_symbol' => $currency->symbol, 'entries' => [], ]; $currentStart = clone $start; - $range = Steam::balanceInRange($account, $start, clone $end); + $range = app('steam')->balanceInRange($account, $start, clone $end); $previous = array_values($range)[0]; while ($currentStart <= $end) { $format = $currentStart->format('Y-m-d'); diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 93ce41c4fd..e3453c7f2b 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -54,14 +54,14 @@ class Steam $currencyId = intval($account->getMeta('currency_id')); // use system default currency: if (0 === $currencyId) { - $currency = app('amount')->getDefaultCurrencyByUser($account->user); + $currency = app('amount')->getDefaultCurrencyByUser($account->user); $currencyId = $currency->id; } // first part: get all balances in own currency: $nativeBalance = strval( $account->transactions() ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') - ->where('transaction_journals.date', '<=', $date->format('Y-m-d')) + ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) ->where('transactions.transaction_currency_id', $currencyId) ->sum('transactions.amount') ); @@ -150,9 +150,10 @@ class Steam $start->subDay(); $end->addDay(); - $balances = []; - $formatted = $start->format('Y-m-d'); - $startBalance = $this->balance($account, $start); + $balances = []; + $formatted = $start->format('Y-m-d'); + $startBalance = $this->balance($account, $start); + $balances[$formatted] = $startBalance; $currencyId = intval($account->getMeta('currency_id')); $start->addDay(); @@ -160,8 +161,8 @@ class Steam // query! $set = $account->transactions() ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') - ->where('transaction_journals.date', '>=', $start->format('Y-m-d')) - ->where('transaction_journals.date', '<=', $end->format('Y-m-d')) + ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00')) + ->where('transaction_journals.date', '<=', $end->format('Y-m-d 23:59:59')) ->groupBy('transaction_journals.date') ->groupBy('transactions.transaction_currency_id') ->groupBy('transactions.foreign_currency_id')