mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various code cleanup.
This commit is contained in:
parent
71f6ba3418
commit
738a311f49
@ -75,6 +75,11 @@ class AccountController extends Controller
|
||||
$defaultCurrency = Amount::getDefaultCurrency();
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
|
||||
$subTitle = trans('firefly.make_new_' . $what . '_account');
|
||||
$roles = [];
|
||||
foreach (config('firefly.accountRoles') as $role) {
|
||||
$roles[$role] = strval(trans('firefly.account_role_' . $role));
|
||||
}
|
||||
|
||||
|
||||
// pre fill some data
|
||||
Session::flash('preFilled', ['currency_id' => $defaultCurrency->id,]);
|
||||
@ -87,7 +92,7 @@ class AccountController extends Controller
|
||||
Session::flash('gaEventCategory', 'accounts');
|
||||
Session::flash('gaEventAction', 'create-' . $what);
|
||||
|
||||
return view('accounts.create', compact('subTitleIcon', 'what', 'subTitle', 'currencies'));
|
||||
return view('accounts.create', compact('subTitleIcon', 'what', 'subTitle', 'currencies', 'roles'));
|
||||
|
||||
}
|
||||
|
||||
@ -155,6 +160,11 @@ class AccountController extends Controller
|
||||
/** @var CurrencyRepositoryInterface $repository */
|
||||
$repository = app(CurrencyRepositoryInterface::class);
|
||||
$currencies = ExpandedForm::makeSelectList($repository->get());
|
||||
$roles = [];
|
||||
foreach (config('firefly.accountRoles') as $role) {
|
||||
$roles[$role] = strval(trans('firefly.account_role_' . $role));
|
||||
}
|
||||
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('accounts.edit.fromUpdate') !== true) {
|
||||
@ -185,7 +195,7 @@ class AccountController extends Controller
|
||||
Session::flash('gaEventCategory', 'accounts');
|
||||
Session::flash('gaEventAction', 'edit-' . $what);
|
||||
|
||||
return view('accounts.edit', compact('currencies', 'account', 'subTitle', 'subTitleIcon', 'openingBalance', 'what'));
|
||||
return view('accounts.edit', compact('currencies', 'account', 'subTitle', 'subTitleIcon', 'openingBalance', 'what', 'roles'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,27 +88,52 @@ class Request extends FormRequest
|
||||
protected function string(string $field): string
|
||||
{
|
||||
$string = $this->get($field) ?? '';
|
||||
|
||||
$search = [
|
||||
"\u{0001}", // start of heading
|
||||
"\u{0002}", // start of text
|
||||
"\u{0003}", // end of text
|
||||
"\u{0004}", // end of transmission
|
||||
"\u{0005}", // enquiry
|
||||
"\u{0006}", // ACK
|
||||
"\u{0007}", // BEL
|
||||
"\u{0008}", // backspace
|
||||
"\u{000E}", // shift out
|
||||
"\u{000F}", // shift in
|
||||
"\u{0010}", // data link escape
|
||||
"\u{0011}", // DC1
|
||||
"\u{0012}", // DC2
|
||||
"\u{0013}", // DC3
|
||||
"\u{0014}", // DC4
|
||||
"\u{0015}", // NAK
|
||||
"\u{0016}", // SYN
|
||||
"\u{0017}", // ETB
|
||||
"\u{0018}", // CAN
|
||||
"\u{0019}", // EM
|
||||
"\u{001A}", // SUB
|
||||
"\u{001B}", // escape
|
||||
"\u{001C}", // file separator
|
||||
"\u{001D}", // group separator
|
||||
"\u{001E}", // record separator
|
||||
"\u{001F}", // unit separator
|
||||
"\u{007F}", // DEL
|
||||
"\u{00A0}", // non-breaking space
|
||||
"\u{1680}", // OGHAM SPACE MARK
|
||||
"\u{180E}", // MONGOLIAN VOWEL SEPARATOR
|
||||
"\u{2000}", // EN QUAD
|
||||
"\u{2001}", // EM QUAD
|
||||
"\u{2002}", // EN SPACE
|
||||
"\u{2003}", // EM SPACE
|
||||
"\u{2004}", // THREE-PER-EM SPACE
|
||||
"\u{2005}", // FOUR-PER-EM SPACE
|
||||
"\u{2006}", // SIX-PER-EM SPACE
|
||||
"\u{2007}", // FIGURE SPACE
|
||||
"\u{2008}", // PUNCTUATION SPACE
|
||||
"\u{2009}", // THIN SPACE
|
||||
"\u{200A}", // HAIR SPACE
|
||||
"\u{200B}", // ZERO WIDTH SPACE
|
||||
"\u{202F}", // NARROW NO-BREAK SPACE
|
||||
"\u{205F}", // MEDIUM MATHEMATICAL SPACE
|
||||
"\u{3000}", // IDEOGRAPHIC SPACE
|
||||
"\u{FEFF}", // ZERO WIDTH NO -BREAK SPACE
|
||||
"\u{1680}", // ogham space mark
|
||||
"\u{180E}", // mongolian vowel separator
|
||||
"\u{2000}", // en quad
|
||||
"\u{2001}", // em quad
|
||||
"\u{2002}", // en space
|
||||
"\u{2003}", // em space
|
||||
"\u{2004}", // three-per-em space
|
||||
"\u{2005}", // four-per-em space
|
||||
"\u{2006}", // six-per-em space
|
||||
"\u{2007}", // figure space
|
||||
"\u{2008}", // punctuation space
|
||||
"\u{2009}", // thin space
|
||||
"\u{200A}", // hair space
|
||||
"\u{200B}", // zero width space
|
||||
"\u{202F}", // narrow no-break space
|
||||
"\u{3000}", // ideographic space
|
||||
"\u{FEFF}", // zero width no -break space
|
||||
];
|
||||
$replace = "\x20"; // plain old normal space
|
||||
$string = str_replace($search, $replace, $string);
|
||||
|
@ -14,7 +14,6 @@ declare(strict_types = 1);
|
||||
namespace FireflyIII\Support\Twig;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Route;
|
||||
@ -42,7 +41,6 @@ class General extends Twig_Extension
|
||||
$this->formatAmountPlain(),
|
||||
$this->formatJournal(),
|
||||
$this->balance(),
|
||||
$this->getAccountRole(),
|
||||
$this->formatFilesize(),
|
||||
$this->mimeIcon(),
|
||||
];
|
||||
@ -234,18 +232,6 @@ class General extends Twig_Extension
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFilter
|
||||
*/
|
||||
protected function getAccountRole(): Twig_SimpleFilter
|
||||
{
|
||||
return new Twig_SimpleFilter(
|
||||
'getAccountRole', function (string $name): string {
|
||||
return Config::get('firefly.accountRoles.' . $name);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
|
@ -41,12 +41,7 @@ return [
|
||||
'default_export_format' => 'csv',
|
||||
'default_import_format' => 'csv',
|
||||
'bill_periods' => ['weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
|
||||
'accountRoles' => [
|
||||
'defaultAsset' => 'Default asset account',
|
||||
'sharedAsset' => 'Shared asset account',
|
||||
'savingAsset' => 'Savings account',
|
||||
'ccAsset' => 'Credit card',
|
||||
],
|
||||
'accountRoles' => ['defaultAsset', 'sharedAsset', 'savingAsset', 'ccAsset',],
|
||||
'ccTypes' => [
|
||||
'monthlyFull' => 'Full payment every month',
|
||||
],
|
||||
|
@ -745,7 +745,10 @@ return [
|
||||
'description' => 'Description',
|
||||
'sum_of_period' => 'Sum of period',
|
||||
'average_in_period' => 'Average in period',
|
||||
|
||||
'account_role_defaultAsset' => 'Default asset account',
|
||||
'account_role_sharedAsset' => 'Shared asset account',
|
||||
'account_role_savingAsset' => 'Savings account',
|
||||
'account_role_ccAsset' => 'Credit card',
|
||||
|
||||
// charts:
|
||||
'chart' => 'Chart',
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
{{ ExpandedForm.balance('openingBalance') }}
|
||||
{{ ExpandedForm.date('openingBalanceDate', phpdate('Y-m-d')) }}
|
||||
{{ ExpandedForm.select('accountRole', Config.get('firefly.accountRoles'),null,{'helpText' : 'asset_account_role_help'|_}) }}
|
||||
{{ ExpandedForm.select('accountRole', roles,null,{'helpText' : 'asset_account_role_help'|_}) }}
|
||||
{{ ExpandedForm.balance('virtualBalance') }}
|
||||
{% endif %}
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
{% if account.accounttype.type == 'Default account' or account.accounttype.type == 'Asset account' %}
|
||||
{{ ExpandedForm.balance('openingBalance',null, {'currency' : openingBalance ? openingBalance.transactionCurrency : null}) }}
|
||||
{{ ExpandedForm.date('openingBalanceDate') }}
|
||||
{{ ExpandedForm.select('accountRole',Config.get('firefly.accountRoles')) }}
|
||||
{{ ExpandedForm.select('accountRole', roles) }}
|
||||
{{ ExpandedForm.balance('virtualBalance',null) }}
|
||||
|
||||
{% endif %}
|
||||
|
@ -28,7 +28,7 @@
|
||||
<td class="hidden-sm hidden-xs">
|
||||
{% for entry in account.accountmeta %}
|
||||
{% if entry.name == 'accountRole' %}
|
||||
{{ entry.data|getAccountRole }}
|
||||
{{ ('account_role_'~entry.data)|_ }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
@ -24,7 +24,7 @@
|
||||
<td class="hidden-sm hidden-xs">
|
||||
{% for entry in account.accountmeta %}
|
||||
{% if entry.name == 'accountRole' %}
|
||||
{{ trans('firefly.'~entry.data|getAccountRole) }}
|
||||
{{ ('account_role_'~entry.data)|_ }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
Loading…
Reference in New Issue
Block a user