Add preferences option to enable or disable the custom fiscal year handling.

Stored in DB as 0 or 1 and converted:-
- twig expression in view (expandedform needs true boolean)
- checkbox true/false converted to integer in set function in controller

Oh and I worked out how to localize the label ... took me a while but ended up so simple.

This is stage 1 of the overall custom fiscal year extension for Firefly.
This commit is contained in:
Graham Miller
2016-01-22 21:09:02 +10:00
parent 91b3ca047a
commit d9b3ebc82f
3 changed files with 21 additions and 1 deletions

View File

@@ -39,10 +39,11 @@ class PreferencesController extends Controller
$budgetMax = Preferences::get('budgetMaximum', 1000);
$language = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'))->data;
$budgetMaximum = $budgetMax->data;
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', 'false') == 'true';
return view('preferences.index', compact('budgetMaximum', 'language', 'accounts', 'frontPageAccounts', 'viewRange', 'showIncomplete'));
return view('preferences.index', compact('budgetMaximum', 'language', 'accounts', 'frontPageAccounts', 'viewRange', 'customFiscalYear', 'showIncomplete'));
}
/**
@@ -70,6 +71,10 @@ class PreferencesController extends Controller
$budgetMaximum = intval(Input::get('budgetMaximum'));
Preferences::set('budgetMaximum', $budgetMaximum);
// custom fiscal year
$customFiscalYear = (int) Input::get('customFiscalYear');
Preferences::set('customFiscalYear', $customFiscalYear);
// language:
$lang = Input::get('language');
if (in_array($lang, array_keys(Config::get('firefly.languages')))) {

View File

@@ -169,6 +169,9 @@ return [
'pref_6M' => 'Six months',
'pref_languages' => 'Languages',
'pref_languages_help' => 'Firefly III supports several languages. Which one do you prefer?',
'pref_custom_fiscal_year' => 'Fiscal year settings',
'pref_custom_fiscal_year_label' => 'Enabled',
'pref_custom_fiscal_year_help' => 'In countries that use a financial year other than January 1 to December 31, you can switch this on and specify start / end days of the fiscal year',
'pref_save_settings' => 'Save settings',
// profile:

View File

@@ -45,6 +45,18 @@
{{ ExpandedForm.amount('budgetMaximum',budgetMaximum,{'label' : 'Budget maximum'}) }}
</div>
</div>
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'pref_custom_fiscal_year'|_ }}</h3>
</div>
<div class="box-body">
<p class="text-info">
{{ 'pref_custom_fiscal_year_help'|_ }}
</p>
{% set isCustomFiscalYear = customFiscalYear == 1 ? true : false %}
{{ ExpandedForm.checkbox('customFiscalYear','1',isCustomFiscalYear,{ 'label' : 'pref_custom_fiscal_year_label'|_ }) }}
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">