mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 03:08:11 +00:00
Various code fixes.
This commit is contained in:
@@ -17,6 +17,7 @@ parameters:
|
|||||||
- ../app/Console/Commands/Correction/FixAccountTypes.php
|
- ../app/Console/Commands/Correction/FixAccountTypes.php
|
||||||
- ../app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
|
- ../app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
|
||||||
- ../app/Exceptions/GracefulNotFoundHandler.php
|
- ../app/Exceptions/GracefulNotFoundHandler.php
|
||||||
|
- ../app/Generator/Webhook/StandardMessageGenerator.php
|
||||||
-
|
-
|
||||||
message: '#Function compact\(\) should not be used#'
|
message: '#Function compact\(\) should not be used#'
|
||||||
paths:
|
paths:
|
||||||
@@ -28,6 +29,9 @@ parameters:
|
|||||||
- ../app/Generator/Report/Standard/MultiYearReportGenerator.php
|
- ../app/Generator/Report/Standard/MultiYearReportGenerator.php
|
||||||
- ../app/Generator/Report/Standard/YearReportGenerator.php
|
- ../app/Generator/Report/Standard/YearReportGenerator.php
|
||||||
- ../app/Generator/Report/Tag/MonthReportGenerator.php
|
- ../app/Generator/Report/Tag/MonthReportGenerator.php
|
||||||
|
- ../app/Http/Controllers/Account/*.php
|
||||||
|
- ../app/Http/Controllers/Admin/*.php
|
||||||
|
- ../app/Http/Controllers/*.php
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
- ../app
|
- ../app
|
||||||
|
@@ -156,7 +156,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
|||||||
return [
|
return [
|
||||||
'journals' => $journals,
|
'journals' => $journals,
|
||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'exists' => !empty($journals),
|
'exists' => 0 !== count($journals),
|
||||||
'end' => $this->end->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)),
|
'end' => $this->end->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)),
|
||||||
'endBalance' => app('steam')->balance($account, $this->end),
|
'endBalance' => app('steam')->balance($account, $this->end),
|
||||||
'dayBefore' => $date->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)),
|
'dayBefore' => $date->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)),
|
||||||
|
@@ -180,7 +180,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
|||||||
*/
|
*/
|
||||||
protected function getExpenses(): array
|
protected function getExpenses(): array
|
||||||
{
|
{
|
||||||
if (!empty($this->expenses)) {
|
if (0 !== count($this->expenses)) {
|
||||||
Log::debug('Return previous set of expenses.');
|
Log::debug('Return previous set of expenses.');
|
||||||
|
|
||||||
return $this->expenses;
|
return $this->expenses;
|
||||||
|
@@ -188,7 +188,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
|||||||
*/
|
*/
|
||||||
protected function getExpenses(): array
|
protected function getExpenses(): array
|
||||||
{
|
{
|
||||||
if (!empty($this->expenses)) {
|
if (0 !== count($this->expenses)) {
|
||||||
Log::debug('Return previous set of expenses.');
|
Log::debug('Return previous set of expenses.');
|
||||||
|
|
||||||
return $this->expenses;
|
return $this->expenses;
|
||||||
@@ -213,7 +213,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
|||||||
*/
|
*/
|
||||||
protected function getIncome(): array
|
protected function getIncome(): array
|
||||||
{
|
{
|
||||||
if (!empty($this->income)) {
|
if (0 !== count($this->income)) {
|
||||||
return $this->income;
|
return $this->income;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UserEventHandler.php
|
* UserEventHandler.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@@ -149,6 +150,8 @@ class UserEventHandler
|
|||||||
$groupExists = true;
|
$groupExists = true;
|
||||||
$groupTitle = $user->email;
|
$groupTitle = $user->email;
|
||||||
$index = 1;
|
$index = 1;
|
||||||
|
/** @var UserGroup $group */
|
||||||
|
$group = null;
|
||||||
|
|
||||||
// create a new group.
|
// create a new group.
|
||||||
while (true === $groupExists) {
|
while (true === $groupExists) {
|
||||||
@@ -163,6 +166,7 @@ class UserEventHandler
|
|||||||
throw new FireflyException('Email address can no longer be used for registrations.');
|
throw new FireflyException('Email address can no longer be used for registrations.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/** @var UserRole $role */
|
||||||
$role = UserRole::where('title', UserRole::OWNER)->first();
|
$role = UserRole::where('title', UserRole::OWNER)->first();
|
||||||
if (null === $role) {
|
if (null === $role) {
|
||||||
throw new FireflyException('The user role is unexpectedly empty. Did you run all migrations?');
|
throw new FireflyException('The user role is unexpectedly empty. Did you run all migrations?');
|
||||||
@@ -266,7 +270,7 @@ class UserEventHandler
|
|||||||
$oldEmail = $event->oldEmail;
|
$oldEmail = $event->oldEmail;
|
||||||
$user = $event->user;
|
$user = $event->user;
|
||||||
$token = app('preferences')->getForUser($user, 'email_change_undo_token', 'invalid');
|
$token = app('preferences')->getForUser($user, 'email_change_undo_token', 'invalid');
|
||||||
$hashed = hash('sha256', sprintf('%s%s', (string) config('app.key'), $oldEmail));
|
$hashed = hash('sha256', sprintf('%s%s', (string)config('app.key'), $oldEmail));
|
||||||
$url = route('profile.undo-email-change', [$token->data, $hashed]);
|
$url = route('profile.undo-email-change', [$token->data, $hashed]);
|
||||||
try {
|
try {
|
||||||
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));
|
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));
|
||||||
|
@@ -372,7 +372,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function excludeJournalIds(array $journalIds): GroupCollectorInterface
|
public function excludeJournalIds(array $journalIds): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
if (!empty($journalIds)) {
|
if (0 !== count($journalIds)) {
|
||||||
// make all integers.
|
// make all integers.
|
||||||
$integerIDs = array_map('intval', $journalIds);
|
$integerIDs = array_map('intval', $journalIds);
|
||||||
|
|
||||||
@@ -894,7 +894,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function setJournalIds(array $journalIds): GroupCollectorInterface
|
public function setJournalIds(array $journalIds): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
if (!empty($journalIds)) {
|
if (0 !== count($journalIds)) {
|
||||||
// make all integers.
|
// make all integers.
|
||||||
$integerIDs = array_map('intval', $journalIds);
|
$integerIDs = array_map('intval', $journalIds);
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ class CreateController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||||
app('view')->share('title', (string) trans('firefly.accounts'));
|
app('view')->share('title', (string)trans('firefly.accounts'));
|
||||||
|
|
||||||
$this->repository = app(AccountRepositoryInterface::class);
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
$this->attachments = app(AttachmentHelperInterface::class);
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
@@ -75,16 +75,15 @@ class CreateController extends Controller
|
|||||||
* Create a new account.
|
* Create a new account.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param string|null $objectType
|
* @param string $objectType
|
||||||
*
|
*
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
*/
|
*/
|
||||||
public function create(Request $request, string $objectType = null)
|
public function create(Request $request, string $objectType)
|
||||||
{
|
{
|
||||||
$objectType = $objectType ?? 'asset';
|
|
||||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||||
$subTitle = (string) trans(sprintf('firefly.make_new_%s_account', $objectType));
|
$subTitle = (string)trans(sprintf('firefly.make_new_%s_account', $objectType));
|
||||||
$roles = $this->getRoles();
|
$roles = $this->getRoles();
|
||||||
$liabilityTypes = $this->getLiabilityTypes();
|
$liabilityTypes = $this->getLiabilityTypes();
|
||||||
$hasOldInput = null !== $request->old('_token');
|
$hasOldInput = null !== $request->old('_token');
|
||||||
@@ -103,9 +102,9 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
// interest calculation periods:
|
// interest calculation periods:
|
||||||
$interestPeriods = [
|
$interestPeriods = [
|
||||||
'daily' => (string) trans('firefly.interest_calc_daily'),
|
'daily' => (string)trans('firefly.interest_calc_daily'),
|
||||||
'monthly' => (string) trans('firefly.interest_calc_monthly'),
|
'monthly' => (string)trans('firefly.interest_calc_monthly'),
|
||||||
'yearly' => (string) trans('firefly.interest_calc_yearly'),
|
'yearly' => (string)trans('firefly.interest_calc_yearly'),
|
||||||
];
|
];
|
||||||
|
|
||||||
// pre fill some data
|
// pre fill some data
|
||||||
@@ -113,7 +112,7 @@ class CreateController extends Controller
|
|||||||
'preFilled',
|
'preFilled',
|
||||||
[
|
[
|
||||||
'currency_id' => $defaultCurrency->id,
|
'currency_id' => $defaultCurrency->id,
|
||||||
'include_net_worth' => $hasOldInput ? (bool) $request->old('include_net_worth') : true,
|
'include_net_worth' => $hasOldInput ? (bool)$request->old('include_net_worth') : true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -144,7 +143,7 @@ class CreateController extends Controller
|
|||||||
{
|
{
|
||||||
$data = $request->getAccountData();
|
$data = $request->getAccountData();
|
||||||
$account = $this->repository->store($data);
|
$account = $this->repository->store($data);
|
||||||
$request->session()->flash('success', (string) trans('firefly.stored_new_account', ['name' => $account->name]));
|
$request->session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
Log::channel('audit')->info('Stored new account.', $data);
|
Log::channel('audit')->info('Stored new account.', $data);
|
||||||
@@ -163,7 +162,7 @@ class CreateController extends Controller
|
|||||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||||
}
|
}
|
||||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
@@ -172,7 +171,7 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
// redirect to previous URL.
|
// redirect to previous URL.
|
||||||
$redirect = redirect($this->getPreviousUrl('accounts.create.url'));
|
$redirect = redirect($this->getPreviousUrl('accounts.create.url'));
|
||||||
if (1 === (int) $request->get('create_another')) {
|
if (1 === (int)$request->get('create_another')) {
|
||||||
// set value so create routine will not overwrite URL:
|
// set value so create routine will not overwrite URL:
|
||||||
$request->session()->put('accounts.create.fromStore', true);
|
$request->session()->put('accounts.create.fromStore', true);
|
||||||
|
|
||||||
|
@@ -79,7 +79,6 @@ class IndexController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function inactive(Request $request, string $objectType)
|
public function inactive(Request $request, string $objectType)
|
||||||
{
|
{
|
||||||
$objectType = $objectType ?? 'asset';
|
|
||||||
$inactivePage = true;
|
$inactivePage = true;
|
||||||
$subTitle = (string) trans(sprintf('firefly.%s_accounts_inactive', $objectType));
|
$subTitle = (string) trans(sprintf('firefly.%s_accounts_inactive', $objectType));
|
||||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||||
@@ -137,7 +136,6 @@ class IndexController extends Controller
|
|||||||
public function index(Request $request, string $objectType)
|
public function index(Request $request, string $objectType)
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||||
$objectType = $objectType ?? 'asset';
|
|
||||||
$subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType));
|
$subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType));
|
||||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||||
$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));
|
$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));
|
||||||
|
@@ -90,7 +90,7 @@ class ReconcileController extends Controller
|
|||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws \Psr\Container\ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null)
|
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
if (!$this->isEditableAccount($account)) {
|
if (!$this->isEditableAccount($account)) {
|
||||||
return $this->redirectAccountToAccount($account);
|
return $this->redirectAccountToAccount($account);
|
||||||
|
@@ -88,7 +88,7 @@ class ShowController extends Controller
|
|||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws \Psr\Container\ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null)
|
public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
|
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
|
||||||
|
|
||||||
|
@@ -81,8 +81,6 @@ class LoginController extends Controller
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return JsonResponse|RedirectResponse
|
|
||||||
*
|
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function login(Request $request)
|
public function login(Request $request)
|
||||||
|
@@ -126,7 +126,7 @@ class ResetPasswordController extends Controller
|
|||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws \Psr\Container\ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function showResetForm(Request $request, $token = null)
|
public function showResetForm(Request $request, $token = null) // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
$loginProvider = config('firefly.login_provider');
|
$loginProvider = config('firefly.login_provider');
|
||||||
if ('eloquent' !== $loginProvider) {
|
if ('eloquent' !== $loginProvider) {
|
||||||
|
@@ -96,7 +96,7 @@ class IndexController extends Controller
|
|||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws \Psr\Container\ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function index(Request $request, Carbon $start = null, Carbon $end = null)
|
public function index(Request $request, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
Log::debug('Start of IndexController::index()');
|
Log::debug('Start of IndexController::index()');
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ class IndexController extends Controller
|
|||||||
$sums = $this->getSums($budgets);
|
$sums = $this->getSums($budgets);
|
||||||
|
|
||||||
// get budgeted for default currency:
|
// get budgeted for default currency:
|
||||||
if (empty($availableBudgets)) {
|
if (0 === count($availableBudgets)) {
|
||||||
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency, );
|
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency, );
|
||||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
|
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
|
||||||
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
|
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
|
||||||
|
@@ -84,7 +84,7 @@ class ShowController extends Controller
|
|||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws \Psr\Container\ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function noBudget(Request $request, Carbon $start = null, Carbon $end = null)
|
public function noBudget(Request $request, Carbon $start = null, Carbon $end = null)// @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
$start = $start ?? session('start');
|
$start = $start ?? session('start');
|
||||||
|
@@ -80,7 +80,7 @@ class NoCategoryController extends Controller
|
|||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws \Psr\Container\ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function show(Request $request, Carbon $start = null, Carbon $end = null)
|
public function show(Request $request, Carbon $start = null, Carbon $end = null)// @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
Log::debug('Start of noCategory()');
|
Log::debug('Start of noCategory()');
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
|
@@ -82,7 +82,7 @@ class ShowController extends Controller
|
|||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws \Psr\Container\ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null)
|
public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
$start = $start ?? session('start', Carbon::now()->startOfMonth());
|
$start = $start ?? session('start', Carbon::now()->startOfMonth());
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountController.php
|
* AccountController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@@ -114,14 +115,14 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
// loop the end balances. This is an array for each account ($expenses)
|
// loop the end balances. This is an array for each account ($expenses)
|
||||||
foreach ($endBalances as $accountId => $expenses) {
|
foreach ($endBalances as $accountId => $expenses) {
|
||||||
$accountId = (int) $accountId;
|
$accountId = (int)$accountId;
|
||||||
// loop each expense entry (each entry can be a different currency).
|
// loop each expense entry (each entry can be a different currency).
|
||||||
foreach ($expenses as $currencyId => $endAmount) {
|
foreach ($expenses as $currencyId => $endAmount) {
|
||||||
$currencyId = (int) $currencyId;
|
$currencyId = (int)$currencyId;
|
||||||
|
|
||||||
// see if there is an accompanying start amount.
|
// see if there is an accompanying start amount.
|
||||||
// grab the difference and find the currency.
|
// grab the difference and find the currency.
|
||||||
$startAmount = (string) ($startBalances[$accountId][$currencyId] ?? '0');
|
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
|
||||||
$diff = bcsub((string)$endAmount, $startAmount);
|
$diff = bcsub((string)$endAmount, $startAmount);
|
||||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
||||||
if (0 !== bccomp($diff, '0')) {
|
if (0 !== bccomp($diff, '0')) {
|
||||||
@@ -129,7 +130,7 @@ class AccountController extends Controller
|
|||||||
$tempData[] = [
|
$tempData[] = [
|
||||||
'name' => $accountNames[$accountId],
|
'name' => $accountNames[$accountId],
|
||||||
'difference' => $diff,
|
'difference' => $diff,
|
||||||
'diff_float' => (float) $diff,
|
'diff_float' => (float)$diff,
|
||||||
'currency_id' => $currencyId,
|
'currency_id' => $currencyId,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -148,7 +149,7 @@ class AccountController extends Controller
|
|||||||
foreach ($currencies as $currencyId => $currency) {
|
foreach ($currencies as $currencyId => $currency) {
|
||||||
$dataSet
|
$dataSet
|
||||||
= [
|
= [
|
||||||
'label' => (string) trans('firefly.spent'),
|
'label' => (string)trans('firefly.spent'),
|
||||||
'type' => 'bar',
|
'type' => 'bar',
|
||||||
'currency_symbol' => $currency->symbol,
|
'currency_symbol' => $currency->symbol,
|
||||||
'currency_code' => $currency->code,
|
'currency_code' => $currency->code,
|
||||||
@@ -215,7 +216,7 @@ class AccountController extends Controller
|
|||||||
$budgetIds = [];
|
$budgetIds = [];
|
||||||
/** @var array $journal */
|
/** @var array $journal */
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$budgetId = (int) $journal['budget_id'];
|
$budgetId = (int)$journal['budget_id'];
|
||||||
$key = sprintf('%d-%d', $budgetId, $journal['currency_id']);
|
$key = sprintf('%d-%d', $budgetId, $journal['currency_id']);
|
||||||
$budgetIds[] = $budgetId;
|
$budgetIds[] = $budgetId;
|
||||||
if (!array_key_exists($key, $result)) {
|
if (!array_key_exists($key, $result)) {
|
||||||
@@ -235,7 +236,7 @@ class AccountController extends Controller
|
|||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$budgetId = $row['budget_id'];
|
$budgetId = $row['budget_id'];
|
||||||
$name = $names[$budgetId];
|
$name = $names[$budgetId];
|
||||||
$label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
||||||
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
|
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +296,7 @@ class AccountController extends Controller
|
|||||||
if (!array_key_exists($key, $result)) {
|
if (!array_key_exists($key, $result)) {
|
||||||
$result[$key] = [
|
$result[$key] = [
|
||||||
'total' => '0',
|
'total' => '0',
|
||||||
'category_id' => (int) $journal['category_id'],
|
'category_id' => (int)$journal['category_id'],
|
||||||
'currency_name' => $journal['currency_name'],
|
'currency_name' => $journal['currency_name'],
|
||||||
'currency_symbol' => $journal['currency_symbol'],
|
'currency_symbol' => $journal['currency_symbol'],
|
||||||
'currency_code' => $journal['currency_code'],
|
'currency_code' => $journal['currency_code'],
|
||||||
@@ -308,7 +309,7 @@ class AccountController extends Controller
|
|||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$categoryId = $row['category_id'];
|
$categoryId = $row['category_id'];
|
||||||
$name = $names[$categoryId] ?? '(unknown)';
|
$name = $names[$categoryId] ?? '(unknown)';
|
||||||
$label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
||||||
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
|
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +338,7 @@ class AccountController extends Controller
|
|||||||
Log::debug('Default set is ', $defaultSet);
|
Log::debug('Default set is ', $defaultSet);
|
||||||
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
||||||
Log::debug('Frontpage preference set is ', $frontPage->data);
|
Log::debug('Frontpage preference set is ', $frontPage->data);
|
||||||
if (empty($frontPage->data)) {
|
if (0 === count($frontPage->data)) {
|
||||||
app('preferences')->set('frontPageAccounts', $defaultSet);
|
app('preferences')->set('frontPageAccounts', $defaultSet);
|
||||||
Log::debug('frontpage set is empty!');
|
Log::debug('frontpage set is empty!');
|
||||||
}
|
}
|
||||||
@@ -410,7 +411,7 @@ class AccountController extends Controller
|
|||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$categoryId = $row['category_id'];
|
$categoryId = $row['category_id'];
|
||||||
$name = $names[$categoryId] ?? '(unknown)';
|
$name = $names[$categoryId] ?? '(unknown)';
|
||||||
$label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
||||||
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
|
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
|
||||||
}
|
}
|
||||||
$data = $this->generator->multiCurrencyPieChart($chartData);
|
$data = $this->generator->multiCurrencyPieChart($chartData);
|
||||||
@@ -478,38 +479,31 @@ class AccountController extends Controller
|
|||||||
'label' => sprintf('%s (%s)', $account->name, $currency->symbol),
|
'label' => sprintf('%s (%s)', $account->name, $currency->symbol),
|
||||||
'currency_symbol' => $currency->symbol,
|
'currency_symbol' => $currency->symbol,
|
||||||
'currency_code' => $currency->code,
|
'currency_code' => $currency->code,
|
||||||
'entries' => [],
|
|
||||||
];
|
];
|
||||||
$entries = [];
|
$entries = [];
|
||||||
$current = clone $start;
|
$current = clone $start;
|
||||||
switch ($step) {
|
|
||||||
default:
|
if ('1D' === $step) {
|
||||||
break;
|
|
||||||
case '1D':
|
|
||||||
// per day the entire period, balance for every day.
|
// per day the entire period, balance for every day.
|
||||||
$format = (string) trans('config.month_and_day_js', [], $locale);
|
$format = (string)trans('config.month_and_day_js', [], $locale);
|
||||||
$range = app('steam')->balanceInRange($account, $start, $end, $currency);
|
$range = app('steam')->balanceInRange($account, $start, $end, $currency);
|
||||||
$previous = array_values($range)[0];
|
$previous = array_values($range)[0];
|
||||||
while ($end >= $current) {
|
while ($end >= $current) {
|
||||||
$theDate = $current->format('Y-m-d');
|
$theDate = $current->format('Y-m-d');
|
||||||
$balance = $range[$theDate] ?? $previous;
|
$balance = $range[$theDate] ?? $previous;
|
||||||
$label = $current->isoFormat($format);
|
$label = $current->isoFormat($format);
|
||||||
$entries[$label] = (float) $balance;
|
$entries[$label] = (float)$balance;
|
||||||
$previous = $balance;
|
$previous = $balance;
|
||||||
$current->addDay();
|
$current->addDay();
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
if ('1W' === $step || '1M' === $step || '1Y' === $step) {
|
||||||
case '1W':
|
|
||||||
case '1M':
|
|
||||||
case '1Y':
|
|
||||||
while ($end >= $current) {
|
while ($end >= $current) {
|
||||||
$balance = (float) app('steam')->balance($account, $current, $currency);
|
$balance = (float)app('steam')->balance($account, $current, $currency);
|
||||||
$label = app('navigation')->periodShow($current, $step);
|
$label = app('navigation')->periodShow($current, $step);
|
||||||
$entries[$label] = $balance;
|
$entries[$label] = $balance;
|
||||||
$current = app('navigation')->addPeriod($current, $step, 0);
|
$current = app('navigation')->addPeriod($current, $step, 0);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
$result['entries'] = $entries;
|
$result['entries'] = $entries;
|
||||||
|
|
||||||
@@ -572,22 +566,22 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
// loop the end balances. This is an array for each account ($expenses)
|
// loop the end balances. This is an array for each account ($expenses)
|
||||||
foreach ($endBalances as $accountId => $expenses) {
|
foreach ($endBalances as $accountId => $expenses) {
|
||||||
$accountId = (int) $accountId;
|
$accountId = (int)$accountId;
|
||||||
// loop each expense entry (each entry can be a different currency).
|
// loop each expense entry (each entry can be a different currency).
|
||||||
foreach ($expenses as $currencyId => $endAmount) {
|
foreach ($expenses as $currencyId => $endAmount) {
|
||||||
$currencyId = (int) $currencyId;
|
$currencyId = (int)$currencyId;
|
||||||
|
|
||||||
// see if there is an accompanying start amount.
|
// see if there is an accompanying start amount.
|
||||||
// grab the difference and find the currency.
|
// grab the difference and find the currency.
|
||||||
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
|
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
|
||||||
$diff = bcsub((string) $endAmount, $startAmount);
|
$diff = bcsub((string)$endAmount, $startAmount);
|
||||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
||||||
if (0 !== bccomp($diff, '0')) {
|
if (0 !== bccomp($diff, '0')) {
|
||||||
// store the values in a temporary array.
|
// store the values in a temporary array.
|
||||||
$tempData[] = [
|
$tempData[] = [
|
||||||
'name' => $accountNames[$accountId],
|
'name' => $accountNames[$accountId],
|
||||||
'difference' => $diff,
|
'difference' => $diff,
|
||||||
'diff_float' => (float) $diff,
|
'diff_float' => (float)$diff,
|
||||||
'currency_id' => $currencyId,
|
'currency_id' => $currencyId,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -606,7 +600,7 @@ class AccountController extends Controller
|
|||||||
foreach ($currencies as $currencyId => $currency) {
|
foreach ($currencies as $currencyId => $currency) {
|
||||||
$dataSet
|
$dataSet
|
||||||
= [
|
= [
|
||||||
'label' => (string) trans('firefly.earned'),
|
'label' => (string)trans('firefly.earned'),
|
||||||
'type' => 'bar',
|
'type' => 'bar',
|
||||||
'currency_symbol' => $currency->symbol,
|
'currency_symbol' => $currency->symbol,
|
||||||
'currency_code' => $currency->code,
|
'currency_code' => $currency->code,
|
||||||
|
@@ -205,7 +205,7 @@ class BudgetController extends Controller
|
|||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function expenseAsset(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse
|
public function expenseAsset(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
@@ -273,7 +273,7 @@ class BudgetController extends Controller
|
|||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function expenseCategory(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse
|
public function expenseCategory(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
@@ -337,7 +337,7 @@ class BudgetController extends Controller
|
|||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function expenseExpense(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse
|
public function expenseExpense(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CategoryController.php
|
* CategoryController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@@ -23,7 +24,6 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Chart;
|
namespace FireflyIII\Http\Controllers\Chart;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Exception;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
@@ -39,7 +39,6 @@ use FireflyIII\Support\Http\Controllers\ChartGeneration;
|
|||||||
use FireflyIII\Support\Http\Controllers\DateCalculation;
|
use FireflyIII\Support\Http\Controllers\DateCalculation;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use JsonException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CategoryController.
|
* Class CategoryController.
|
||||||
@@ -106,14 +105,7 @@ class CategoryController extends Controller
|
|||||||
*/
|
*/
|
||||||
private function getDate(): Carbon
|
private function getDate(): Carbon
|
||||||
{
|
{
|
||||||
$carbon = null;
|
return today(config('app.timezone'));
|
||||||
try {
|
|
||||||
$carbon = today(config('app.timezone'));
|
|
||||||
} catch (Exception $e) {
|
|
||||||
// @ignoreException
|
|
||||||
}
|
|
||||||
|
|
||||||
return $carbon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,7 +191,7 @@ class CategoryController extends Controller
|
|||||||
if (null !== $category) {
|
if (null !== $category) {
|
||||||
/** @var OperationsRepositoryInterface $opsRepository */
|
/** @var OperationsRepositoryInterface $opsRepository */
|
||||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
$categoryId = (int) $category->id;
|
$categoryId = (int)$category->id;
|
||||||
// this gives us all currencies
|
// this gives us all currencies
|
||||||
$collection = new Collection([$category]);
|
$collection = new Collection([$category]);
|
||||||
$expenses = $opsRepository->listExpenses($start, $end, null, $collection);
|
$expenses = $opsRepository->listExpenses($start, $end, null, $collection);
|
||||||
@@ -217,7 +209,7 @@ class CategoryController extends Controller
|
|||||||
$inKey = sprintf('%d-in', $currencyId);
|
$inKey = sprintf('%d-in', $currencyId);
|
||||||
$chartData[$outKey]
|
$chartData[$outKey]
|
||||||
= [
|
= [
|
||||||
'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currencyInfo['currency_name']),
|
'label' => sprintf('%s (%s)', (string)trans('firefly.spent'), $currencyInfo['currency_name']),
|
||||||
'entries' => [],
|
'entries' => [],
|
||||||
'type' => 'bar',
|
'type' => 'bar',
|
||||||
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
|
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
|
||||||
@@ -225,7 +217,7 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
$chartData[$inKey]
|
$chartData[$inKey]
|
||||||
= [
|
= [
|
||||||
'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']),
|
'label' => sprintf('%s (%s)', (string)trans('firefly.earned'), $currencyInfo['currency_name']),
|
||||||
'entries' => [],
|
'entries' => [],
|
||||||
'type' => 'bar',
|
'type' => 'bar',
|
||||||
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
||||||
|
@@ -318,7 +318,7 @@ class DoubleReportController extends Controller
|
|||||||
$journalId = $journal['transaction_journal_id'];
|
$journalId = $journal['transaction_journal_id'];
|
||||||
|
|
||||||
// no tags? also deserves a sport
|
// no tags? also deserves a sport
|
||||||
if (empty($journal['tags'])) {
|
if (0 === count($journal['tags'])) {
|
||||||
$includedJournals[] = $journalId;
|
$includedJournals[] = $journalId;
|
||||||
// do something
|
// do something
|
||||||
$tagName = trans('firefly.no_tags');
|
$tagName = trans('firefly.no_tags');
|
||||||
@@ -378,7 +378,7 @@ class DoubleReportController extends Controller
|
|||||||
$journalId = $journal['transaction_journal_id'];
|
$journalId = $journal['transaction_journal_id'];
|
||||||
|
|
||||||
// no tags? also deserves a sport
|
// no tags? also deserves a sport
|
||||||
if (empty($journal['tags'])) {
|
if (0 === count($journal['tags'])) {
|
||||||
$includedJournals[] = $journalId;
|
$includedJournals[] = $journalId;
|
||||||
// do something
|
// do something
|
||||||
$tagName = trans('firefly.no_tags');
|
$tagName = trans('firefly.no_tags');
|
||||||
|
@@ -189,7 +189,7 @@ class ExpenseReportController extends Controller
|
|||||||
$newSet[$key] = $entry;
|
$newSet[$key] = $entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($newSet)) {
|
if (0 === count($newSet)) {
|
||||||
$newSet = $chartData;
|
$newSet = $chartData;
|
||||||
}
|
}
|
||||||
$data = $this->generator->multiSet($newSet);
|
$data = $this->generator->multiSet($newSet);
|
||||||
|
@@ -115,20 +115,17 @@ class TransactionController extends Controller
|
|||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->withCategoryInformation();
|
$collector->withCategoryInformation();
|
||||||
switch ($objectType) {
|
|
||||||
default:
|
if ('withdrawal' === $objectType) {
|
||||||
throw new FireflyException(sprintf('Cant handle "%s"', $objectType));
|
|
||||||
case 'withdrawal':
|
|
||||||
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
break;
|
|
||||||
case 'deposit':
|
|
||||||
$collector->setTypes([TransactionType::DEPOSIT]);
|
|
||||||
break;
|
|
||||||
case 'transfers':
|
|
||||||
case 'transfer':
|
|
||||||
$collector->setTypes([TransactionType::TRANSFER]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if ('deposit' === $objectType) {
|
||||||
|
$collector->setTypes([TransactionType::DEPOSIT]);
|
||||||
|
}
|
||||||
|
if ('transfer' === $objectType || 'transfers' === $objectType) {
|
||||||
|
$collector->setTypes([TransactionType::TRANSFER]);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $collector->getExtractedJournals();
|
$result = $collector->getExtractedJournals();
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
@@ -172,20 +169,17 @@ class TransactionController extends Controller
|
|||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->withAccountInformation();
|
$collector->withAccountInformation();
|
||||||
switch ($objectType) {
|
|
||||||
default:
|
if ('withdrawal' === $objectType) {
|
||||||
throw new FireflyException(sprintf('Cant handle "%s"', $objectType));
|
|
||||||
case 'withdrawal':
|
|
||||||
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
break;
|
|
||||||
case 'deposit':
|
|
||||||
$collector->setTypes([TransactionType::DEPOSIT]);
|
|
||||||
break;
|
|
||||||
case 'transfers':
|
|
||||||
case 'transfer':
|
|
||||||
$collector->setTypes([TransactionType::TRANSFER]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if ('deposit' === $objectType) {
|
||||||
|
$collector->setTypes([TransactionType::DEPOSIT]);
|
||||||
|
}
|
||||||
|
if ('transfer' === $objectType || 'transfers' === $objectType) {
|
||||||
|
$collector->setTypes([TransactionType::TRANSFER]);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $collector->getExtractedJournals();
|
$result = $collector->getExtractedJournals();
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
@@ -229,20 +223,17 @@ class TransactionController extends Controller
|
|||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->withAccountInformation();
|
$collector->withAccountInformation();
|
||||||
switch ($objectType) {
|
|
||||||
default:
|
if ('withdrawal' === $objectType) {
|
||||||
throw new FireflyException(sprintf('Cant handle "%s"', $objectType));
|
|
||||||
case 'withdrawal':
|
|
||||||
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
break;
|
|
||||||
case 'deposit':
|
|
||||||
$collector->setTypes([TransactionType::DEPOSIT]);
|
|
||||||
break;
|
|
||||||
case 'transfers':
|
|
||||||
case 'transfer':
|
|
||||||
$collector->setTypes([TransactionType::TRANSFER]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if ('deposit' === $objectType) {
|
||||||
|
$collector->setTypes([TransactionType::DEPOSIT]);
|
||||||
|
}
|
||||||
|
if ('transfer' === $objectType || 'transfers' === $objectType) {
|
||||||
|
$collector->setTypes([TransactionType::TRANSFER]);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $collector->getExtractedJournals();
|
$result = $collector->getExtractedJournals();
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
|
@@ -98,7 +98,7 @@ class DebugController extends Controller
|
|||||||
Log::debug('Call twig:clean...');
|
Log::debug('Call twig:clean...');
|
||||||
try {
|
try {
|
||||||
Artisan::call('twig:clean');
|
Artisan::call('twig:clean');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) { // @phpstan-ignore-line
|
||||||
// @ignoreException
|
// @ignoreException
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ class DebugController extends Controller
|
|||||||
if (null !== $logFile) {
|
if (null !== $logFile) {
|
||||||
try {
|
try {
|
||||||
$logContent = file_get_contents($logFile);
|
$logContent = file_get_contents($logFile);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) { // @phpstan-ignore-line
|
||||||
// @ignoreException
|
// @ignoreException
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -190,7 +190,7 @@ class BoxController extends Controller
|
|||||||
$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);
|
$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);
|
||||||
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
|
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
|
||||||
}
|
}
|
||||||
if (empty($sums)) {
|
if (0 === count($sums)) {
|
||||||
$currency = app('amount')->getDefaultCurrency();
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
$sums[$currency->id] = app('amount')->formatAnything($currency, '0', false);
|
$sums[$currency->id] = app('amount')->formatAnything($currency, '0', false);
|
||||||
$incomes[$currency->id] = app('amount')->formatAnything($currency, '0', false);
|
$incomes[$currency->id] = app('amount')->formatAnything($currency, '0', false);
|
||||||
|
@@ -68,7 +68,7 @@ class FrontpageController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$html = '';
|
$html = '';
|
||||||
if (!empty($info)) {
|
if (0 !== count($info)) {
|
||||||
try {
|
try {
|
||||||
$html = view('json.piggy-banks', compact('info'))->render();
|
$html = view('json.piggy-banks', compact('info'))->render();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
|
@@ -43,13 +43,13 @@ class IntroController extends Controller
|
|||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function getIntroSteps(string $route, string $specificPage = null): JsonResponse
|
public function getIntroSteps(string $route, string $specificPage = null): JsonResponse // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage));
|
Log::debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage));
|
||||||
$specificPage = $specificPage ?? '';
|
$specificPage = $specificPage ?? '';
|
||||||
$steps = $this->getBasicSteps($route);
|
$steps = $this->getBasicSteps($route);
|
||||||
$specificSteps = $this->getSpecificSteps($route, $specificPage);
|
$specificSteps = $this->getSpecificSteps($route, $specificPage);
|
||||||
if (empty($specificSteps)) {
|
if (0 === count($specificSteps)) {
|
||||||
Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage));
|
Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage));
|
||||||
|
|
||||||
return response()->json($steps);
|
return response()->json($steps);
|
||||||
@@ -104,7 +104,7 @@ class IntroController extends Controller
|
|||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function postEnable(string $route, string $specialPage = null): JsonResponse
|
public function postEnable(string $route, string $specialPage = null): JsonResponse // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
$specialPage = $specialPage ?? '';
|
$specialPage = $specialPage ?? '';
|
||||||
$route = str_replace('.', '_', $route);
|
$route = str_replace('.', '_', $route);
|
||||||
@@ -128,7 +128,7 @@ class IntroController extends Controller
|
|||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function postFinished(string $route, string $specialPage = null): JsonResponse
|
public function postFinished(string $route, string $specialPage = null): JsonResponse // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
$specialPage = $specialPage ?? '';
|
$specialPage = $specialPage ?? '';
|
||||||
$key = 'shown_demo_' . $route;
|
$key = 'shown_demo_' . $route;
|
||||||
|
@@ -85,7 +85,7 @@ class ReconcileController extends Controller
|
|||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function overview(Request $request, Account $account = null, Carbon $start = null, Carbon $end = null): JsonResponse
|
public function overview(Request $request, Account $account = null, Carbon $start = null, Carbon $end = null): JsonResponse // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
$startBalance = $request->get('startBalance');
|
$startBalance = $request->get('startBalance');
|
||||||
$endBalance = $request->get('endBalance');
|
$endBalance = $request->get('endBalance');
|
||||||
@@ -226,7 +226,7 @@ class ReconcileController extends Controller
|
|||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function transactions(Account $account, Carbon $start = null, Carbon $end = null)
|
public function transactions(Account $account, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
|
||||||
{
|
{
|
||||||
if (null === $start || null === $end) {
|
if (null === $start || null === $end) {
|
||||||
throw new FireflyException('Invalid dates submitted.');
|
throw new FireflyException('Invalid dates submitted.');
|
||||||
|
@@ -127,7 +127,7 @@ class PreferencesController extends Controller
|
|||||||
$locales = ['equal' => (string) trans('firefly.equal_to_language')] + $locales;
|
$locales = ['equal' => (string) trans('firefly.equal_to_language')] + $locales;
|
||||||
// an important fallback is that the frontPageAccount array gets refilled automatically
|
// an important fallback is that the frontPageAccount array gets refilled automatically
|
||||||
// when it turns up empty.
|
// when it turns up empty.
|
||||||
if (empty($frontPageAccounts->data)) {
|
if (0 === count($frontPageAccounts->data)) {
|
||||||
$frontPageAccounts = $accountIds;
|
$frontPageAccounts = $accountIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -728,7 +728,7 @@ class CategoryController extends Controller
|
|||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||||
$result = sprintf('Could not render view: %s', $e->getMessage());
|
$result = sprintf('Could not render view: %s', $e->getMessage());
|
||||||
throw new FireflyException($result, 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -778,7 +778,7 @@ class CategoryController extends Controller
|
|||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||||
$result = sprintf('Could not render view: %s', $e->getMessage());
|
$result = sprintf('Could not render view: %s', $e->getMessage());
|
||||||
throw new FireflyException($result, 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@@ -115,7 +115,7 @@ class DoubleController extends Controller
|
|||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||||
$result = sprintf('Could not render view: %s', $e->getMessage());
|
$result = sprintf('Could not render view: %s', $e->getMessage());
|
||||||
throw new FireflyException($result, 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -167,7 +167,7 @@ class DoubleController extends Controller
|
|||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||||
$result = sprintf('Could not render view: %s', $e->getMessage());
|
$result = sprintf('Could not render view: %s', $e->getMessage());
|
||||||
throw new FireflyException($result, 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -461,7 +461,7 @@ class DoubleController extends Controller
|
|||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||||
$result = sprintf('Could not render view: %s', $e->getMessage());
|
$result = sprintf('Could not render view: %s', $e->getMessage());
|
||||||
throw new FireflyException($result, 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -511,7 +511,7 @@ class DoubleController extends Controller
|
|||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||||
$result = sprintf('Could not render view: %s', $e->getMessage());
|
$result = sprintf('Could not render view: %s', $e->getMessage());
|
||||||
throw new FireflyException($result, 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@@ -145,7 +145,7 @@ class SelectController extends Controller
|
|||||||
$textTriggers = $this->getValidTriggerList($request);
|
$textTriggers = $this->getValidTriggerList($request);
|
||||||
|
|
||||||
// warn if nothing.
|
// warn if nothing.
|
||||||
if (empty($textTriggers)) {
|
if (0 === count($textTriggers)) {
|
||||||
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
|
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ class SelectController extends Controller
|
|||||||
|
|
||||||
// Warn the user if only a subset of transactions is returned
|
// Warn the user if only a subset of transactions is returned
|
||||||
$warning = '';
|
$warning = '';
|
||||||
if (empty($collection)) {
|
if (0 === count($collection)) {
|
||||||
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ class SelectController extends Controller
|
|||||||
{
|
{
|
||||||
$triggers = $rule->ruleTriggers;
|
$triggers = $rule->ruleTriggers;
|
||||||
|
|
||||||
if (empty($triggers)) {
|
if (0 === count($triggers)) {
|
||||||
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
|
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
|
||||||
}
|
}
|
||||||
// create new rule engine:
|
// create new rule engine:
|
||||||
@@ -212,7 +212,7 @@ class SelectController extends Controller
|
|||||||
$collection = $collection->slice(0, 20);
|
$collection = $collection->slice(0, 20);
|
||||||
|
|
||||||
$warning = '';
|
$warning = '';
|
||||||
if (empty($collection)) {
|
if (0 === count($collection)) {
|
||||||
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -87,7 +87,7 @@ class Authenticate
|
|||||||
*/
|
*/
|
||||||
protected function authenticate($request, array $guards)
|
protected function authenticate($request, array $guards)
|
||||||
{
|
{
|
||||||
if (empty($guards)) {
|
if (0 === count($guards)) {
|
||||||
try {
|
try {
|
||||||
// go for default guard:
|
// go for default guard:
|
||||||
if ($this->auth->check()) {
|
if ($this->auth->check()) {
|
||||||
|
@@ -296,7 +296,7 @@ class TransactionJournal extends Model
|
|||||||
if (!self::isJoined($query, 'transaction_types')) {
|
if (!self::isJoined($query, 'transaction_types')) {
|
||||||
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
|
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
|
||||||
}
|
}
|
||||||
if (!empty($types)) {
|
if (0 !== count($types)) {
|
||||||
$query->whereIn('transaction_types.type', $types);
|
$query->whereIn('transaction_types.type', $types);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -142,7 +142,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!empty($types)) {
|
if (0 !== count($types)) {
|
||||||
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$dbQuery->whereIn('account_types.type', $types);
|
$dbQuery->whereIn('account_types.type', $types);
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
{
|
{
|
||||||
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
|
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
|
||||||
|
|
||||||
if (!empty($types)) {
|
if (0 !== count($types)) {
|
||||||
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$query->whereIn('account_types.type', $types);
|
$query->whereIn('account_types.type', $types);
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
{
|
{
|
||||||
$query = $this->user->accounts();
|
$query = $this->user->accounts();
|
||||||
|
|
||||||
if (!empty($types)) {
|
if (0 !== count($types)) {
|
||||||
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$query->whereIn('account_types.type', $types);
|
$query->whereIn('account_types.type', $types);
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
{
|
{
|
||||||
$query = $this->user->accounts();
|
$query = $this->user->accounts();
|
||||||
|
|
||||||
if (!empty($accountIds)) {
|
if (0 !== count($accountIds)) {
|
||||||
$query->whereIn('accounts.id', $accountIds);
|
$query->whereIn('accounts.id', $accountIds);
|
||||||
}
|
}
|
||||||
$query->orderBy('accounts.order', 'ASC');
|
$query->orderBy('accounts.order', 'ASC');
|
||||||
@@ -240,7 +240,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
$query->where('name', 'account_role');
|
$query->where('name', 'account_role');
|
||||||
}, 'attachments']
|
}, 'attachments']
|
||||||
);
|
);
|
||||||
if (!empty($types)) {
|
if (0 !== count($types)) {
|
||||||
$query->accountTypeIn($types);
|
$query->accountTypeIn($types);
|
||||||
}
|
}
|
||||||
$query->where('active', true);
|
$query->where('active', true);
|
||||||
@@ -316,7 +316,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
$query->where('name', 'account_role');
|
$query->where('name', 'account_role');
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
if (!empty($types)) {
|
if (0 !== count($types)) {
|
||||||
$query->accountTypeIn($types);
|
$query->accountTypeIn($types);
|
||||||
}
|
}
|
||||||
$query->where('active', 0);
|
$query->where('active', 0);
|
||||||
@@ -585,19 +585,19 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
{
|
{
|
||||||
$res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);
|
$res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);
|
||||||
$query = $this->user->accounts();
|
$query = $this->user->accounts();
|
||||||
if (!empty($types)) {
|
if (0 !== count($types)) {
|
||||||
$query->accountTypeIn($types);
|
$query->accountTypeIn($types);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add sort parameters. At this point they're filtered to allowed fields to sort by:
|
// add sort parameters. At this point they're filtered to allowed fields to sort by:
|
||||||
if (!empty($sort)) {
|
if (0 !== count($sort)) {
|
||||||
foreach ($sort as $param) {
|
foreach ($sort as $param) {
|
||||||
$query->orderBy($param[0], $param[1]);
|
$query->orderBy($param[0], $param[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($sort)) {
|
if (0 === count($sort)) {
|
||||||
if (!empty($res)) {
|
if (0 !== count($res)) {
|
||||||
$query->orderBy('accounts.order', 'ASC');
|
$query->orderBy('accounts.order', 'ASC');
|
||||||
}
|
}
|
||||||
$query->orderBy('accounts.active', 'DESC');
|
$query->orderBy('accounts.active', 'DESC');
|
||||||
@@ -698,7 +698,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
$dbQuery->where('name', 'LIKE', $search);
|
$dbQuery->where('name', 'LIKE', $search);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($types)) {
|
if (0 !== count($types)) {
|
||||||
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$dbQuery->whereIn('account_types.type', $types);
|
$dbQuery->whereIn('account_types.type', $types);
|
||||||
}
|
}
|
||||||
@@ -736,7 +736,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($types)) {
|
if (0 !== count($types)) {
|
||||||
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$dbQuery->whereIn('account_types.type', $types);
|
$dbQuery->whereIn('account_types.type', $types);
|
||||||
}
|
}
|
||||||
|
@@ -332,7 +332,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
|||||||
foreach ($journalMeta as $journalId) {
|
foreach ($journalMeta as $journalId) {
|
||||||
$search[] = (int) $journalId;
|
$search[] = (int) $journalId;
|
||||||
}
|
}
|
||||||
if (empty($search)) {
|
if (0 === count($search)) {
|
||||||
return new Collection();
|
return new Collection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@ class CreditRecalculateService
|
|||||||
// work based on account.
|
// work based on account.
|
||||||
$this->processAccount();
|
$this->processAccount();
|
||||||
}
|
}
|
||||||
if (empty($this->work)) {
|
if (0 === count($this->work)) {
|
||||||
Log::debug('No work accounts, do not do CreditRecalculationService');
|
Log::debug('No work accounts, do not do CreditRecalculationService');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -84,7 +84,7 @@ class CreditRecalculateService
|
|||||||
{
|
{
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
foreach ($this->group->transactionJournals as $journal) {
|
foreach ($this->group->transactionJournals as $journal) {
|
||||||
if (empty($this->work)) {
|
if (0 === count($this->work)) {
|
||||||
try {
|
try {
|
||||||
$this->findByJournal($journal);
|
$this->findByJournal($journal);
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
|
@@ -339,7 +339,7 @@ trait RecurringTransactionTrait
|
|||||||
*/
|
*/
|
||||||
protected function updateTags(RecurrenceTransaction $transaction, array $tags): void
|
protected function updateTags(RecurrenceTransaction $transaction, array $tags): void
|
||||||
{
|
{
|
||||||
if (!empty($tags)) {
|
if (0 !== count($tags)) {
|
||||||
/** @var RecurrenceMeta|null $entry */
|
/** @var RecurrenceMeta|null $entry */
|
||||||
$entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first();
|
$entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first();
|
||||||
if (null === $entry) {
|
if (null === $entry) {
|
||||||
@@ -348,7 +348,7 @@ trait RecurringTransactionTrait
|
|||||||
$entry->value = json_encode($tags);
|
$entry->value = json_encode($tags);
|
||||||
$entry->save();
|
$entry->save();
|
||||||
}
|
}
|
||||||
if (empty($tags)) {
|
if (0 === count($tags)) {
|
||||||
// delete if present
|
// delete if present
|
||||||
$transaction->recurrenceTransactionMeta()->where('name', 'tags')->delete();
|
$transaction->recurrenceTransactionMeta()->where('name', 'tags')->delete();
|
||||||
}
|
}
|
||||||
|
@@ -60,7 +60,7 @@ class GroupUpdateService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (empty($transactions)) {
|
if (0 === count($transactions)) {
|
||||||
Log::debug('No transactions submitted, do nothing.');
|
Log::debug('No transactions submitted, do nothing.');
|
||||||
|
|
||||||
return $transactionGroup;
|
return $transactionGroup;
|
||||||
@@ -119,7 +119,7 @@ class GroupUpdateService
|
|||||||
private function updateTransactionJournal(TransactionGroup $transactionGroup, TransactionJournal $journal, array $data): void
|
private function updateTransactionJournal(TransactionGroup $transactionGroup, TransactionJournal $journal, array $data): void
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||||
if (empty($data)) {
|
if (0 === count($data)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (1 === count($data) && array_key_exists('transaction_journal_id', $data)) {
|
if (1 === count($data) && array_key_exists('transaction_journal_id', $data)) {
|
||||||
|
@@ -150,7 +150,7 @@ class RecurrenceUpdateService
|
|||||||
private function updateRepetitions(Recurrence $recurrence, array $repetitions): void
|
private function updateRepetitions(Recurrence $recurrence, array $repetitions): void
|
||||||
{
|
{
|
||||||
$originalCount = $recurrence->recurrenceRepetitions()->count();
|
$originalCount = $recurrence->recurrenceRepetitions()->count();
|
||||||
if (empty($repetitions)) {
|
if (0 === count($repetitions)) {
|
||||||
// wont drop repetition, rather avoid.
|
// wont drop repetition, rather avoid.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,7 @@ class RecurrenceUpdateService
|
|||||||
private function updateTransactions(Recurrence $recurrence, array $transactions): void
|
private function updateTransactions(Recurrence $recurrence, array $transactions): void
|
||||||
{
|
{
|
||||||
$originalCount = $recurrence->recurrenceTransactions()->count();
|
$originalCount = $recurrence->recurrenceTransactions()->count();
|
||||||
if (empty($transactions)) {
|
if (0 === count($transactions)) {
|
||||||
// wont drop transactions, rather avoid.
|
// wont drop transactions, rather avoid.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,7 @@ class BudgetList implements BinderInterface
|
|||||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||||
|
|
||||||
|
|
||||||
if (empty($list)) {
|
if (0 === count($list)) {
|
||||||
app('log')->warning('Budget list count is zero, return 404.');
|
app('log')->warning('Budget list count is zero, return 404.');
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ class CategoryList implements BinderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||||
if (empty($list)) {
|
if (0 === count($list)) {
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ class JournalList implements BinderInterface
|
|||||||
$collector->withCategoryInformation()->withBudgetInformation()->withTagInformation()->withAccountInformation();
|
$collector->withCategoryInformation()->withBudgetInformation()->withTagInformation()->withAccountInformation();
|
||||||
$collector->setJournalIds($list);
|
$collector->setJournalIds($list);
|
||||||
$result = $collector->getExtractedJournals();
|
$result = $collector->getExtractedJournals();
|
||||||
if (empty($result)) {
|
if (0 === count($result)) {
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ class JournalList implements BinderInterface
|
|||||||
protected static function parseList(string $value): array
|
protected static function parseList(string $value): array
|
||||||
{
|
{
|
||||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||||
if (empty($list)) {
|
if (0 === count($list)) {
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ class TagList implements BinderInterface
|
|||||||
$list = array_unique(array_map('\strtolower', explode(',', $value)));
|
$list = array_unique(array_map('\strtolower', explode(',', $value)));
|
||||||
Log::debug('List of tags is', $list);
|
Log::debug('List of tags is', $list);
|
||||||
|
|
||||||
if (empty($list)) {
|
if (0 === count($list)) {
|
||||||
Log::error('Tag list is empty.');
|
Log::error('Tag list is empty.');
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
@@ -767,7 +767,7 @@ class ExportDataGenerator
|
|||||||
*/
|
*/
|
||||||
private function mergeTags(array $tags): string
|
private function mergeTags(array $tags): string
|
||||||
{
|
{
|
||||||
if (empty($tags)) {
|
if (0 === count($tags)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$smol = [];
|
$smol = [];
|
||||||
|
@@ -1993,7 +1993,7 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
*/
|
*/
|
||||||
public function searchTransactions(): LengthAwarePaginator
|
public function searchTransactions(): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
if (empty($this->getWords()) && empty($this->getOperators())) {
|
if (0 === count($this->getWords()) && 0 === count($this->getOperators())) {
|
||||||
return new LengthAwarePaginator([], 0, 5, 1);
|
return new LengthAwarePaginator([], 0, 5, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -92,7 +92,7 @@ class ActionFactory
|
|||||||
*/
|
*/
|
||||||
protected static function getActionTypes(): array
|
protected static function getActionTypes(): array
|
||||||
{
|
{
|
||||||
if (empty(self::$actionTypes)) {
|
if (0 === count(self::$actionTypes)) {
|
||||||
self::$actionTypes = Domain::getRuleActions();
|
self::$actionTypes = Domain::getRuleActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -126,7 +126,7 @@ trait RecurrenceValidation
|
|||||||
$data = $validator->getData();
|
$data = $validator->getData();
|
||||||
$repetitions = $data['repetitions'] ?? [];
|
$repetitions = $data['repetitions'] ?? [];
|
||||||
// need at least one transaction
|
// need at least one transaction
|
||||||
if (!is_countable($repetitions) || empty($repetitions)) {
|
if (!is_countable($repetitions) || 0 === count($repetitions)) {
|
||||||
$validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition'));
|
$validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ trait RecurrenceValidation
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// need at least one transaction
|
// need at least one transaction
|
||||||
if (empty($repetitions)) {
|
if (0 === count($repetitions)) {
|
||||||
$validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition'));
|
$validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -312,7 +312,7 @@ trait TransactionValidation
|
|||||||
$transactions = $this->getTransactionsArray($validator);
|
$transactions = $this->getTransactionsArray($validator);
|
||||||
|
|
||||||
// need at least one transaction
|
// need at least one transaction
|
||||||
if (empty($transactions)) {
|
if (0 === count($transactions)) {
|
||||||
$validator->errors()->add('transactions', (string) trans('validation.at_least_one_transaction'));
|
$validator->errors()->add('transactions', (string) trans('validation.at_least_one_transaction'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -327,7 +327,7 @@ trait TransactionValidation
|
|||||||
Log::debug('Now in validateOneTransaction()');
|
Log::debug('Now in validateOneTransaction()');
|
||||||
$transactions = $this->getTransactionsArray($validator);
|
$transactions = $this->getTransactionsArray($validator);
|
||||||
// need at least one transaction
|
// need at least one transaction
|
||||||
if (empty($transactions)) {
|
if (0 === count($transactions)) {
|
||||||
$validator->errors()->add('transactions.0.description', (string) trans('validation.at_least_one_transaction'));
|
$validator->errors()->add('transactions.0.description', (string) trans('validation.at_least_one_transaction'));
|
||||||
Log::debug('Added error: at_least_one_transaction.');
|
Log::debug('Added error: at_least_one_transaction.');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user