Various code cleanup.

This commit is contained in:
James Cole
2018-08-04 17:30:06 +02:00
parent 5af026674f
commit f0d3ca5d53
88 changed files with 552 additions and 311 deletions

View File

@@ -84,7 +84,7 @@ class RecurrenceRequest extends Request
*/ */
public function rules(): array public function rules(): array
{ {
$today = Carbon::create()->addDay(); $today = Carbon::now()->addDay();
return [ return [
'type' => 'required|in:withdrawal,transfer,deposit', 'type' => 'required|in:withdrawal,transfer,deposit',

View File

@@ -25,6 +25,8 @@ namespace FireflyIII\Generator\Report\Account;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Report\ReportGeneratorInterface; use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
use Throwable;
/** /**
* Class MonthReportGenerator. * Class MonthReportGenerator.
@@ -44,7 +46,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
* Generate the report. * Generate the report.
* *
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@@ -52,11 +53,17 @@ class MonthReportGenerator implements ReportGeneratorInterface
$expenseIds = implode(',', $this->expense->pluck('id')->toArray()); $expenseIds = implode(',', $this->expense->pluck('id')->toArray());
$reportType = 'account'; $reportType = 'account';
$preferredPeriod = $this->preferredPeriod(); $preferredPeriod = $this->preferredPeriod();
try {
$result = view(
'reports.account.report',
compact('accountIds', 'reportType', 'expenseIds', 'preferredPeriod')
)->with('start', $this->start)->with('end', $this->end)->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
return view( return $result;
'reports.account.report',
compact('accountIds', 'reportType', 'expenseIds', 'preferredPeriod')
)->with('start', $this->start)->with('end', $this->end)->render();
} }
/** /**

View File

@@ -34,6 +34,8 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
use Throwable;
/** /**
* Class MonthReportGenerator. * Class MonthReportGenerator.
@@ -52,7 +54,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
* *
* @return string * @return string
* @throws FireflyException * @throws FireflyException
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@@ -78,10 +79,16 @@ class MonthReportGenerator implements ReportGeneratorInterface
'internal_reference', 'notes', 'internal_reference', 'notes',
'create_date', 'update_date', 'create_date', 'update_date',
]; ];
try {
$result = view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow'))
->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)
->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.audit.report: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
return view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow')) return $result;
->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)
->render();
} }
/** /**

View File

@@ -35,6 +35,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Throwable;
/** /**
* Class MonthReportGenerator. * Class MonthReportGenerator.
@@ -64,7 +65,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
* Generates the report. * Generates the report.
* *
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@@ -77,11 +77,17 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$topExpenses = $this->getTopExpenses(); $topExpenses = $this->getTopExpenses();
// render! // render!
return view('reports.budget.month', compact('accountIds', 'budgetIds', 'accountSummary', 'budgetSummary', 'averageExpenses', 'topExpenses')) try {
$result= view('reports.budget.month', compact('accountIds', 'budgetIds', 'accountSummary', 'budgetSummary', 'averageExpenses', 'topExpenses'))
->with('start', $this->start)->with('end', $this->end) ->with('start', $this->start)->with('end', $this->end)
->with('budgets', $this->budgets) ->with('budgets', $this->budgets)
->with('accounts', $this->accounts) ->with('accounts', $this->accounts)
->render(); ->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
return $result;
} }
/** /**

View File

@@ -36,6 +36,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Throwable;
/** /**
* Class MonthReportGenerator. * Class MonthReportGenerator.
@@ -68,7 +69,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
* Generates the report. * Generates the report.
* *
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@@ -85,24 +85,23 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$topIncome = $this->getTopIncome(); $topIncome = $this->getTopIncome();
// render! // render!
return view( try {
'reports.category.month', return view(
compact( 'reports.category.month', compact(
'accountIds', 'accountIds', 'categoryIds', 'topIncome', 'reportType', 'accountSummary', 'categorySummary', 'averageExpenses',
'categoryIds', 'averageIncome', 'topExpenses'
'topIncome', )
'reportType',
'accountSummary',
'categorySummary',
'averageExpenses',
'averageIncome',
'topExpenses'
) )
) ->with('start', $this->start)->with('end', $this->end)
->with('start', $this->start)->with('end', $this->end) ->with('categories', $this->categories)
->with('categories', $this->categories) ->with('accounts', $this->accounts)
->with('accounts', $this->accounts) ->render();
->render(); } catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.category.month: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
return $result;
} }
/** /**

View File

@@ -26,6 +26,8 @@ use Carbon\Carbon;
use FireflyIII\Generator\Report\ReportGeneratorInterface; use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Helpers\Report\ReportHelperInterface; use FireflyIII\Helpers\Report\ReportHelperInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
use Throwable;
/** /**
* Class MonthReportGenerator. * Class MonthReportGenerator.
@@ -43,7 +45,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
* Generates the report. * Generates the report.
* *
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@@ -53,11 +54,17 @@ class MonthReportGenerator implements ReportGeneratorInterface
$accountIds = implode(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default'; $reportType = 'default';
// continue! try {
return view( return view(
'reports.default.month', 'reports.default.month',
compact('bills', 'accountIds', 'reportType') compact('bills', 'accountIds', 'reportType')
)->with('start', $this->start)->with('end', $this->end)->render(); )->with('start', $this->start)->with('end', $this->end)->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
return $result;
} }
/** /**

View File

@@ -25,6 +25,8 @@ namespace FireflyIII\Generator\Report\Standard;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Report\ReportGeneratorInterface; use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
use Throwable;
/** /**
* Class MonthReportGenerator. * Class MonthReportGenerator.
@@ -42,7 +44,6 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
* Generates the report. * Generates the report.
* *
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@@ -50,11 +51,17 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
$accountIds = implode(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default'; $reportType = 'default';
// continue! try {
return view( return view(
'reports.default.multi-year', 'reports.default.multi-year',
compact('accountIds', 'reportType') compact('accountIds', 'reportType')
)->with('start', $this->start)->with('end', $this->end)->render(); )->with('start', $this->start)->with('end', $this->end)->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
return $result;
} }
/** /**

View File

@@ -25,6 +25,8 @@ namespace FireflyIII\Generator\Report\Standard;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Report\ReportGeneratorInterface; use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
use Throwable;
/** /**
* Class MonthReportGenerator. * Class MonthReportGenerator.
@@ -42,7 +44,6 @@ class YearReportGenerator implements ReportGeneratorInterface
* Generates the report. * Generates the report.
* *
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@@ -50,13 +51,20 @@ class YearReportGenerator implements ReportGeneratorInterface
$accountIds = implode(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default'; $reportType = 'default';
// continue! try {
return view( $result = view(
'reports.default.year', 'reports.default.year',
compact('accountIds', 'reportType') compact('accountIds', 'reportType')
)->with('start', $this->start)->with('end', $this->end)->render(); )->with('start', $this->start)->with('end', $this->end)->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
return $result;
} }
/** /**
* Set the accounts. * Set the accounts.
* *

View File

@@ -38,6 +38,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Throwable;
/** /**
* Class MonthReportGenerator. * Class MonthReportGenerator.
@@ -70,7 +71,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
* Generate the report. * Generate the report.
* *
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@@ -87,20 +87,18 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$topIncome = $this->getTopIncome(); $topIncome = $this->getTopIncome();
// render! // render!
return view( try {
'reports.tag.month', $result = view(
compact( 'reports.tag.month', compact(
'accountIds', 'accountIds', 'tagTags', 'reportType', 'accountSummary', 'tagSummary', 'averageExpenses', 'averageIncome', 'topIncome', 'topExpenses'
'tagTags',
'reportType',
'accountSummary',
'tagSummary',
'averageExpenses',
'averageIncome',
'topIncome',
'topExpenses'
) )
)->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render(); )->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
return $result;
} }
/** /**

View File

@@ -142,7 +142,7 @@ class ShowController extends Controller
public function show(Request $request, Budget $budget) public function show(Request $request, Budget $budget)
{ {
/** @var Carbon $start */ /** @var Carbon $start */
$start = session('first', Carbon::create()->startOfYear()); $start = session('first', Carbon::now()->startOfYear());
$end = new Carbon; $end = new Carbon;
$page = (int)$request->get('page'); $page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
@@ -196,7 +196,7 @@ class ShowController extends Controller
$transactions = $collector->getPaginatedJournals(); $transactions = $collector->getPaginatedJournals();
$transactions->setPath(route('budgets.show', [$budget->id, $budgetLimit->id])); $transactions->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
/** @var Carbon $start */ /** @var Carbon $start */
$start = session('first', Carbon::create()->startOfYear()); $start = session('first', Carbon::now()->startOfYear());
$end = new Carbon; $end = new Carbon;
$limits = $this->getLimits($budget, $start, $end); $limits = $this->getLimits($budget, $start, $end);

View File

@@ -90,9 +90,9 @@ class ShowController extends Controller
{ {
Log::debug('Now in show()'); Log::debug('Now in show()');
/** @var Carbon $start */ /** @var Carbon $start */
$start = $start ?? session('start', Carbon::create()->startOfMonth()); $start = $start ?? session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */ /** @var Carbon $end */
$end = $end ?? session('end', Carbon::create()->startOfMonth()); $end = $end ?? session('end', Carbon::now()->startOfMonth());
$subTitleIcon = 'fa-bar-chart'; $subTitleIcon = 'fa-bar-chart';
$moment = ''; $moment = '';
$page = (int)$request->get('page'); $page = (int)$request->get('page');

View File

@@ -120,7 +120,7 @@ class DebugController extends Controller
$phpVersion = str_replace($search, $replace, PHP_VERSION); $phpVersion = str_replace($search, $replace, PHP_VERSION);
$phpOs = str_replace($search, $replace, PHP_OS); $phpOs = str_replace($search, $replace, PHP_OS);
$interface = PHP_SAPI; $interface = PHP_SAPI;
$now = Carbon::create()->format('Y-m-d H:i:s e'); $now = Carbon::now()->format('Y-m-d H:i:s e');
$extensions = implode(', ', get_loaded_extensions()); $extensions = implode(', ', get_loaded_extensions());
$drivers = implode(', ', DB::availableDrivers()); $drivers = implode(', ', DB::availableDrivers());
$currentDriver = DB::getDriverName(); $currentDriver = DB::getDriverName();

View File

@@ -125,7 +125,7 @@ class ExportController extends Controller
$formats = array_keys(config('firefly.export_formats')); $formats = array_keys(config('firefly.export_formats'));
$defaultFormat = app('preferences')->get('export_format', config('firefly.default_export_format'))->data; $defaultFormat = app('preferences')->get('export_format', config('firefly.default_export_format'))->data;
$first = session('first')->format('Y-m-d'); $first = session('first')->format('Y-m-d');
$today = Carbon::create()->format('Y-m-d'); $today = Carbon::now()->format('Y-m-d');
return view('export.index', compact('job', 'formats', 'defaultFormat', 'first', 'today')); return view('export.index', compact('job', 'formats', 'defaultFormat', 'first', 'today'));
} }

View File

@@ -36,6 +36,8 @@ class CallbackController extends Controller
{ {
/** /**
* Callback specifically for YNAB logins.
*
* @param Request $request * @param Request $request
* *
* @param ImportJobRepositoryInterface $repository * @param ImportJobRepositoryInterface $repository

View File

@@ -37,7 +37,7 @@ use Log;
*/ */
class IndexController extends Controller class IndexController extends Controller
{ {
/** @var array */ /** @var array All available providers */
public $providers; public $providers;
/** @var ImportJobRepositoryInterface The import job repository */ /** @var ImportJobRepositoryInterface The import job repository */
public $repository; public $repository;

View File

@@ -26,6 +26,8 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBank;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Log;
use Throwable;
/** /**
* Class FrontpageController. * Class FrontpageController.
@@ -38,7 +40,6 @@ class FrontpageController extends Controller
* @param PiggyBankRepositoryInterface $repository * @param PiggyBankRepositoryInterface $repository
* *
* @return JsonResponse * @return JsonResponse
* @throws \Throwable
*/ */
public function piggyBanks(PiggyBankRepositoryInterface $repository): JsonResponse public function piggyBanks(PiggyBankRepositoryInterface $repository): JsonResponse
{ {
@@ -64,7 +65,12 @@ class FrontpageController extends Controller
} }
$html = ''; $html = '';
if (\count($info) > 0) { if (\count($info) > 0) {
$html = view('json.piggy-banks', compact('info'))->render(); try {
$html = view('json.piggy-banks', compact('info'))->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render json.piggy-banks: %s', $e->getMessage()));
$html = 'Could not render view.';
}
} }
return response()->json(['html' => $html]); return response()->json(['html' => $html]);

View File

@@ -24,6 +24,8 @@ namespace FireflyIII\Http\Controllers;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Log;
use Throwable;
/** /**
* Class JsonController. * Class JsonController.
@@ -36,7 +38,6 @@ class JsonController extends Controller
* @param Request $request * @param Request $request
* *
* @return JsonResponse * @return JsonResponse
* @throws \Throwable
*/ */
public function action(Request $request): JsonResponse public function action(Request $request): JsonResponse
{ {
@@ -46,7 +47,12 @@ class JsonController extends Controller
foreach ($keys as $key) { foreach ($keys as $key) {
$actions[$key] = (string)trans('firefly.rule_action_' . $key . '_choice'); $actions[$key] = (string)trans('firefly.rule_action_' . $key . '_choice');
} }
$view = view('rules.partials.action', compact('actions', 'count'))->render(); try {
$view = view('rules.partials.action', compact('actions', 'count'))->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render rules.partials.action: %s', $e->getMessage()));
$view = 'Could not render view.';
}
return response()->json(['html' => $view]); return response()->json(['html' => $view]);
} }
@@ -57,7 +63,6 @@ class JsonController extends Controller
* @param Request $request * @param Request $request
* *
* @return JsonResponse * @return JsonResponse
* @throws \Throwable
*/ */
public function trigger(Request $request): JsonResponse public function trigger(Request $request): JsonResponse
{ {
@@ -71,7 +76,12 @@ class JsonController extends Controller
} }
asort($triggers); asort($triggers);
$view = view('rules.partials.trigger', compact('triggers', 'count'))->render(); try {
$view = view('rules.partials.trigger', compact('triggers', 'count'))->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render rules.partials.trigger: %s', $e->getMessage()));
$view = 'Could not render view.';
}
return response()->json(['html' => $view]); return response()->json(['html' => $view]);
} }

View File

@@ -274,7 +274,7 @@ class ReportController extends Controller
$attributes['startDate'] = Carbon::createFromFormat('Ymd', $attributes['startDate']); $attributes['startDate'] = Carbon::createFromFormat('Ymd', $attributes['startDate']);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
Log::debug(sprintf('Not important error message: %s', $e->getMessage())); Log::debug(sprintf('Not important error message: %s', $e->getMessage()));
$date = Carbon::create()->startOfMonth(); $date = Carbon::now()->startOfMonth();
$attributes['startDate'] = $date; $attributes['startDate'] = $date;
} }
@@ -282,7 +282,7 @@ class ReportController extends Controller
$attributes['endDate'] = Carbon::createFromFormat('Ymd', $attributes['endDate']); $attributes['endDate'] = Carbon::createFromFormat('Ymd', $attributes['endDate']);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
Log::debug(sprintf('Not important error message: %s', $e->getMessage())); Log::debug(sprintf('Not important error message: %s', $e->getMessage()));
$date = Carbon::create()->startOfMonth(); $date = Carbon::now()->startOfMonth();
$attributes['endDate'] = $date; $attributes['endDate'] = $date;
} }

View File

@@ -38,7 +38,7 @@ class OperationsController extends Controller
private $tasker; private $tasker;
/** /**
* * OperationsController constructor.
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -36,6 +36,7 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Throwable;
/** /**
* Class ReportController. * Class ReportController.
@@ -277,7 +278,6 @@ class ReportController extends Controller
* *
* @return mixed * @return mixed
* @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @throws \Throwable
*/ */
public function options(string $reportType) public function options(string $reportType)
{ {
@@ -391,7 +391,6 @@ class ReportController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string
*
* @throws \FireflyIII\Exceptions\FireflyException * @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end) public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
@@ -423,7 +422,6 @@ class ReportController extends Controller
* Get options for account report. * Get options for account report.
* *
* @return string * @return string
* @throws \Throwable
*/ */
private function accountReportOptions(): string private function accountReportOptions(): string
{ {
@@ -438,52 +436,77 @@ class ReportController extends Controller
$set->push($exp); $set->push($exp);
} }
} }
try {
$result = view('reports.options.account', compact('set'))->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));
$result = 'Could not render view.';
}
return view('reports.options.account', compact('set'))->render(); return $result;
} }
/** /**
* Get options for budget report. * Get options for budget report.
*
* @return string * @return string
* @throws \Throwable
*/ */
private function budgetReportOptions(): string private function budgetReportOptions(): string
{ {
/** @var BudgetRepositoryInterface $repository */ /** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class); $repository = app(BudgetRepositoryInterface::class);
$budgets = $repository->getBudgets(); $budgets = $repository->getBudgets();
try {
$result = view('reports.options.budget', compact('budgets'))->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));
$result = 'Could not render view.';
}
return view('reports.options.budget', compact('budgets'))->render(); return $result;
} }
/** /**
* Get options for category report. * Get options for category report.
*
* @return string * @return string
* @throws \Throwable
*/ */
private function categoryReportOptions(): string private function categoryReportOptions(): string
{ {
/** @var CategoryRepositoryInterface $repository */ /** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class); $repository = app(CategoryRepositoryInterface::class);
$categories = $repository->getCategories(); $categories = $repository->getCategories();
try {
$result = view('reports.options.category', compact('categories'))->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.options.category: %s', $e->getMessage()));
$result = 'Could not render view.';
}
return view('reports.options.category', compact('categories'))->render(); return $result;
} }
/** /**
* Get options for default report. * Get options for default report.
*
* @return string * @return string
* @throws \Throwable
*/ */
private function noReportOptions(): string private function noReportOptions(): string
{ {
return view('reports.options.no-options')->render(); try {
$result = view('reports.options.no-options')->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.options.no-options: %s', $e->getMessage()));
$result = 'Could not render view.';
}
return $result;
} }
/** /**
* Get options for tag report. * Get options for tag report.
*
* @return string * @return string
* @throws \Throwable
*/ */
private function tagReportOptions(): string private function tagReportOptions(): string
{ {
@@ -494,7 +517,13 @@ class ReportController extends Controller
return $tag->tag; return $tag->tag;
} }
); );
try {
$result = view('reports.options.tag', compact('tags'))->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));
$result = 'Could not render view.';
}
return view('reports.options.tag', compact('tags'))->render(); return $result;
} }
} }

View File

@@ -118,7 +118,7 @@ class SelectController extends Controller
{ {
// does the user have shared accounts? // does the user have shared accounts?
$first = session('first')->format('Y-m-d'); $first = session('first')->format('Y-m-d');
$today = Carbon::create()->format('Y-m-d'); $today = Carbon::now()->format('Y-m-d');
$subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]); $subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);
return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle')); return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));

View File

@@ -208,7 +208,7 @@ class RuleGroupController extends Controller
public function selectTransactions(RuleGroup $ruleGroup) public function selectTransactions(RuleGroup $ruleGroup)
{ {
$first = session('first')->format('Y-m-d'); $first = session('first')->format('Y-m-d');
$today = Carbon::create()->format('Y-m-d'); $today = Carbon::now()->format('Y-m-d');
$subTitle = (string)trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]); $subTitle = (string)trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);
return view('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle')); return view('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle'));

View File

@@ -27,6 +27,8 @@ use FireflyIII\Support\Search\SearchInterface;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
use Throwable;
/** /**
* Class SearchController. * Class SearchController.
@@ -77,7 +79,6 @@ class SearchController extends Controller
* @param SearchInterface $searcher * @param SearchInterface $searcher
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* @throws \Throwable
*/ */
public function search(Request $request, SearchInterface $searcher): JsonResponse public function search(Request $request, SearchInterface $searcher): JsonResponse
{ {
@@ -99,8 +100,12 @@ class SearchController extends Controller
$transactions = $searcher->searchTransactions(); $transactions = $searcher->searchTransactions();
$cache->store($transactions); $cache->store($transactions);
} }
try {
$html = view('search.search', compact('transactions'))->render(); $html = view('search.search', compact('transactions'))->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render search.search: %s', $e->getMessage()));
$html = 'Could not render view.';
}
return response()->json(['count' => $transactions->count(), 'html' => $html]); return response()->json(['count' => $transactions->count(), 'html' => $html]);
} }

View File

@@ -262,7 +262,7 @@ class TransactionController extends Controller
{ {
$range = app('preferences')->get('viewRange', '1M')->data; $range = app('preferences')->get('viewRange', '1M')->data;
$first = $this->repository->firstNull(); $first = $this->repository->firstNull();
$start = Carbon::create()->subYear(); $start = Carbon::now()->subYear();
$types = config('firefly.transactionTypesByWhat.' . $what); $types = config('firefly.transactionTypesByWhat.' . $what);
$entries = new Collection; $entries = new Collection;
if (null !== $first) { if (null !== $first) {

View File

@@ -48,7 +48,7 @@ class AccountFormRequest extends Request
*/ */
public function getAccountData(): array public function getAccountData(): array
{ {
return [ $data = [
'name' => $this->string('name'), 'name' => $this->string('name'),
'active' => $this->boolean('active'), 'active' => $this->boolean('active'),
'accountType' => $this->string('what'), 'accountType' => $this->string('what'),
@@ -64,7 +64,22 @@ class AccountFormRequest extends Request
'ccType' => $this->string('ccType'), 'ccType' => $this->string('ccType'),
'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'), 'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'),
'notes' => $this->string('notes'), 'notes' => $this->string('notes'),
'interest' => $this->string('interest'),
'interest_period' => $this->string('interest_period'),
]; ];
// if the account type is "liabilities" there are actually four types of liability
// that could have been selected.
if ($data['accountType'] === 'liabilities') {
$data['accountType'] = null;
$data['account_type_id'] = $this->integer('liability_type_id');
// also reverse the opening balance:
if ('' !== $data['openingBalance']) {
$data['openingBalance'] = bcmul($data['openingBalance'], '-1');
}
}
return $data;
} }
/** /**
@@ -93,8 +108,14 @@ class AccountFormRequest extends Request
'amount_currency_id_openingBalance' => 'exists:transaction_currencies,id', 'amount_currency_id_openingBalance' => 'exists:transaction_currencies,id',
'amount_currency_id_virtualBalance' => 'exists:transaction_currencies,id', 'amount_currency_id_virtualBalance' => 'exists:transaction_currencies,id',
'what' => 'in:' . $types, 'what' => 'in:' . $types,
'interest_period' => 'in:daily,monthly,yearly',
]; ];
if ('liabilities' === $this->get('what')) {
$rules['openingBalance'] = 'numeric|required|more:0';
$rules['openingBalanceDate'] = 'date|required';
}
/** @var Account $account */ /** @var Account $account */
$account = $this->route()->parameter('account'); $account = $this->route()->parameter('account');
if (null !== $account) { if (null !== $account) {

View File

@@ -50,7 +50,7 @@ class ExportFormRequest extends Request
/** @var Carbon $sessionFirst */ /** @var Carbon $sessionFirst */
$sessionFirst = clone session('first'); $sessionFirst = clone session('first');
$first = $sessionFirst->subDay()->format('Y-m-d'); $first = $sessionFirst->subDay()->format('Y-m-d');
$today = Carbon::create()->addDay()->format('Y-m-d'); $today = Carbon::now()->addDay()->format('Y-m-d');
$formats = implode(',', array_keys(config('firefly.export_formats'))); $formats = implode(',', array_keys(config('firefly.export_formats')));
// fixed // fixed

View File

@@ -149,7 +149,7 @@ class RecurrenceFormRequest extends Request
public function rules(): array public function rules(): array
{ {
$today = new Carbon; $today = new Carbon;
$tomorrow = Carbon::create()->addDay(); $tomorrow = Carbon::now()->addDay();
$rules = [ $rules = [
// mandatory info for recurrence. // mandatory info for recurrence.
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title', 'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',

View File

@@ -53,7 +53,7 @@ class SelectTransactionsRequest extends Request
/** @var Carbon $sessionFirst */ /** @var Carbon $sessionFirst */
$sessionFirst = clone session('first'); $sessionFirst = clone session('first');
$first = $sessionFirst->subDay()->format('Y-m-d'); $first = $sessionFirst->subDay()->format('Y-m-d');
$today = Carbon::create()->addDay()->format('Y-m-d'); $today = Carbon::now()->addDay()->format('Y-m-d');
return [ return [
'start_date' => 'required|date|after:' . $first, 'start_date' => 'required|date|after:' . $first,

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Import\Storage;
use Carbon\Carbon; use Carbon\Carbon;
use DB; use DB;
use FireflyIII\Events\RequestedReportOnJournals;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter; use FireflyIII\Helpers\Filter\InternalTransferFilter;
@@ -114,6 +115,9 @@ class ImportArrayStorage
app('preferences')->mark(); app('preferences')->mark();
// email about this:
event(new RequestedReportOnJournals($this->importJob->user_id, $collection));
return $collection; return $collection;
} }

View File

@@ -75,18 +75,20 @@ class Account extends Model
'active' => 'boolean', 'active' => 'boolean',
'encrypted' => 'boolean', 'encrypted' => 'boolean',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban']; protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
/** @var array */ /** @var array Hidden from view */
protected $hidden = ['encrypted']; protected $hidden = ['encrypted'];
/** @var bool */ /** @var bool */
private $joinedAccountTypes; private $joinedAccountTypes;
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return Account * @return Account
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): Account public static function routeBinder(string $value): Account
{ {

View File

@@ -44,11 +44,9 @@ class AccountMeta extends Model
'created_at' => 'datetime', 'created_at' => 'datetime',
'updated_at' => 'datetime', 'updated_at' => 'datetime',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['account_id', 'name', 'data']; protected $fillable = ['account_id', 'name', 'data'];
/** /** @var string The table to store the data in */
* @var string
*/
protected $table = 'account_meta'; protected $table = 'account_meta';
/** /**

View File

@@ -35,25 +35,43 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
*/ */
class AccountType extends Model class AccountType extends Model
{ {
/** @var string */
public const DEFAULT = 'Default account'; public const DEFAULT = 'Default account';
/** @var string */
public const CASH = 'Cash account'; public const CASH = 'Cash account';
/** @var string */
public const ASSET = 'Asset account'; public const ASSET = 'Asset account';
/** @var string */
public const EXPENSE = 'Expense account'; public const EXPENSE = 'Expense account';
/** @var string */
public const REVENUE = 'Revenue account'; public const REVENUE = 'Revenue account';
/** @var string */
public const INITIAL_BALANCE = 'Initial balance account'; public const INITIAL_BALANCE = 'Initial balance account';
/** @var string */
public const BENEFICIARY = 'Beneficiary account'; public const BENEFICIARY = 'Beneficiary account';
/** @var string */
public const IMPORT = 'Import account'; public const IMPORT = 'Import account';
/** @var string */
public const RECONCILIATION = 'Reconciliation account'; public const RECONCILIATION = 'Reconciliation account';
/** @var string */
public const LOAN = 'Loan'; public const LOAN = 'Loan';
/** @var string */
public const DEBT = 'Debt'; public const DEBT = 'Debt';
/** @var string */
public const MORTGAGE = 'Mortgage'; public const MORTGAGE = 'Mortgage';
/** @var string */
public const CREDITCARD = 'Credit card'; public const CREDITCARD = 'Credit card';
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts protected $casts
= [ = [
'created_at' => 'datetime', 'created_at' => 'datetime',
'updated_at' => 'datetime', 'updated_at' => 'datetime',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['type']; protected $fillable = ['type'];
/** /**

View File

@@ -66,14 +66,16 @@ class Attachment extends Model
'deleted_at' => 'datetime', 'deleted_at' => 'datetime',
'uploaded' => 'boolean', 'uploaded' => 'boolean',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['attachable_id', 'attachable_type', 'user_id', 'md5', 'filename', 'mime', 'title', 'description', 'size', 'uploaded']; protected $fillable = ['attachable_id', 'attachable_type', 'user_id', 'md5', 'filename', 'mime', 'title', 'description', 'size', 'uploaded'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return Attachment * @return Attachment
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): Attachment public static function routeBinder(string $value): Attachment
{ {

View File

@@ -58,14 +58,16 @@ class AvailableBudget extends Model
'start_date' => 'date', 'start_date' => 'date',
'end_date' => 'date', 'end_date' => 'date',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['user_id', 'transaction_currency_id', 'amount', 'start_date', 'end_date']; protected $fillable = ['user_id', 'transaction_currency_id', 'amount', 'start_date', 'end_date'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return AvailableBudget * @return AvailableBudget
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): AvailableBudget public static function routeBinder(string $value): AvailableBudget
{ {
@@ -84,7 +86,7 @@ class AvailableBudget extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function transactionCurrency(): BelongsTo public function transactionCurrency(): BelongsTo
{ {

View File

@@ -77,22 +77,21 @@ class Bill extends Model
'name_encrypted' => 'boolean', 'name_encrypted' => 'boolean',
'match_encrypted' => 'boolean', 'match_encrypted' => 'boolean',
]; ];
/**
* @var array /** @var array Fields that can be filled */
*/
protected $fillable protected $fillable
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', = ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
'automatch', 'active', 'transaction_currency_id']; 'automatch', 'active', 'transaction_currency_id'];
/** /** @var array Hidden from view */
* @var array
*/
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted']; protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return Bill * @return Bill
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): Bill public static function routeBinder(string $value): Bill
{ {

View File

@@ -26,6 +26,8 @@ use Crypt;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -58,16 +60,18 @@ class Budget extends Model
'active' => 'boolean', 'active' => 'boolean',
'encrypted' => 'boolean', 'encrypted' => 'boolean',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['user_id', 'name', 'active']; protected $fillable = ['user_id', 'name', 'active'];
/** @var array */ /** @var array Hidden from view */
protected $hidden = ['encrypted']; protected $hidden = ['encrypted'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return Budget * @return Budget
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): Budget public static function routeBinder(string $value): Budget
{ {
@@ -86,9 +90,9 @@ class Budget extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function budgetlimits(): \Illuminate\Database\Eloquent\Relations\HasMany public function budgetlimits(): HasMany
{ {
return $this->hasMany(BudgetLimit::class); return $this->hasMany(BudgetLimit::class);
} }
@@ -126,18 +130,18 @@ class Budget extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\BelongsToMany public function transactionJournals(): BelongsToMany
{ {
return $this->belongsToMany(TransactionJournal::class, 'budget_transaction_journal', 'budget_id'); return $this->belongsToMany(TransactionJournal::class, 'budget_transaction_journal', 'budget_id');
} }
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function transactions(): \Illuminate\Database\Eloquent\Relations\BelongsToMany public function transactions(): BelongsToMany
{ {
return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id'); return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id');
} }

View File

@@ -54,13 +54,17 @@ class BudgetLimit extends Model
'start_date' => 'date', 'start_date' => 'date',
'end_date' => 'date', 'end_date' => 'date',
]; ];
/** @var array Fields that can be filled */
protected $fillable = ['budget_id', 'start_date', 'end_date', 'amount']; protected $fillable = ['budget_id', 'start_date', 'end_date', 'amount'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return mixed * @return mixed
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): BudgetLimit public static function routeBinder(string $value): BudgetLimit
{ {

View File

@@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Models; namespace FireflyIII\Models;
@@ -27,6 +28,7 @@ use Crypt;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -55,16 +57,18 @@ class Category extends Model
'deleted_at' => 'datetime', 'deleted_at' => 'datetime',
'encrypted' => 'boolean', 'encrypted' => 'boolean',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['user_id', 'name']; protected $fillable = ['user_id', 'name'];
/** @var array */ /** @var array Hidden from view */
protected $hidden = ['encrypted']; protected $hidden = ['encrypted'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return Category * @return Category
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): Category public static function routeBinder(string $value): Category
{ {
@@ -114,18 +118,18 @@ class Category extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\BelongsToMany public function transactionJournals(): BelongsToMany
{ {
return $this->belongsToMany(TransactionJournal::class, 'category_transaction_journal', 'category_id'); return $this->belongsToMany(TransactionJournal::class, 'category_transaction_journal', 'category_id');
} }
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function transactions(): \Illuminate\Database\Eloquent\Relations\BelongsToMany public function transactions(): BelongsToMany
{ {
return $this->belongsToMany(Transaction::class, 'category_transaction', 'category_id'); return $this->belongsToMany(Transaction::class, 'category_transaction', 'category_id');
} }

View File

@@ -44,10 +44,9 @@ class Configuration extends Model
= [ = [
'created_at' => 'datetime', 'created_at' => 'datetime',
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'deleted_at' => 'datetime',
]; ];
/** /** @var string The table to store the data in */
* @var string
*/
protected $table = 'configuration'; protected $table = 'configuration';
/** /**

View File

@@ -43,8 +43,16 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
*/ */
class CurrencyExchangeRate extends Model class CurrencyExchangeRate extends Model
{ {
/** @var array */ /** @var array Convert these fields to other data types */
protected $dates = ['date']; protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'user_id' => 'int',
'from_currency_id' => 'int',
'to_currency_id' => 'int',
'date' => 'datetime',
];
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
@@ -37,7 +38,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/ */
class ExportJob extends Model class ExportJob extends Model
{ {
/** @var array */ /**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts protected $casts
= [ = [
'created_at' => 'datetime', 'created_at' => 'datetime',
@@ -45,6 +50,8 @@ class ExportJob extends Model
]; ];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return ExportJob * @return ExportJob
@@ -67,9 +74,12 @@ class ExportJob extends Model
} }
/** /**
* @codeCoverageIgnore * Change the status of this export job.
* *
* @param $status * @param $status
*
* @deprecated
* @codeCoverageIgnore
*/ */
public function change($status): void public function change($status): void
{ {
@@ -78,10 +88,13 @@ class ExportJob extends Model
} }
/** /**
* Returns the user this objects belongs to.
*
*
* @return BelongsTo
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function user(): BelongsTo
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);
} }

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
@@ -61,10 +62,12 @@ class ImportJob extends Model
'transactions' => 'array', 'transactions' => 'array',
'errors' => 'array', 'errors' => 'array',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['key', 'user_id', 'file_type', 'provider', 'status', 'stage', 'configuration', 'extended_status', 'transactions', 'errors']; protected $fillable = ['key', 'user_id', 'file_type', 'provider', 'status', 'stage', 'configuration', 'extended_status', 'transactions', 'errors'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param $value * @param $value
* *
* @return mixed * @return mixed
@@ -97,18 +100,18 @@ class ImportJob extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function tag(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function tag(): BelongsTo
{ {
return $this->belongsTo(Tag::class); return $this->belongsTo(Tag::class);
} }
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function user(): BelongsTo
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);
} }

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -55,10 +56,12 @@ class LinkType extends Model
'editable' => 'boolean', 'editable' => 'boolean',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['name', 'inward', 'outward', 'editable']; protected $fillable = ['name', 'inward', 'outward', 'editable'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param $value * @param $value
* *
* @return LinkType * @return LinkType
@@ -79,9 +82,9 @@ class LinkType extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function transactionJournalLinks(): \Illuminate\Database\Eloquent\Relations\HasMany public function transactionJournalLinks(): HasMany
{ {
return $this->hasMany(TransactionJournalLink::class); return $this->hasMany(TransactionJournalLink::class);
} }

View File

@@ -51,7 +51,7 @@ class Note extends Model
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'deleted_at' => 'datetime', 'deleted_at' => 'datetime',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['title', 'text', 'noteable_id', 'noteable_type']; protected $fillable = ['title', 'text', 'noteable_id', 'noteable_type'];
/** /**

View File

@@ -26,6 +26,7 @@ use Carbon\Carbon;
use Crypt; use Crypt;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -67,18 +68,18 @@ class PiggyBank extends Model
'active' => 'boolean', 'active' => 'boolean',
'encrypted' => 'boolean', 'encrypted' => 'boolean',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $dates = ['startdate', 'targetdate'];
/** @var array */
protected $fillable = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate', 'active']; protected $fillable = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate', 'active'];
/** @var array */ /** @var array Hidden from view */
protected $hidden = ['targetamount_encrypted', 'encrypted']; protected $hidden = ['targetamount_encrypted', 'encrypted'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return PiggyBank * @return PiggyBank
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): PiggyBank public static function routeBinder(string $value): PiggyBank
{ {
@@ -96,7 +97,7 @@ class PiggyBank extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function account(): BelongsTo public function account(): BelongsTo
{ {
@@ -131,18 +132,18 @@ class PiggyBank extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function piggyBankEvents(): \Illuminate\Database\Eloquent\Relations\HasMany public function piggyBankEvents(): HasMany
{ {
return $this->hasMany(PiggyBankEvent::class); return $this->hasMany(PiggyBankEvent::class);
} }
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function piggyBankRepetitions(): \Illuminate\Database\Eloquent\Relations\HasMany public function piggyBankRepetitions(): HasMany
{ {
return $this->hasMany(PiggyBankRepetition::class); return $this->hasMany(PiggyBankRepetition::class);
} }

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/** /**
* Class PiggyBankEvent. * Class PiggyBankEvent.
@@ -47,22 +48,16 @@ class PiggyBankEvent extends Model
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'date' => 'date', 'date' => 'date',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $dates = ['date'];
/**
* @var array
*/
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount']; protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
/** /** @var array Hidden from view */
* @var array
*/
protected $hidden = ['amount_encrypted']; protected $hidden = ['amount_encrypted'];
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function piggyBank(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function piggyBank(): BelongsTo
{ {
return $this->belongsTo(PiggyBank::class); return $this->belongsTo(PiggyBank::class);
} }
@@ -79,9 +74,9 @@ class PiggyBankEvent extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function transactionJournal(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function transactionJournal(): BelongsTo
{ {
return $this->belongsTo(TransactionJournal::class); return $this->belongsTo(TransactionJournal::class);
} }

View File

@@ -25,6 +25,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/** /**
* Class PiggyBankRepetition. * Class PiggyBankRepetition.
@@ -44,20 +45,17 @@ class PiggyBankRepetition extends Model
= [ = [
'created_at' => 'datetime', 'created_at' => 'datetime',
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'deleted_at' => 'datetime',
'startdate' => 'date', 'startdate' => 'date',
'targetdate' => 'date', 'targetdate' => 'date',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $dates = ['startdate', 'targetdate'];
/** @var array */
protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount']; protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function piggyBank(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function piggyBank(): BelongsTo
{ {
return $this->belongsTo(PiggyBank::class); return $this->belongsTo(PiggyBank::class);
} }

View File

@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Log; use Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -55,14 +56,16 @@ class Preference extends Model
'updated_at' => 'datetime', 'updated_at' => 'datetime',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['user_id', 'data', 'name']; protected $fillable = ['user_id', 'data', 'name'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return Preference * @return Preference
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): Preference public static function routeBinder(string $value): Preference
{ {
@@ -129,9 +132,9 @@ class Preference extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function user(): BelongsTo
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);
} }

View File

@@ -82,17 +82,19 @@ class Recurrence extends Model
'active' => 'bool', 'active' => 'bool',
'apply_rules' => 'bool', 'apply_rules' => 'bool',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable protected $fillable
= ['user_id', 'transaction_type_id', 'title', 'description', 'first_date', 'repeat_until', 'latest_date', 'repetitions', 'apply_rules', 'active']; = ['user_id', 'transaction_type_id', 'title', 'description', 'first_date', 'repeat_until', 'latest_date', 'repetitions', 'apply_rules', 'active'];
/** @var string */ /** @var string The table to store the data in */
protected $table = 'recurrences'; protected $table = 'recurrences';
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return Recurrence * @return Recurrence
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): Recurrence public static function routeBinder(string $value): Recurrence
{ {

View File

@@ -37,7 +37,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class RecurrenceMeta extends Model class RecurrenceMeta extends Model
{ {
use SoftDeletes; use SoftDeletes;
/** @var array */ /**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts protected $casts
= [ = [
'created_at' => 'datetime', 'created_at' => 'datetime',
@@ -46,9 +50,9 @@ class RecurrenceMeta extends Model
'name' => 'string', 'name' => 'string',
'value' => 'string', 'value' => 'string',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['recurrence_id', 'name', 'value']; protected $fillable = ['recurrence_id', 'name', 'value'];
/** @var string */ /** @var string The table to store the data in */
protected $table = 'recurrences_meta'; protected $table = 'recurrences_meta';
/** /**

View File

@@ -51,7 +51,11 @@ class RecurrenceRepetition extends Model
/** @var int */ /** @var int */
public const WEEKEND_TO_MONDAY = 4; public const WEEKEND_TO_MONDAY = 4;
use SoftDeletes; use SoftDeletes;
/** @var array */ /**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts protected $casts
= [ = [
'created_at' => 'datetime', 'created_at' => 'datetime',
@@ -62,8 +66,9 @@ class RecurrenceRepetition extends Model
'repetition_skip' => 'int', 'repetition_skip' => 'int',
'weekend' => 'int', 'weekend' => 'int',
]; ];
/** @var array Fields that can be filled */
protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip']; protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip'];
/** @var string */ /** @var string The table to store the data in */
protected $table = 'recurrences_repetitions'; protected $table = 'recurrences_repetitions';
/** /**

View File

@@ -51,7 +51,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class RecurrenceTransaction extends Model class RecurrenceTransaction extends Model
{ {
use SoftDeletes; use SoftDeletes;
/** @var array */ /**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts protected $casts
= [ = [
'created_at' => 'datetime', 'created_at' => 'datetime',
@@ -61,16 +65,16 @@ class RecurrenceTransaction extends Model
'foreign_amount' => 'string', 'foreign_amount' => 'string',
'description' => 'string', 'description' => 'string',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable protected $fillable
= ['recurrence_id', 'transaction_currency_id', 'foreign_currency_id', 'source_id', 'destination_id', 'amount', 'foreign_amount', = ['recurrence_id', 'transaction_currency_id', 'foreign_currency_id', 'source_id', 'destination_id', 'amount', 'foreign_amount',
'description']; 'description'];
/** @var string */ /** @var string The table to store the data in */
protected $table = 'recurrences_transactions'; protected $table = 'recurrences_transactions';
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function destinationAccount(): BelongsTo public function destinationAccount(): BelongsTo
{ {
@@ -106,7 +110,7 @@ class RecurrenceTransaction extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function sourceAccount(): BelongsTo public function sourceAccount(): BelongsTo
{ {

View File

@@ -37,7 +37,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class RecurrenceTransactionMeta extends Model class RecurrenceTransactionMeta extends Model
{ {
use SoftDeletes; use SoftDeletes;
/** @var array */ /**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts protected $casts
= [ = [
'created_at' => 'datetime', 'created_at' => 'datetime',
@@ -46,8 +50,9 @@ class RecurrenceTransactionMeta extends Model
'name' => 'string', 'name' => 'string',
'value' => 'string', 'value' => 'string',
]; ];
/** @var array Fields that can be filled */
protected $fillable = ['rt_id', 'name', 'value']; protected $fillable = ['rt_id', 'name', 'value'];
/** @var string */ /** @var string The table to store the data in */
protected $table = 'rt_meta'; protected $table = 'rt_meta';
/** /**

View File

@@ -45,14 +45,12 @@ class Role extends Model
'updated_at' => 'datetime', 'updated_at' => 'datetime',
]; ];
/** /** @var array Fields that can be filled */
* @var array
*/
protected $fillable = ['name', 'display_name', 'description']; protected $fillable = ['name', 'display_name', 'description'];
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function users(): BelongsToMany public function users(): BelongsToMany
{ {

View File

@@ -70,14 +70,16 @@ class Rule extends Model
'id' => 'int', 'id' => 'int',
'strict' => 'boolean', 'strict' => 'boolean',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['rule_group_id', 'order', 'active', 'title', 'description', 'user_id', 'strict']; protected $fillable = ['rule_group_id', 'order', 'active', 'title', 'description', 'user_id', 'strict'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return Rule * @return Rule
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): Rule public static function routeBinder(string $value): Rule
{ {

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/** /**
* Class RuleAction. * Class RuleAction.
@@ -54,14 +55,14 @@ class RuleAction extends Model
'stop_processing' => 'boolean', 'stop_processing' => 'boolean',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['rule_id', 'action_type', 'action_value', 'order', 'active', 'stop_processing']; protected $fillable = ['rule_id', 'action_type', 'action_value', 'order', 'active', 'stop_processing'];
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function rule(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function rule(): BelongsTo
{ {
return $this->belongsTo(Rule::class); return $this->belongsTo(Rule::class);
} }

View File

@@ -25,6 +25,8 @@ namespace FireflyIII\Models;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -60,16 +62,16 @@ class RuleGroup extends Model
'order' => 'int', 'order' => 'int',
]; ];
/** /** @var array Fields that can be filled */
* @var array
*/
protected $fillable = ['user_id', 'order', 'title', 'description', 'active']; protected $fillable = ['user_id', 'order', 'title', 'description', 'active'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return RuleGroup * @return RuleGroup
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): RuleGroup public static function routeBinder(string $value): RuleGroup
{ {
@@ -88,18 +90,18 @@ class RuleGroup extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function rules(): \Illuminate\Database\Eloquent\Relations\HasMany public function rules(): HasMany
{ {
return $this->hasMany(Rule::class); return $this->hasMany(Rule::class);
} }
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function user(): BelongsTo
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);
} }

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/** /**
* Class RuleTrigger. * Class RuleTrigger.
@@ -53,14 +54,14 @@ class RuleTrigger extends Model
'stop_processing' => 'boolean', 'stop_processing' => 'boolean',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['rule_id', 'trigger_type', 'trigger_value', 'order', 'active', 'stop_processing']; protected $fillable = ['rule_id', 'trigger_type', 'trigger_value', 'order', 'active', 'stop_processing'];
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function rule(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function rule(): BelongsTo
{ {
return $this->belongsTo(Rule::class); return $this->belongsTo(Rule::class);
} }

View File

@@ -25,6 +25,8 @@ namespace FireflyIII\Models;
use Crypt; use Crypt;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -60,16 +62,16 @@ class Tag extends Model
'date' => 'date', 'date' => 'date',
'zoomLevel' => 'int', 'zoomLevel' => 'int',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $dates = ['date'];
/** @var array */
protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode']; protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return Tag * @return Tag
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): Tag public static function routeBinder(string $value): Tag
{ {
@@ -146,18 +148,18 @@ class Tag extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\BelongsToMany public function transactionJournals(): BelongsToMany
{ {
return $this->belongsToMany(TransactionJournal::class); return $this->belongsToMany(TransactionJournal::class);
} }
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function user(): BelongsTo
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);
} }

View File

@@ -27,6 +27,7 @@ use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -100,6 +101,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/ */
class Transaction extends Model class Transaction extends Model
{ {
use SoftDeletes;
/** /**
* The attributes that should be casted to native types. * The attributes that should be casted to native types.
* *
@@ -115,24 +117,23 @@ class Transaction extends Model
'bill_name_encrypted' => 'boolean', 'bill_name_encrypted' => 'boolean',
'reconciled' => 'boolean', 'reconciled' => 'boolean',
]; ];
/** /** @var array Fields that can be filled */
* @var array
*/
protected $fillable protected $fillable
= ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier', 'transaction_currency_id', 'foreign_currency_id', = ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier', 'transaction_currency_id', 'foreign_currency_id',
'foreign_amount', 'reconciled']; 'foreign_amount', 'reconciled'];
/** /** @var array Hidden from view */
* @var array
*/
protected $hidden = ['encrypted']; protected $hidden = ['encrypted'];
/** /**
* @codeCoverageIgnore * Check if a table is joined.
*
*
* *
* @param Builder $query * @param Builder $query
* @param string $table * @param string $table
* *
* @return bool * @return bool
* @codeCoverageIgnore
*/ */
public static function isJoined(Builder $query, string $table): bool public static function isJoined(Builder $query, string $table): bool
{ {
@@ -150,10 +151,12 @@ class Transaction extends Model
} }
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return Transaction * @return Transaction
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): Transaction public static function routeBinder(string $value): Transaction
{ {
@@ -171,11 +174,12 @@ class Transaction extends Model
throw new NotFoundHttpException; throw new NotFoundHttpException;
} }
use SoftDeletes;
/** /**
* Get the account this object belongs to.
*
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function account(): BelongsTo public function account(): BelongsTo
{ {
@@ -183,26 +187,32 @@ class Transaction extends Model
} }
/** /**
* Get the budget(s) this object belongs to.
*
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function budgets(): \Illuminate\Database\Eloquent\Relations\BelongsToMany public function budgets(): BelongsToMany
{ {
return $this->belongsToMany(Budget::class); return $this->belongsToMany(Budget::class);
} }
/** /**
* Get the category(ies) this object belongs to.
*
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function categories(): \Illuminate\Database\Eloquent\Relations\BelongsToMany public function categories(): BelongsToMany
{ {
return $this->belongsToMany(Category::class); return $this->belongsToMany(Category::class);
} }
/** /**
* Get the currency this object belongs to.
*
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function foreignCurrency(): BelongsTo public function foreignCurrency(): BelongsTo
{ {
@@ -210,6 +220,8 @@ class Transaction extends Model
} }
/** /**
* Check for transactions AFTER a specified date.
*
* @codeCoverageIgnore * @codeCoverageIgnore
* *
* @param Builder $query * @param Builder $query
@@ -224,6 +236,7 @@ class Transaction extends Model
} }
/** /**
* Check for transactions BEFORE the specified date.
* @codeCoverageIgnore * @codeCoverageIgnore
* *
* @param Builder $query * @param Builder $query

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Models; namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -52,16 +53,16 @@ class TransactionCurrency extends Model
'deleted_at' => 'datetime', 'deleted_at' => 'datetime',
'decimal_places' => 'int', 'decimal_places' => 'int',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $dates = ['date'];
/** @var array */
protected $fillable = ['name', 'code', 'symbol', 'decimal_places']; protected $fillable = ['name', 'code', 'symbol', 'decimal_places'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return TransactionCurrency * @return TransactionCurrency
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): TransactionCurrency public static function routeBinder(string $value): TransactionCurrency
{ {
@@ -77,9 +78,9 @@ class TransactionCurrency extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\HasMany public function transactionJournals(): HasMany
{ {
return $this->hasMany(TransactionJournal::class); return $this->hasMany(TransactionJournal::class);
} }

View File

@@ -28,6 +28,7 @@ use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphMany;
@@ -91,15 +92,17 @@ class TransactionJournal extends Model
'completed' => 'boolean', 'completed' => 'boolean',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable protected $fillable
= ['user_id', 'transaction_type_id', 'bill_id', 'interest_date', 'book_date', 'process_date', = ['user_id', 'transaction_type_id', 'bill_id', 'interest_date', 'book_date', 'process_date',
'transaction_currency_id', 'description', 'completed', 'transaction_currency_id', 'description', 'completed',
'date', 'rent_date', 'encrypted', 'tag_count',]; 'date', 'rent_date', 'encrypted', 'tag_count',];
/** @var array */ /** @var array Hidden from view */
protected $hidden = ['encrypted']; protected $hidden = ['encrypted'];
/** /**
* Checks if tables are joined.
*
* @param Builder $query * @param Builder $query
* @param string $table * @param string $table
* *
@@ -121,10 +124,12 @@ class TransactionJournal extends Model
} }
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return TransactionJournal * @return TransactionJournal
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): TransactionJournal public static function routeBinder(string $value): TransactionJournal
{ {
@@ -154,16 +159,16 @@ class TransactionJournal extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function bill(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function bill(): BelongsTo
{ {
return $this->belongsTo(Bill::class); return $this->belongsTo(Bill::class);
} }
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function budgets(): BelongsToMany public function budgets(): BelongsToMany
{ {
@@ -172,7 +177,7 @@ class TransactionJournal extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function categories(): BelongsToMany public function categories(): BelongsToMany
{ {
@@ -259,7 +264,7 @@ class TransactionJournal extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function piggyBankEvents(): HasMany public function piggyBankEvents(): HasMany
{ {
@@ -333,7 +338,7 @@ class TransactionJournal extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function tags(): BelongsToMany public function tags(): BelongsToMany
{ {
@@ -342,9 +347,9 @@ class TransactionJournal extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function transactionCurrency(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function transactionCurrency(): BelongsTo
{ {
return $this->belongsTo(TransactionCurrency::class); return $this->belongsTo(TransactionCurrency::class);
} }
@@ -360,9 +365,9 @@ class TransactionJournal extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function transactionType(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function transactionType(): BelongsTo
{ {
return $this->belongsTo(TransactionType::class); return $this->belongsTo(TransactionType::class);
} }
@@ -378,9 +383,9 @@ class TransactionJournal extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function user(): BelongsTo
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);
} }

View File

@@ -45,12 +45,23 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/ */
class TransactionJournalLink extends Model class TransactionJournalLink extends Model
{ {
/** /** @var string The table to store the data in */
* @var string
*/
protected $table = 'journal_links'; protected $table = 'journal_links';
/** /**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value * @param string $value
* *
* @return mixed * @return mixed
@@ -76,7 +87,7 @@ class TransactionJournalLink extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function destination(): BelongsTo public function destination(): BelongsTo
{ {
@@ -101,7 +112,7 @@ class TransactionJournalLink extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function linkType(): BelongsTo public function linkType(): BelongsTo
{ {
@@ -136,7 +147,7 @@ class TransactionJournalLink extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function source(): BelongsTo public function source(): BelongsTo
{ {

View File

@@ -49,9 +49,9 @@ class TransactionJournalMeta extends Model
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'deleted_at' => 'datetime', 'deleted_at' => 'datetime',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash']; protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash'];
/** @var string */ /** @var string The table to store the data in */
protected $table = 'journal_meta'; protected $table = 'journal_meta';
/** /**
@@ -80,7 +80,7 @@ class TransactionJournalMeta extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function transactionJournal(): BelongsTo public function transactionJournal(): BelongsTo
{ {

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Models; namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -67,14 +68,16 @@ class TransactionType extends Model
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'deleted_at' => 'datetime', 'deleted_at' => 'datetime',
]; ];
/** @var array */ /** @var array Fields that can be filled */
protected $fillable = ['type']; protected $fillable = ['type'];
/** /**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $type * @param string $type
* *
* @return Model|null|static * @return Model|null|static
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $type): TransactionType public static function routeBinder(string $type): TransactionType
{ {
@@ -126,9 +129,9 @@ class TransactionType extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\HasMany public function transactionJournals(): HasMany
{ {
return $this->hasMany(TransactionJournal::class); return $this->hasMany(TransactionJournal::class);
} }

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\ExportJob; namespace FireflyIII\Repositories\ExportJob;
use Carbon\Carbon; use Carbon\Carbon;
use Exception;
use FireflyIII\Models\ExportJob; use FireflyIII\Models\ExportJob;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Contracts\Filesystem\FileNotFoundException; use Illuminate\Contracts\Filesystem\FileNotFoundException;
@@ -54,11 +55,10 @@ class ExportJobRepository implements ExportJobRepositoryInterface
/** /**
* @return bool * @return bool
* @throws \Exception
*/ */
public function cleanup(): bool public function cleanup(): bool
{ {
$dayAgo = Carbon::create()->subDay(); $dayAgo = Carbon::now()->subDay();
$set = ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s')) $set = ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s'))
->whereIn('status', ['never_started', 'export_status_finished', 'export_downloaded']) ->whereIn('status', ['never_started', 'export_status_finished', 'export_downloaded'])
->get(); ->get();
@@ -74,7 +74,11 @@ class ExportJobRepository implements ExportJobRepositoryInterface
unlink(storage_path('export') . DIRECTORY_SEPARATOR . $file); unlink(storage_path('export') . DIRECTORY_SEPARATOR . $file);
} }
} }
$entry->delete(); try {
$entry->delete();
} catch (Exception $e) {
Log::debug(sprintf('Could not delete object: %s', $e->getMessage()));
}
} }
return true; return true;
@@ -142,8 +146,8 @@ class ExportJobRepository implements ExportJobRepositoryInterface
*/ */
public function getContent(ExportJob $job): string public function getContent(ExportJob $job): string
{ {
$disk = Storage::disk('export'); $disk = Storage::disk('export');
$file = $job->key . '.zip'; $file = $job->key . '.zip';
try { try {
$content = $disk->get($file); $content = $disk->get($file);

View File

@@ -375,7 +375,7 @@ class RecurringRepository implements RecurringRepositoryInterface
} }
if ('yearly' === $repetition->repetition_type) { if ('yearly' === $repetition->repetition_type) {
// //
$today = Carbon::create()->endOfYear(); $today = Carbon::now()->endOfYear();
$repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment); $repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment);
$diffInYears = $today->diffInYears($repDate); $diffInYears = $today->diffInYears($repDate);
$repDate->addYears($diffInYears); // technically not necessary. $repDate->addYears($diffInYears); // technically not necessary.

View File

@@ -267,6 +267,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
* - Add the value to the list of "values" that the user must map. * - Add the value to the list of "values" that the user must map.
* *
* @param Reader $reader * @param Reader $reader
* @param array $config
* @param array $columnConfig * @param array $columnConfig
* *
* @return array * @return array

View File

@@ -101,7 +101,7 @@ class NewFileJobHandler implements FileConfigurationInterface
} }
/** /**
* @param ImportJob $job * @param ImportJob $importJob
*/ */
public function setImportJob(ImportJob $importJob): void public function setImportJob(ImportJob $importJob): void
{ {
@@ -114,7 +114,6 @@ class NewFileJobHandler implements FileConfigurationInterface
/** /**
* Store config from job. * Store config from job.
* *
* @throws FireflyException
*/ */
public function storeConfiguration(): void public function storeConfiguration(): void
{ {

View File

@@ -87,6 +87,8 @@ class NewYnabJobHandler implements YnabJobConfigurationInterface
* Get data for config view. * Get data for config view.
* *
* @return array * @return array
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
*/ */
public function getNextData(): array public function getNextData(): array
{ {
@@ -134,6 +136,8 @@ class NewYnabJobHandler implements YnabJobConfigurationInterface
/** /**
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
*/ */
private function getAccessToken(): void private function getAccessToken(): void
@@ -231,6 +235,8 @@ class NewYnabJobHandler implements YnabJobConfigurationInterface
/** /**
* @return bool * @return bool
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
*/ */
private function hasRefreshToken(): bool private function hasRefreshToken(): bool
{ {

View File

@@ -218,7 +218,7 @@ class SelectAccountsHandler implements YnabJobConfigurationInterface
} }
/** /**
* @param int $accountId * @param string $accountId
* *
* @return string * @return string
*/ */

View File

@@ -111,6 +111,7 @@ class StageImportDataHandler
* @param LocalAccount $source * @param LocalAccount $source
* *
* @return array * @return array
* @throws FireflyException
*/ */
private function convertPayment(BunqPayment $payment, LocalAccount $source): array private function convertPayment(BunqPayment $payment, LocalAccount $source): array
{ {

View File

@@ -47,7 +47,7 @@ class StageFinalHandler
for ($i = 0; $i < 5; $i++) { for ($i = 0; $i < 5; $i++) {
$transaction = [ $transaction = [
'type' => 'withdrawal', 'type' => 'withdrawal',
'date' => Carbon::create()->format('Y-m-d'), 'date' => Carbon::now()->format('Y-m-d'),
'tags' => '', 'tags' => '',
'user' => $this->importJob->user_id, 'user' => $this->importJob->user_id,

View File

@@ -71,7 +71,7 @@ class CurrencyMapper
return $result; return $result;
} }
} }
if (!isset($data['code']) || null === $data['code']) { if (!isset($data['code'])) {
return null; return null;
} }

View File

@@ -212,7 +212,7 @@ class ImportableConverter
return [ return [
'type' => $transactionType, 'type' => $transactionType,
'date' => $this->convertDateValue($importable->date) ?? Carbon::create()->format('Y-m-d'), 'date' => $this->convertDateValue($importable->date) ?? Carbon::now()->format('Y-m-d'),
'tags' => $importable->tags, 'tags' => $importable->tags,
'user' => $this->importJob->user_id, 'user' => $this->importJob->user_id,
'notes' => $importable->note, 'notes' => $importable->note,

View File

@@ -64,7 +64,7 @@ class ImportDataHandler
/** /**
* @var string $ynabId * @var string $ynabId
* @var int $localId * @var string $localId
*/ */
foreach ($mapping as $ynabId => $localId) { foreach ($mapping as $ynabId => $localId) {
$localAccount = $this->getLocalAccount((int)$localId); $localAccount = $this->getLocalAccount((int)$localId);
@@ -252,7 +252,6 @@ class ImportDataHandler
/** /**
* @param string $token * @param string $token
* @param string $budget
* @param string $account * @param string $account
* *
* @return array * @return array

View File

@@ -45,6 +45,8 @@ class StageGetAccessHandler
/** /**
* Send a token request to YNAB. Return with access token (if all goes well). * Send a token request to YNAB. Return with access token (if all goes well).
* *
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
*/ */
public function run(): void public function run(): void

View File

@@ -171,10 +171,7 @@ class Preferences
if (\is_array($lastActivity)) { if (\is_array($lastActivity)) {
$lastActivity = implode(',', $lastActivity); $lastActivity = implode(',', $lastActivity);
} }
$hash = md5($lastActivity); return md5($lastActivity);
//Log::debug(sprintf('Value of last activity is %s, hash is %s', $lastActivity, $hash));
return $hash;
} }
/** /**

View File

@@ -246,7 +246,7 @@ class Search implements SearchInterface
private function extractModifier(string $string): void private function extractModifier(string $string): void
{ {
$parts = explode(':', $string); $parts = explode(':', $string);
if (2 === \count($parts) && \strlen(trim((string)$parts[0])) > 0 && '' !== trim((string)$parts[1])) { if (2 === \count($parts) && '' !== trim((string)$parts[1]) && \strlen(trim((string)$parts[0])) > 0) {
$type = trim((string)$parts[0]); $type = trim((string)$parts[0]);
$value = trim((string)$parts[1]); $value = trim((string)$parts[1]);
if (\in_array($type, $this->validModifiers, true)) { if (\in_array($type, $this->validModifiers, true)) {

View File

@@ -132,6 +132,7 @@ class AmountFormat extends Twig_Extension
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'formatAmountBySymbol', 'formatAmountBySymbol',
/** @noinspection MoreThanThreeArgumentsInspection */
function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string { function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string {
$decimalPlaces = $decimalPlaces ?? 2; $decimalPlaces = $decimalPlaces ?? 2;
$coloured = $coloured ?? true; $coloured = $coloured ?? true;

View File

@@ -136,7 +136,7 @@ class TransactionJournal extends Twig_Extension
/** /**
* @param JournalModel $journal * @param JournalModel $journal
* *
* @return string * @return array
*/ */
private function getTotalAmount(JournalModel $journal): array private function getTotalAmount(JournalModel $journal): array
{ {

View File

@@ -103,9 +103,7 @@ class General extends Twig_Extension
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'activeRoutePartialWhat', 'activeRoutePartialWhat',
function ($context): string { function ($context): string {
$args = \func_get_args(); [, $route, $what] = \func_get_args();
$route = $args[1]; // name of the route.
$what = $args[2]; // name of the route.
$activeWhat = $context['what'] ?? false; $activeWhat = $context['what'] ?? false;
if ($what === $activeWhat && !(false === stripos(Route::getCurrentRoute()->getName(), $route))) { if ($what === $activeWhat && !(false === stripos(Route::getCurrentRoute()->getName(), $route))) {

View File

@@ -302,7 +302,7 @@ class User extends Authenticatable
* *
* @param string $token * @param string $token
*/ */
public function sendPasswordResetNotification($token) public function sendPasswordResetNotification($token): void
{ {
$ipAddress = Request::ip(); $ipAddress = Request::ip();

View File

@@ -112,10 +112,10 @@ trait TransactionValidation
{ {
$data = $validator->getData(); $data = $validator->getData();
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
$journalDescription = (string)($data['description'] ?? ''); $journalDescription = (string)($data['description'] ?? null);
$validDescriptions = 0; $validDescriptions = 0;
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
if (\strlen((string)($transaction['description'] ?? '')) > 0) { if (\strlen((string)($transaction['description'] ?? null)) > 0) {
$validDescriptions++; $validDescriptions++;
} }
} }
@@ -157,9 +157,9 @@ trait TransactionValidation
{ {
$data = $validator->getData(); $data = $validator->getData();
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
$journalDescription = (string)($data['description'] ?? ''); $journalDescription = (string)($data['description'] ?? null);
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
$description = (string)($transaction['description'] ?? ''); $description = (string)($transaction['description'] ?? null);
// description cannot be equal to journal description. // description cannot be equal to journal description.
if ($description === $journalDescription) { if ($description === $journalDescription) {
$validator->errors()->add('transactions.' . $index . '.description', (string)trans('validation.equal_description')); $validator->errors()->add('transactions.' . $index . '.description', (string)trans('validation.equal_description'));
@@ -249,7 +249,7 @@ trait TransactionValidation
$data = $validator->getData(); $data = $validator->getData();
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
$description = (string)($transaction['description'] ?? ''); $description = (string)($transaction['description'] ?? null);
// filled description is mandatory for split transactions. // filled description is mandatory for split transactions.
if ('' === $description && \count($transactions) > 1) { if ('' === $description && \count($transactions) > 1) {
$validator->errors()->add( $validator->errors()->add(

View File

@@ -50,7 +50,7 @@ return [
'at_least_one_action' => 'Rule must have at least one action.', 'at_least_one_action' => 'Rule must have at least one action.',
'base64' => 'This is not valid base64 encoded data.', 'base64' => 'This is not valid base64 encoded data.',
'model_id_invalid' => 'The given ID seems invalid for this model.', 'model_id_invalid' => 'The given ID seems invalid for this model.',
'more' => ':attribute must be larger than :value.', 'more' => ':attribute must be larger than zero.',
'less' => ':attribute must be less than 10,000,000', 'less' => ':attribute must be less than 10,000,000',
'active_url' => 'The :attribute is not a valid URL.', 'active_url' => 'The :attribute is not a valid URL.',
'after' => 'The :attribute must be a date after :date.', 'after' => 'The :attribute must be a date after :date.',

View File

@@ -2,6 +2,7 @@
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label> <label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8"> <div class="col-sm-8">
{{ Form.input('number', name, value, options) }} {{ Form.input('number', name, value, options) }}
{% include 'form/help' %}
{% include 'form/feedback' %} {% include 'form/feedback' %}
</div> </div>
</div> </div>

View File

@@ -3,6 +3,7 @@
<div class="col-sm-8"> <div class="col-sm-8">
{{ Form.input('number', name, value, options) }} {{ Form.input('number', name, value, options) }}
{% include 'form/help' %}
{% include 'form/feedback' %} {% include 'form/feedback' %}
</div> </div>
</div> </div>

View File

@@ -426,8 +426,8 @@
<div class="col-sm-10"> <div class="col-sm-10">
<select id="link_type" class="form-control" name="link_type"> <select id="link_type" class="form-control" name="link_type">
{% for linkType in linkTypes %} {% for linkType in linkTypes %}
<option label="{{ trans('firefly.link_'~linkType.inward) }}" value="{{ linkType.id }}_inward">{{ trans('firefly.link_'~linkType.inward) }}</option> <option label="{{ journalLinkTranslation('inward', linkType.inward) }}" value="{{ linkType.id }}_inward">{{ journalLinkTranslation('inward', linkType.inward) }}</option>
<option label="{{ trans('firefly.link_'~linkType.outward) }}" value="{{ linkType.id }}_outward">{{ trans('firefly.link_'~linkType.outward) }}</option> <option label="{{ journalLinkTranslation('outward', linkType.outward) }}" value="{{ linkType.id }}_outward">{{ journalLinkTranslation('outward', linkType.outward) }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>