mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
PHPStorm can order methods by alphabet, who knew.
This commit is contained in:
@@ -55,6 +55,37 @@ class AccountForm
|
||||
return $this->select($name, $grouped, $value, $options);
|
||||
}
|
||||
|
||||
private function getAccountsGrouped(array $types, AccountRepositoryInterface $repository = null): array
|
||||
{
|
||||
if (null === $repository) {
|
||||
$repository = $this->getAccountRepository();
|
||||
}
|
||||
$accountList = $repository->getActiveAccountsByType($types);
|
||||
$liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
|
||||
$grouped = [];
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$role = (string)$repository->getMetaValue($account, 'account_role');
|
||||
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
$role = sprintf('l_%s', $account->accountType->type);
|
||||
}
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type';
|
||||
if (AccountType::EXPENSE === $account->accountType->type) {
|
||||
$role = 'expense_account';
|
||||
}
|
||||
if (AccountType::REVENUE === $account->accountType->type) {
|
||||
$role = 'revenue_account';
|
||||
}
|
||||
}
|
||||
$key = (string)trans(sprintf('firefly.opt_group_%s', $role));
|
||||
$grouped[$key][$account->id] = $account->name;
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grouped dropdown list of all accounts that are valid as the destination of a withdrawal.
|
||||
*/
|
||||
@@ -127,35 +158,4 @@ class AccountForm
|
||||
|
||||
return $this->select($name, $grouped, $value, $options);
|
||||
}
|
||||
|
||||
private function getAccountsGrouped(array $types, AccountRepositoryInterface $repository = null): array
|
||||
{
|
||||
if (null === $repository) {
|
||||
$repository = $this->getAccountRepository();
|
||||
}
|
||||
$accountList = $repository->getActiveAccountsByType($types);
|
||||
$liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
|
||||
$grouped = [];
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$role = (string)$repository->getMetaValue($account, 'account_role');
|
||||
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
$role = sprintf('l_%s', $account->accountType->type);
|
||||
}
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type';
|
||||
if (AccountType::EXPENSE === $account->accountType->type) {
|
||||
$role = 'expense_account';
|
||||
}
|
||||
if (AccountType::REVENUE === $account->accountType->type) {
|
||||
$role = 'revenue_account';
|
||||
}
|
||||
}
|
||||
$key = (string)trans(sprintf('firefly.opt_group_%s', $role));
|
||||
$grouped[$key][$account->id] = $account->name;
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
}
|
||||
|
@@ -47,64 +47,6 @@ class CurrencyForm
|
||||
return $this->currencyField($name, 'amount', $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO describe and cleanup.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function balanceAll(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
return $this->allCurrencyField($name, 'balance', $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO cleanup and describe
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function currencyList(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
|
||||
// get all currencies:
|
||||
$list = $currencyRepos->get();
|
||||
$array = [];
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($list as $currency) {
|
||||
$array[$currency->id] = $currency->name.' ('.$currency->symbol.')';
|
||||
}
|
||||
|
||||
return $this->select($name, $array, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO cleanup and describe
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function currencyListEmpty(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
|
||||
// get all currencies:
|
||||
$list = $currencyRepos->get();
|
||||
$array = [
|
||||
0 => (string)trans('firefly.no_currency'),
|
||||
];
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($list as $currency) {
|
||||
$array[$currency->id] = $currency->name.' ('.$currency->symbol.')';
|
||||
}
|
||||
|
||||
return $this->select($name, $array, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
@@ -157,6 +99,18 @@ class CurrencyForm
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO describe and cleanup.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function balanceAll(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
return $this->allCurrencyField($name, 'balance', $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO describe and cleanup
|
||||
*
|
||||
@@ -213,4 +167,50 @@ class CurrencyForm
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO cleanup and describe
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function currencyList(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
|
||||
// get all currencies:
|
||||
$list = $currencyRepos->get();
|
||||
$array = [];
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($list as $currency) {
|
||||
$array[$currency->id] = $currency->name.' ('.$currency->symbol.')';
|
||||
}
|
||||
|
||||
return $this->select($name, $array, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO cleanup and describe
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function currencyListEmpty(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
|
||||
// get all currencies:
|
||||
$list = $currencyRepos->get();
|
||||
$array = [
|
||||
0 => (string)trans('firefly.no_currency'),
|
||||
];
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($list as $currency) {
|
||||
$array[$currency->id] = $currency->name.' ('.$currency->symbol.')';
|
||||
}
|
||||
|
||||
return $this->select($name, $array, $value, $options);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user