Various bugfixes and code clean up.

This commit is contained in:
James Cole
2018-07-27 04:46:21 +02:00
parent 2ad8e7f343
commit 0312ba8ad7
60 changed files with 223 additions and 353 deletions

View File

@@ -144,10 +144,13 @@ class ReconcileController extends Controller
// get start and end
if (null === $start && null === $end) {
/** @var Carbon $start */
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range));
/** @var Carbon $end */
$end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range));
}
if (null === $end) {
/** @var Carbon $end */
$end = app('navigation')->endOfPeriod($start, $range);
}

View File

@@ -90,7 +90,9 @@ class ShowController extends Controller
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
return $this->redirectToOriginalAccount($account);
}
/** @var Carbon $start */
$start = $start ?? session('start');
/** @var Carbon $end */
$end = $end ?? session('end');
if ($end < $start) {
throw new FireflyException('End is after start!'); // @codeCoverageIgnore

View File

@@ -101,7 +101,7 @@ class UpdateController extends Controller
{
$latestRelease = $this->getLatestRelease();
$versionCheck = $this->versionCheck($latestRelease);
$resultString = $this->parseResult($latestRelease, $versionCheck);
$resultString = $this->parseResult($versionCheck, $latestRelease);
if (0 !== $versionCheck && '' !== $resultString) {
// flash info

View File

@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Requests\BillFormRequest;
@@ -277,7 +278,9 @@ class BillController extends Controller
// add info about rules:
$rules = $this->billRepository->getRulesForBill($bill);
$subTitle = $bill->name;
/** @var Carbon $start */
$start = session('start');
/** @var Carbon $end */
$end = session('end');
$year = $start->year;
$page = (int)$request->get('page');

View File

@@ -77,6 +77,7 @@ class IndexController extends Controller
*/
public function index(Request $request, string $moment = null)
{
/** @var string $range */
$range = app('preferences')->get('viewRange', '1M')->data;
/** @var Carbon $start */
$start = session('start', new Carbon);

View File

@@ -195,6 +195,7 @@ class ShowController extends Controller
->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
$transactions = $collector->getPaginatedJournals();
$transactions->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
/** @var Carbon $start */
$start = session('first', Carbon::create()->startOfYear());
$end = new Carbon;
$limits = $this->getLimits($budget, $start, $end);

View File

@@ -74,7 +74,9 @@ class AccountController extends Controller
*/
public function expenseAccounts(AccountRepositoryInterface $repository): JsonResponse
{
/** @var Carbon $start */
$start = clone session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
$end = clone session('end', Carbon::now()->endOfMonth());
$cache = new CacheProperties;
$cache->addProperty($start);

View File

@@ -276,7 +276,7 @@ class DebugController extends Controller
{
$packages = [];
$file = \dirname(__DIR__, 3) . '/vendor/composer/installed.json';
if (!(false === $file) && file_exists($file)) {
if (file_exists($file)) {
// file exists!
$content = file_get_contents($file);
$json = json_decode($content, true);

View File

@@ -59,6 +59,7 @@ class HelpController extends Controller
*/
public function show(string $route): JsonResponse
{
/** @var string $language */
$language = app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;
$html = $this->getHelpText($route, $language);

View File

@@ -149,8 +149,11 @@ class JavascriptController extends Controller
private function getDateRangeConfig(): array
{
$viewRange = app('preferences')->get('viewRange', '1M')->data;
/** @var Carbon $start */
$start = session('start');
/** @var Carbon $end */
$end = session('end');
/** @var Carbon $first */
$first = session('first');
$title = sprintf('%s - %s', $start->formatLocalized($this->monthAndDayFormat), $end->formatLocalized($this->monthAndDayFormat));
$isCustom = true === session('is_custom_range', false);

View File

@@ -54,7 +54,9 @@ class BoxController extends Controller
*/
public function available(BudgetRepositoryInterface $repository): JsonResponse
{
/** @var Carbon $start */
$start = session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
$end = session('end', Carbon::now()->endOfMonth());
$today = new Carbon;
$cache = new CacheProperties;
@@ -111,7 +113,9 @@ class BoxController extends Controller
public function balance(CurrencyRepositoryInterface $repository): JsonResponse
{
// Cache result, return cache if present.
/** @var Carbon $start */
$start = session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
$end = session('end', Carbon::now()->endOfMonth());
$cache = new CacheProperties;
$cache->addProperty($start);
@@ -195,7 +199,9 @@ class BoxController extends Controller
*/
public function bills(BillRepositoryInterface $repository): JsonResponse
{
/** @var Carbon $start */
$start = session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
$end = session('end', Carbon::now()->endOfMonth());
$cache = new CacheProperties;

View File

@@ -161,7 +161,7 @@ class ReconcileController extends Controller
$currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currency) {
if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
}

View File

@@ -156,10 +156,10 @@ class RecurrenceController extends Controller
if ($date > $today || 'true' === (string)$request->get('past')) {
$weekly = sprintf('weekly,%s', $date->dayOfWeekIso);
$monthly = sprintf('monthly,%s', $date->day);
$dayOfWeek = trans(sprintf('config.dow_%s', $date->dayOfWeekIso));
$dayOfWeek = (string)trans(sprintf('config.dow_%s', $date->dayOfWeekIso));
$ndom = sprintf('ndom,%s,%s', $date->weekOfMonth, $date->dayOfWeekIso);
$yearly = sprintf('yearly,%s', $date->format('Y-m-d'));
$yearlyDate = $date->formatLocalized(trans('config.month_and_day_no_year'));
$yearlyDate = $date->formatLocalized((string)trans('config.month_and_day_no_year'));
$result = [
'daily' => ['label' => (string)trans('firefly.recurring_daily'), 'selected' => 0 === strpos($preSelected, 'daily')],
$weekly => ['label' => (string)trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]),

View File

@@ -95,19 +95,16 @@ class IndexController extends Controller
/**
* Show a single recurring transaction.
*
* @param Request $request
* @param Recurrence $recurrence
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws FireflyException
*/
public function show(Request $request, Recurrence $recurrence)
public function show(Recurrence $recurrence)
{
$transformer = new RecurrenceTransformer(new ParameterBag);
$array = $transformer->transform($recurrence);
$page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$transactions = $this->recurring->getTransactions($recurrence, $page, $pageSize);
$transactions = $this->recurring->getTransactions($recurrence);
// transform dates back to Carbon objects:
foreach ($array['recurrence_repetitions'] as $index => $repetition) {