Clean up some code.

This commit is contained in:
James Cole 2020-10-13 06:35:33 +02:00
parent 3bd5ac21c9
commit 4e51f0abc4
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
33 changed files with 149 additions and 294 deletions

View File

@ -41,7 +41,6 @@ class AccountController extends Controller
use AccountFilter; use AccountFilter;
private array $balanceTypes; private array $balanceTypes;
private AccountRepositoryInterface $repository; private AccountRepositoryInterface $repository;
@ -76,16 +75,14 @@ class AccountController extends Controller
$query = $data['query']; $query = $data['query'];
$date = $data['date'] ?? today(config('app.timezone')); $date = $data['date'] ?? today(config('app.timezone'));
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$return = []; $return = [];
$result = $repository->searchAccount((string) $query, $types, $data['limit']); $result = $this->repository->searchAccount((string) $query, $types, $data['limit']);
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
/** @var Account $account */ /** @var Account $account */
foreach ($result as $account) { foreach ($result as $account) {
$nameWithBalance = $account->name; $nameWithBalance = $account->name;
$currency = $repository->getAccountCurrency($account) ?? $defaultCurrency; $currency = $this->repository->getAccountCurrency($account) ?? $defaultCurrency;
if (in_array($account->accountType->type, $this->balanceTypes, true)) { if (in_array($account->accountType->type, $this->balanceTypes, true)) {
$balance = app('steam')->balance($account, $date); $balance = app('steam')->balance($account, $date);

View File

@ -58,13 +58,10 @@ class BudgetController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
//$this->generator = app(GeneratorInterface::class);
$this->repository = app(BudgetRepositoryInterface::class); $this->repository = app(BudgetRepositoryInterface::class);
$this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class); $this->blRepository = app(BudgetLimitRepositoryInterface::class);
//$this->nbRepository = app(NoBudgetRepositoryInterface::class);
return $next($request); return $next($request);
} }
); );
@ -195,7 +192,6 @@ class BudgetController extends Controller
{ {
foreach ($sets as $set) { foreach ($sets as $set) {
$label = $set['label']; $label = $set['label'];
//$basic['spent']['entries'][$label] = $set['entries']['spent'];
$basic['spent_capped']['entries'][$label] = $set['entries']['spent_capped']; $basic['spent_capped']['entries'][$label] = $set['entries']['spent_capped'];
$basic['left']['entries'][$label] = $set['entries']['left']; $basic['left']['entries'][$label] = $set['entries']['left'];
$basic['overspent']['entries'][$label] = $set['entries']['overspent']; $basic['overspent']['entries'][$label] = $set['entries']['overspent'];

View File

@ -46,14 +46,10 @@ class FixAccountTypes extends Command
* The name and signature of the console command. * The name and signature of the console command.
* @var string * @var string
*/ */
protected $signature = 'firefly-iii:fix-account-types'; protected $signature = 'firefly-iii:fix-account-types';
/** @var int */ private int $count;
private $count; private array $expected;
private array $expected; private AccountFactory $factory;
/** @var AccountFactory */
private $factory;
/** @var array */
private $fixable;
/** /**
@ -65,19 +61,8 @@ class FixAccountTypes extends Command
{ {
$this->stupidLaravel(); $this->stupidLaravel();
Log::debug('Now in fix-account-types'); Log::debug('Now in fix-account-types');
$start = microtime(true); $start = microtime(true);
$this->factory = app(AccountFactory::class); $this->factory = app(AccountFactory::class);
// some combinations can be fixed by this script:
$this->fixable = [// transfers from asset to liability and vice versa
sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::LOAN), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::DEBT), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::MORTGAGE), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::LOAN, AccountType::ASSET), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::DEBT, AccountType::ASSET), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::MORTGAGE, AccountType::ASSET),
// withdrawals with a revenue account as destination instead of an expense account.
sprintf('%s%s%s', TransactionType::WITHDRAWAL, AccountType::ASSET, AccountType::REVENUE),
// deposits with an expense account as source instead of a revenue account.
sprintf('%s%s%s', TransactionType::DEPOSIT, AccountType::EXPENSE, AccountType::ASSET),];
$this->expected = config('firefly.source_dests'); $this->expected = config('firefly.source_dests');
$journals = TransactionJournal::with(['TransactionType', 'transactions', 'transactions.account', 'transactions.account.accounttype'])->get(); $journals = TransactionJournal::with(['TransactionType', 'transactions', 'transactions.account', 'transactions.account.accounttype'])->get();
Log::debug(sprintf('Found %d journals to inspect.', $journals->count())); Log::debug(sprintf('Found %d journals to inspect.', $journals->count()));
@ -203,10 +188,10 @@ class FixAccountTypes extends Command
*/ */
private function inspectJournal(TransactionJournal $journal): void private function inspectJournal(TransactionJournal $journal): void
{ {
$count = $journal->transactions()->count(); $transactions = $journal->transactions()->count();
if (2 !== $count) { if (2 !== $transactions) {
Log::debug(sprintf('Journal has %d transactions, so cant fix.', $count)); Log::debug(sprintf('Journal has %d transactions, so can\'t fix.', $transactions));
$this->info(sprintf('Cannot inspect transaction journal #%d because it has %d transaction(s) instead of 2.', $journal->id, $count)); $this->info(sprintf('Cannot inspect transaction journal #%d because it has %d transaction(s) instead of 2.', $journal->id, $transactions));
return; return;
} }

View File

@ -44,8 +44,7 @@ class RenameMetaFields extends Command
*/ */
protected $signature = 'firefly-iii:rename-meta-fields'; protected $signature = 'firefly-iii:rename-meta-fields';
/** @var int */ private int $count;
private $count;
/** /**
@ -93,9 +92,9 @@ class RenameMetaFields extends Command
*/ */
private function rename(string $original, string $update): void private function rename(string $original, string $update): void
{ {
$count = DB::table('journal_meta') $total = DB::table('journal_meta')
->where('name', '=', $original) ->where('name', '=', $original)
->update(['name' => $update]); ->update(['name' => $update]);
$this->count += $count; $this->count += $total;
} }
} }

View File

@ -98,8 +98,6 @@ class DecryptDatabase extends Command
} catch(JsonException $e) { } catch(JsonException $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
//Log::debug(sprintf('Decrypted field "%s" "%s" to "%s" in table "%s" (row #%d)', $field, $original, print_r($value, true), $table, $id));
/** @var Preference $object */ /** @var Preference $object */
$object = Preference::find((int) $id); $object = Preference::find((int) $id);
if (null !== $object) { if (null !== $object) {
@ -110,7 +108,6 @@ class DecryptDatabase extends Command
} }
if ($value !== $original) { if ($value !== $original) {
//Log::debug(sprintf('Decrypted field "%s" "%s" to "%s" in table "%s" (row #%d)', $field, $original, $value, $table, $id));
DB::table($table)->where('id', $id)->update([$field => $value]); DB::table($table)->where('id', $id)->update([$field => $value]);
} }
} }

View File

@ -131,11 +131,11 @@ class ApplyRules extends Command
$ruleEngine->setUser($this->getUser()); $ruleEngine->setUser($this->getUser());
// add the accounts as filter: // add the accounts as filter:
$accounts = []; $filterAccountList = [];
foreach($this->accounts as $account) { foreach($this->accounts as $account) {
$accounts[] = $account->id; $filterAccountList[] = $account->id;
} }
$list = implode(',', $accounts); $list = implode(',', $filterAccountList);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => $list]); $ruleEngine->addOperator(['type' => 'account_id', 'value' => $list]);
// add the date as a filter: // add the date as a filter:
@ -295,7 +295,7 @@ class ApplyRules extends Command
private function verifyInputDates(): void private function verifyInputDates(): void
{ {
// parse start date. // parse start date.
$startDate = Carbon::now()->startOfMonth(); $inputStart = Carbon::now()->startOfMonth();
$startString = $this->option('start_date'); $startString = $this->option('start_date');
if (null === $startString) { if (null === $startString) {
/** @var JournalRepositoryInterface $repository */ /** @var JournalRepositoryInterface $repository */
@ -303,26 +303,26 @@ class ApplyRules extends Command
$repository->setUser($this->getUser()); $repository->setUser($this->getUser());
$first = $repository->firstNull(); $first = $repository->firstNull();
if (null !== $first) { if (null !== $first) {
$startDate = $first->date; $inputStart = $first->date;
} }
} }
if (null !== $startString && '' !== $startString) { if (null !== $startString && '' !== $startString) {
$startDate = Carbon::createFromFormat('Y-m-d', $startString); $inputStart = Carbon::createFromFormat('Y-m-d', $startString);
} }
// parse end date // parse end date
$endDate = Carbon::now(); $inputEnd = Carbon::now();
$endString = $this->option('end_date'); $endString = $this->option('end_date');
if (null !== $endString && '' !== $endString) { if (null !== $endString && '' !== $endString) {
$endDate = Carbon::createFromFormat('Y-m-d', $endString); $inputEnd = Carbon::createFromFormat('Y-m-d', $endString);
} }
if ($startDate > $endDate) { if ($inputStart > $inputEnd) {
[$endDate, $startDate] = [$startDate, $endDate]; [$inputEnd, $inputStart] = [$inputStart, $inputEnd];
} }
$this->startDate = $startDate; $this->startDate = $inputStart;
$this->endDate = $endDate; $this->endDate = $inputEnd;
} }
/** /**

View File

@ -72,8 +72,8 @@ class MigrateAttachments extends Command
foreach ($attachments as $att) { foreach ($attachments as $att) {
// move description: // move description:
$description = (string) $att->description; $attDescription = (string) $att->description;
if ('' !== $description) { if ('' !== $attDescription) {
// find or create note: // find or create note:
$note = $att->notes()->first(); $note = $att->notes()->first();
@ -81,7 +81,7 @@ class MigrateAttachments extends Command
$note = new Note; $note = new Note;
$note->noteable()->associate($att); $note->noteable()->associate($att);
} }
$note->text = $description; $note->text = $attDescription;
$note->save(); $note->save();
// clear description: // clear description:

View File

@ -58,23 +58,18 @@ class MigrateToGroups extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}'; protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
/** @var JournalCLIRepositoryInterface */ private JournalCLIRepositoryInterface $cliRepository;
private $cliRepository; private int $count;
private $count; private TransactionGroupFactory $groupFactory;
/** @var TransactionGroupFactory */ private JournalRepositoryInterface $journalRepository;
private $groupFactory; private JournalDestroyService $service;
/** @var JournalRepositoryInterface */
private $journalRepository;
/** @var JournalDestroyService */
private $service;
/** /**
* Execute the console command. * Execute the console command.
* *
* @throws Exception
* @return int * @return int
* @throws Exception
*/ */
public function handle(): int public function handle(): int
{ {
@ -254,16 +249,16 @@ class MigrateToGroups extends Command
private function makeGroupsFromAll(): void private function makeGroupsFromAll(): void
{ {
$orphanedJournals = $this->cliRepository->getJournalsWithoutGroup(); $orphanedJournals = $this->cliRepository->getJournalsWithoutGroup();
$count = count($orphanedJournals); $total = count($orphanedJournals);
if ($count > 0) { if ($total > 0) {
Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $count)); Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $total));
$this->line(sprintf('Going to convert %d transaction journals. Please hold..', $count)); $this->line(sprintf('Going to convert %d transaction journals. Please hold..', $total));
/** @var array $journal */ /** @var array $journal */
foreach ($orphanedJournals as $array) { foreach ($orphanedJournals as $array) {
$this->giveGroup($array); $this->giveGroup($array);
} }
} }
if (0 === $count) { if (0 === $total) {
$this->info('No need to convert transaction journals.'); $this->info('No need to convert transaction journals.');
} }
} }

View File

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
use Carbon\Carbon;
use Exception; use Exception;
use FireflyIII\Exceptions\DuplicateTransactionException; use FireflyIII\Exceptions\DuplicateTransactionException;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
@ -56,26 +55,17 @@ class TransactionJournalFactory
{ {
use JournalServiceTrait; use JournalServiceTrait;
private AccountRepositoryInterface $accountRepository; private AccountRepositoryInterface $accountRepository;
private AccountValidator $accountValidator; private AccountValidator $accountValidator;
private BillRepositoryInterface $billRepository; private BillRepositoryInterface $billRepository;
/** @var CurrencyRepositoryInterface */ private CurrencyRepositoryInterface $currencyRepository;
private $currencyRepository; private bool $errorOnHash;
/** @var bool */ private array $fields;
private $errorOnHash; private PiggyBankEventFactory $piggyEventFactory;
/** @var array */ private PiggyBankRepositoryInterface $piggyRepository;
private $fields; private TransactionFactory $transactionFactory;
/** @var PiggyBankEventFactory */ private TransactionTypeRepositoryInterface $typeRepository;
private $piggyEventFactory; private User $user;
/** @var PiggyBankRepositoryInterface */
private $piggyRepository;
/** @var TransactionFactory */
private $transactionFactory;
/** @var TransactionTypeRepositoryInterface */
private $typeRepository;
/** @var User The user */
private $user;
/** /**
* Constructor. * Constructor.
@ -112,7 +102,6 @@ class TransactionJournalFactory
$this->currencyRepository = app(CurrencyRepositoryInterface::class); $this->currencyRepository = app(CurrencyRepositoryInterface::class);
$this->typeRepository = app(TransactionTypeRepositoryInterface::class); $this->typeRepository = app(TransactionTypeRepositoryInterface::class);
$this->transactionFactory = app(TransactionFactory::class);
$this->billRepository = app(BillRepositoryInterface::class); $this->billRepository = app(BillRepositoryInterface::class);
$this->budgetRepository = app(BudgetRepositoryInterface::class); $this->budgetRepository = app(BudgetRepositoryInterface::class);
$this->categoryRepository = app(CategoryRepositoryInterface::class); $this->categoryRepository = app(CategoryRepositoryInterface::class);
@ -196,7 +185,6 @@ class TransactionJournalFactory
$this->user = $user; $this->user = $user;
$this->currencyRepository->setUser($this->user); $this->currencyRepository->setUser($this->user);
$this->tagFactory->setUser($user); $this->tagFactory->setUser($user);
$this->transactionFactory->setUser($this->user);
$this->billRepository->setUser($this->user); $this->billRepository->setUser($this->user);
$this->budgetRepository->setUser($this->user); $this->budgetRepository->setUser($this->user);
$this->categoryRepository->setUser($this->user); $this->categoryRepository->setUser($this->user);
@ -329,7 +317,6 @@ class TransactionJournalFactory
Log::debug(sprintf('Created new journal #%d: "%s"', $journal->id, $journal->description)); Log::debug(sprintf('Created new journal #%d: "%s"', $journal->id, $journal->description));
/** Create two transactions. */ /** Create two transactions. */
/** @var TransactionFactory $transactionFactory */
$transactionFactory = app(TransactionFactory::class); $transactionFactory = app(TransactionFactory::class);
$transactionFactory->setUser($this->user); $transactionFactory->setUser($this->user);
$transactionFactory->setJournal($journal); $transactionFactory->setJournal($journal);

View File

@ -39,11 +39,8 @@ use Illuminate\View\View;
*/ */
class CreateController extends Controller class CreateController extends Controller
{ {
/** @var CategoryRepositoryInterface The category repository */ private CategoryRepositoryInterface $repository;
private $repository; private AttachmentHelperInterface $attachments;
/** @var AttachmentHelperInterface Helper for attachments. */
private $attachments;
/** /**
* CategoryController constructor. * CategoryController constructor.
@ -58,7 +55,7 @@ class CreateController extends Controller
function ($request, $next) { function ($request, $next) {
app('view')->share('title', (string) trans('firefly.categories')); app('view')->share('title', (string) trans('firefly.categories'));
app('view')->share('mainTitleIcon', 'fa-bookmark'); app('view')->share('mainTitleIcon', 'fa-bookmark');
$this->repository = app(CategoryRepositoryInterface::class); $this->repository = app(CategoryRepositoryInterface::class);
$this->attachments = app(AttachmentHelperInterface::class); $this->attachments = app(AttachmentHelperInterface::class);
return $next($request); return $next($request);
@ -107,7 +104,7 @@ class CreateController extends Controller
$this->attachments->saveAttachmentsForModel($category, $files); $this->attachments->saveAttachmentsForModel($category, $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) {

View File

@ -45,6 +45,7 @@ use Illuminate\Support\Collection;
class CategoryController extends Controller class CategoryController extends Controller
{ {
use DateCalculation, AugumentData, ChartGeneration; use DateCalculation, AugumentData, ChartGeneration;
/** @var GeneratorInterface Chart generation methods. */ /** @var GeneratorInterface Chart generation methods. */
protected $generator; protected $generator;
@ -85,10 +86,10 @@ class CategoryController extends Controller
$start = app('navigation')->startOfPeriod($start, $range); $start = app('navigation')->startOfPeriod($start, $range);
$end = $this->getDate(); $end = $this->getDate();
/** @var WholePeriodChartGenerator $generator */ /** @var WholePeriodChartGenerator $chartGenerator */
$generator = app(WholePeriodChartGenerator::class); $chartGenerator = app(WholePeriodChartGenerator::class);
$chartData = $generator->generate($category, $start, $end); $chartData = $chartGenerator->generate($category, $start, $end);
$data = $this->generator->multiSet($chartData); $data = $this->generator->multiSet($chartData);
$cache->store($data); $cache->store($data);
return response()->json($data); return response()->json($data);
@ -111,14 +112,14 @@ class CategoryController extends Controller
$cache->addProperty($end); $cache->addProperty($end);
$cache->addProperty('chart.category.frontpage'); $cache->addProperty('chart.category.frontpage');
if ($cache->has()) { if ($cache->has()) {
return response()->json($cache->get()); // @codeCoverageIgnore return response()->json($cache->get()); // @codeCoverageIgnore
} }
$frontPageGenerator = new FrontpageChartGenerator($start, $end); $frontPageGenerator = new FrontpageChartGenerator($start, $end);
$chartData = $frontPageGenerator->generate(); $chartData = $frontPageGenerator->generate();
$data = $this->generator->multiSet($chartData); $data = $this->generator->multiSet($chartData);
$cache->store($data); $cache->store($data);
return response()->json($data); return response()->json($data);
@ -210,13 +211,10 @@ class CategoryController extends Controller
return response()->json($cache->get()); // @codeCoverageIgnore return response()->json($cache->get()); // @codeCoverageIgnore
} }
/** @var GeneratorInterface $generator */
$generator = app(GeneratorInterface::class);
/** @var WholePeriodChartGenerator $chartGenerator */ /** @var WholePeriodChartGenerator $chartGenerator */
$chartGenerator = app(WholePeriodChartGenerator::class); $chartGenerator = app(WholePeriodChartGenerator::class);
$chartData = $chartGenerator->generate($category, $start, $end); $chartData = $chartGenerator->generate($category, $start, $end);
$data = $generator->multiSet($chartData); $data = $this->generator->multiSet($chartData);
$cache->store($data); $cache->store($data);

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Recurring; namespace FireflyIII\Http\Controllers\Recurring;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@ -45,12 +44,9 @@ use Illuminate\View\View;
*/ */
class CreateController extends Controller class CreateController extends Controller
{ {
/** @var BudgetRepositoryInterface The budget repository */ private BudgetRepositoryInterface $budgetRepos;
private $budgets; private RecurringRepositoryInterface $recurring;
/** @var RecurringRepositoryInterface Recurring repository */ private AttachmentHelperInterface $attachments;
private $recurring;
private AttachmentHelperInterface $attachments;
/** /**
* CreateController constructor. * CreateController constructor.
@ -69,7 +65,7 @@ class CreateController extends Controller
app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence')); app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence'));
$this->recurring = app(RecurringRepositoryInterface::class); $this->recurring = app(RecurringRepositoryInterface::class);
$this->budgets = app(BudgetRepositoryInterface::class); $this->budgetRepos = app(BudgetRepositoryInterface::class);
$this->attachments = app(AttachmentHelperInterface::class); $this->attachments = app(AttachmentHelperInterface::class);
return $next($request); return $next($request);
@ -83,7 +79,7 @@ class CreateController extends Controller
*/ */
public function createFromJournal(Request $request, TransactionJournal $journal) public function createFromJournal(Request $request, TransactionJournal $journal)
{ {
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets()); $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
$tomorrow = today(config('app.timezone')); $tomorrow = today(config('app.timezone'));
$oldRepetitionType = $request->old('repetition_type'); $oldRepetitionType = $request->old('repetition_type');
@ -177,7 +173,7 @@ class CreateController extends Controller
*/ */
public function create(Request $request) public function create(Request $request)
{ {
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets()); $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
$tomorrow = today(config('app.timezone')); $tomorrow = today(config('app.timezone'));
$oldRepetitionType = $request->old('repetition_type'); $oldRepetitionType = $request->old('repetition_type');

View File

@ -46,11 +46,9 @@ use Symfony\Component\HttpFoundation\ParameterBag;
*/ */
class EditController extends Controller class EditController extends Controller
{ {
/** @var BudgetRepositoryInterface The budget repository */ private BudgetRepositoryInterface $budgetRepos;
private $budgets; private RecurringRepositoryInterface $recurring;
/** @var RecurringRepositoryInterface Recurring repository */ private AttachmentHelperInterface $attachments;
private $recurring;
private AttachmentHelperInterface $attachments;
/** /**
* EditController constructor. * EditController constructor.
@ -69,7 +67,7 @@ class EditController extends Controller
app('view')->share('subTitle', (string) trans('firefly.recurrences')); app('view')->share('subTitle', (string) trans('firefly.recurrences'));
$this->recurring = app(RecurringRepositoryInterface::class); $this->recurring = app(RecurringRepositoryInterface::class);
$this->budgets = app(BudgetRepositoryInterface::class); $this->budgetRepos = app(BudgetRepositoryInterface::class);
$this->attachments = app(AttachmentHelperInterface::class); $this->attachments = app(AttachmentHelperInterface::class);
return $next($request); return $next($request);
} }
@ -82,9 +80,9 @@ class EditController extends Controller
* @param Request $request * @param Request $request
* @param Recurrence $recurrence * @param Recurrence $recurrence
* *
* @return Factory|View
* @throws FireflyException * @throws FireflyException
* *
* @return Factory|View
*/ */
public function edit(Request $request, Recurrence $recurrence) public function edit(Request $request, Recurrence $recurrence)
{ {
@ -93,7 +91,7 @@ class EditController extends Controller
$transformer->setParameters(new ParameterBag); $transformer->setParameters(new ParameterBag);
$array = $transformer->transform($recurrence); $array = $transformer->transform($recurrence);
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets()); $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
/** @var RecurrenceRepetition $repetition */ /** @var RecurrenceRepetition $repetition */
$repetition = $recurrence->recurrenceRepetitions()->first(); $repetition = $recurrence->recurrenceRepetitions()->first();
@ -108,7 +106,7 @@ class EditController extends Controller
} }
$request->session()->forget('recurrences.edit.fromUpdate'); $request->session()->forget('recurrences.edit.fromUpdate');
$repetitionEnd = 'forever'; $repetitionEnd = 'forever';
$repetitionEnds = [ $repetitionEnds = [
'forever' => (string) trans('firefly.repeat_forever'), 'forever' => (string) trans('firefly.repeat_forever'),
'until_date' => (string) trans('firefly.repeat_until_date'), 'until_date' => (string) trans('firefly.repeat_until_date'),
@ -129,7 +127,7 @@ class EditController extends Controller
]; ];
$hasOldInput = null !== $request->old('_token'); $hasOldInput = null !== $request->old('_token');
$preFilled = [ $preFilled = [
'transaction_type' => strtolower($recurrence->transactionType->type), 'transaction_type' => strtolower($recurrence->transactionType->type),
'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active, 'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active,
'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules, 'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules,
@ -151,8 +149,8 @@ class EditController extends Controller
* @param RecurrenceFormRequest $request * @param RecurrenceFormRequest $request
* @param Recurrence $recurrence * @param Recurrence $recurrence
* *
* @throws FireflyException
* @return RedirectResponse|Redirector * @return RedirectResponse|Redirector
* @throws FireflyException
*/ */
public function update(RecurrenceFormRequest $request, Recurrence $recurrence) public function update(RecurrenceFormRequest $request, Recurrence $recurrence)
{ {

View File

@ -45,8 +45,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
class IndexController extends Controller class IndexController extends Controller
{ {
use GetConfigurationData; use GetConfigurationData;
/** @var RecurringRepositoryInterface Recurring repository */ private RecurringRepositoryInterface $recurringRepos;
private $recurring;
/** /**
* IndexController constructor. * IndexController constructor.
@ -63,7 +62,7 @@ class IndexController extends Controller
app('view')->share('mainTitleIcon', 'fa-paint-brush'); app('view')->share('mainTitleIcon', 'fa-paint-brush');
app('view')->share('title', (string) trans('firefly.recurrences')); app('view')->share('title', (string) trans('firefly.recurrences'));
$this->recurring = app(RecurringRepositoryInterface::class); $this->recurringRepos = app(RecurringRepositoryInterface::class);
return $next($request); return $next($request);
} }
@ -84,13 +83,12 @@ class IndexController extends Controller
{ {
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data; $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
$collection = $this->recurring->get(); $collection = $this->recurringRepos->get();
$today = today(config('app.timezone')); $today = today(config('app.timezone'));
$year = today(config('app.timezone')); $year = today(config('app.timezone'));
// split collection // split collection
$total = $collection->count(); $total = $collection->count();
/** @var Collection $recurrences */
$recurrences = $collection->slice(($page - 1) * $pageSize, $pageSize); $recurrences = $collection->slice(($page - 1) * $pageSize, $pageSize);
/** @var RecurrenceTransformer $transformer */ /** @var RecurrenceTransformer $transformer */

View File

@ -26,7 +26,6 @@ use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface; use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;
use FireflyIII\Repositories\Category\OperationsRepositoryInterface; use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
@ -44,9 +43,8 @@ class CategoryController extends Controller
{ {
use BasicDataSupport; use BasicDataSupport;
private OperationsRepositoryInterface $opsRepository;
/** @var OperationsRepositoryInterface */ private NoCategoryRepositoryInterface $noCatRepository;
private $opsRepository;
/** /**
* ExpenseReportController constructor. * ExpenseReportController constructor.
@ -58,8 +56,8 @@ class CategoryController extends Controller
parent::__construct(); parent::__construct();
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class);
$this->noCatRepository = app(NoCategoryRepositoryInterface::class);
return $next($request); return $next($request);
} }
); );
@ -505,14 +503,6 @@ class CategoryController extends Controller
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
} }
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
/** @var OperationsRepositoryInterface $opsRepository */
$opsRepository = app(OperationsRepositoryInterface::class);
/** @var NoCategoryRepositoryInterface $noCatRepos */
$noCatRepos = app(NoCategoryRepositoryInterface::class);
// depending on the carbon format (a reliable way to determine the general date difference) // depending on the carbon format (a reliable way to determine the general date difference)
// change the "listOfPeriods" call so the entire period gets included correctly. // change the "listOfPeriods" call so the entire period gets included correctly.
@ -527,8 +517,8 @@ class CategoryController extends Controller
$periods = app('navigation')->listOfPeriods($start, $end); $periods = app('navigation')->listOfPeriods($start, $end);
$data = []; $data = [];
$with = $opsRepository->listExpenses($start, $end, $accounts); $with = $this->opsRepository->listExpenses($start, $end, $accounts);
$without = $noCatRepos->listExpenses($start, $end, $accounts); $without = $this->noCatRepository->listExpenses($start, $end, $accounts);
foreach ([$with, $without] as $set) { foreach ([$with, $without] as $set) {
foreach ($set as $currencyId => $currencyRow) { foreach ($set as $currencyId => $currencyRow) {
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) { foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
@ -594,12 +584,6 @@ class CategoryController extends Controller
return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
} }
/** @var OperationsRepositoryInterface $opsRepository */
$opsRepository = app(OperationsRepositoryInterface::class);
/** @var NoCategoryRepositoryInterface $noCatRepos */
$noCatRepos = app(NoCategoryRepositoryInterface::class);
// depending on the carbon format (a reliable way to determine the general date difference) // depending on the carbon format (a reliable way to determine the general date difference)
// change the "listOfPeriods" call so the entire period gets included correctly. // change the "listOfPeriods" call so the entire period gets included correctly.
$format = app('navigation')->preferredCarbonFormat($start, $end); $format = app('navigation')->preferredCarbonFormat($start, $end);
@ -613,8 +597,8 @@ class CategoryController extends Controller
$periods = app('navigation')->listOfPeriods($start, $end); $periods = app('navigation')->listOfPeriods($start, $end);
$data = []; $data = [];
$with = $opsRepository->listIncome($start, $end, $accounts); $with = $this->opsRepository->listIncome($start, $end, $accounts);
$without = $noCatRepos->listIncome($start, $end, $accounts); $without = $this->noCatRepository->listIncome($start, $end, $accounts);
foreach ([$with, $without] as $set) { foreach ([$with, $without] as $set) {
foreach ($set as $currencyId => $currencyRow) { foreach ($set as $currencyId => $currencyRow) {
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) { foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
@ -677,19 +661,13 @@ class CategoryController extends Controller
$cache->addProperty('category-report'); $cache->addProperty('category-report');
$cache->addProperty($accounts->pluck('id')->toArray()); $cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) { if ($cache->has()) {
// return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
} }
/** @var OperationsRepositoryInterface $opsRepository */ $earnedWith = $this->opsRepository->listIncome($start, $end, $accounts);
$opsRepository = app(OperationsRepositoryInterface::class); $spentWith = $this->opsRepository->listExpenses($start, $end, $accounts);
$earnedWithout = $this->noCatRepository->listIncome($start, $end, $accounts);
/** @var NoCategoryRepositoryInterface $noCatRepository */ $spentWithout = $this->noCatRepository->listExpenses($start, $end, $accounts);
$noCatRepository = app(NoCategoryRepositoryInterface::class);
$earnedWith = $opsRepository->listIncome($start, $end, $accounts);
$spentWith = $opsRepository->listExpenses($start, $end, $accounts);
$earnedWithout = $noCatRepository->listIncome($start, $end, $accounts);
$spentWithout = $noCatRepository->listExpenses($start, $end, $accounts);
$report = [ $report = [
'categories' => [], 'categories' => [],

View File

@ -43,11 +43,8 @@ class TagController extends Controller
{ {
use PeriodOverview; use PeriodOverview;
/** @var TagRepositoryInterface The tag repository. */ protected TagRepositoryInterface $repository;
protected $repository; private AttachmentHelperInterface $attachmentsHelper;
/** @var AttachmentHelperInterface Helper for attachments. */
private $attachments;
/** /**
* TagController constructor. * TagController constructor.
@ -62,7 +59,7 @@ class TagController extends Controller
app('view')->share('title', (string) trans('firefly.tags')); app('view')->share('title', (string) trans('firefly.tags'));
app('view')->share('mainTitleIcon', 'fa-tag'); app('view')->share('mainTitleIcon', 'fa-tag');
$this->attachments = app(AttachmentHelperInterface::class); $this->attachmentsHelper = app(AttachmentHelperInterface::class);
$this->repository = app(TagRepositoryInterface::class); $this->repository = app(TagRepositoryInterface::class);
return $next($request); return $next($request);
@ -323,14 +320,14 @@ class TagController extends Controller
/** @var array $files */ /** @var array $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null; $files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) { if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($result, $files); $this->attachmentsHelper->saveAttachmentsForModel($result, $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->attachmentsHelper->getMessages()->get('attachments')) > 0) {
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); // @codeCoverageIgnore
} }
@ -366,14 +363,14 @@ class TagController extends Controller
/** @var array $files */ /** @var array $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null; $files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) { if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($tag, $files); $this->attachmentsHelper->saveAttachmentsForModel($tag, $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->attachmentsHelper->getMessages()->get('attachments')) > 0) {
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); // @codeCoverageIgnore
} }

View File

@ -81,9 +81,9 @@ class BulkController extends Controller
// make amounts positive. // make amounts positive.
// get list of budgets: // get list of budgets:
/** @var BudgetRepositoryInterface $repository */ /** @var BudgetRepositoryInterface $budgetRepos */
$repository = app(BudgetRepositoryInterface::class); $budgetRepos = app(BudgetRepositoryInterface::class);
$budgetList = app('expandedform')->makeSelectListWithEmpty($repository->getActiveBudgets()); $budgetList = app('expandedform')->makeSelectListWithEmpty($budgetRepos->getActiveBudgets());
return view('transactions.bulk.edit', compact('journals', 'subTitle', 'budgetList')); return view('transactions.bulk.edit', compact('journals', 'subTitle', 'budgetList'));
} }

View File

@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction; namespace FireflyIII\Http\Controllers\Transaction;
use Carbon\Carbon;
use Exception; use Exception;
use FireflyIII\Events\UpdatedTransactionGroup; use FireflyIII\Events\UpdatedTransactionGroup;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
@ -43,7 +42,6 @@ use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Routing\Redirector; use Illuminate\Routing\Redirector;
use Log; use Log;
use View;
/** /**
* Class ConvertController. * Class ConvertController.
@ -55,6 +53,7 @@ class ConvertController extends Controller
use ModelInformation, UserNavigation; use ModelInformation, UserNavigation;
private JournalRepositoryInterface $repository; private JournalRepositoryInterface $repository;
private AccountRepositoryInterface $accountRepository;
/** /**
* ConvertController constructor. * ConvertController constructor.
@ -68,8 +67,8 @@ class ConvertController extends Controller
// some useful repositories: // some useful repositories:
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(JournalRepositoryInterface::class); $this->repository = app(JournalRepositoryInterface::class);
$this->accountRepository = app(AccountRepositoryInterface::class);
app('view')->share('title', (string) trans('firefly.transactions')); app('view')->share('title', (string) trans('firefly.transactions'));
app('view')->share('mainTitleIcon', 'fa-exchange'); app('view')->share('mainTitleIcon', 'fa-exchange');
@ -85,9 +84,9 @@ class ConvertController extends Controller
* @param TransactionType $destinationType * @param TransactionType $destinationType
* @param TransactionGroup $group * @param TransactionGroup $group
* *
* @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws Exception * @throws Exception
* *
* @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/ */
public function index(TransactionType $destinationType, TransactionGroup $group) public function index(TransactionType $destinationType, TransactionGroup $group)
{ {
@ -151,9 +150,9 @@ class ConvertController extends Controller
* @param TransactionType $destinationType * @param TransactionType $destinationType
* @param TransactionGroup $group * @param TransactionGroup $group
* *
* @throws FireflyException
* @return RedirectResponse|Redirector * @return RedirectResponse|Redirector
* *
* @throws FireflyException
*/ */
public function postIndex(Request $request, TransactionType $destinationType, TransactionGroup $group) public function postIndex(Request $request, TransactionType $destinationType, TransactionGroup $group)
{ {
@ -188,8 +187,8 @@ class ConvertController extends Controller
* @param TransactionType $transactionType * @param TransactionType $transactionType
* @param array $data * @param array $data
* *
* @throws FireflyException
* @return TransactionJournal * @return TransactionJournal
* @throws FireflyException
*/ */
private function convertJournal(TransactionJournal $journal, TransactionType $transactionType, array $data): TransactionJournal private function convertJournal(TransactionJournal $journal, TransactionType $transactionType, array $data): TransactionJournal
{ {
@ -245,23 +244,23 @@ class ConvertController extends Controller
} }
/** /**
* @throws Exception
* @return array * @return array
* @throws Exception
*/ */
private function getAssetAccounts(): array private function getAssetAccounts(): array
{ {
// make repositories // make repositories
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $accountRepository */
$repository = app(AccountRepositoryInterface::class); $accountRepository = app(AccountRepositoryInterface::class);
$accountList = $repository->getActiveAccountsByType([AccountType::ASSET]); $accountList = $accountRepository->getActiveAccountsByType([AccountType::ASSET]);
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
$grouped = []; $grouped = [];
// group accounts: // group accounts:
/** @var Account $account */ /** @var Account $account */
foreach ($accountList as $account) { foreach ($accountList as $account) {
$balance = app('steam')->balance($account, today()); $balance = app('steam')->balance($account, today());
$currency = $repository->getAccountCurrency($account) ?? $defaultCurrency; $currency = $accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
$role = (string) $repository->getMetaValue($account, 'account_role'); $role = (string) $accountRepository->getMetaValue($account, 'account_role');
if ('' === $role) { if ('' === $role) {
$role = 'no_account_type'; // @codeCoverageIgnore $role = 'no_account_type'; // @codeCoverageIgnore
} }
@ -274,22 +273,22 @@ class ConvertController extends Controller
} }
/** /**
* @throws Exception
* @return array * @return array
* @throws Exception
*/ */
private function getLiabilities(): array private function getLiabilities(): array
{ {
// make repositories // make repositories
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $accountRepository */
$repository = app(AccountRepositoryInterface::class); $accountRepository = app(AccountRepositoryInterface::class);
$accountList = $repository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]); $accountList = $accountRepository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
$grouped = []; $grouped = [];
// group accounts: // group accounts:
/** @var Account $account */ /** @var Account $account */
foreach ($accountList as $account) { foreach ($accountList as $account) {
$balance = app('steam')->balance($account, today()); $balance = app('steam')->balance($account, today());
$currency = $repository->getAccountCurrency($account) ?? $defaultCurrency; $currency = $accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
$role = 'l_' . $account->accountType->type; $role = 'l_' . $account->accountType->type;
$key = (string) trans('firefly.opt_group_' . $role); $key = (string) trans('firefly.opt_group_' . $role);
$grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')'; $grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
@ -304,16 +303,16 @@ class ConvertController extends Controller
private function getValidDepositSources(): array private function getValidDepositSources(): array
{ {
// make repositories // make repositories
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $accountRepository */
$repository = app(AccountRepositoryInterface::class); $accountRepository = app(AccountRepositoryInterface::class);
$liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN]; $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
$accountList = $repository $accountList = $accountRepository
->getActiveAccountsByType([AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]); ->getActiveAccountsByType([AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
$grouped = []; $grouped = [];
// group accounts: // group accounts:
/** @var Account $account */ /** @var Account $account */
foreach ($accountList as $account) { foreach ($accountList as $account) {
$role = (string) $repository->getMetaValue($account, 'account_role'); $role = (string) $accountRepository->getMetaValue($account, 'account_role');
$name = $account->name; $name = $account->name;
if ('' === $role) { if ('' === $role) {
$role = 'no_account_type'; // @codeCoverageIgnore $role = 'no_account_type'; // @codeCoverageIgnore

View File

@ -282,10 +282,8 @@ class CreateRecurringTransactions implements ShouldQueue
*/ */
private function handleOccurrence(Recurrence $recurrence, RecurrenceRepetition $repetition, Carbon $date): ?TransactionGroup private function handleOccurrence(Recurrence $recurrence, RecurrenceRepetition $repetition, Carbon $date): ?TransactionGroup
{ {
#Log::debug(sprintf('Now at date %s.', $date->format('Y-m-d')));
$date->startOfDay(); $date->startOfDay();
if ($date->ne($this->date)) { if ($date->ne($this->date)) {
#Log::debug(sprintf('%s is not today (%s)', $date->format('Y-m-d'), $this->date->format('Y-m-d')));
return null; return null;
} }

View File

@ -196,7 +196,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
} }
// currency of the account + the piggy bank currency are almost the same. // currency of the account + the piggy bank currency are almost the same.
// which amount from the transaction matches? // which amount from the transaction matches?
// $currency->id === $piggyBankCurrency->id
$amount = null; $amount = null;
if ((int)$source->transaction_currency_id === (int)$currency->id) { if ((int)$source->transaction_currency_id === (int)$currency->id) {
Log::debug('Use normal amount'); Log::debug('Use normal amount');

View File

@ -89,7 +89,6 @@ class RecurrenceUpdateService
$recurrence->save(); $recurrence->save();
// update all meta data: // update all meta data:
//$this->updateMetaData($recurrence, $data);
if (isset($data['recurrence']['notes']) && null !== $data['recurrence']['notes']) { if (isset($data['recurrence']['notes']) && null !== $data['recurrence']['notes']) {
$this->setNoteText($recurrence, $data['recurrence']['notes']); $this->setNoteText($recurrence, $data['recurrence']['notes']);

View File

@ -311,7 +311,6 @@ class Amount
$currencyPrefStr = $currencyPreference ? $currencyPreference->data : 'EUR'; $currencyPrefStr = $currencyPreference ? $currencyPreference->data : 'EUR';
// at this point the currency preference could be encrypted, if coming from an old version. // at this point the currency preference could be encrypted, if coming from an old version.
//Log::debug('Going to try to decrypt users currency preference.');
$currencyCode = $this->tryDecrypt((string) $currencyPrefStr); $currencyCode = $this->tryDecrypt((string) $currencyPrefStr);
// could still be json encoded: // could still be json encoded:
@ -351,7 +350,6 @@ class Amount
try { try {
$value = Crypt::decrypt($value); // verified $value = Crypt::decrypt($value); // verified
} catch (DecryptException $e) { } catch (DecryptException $e) {
//Log::debug(sprintf('Could not decrypt "%s". %s', $value, $e->getMessage()));
} }
return $value; return $value;

View File

@ -69,7 +69,6 @@ class BudgetList implements BinderInterface
// add empty budget if applicable. // add empty budget if applicable.
if (in_array(0, $list, true)) { if (in_array(0, $list, true)) {
//Log::debug('Add empty budget because $list contains 0.');
$collection->push(new Budget); $collection->push(new Budget);
} }

View File

@ -87,8 +87,6 @@ class FireflyConfig
/** @var Configuration $config */ /** @var Configuration $config */
$config = Configuration::where('name', $name)->first(['id', 'name', 'data']); $config = Configuration::where('name', $name)->first(['id', 'name', 'data']);
} catch (QueryException|Exception $e) { } catch (QueryException|Exception $e) {
//Log::error(sprintf('Query exception while polling for config var: %s', $e->getMessage()));
//Log::error($e->getTraceAsString());
throw new FireflyException(sprintf('Could not poll the database: %s', $e->getMessage())); throw new FireflyException(sprintf('Could not poll the database: %s', $e->getMessage()));
} }
@ -156,7 +154,6 @@ class FireflyConfig
if ('testing' === config('app.env')) { if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
} }
//Log::debug('Set new value for ', ['name' => $name]);
/** @var Configuration $config */ /** @var Configuration $config */
try { try {
$config = Configuration::whereName($name)->first(); $config = Configuration::whereName($name)->first();
@ -168,7 +165,6 @@ class FireflyConfig
return $item; return $item;
} }
if (null === $config) { if (null === $config) {
//Log::debug('Does not exist yet ', ['name' => $name]);
/** @var Configuration $item */ /** @var Configuration $item */
$item = new Configuration; $item = new Configuration;
$item->name = $name; $item->name = $name;
@ -179,7 +175,6 @@ class FireflyConfig
return $item; return $item;
} }
//Log::debug('Exists already, overwrite value.', ['name' => $name]);
$config->data = $value; $config->data = $value;
$config->save(); $config->save();
Cache::forget('ff-config-' . $name); Cache::forget('ff-config-' . $name);

View File

@ -46,11 +46,8 @@ trait CalculateRangeOccurrences
{ {
$return = []; $return = [];
$attempts = 0; $attempts = 0;
#Log::debug('Rep is daily. Start of loop.');
while ($start <= $end) { while ($start <= $end) {
#Log::debug(sprintf('Mutator is now: %s', $start->format('Y-m-d')));
if (0 === $attempts % $skipMod) { if (0 === $attempts % $skipMod) {
#Log::debug(sprintf('Attempts modulo skipmod is zero, include %s', $start->format('Y-m-d')));
$return[] = clone $start; $return[] = clone $start;
} }
$start->addDay(); $start->addDay();
@ -77,27 +74,14 @@ trait CalculateRangeOccurrences
$return = []; $return = [];
$attempts = 0; $attempts = 0;
$dayOfMonth = (int)$moment; $dayOfMonth = (int)$moment;
#Log::debug(sprintf('Day of month in repetition is %d', $dayOfMonth));
#Log::debug(sprintf('Start is %s.', $start->format('Y-m-d')));
#Log::debug(sprintf('End is %s.', $end->format('Y-m-d')));
if ($start->day > $dayOfMonth) { if ($start->day > $dayOfMonth) {
#Log::debug('Add a month.');
// day has passed already, add a month. // day has passed already, add a month.
$start->addMonth(); $start->addMonth();
} }
#Log::debug(sprintf('Start is now %s.', $start->format('Y-m-d')));
#Log::debug('Start loop.');
while ($start < $end) { while ($start < $end) {
#Log::debug(sprintf('Mutator is now %s.', $start->format('Y-m-d')));
$domCorrected = min($dayOfMonth, $start->daysInMonth); $domCorrected = min($dayOfMonth, $start->daysInMonth);
#Log::debug(sprintf('DoM corrected is %d', $domCorrected));
$start->day = $domCorrected; $start->day = $domCorrected;
#Log::debug(sprintf('Mutator is now %s.', $start->format('Y-m-d')));
#Log::debug(sprintf('$attempts %% $skipMod === 0 is %s', var_export(0 === $attempts % $skipMod, true)));
#Log::debug(sprintf('$start->lte($mutator) is %s', var_export($start->lte($start), true)));
#Log::debug(sprintf('$end->gte($mutator) is %s', var_export($end->gte($start), true)));
if (0 === $attempts % $skipMod && $start->lte($start) && $end->gte($start)) { if (0 === $attempts % $skipMod && $start->lte($start) && $end->gte($start)) {
#Log::debug(sprintf('ADD %s to return!', $start->format('Y-m-d')));
$return[] = clone $start; $return[] = clone $start;
} }
$attempts++; $attempts++;

View File

@ -240,7 +240,6 @@ class AccountTransformer extends AbstractTransformer
$openingBalance = null; $openingBalance = null;
$openingBalanceDate = null; $openingBalanceDate = null;
if (in_array($accountType, ['asset', 'liabilities'], true)) { if (in_array($accountType, ['asset', 'liabilities'], true)) {
//$journal = $this->repository->getOpeningBalance($account);
$amount = $this->repository->getOpeningBalanceAmount($account); $amount = $this->repository->getOpeningBalanceAmount($account);
$openingBalance = $amount; $openingBalance = $amount;
$openingBalanceDate = $this->repository->getOpeningBalanceDate($account); $openingBalanceDate = $this->repository->getOpeningBalanceDate($account);

View File

@ -53,7 +53,7 @@ trait ReconciliationValidation
return false; return false;
} }
// $types depends on type of source: // types depends on type of source:
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]; $types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
// if source is reconciliation, destination can't be. // if source is reconciliation, destination can't be.
if (null !== $this->source && AccountType::RECONCILIATION === $this->source->accountType->type) { if (null !== $this->source && AccountType::RECONCILIATION === $this->source->accountType->type) {

View File

@ -103,7 +103,7 @@ function updateBudgetedAmount(e) {
updateTotalBudgetedAmount(data.transaction_currency_id); updateTotalBudgetedAmount(data.transaction_currency_id);
}).fail(function () { }).fail(function () {
alert('I failed :('); console.error('I failed :(');
}); });
} else { } else {
$.post(updateBudgetLimitUri.replace('REPLACEME', budgetLimitId.toString()), { $.post(updateBudgetLimitUri.replace('REPLACEME', budgetLimitId.toString()), {
@ -119,7 +119,7 @@ function updateBudgetedAmount(e) {
// update budgeted amount // update budgeted amount
}).fail(function () { }).fail(function () {
alert('I failed :('); console.error('I failed :(');
}); });
} }
} }

View File

@ -70,7 +70,7 @@ $(function () {
}).done(function () { }).done(function () {
window.location.reload(true); window.location.reload(true);
}).fail(function () { }).fail(function () {
alert('Could not change date range'); console.error('Could not change date range');
}); });
} }
); );

View File

@ -53,7 +53,7 @@ function enableGuidance(route, specialPage) {
$.post('json/intro/enable/' + route + '/' + specialPage, {_token: token}).done(function (data) { $.post('json/intro/enable/' + route + '/' + specialPage, {_token: token}).done(function (data) {
alert(data.message); alert(data.message);
}).fail(function () { }).fail(function () {
alert('Could not re-enable introduction.'); console.error('Could not re-enable introduction.');
}); });
} }

View File

@ -18,7 +18,7 @@
<li role="presentation"> <li role="presentation">
<a href="#cmd" aria-controls="profile" role="tab" data-toggle="tab">{{ 'command_line_token'|_ }}</a> <a href="#cmd" aria-controls="profile" role="tab" data-toggle="tab">{{ 'command_line_token'|_ }}</a>
</li> </li>
{% if false == externalIdentity %} {% if false == isExternalIdentity %}
<li role="presentation"> <li role="presentation">
<a href="#oauth" aria-controls="messages" role="tab" data-toggle="tab">{{ 'oauth'|_ }}</a> <a href="#oauth" aria-controls="messages" role="tab" data-toggle="tab">{{ 'oauth'|_ }}</a>
</li> </li>
@ -42,7 +42,7 @@
<div class="row"> <div class="row">
<div class="col-lg-6"> <div class="col-lg-6">
<ul> <ul>
{% if false == externalIdentity %} {% if false == isExternalIdentity %}
<li> <li>
<a href="{{ route('profile.change-email') }}">{{ 'change_your_email'|_ }}</a> <a href="{{ route('profile.change-email') }}">{{ 'change_your_email'|_ }}</a>
</li> </li>
@ -52,7 +52,7 @@
{% endif %} {% endif %}
<li><a href="{{ route('logout') }}">{{ 'logout'|_ }}</a></li> <li><a href="{{ route('logout') }}">{{ 'logout'|_ }}</a></li>
{% if false == externalIdentity %} {% if false == isExternalIdentity %}
<li> <li>
<a href="{{ route('profile.logout-others') }}">{{ 'logout_other_sessions'|_ }}</a> <a href="{{ route('profile.logout-others') }}">{{ 'logout_other_sessions'|_ }}</a>
</li> </li>
@ -93,7 +93,7 @@
</div> </div>
</div> </div>
{% if false == externalIdentity %} {% if false == isExternalIdentity %}
<!-- OAuth --> <!-- OAuth -->
<div role="tabpanel" class="tab-pane" id="oauth"> <div role="tabpanel" class="tab-pane" id="oauth">
<div id="passport_clients"></div> <div id="passport_clients"></div>

View File

@ -240,18 +240,6 @@ Route::group(
} }
); );
//// Bills
//Route::group(
// ['namespace' => 'FireflyIII\Api\V1\Controllers\Chart', 'prefix' => 'chart/bill',
// 'as' => 'api.v1.chart.bill.',],
// static function () {
//
// // Overview API routes:
// // Route::get('overview', ['uses' => 'BillController@overview', 'as' => 'overview']);
// }
//);
// Configuration // Configuration
Route::group( Route::group(
['namespace' => 'FireflyIII\Api\V1\Controllers', 'prefix' => 'configuration', ['namespace' => 'FireflyIII\Api\V1\Controllers', 'prefix' => 'configuration',

View File

@ -78,10 +78,10 @@ Route::group(
} }
); );
///** /**
// * For the two factor routes, the user must be logged in, but NOT 2FA. Account confirmation does not matter here. * For the two factor routes, the user must be logged in, but NOT 2FA. Account confirmation does not matter here.
// * *
// */ */
Route::group( Route::group(
['middleware' => 'user-logged-in-no-2fa', 'prefix' => 'two-factor', 'as' => 'two-factor.', 'namespace' => 'FireflyIII\Http\Controllers\Auth'], ['middleware' => 'user-logged-in-no-2fa', 'prefix' => 'two-factor', 'as' => 'two-factor.', 'namespace' => 'FireflyIII\Http\Controllers\Auth'],
static function () { static function () {
@ -603,11 +603,6 @@ Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'json', 'as' => 'json.'], ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'json', 'as' => 'json.'],
static function () { static function () {
// for auto complete
// Route::get('transaction-journals/all', ['uses' => 'Json\AutoCompleteController@allJournals', 'as' => 'autocomplete.all-journals']);
// Route::get('transaction-journals/with-id', ['uses' => 'Json\AutoCompleteController@allJournalsWithID', 'as' => 'autocomplete.all-journals-with-id']);
// Route::get('currency-names', ['uses' => 'Json\AutoCompleteController@currencyNames', 'as' => 'autocomplete.currency-names']);
// budgets: // budgets:
Route::get( Route::get(
'budget/total-budgeted/{currency}/{start_date}/{end_date}', 'budget/total-budgeted/{currency}/{start_date}/{end_date}',
@ -909,8 +904,6 @@ Route::group(
// index controller // index controller
Route::get('', ['uses' => 'Rule\IndexController@index', 'as' => 'index']); Route::get('', ['uses' => 'Rule\IndexController@index', 'as' => 'index']);
//Route::get('up/{rule}', ['uses' => 'Rule\IndexController@up', 'as' => 'up']);
//Route::get('down/{rule}', ['uses' => 'Rule\IndexController@down', 'as' => 'down']);
Route::post('move-rule/{rule}/{ruleGroup}', ['uses' => 'Rule\IndexController@moveRule', 'as' => 'move-rule']); Route::post('move-rule/{rule}/{ruleGroup}', ['uses' => 'Rule\IndexController@moveRule', 'as' => 'move-rule']);
@ -1044,20 +1037,6 @@ Route::group(
} }
); );
/**
* Transaction Split Controller.
*/
//Route::group(
// ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Transaction', 'prefix' => 'transactions/split',
// 'as' => 'transactions.split.'], static function () {
// // TODO improve these routes
// Route::get('edit/{tj}', ['uses' => 'SplitController@edit', 'as' => 'edit']);
// Route::post('update/{tj}', ['uses' => 'SplitController@update', 'as' => 'update']);
// // TODO end of todo.
//
//}
//);
/** /**
* Transaction Convert Controller. * Transaction Convert Controller.
*/ */