mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-25 06:51:08 +00:00
Various code cleanup [skip ci]
This commit is contained in:
@@ -9,7 +9,8 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Helpers\Attachments;
|
namespace FireflyIII\Helpers\Attachments;
|
||||||
|
|
||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
@@ -42,7 +43,7 @@ interface AttachmentHelperInterface
|
|||||||
public function getMessages(): MessageBag;
|
public function getMessages(): MessageBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Model $model
|
* @param Model $model
|
||||||
*
|
*
|
||||||
* @param null|array $files
|
* @param null|array $files
|
||||||
*
|
*
|
||||||
|
@@ -9,7 +9,8 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Helpers\Help;
|
namespace FireflyIII\Helpers\Help;
|
||||||
|
|
||||||
use Cache;
|
use Cache;
|
||||||
@@ -123,6 +124,7 @@ class Help implements HelpInterface
|
|||||||
if (strlen($content) > 0) {
|
if (strlen($content) > 0) {
|
||||||
Log::debug(sprintf('Will store entry in cache: %s', $key));
|
Log::debug(sprintf('Will store entry in cache: %s', $key));
|
||||||
Cache::put($key, $content, 10080); // a week.
|
Cache::put($key, $content, 10080); // a week.
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log::info(sprintf('Will not cache %s because content is empty.', $key));
|
Log::info(sprintf('Will not cache %s because content is empty.', $key));
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
@@ -347,7 +347,7 @@ class ImportController extends Controller
|
|||||||
*
|
*
|
||||||
* @param ImportUploadRequest $request
|
* @param ImportUploadRequest $request
|
||||||
* @param ImportJobRepositoryInterface $repository
|
* @param ImportJobRepositoryInterface $repository
|
||||||
* @param UserRepositoryInterface $userRepository
|
* @param UserRepositoryInterface $userRepository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
@@ -368,7 +368,7 @@ class ImportController extends Controller
|
|||||||
$disk = Storage::disk('upload');
|
$disk = Storage::disk('upload');
|
||||||
|
|
||||||
// user is demo user, replace upload with prepared file.
|
// user is demo user, replace upload with prepared file.
|
||||||
if ($userRepository->hasRole(auth()->user(),'demo')) {
|
if ($userRepository->hasRole(auth()->user(), 'demo')) {
|
||||||
$stubsDisk = Storage::disk('stubs');
|
$stubsDisk = Storage::disk('stubs');
|
||||||
$content = $stubsDisk->get('demo-import.csv');
|
$content = $stubsDisk->get('demo-import.csv');
|
||||||
$contentEncrypted = Crypt::encrypt($content);
|
$contentEncrypted = Crypt::encrypt($content);
|
||||||
@@ -376,14 +376,14 @@ class ImportController extends Controller
|
|||||||
Log::debug('Replaced upload with demo file.');
|
Log::debug('Replaced upload with demo file.');
|
||||||
|
|
||||||
// also set up prepared configuration.
|
// also set up prepared configuration.
|
||||||
$configuration = json_decode($stubsDisk->get('demo-configuration.json'), true);
|
$configuration = json_decode($stubsDisk->get('demo-configuration.json'), true);
|
||||||
$repository->setConfiguration($job, $configuration);
|
$repository->setConfiguration($job, $configuration);
|
||||||
Log::debug('Set configuration for demo user', $configuration);
|
Log::debug('Set configuration for demo user', $configuration);
|
||||||
|
|
||||||
// also flash info
|
// also flash info
|
||||||
Session::flash('info', trans('demo.import-configure-security'));
|
Session::flash('info', trans('demo.import-configure-security'));
|
||||||
}
|
}
|
||||||
if (!$userRepository->hasRole(auth()->user(),'demo')) {
|
if (!$userRepository->hasRole(auth()->user(), 'demo')) {
|
||||||
// user is not demo, process original upload:
|
// user is not demo, process original upload:
|
||||||
$disk->put($newName, $contentEncrypted);
|
$disk->put($newName, $contentEncrypted);
|
||||||
Log::debug('Uploaded file', ['name' => $upload->getClientOriginalName(), 'size' => $upload->getSize(), 'mime' => $upload->getClientMimeType()]);
|
Log::debug('Uploaded file', ['name' => $upload->getClientOriginalName(), 'size' => $upload->getSize(), 'mime' => $upload->getClientMimeType()]);
|
||||||
@@ -410,6 +410,7 @@ class ImportController extends Controller
|
|||||||
}
|
}
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(route('import.configure', [$job->key]));
|
return redirect(route('import.configure', [$job->key]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,6 +430,7 @@ class ImportController extends Controller
|
|||||||
case 'settings':
|
case 'settings':
|
||||||
case 'store-settings':
|
case 'store-settings':
|
||||||
Log::debug(sprintf('Job %d with key %s has status %s', $job->id, $job->key, $job->status));
|
Log::debug(sprintf('Job %d with key %s has status %s', $job->id, $job->key, $job->status));
|
||||||
|
|
||||||
return $job->status === 'import_configuration_saved';
|
return $job->status === 'import_configuration_saved';
|
||||||
case 'finished':
|
case 'finished':
|
||||||
return $job->status === 'import_complete';
|
return $job->status === 'import_complete';
|
||||||
|
@@ -18,7 +18,6 @@ use FireflyIII\Models\AccountType;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Log;
|
|
||||||
use PragmaRX\Google2FA\Contracts\Google2FA;
|
use PragmaRX\Google2FA\Contracts\Google2FA;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
use Session;
|
||||||
|
@@ -9,12 +9,11 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Generator\Report\ReportGeneratorFactory;
|
use FireflyIII\Generator\Report\ReportGeneratorFactory;
|
||||||
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||||
use FireflyIII\Http\Requests\ReportFormRequest;
|
use FireflyIII\Http\Requests\ReportFormRequest;
|
||||||
|
@@ -475,7 +475,7 @@ class RuleController extends Controller
|
|||||||
$actions[] = view(
|
$actions[] = view(
|
||||||
'rules.partials.action',
|
'rules.partials.action',
|
||||||
[
|
[
|
||||||
'oldAction' => $entry,
|
'oldAction' => $entry,
|
||||||
'oldValue' => $request->old('rule-action-value')[$index],
|
'oldValue' => $request->old('rule-action-value')[$index],
|
||||||
'oldChecked' => $checked,
|
'oldChecked' => $checked,
|
||||||
'count' => $count,
|
'count' => $count,
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ class BillFormRequest extends Request
|
|||||||
$nameRule = 'required|between:1,255|uniqueObjectForUser:bills,name';
|
$nameRule = 'required|between:1,255|uniqueObjectForUser:bills,name';
|
||||||
$matchRule = 'required|between:1,255|uniqueObjectForUser:bills,match';
|
$matchRule = 'required|between:1,255|uniqueObjectForUser:bills,match';
|
||||||
if (intval($this->get('id')) > 0) {
|
if (intval($this->get('id')) > 0) {
|
||||||
$nameRule .= ',' . intval($this->get('id'));
|
$nameRule .= ',' . intval($this->get('id'));
|
||||||
$matchRule .= ',' . intval($this->get('id'));
|
$matchRule .= ',' . intval($this->get('id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use DaveJamesMiller\Breadcrumbs\Generator as BreadCrumbGenerator;
|
use DaveJamesMiller\Breadcrumbs\Generator as BreadCrumbGenerator;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
@@ -79,8 +79,9 @@ Breadcrumbs::register(
|
|||||||
}
|
}
|
||||||
// when is specific period:
|
// when is specific period:
|
||||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||||
$title = trans('firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
$title = trans(
|
||||||
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
||||||
|
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
||||||
);
|
);
|
||||||
$breadcrumbs->push($title, route('accounts.show', [$account->id, $moment]));
|
$breadcrumbs->push($title, route('accounts.show', [$account->id, $moment]));
|
||||||
}
|
}
|
||||||
@@ -333,8 +334,9 @@ Breadcrumbs::register(
|
|||||||
}
|
}
|
||||||
// when is specific period:
|
// when is specific period:
|
||||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||||
$title = trans('firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
$title = trans(
|
||||||
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
||||||
|
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
||||||
);
|
);
|
||||||
$breadcrumbs->push($title, route('categories.show', [$category->id, $moment]));
|
$breadcrumbs->push($title, route('categories.show', [$category->id, $moment]));
|
||||||
}
|
}
|
||||||
@@ -742,8 +744,9 @@ Breadcrumbs::register(
|
|||||||
|
|
||||||
// when is specific period:
|
// when is specific period:
|
||||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||||
$title = trans('firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
$title = trans(
|
||||||
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
||||||
|
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
||||||
);
|
);
|
||||||
$breadcrumbs->push($title, route('transactions.index', [$what, $moment]));
|
$breadcrumbs->push($title, route('transactions.index', [$what, $moment]));
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Import;
|
namespace FireflyIII\Import;
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ class ImportEntry
|
|||||||
*/
|
*/
|
||||||
private function setAppendableString(string $field, string $value)
|
private function setAppendableString(string $field, string $value)
|
||||||
{
|
{
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
$this->fields[$field] .= ' ' . $value;
|
$this->fields[$field] .= ' ' . $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Models;
|
namespace FireflyIII\Models;
|
||||||
|
|
||||||
@@ -48,6 +48,7 @@ class AccountType extends Model
|
|||||||
protected $dates = ['created_at', 'updated_at'];
|
protected $dates = ['created_at', 'updated_at'];
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return HasMany
|
* @return HasMany
|
||||||
*/
|
*/
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Models;
|
namespace FireflyIII\Models;
|
||||||
|
|
||||||
@@ -71,8 +71,8 @@ class ImportJob extends Model
|
|||||||
*/
|
*/
|
||||||
public function addStepsDone(int $count)
|
public function addStepsDone(int $count)
|
||||||
{
|
{
|
||||||
$status = $this->extended_status;
|
$status = $this->extended_status;
|
||||||
$status['steps_done'] += $count;
|
$status['steps_done'] += $count;
|
||||||
$this->extended_status = $status;
|
$this->extended_status = $status;
|
||||||
$this->save();
|
$this->save();
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ class ImportJob extends Model
|
|||||||
*/
|
*/
|
||||||
public function addTotalSteps(int $count)
|
public function addTotalSteps(int $count)
|
||||||
{
|
{
|
||||||
$status = $this->extended_status;
|
$status = $this->extended_status;
|
||||||
$status['total_steps'] += $count;
|
$status['total_steps'] += $count;
|
||||||
$this->extended_status = $status;
|
$this->extended_status = $status;
|
||||||
$this->save();
|
$this->save();
|
||||||
|
@@ -9,14 +9,14 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Models;
|
namespace FireflyIII\Models;
|
||||||
|
|
||||||
|
use Crypt;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Crypt;
|
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Binder;
|
namespace FireflyIII\Support\Binder;
|
||||||
|
|
||||||
@@ -39,11 +39,13 @@ class JournalList implements BinderInterface
|
|||||||
$object = TransactionJournal::whereIn('transaction_journals.id', $ids)
|
$object = TransactionJournal::whereIn('transaction_journals.id', $ids)
|
||||||
->expanded()
|
->expanded()
|
||||||
->where('transaction_journals.user_id', auth()->user()->id)
|
->where('transaction_journals.user_id', auth()->user()->id)
|
||||||
->get([
|
->get(
|
||||||
'transaction_journals.*',
|
[
|
||||||
'transaction_types.type AS transaction_type_type',
|
'transaction_journals.*',
|
||||||
'transaction_currencies.code AS transaction_currency_code',
|
'transaction_types.type AS transaction_type_type',
|
||||||
]);
|
'transaction_currencies.code AS transaction_currency_code',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
if ($object->count() > 0) {
|
if ($object->count() > 0) {
|
||||||
return $object;
|
return $object;
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Models;
|
namespace FireflyIII\Support\Models;
|
||||||
|
|
||||||
@@ -15,10 +15,8 @@ namespace FireflyIII\Support\Models;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +105,7 @@ trait TransactionJournalTrait
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $dateField
|
* @param string $dateField
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -118,7 +116,7 @@ trait TransactionJournalTrait
|
|||||||
}
|
}
|
||||||
if (!is_null($this->$dateField) && $this->$dateField instanceof Carbon) {
|
if (!is_null($this->$dateField) && $this->$dateField instanceof Carbon) {
|
||||||
// make field NULL
|
// make field NULL
|
||||||
$carbon = clone $this->$dateField;
|
$carbon = clone $this->$dateField;
|
||||||
$this->$dateField = null;
|
$this->$dateField = null;
|
||||||
$this->save();
|
$this->save();
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Validation;
|
namespace FireflyIII\Validation;
|
||||||
|
|
||||||
@@ -29,7 +29,6 @@ use Google2FA;
|
|||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
use Illuminate\Contracts\Translation\Translator;
|
use Illuminate\Contracts\Translation\Translator;
|
||||||
use Illuminate\Validation\Validator;
|
use Illuminate\Validation\Validator;
|
||||||
use Log;
|
|
||||||
use Session;
|
use Session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user