Merge pull request #3278 from CihanSenturk/fix-create-new-currency-decimal-and-thousands-field-control
Create new currency decimal and thousands field control
This commit is contained in:
commit
19adb56f52
|
|
@ -29,8 +29,9 @@ class Currency extends FormRequest
|
|||
'rate' => 'required|gt:0',
|
||||
'enabled' => 'integer|boolean',
|
||||
'default_currency' => 'nullable|boolean',
|
||||
'decimal_mark' => 'required|string|different:thousands_separator|regex:/^[A-Za-z.,_-\s-]+$/',
|
||||
'symbol_first' => 'nullable|boolean',
|
||||
'thousands_separator' => 'different:decimal_mark',
|
||||
'thousands_separator' => 'different:decimal_mark|regex:/^[A-Za-z.,_-`\s-]+$/',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,6 +102,16 @@ class Currency extends Model
|
|||
return $this->contacts()->whereIn('contacts.type', (array) $this->getVendorTypes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default currency.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function default()
|
||||
{
|
||||
return $this->code(default_currency())->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope currency by code.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ const app = new Vue({
|
|||
},
|
||||
|
||||
onChangeCode(code) {
|
||||
if (! code) {
|
||||
return;
|
||||
}
|
||||
|
||||
axios.get(url + '/settings/currencies/config', {
|
||||
params: {
|
||||
code: code
|
||||
|
|
@ -62,5 +66,23 @@ const app = new Vue({
|
|||
this.form.rate = 1;
|
||||
}
|
||||
},
|
||||
'form.decimal_mark': function (newVal, oldVal) {
|
||||
const regex = /^[A-Za-z.,_-\s-]+$/;
|
||||
|
||||
if (newVal && ! regex.test(newVal)) {
|
||||
newVal = newVal.replace(/[^A-Za-z.,_-\s-]+/g, ".");
|
||||
}
|
||||
|
||||
this.form.decimal_mark = newVal;
|
||||
},
|
||||
'form.thousands_separator': function (newVal, oldVal) {
|
||||
const regex = /^[A-Za-z.,_-\s-]+$/;
|
||||
|
||||
if (newVal && ! regex.test(newVal)) {
|
||||
newVal = newVal.replace(/[^A-Za-z.,_-\s-]+/g, ",");
|
||||
}
|
||||
|
||||
this.form.thousands_separator = newVal;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue