mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Moved getAccountsByType
This commit is contained in:
@@ -84,29 +84,6 @@ class AccountCrud implements AccountCrudInterface
|
|||||||
return new Account;
|
return new Account;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $types
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getAccountsByType(array $types): Collection
|
|
||||||
{
|
|
||||||
/** @var Collection $result */
|
|
||||||
$query = $this->user->accounts();
|
|
||||||
if (count($types) > 0) {
|
|
||||||
$query->accountTypeIn($types);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $query->get(['accounts.*']);
|
|
||||||
$result = $result->sortBy(
|
|
||||||
function (Account $account) {
|
|
||||||
return strtolower($account->name);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*
|
*
|
||||||
|
@@ -35,13 +35,6 @@ interface AccountCrudInterface
|
|||||||
*/
|
*/
|
||||||
public function findByName(string $name, array $types): Account;
|
public function findByName(string $name, array $types): Account;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $types
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getAccountsByType(array $types): Collection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*
|
*
|
||||||
|
@@ -73,16 +73,16 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
* @param ARI $repository
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function delete(AccountCrudInterface $crud, Account $account)
|
public function delete(ARI $repository, Account $account)
|
||||||
{
|
{
|
||||||
$typeName = config('firefly.shortNamesByFullName.' . $account->accountType->type);
|
$typeName = config('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||||
$subTitle = trans('firefly.delete_' . $typeName . '_account', ['name' => $account->name]);
|
$subTitle = trans('firefly.delete_' . $typeName . '_account', ['name' => $account->name]);
|
||||||
$accountList = ExpandedForm::makeSelectListWithEmpty($crud->getAccountsByType([$account->accountType->type]));
|
$accountList = ExpandedForm::makeSelectListWithEmpty($repository->getAccountsByType([$account->accountType->type]));
|
||||||
unset($accountList[$account->id]);
|
unset($accountList[$account->id]);
|
||||||
|
|
||||||
// put previous url in session
|
// put previous url in session
|
||||||
@@ -158,19 +158,19 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
* @param ARI $repository
|
||||||
* @param string $what
|
* @param string $what
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(AccountCrudInterface $crud, string $what)
|
public function index(ARI $repository, string $what)
|
||||||
{
|
{
|
||||||
$what = $what ?? 'asset';
|
$what = $what ?? 'asset';
|
||||||
|
|
||||||
$subTitle = trans('firefly.' . $what . '_accounts');
|
$subTitle = trans('firefly.' . $what . '_accounts');
|
||||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
|
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
|
||||||
$types = config('firefly.accountTypesByIdentifier.' . $what);
|
$types = config('firefly.accountTypesByIdentifier.' . $what);
|
||||||
$accounts = $crud->getAccountsByType($types);
|
$accounts = $repository->getAccountsByType($types);
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||||
/** @var Carbon $end */
|
/** @var Carbon $end */
|
||||||
@@ -195,13 +195,12 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountTaskerInterface $tasker
|
* @param AccountTaskerInterface $tasker
|
||||||
* @param AccountCrudInterface $crud
|
|
||||||
* @param ARI $repository
|
* @param ARI $repository
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function show(AccountTaskerInterface $tasker, AccountCrudInterface $crud, ARI $repository, Account $account)
|
public function show(AccountTaskerInterface $tasker, ARI $repository, Account $account)
|
||||||
{
|
{
|
||||||
// show journals from current period only:
|
// show journals from current period only:
|
||||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
||||||
@@ -245,7 +244,7 @@ class AccountController extends Controller
|
|||||||
// only include asset accounts when this account is an asset:
|
// only include asset accounts when this account is an asset:
|
||||||
$assets = new Collection;
|
$assets = new Collection;
|
||||||
if (in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEFAULT])) {
|
if (in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEFAULT])) {
|
||||||
$assets = $crud->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
|
$assets = $repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($end >= $start) {
|
while ($end >= $start) {
|
||||||
|
@@ -16,12 +16,12 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
use Amount;
|
use Amount;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Config;
|
use Config;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Http\Requests\BudgetFormRequest;
|
use FireflyIII\Http\Requests\BudgetFormRequest;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\LimitRepetition;
|
use FireflyIII\Models\LimitRepetition;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@@ -159,11 +159,12 @@ class BudgetController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param BudgetRepositoryInterface $repository
|
* @param BudgetRepositoryInterface $repository
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $accountRepository
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function index(BudgetRepositoryInterface $repository, AccountCrudInterface $crud)
|
public function index(BudgetRepositoryInterface $repository, AccountRepositoryInterface $accountRepository)
|
||||||
{
|
{
|
||||||
$repository->cleanupBudgets();
|
$repository->cleanupBudgets();
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ class BudgetController extends Controller
|
|||||||
$period = Navigation::periodShow($start, $range);
|
$period = Navigation::periodShow($start, $range);
|
||||||
$periodStart = $start->formatLocalized($this->monthAndDayFormat);
|
$periodStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||||
$periodEnd = $end->formatLocalized($this->monthAndDayFormat);
|
$periodEnd = $end->formatLocalized($this->monthAndDayFormat);
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
|
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
|
||||||
$startAsString = $start->format('Y-m-d');
|
$startAsString = $start->format('Y-m-d');
|
||||||
$endAsString = $end->format('Y-m-d');
|
$endAsString = $end->format('Y-m-d');
|
||||||
|
|
||||||
|
@@ -14,10 +14,10 @@ declare(strict_types = 1);
|
|||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Http\Requests\CategoryFormRequest;
|
use FireflyIII\Http\Requests\CategoryFormRequest;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
@@ -160,12 +160,12 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CRI $repository
|
* @param CRI $repository
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $accountRepository
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function show(CRI $repository, AccountCrudInterface $crud, Category $category)
|
public function show(CRI $repository, AccountRepositoryInterface $accountRepository, Category $category)
|
||||||
{
|
{
|
||||||
$range = Preferences::get('viewRange', '1M')->data;
|
$range = Preferences::get('viewRange', '1M')->data;
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
@@ -210,7 +210,7 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
$categoryCollection = new Collection([$category]);
|
$categoryCollection = new Collection([$category]);
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
while ($end >= $start) {
|
while ($end >= $start) {
|
||||||
$end = Navigation::startOfPeriod($end, $range);
|
$end = Navigation::startOfPeriod($end, $range);
|
||||||
$currentEnd = Navigation::endOfPeriod($end, $range);
|
$currentEnd = Navigation::endOfPeriod($end, $range);
|
||||||
|
@@ -15,7 +15,6 @@ namespace FireflyIII\Http\Controllers\Chart;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Exception;
|
use Exception;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Generator\Chart\Account\AccountChartGeneratorInterface;
|
use FireflyIII\Generator\Chart\Account\AccountChartGeneratorInterface;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
@@ -54,11 +53,11 @@ class AccountController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Shows the balances for all the user's expense accounts.
|
* Shows the balances for all the user's expense accounts.
|
||||||
*
|
*
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function expenseAccounts(AccountCrudInterface $crud)
|
public function expenseAccounts(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||||
@@ -70,7 +69,7 @@ class AccountController extends Controller
|
|||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return Response::json($cache->get());
|
return Response::json($cache->get());
|
||||||
}
|
}
|
||||||
$accounts = $crud->getAccountsByType([AccountType::EXPENSE, AccountType::BENEFICIARY]);
|
$accounts = $repository->getAccountsByType([AccountType::EXPENSE, AccountType::BENEFICIARY]);
|
||||||
|
|
||||||
$start->subDay();
|
$start->subDay();
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
@@ -103,12 +102,11 @@ class AccountController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Shows the balances for all the user's frontpage accounts.
|
* Shows the balances for all the user's frontpage accounts.
|
||||||
*
|
*
|
||||||
* @param AccountCrudInterface $crud
|
|
||||||
* @param AccountRepositoryInterface $repository
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function frontpage(AccountCrudInterface $crud, AccountRepositoryInterface $repository)
|
public function frontpage(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||||
@@ -124,7 +122,7 @@ class AccountController extends Controller
|
|||||||
return Response::json($cache->get());
|
return Response::json($cache->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
$frontPage = Preferences::get('frontPageAccounts', $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray());
|
$frontPage = Preferences::get('frontPageAccounts', $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray());
|
||||||
$accounts = $repository->getAccountsById($frontPage->data);
|
$accounts = $repository->getAccountsById($frontPage->data);
|
||||||
|
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
|
@@ -15,11 +15,11 @@ namespace FireflyIII\Http\Controllers\Chart;
|
|||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Generator\Chart\Category\CategoryChartGeneratorInterface;
|
use FireflyIII\Generator\Chart\Category\CategoryChartGeneratorInterface;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@@ -53,12 +53,12 @@ class CategoryController extends Controller
|
|||||||
* Show an overview for a category for all time, per month/week/year.
|
* Show an overview for a category for all time, per month/week/year.
|
||||||
*
|
*
|
||||||
* @param CRI $repository
|
* @param CRI $repository
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $accountRepository
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function all(CRI $repository, AccountCrudInterface $crud, Category $category)
|
public function all(CRI $repository, AccountRepositoryInterface $accountRepository, Category $category)
|
||||||
{
|
{
|
||||||
$start = $repository->firstUseDate($category);
|
$start = $repository->firstUseDate($category);
|
||||||
$range = Preferences::get('viewRange', '1M')->data;
|
$range = Preferences::get('viewRange', '1M')->data;
|
||||||
@@ -67,7 +67,7 @@ class CategoryController extends Controller
|
|||||||
$end = new Carbon;
|
$end = new Carbon;
|
||||||
$entries = new Collection;
|
$entries = new Collection;
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('all');
|
$cache->addProperty('all');
|
||||||
@@ -111,11 +111,11 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CRI $repository
|
* @param CRI $repository
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $accountRepository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function frontpage(CRI $repository, AccountCrudInterface $crud)
|
public function frontpage(CRI $repository, AccountRepositoryInterface $accountRepository)
|
||||||
{
|
{
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
@@ -129,7 +129,7 @@ class CategoryController extends Controller
|
|||||||
return Response::json($cache->get());
|
return Response::json($cache->get());
|
||||||
}
|
}
|
||||||
$categories = $repository->getCategories();
|
$categories = $repository->getCategories();
|
||||||
$accounts = $crud->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
|
$accounts = $accountRepository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
|
||||||
$set = new Collection;
|
$set = new Collection;
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
@@ -256,9 +256,10 @@ class CategoryController extends Controller
|
|||||||
{
|
{
|
||||||
$categoryCollection = new Collection([$category]);
|
$categoryCollection = new Collection([$category]);
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
/** @var AccountCrudInterface $crud */
|
|
||||||
$crud = app(AccountCrudInterface::class);
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
|
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
|
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
|
@@ -16,7 +16,6 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use ExpandedForm;
|
use ExpandedForm;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Export\Processor;
|
use FireflyIII\Export\Processor;
|
||||||
use FireflyIII\Http\Requests\ExportFormRequest;
|
use FireflyIII\Http\Requests\ExportFormRequest;
|
||||||
@@ -91,12 +90,12 @@ class ExportController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $repository
|
||||||
* @param EJRI $jobs
|
* @param EJRI $jobs
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(AccountCrudInterface $crud, EJRI $jobs)
|
public function index(AccountRepositoryInterface $repository, EJRI $jobs)
|
||||||
{
|
{
|
||||||
// create new export job.
|
// create new export job.
|
||||||
$job = $jobs->create();
|
$job = $jobs->create();
|
||||||
@@ -104,7 +103,7 @@ class ExportController extends Controller
|
|||||||
$jobs->cleanup();
|
$jobs->cleanup();
|
||||||
|
|
||||||
// does the user have shared accounts?
|
// does the user have shared accounts?
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
$accountList = ExpandedForm::makeSelectList($accounts);
|
$accountList = ExpandedForm::makeSelectList($accounts);
|
||||||
$checked = array_keys($accountList);
|
$checked = array_keys($accountList);
|
||||||
$formats = array_keys(config('firefly.export_formats'));
|
$formats = array_keys(config('firefly.export_formats'));
|
||||||
|
@@ -14,7 +14,6 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
|
|
||||||
use Artisan;
|
use Artisan;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Tag;
|
use FireflyIII\Models\Tag;
|
||||||
@@ -115,12 +114,11 @@ class HomeController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ARI $repository
|
* @param ARI $repository
|
||||||
* @param AccountCrudInterface $crud
|
|
||||||
* @param AccountTaskerInterface $tasker
|
* @param AccountTaskerInterface $tasker
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function index(ARI $repository, AccountCrudInterface $crud, AccountTaskerInterface $tasker)
|
public function index(ARI $repository, AccountTaskerInterface $tasker)
|
||||||
{
|
{
|
||||||
|
|
||||||
$types = config('firefly.accountTypesByIdentifier.asset');
|
$types = config('firefly.accountTypesByIdentifier.asset');
|
||||||
@@ -135,7 +133,7 @@ class HomeController extends Controller
|
|||||||
$mainTitleIcon = 'fa-fire';
|
$mainTitleIcon = 'fa-fire';
|
||||||
$transactions = [];
|
$transactions = [];
|
||||||
$frontPage = Preferences::get(
|
$frontPage = Preferences::get(
|
||||||
'frontPageAccounts', $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray()
|
'frontPageAccounts', $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray()
|
||||||
);
|
);
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
|
@@ -14,9 +14,9 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
|
|
||||||
use Amount;
|
use Amount;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
|
||||||
@@ -98,12 +98,14 @@ class JsonController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountTaskerInterface $accountTasker
|
* @param AccountTaskerInterface $accountTasker
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
* @internal param AccountCrudInterface $crud
|
||||||
|
*
|
||||||
* @internal param ARI $accountRepository
|
* @internal param ARI $accountRepository
|
||||||
*/
|
*/
|
||||||
public function boxIn(AccountTaskerInterface $accountTasker, AccountCrudInterface $crud)
|
public function boxIn(AccountTaskerInterface $accountTasker, AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
@@ -116,8 +118,8 @@ class JsonController extends Controller
|
|||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return Response::json($cache->get());
|
return Response::json($cache->get());
|
||||||
}
|
}
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
|
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
|
||||||
$assets = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$assets = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
$amount = $accountTasker->amountInInPeriod($accounts, $assets, $start, $end);
|
$amount = $accountTasker->amountInInPeriod($accounts, $assets, $start, $end);
|
||||||
$data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
$data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
@@ -126,13 +128,12 @@ class JsonController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
|
||||||
* @param AccountTaskerInterface $accountTasker
|
* @param AccountTaskerInterface $accountTasker
|
||||||
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
* @internal param ARI $accountRepository
|
|
||||||
*/
|
*/
|
||||||
public function boxOut(AccountCrudInterface $crud, AccountTaskerInterface $accountTasker)
|
public function boxOut(AccountTaskerInterface $accountTasker, AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
@@ -146,8 +147,8 @@ class JsonController extends Controller
|
|||||||
return Response::json($cache->get());
|
return Response::json($cache->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
|
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
|
||||||
$assets = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$assets = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
$amount = $accountTasker->amountOutInPeriod($accounts, $assets, $start, $end);
|
$amount = $accountTasker->amountOutInPeriod($accounts, $assets, $start, $end);
|
||||||
|
|
||||||
$data = ['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
$data = ['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||||
@@ -187,13 +188,14 @@ class JsonController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Returns a JSON list of all beneficiaries.
|
* Returns a JSON list of all beneficiaries.
|
||||||
*
|
*
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function expenseAccounts(AccountCrudInterface $crud)
|
public function expenseAccounts(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$list = $crud->getAccountsByType([AccountType::EXPENSE, AccountType::BENEFICIARY]);
|
$list = $repository->getAccountsByType([AccountType::EXPENSE, AccountType::BENEFICIARY]);
|
||||||
$return = [];
|
$return = [];
|
||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
$return[] = $entry->name;
|
$return[] = $entry->name;
|
||||||
@@ -204,13 +206,14 @@ class JsonController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function revenueAccounts(AccountCrudInterface $crud)
|
public function revenueAccounts(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$list = $crud->getAccountsByType([AccountType::REVENUE]);
|
$list = $repository->getAccountsByType([AccountType::REVENUE]);
|
||||||
$return = [];
|
$return = [];
|
||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
$return[] = $entry->name;
|
$return[] = $entry->name;
|
||||||
|
@@ -15,10 +15,10 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
use Amount;
|
use Amount;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use ExpandedForm;
|
use ExpandedForm;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Http\Requests\PiggyBankFormRequest;
|
use FireflyIII\Http\Requests\PiggyBankFormRequest;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Input;
|
use Input;
|
||||||
@@ -88,13 +88,14 @@ class PiggyBankController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function create(AccountCrudInterface $crud)
|
public function create(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$accounts = ExpandedForm::makeSelectList($crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]));
|
$accounts = ExpandedForm::makeSelectList($repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]));
|
||||||
$subTitle = trans('firefly.new_piggy_bank');
|
$subTitle = trans('firefly.new_piggy_bank');
|
||||||
$subTitleIcon = 'fa-plus';
|
$subTitleIcon = 'fa-plus';
|
||||||
|
|
||||||
@@ -144,15 +145,15 @@ class PiggyBankController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $repository
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(AccountCrudInterface $crud, PiggyBank $piggyBank)
|
public function edit(AccountRepositoryInterface $repository, PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
|
|
||||||
$accounts = ExpandedForm::makeSelectList($crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]));
|
$accounts = ExpandedForm::makeSelectList($repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]));
|
||||||
$subTitle = trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);
|
$subTitle = trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);
|
||||||
$subTitleIcon = 'fa-pencil';
|
$subTitleIcon = 'fa-pencil';
|
||||||
$targetDate = null;
|
$targetDate = null;
|
||||||
|
@@ -12,9 +12,9 @@
|
|||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Http\Requests\TokenFormRequest;
|
use FireflyIII\Http\Requests\TokenFormRequest;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use PragmaRX\Google2FA\Contracts\Google2FA;
|
use PragmaRX\Google2FA\Contracts\Google2FA;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
@@ -70,13 +70,13 @@ class PreferencesController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(AccountCrudInterface $crud)
|
public function index(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
$viewRangePref = Preferences::get('viewRange', '1M');
|
$viewRangePref = Preferences::get('viewRange', '1M');
|
||||||
$viewRange = $viewRangePref->data;
|
$viewRange = $viewRangePref->data;
|
||||||
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
|
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
|
||||||
|
@@ -14,7 +14,6 @@ declare(strict_types = 1);
|
|||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Report\BalanceReportHelperInterface;
|
use FireflyIII\Helpers\Report\BalanceReportHelperInterface;
|
||||||
use FireflyIII\Helpers\Report\BudgetReportHelperInterface;
|
use FireflyIII\Helpers\Report\BudgetReportHelperInterface;
|
||||||
@@ -22,6 +21,7 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;
|
|||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
@@ -61,11 +61,11 @@ class ReportController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(AccountCrudInterface $crud)
|
public function index(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$this->createRepositories();
|
$this->createRepositories();
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
@@ -74,7 +74,7 @@ class ReportController extends Controller
|
|||||||
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
|
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
|
||||||
|
|
||||||
// does the user have shared accounts?
|
// does the user have shared accounts?
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
// get id's for quick links:
|
// get id's for quick links:
|
||||||
$accountIds = [];
|
$accountIds = [];
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
|
@@ -15,7 +15,6 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use ExpandedForm;
|
use ExpandedForm;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Http\Requests\RuleGroupFormRequest;
|
use FireflyIII\Http\Requests\RuleGroupFormRequest;
|
||||||
use FireflyIII\Http\Requests\SelectTransactionsRequest;
|
use FireflyIII\Http\Requests\SelectTransactionsRequest;
|
||||||
use FireflyIII\Jobs\ExecuteRuleGroupOnExistingTransactions;
|
use FireflyIII\Jobs\ExecuteRuleGroupOnExistingTransactions;
|
||||||
@@ -179,15 +178,15 @@ class RuleGroupController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountRepositoryInterface $repository
|
||||||
* @param RuleGroup $ruleGroup
|
* @param RuleGroup $ruleGroup
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function selectTransactions(AccountCrudInterface $crud, RuleGroup $ruleGroup)
|
public function selectTransactions(AccountRepositoryInterface $repository, RuleGroup $ruleGroup)
|
||||||
{
|
{
|
||||||
// does the user have shared accounts?
|
// does the user have shared accounts?
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
$accountList = ExpandedForm::makeSelectList($accounts);
|
$accountList = ExpandedForm::makeSelectList($accounts);
|
||||||
$checkedAccounts = array_keys($accountList);
|
$checkedAccounts = array_keys($accountList);
|
||||||
$first = session('first')->format('Y-m-d');
|
$first = session('first')->format('Y-m-d');
|
||||||
|
@@ -20,6 +20,7 @@ use FireflyIII\Http\Requests\MassDeleteJournalRequest;
|
|||||||
use FireflyIII\Http\Requests\MassEditJournalRequest;
|
use FireflyIII\Http\Requests\MassEditJournalRequest;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
@@ -108,8 +109,10 @@ class MassController extends Controller
|
|||||||
public function massEdit(Collection $journals)
|
public function massEdit(Collection $journals)
|
||||||
{
|
{
|
||||||
$subTitle = trans('firefly.mass_edit_journals');
|
$subTitle = trans('firefly.mass_edit_journals');
|
||||||
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
|
|
||||||
$accountList = ExpandedForm::makeSelectList($crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]));
|
/** @var AccountRepositoryInterface $repository */
|
||||||
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
|
$accountList = ExpandedForm::makeSelectList($repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]));
|
||||||
|
|
||||||
// skip transactions that have multiple destinations
|
// skip transactions that have multiple destinations
|
||||||
// or multiple sources:
|
// or multiple sources:
|
||||||
|
@@ -24,6 +24,7 @@ use FireflyIII\Models\Account;
|
|||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -61,8 +62,11 @@ class SplitController extends Controller
|
|||||||
$currencyRepository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
|
$currencyRepository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
|
||||||
$budgetRepository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
$budgetRepository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||||
$piggyRepository = app('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
|
$piggyRepository = app('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
|
||||||
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
|
|
||||||
$assetAccounts = ExpandedForm::makeSelectList($crud->getAccountsByType(['Default account', 'Asset account']));
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
$assetAccounts = ExpandedForm::makeSelectList($accountRepository->getAccountsByType(['Default account', 'Asset account']));
|
||||||
$sessionData = session('journal-data', []);
|
$sessionData = session('journal-data', []);
|
||||||
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
|
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
|
||||||
$currencies = ExpandedForm::makeSelectList($currencyRepository->get());
|
$currencies = ExpandedForm::makeSelectList($currencyRepository->get());
|
||||||
@@ -100,10 +104,13 @@ class SplitController extends Controller
|
|||||||
{
|
{
|
||||||
$currencyRepository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
|
$currencyRepository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
|
||||||
$budgetRepository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
$budgetRepository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||||
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
|
|
||||||
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
|
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
|
||||||
$currencies = ExpandedForm::makeSelectList($currencyRepository->get());
|
$currencies = ExpandedForm::makeSelectList($currencyRepository->get());
|
||||||
$assetAccounts = ExpandedForm::makeSelectList($crud->getAccountsByType(['Default account', 'Asset account']));
|
$assetAccounts = ExpandedForm::makeSelectList($accountRepository->getAccountsByType(['Default account', 'Asset account']));
|
||||||
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
||||||
$budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
$budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
||||||
$preFilled = $this->arrayFromJournal($request, $journal);
|
$preFilled = $this->arrayFromJournal($request, $journal);
|
||||||
|
@@ -23,6 +23,7 @@ use FireflyIII\Http\Requests\JournalFormRequest;
|
|||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
@@ -150,8 +151,11 @@ class TransactionController extends Controller
|
|||||||
// code to get list data:
|
// code to get list data:
|
||||||
$budgetRepository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
$budgetRepository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||||
$piggyRepository = app('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
|
$piggyRepository = app('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
|
||||||
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
|
|
||||||
$assetAccounts = ExpandedForm::makeSelectList($crud->getAccountsByType(['Default account', 'Asset account']));
|
/** @var AccountRepositoryInterface $repository */
|
||||||
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
$assetAccounts = ExpandedForm::makeSelectList($repository->getAccountsByType(['Default account', 'Asset account']));
|
||||||
$budgetList = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
$budgetList = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
||||||
$piggyBankList = ExpandedForm::makeSelectListWithEmpty($piggyRepository->getPiggyBanks());
|
$piggyBankList = ExpandedForm::makeSelectListWithEmpty($piggyRepository->getPiggyBanks());
|
||||||
|
|
||||||
|
@@ -13,9 +13,9 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Import\Mapper;
|
namespace FireflyIII\Import\Mapper;
|
||||||
|
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AssetAccounts
|
* Class AssetAccounts
|
||||||
@@ -30,9 +30,9 @@ class AssetAccountIbans implements MapperInterface
|
|||||||
*/
|
*/
|
||||||
public function getMap(): array
|
public function getMap(): array
|
||||||
{
|
{
|
||||||
/** @var AccountCrudInterface $crud */
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
$crud = app(AccountCrudInterface::class);
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$set = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$set = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
$topList = [];
|
$topList = [];
|
||||||
$list = [];
|
$list = [];
|
||||||
|
|
||||||
|
@@ -13,9 +13,9 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Import\Mapper;
|
namespace FireflyIII\Import\Mapper;
|
||||||
|
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AssetAccounts
|
* Class AssetAccounts
|
||||||
@@ -30,9 +30,9 @@ class AssetAccounts implements MapperInterface
|
|||||||
*/
|
*/
|
||||||
public function getMap(): array
|
public function getMap(): array
|
||||||
{
|
{
|
||||||
/** @var AccountCrudInterface $crud */
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
$crud = app(AccountCrudInterface::class);
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$set = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$set = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
$list = [];
|
$list = [];
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
|
@@ -13,9 +13,9 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Import\Mapper;
|
namespace FireflyIII\Import\Mapper;
|
||||||
|
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class OpposingAccounts
|
* Class OpposingAccounts
|
||||||
@@ -30,9 +30,9 @@ class OpposingAccountIbans implements MapperInterface
|
|||||||
*/
|
*/
|
||||||
public function getMap(): array
|
public function getMap(): array
|
||||||
{
|
{
|
||||||
/** @var AccountCrudInterface $crud */
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
$crud = app(AccountCrudInterface::class);
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$set = $crud->getAccountsByType(
|
$set = $accountRepository->getAccountsByType(
|
||||||
[
|
[
|
||||||
AccountType::DEFAULT, AccountType::ASSET,
|
AccountType::DEFAULT, AccountType::ASSET,
|
||||||
AccountType::EXPENSE, AccountType::BENEFICIARY,
|
AccountType::EXPENSE, AccountType::BENEFICIARY,
|
||||||
|
@@ -13,9 +13,9 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Import\Mapper;
|
namespace FireflyIII\Import\Mapper;
|
||||||
|
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class OpposingAccounts
|
* Class OpposingAccounts
|
||||||
@@ -30,9 +30,9 @@ class OpposingAccounts implements MapperInterface
|
|||||||
*/
|
*/
|
||||||
public function getMap(): array
|
public function getMap(): array
|
||||||
{
|
{
|
||||||
/** @var AccountCrudInterface $crud */
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
$crud = app(AccountCrudInterface::class);
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$set = $crud->getAccountsByType(
|
$set = $accountRepository->getAccountsByType(
|
||||||
[
|
[
|
||||||
AccountType::DEFAULT, AccountType::ASSET,
|
AccountType::DEFAULT, AccountType::ASSET,
|
||||||
AccountType::EXPENSE, AccountType::BENEFICIARY,
|
AccountType::EXPENSE, AccountType::BENEFICIARY,
|
||||||
|
@@ -15,7 +15,6 @@ namespace FireflyIII\Import\Setup;
|
|||||||
|
|
||||||
|
|
||||||
use ExpandedForm;
|
use ExpandedForm;
|
||||||
use FireflyIII\Crud\Account\AccountCrud;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Import\Mapper\MapperInterface;
|
use FireflyIII\Import\Mapper\MapperInterface;
|
||||||
use FireflyIII\Import\MapperPreProcess\PreProcessorInterface;
|
use FireflyIII\Import\MapperPreProcess\PreProcessorInterface;
|
||||||
@@ -75,8 +74,9 @@ class CsvSetup implements SetupInterface
|
|||||||
*/
|
*/
|
||||||
public function getConfigurationData(): array
|
public function getConfigurationData(): array
|
||||||
{
|
{
|
||||||
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
|
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
$delimiters = [
|
$delimiters = [
|
||||||
',' => trans('form.csv_comma'),
|
',' => trans('form.csv_comma'),
|
||||||
';' => trans('form.csv_semicolon'),
|
';' => trans('form.csv_semicolon'),
|
||||||
|
@@ -202,6 +202,29 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $types
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getAccountsByType(array $types): Collection
|
||||||
|
{
|
||||||
|
/** @var Collection $result */
|
||||||
|
$query = $this->user->accounts();
|
||||||
|
if (count($types) > 0) {
|
||||||
|
$query->accountTypeIn($types);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $query->get(['accounts.*']);
|
||||||
|
$result = $result->sortBy(
|
||||||
|
function (Account $account) {
|
||||||
|
return strtolower($account->name);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the date of the very first transaction in this account.
|
* Returns the date of the very first transaction in this account.
|
||||||
*
|
*
|
||||||
|
@@ -34,21 +34,6 @@ interface AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function count(array $types): int;
|
public function count(array $types): int;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $accountIds
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getAccountsById(array $accountIds): Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $name
|
|
||||||
* @param array $types
|
|
||||||
*
|
|
||||||
* @return Account
|
|
||||||
*/
|
|
||||||
public function findByName(string $name, array $types): Account;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moved here from account CRUD.
|
* Moved here from account CRUD.
|
||||||
*
|
*
|
||||||
@@ -82,6 +67,28 @@ interface AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function findByIban(string $iban, array $types): Account;
|
public function findByIban(string $iban, array $types): Account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param array $types
|
||||||
|
*
|
||||||
|
* @return Account
|
||||||
|
*/
|
||||||
|
public function findByName(string $name, array $types): Account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $accountIds
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getAccountsById(array $accountIds): Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $types
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getAccountsByType(array $types): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the date of the very first transaction in this account.
|
* Returns the date of the very first transaction in this account.
|
||||||
*
|
*
|
||||||
|
@@ -62,6 +62,15 @@ interface AccountTaskerInterface
|
|||||||
*/
|
*/
|
||||||
public function expenseReport(Collection $accounts, Collection $excluded, Carbon $start, Carbon $end): Collection;
|
public function expenseReport(Collection $accounts, Collection $excluded, Carbon $start, Carbon $end): Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return AccountCollection
|
||||||
|
*/
|
||||||
|
public function getAccountReport(Carbon $start, Carbon $end, Collection $accounts): AccountCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Experimental getJournals method.
|
* Experimental getJournals method.
|
||||||
*
|
*
|
||||||
@@ -74,15 +83,6 @@ interface AccountTaskerInterface
|
|||||||
*/
|
*/
|
||||||
public function getJournalsInPeriod(Collection $accounts, array $types, Carbon $start, Carbon $end): Collection;
|
public function getJournalsInPeriod(Collection $accounts, array $types, Carbon $start, Carbon $end): Collection;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
|
||||||
* @return AccountCollection
|
|
||||||
*/
|
|
||||||
public function getAccountReport(Carbon $start, Carbon $end, Collection $accounts): AccountCollection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
* @param Collection $excluded
|
* @param Collection $excluded
|
||||||
|
Reference in New Issue
Block a user