added all currencies in global mix

This commit is contained in:
Cüneyt Şentürk 2021-03-18 11:43:10 +03:00
parent 6a392fd9d2
commit 4ebe2ae51d

View File

@ -70,6 +70,7 @@ export default {
"decimal_mark":".",
"thousands_separator":",",
},
all_currencies: [],
}
},
@ -83,6 +84,10 @@ export default {
if (aka_currency) {
this.currency = aka_currency;
}
if (typeof all_currencies !== 'undefined' && all_currencies) {
this.all_currencies = all_currencies;
}
},
methods: {
@ -210,6 +215,10 @@ export default {
// Change bank account get money and currency rate
onChangeAccount(account_id) {
if (!account_id) {
return;
}
axios.get(url + '/banking/accounts/currency', {
params: {
account_id: account_id
@ -227,19 +236,31 @@ export default {
// Change currency get money
onChangeCurrency(currency_code) {
axios.get(url + '/settings/currencies/currency', {
params: {
code: currency_code
}
})
.then(response => {
this.currency = response.data;
if (!currency_code) {
return;
}
this.form.currency_code = response.data.code;
this.form.currency_rate = response.data.rate;
})
.catch(error => {
});
if (!this.all_currencies.length) {
let currency_promise = Promise.resolve(window.axios.get((url + '/settings/currencies')));
currency_promise.then(response => {
if ( response.data.success) {
this.all_currencies = response.data.data;
}
})
.catch(error => {
this.onChangeCurrency(currency_code);
});
}
this.all_currencies.forEach(function (currency, index) {
if (currency_code == currency.code) {
this.currency = currency;
this.form.currency_code = currency.code;
this.form.currency_rate = currency.rate;
}
}, this);
},
// Pages limit change