mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Expand views to allow editing of currency decimals #506
This commit is contained in:
@@ -36,9 +36,10 @@ class CurrencyFormRequest extends Request
|
|||||||
public function getCurrencyData()
|
public function getCurrencyData()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->get('name'),
|
'name' => $this->get('name'),
|
||||||
'code' => $this->get('code'),
|
'code' => $this->get('code'),
|
||||||
'symbol' => $this->get('symbol'),
|
'symbol' => $this->get('symbol'),
|
||||||
|
'decimal_places' => intval($this->get('decimal_places')),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,15 +50,17 @@ class CurrencyFormRequest extends Request
|
|||||||
{
|
{
|
||||||
|
|
||||||
$rules = [
|
$rules = [
|
||||||
'code' => 'required|min:3|max:3|unique:transaction_currencies,code',
|
'name' => 'required|max:48|min:1|unique:transaction_currencies,name',
|
||||||
'name' => 'required|max:48|min:1|unique:transaction_currencies,name',
|
'code' => 'required|min:3|max:3|unique:transaction_currencies,code',
|
||||||
'symbol' => 'required|min:1|max:8|unique:transaction_currencies,symbol',
|
'symbol' => 'required|min:1|max:8|unique:transaction_currencies,symbol',
|
||||||
|
'decimal_places' => 'required|min:0|max:12|numeric',
|
||||||
];
|
];
|
||||||
if (intval($this->get('id')) > 0) {
|
if (intval($this->get('id')) > 0) {
|
||||||
$rules = [
|
$rules = [
|
||||||
'code' => 'required|min:3|max:3',
|
'name' => 'required|max:48|min:1',
|
||||||
'name' => 'required|max:48|min:1',
|
'code' => 'required|min:3|max:3',
|
||||||
'symbol' => 'required|min:1|max:8',
|
'symbol' => 'required|min:1|max:8',
|
||||||
|
'decimal_places' => 'required|min:0|max:12|numeric',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,20 +27,28 @@ class TransactionCurrency extends Model
|
|||||||
{
|
{
|
||||||
use SoftDeletes, ValidatingTrait;
|
use SoftDeletes, ValidatingTrait;
|
||||||
|
|
||||||
protected $dates = ['created_at', 'updated_at', 'deleted_at','date'];
|
|
||||||
protected $fillable = ['name', 'code', 'symbol'];
|
|
||||||
protected $rules = ['name' => 'required|between:1,200', 'code' => 'required|between:3,3', 'symbol' => 'required|between:1,12'];
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be casted to native types.
|
* The attributes that should be casted to native types.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $casts
|
protected $casts
|
||||||
= [
|
= [
|
||||||
'created_at' => 'date',
|
'created_at' => 'date',
|
||||||
'updated_at' => 'date',
|
'updated_at' => 'date',
|
||||||
'deleted_at' => 'date',
|
'deleted_at' => 'date',
|
||||||
|
'decimal_places' => 'int',
|
||||||
];
|
];
|
||||||
|
protected $dates = ['created_at', 'updated_at', 'deleted_at', 'date'];
|
||||||
|
protected $fillable = ['name', 'code', 'symbol', 'decimal_places'];
|
||||||
|
protected $rules
|
||||||
|
= [
|
||||||
|
'name' => 'required|between:1,48',
|
||||||
|
'code' => 'required|between:3,3',
|
||||||
|
'symbol' => 'required|between:1,8',
|
||||||
|
'decimal_places' => 'required|min:0|max:12|numeric',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionCurrency $currency
|
* @param TransactionCurrency $currency
|
||||||
*
|
*
|
||||||
|
@@ -197,9 +197,10 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
{
|
{
|
||||||
$currency = TransactionCurrency::create(
|
$currency = TransactionCurrency::create(
|
||||||
[
|
[
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
'code' => $data['code'],
|
'code' => $data['code'],
|
||||||
'symbol' => $data['symbol'],
|
'symbol' => $data['symbol'],
|
||||||
|
'decimal_places' => $data['decimal_places'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -214,9 +215,10 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function update(TransactionCurrency $currency, array $data): TransactionCurrency
|
public function update(TransactionCurrency $currency, array $data): TransactionCurrency
|
||||||
{
|
{
|
||||||
$currency->code = $data['code'];
|
$currency->code = $data['code'];
|
||||||
$currency->symbol = $data['symbol'];
|
$currency->symbol = $data['symbol'];
|
||||||
$currency->name = $data['name'];
|
$currency->name = $data['name'];
|
||||||
|
$currency->decimal_places = $data['decimal_places'];
|
||||||
$currency->save();
|
$currency->save();
|
||||||
|
|
||||||
return $currency;
|
return $currency;
|
||||||
|
@@ -826,6 +826,7 @@ return [
|
|||||||
'transaction_journal_information' => 'Transaction information',
|
'transaction_journal_information' => 'Transaction information',
|
||||||
'transaction_journal_meta' => 'Meta information',
|
'transaction_journal_meta' => 'Meta information',
|
||||||
'total_amount' => 'Total amount',
|
'total_amount' => 'Total amount',
|
||||||
|
'number_of_decimals' => 'Number of decimals',
|
||||||
|
|
||||||
// administration
|
// administration
|
||||||
'administration' => 'Administration',
|
'administration' => 'Administration',
|
||||||
|
@@ -63,6 +63,7 @@ return [
|
|||||||
'description' => 'Description',
|
'description' => 'Description',
|
||||||
'expense_account' => 'Expense account',
|
'expense_account' => 'Expense account',
|
||||||
'revenue_account' => 'Revenue account',
|
'revenue_account' => 'Revenue account',
|
||||||
|
'decimal_places' => 'Decimal places',
|
||||||
|
|
||||||
'revenue_account_source' => 'Revenue account (source)',
|
'revenue_account_source' => 'Revenue account (source)',
|
||||||
'source_account_asset' => 'Source account (asset account)',
|
'source_account_asset' => 'Source account (asset account)',
|
||||||
@@ -150,30 +151,30 @@ return [
|
|||||||
'category_keep_transactions' => 'The only transaction connected to this category will not be deleted.|All :count transactions connected to this category will spared deletion.',
|
'category_keep_transactions' => 'The only transaction connected to this category will not be deleted.|All :count transactions connected to this category will spared deletion.',
|
||||||
'tag_keep_transactions' => 'The only transaction connected to this tag will not be deleted.|All :count transactions connected to this tag will spared deletion.',
|
'tag_keep_transactions' => 'The only transaction connected to this tag will not be deleted.|All :count transactions connected to this tag will spared deletion.',
|
||||||
|
|
||||||
'email' => 'Email address',
|
'email' => 'Email address',
|
||||||
'password' => 'Password',
|
'password' => 'Password',
|
||||||
'password_confirmation' => 'Password (again)',
|
'password_confirmation' => 'Password (again)',
|
||||||
'blocked' => 'Is blocked?',
|
'blocked' => 'Is blocked?',
|
||||||
'blocked_code' => 'Reason for block',
|
'blocked_code' => 'Reason for block',
|
||||||
|
|
||||||
|
|
||||||
// admin
|
// admin
|
||||||
'domain' => 'Domain',
|
'domain' => 'Domain',
|
||||||
'single_user_mode' => 'Single user mode',
|
'single_user_mode' => 'Single user mode',
|
||||||
'must_confirm_account' => 'New users must activate account',
|
'must_confirm_account' => 'New users must activate account',
|
||||||
'is_demo_site' => 'Is demo site',
|
'is_demo_site' => 'Is demo site',
|
||||||
|
|
||||||
|
|
||||||
// import
|
// import
|
||||||
'import_file' => 'Import file',
|
'import_file' => 'Import file',
|
||||||
'configuration_file' => 'Configuration file',
|
'configuration_file' => 'Configuration file',
|
||||||
'import_file_type' => 'Import file type',
|
'import_file_type' => 'Import file type',
|
||||||
'csv_comma' => 'A comma (,)',
|
'csv_comma' => 'A comma (,)',
|
||||||
'csv_semicolon' => 'A semicolon (;)',
|
'csv_semicolon' => 'A semicolon (;)',
|
||||||
'csv_tab' => 'A tab (invisible)',
|
'csv_tab' => 'A tab (invisible)',
|
||||||
'csv_delimiter' => 'CSV field delimiter',
|
'csv_delimiter' => 'CSV field delimiter',
|
||||||
'csv_import_account' => 'Default import account',
|
'csv_import_account' => 'Default import account',
|
||||||
'csv_config' => 'CSV import configuration',
|
'csv_config' => 'CSV import configuration',
|
||||||
|
|
||||||
|
|
||||||
'due_date' => 'Due date',
|
'due_date' => 'Due date',
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
{{ ExpandedForm.text('name',null,{'maxlength' : 48}) }}
|
{{ ExpandedForm.text('name',null,{'maxlength' : 48}) }}
|
||||||
{{ ExpandedForm.text('symbol',null,{'maxlength': 8}) }}
|
{{ ExpandedForm.text('symbol',null,{'maxlength': 8}) }}
|
||||||
{{ ExpandedForm.text('code',null,{'maxlength' : 3}) }}
|
{{ ExpandedForm.text('code',null,{'maxlength' : 3}) }}
|
||||||
|
{{ ExpandedForm.integer('decimal_places',3,{'maxlength' : 2,'min': 0,'max': 12}) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
{{ ExpandedForm.text('name',null,{'maxlength' : 48}) }}
|
{{ ExpandedForm.text('name',null,{'maxlength' : 48}) }}
|
||||||
{{ ExpandedForm.text('symbol',null,{'maxlength' : 8}) }}
|
{{ ExpandedForm.text('symbol',null,{'maxlength' : 8}) }}
|
||||||
{{ ExpandedForm.text('code',null,{'maxlength' : 3}) }}
|
{{ ExpandedForm.text('code',null,{'maxlength' : 3}) }}
|
||||||
|
{{ ExpandedForm.integer('decimal_places',null,{'maxlength' : 2,'min': 0,'max': 12}) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -20,7 +20,9 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th colspan="2">{{ 'currency'|_ }}</th>
|
<th>{{ 'currency'|_ }}</th>
|
||||||
|
<th>{{ 'number_of_decimals'|_ }}</th>
|
||||||
|
<th> </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -33,6 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ currency.name }} ({{ currency.code }}) ({{ currency.symbol|raw }})</td>
|
<td>{{ currency.name }} ({{ currency.code }}) ({{ currency.symbol|raw }})</td>
|
||||||
|
<td>{{ currency.decimal_places }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if currency.id == defaultCurrency.id %}
|
{% if currency.id == defaultCurrency.id %}
|
||||||
<span class="label label-success">{{ 'default_currency'|_ }}</span>
|
<span class="label label-success">{{ 'default_currency'|_ }}</span>
|
||||||
|
@@ -2,9 +2,8 @@
|
|||||||
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
|
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="input-group">
|
{{ Form.input('number', name, value, options) }}
|
||||||
{{ Form.input('number', name, value, options) }}
|
{% include 'form/help' %}
|
||||||
{% include 'form/feedback' %}
|
{% include 'form/feedback' %}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user