mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 20:22:07 +00:00
Clean up some code.
This commit is contained in:
@@ -39,11 +39,8 @@ use Illuminate\View\View;
|
||||
*/
|
||||
class CreateController extends Controller
|
||||
{
|
||||
/** @var CategoryRepositoryInterface The category repository */
|
||||
private $repository;
|
||||
|
||||
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||
private $attachments;
|
||||
private CategoryRepositoryInterface $repository;
|
||||
private AttachmentHelperInterface $attachments;
|
||||
|
||||
/**
|
||||
* CategoryController constructor.
|
||||
@@ -58,7 +55,7 @@ class CreateController extends Controller
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
|
||||
return $next($request);
|
||||
@@ -107,7 +104,7 @@ class CreateController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($category, $files);
|
||||
}
|
||||
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) {
|
||||
|
@@ -45,6 +45,7 @@ use Illuminate\Support\Collection;
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
use DateCalculation, AugumentData, ChartGeneration;
|
||||
|
||||
/** @var GeneratorInterface Chart generation methods. */
|
||||
protected $generator;
|
||||
|
||||
@@ -85,10 +86,10 @@ class CategoryController extends Controller
|
||||
$start = app('navigation')->startOfPeriod($start, $range);
|
||||
$end = $this->getDate();
|
||||
|
||||
/** @var WholePeriodChartGenerator $generator */
|
||||
$generator = app(WholePeriodChartGenerator::class);
|
||||
$chartData = $generator->generate($category, $start, $end);
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
/** @var WholePeriodChartGenerator $chartGenerator */
|
||||
$chartGenerator = app(WholePeriodChartGenerator::class);
|
||||
$chartData = $chartGenerator->generate($category, $start, $end);
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
@@ -111,14 +112,14 @@ class CategoryController extends Controller
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('chart.category.frontpage');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$frontPageGenerator = new FrontpageChartGenerator($start, $end);
|
||||
|
||||
|
||||
$chartData = $frontPageGenerator->generate();
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$chartData = $frontPageGenerator->generate();
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
@@ -210,13 +211,10 @@ class CategoryController extends Controller
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/** @var GeneratorInterface $generator */
|
||||
$generator = app(GeneratorInterface::class);
|
||||
|
||||
/** @var WholePeriodChartGenerator $chartGenerator */
|
||||
$chartGenerator = app(WholePeriodChartGenerator::class);
|
||||
$chartData = $chartGenerator->generate($category, $start, $end);
|
||||
$data = $generator->multiSet($chartData);
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
|
||||
$cache->store($data);
|
||||
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Recurring;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
@@ -45,12 +44,9 @@ use Illuminate\View\View;
|
||||
*/
|
||||
class CreateController extends Controller
|
||||
{
|
||||
/** @var BudgetRepositoryInterface The budget repository */
|
||||
private $budgets;
|
||||
/** @var RecurringRepositoryInterface Recurring repository */
|
||||
private $recurring;
|
||||
|
||||
private AttachmentHelperInterface $attachments;
|
||||
private BudgetRepositoryInterface $budgetRepos;
|
||||
private RecurringRepositoryInterface $recurring;
|
||||
private AttachmentHelperInterface $attachments;
|
||||
|
||||
/**
|
||||
* CreateController constructor.
|
||||
@@ -69,7 +65,7 @@ class CreateController extends Controller
|
||||
app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->budgets = app(BudgetRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
|
||||
return $next($request);
|
||||
@@ -83,7 +79,7 @@ class CreateController extends Controller
|
||||
*/
|
||||
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();
|
||||
$tomorrow = today(config('app.timezone'));
|
||||
$oldRepetitionType = $request->old('repetition_type');
|
||||
@@ -177,7 +173,7 @@ class CreateController extends Controller
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$tomorrow = today(config('app.timezone'));
|
||||
$oldRepetitionType = $request->old('repetition_type');
|
||||
|
@@ -46,11 +46,9 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
*/
|
||||
class EditController extends Controller
|
||||
{
|
||||
/** @var BudgetRepositoryInterface The budget repository */
|
||||
private $budgets;
|
||||
/** @var RecurringRepositoryInterface Recurring repository */
|
||||
private $recurring;
|
||||
private AttachmentHelperInterface $attachments;
|
||||
private BudgetRepositoryInterface $budgetRepos;
|
||||
private RecurringRepositoryInterface $recurring;
|
||||
private AttachmentHelperInterface $attachments;
|
||||
|
||||
/**
|
||||
* EditController constructor.
|
||||
@@ -69,7 +67,7 @@ class EditController extends Controller
|
||||
app('view')->share('subTitle', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->budgets = app(BudgetRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
return $next($request);
|
||||
}
|
||||
@@ -82,9 +80,9 @@ class EditController extends Controller
|
||||
* @param Request $request
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function edit(Request $request, Recurrence $recurrence)
|
||||
{
|
||||
@@ -93,7 +91,7 @@ class EditController extends Controller
|
||||
$transformer->setParameters(new ParameterBag);
|
||||
|
||||
$array = $transformer->transform($recurrence);
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||
|
||||
/** @var RecurrenceRepetition $repetition */
|
||||
$repetition = $recurrence->recurrenceRepetitions()->first();
|
||||
@@ -108,7 +106,7 @@ class EditController extends Controller
|
||||
}
|
||||
$request->session()->forget('recurrences.edit.fromUpdate');
|
||||
|
||||
$repetitionEnd = 'forever';
|
||||
$repetitionEnd = 'forever';
|
||||
$repetitionEnds = [
|
||||
'forever' => (string) trans('firefly.repeat_forever'),
|
||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
||||
@@ -129,7 +127,7 @@ class EditController extends Controller
|
||||
];
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
$preFilled = [
|
||||
'transaction_type' => strtolower($recurrence->transactionType->type),
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active,
|
||||
'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules,
|
||||
@@ -151,8 +149,8 @@ class EditController extends Controller
|
||||
* @param RecurrenceFormRequest $request
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function update(RecurrenceFormRequest $request, Recurrence $recurrence)
|
||||
{
|
||||
|
@@ -45,8 +45,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
class IndexController extends Controller
|
||||
{
|
||||
use GetConfigurationData;
|
||||
/** @var RecurringRepositoryInterface Recurring repository */
|
||||
private $recurring;
|
||||
private RecurringRepositoryInterface $recurringRepos;
|
||||
|
||||
/**
|
||||
* IndexController constructor.
|
||||
@@ -63,7 +62,7 @@ class IndexController extends Controller
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->recurringRepos = app(RecurringRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@@ -84,13 +83,12 @@ class IndexController extends Controller
|
||||
{
|
||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$collection = $this->recurring->get();
|
||||
$collection = $this->recurringRepos->get();
|
||||
$today = today(config('app.timezone'));
|
||||
$year = today(config('app.timezone'));
|
||||
|
||||
// split collection
|
||||
$total = $collection->count();
|
||||
/** @var Collection $recurrences */
|
||||
$recurrences = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
|
||||
/** @var RecurrenceTransformer $transformer */
|
||||
|
@@ -26,7 +26,6 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
@@ -44,9 +43,8 @@ class CategoryController extends Controller
|
||||
{
|
||||
use BasicDataSupport;
|
||||
|
||||
|
||||
/** @var OperationsRepositoryInterface */
|
||||
private $opsRepository;
|
||||
private OperationsRepositoryInterface $opsRepository;
|
||||
private NoCategoryRepositoryInterface $noCatRepository;
|
||||
|
||||
/**
|
||||
* ExpenseReportController constructor.
|
||||
@@ -58,8 +56,8 @@ class CategoryController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$this->noCatRepository = app(NoCategoryRepositoryInterface::class);
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
@@ -505,14 +503,6 @@ class CategoryController extends Controller
|
||||
if ($cache->has()) {
|
||||
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)
|
||||
// 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);
|
||||
$data = [];
|
||||
$with = $opsRepository->listExpenses($start, $end, $accounts);
|
||||
$without = $noCatRepos->listExpenses($start, $end, $accounts);
|
||||
$with = $this->opsRepository->listExpenses($start, $end, $accounts);
|
||||
$without = $this->noCatRepository->listExpenses($start, $end, $accounts);
|
||||
foreach ([$with, $without] as $set) {
|
||||
foreach ($set as $currencyId => $currencyRow) {
|
||||
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
|
||||
@@ -594,12 +584,6 @@ class CategoryController extends Controller
|
||||
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)
|
||||
// change the "listOfPeriods" call so the entire period gets included correctly.
|
||||
$format = app('navigation')->preferredCarbonFormat($start, $end);
|
||||
@@ -613,8 +597,8 @@ class CategoryController extends Controller
|
||||
|
||||
$periods = app('navigation')->listOfPeriods($start, $end);
|
||||
$data = [];
|
||||
$with = $opsRepository->listIncome($start, $end, $accounts);
|
||||
$without = $noCatRepos->listIncome($start, $end, $accounts);
|
||||
$with = $this->opsRepository->listIncome($start, $end, $accounts);
|
||||
$without = $this->noCatRepository->listIncome($start, $end, $accounts);
|
||||
foreach ([$with, $without] as $set) {
|
||||
foreach ($set as $currencyId => $currencyRow) {
|
||||
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
|
||||
@@ -677,19 +661,13 @@ class CategoryController extends Controller
|
||||
$cache->addProperty('category-report');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
// return $cache->get(); // @codeCoverageIgnore
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/** @var OperationsRepositoryInterface $opsRepository */
|
||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||
|
||||
/** @var NoCategoryRepositoryInterface $noCatRepository */
|
||||
$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);
|
||||
$earnedWith = $this->opsRepository->listIncome($start, $end, $accounts);
|
||||
$spentWith = $this->opsRepository->listExpenses($start, $end, $accounts);
|
||||
$earnedWithout = $this->noCatRepository->listIncome($start, $end, $accounts);
|
||||
$spentWithout = $this->noCatRepository->listExpenses($start, $end, $accounts);
|
||||
|
||||
$report = [
|
||||
'categories' => [],
|
||||
|
@@ -43,11 +43,8 @@ class TagController extends Controller
|
||||
{
|
||||
use PeriodOverview;
|
||||
|
||||
/** @var TagRepositoryInterface The tag repository. */
|
||||
protected $repository;
|
||||
|
||||
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||
private $attachments;
|
||||
protected TagRepositoryInterface $repository;
|
||||
private AttachmentHelperInterface $attachmentsHelper;
|
||||
|
||||
/**
|
||||
* TagController constructor.
|
||||
@@ -62,7 +59,7 @@ class TagController extends Controller
|
||||
app('view')->share('title', (string) trans('firefly.tags'));
|
||||
app('view')->share('mainTitleIcon', 'fa-tag');
|
||||
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->attachmentsHelper = app(AttachmentHelperInterface::class);
|
||||
$this->repository = app(TagRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
@@ -323,14 +320,14 @@ class TagController extends Controller
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($result, $files);
|
||||
$this->attachmentsHelper->saveAttachmentsForModel($result, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
@@ -366,14 +363,14 @@ class TagController extends Controller
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($tag, $files);
|
||||
$this->attachmentsHelper->saveAttachmentsForModel($tag, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
|
@@ -81,9 +81,9 @@ class BulkController extends Controller
|
||||
// make amounts positive.
|
||||
|
||||
// get list of budgets:
|
||||
/** @var BudgetRepositoryInterface $repository */
|
||||
$repository = app(BudgetRepositoryInterface::class);
|
||||
$budgetList = app('expandedform')->makeSelectListWithEmpty($repository->getActiveBudgets());
|
||||
/** @var BudgetRepositoryInterface $budgetRepos */
|
||||
$budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$budgetList = app('expandedform')->makeSelectListWithEmpty($budgetRepos->getActiveBudgets());
|
||||
|
||||
return view('transactions.bulk.edit', compact('journals', 'subTitle', 'budgetList'));
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Transaction;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Events\UpdatedTransactionGroup;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -43,7 +42,6 @@ use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Log;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class ConvertController.
|
||||
@@ -55,6 +53,7 @@ class ConvertController extends Controller
|
||||
use ModelInformation, UserNavigation;
|
||||
|
||||
private JournalRepositoryInterface $repository;
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
|
||||
/**
|
||||
* ConvertController constructor.
|
||||
@@ -68,8 +67,8 @@ class ConvertController extends Controller
|
||||
// some useful repositories:
|
||||
$this->middleware(
|
||||
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('mainTitleIcon', 'fa-exchange');
|
||||
|
||||
@@ -85,9 +84,9 @@ class ConvertController extends Controller
|
||||
* @param TransactionType $destinationType
|
||||
* @param TransactionGroup $group
|
||||
*
|
||||
* @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws Exception
|
||||
*
|
||||
* @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index(TransactionType $destinationType, TransactionGroup $group)
|
||||
{
|
||||
@@ -151,9 +150,9 @@ class ConvertController extends Controller
|
||||
* @param TransactionType $destinationType
|
||||
* @param TransactionGroup $group
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @return RedirectResponse|Redirector
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function postIndex(Request $request, TransactionType $destinationType, TransactionGroup $group)
|
||||
{
|
||||
@@ -188,8 +187,8 @@ class ConvertController extends Controller
|
||||
* @param TransactionType $transactionType
|
||||
* @param array $data
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @return TransactionJournal
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function convertJournal(TransactionJournal $journal, TransactionType $transactionType, array $data): TransactionJournal
|
||||
{
|
||||
@@ -245,23 +244,23 @@ class ConvertController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getAssetAccounts(): array
|
||||
{
|
||||
// make repositories
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$accountList = $repository->getActiveAccountsByType([AccountType::ASSET]);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$grouped = [];
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$accountList = $accountRepository->getActiveAccountsByType([AccountType::ASSET]);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$balance = app('steam')->balance($account, today());
|
||||
$currency = $repository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||
$role = (string) $repository->getMetaValue($account, 'account_role');
|
||||
$currency = $accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||
$role = (string) $accountRepository->getMetaValue($account, 'account_role');
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type'; // @codeCoverageIgnore
|
||||
}
|
||||
@@ -274,22 +273,22 @@ class ConvertController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getLiabilities(): array
|
||||
{
|
||||
// make repositories
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$accountList = $repository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$grouped = [];
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$accountList = $accountRepository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$balance = app('steam')->balance($account, today());
|
||||
$currency = $repository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||
$currency = $accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||
$role = 'l_' . $account->accountType->type;
|
||||
$key = (string) trans('firefly.opt_group_' . $role);
|
||||
$grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
|
||||
@@ -304,16 +303,16 @@ class ConvertController extends Controller
|
||||
private function getValidDepositSources(): array
|
||||
{
|
||||
// make repositories
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
|
||||
$accountList = $repository
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
|
||||
$accountList = $accountRepository
|
||||
->getActiveAccountsByType([AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
|
||||
$grouped = [];
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$role = (string) $repository->getMetaValue($account, 'account_role');
|
||||
$role = (string) $accountRepository->getMetaValue($account, 'account_role');
|
||||
$name = $account->name;
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type'; // @codeCoverageIgnore
|
||||
|
Reference in New Issue
Block a user