diff --git a/app/Api/V1/Requests/RecurrenceRequest.php b/app/Api/V1/Requests/RecurrenceRequest.php
index fd348c733d..77adb8d242 100644
--- a/app/Api/V1/Requests/RecurrenceRequest.php
+++ b/app/Api/V1/Requests/RecurrenceRequest.php
@@ -84,7 +84,7 @@ class RecurrenceRequest extends Request
*/
public function rules(): array
{
- $today = Carbon::create()->addDay();
+ $today = Carbon::now()->addDay();
return [
'type' => 'required|in:withdrawal,transfer,deposit',
diff --git a/app/Generator/Report/Account/MonthReportGenerator.php b/app/Generator/Report/Account/MonthReportGenerator.php
index 49f0cbfbd7..ab135909f7 100644
--- a/app/Generator/Report/Account/MonthReportGenerator.php
+++ b/app/Generator/Report/Account/MonthReportGenerator.php
@@ -25,6 +25,8 @@ namespace FireflyIII\Generator\Report\Account;
use Carbon\Carbon;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
+use Log;
+use Throwable;
/**
* Class MonthReportGenerator.
@@ -44,7 +46,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
* Generate the report.
*
* @return string
- * @throws \Throwable
*/
public function generate(): string
{
@@ -52,11 +53,17 @@ class MonthReportGenerator implements ReportGeneratorInterface
$expenseIds = implode(',', $this->expense->pluck('id')->toArray());
$reportType = 'account';
$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(
- 'reports.account.report',
- compact('accountIds', 'reportType', 'expenseIds', 'preferredPeriod')
- )->with('start', $this->start)->with('end', $this->end)->render();
+ return $result;
}
/**
diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php
index 386f27ded2..3dcaa08952 100644
--- a/app/Generator/Report/Audit/MonthReportGenerator.php
+++ b/app/Generator/Report/Audit/MonthReportGenerator.php
@@ -34,6 +34,8 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection;
+use Log;
+use Throwable;
/**
* Class MonthReportGenerator.
@@ -52,7 +54,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
*
* @return string
* @throws FireflyException
- * @throws \Throwable
*/
public function generate(): string
{
@@ -78,10 +79,16 @@ class MonthReportGenerator implements ReportGeneratorInterface
'internal_reference', 'notes',
'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'))
- ->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)
- ->render();
+ return $result;
}
/**
diff --git a/app/Generator/Report/Budget/MonthReportGenerator.php b/app/Generator/Report/Budget/MonthReportGenerator.php
index ff4229ab26..39aaf1696e 100644
--- a/app/Generator/Report/Budget/MonthReportGenerator.php
+++ b/app/Generator/Report/Budget/MonthReportGenerator.php
@@ -35,6 +35,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
use Log;
+use Throwable;
/**
* Class MonthReportGenerator.
@@ -64,7 +65,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
* Generates the report.
*
* @return string
- * @throws \Throwable
*/
public function generate(): string
{
@@ -77,11 +77,17 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$topExpenses = $this->getTopExpenses();
// 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('budgets', $this->budgets)
->with('accounts', $this->accounts)
->render();
+ } catch (Throwable $e) {
+ Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
+ $result = 'Could not render report view.';
+ }
+ return $result;
}
/**
diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.php
index ef187a575b..d454d85dd8 100644
--- a/app/Generator/Report/Category/MonthReportGenerator.php
+++ b/app/Generator/Report/Category/MonthReportGenerator.php
@@ -36,6 +36,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
use Log;
+use Throwable;
/**
* Class MonthReportGenerator.
@@ -68,7 +69,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
* Generates the report.
*
* @return string
- * @throws \Throwable
*/
public function generate(): string
{
@@ -85,24 +85,23 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$topIncome = $this->getTopIncome();
// render!
- return view(
- 'reports.category.month',
- compact(
- 'accountIds',
- 'categoryIds',
- 'topIncome',
- 'reportType',
- 'accountSummary',
- 'categorySummary',
- 'averageExpenses',
- 'averageIncome',
- 'topExpenses'
+ try {
+ return view(
+ 'reports.category.month', compact(
+ 'accountIds', 'categoryIds', 'topIncome', 'reportType', 'accountSummary', 'categorySummary', 'averageExpenses',
+ 'averageIncome', 'topExpenses'
+ )
)
- )
- ->with('start', $this->start)->with('end', $this->end)
- ->with('categories', $this->categories)
- ->with('accounts', $this->accounts)
- ->render();
+ ->with('start', $this->start)->with('end', $this->end)
+ ->with('categories', $this->categories)
+ ->with('accounts', $this->accounts)
+ ->render();
+ } catch (Throwable $e) {
+ Log::error(sprintf('Cannot render reports.category.month: %s', $e->getMessage()));
+ $result = 'Could not render report view.';
+ }
+
+ return $result;
}
/**
diff --git a/app/Generator/Report/Standard/MonthReportGenerator.php b/app/Generator/Report/Standard/MonthReportGenerator.php
index e27f4d79ed..ad0a9c0b99 100644
--- a/app/Generator/Report/Standard/MonthReportGenerator.php
+++ b/app/Generator/Report/Standard/MonthReportGenerator.php
@@ -26,6 +26,8 @@ use Carbon\Carbon;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use Illuminate\Support\Collection;
+use Log;
+use Throwable;
/**
* Class MonthReportGenerator.
@@ -43,7 +45,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
* Generates the report.
*
* @return string
- * @throws \Throwable
*/
public function generate(): string
{
@@ -53,11 +54,17 @@ class MonthReportGenerator implements ReportGeneratorInterface
$accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default';
- // continue!
- return view(
- 'reports.default.month',
- compact('bills', 'accountIds', 'reportType')
- )->with('start', $this->start)->with('end', $this->end)->render();
+ try {
+ return view(
+ 'reports.default.month',
+ compact('bills', 'accountIds', 'reportType')
+ )->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;
}
/**
diff --git a/app/Generator/Report/Standard/MultiYearReportGenerator.php b/app/Generator/Report/Standard/MultiYearReportGenerator.php
index ec507b9386..9310554b33 100644
--- a/app/Generator/Report/Standard/MultiYearReportGenerator.php
+++ b/app/Generator/Report/Standard/MultiYearReportGenerator.php
@@ -25,6 +25,8 @@ namespace FireflyIII\Generator\Report\Standard;
use Carbon\Carbon;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
+use Log;
+use Throwable;
/**
* Class MonthReportGenerator.
@@ -42,7 +44,6 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
* Generates the report.
*
* @return string
- * @throws \Throwable
*/
public function generate(): string
{
@@ -50,11 +51,17 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
$accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default';
- // continue!
- return view(
- 'reports.default.multi-year',
- compact('accountIds', 'reportType')
- )->with('start', $this->start)->with('end', $this->end)->render();
+ try {
+ return view(
+ 'reports.default.multi-year',
+ compact('accountIds', 'reportType')
+ )->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;
}
/**
diff --git a/app/Generator/Report/Standard/YearReportGenerator.php b/app/Generator/Report/Standard/YearReportGenerator.php
index 47f92f47ad..bec85e462a 100644
--- a/app/Generator/Report/Standard/YearReportGenerator.php
+++ b/app/Generator/Report/Standard/YearReportGenerator.php
@@ -25,6 +25,8 @@ namespace FireflyIII\Generator\Report\Standard;
use Carbon\Carbon;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
+use Log;
+use Throwable;
/**
* Class MonthReportGenerator.
@@ -42,7 +44,6 @@ class YearReportGenerator implements ReportGeneratorInterface
* Generates the report.
*
* @return string
- * @throws \Throwable
*/
public function generate(): string
{
@@ -50,13 +51,20 @@ class YearReportGenerator implements ReportGeneratorInterface
$accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default';
- // continue!
- return view(
- 'reports.default.year',
- compact('accountIds', 'reportType')
- )->with('start', $this->start)->with('end', $this->end)->render();
+ try {
+ $result = view(
+ 'reports.default.year',
+ compact('accountIds', 'reportType')
+ )->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.
*
diff --git a/app/Generator/Report/Tag/MonthReportGenerator.php b/app/Generator/Report/Tag/MonthReportGenerator.php
index e367283624..84532e19f1 100644
--- a/app/Generator/Report/Tag/MonthReportGenerator.php
+++ b/app/Generator/Report/Tag/MonthReportGenerator.php
@@ -38,6 +38,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
use Log;
+use Throwable;
/**
* Class MonthReportGenerator.
@@ -70,7 +71,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
* Generate the report.
*
* @return string
- * @throws \Throwable
*/
public function generate(): string
{
@@ -87,20 +87,18 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$topIncome = $this->getTopIncome();
// render!
- return view(
- 'reports.tag.month',
- compact(
- 'accountIds',
- 'tagTags',
- 'reportType',
- 'accountSummary',
- 'tagSummary',
- 'averageExpenses',
- 'averageIncome',
- 'topIncome',
- 'topExpenses'
+ try {
+ $result = view(
+ 'reports.tag.month', compact(
+ 'accountIds', '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;
}
/**
diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php
index 0b48280422..3e81b43390 100644
--- a/app/Http/Controllers/Budget/ShowController.php
+++ b/app/Http/Controllers/Budget/ShowController.php
@@ -142,7 +142,7 @@ class ShowController extends Controller
public function show(Request $request, Budget $budget)
{
/** @var Carbon $start */
- $start = session('first', Carbon::create()->startOfYear());
+ $start = session('first', Carbon::now()->startOfYear());
$end = new Carbon;
$page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
@@ -196,7 +196,7 @@ class ShowController extends Controller
$transactions = $collector->getPaginatedJournals();
$transactions->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
/** @var Carbon $start */
- $start = session('first', Carbon::create()->startOfYear());
+ $start = session('first', Carbon::now()->startOfYear());
$end = new Carbon;
$limits = $this->getLimits($budget, $start, $end);
diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.php
index eb0e54edfd..623cdaab9d 100644
--- a/app/Http/Controllers/Category/ShowController.php
+++ b/app/Http/Controllers/Category/ShowController.php
@@ -90,9 +90,9 @@ class ShowController extends Controller
{
Log::debug('Now in show()');
/** @var Carbon $start */
- $start = $start ?? session('start', Carbon::create()->startOfMonth());
+ $start = $start ?? session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
- $end = $end ?? session('end', Carbon::create()->startOfMonth());
+ $end = $end ?? session('end', Carbon::now()->startOfMonth());
$subTitleIcon = 'fa-bar-chart';
$moment = '';
$page = (int)$request->get('page');
diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php
index 958c51f017..0735d60db9 100644
--- a/app/Http/Controllers/DebugController.php
+++ b/app/Http/Controllers/DebugController.php
@@ -120,7 +120,7 @@ class DebugController extends Controller
$phpVersion = str_replace($search, $replace, PHP_VERSION);
$phpOs = str_replace($search, $replace, PHP_OS);
$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());
$drivers = implode(', ', DB::availableDrivers());
$currentDriver = DB::getDriverName();
diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php
index 8426d5b2f7..102a10dbb3 100644
--- a/app/Http/Controllers/ExportController.php
+++ b/app/Http/Controllers/ExportController.php
@@ -125,7 +125,7 @@ class ExportController extends Controller
$formats = array_keys(config('firefly.export_formats'));
$defaultFormat = app('preferences')->get('export_format', config('firefly.default_export_format'))->data;
$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'));
}
diff --git a/app/Http/Controllers/Import/CallbackController.php b/app/Http/Controllers/Import/CallbackController.php
index 9f7f7c62f6..2fb1e0b612 100644
--- a/app/Http/Controllers/Import/CallbackController.php
+++ b/app/Http/Controllers/Import/CallbackController.php
@@ -36,6 +36,8 @@ class CallbackController extends Controller
{
/**
+ * Callback specifically for YNAB logins.
+ *
* @param Request $request
*
* @param ImportJobRepositoryInterface $repository
diff --git a/app/Http/Controllers/Import/IndexController.php b/app/Http/Controllers/Import/IndexController.php
index bf45a8c6c3..b24ab51fbb 100644
--- a/app/Http/Controllers/Import/IndexController.php
+++ b/app/Http/Controllers/Import/IndexController.php
@@ -37,7 +37,7 @@ use Log;
*/
class IndexController extends Controller
{
- /** @var array */
+ /** @var array All available providers */
public $providers;
/** @var ImportJobRepositoryInterface The import job repository */
public $repository;
diff --git a/app/Http/Controllers/Json/FrontpageController.php b/app/Http/Controllers/Json/FrontpageController.php
index b27dec9585..7a8247b79e 100644
--- a/app/Http/Controllers/Json/FrontpageController.php
+++ b/app/Http/Controllers/Json/FrontpageController.php
@@ -26,6 +26,8 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Illuminate\Http\JsonResponse;
+use Log;
+use Throwable;
/**
* Class FrontpageController.
@@ -38,7 +40,6 @@ class FrontpageController extends Controller
* @param PiggyBankRepositoryInterface $repository
*
* @return JsonResponse
- * @throws \Throwable
*/
public function piggyBanks(PiggyBankRepositoryInterface $repository): JsonResponse
{
@@ -64,7 +65,12 @@ class FrontpageController extends Controller
}
$html = '';
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]);
diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php
index a18561b929..a270d98a8b 100644
--- a/app/Http/Controllers/JsonController.php
+++ b/app/Http/Controllers/JsonController.php
@@ -24,6 +24,8 @@ namespace FireflyIII\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
+use Log;
+use Throwable;
/**
* Class JsonController.
@@ -36,7 +38,6 @@ class JsonController extends Controller
* @param Request $request
*
* @return JsonResponse
- * @throws \Throwable
*/
public function action(Request $request): JsonResponse
{
@@ -46,7 +47,12 @@ class JsonController extends Controller
foreach ($keys as $key) {
$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]);
}
@@ -57,7 +63,6 @@ class JsonController extends Controller
* @param Request $request
*
* @return JsonResponse
- * @throws \Throwable
*/
public function trigger(Request $request): JsonResponse
{
@@ -71,7 +76,12 @@ class JsonController extends Controller
}
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]);
}
diff --git a/app/Http/Controllers/Popup/ReportController.php b/app/Http/Controllers/Popup/ReportController.php
index d07a09ab63..8e7d3e3cb6 100644
--- a/app/Http/Controllers/Popup/ReportController.php
+++ b/app/Http/Controllers/Popup/ReportController.php
@@ -274,7 +274,7 @@ class ReportController extends Controller
$attributes['startDate'] = Carbon::createFromFormat('Ymd', $attributes['startDate']);
} catch (InvalidArgumentException $e) {
Log::debug(sprintf('Not important error message: %s', $e->getMessage()));
- $date = Carbon::create()->startOfMonth();
+ $date = Carbon::now()->startOfMonth();
$attributes['startDate'] = $date;
}
@@ -282,7 +282,7 @@ class ReportController extends Controller
$attributes['endDate'] = Carbon::createFromFormat('Ymd', $attributes['endDate']);
} catch (InvalidArgumentException $e) {
Log::debug(sprintf('Not important error message: %s', $e->getMessage()));
- $date = Carbon::create()->startOfMonth();
+ $date = Carbon::now()->startOfMonth();
$attributes['endDate'] = $date;
}
diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.php
index 04a5307c0b..b5223dd5b7 100644
--- a/app/Http/Controllers/Report/OperationsController.php
+++ b/app/Http/Controllers/Report/OperationsController.php
@@ -38,7 +38,7 @@ class OperationsController extends Controller
private $tasker;
/**
- *
+ * OperationsController constructor.
*/
public function __construct()
{
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index ff77965966..df5d3baa9c 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -36,6 +36,7 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Collection;
use Log;
+use Throwable;
/**
* Class ReportController.
@@ -277,7 +278,6 @@ class ReportController extends Controller
*
* @return mixed
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
- * @throws \Throwable
*/
public function options(string $reportType)
{
@@ -391,7 +391,6 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string
- *
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
@@ -423,7 +422,6 @@ class ReportController extends Controller
* Get options for account report.
*
* @return string
- * @throws \Throwable
*/
private function accountReportOptions(): string
{
@@ -438,52 +436,77 @@ class ReportController extends Controller
$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.
+ *
* @return string
- * @throws \Throwable
*/
private function budgetReportOptions(): string
{
/** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class);
$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.
+ *
* @return string
- * @throws \Throwable
*/
private function categoryReportOptions(): string
{
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
$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.
+ *
* @return string
- * @throws \Throwable
*/
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.
+ *
* @return string
- * @throws \Throwable
*/
private function tagReportOptions(): string
{
@@ -494,7 +517,13 @@ class ReportController extends Controller
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;
}
}
diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.php
index 6381fbf21c..b8c30229f2 100644
--- a/app/Http/Controllers/Rule/SelectController.php
+++ b/app/Http/Controllers/Rule/SelectController.php
@@ -118,7 +118,7 @@ class SelectController extends Controller
{
// does the user have shared accounts?
$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]);
return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));
diff --git a/app/Http/Controllers/RuleGroupController.php b/app/Http/Controllers/RuleGroupController.php
index c814776eb8..8a99cd2ab7 100644
--- a/app/Http/Controllers/RuleGroupController.php
+++ b/app/Http/Controllers/RuleGroupController.php
@@ -208,7 +208,7 @@ class RuleGroupController extends Controller
public function selectTransactions(RuleGroup $ruleGroup)
{
$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]);
return view('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle'));
diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php
index 6308bd1770..57e1b9e949 100644
--- a/app/Http/Controllers/SearchController.php
+++ b/app/Http/Controllers/SearchController.php
@@ -27,6 +27,8 @@ use FireflyIII\Support\Search\SearchInterface;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
+use Log;
+use Throwable;
/**
* Class SearchController.
@@ -77,7 +79,6 @@ class SearchController extends Controller
* @param SearchInterface $searcher
*
* @return \Illuminate\Http\JsonResponse
- * @throws \Throwable
*/
public function search(Request $request, SearchInterface $searcher): JsonResponse
{
@@ -99,8 +100,12 @@ class SearchController extends Controller
$transactions = $searcher->searchTransactions();
$cache->store($transactions);
}
-
- $html = view('search.search', compact('transactions'))->render();
+ try {
+ $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]);
}
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index c9685012a6..a989dda208 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -262,7 +262,7 @@ class TransactionController extends Controller
{
$range = app('preferences')->get('viewRange', '1M')->data;
$first = $this->repository->firstNull();
- $start = Carbon::create()->subYear();
+ $start = Carbon::now()->subYear();
$types = config('firefly.transactionTypesByWhat.' . $what);
$entries = new Collection;
if (null !== $first) {
diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php
index f79500515a..d347aa7a9e 100644
--- a/app/Http/Requests/AccountFormRequest.php
+++ b/app/Http/Requests/AccountFormRequest.php
@@ -48,7 +48,7 @@ class AccountFormRequest extends Request
*/
public function getAccountData(): array
{
- return [
+ $data = [
'name' => $this->string('name'),
'active' => $this->boolean('active'),
'accountType' => $this->string('what'),
@@ -64,7 +64,22 @@ class AccountFormRequest extends Request
'ccType' => $this->string('ccType'),
'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'),
'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_virtualBalance' => 'exists:transaction_currencies,id',
'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 */
$account = $this->route()->parameter('account');
if (null !== $account) {
diff --git a/app/Http/Requests/ExportFormRequest.php b/app/Http/Requests/ExportFormRequest.php
index 942aca6870..d19441209c 100644
--- a/app/Http/Requests/ExportFormRequest.php
+++ b/app/Http/Requests/ExportFormRequest.php
@@ -50,7 +50,7 @@ class ExportFormRequest extends Request
/** @var Carbon $sessionFirst */
$sessionFirst = clone session('first');
$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')));
// fixed
diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.php
index 47c389922e..7f2fba4f03 100644
--- a/app/Http/Requests/RecurrenceFormRequest.php
+++ b/app/Http/Requests/RecurrenceFormRequest.php
@@ -149,7 +149,7 @@ class RecurrenceFormRequest extends Request
public function rules(): array
{
$today = new Carbon;
- $tomorrow = Carbon::create()->addDay();
+ $tomorrow = Carbon::now()->addDay();
$rules = [
// mandatory info for recurrence.
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
diff --git a/app/Http/Requests/SelectTransactionsRequest.php b/app/Http/Requests/SelectTransactionsRequest.php
index 9207a51159..5697fdfb62 100644
--- a/app/Http/Requests/SelectTransactionsRequest.php
+++ b/app/Http/Requests/SelectTransactionsRequest.php
@@ -53,7 +53,7 @@ class SelectTransactionsRequest extends Request
/** @var Carbon $sessionFirst */
$sessionFirst = clone session('first');
$first = $sessionFirst->subDay()->format('Y-m-d');
- $today = Carbon::create()->addDay()->format('Y-m-d');
+ $today = Carbon::now()->addDay()->format('Y-m-d');
return [
'start_date' => 'required|date|after:' . $first,
diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php
index 1a736c5acc..ebe5eeb859 100644
--- a/app/Import/Storage/ImportArrayStorage.php
+++ b/app/Import/Storage/ImportArrayStorage.php
@@ -26,6 +26,7 @@ namespace FireflyIII\Import\Storage;
use Carbon\Carbon;
use DB;
+use FireflyIII\Events\RequestedReportOnJournals;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter;
@@ -114,6 +115,9 @@ class ImportArrayStorage
app('preferences')->mark();
+ // email about this:
+ event(new RequestedReportOnJournals($this->importJob->user_id, $collection));
+
return $collection;
}
diff --git a/app/Models/Account.php b/app/Models/Account.php
index ba5aef5da0..b4d40cc1af 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -75,18 +75,20 @@ class Account extends Model
'active' => 'boolean',
'encrypted' => 'boolean',
];
- /** @var array */
+ /** @var array Fields that can be filled */
protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
- /** @var array */
+ /** @var array Hidden from view */
protected $hidden = ['encrypted'];
/** @var bool */
private $joinedAccountTypes;
/**
+ * Route binder. Converts the key in the URL to the specified object (or throw 404).
+ *
* @param string $value
*
* @return Account
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+ * @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Account
{
diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php
index 4f6e68e52c..ff36c2ec93 100644
--- a/app/Models/AccountMeta.php
+++ b/app/Models/AccountMeta.php
@@ -44,11 +44,9 @@ class AccountMeta extends Model
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
- /** @var array */
+ /** @var array Fields that can be filled */
protected $fillable = ['account_id', 'name', 'data'];
- /**
- * @var string
- */
+ /** @var string The table to store the data in */
protected $table = 'account_meta';
/**
diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php
index 1446d0d6e3..2faad2e91a 100644
--- a/app/Models/AccountType.php
+++ b/app/Models/AccountType.php
@@ -35,25 +35,43 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
*/
class AccountType extends Model
{
+ /** @var string */
public const DEFAULT = 'Default account';
+ /** @var string */
public const CASH = 'Cash account';
+ /** @var string */
public const ASSET = 'Asset account';
+ /** @var string */
public const EXPENSE = 'Expense account';
+ /** @var string */
public const REVENUE = 'Revenue account';
+ /** @var string */
public const INITIAL_BALANCE = 'Initial balance account';
+ /** @var string */
public const BENEFICIARY = 'Beneficiary account';
+ /** @var string */
public const IMPORT = 'Import account';
+ /** @var string */
public const RECONCILIATION = 'Reconciliation account';
+ /** @var string */
public const LOAN = 'Loan';
+ /** @var string */
public const DEBT = 'Debt';
+ /** @var string */
public const MORTGAGE = 'Mortgage';
+ /** @var string */
public const CREDITCARD = 'Credit card';
+ /**
+ * The attributes that should be casted to native types.
+ *
+ * @var array
+ */
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
- /** @var array */
+ /** @var array Fields that can be filled */
protected $fillable = ['type'];
/**
diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php
index 591f2dfa71..967316202b 100644
--- a/app/Models/Attachment.php
+++ b/app/Models/Attachment.php
@@ -66,14 +66,16 @@ class Attachment extends Model
'deleted_at' => 'datetime',
'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'];
/**
+ * Route binder. Converts the key in the URL to the specified object (or throw 404).
+ *
* @param string $value
*
* @return Attachment
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+ * @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Attachment
{
diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.php
index 4950cb7661..0e41aaf521 100644
--- a/app/Models/AvailableBudget.php
+++ b/app/Models/AvailableBudget.php
@@ -58,14 +58,16 @@ class AvailableBudget extends Model
'start_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'];
/**
+ * Route binder. Converts the key in the URL to the specified object (or throw 404).
+ *
* @param string $value
*
* @return AvailableBudget
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+ * @throws NotFoundHttpException
*/
public static function routeBinder(string $value): AvailableBudget
{
@@ -84,7 +86,7 @@ class AvailableBudget extends Model
/**
* @codeCoverageIgnore
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ * @return BelongsTo
*/
public function transactionCurrency(): BelongsTo
{
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index f0b0ce6711..2354c460f0 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -77,22 +77,21 @@ class Bill extends Model
'name_encrypted' => 'boolean',
'match_encrypted' => 'boolean',
];
- /**
- * @var array
- */
+
+ /** @var array Fields that can be filled */
protected $fillable
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
'automatch', 'active', 'transaction_currency_id'];
- /**
- * @var array
- */
+ /** @var array Hidden from view */
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
*
* @return Bill
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+ * @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Bill
{
diff --git a/app/Models/Budget.php b/app/Models/Budget.php
index ab87f02080..106739fcec 100644
--- a/app/Models/Budget.php
+++ b/app/Models/Budget.php
@@ -26,6 +26,8 @@ use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
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\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -58,16 +60,18 @@ class Budget extends Model
'active' => 'boolean',
'encrypted' => 'boolean',
];
- /** @var array */
+ /** @var array Fields that can be filled */
protected $fillable = ['user_id', 'name', 'active'];
- /** @var array */
+ /** @var array Hidden from view */
protected $hidden = ['encrypted'];
/**
+ * Route binder. Converts the key in the URL to the specified object (or throw 404).
+ *
* @param string $value
*
* @return Budget
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+ * @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Budget
{
@@ -86,9 +90,9 @@ class Budget extends Model
/**
* @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);
}
@@ -126,18 +130,18 @@ class Budget extends Model
/**
* @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');
}
/**
* @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');
}
diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php
index 15f11689a2..2306e375de 100644
--- a/app/Models/BudgetLimit.php
+++ b/app/Models/BudgetLimit.php
@@ -54,13 +54,17 @@ class BudgetLimit extends Model
'start_date' => 'date',
'end_date' => 'date',
];
+
+ /** @var array Fields that can be filled */
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
*
* @return mixed
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+ * @throws NotFoundHttpException
*/
public static function routeBinder(string $value): BudgetLimit
{
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 359dd039e3..92e657d78f 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see