mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 18:41:08 +00:00
Expand views to allow editing of currency decimals #506
This commit is contained in:
@@ -39,6 +39,7 @@ class CurrencyFormRequest extends Request
|
||||
'name' => $this->get('name'),
|
||||
'code' => $this->get('code'),
|
||||
'symbol' => $this->get('symbol'),
|
||||
'decimal_places' => intval($this->get('decimal_places')),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -49,15 +50,17 @@ class CurrencyFormRequest extends Request
|
||||
{
|
||||
|
||||
$rules = [
|
||||
'code' => 'required|min:3|max:3|unique:transaction_currencies,code',
|
||||
'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',
|
||||
'decimal_places' => 'required|min:0|max:12|numeric',
|
||||
];
|
||||
if (intval($this->get('id')) > 0) {
|
||||
$rules = [
|
||||
'code' => 'required|min:3|max:3',
|
||||
'name' => 'required|max:48|min:1',
|
||||
'code' => 'required|min:3|max:3',
|
||||
'symbol' => 'required|min:1|max:8',
|
||||
'decimal_places' => 'required|min:0|max:12|numeric',
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -27,9 +27,6 @@ class TransactionCurrency extends Model
|
||||
{
|
||||
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.
|
||||
*
|
||||
@@ -40,7 +37,18 @@ class TransactionCurrency extends Model
|
||||
'created_at' => 'date',
|
||||
'updated_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
|
||||
*
|
||||
|
@@ -200,6 +200,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
'name' => $data['name'],
|
||||
'code' => $data['code'],
|
||||
'symbol' => $data['symbol'],
|
||||
'decimal_places' => $data['decimal_places'],
|
||||
]
|
||||
);
|
||||
|
||||
@@ -217,6 +218,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
$currency->code = $data['code'];
|
||||
$currency->symbol = $data['symbol'];
|
||||
$currency->name = $data['name'];
|
||||
$currency->decimal_places = $data['decimal_places'];
|
||||
$currency->save();
|
||||
|
||||
return $currency;
|
||||
|
@@ -826,6 +826,7 @@ return [
|
||||
'transaction_journal_information' => 'Transaction information',
|
||||
'transaction_journal_meta' => 'Meta information',
|
||||
'total_amount' => 'Total amount',
|
||||
'number_of_decimals' => 'Number of decimals',
|
||||
|
||||
// administration
|
||||
'administration' => 'Administration',
|
||||
|
@@ -63,6 +63,7 @@ return [
|
||||
'description' => 'Description',
|
||||
'expense_account' => 'Expense account',
|
||||
'revenue_account' => 'Revenue account',
|
||||
'decimal_places' => 'Decimal places',
|
||||
|
||||
'revenue_account_source' => 'Revenue account (source)',
|
||||
'source_account_asset' => 'Source account (asset account)',
|
||||
|
@@ -17,6 +17,7 @@
|
||||
{{ ExpandedForm.text('name',null,{'maxlength' : 48}) }}
|
||||
{{ ExpandedForm.text('symbol',null,{'maxlength': 8}) }}
|
||||
{{ ExpandedForm.text('code',null,{'maxlength' : 3}) }}
|
||||
{{ ExpandedForm.integer('decimal_places',3,{'maxlength' : 2,'min': 0,'max': 12}) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -18,6 +18,7 @@
|
||||
{{ ExpandedForm.text('name',null,{'maxlength' : 48}) }}
|
||||
{{ ExpandedForm.text('symbol',null,{'maxlength' : 8}) }}
|
||||
{{ ExpandedForm.text('code',null,{'maxlength' : 3}) }}
|
||||
{{ ExpandedForm.integer('decimal_places',null,{'maxlength' : 2,'min': 0,'max': 12}) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -20,7 +20,9 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th colspan="2">{{ 'currency'|_ }}</th>
|
||||
<th>{{ 'currency'|_ }}</th>
|
||||
<th>{{ 'number_of_decimals'|_ }}</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -33,6 +35,7 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ currency.name }} ({{ currency.code }}) ({{ currency.symbol|raw }})</td>
|
||||
<td>{{ currency.decimal_places }}</td>
|
||||
<td>
|
||||
{% if currency.id == defaultCurrency.id %}
|
||||
<span class="label label-success">{{ 'default_currency'|_ }}</span>
|
||||
|
@@ -2,9 +2,8 @@
|
||||
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
|
||||
|
||||
<div class="col-sm-8">
|
||||
<div class="input-group">
|
||||
{{ Form.input('number', name, value, options) }}
|
||||
{% include 'form/help' %}
|
||||
{% include 'form/feedback' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user