mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-27 09:21:04 -06:00
Specify times for SQLite database. #1192
This commit is contained in:
parent
4e6afd5afc
commit
9d457787f7
@ -595,7 +595,7 @@ class JournalCollector implements JournalCollectorInterface
|
|||||||
{
|
{
|
||||||
if ($start <= $end) {
|
if ($start <= $end) {
|
||||||
$startStr = $start->format('Y-m-d 00:00:00');
|
$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', '>=', $startStr);
|
||||||
$this->query->where('transaction_journals.date', '<=', $endStr);
|
$this->query->where('transaction_journals.date', '<=', $endStr);
|
||||||
Log::debug(sprintf('JournalCollector range is now %s - %s (inclusive)', $startStr, $endStr));
|
Log::debug(sprintf('JournalCollector range is now %s - %s (inclusive)', $startStr, $endStr));
|
||||||
|
@ -39,7 +39,6 @@ use Illuminate\Support\Collection;
|
|||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Response;
|
use Response;
|
||||||
use Steam;
|
|
||||||
|
|
||||||
/** checked
|
/** checked
|
||||||
* Class AccountController.
|
* Class AccountController.
|
||||||
@ -80,8 +79,8 @@ class AccountController extends Controller
|
|||||||
$start->subDay();
|
$start->subDay();
|
||||||
|
|
||||||
$accounts = $repository->getAccountsByType([AccountType::EXPENSE, AccountType::BENEFICIARY]);
|
$accounts = $repository->getAccountsByType([AccountType::EXPENSE, AccountType::BENEFICIARY]);
|
||||||
$startBalances = Steam::balancesByAccounts($accounts, $start);
|
$startBalances = app('steam')->balancesByAccounts($accounts, $start);
|
||||||
$endBalances = Steam::balancesByAccounts($accounts, $end);
|
$endBalances = app('steam')->balancesByAccounts($accounts, $end);
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
|
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
@ -330,7 +329,7 @@ class AccountController extends Controller
|
|||||||
switch ($step) {
|
switch ($step) {
|
||||||
case '1D':
|
case '1D':
|
||||||
$format = (string)trans('config.month_and_day');
|
$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];
|
$previous = array_values($range)[0];
|
||||||
while ($end >= $current) {
|
while ($end >= $current) {
|
||||||
$theDate = $current->format('Y-m-d');
|
$theDate = $current->format('Y-m-d');
|
||||||
@ -345,7 +344,7 @@ class AccountController extends Controller
|
|||||||
case '1M': // @codeCoverageIgnore
|
case '1M': // @codeCoverageIgnore
|
||||||
case '1Y': // @codeCoverageIgnore
|
case '1Y': // @codeCoverageIgnore
|
||||||
while ($end >= $current) {
|
while ($end >= $current) {
|
||||||
$balance = floatval(Steam::balance($account, $current));
|
$balance = floatval(app('steam')->balance($account, $current));
|
||||||
$label = app('navigation')->periodShow($current, $step);
|
$label = app('navigation')->periodShow($current, $step);
|
||||||
$chartData[$label] = $balance;
|
$chartData[$label] = $balance;
|
||||||
$current = app('navigation')->addPeriod($current, $step, 1);
|
$current = app('navigation')->addPeriod($current, $step, 1);
|
||||||
@ -394,8 +393,8 @@ class AccountController extends Controller
|
|||||||
$accounts = $repository->getAccountsByType([AccountType::REVENUE]);
|
$accounts = $repository->getAccountsByType([AccountType::REVENUE]);
|
||||||
|
|
||||||
$start->subDay();
|
$start->subDay();
|
||||||
$startBalances = Steam::balancesByAccounts($accounts, $start);
|
$startBalances = app('steam')->balancesByAccounts($accounts, $start);
|
||||||
$endBalances = Steam::balancesByAccounts($accounts, $end);
|
$endBalances = app('steam')->balancesByAccounts($accounts, $end);
|
||||||
|
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$id = $account->id;
|
$id = $account->id;
|
||||||
@ -440,14 +439,14 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$currency = $repository->find(intval($account->getMeta('currency_id')));
|
$currency = $repository->findNull(intval($account->getMeta('currency_id')));
|
||||||
$currentSet = [
|
$currentSet = [
|
||||||
'label' => $account->name,
|
'label' => $account->name,
|
||||||
'currency_symbol' => $currency->symbol,
|
'currency_symbol' => $currency->symbol,
|
||||||
'entries' => [],
|
'entries' => [],
|
||||||
];
|
];
|
||||||
$currentStart = clone $start;
|
$currentStart = clone $start;
|
||||||
$range = Steam::balanceInRange($account, $start, clone $end);
|
$range = app('steam')->balanceInRange($account, $start, clone $end);
|
||||||
$previous = array_values($range)[0];
|
$previous = array_values($range)[0];
|
||||||
while ($currentStart <= $end) {
|
while ($currentStart <= $end) {
|
||||||
$format = $currentStart->format('Y-m-d');
|
$format = $currentStart->format('Y-m-d');
|
||||||
|
@ -54,14 +54,14 @@ class Steam
|
|||||||
$currencyId = intval($account->getMeta('currency_id'));
|
$currencyId = intval($account->getMeta('currency_id'));
|
||||||
// use system default currency:
|
// use system default currency:
|
||||||
if (0 === $currencyId) {
|
if (0 === $currencyId) {
|
||||||
$currency = app('amount')->getDefaultCurrencyByUser($account->user);
|
$currency = app('amount')->getDefaultCurrencyByUser($account->user);
|
||||||
$currencyId = $currency->id;
|
$currencyId = $currency->id;
|
||||||
}
|
}
|
||||||
// first part: get all balances in own currency:
|
// first part: get all balances in own currency:
|
||||||
$nativeBalance = strval(
|
$nativeBalance = strval(
|
||||||
$account->transactions()
|
$account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->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)
|
->where('transactions.transaction_currency_id', $currencyId)
|
||||||
->sum('transactions.amount')
|
->sum('transactions.amount')
|
||||||
);
|
);
|
||||||
@ -150,9 +150,10 @@ class Steam
|
|||||||
|
|
||||||
$start->subDay();
|
$start->subDay();
|
||||||
$end->addDay();
|
$end->addDay();
|
||||||
$balances = [];
|
$balances = [];
|
||||||
$formatted = $start->format('Y-m-d');
|
$formatted = $start->format('Y-m-d');
|
||||||
$startBalance = $this->balance($account, $start);
|
$startBalance = $this->balance($account, $start);
|
||||||
|
|
||||||
$balances[$formatted] = $startBalance;
|
$balances[$formatted] = $startBalance;
|
||||||
$currencyId = intval($account->getMeta('currency_id'));
|
$currencyId = intval($account->getMeta('currency_id'));
|
||||||
$start->addDay();
|
$start->addDay();
|
||||||
@ -160,8 +161,8 @@ class Steam
|
|||||||
// query!
|
// query!
|
||||||
$set = $account->transactions()
|
$set = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->where('transaction_journals.date', '>=', $start->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'))
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d 23:59:59'))
|
||||||
->groupBy('transaction_journals.date')
|
->groupBy('transaction_journals.date')
|
||||||
->groupBy('transactions.transaction_currency_id')
|
->groupBy('transactions.transaction_currency_id')
|
||||||
->groupBy('transactions.foreign_currency_id')
|
->groupBy('transactions.foreign_currency_id')
|
||||||
|
Loading…
Reference in New Issue
Block a user