Remove all time jumps because they’re unclear and complex.

This commit is contained in:
James Cole 2017-07-30 13:53:04 +02:00
parent 1caa393974
commit 1cfa1faccc
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
7 changed files with 49 additions and 182 deletions

View File

@ -32,7 +32,6 @@ use Illuminate\Support\Collection;
use Log; use Log;
use Navigation; use Navigation;
use Preferences; use Preferences;
use Session;
use Steam; use Steam;
use View; use View;
@ -292,37 +291,14 @@ class AccountController extends Controller
$periods = $this->getPeriodOverview($account); $periods = $this->getPeriodOverview($account);
} }
$count = 0; // grab journals:
$loop = 0; $collector = app(JournalCollectorInterface::class);
// grab journals, but be prepared to jump a period back to get the right ones: $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
Log::info('Now at loop start.'); if (!is_null($start)) {
while ($count === 0 && $loop < 3) { $collector->setRange($start, $end);
$loop++;
$collector = app(JournalCollectorInterface::class);
Log::info('Count is zero, search for journals.');
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
if (!is_null($start)) {
$collector->setRange($start, $end);
}
$journals = $collector->getPaginatedJournals();
$journals->setPath(route('accounts.show', [$account->id, $moment]));
$count = $journals->getCollection()->count();
if ($count === 0 && $loop < 3) {
$start->subDay();
$start = Navigation::startOfPeriod($start, $range);
$end = Navigation::endOfPeriod($start, $range);
Log::info(sprintf('Count is still zero, go back in time to "%s" and "%s"!', $start->format('Y-m-d'), $end->format('Y-m-d')));
}
} }
$journals = $collector->getPaginatedJournals();
if ($moment !== 'all' && $loop > 1) { $journals->setPath(route('accounts.show', [$account->id, $moment]));
$fStart = $start->formatLocalized($this->monthAndDayFormat);
$fEnd = $end->formatLocalized($this->monthAndDayFormat);
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d')]);
$subTitle = trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);
Session::flash('info', trans('firefly.jump_back_in_time'));
}
return view( return view(
'accounts.show', 'accounts.show',

View File

@ -34,7 +34,6 @@ use Log;
use Navigation; use Navigation;
use Preferences; use Preferences;
use Response; use Response;
use Session;
use View; use View;
/** /**
@ -297,35 +296,12 @@ class BudgetController extends Controller
$page = intval($request->get('page')); $page = intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data); $pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$count = 0; /** @var JournalCollectorInterface $collector */
$loop = 0; $collector = app(JournalCollectorInterface::class);
// grab journals, but be prepared to jump a period back to get the right ones: $collector->setAllAssetAccounts()->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)
Log::info('Now at no-budget loop start.'); ->withoutBudget()->withOpposingAccount();
while ($count === 0 && $loop < 3) { $journals = $collector->getPaginatedJournals();
$loop++; $journals->setPath(route('budgets.no-budget'));
Log::info(sprintf('Count is zero, search for journals between %s and %s.', $start->format('Y-m-d'), $end->format('Y-m-d')));
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)
->withoutBudget()->withOpposingAccount();
$journals = $collector->getPaginatedJournals();
$journals->setPath(route('budgets.no-budget'));
$count = $journals->getCollection()->count();
if ($count === 0 && $loop < 3) {
$start->subDay();
$start = Navigation::startOfPeriod($start, $range);
$end = Navigation::endOfPeriod($start, $range);
Log::info(sprintf('Count is still zero, go back in time to "%s" and "%s"!', $start->format('Y-m-d'), $end->format('Y-m-d')));
}
}
if ($moment !== 'all' && $loop > 1) {
$subTitle = trans(
'firefly.without_budget_between',
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
);
Session::flash('info', trans('firefly.jump_back_in_time'));
}
return view('budgets.no-budget', compact('journals', 'subTitle', 'moment', 'periods', 'start', 'end')); return view('budgets.no-budget', compact('journals', 'subTitle', 'moment', 'periods', 'start', 'end'));
} }

View File

@ -29,7 +29,6 @@ use Illuminate\Support\Collection;
use Log; use Log;
use Navigation; use Navigation;
use Preferences; use Preferences;
use Session;
use Steam; use Steam;
use View; use View;
@ -165,10 +164,12 @@ class CategoryController extends Controller
public function noCategory(Request $request, JournalRepositoryInterface $repository, string $moment = '') public function noCategory(Request $request, JournalRepositoryInterface $repository, string $moment = '')
{ {
// default values: // default values:
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
$start = null; $start = null;
$end = null; $end = null;
$periods = new Collection; $periods = new Collection;
$page = intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
// prep for "all" view. // prep for "all" view.
if ($moment === 'all') { if ($moment === 'all') {
@ -200,38 +201,13 @@ class CategoryController extends Controller
); );
} }
$page = intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$count = 0; /** @var JournalCollectorInterface $collector */
$loop = 0; $collector = app(JournalCollectorInterface::class);
// grab journals, but be prepared to jump a period back to get the right ones: $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()->withOpposingAccount();
Log::info('Now at no-cat loop start.'); $collector->removeFilter(InternalTransferFilter::class);
while ($count === 0 && $loop < 3) { $journals = $collector->getPaginatedJournals();
$loop++; $journals->setPath(route('categories.no-category'));
Log::info('Count is zero, search for journals.');
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()->withOpposingAccount();
$collector->removeFilter(InternalTransferFilter::class);
$journals = $collector->getPaginatedJournals();
$journals->setPath(route('categories.no-category'));
$count = $journals->getCollection()->count();
if ($count === 0 && $loop < 3) {
$start->subDay();
$start = Navigation::startOfPeriod($start, $range);
$end = Navigation::endOfPeriod($start, $range);
Log::info(sprintf('Count is still zero, go back in time to "%s" and "%s"!', $start->format('Y-m-d'), $end->format('Y-m-d')));
}
}
if ($moment !== 'all' && $loop > 1) {
$subTitle = trans(
'firefly.without_category_between',
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
);
Session::flash('info', trans('firefly.jump_back_in_time'));
}
return view('categories.no-category', compact('journals', 'subTitle', 'moment', 'periods', 'start', 'end')); return view('categories.no-category', compact('journals', 'subTitle', 'moment', 'periods', 'start', 'end'));
} }
@ -289,35 +265,15 @@ class CategoryController extends Controller
'end' => $end->formatLocalized($this->monthAndDayFormat)] 'end' => $end->formatLocalized($this->monthAndDayFormat)]
); );
} }
// grab journals, but be prepared to jump a period back to get the right ones:
Log::info('Now at category loop start.');
while ($count === 0 && $loop < 3) {
$loop++;
Log::info('Count is zero, search for journals.');
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
->setCategory($category)->withBudgetInformation()->withCategoryInformation();
$collector->removeFilter(InternalTransferFilter::class);
$journals = $collector->getPaginatedJournals();
$journals->setPath(route('categories.show', [$category->id]));
$count = $journals->getCollection()->count();
if ($count === 0 && $loop < 3) {
$start->subDay();
$start = Navigation::startOfPeriod($start, $range);
$end = Navigation::endOfPeriod($start, $range);
Log::info(sprintf('Count is still zero, go back in time to "%s" and "%s"!', $start->format('Y-m-d'), $end->format('Y-m-d')));
}
}
if ($moment !== 'all' && $loop > 1) { /** @var JournalCollectorInterface $collector */
$subTitle = trans( $collector = app(JournalCollectorInterface::class);
'firefly.journals_in_period_for_category', $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
['name' => $category->name, 'start' => $start->formatLocalized($this->monthAndDayFormat), ->setCategory($category)->withBudgetInformation()->withCategoryInformation();
'end' => $end->formatLocalized($this->monthAndDayFormat)] $collector->removeFilter(InternalTransferFilter::class);
); $journals = $collector->getPaginatedJournals();
Session::flash('info', trans('firefly.jump_back_in_time')); $journals->setPath(route('categories.show', [$category->id]));
}
return view('categories.show', compact('category', 'moment', 'journals', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); return view('categories.show', compact('category', 'moment', 'journals', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
} }

View File

@ -22,7 +22,6 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
use Navigation; use Navigation;
use Preferences; use Preferences;
use Session; use Session;
@ -217,8 +216,6 @@ class TagController extends Controller
$subTitleIcon = 'fa-tag'; $subTitleIcon = 'fa-tag';
$page = intval($request->get('page')); $page = intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data); $pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$count = 0;
$loop = 0;
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
$start = null; $start = null;
$end = null; $end = null;
@ -260,33 +257,14 @@ class TagController extends Controller
['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] ['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
); );
} }
// grab journals, but be prepared to jump a period back to get the right ones:
Log::info('Now at tag loop start.');
while ($count === 0 && $loop < 3) {
$loop++;
Log::info(sprintf('Count is zero, search for journals between %s and %s (pagesize %d, page %d).', $start, $end, $pageSize, $page));
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
->setTag($tag)->withBudgetInformation()->withCategoryInformation()->removeFilter(InternalTransferFilter::class);
$journals = $collector->getPaginatedJournals();
$journals->setPath($path);
$count = $journals->getCollection()->count();
if ($count === 0 && $loop < 3) {
$start->subDay();
$start = Navigation::startOfPeriod($start, $range);
$end = Navigation::endOfPeriod($start, $range);
Log::info(sprintf('Count is still zero, go back in time to "%s" and "%s"!', $start->format('Y-m-d'), $end->format('Y-m-d')));
}
}
if ($moment !== 'all' && $loop > 1) { /** @var JournalCollectorInterface $collector */
$subTitle = trans( $collector = app(JournalCollectorInterface::class);
'firefly.journals_in_period_for_tag', $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] ->setTag($tag)->withBudgetInformation()->withCategoryInformation()->removeFilter(InternalTransferFilter::class);
); $journals = $collector->getPaginatedJournals();
Session::flash('info', trans('firefly.jump_back_in_time')); $journals->setPath($path);
}
return view('tags.show', compact('apiKey', 'tag', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end', 'moment')); return view('tags.show', compact('apiKey', 'tag', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end', 'moment'));
} }

View File

@ -27,7 +27,6 @@ use Log;
use Navigation; use Navigation;
use Preferences; use Preferences;
use Response; use Response;
use Session;
use Steam; use Steam;
use View; use View;
@ -112,33 +111,14 @@ class TransactionController extends Controller
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
); );
} }
// grab journals, but be prepared to jump a period back to get the right ones:
Log::info('Now at transaction loop start.');
while ($count === 0 && $loop < 3) {
$loop++;
Log::info('Count is zero, search for journals.');
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($start, $end)->setTypes($types)->setLimit($pageSize)->setPage($page)->withOpposingAccount();
$collector->removeFilter(InternalTransferFilter::class);
$journals = $collector->getPaginatedJournals();
$journals->setPath($path);
$count = $journals->getCollection()->count();
if ($count === 0 && $loop < 3) {
$start->subDay();
$start = Navigation::startOfPeriod($start, $range);
$end = Navigation::endOfPeriod($start, $range);
Log::info(sprintf('Count is still zero, go back in time to "%s" and "%s"!', $start->format('Y-m-d'), $end->format('Y-m-d')));
}
}
if ($moment !== 'all' && $loop > 1) { /** @var JournalCollectorInterface $collector */
$subTitle = trans( $collector = app(JournalCollectorInterface::class);
'firefly.title_' . $what . '_between', $collector->setAllAssetAccounts()->setRange($start, $end)->setTypes($types)->setLimit($pageSize)->setPage($page)->withOpposingAccount();
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] $collector->removeFilter(InternalTransferFilter::class);
); $journals = $collector->getPaginatedJournals();
Session::flash('info', trans('firefly.jump_back_in_time')); $journals->setPath($path);
}
return view('transactions.index', compact('subTitle', 'what', 'subTitleIcon', 'journals', 'periods', 'start', 'end', 'moment')); return view('transactions.index', compact('subTitle', 'what', 'subTitleIcon', 'journals', 'periods', 'start', 'end', 'moment'));

View File

@ -29,6 +29,8 @@ class Amount implements ConverterInterface
* @param $value * @param $value
* *
* @return string * @return string
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
public function convert($value): string public function convert($value): string
{ {

View File

@ -145,7 +145,6 @@ return [
'exchange_rate_instructions' => 'Asset account "@name" only accepts transactions in @native_currency. If you wish to use @foreign_currency instead, make sure that the amount in @native_currency is known as well:', 'exchange_rate_instructions' => 'Asset account "@name" only accepts transactions in @native_currency. If you wish to use @foreign_currency instead, make sure that the amount in @native_currency is known as well:',
'transfer_exchange_rate_instructions' => 'Source asset account "@source_name" only accepts transactions in @source_currency. Destination asset account "@dest_name" only accepts transactions in @dest_currency. You must provide the transferred amount correctly in both currencies.', 'transfer_exchange_rate_instructions' => 'Source asset account "@source_name" only accepts transactions in @source_currency. Destination asset account "@dest_name" only accepts transactions in @dest_currency. You must provide the transferred amount correctly in both currencies.',
'transaction_data' => 'Transaction data', 'transaction_data' => 'Transaction data',
'jump_back_in_time' => 'The period you selected contains no transactions. Firefly III has skipped this empty period. The dates below may divert from what you have selected.',
// search // search
'search' => 'Search', 'search' => 'Search',