This commit is contained in:
James Cole 2025-02-09 05:26:37 +01:00
parent f9bcc4b1fa
commit edab602bb7
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
7 changed files with 255 additions and 202 deletions

View File

@ -113,6 +113,11 @@ class AccountController extends Controller
'currency_code' => $useCurrency->code, 'currency_code' => $useCurrency->code,
'currency_symbol' => $useCurrency->symbol, 'currency_symbol' => $useCurrency->symbol,
'currency_decimal_places' => $useCurrency->decimal_places, 'currency_decimal_places' => $useCurrency->decimal_places,
'account_currency_id' => (string) $currency->id,
'account_currency_name' => $currency->name,
'account_currency_code' => $currency->code,
'account_currency_symbol' => $currency->symbol,
'account_currency_decimal_places' => $currency->decimal_places,
]; ];
} }

View File

@ -20,8 +20,12 @@
"/public/v1/js/app.js.LICENSE.txt": "/public/v1/js/app.js.LICENSE.txt", "/public/v1/js/app.js.LICENSE.txt": "/public/v1/js/app.js.LICENSE.txt",
"/public/v1/js/app_vue.js": "/public/v1/js/app_vue.js", "/public/v1/js/app_vue.js": "/public/v1/js/app_vue.js",
"/public/v1/js/app_vue.js.LICENSE.txt": "/public/v1/js/app_vue.js.LICENSE.txt", "/public/v1/js/app_vue.js.LICENSE.txt": "/public/v1/js/app_vue.js.LICENSE.txt",
"/public/v1/js/create.js": "/public/v1/js/create.js",
"/public/v1/js/create.js.LICENSE.txt": "/public/v1/js/create.js.LICENSE.txt",
"/public/v1/js/create_transaction.js": "/public/v1/js/create_transaction.js", "/public/v1/js/create_transaction.js": "/public/v1/js/create_transaction.js",
"/public/v1/js/create_transaction.js.LICENSE.txt": "/public/v1/js/create_transaction.js.LICENSE.txt", "/public/v1/js/create_transaction.js.LICENSE.txt": "/public/v1/js/create_transaction.js.LICENSE.txt",
"/public/v1/js/edit.js": "/public/v1/js/edit.js",
"/public/v1/js/edit.js.LICENSE.txt": "/public/v1/js/edit.js.LICENSE.txt",
"/public/v1/js/edit_transaction.js": "/public/v1/js/edit_transaction.js", "/public/v1/js/edit_transaction.js": "/public/v1/js/edit_transaction.js",
"/public/v1/js/edit_transaction.js.LICENSE.txt": "/public/v1/js/edit_transaction.js.LICENSE.txt", "/public/v1/js/edit_transaction.js.LICENSE.txt": "/public/v1/js/edit_transaction.js.LICENSE.txt",
"/public/v1/js/exchange-rates/index.js": "/public/v1/js/exchange-rates/index.js", "/public/v1/js/exchange-rates/index.js": "/public/v1/js/exchange-rates/index.js",
@ -96,6 +100,8 @@
"/public/v1/js/ff/transactions/mass/edit-bulk.js": "/public/v1/js/ff/transactions/mass/edit-bulk.js", "/public/v1/js/ff/transactions/mass/edit-bulk.js": "/public/v1/js/ff/transactions/mass/edit-bulk.js",
"/public/v1/js/ff/transactions/mass/edit.js": "/public/v1/js/ff/transactions/mass/edit.js", "/public/v1/js/ff/transactions/mass/edit.js": "/public/v1/js/ff/transactions/mass/edit.js",
"/public/v1/js/ff/transactions/show.js": "/public/v1/js/ff/transactions/show.js", "/public/v1/js/ff/transactions/show.js": "/public/v1/js/ff/transactions/show.js",
"/public/v1/js/index.js": "/public/v1/js/index.js",
"/public/v1/js/index.js.LICENSE.txt": "/public/v1/js/index.js.LICENSE.txt",
"/public/v1/js/lib/Chart.bundle.min.js": "/public/v1/js/lib/Chart.bundle.min.js", "/public/v1/js/lib/Chart.bundle.min.js": "/public/v1/js/lib/Chart.bundle.min.js",
"/public/v1/js/lib/accounting.min.js": "/public/v1/js/lib/accounting.min.js", "/public/v1/js/lib/accounting.min.js": "/public/v1/js/lib/accounting.min.js",
"/public/v1/js/lib/bootstrap-multiselect.js": "/public/v1/js/lib/bootstrap-multiselect.js", "/public/v1/js/lib/bootstrap-multiselect.js": "/public/v1/js/lib/bootstrap-multiselect.js",
@ -154,6 +160,8 @@
"/public/v1/js/lib/vue.js": "/public/v1/js/lib/vue.js", "/public/v1/js/lib/vue.js": "/public/v1/js/lib/vue.js",
"/public/v1/js/profile.js": "/public/v1/js/profile.js", "/public/v1/js/profile.js": "/public/v1/js/profile.js",
"/public/v1/js/profile.js.LICENSE.txt": "/public/v1/js/profile.js.LICENSE.txt", "/public/v1/js/profile.js.LICENSE.txt": "/public/v1/js/profile.js.LICENSE.txt",
"/public/v1/js/show.js": "/public/v1/js/show.js",
"/public/v1/js/show.js.LICENSE.txt": "/public/v1/js/show.js.LICENSE.txt",
"/public/v1/js/webhooks/create.js": "/public/v1/js/webhooks/create.js", "/public/v1/js/webhooks/create.js": "/public/v1/js/webhooks/create.js",
"/public/v1/js/webhooks/create.js.LICENSE.txt": "/public/v1/js/webhooks/create.js.LICENSE.txt", "/public/v1/js/webhooks/create.js.LICENSE.txt": "/public/v1/js/webhooks/create.js.LICENSE.txt",
"/public/v1/js/webhooks/edit.js": "/public/v1/js/webhooks/edit.js", "/public/v1/js/webhooks/edit.js": "/public/v1/js/webhooks/edit.js",

View File

@ -381,7 +381,7 @@ export default {
this.totalPages = parseInt(response.data.meta.pagination.total_pages); this.totalPages = parseInt(response.data.meta.pagination.total_pages);
this.loading = false; this.loading = false;
this.rates = Object.values(this.tempRates); this.rates = Object.values(this.tempRates);
console.log('Do not download more pages. Now on page ' + this.page + ' of ' + this.totalPages); // console.log('Do not download more pages. Now on page ' + this.page + ' of ' + this.totalPages);
}); });
} }
}, },

View File

@ -36,7 +36,6 @@
class="form-control" class="form-control"
data-role="input" data-role="input"
type="text" type="text"
v-on:keypress="handleEnter"
v-on:submit.prevent> v-on:submit.prevent>
<span class="input-group-btn"> <span class="input-group-btn">
<button <button
@ -217,7 +216,7 @@ export default {
} }
}, },
selectedItem: function (e) { selectedItem: function (e) {
// console.log('In SelectedItem()'); console.log('In SelectedItem()');
if (typeof this.name === 'undefined') { if (typeof this.name === 'undefined') {
// console.log('Is undefined'); // console.log('Is undefined');
return; return;
@ -239,12 +238,6 @@ export default {
this.name = ''; this.name = '';
// some event? // some event?
this.$emit('clear:value') this.$emit('clear:value')
},
handleEnter: function (e) {
// TODO feels sloppy. Can be removed.
if (e.keyCode === 13) {
//e.preventDefault();
}
} }
} }
} }

View File

@ -922,6 +922,12 @@ export default {
allowed_types: this.transactions[index].source_account.allowed_types, allowed_types: this.transactions[index].source_account.allowed_types,
default_allowed_types: ['Asset account', 'Revenue account', 'Loan', 'Debt', 'Mortgage'] default_allowed_types: ['Asset account', 'Revenue account', 'Loan', 'Debt', 'Mortgage']
}; };
if(model.hasOwnProperty('account_currency_id') && null !== model.account_currency_id) {
this.transactions[index].source_account.currency_id = model.account_currency_id;
this.transactions[index].source_account.currency_name = model.account_currency_name;
this.transactions[index].source_account.currency_code = model.account_currency_code;
this.transactions[index].source_account.currency_decimal_places = model.account_currency_decimal_places;
}
// force types on destination selector. // force types on destination selector.
this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type]; this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
@ -946,6 +952,12 @@ export default {
allowed_types: this.transactions[index].destination_account.allowed_types, allowed_types: this.transactions[index].destination_account.allowed_types,
default_allowed_types: ['Asset account', 'Expense account', 'Loan', 'Debt', 'Mortgage'] default_allowed_types: ['Asset account', 'Expense account', 'Loan', 'Debt', 'Mortgage']
}; };
if(model.hasOwnProperty('account_currency_id') && null !== model.account_currency_id) {
this.transactions[index].destination_account.currency_id = model.account_currency_id;
this.transactions[index].destination_account.currency_name = model.account_currency_name;
this.transactions[index].destination_account.currency_code = model.account_currency_code;
this.transactions[index].destination_account.currency_decimal_places = model.account_currency_decimal_places;
}
// force types on destination selector. // force types on destination selector.
this.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type]; this.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type];

View File

@ -155,8 +155,8 @@
v-bind:title="$t('form.foreign_amount')" v-bind:title="$t('form.foreign_amount')"
></foreign-amount> ></foreign-amount>
<reconciled v-show="isReconciled" <reconciled v-show="isReconciled"
v-model="transaction.reconciled" v-model="transaction.reconciled"
:error="transaction.errors.reconciled" :error="transaction.errors.reconciled"
></reconciled> ></reconciled>
</div> </div>
<div class="col-lg-4"> <div class="col-lg-4">
@ -322,6 +322,12 @@ export default {
currency_decimal_places: model.currency_decimal_places, currency_decimal_places: model.currency_decimal_places,
allowed_types: this.transactions[index].source_account.allowed_types allowed_types: this.transactions[index].source_account.allowed_types
}; };
if(model.hasOwnProperty('account_currency_id') && null !== model.account_currency_id) {
this.transactions[index].source_account.currency_id = model.account_currency_id;
this.transactions[index].source_account.currency_name = model.account_currency_name;
this.transactions[index].source_account.currency_code = model.account_currency_code;
this.transactions[index].source_account.currency_decimal_places = model.account_currency_decimal_places;
}
}, },
selectedDestinationAccount(index, model) { selectedDestinationAccount(index, model) {
if (typeof model === 'string') { if (typeof model === 'string') {
@ -341,6 +347,12 @@ export default {
currency_decimal_places: model.currency_decimal_places, currency_decimal_places: model.currency_decimal_places,
allowed_types: this.transactions[index].destination_account.allowed_types allowed_types: this.transactions[index].destination_account.allowed_types
}; };
if(model.hasOwnProperty('account_currency_id') && null !== model.account_currency_id) {
this.transactions[index].destination_account.currency_id = model.account_currency_id;
this.transactions[index].destination_account.currency_name = model.account_currency_name;
this.transactions[index].destination_account.currency_code = model.account_currency_code;
this.transactions[index].destination_account.currency_decimal_places = model.account_currency_decimal_places;
}
}, },
clearSource(index) { clearSource(index) {
// reset source account: // reset source account:
@ -437,7 +449,7 @@ export default {
//console.log('EditTransaction: processIncomingGroupRow()'); //console.log('EditTransaction: processIncomingGroupRow()');
this.setTransactionType(transaction.type); this.setTransactionType(transaction.type);
if(true === transaction.reconciled) { if (true === transaction.reconciled) {
this.isReconciled = true; this.isReconciled = true;
} }
@ -528,7 +540,16 @@ export default {
allowed_types: window.expectedSourceTypes.destination[this.ucFirst(transaction.type)] allowed_types: window.expectedSourceTypes.destination[this.ucFirst(transaction.type)]
} }
}; };
if(null === transaction.foreign_amount) { // if transaction type is transfer, the destination currency_id etc. MUST match the actual account currency info.
if ('transfer' === transaction.type && null !== transaction.foreign_currency_code) {
result.destination_account.currency_id = transaction.foreign_currency_id;
result.destination_account.currency_name = transaction.foreign_currency_name;
result.destination_account.currency_code = transaction.foreign_currency_code;
result.destination_account.currency_decimal_places = transaction.foreign_currency_decimal_places;
}
if (null === transaction.foreign_amount) {
result.foreign_amount.amount = ''; result.foreign_amount.amount = '';
} }
this.transactions.push(result); this.transactions.push(result);
@ -736,7 +757,7 @@ export default {
if (parseInt(row.piggy_bank) > 0) { if (parseInt(row.piggy_bank) > 0) {
currentArray.piggy_bank_id = parseInt(row.piggy_bank); currentArray.piggy_bank_id = parseInt(row.piggy_bank);
} }
if(this.isReconciled && !this.storeAsNew && true === row.reconciled) { if (this.isReconciled && !this.storeAsNew && true === row.reconciled) {
// drop content from array: // drop content from array:
delete currentArray.source_id; delete currentArray.source_id;
delete currentArray.source_name; delete currentArray.source_name;
@ -748,7 +769,7 @@ export default {
delete currentArray.currency_id; delete currentArray.currency_id;
currentArray.reconciled = true; currentArray.reconciled = true;
} }
if(true === row.isReconciled) { if (true === row.isReconciled) {
this.isReconciled = false; this.isReconciled = false;
} }
@ -801,10 +822,16 @@ export default {
this.setDefaultErrors(); this.setDefaultErrors();
// do message if update or new: // do message if update or new:
if (this.storeAsNew) { if (this.storeAsNew) {
this.success_message = this.$t('firefly.transaction_new_stored_link', {ID: groupId, title: this.escapeHtml(title)}); this.success_message = this.$t('firefly.transaction_new_stored_link', {
ID: groupId,
title: this.escapeHtml(title)
});
this.error_message = ''; this.error_message = '';
} else { } else {
this.success_message = this.$t('firefly.transaction_updated_link', {ID: groupId, title: this.escapeHtml(title)}); this.success_message = this.$t('firefly.transaction_updated_link', {
ID: groupId,
title: this.escapeHtml(title)
});
this.error_message = ''; this.error_message = '';
} }
} else { } else {

View File

@ -19,205 +19,213 @@
--> -->
<template> <template>
<!-- <!--
Show if: Show if:
- one or more currencies. - one or more currencies.
--> -->
<div v-if="this.enabledCurrencies.length >= 1" class="form-group" v-bind:class="{ 'has-error': hasError()}"> <div v-if="this.enabledCurrencies.length >= 1" class="form-group" v-bind:class="{ 'has-error': hasError()}">
<div class="col-sm-8 col-sm-offset-4 text-sm"> <div class="col-sm-8 col-sm-offset-4 text-sm">
{{ $t('form.foreign_amount') }} {{ $t('form.foreign_amount') }}
</div> </div>
<div class="col-sm-4"> <div class="col-sm-4">
<select ref="currency_select" class="form-control" name="foreign_currency[]" @input="handleInput"> <select ref="currency_select" class="form-control" name="foreign_currency[]" @input="handleInput">
<option <option
v-for="currency in this.enabledCurrencies" v-for="currency in this.enabledCurrencies"
:label="currency.attributes.name" :label="currency.attributes.name"
:selected="parseInt(value.currency_id) === parseInt(currency.id)" :selected="parseInt(value.currency_id) === parseInt(currency.id)"
:value="currency.id" :value="currency.id"
> >
{{ currency.attributes.name }} {{ currency.attributes.name }}
</option> </option>
</select> </select>
</div> </div>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="input-group"> <div class="input-group">
<input v-if="this.enabledCurrencies.length > 0" ref="amount" :placeholder="this.title" :title="this.title" :value="value.amount" autocomplete="off" <input v-if="this.enabledCurrencies.length > 0" ref="amount" :placeholder="this.title"
class="form-control" name="foreign_amount[]" :title="this.title" :value="value.amount" autocomplete="off"
step="any" type="number" @input="handleInput"> class="form-control" name="foreign_amount[]"
<span class="input-group-btn"> step="any" type="number" @input="handleInput">
<span class="input-group-btn">
<button <button
class="btn btn-default" class="btn btn-default"
tabIndex="-1" tabIndex="-1"
type="button" type="button"
v-on:click="clearAmount"><i class="fa fa-trash-o"></i></button> v-on:click="clearAmount"><i class="fa fa-trash-o"></i></button>
</span> </span>
</div> </div>
<ul v-for="error in this.error" class="list-unstyled"> <ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li> <li class="text-danger">{{ error }}</li>
</ul> </ul>
</div>
</div> </div>
</div>
</template> </template>
<script> <script>
export default { export default {
name: "ForeignAmountSelect", name: "ForeignAmountSelect",
props: ['source', 'destination', 'transactionType', 'value', 'error', 'no_currency', 'title',], props: ['source', 'destination', 'transactionType', 'value', 'error', 'no_currency', 'title',],
mounted() { mounted() {
this.liability = false; this.liability = false;
this.loadCurrencies(); // console.log('I am mounted with a ' + this.transactionType + ' transaction type and currency id!');
// console.log(this.value);
this.loadCurrencies();
},
data() {
return {
currencies: [],
enabledCurrencies: [],
exclude: null,
// liability overrules the drop-down list if the source or dest is a liability
liability: false
}
},
watch: {
source: function () {
// console.log('ForeignAmountSelect watch source');
this.changeData();
},
destination: function () {
// console.log('ForeignAmountSelect watch destination');
this.changeData();
},
transactionType: function () {
// console.log('ForeignAmountSelect watch transaction type (is now ' + this.transactionType + ')');
this.changeData();
}
},
methods: {
clearAmount: function () {
this.$refs.amount.value = '';
this.$emit('input', this.$refs.amount.value);
// some event?
this.$emit('clear:amount')
},
hasError: function () {
//console.log('ForeignAmountSelect hasError');
return this.error.length > 0;
},
handleInput(e) {
// console.log('ForeignAmountSelect handleInput');
let obj = {
amount: this.$refs.amount.value,
currency_id: this.$refs.currency_select.value,
};
// console.log(obj);
this.$emit('input', obj
);
},
changeData: function () {
// console.log('ForeignAmountSelect changeData');
this.enabledCurrencies = [];
let destType = this.destination.type ? this.destination.type.toLowerCase() : 'invalid';
let srcType = this.source.type ? this.source.type.toLowerCase() : 'invalid';
let tType = this.transactionType ? this.transactionType.toLowerCase() : 'invalid';
let liabilities = ['loan', 'debt', 'mortgage'];
let sourceIsLiability = liabilities.indexOf(srcType) !== -1;
let destIsLiability = liabilities.indexOf(destType) !== -1;
}, // console.log(srcType + ' (source) is a liability: ' + sourceIsLiability);
data() { // console.log(destType + ' (dest) is a liability: ' + destIsLiability);
return { // console.log('tType: ' + tType);
currencies: [], if (tType === 'transfer' || destIsLiability || sourceIsLiability) {
enabledCurrencies: [], // console.log('Source is liability OR dest is liability, OR transfer. Lock list on currency of destination.');
exclude: null, // console.log('Length of currencies is ' + this.currencies.length);
// liability overrules the drop down list if the source or dest is a liability // console.log(this.currencies);
liability: false this.liability = true;
// lock dropdown list on currencyID of destination.
for (const key in this.currencies) {
if (this.currencies.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
if (
parseInt(this.currencies[key].id) === parseInt(this.destination.currency_id)
) {
// console.log('Enable currency!!');
// console.log(this.destination);
// console.log(this.currencies[key]);
this.enabledCurrencies.push(this.currencies[key]);
}
}
}
// console.log('Enabled currencies length is now ' + this.enabledCurrencies.length);
return;
}
// if type is withdrawal, list all but skip the source account ID.
if (tType === 'withdrawal' && this.source && false === sourceIsLiability) {
for (const key in this.currencies) {
if (this.currencies.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
if (this.source.currency_id !== this.currencies[key].id) {
this.enabledCurrencies.push(this.currencies[key]);
}
}
}
return;
}
// if type is deposit, list all but skip the source account ID.
if (tType === 'deposit' && this.destination) {
for (const key in this.currencies) {
if (this.currencies.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
if (this.destination.currency_id !== this.currencies[key].id) {
this.enabledCurrencies.push(this.currencies[key]);
}
}
}
return;
}
for (const key in this.currencies) {
if (this.currencies.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
this.enabledCurrencies.push(this.currencies[key]);
}
}
},
loadCurrencies: function () {
// console.log('loadCurrencies');
// reset list of currencies:
this.currencies = [
{
id: 0,
attributes: {
name: this.no_currency,
enabled: true
},
}
];
this.enabledCurrencies = [
{
attributes: {
name: this.no_currency,
enabled: true
},
id: 0,
}
];
this.getCurrencies(1);
},
getCurrencies: function (page) {
let url = document.getElementsByTagName('base')[0].href + "api/v1/currencies?page=" + page;
axios.get(url, {}).then((res) => {
for (const key in res.data.data) {
if (res.data.data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
if (res.data.data[key].attributes.enabled) {
// console.log(res.data.data[key].attributes);
this.currencies.push(res.data.data[key]);
this.enabledCurrencies.push(res.data.data[key]);
}
}
}
if (res.data.meta.pagination.current_page < res.data.meta.pagination.total_pages) {
this.getCurrencies(res.data.meta.pagination.current_page + 1);
return;
}
this.changeData();
});
}
} }
},
watch: {
source: function () {
//console.log('ForeignAmountSelect watch source');
this.changeData();
},
destination: function () {
//console.log('ForeignAmountSelect watch destination');
this.changeData();
},
transactionType: function () {
//console.log('ForeignAmountSelect watch transaction type (is now ' + this.transactionType + ')');
this.changeData();
}
},
methods: {
clearAmount: function () {
this.$refs.amount.value = '';
this.$emit('input', this.$refs.amount.value);
// some event?
this.$emit('clear:amount')
},
hasError: function () {
//console.log('ForeignAmountSelect hasError');
return this.error.length > 0;
},
handleInput(e) {
//console.log('ForeignAmountSelect handleInput');
let obj = {
amount: this.$refs.amount.value,
currency_id: this.$refs.currency_select.value,
};
// console.log(obj);
this.$emit('input', obj
);
},
changeData: function () {
// console.log('ForeignAmountSelect changeData');
this.enabledCurrencies = [];
let destType = this.destination.type ? this.destination.type.toLowerCase() : 'invalid';
let srcType = this.source.type ? this.source.type.toLowerCase() : 'invalid';
let tType = this.transactionType ? this.transactionType.toLowerCase() : 'invalid';
let liabilities = ['loan', 'debt', 'mortgage'];
let sourceIsLiability = liabilities.indexOf(srcType) !== -1;
let destIsLiability = liabilities.indexOf(destType) !== -1;
// console.log(srcType + ' (source) is a liability: ' + sourceIsLiability);
// console.log(destType + ' (dest) is a liability: ' + destIsLiability);
if (tType === 'transfer' || destIsLiability || sourceIsLiability) {
// console.log('Source is liability OR dest is liability, OR transfer. Lock list on currency of destination.');
// console.log('Length of currencies is ' + this.currencies.length);
// console.log(this.currencies);
this.liability = true;
// lock dropdown list on currencyID of destination.
for (const key in this.currencies) {
if (this.currencies.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
// console.log('this.currencies[key].id = ' + this.currencies[key].id);
// console.log('this.destination.currency_id = ' + this.destination.currency_id);
if (parseInt(this.currencies[key].id) === parseInt(this.destination.currency_id)) {
this.enabledCurrencies.push(this.currencies[key]);
}
}
}
// console.log('Enabled currencies length is now ' + this.enabledCurrencies.length);
return;
}
// if type is withdrawal, list all but skip the source account ID.
if (tType === 'withdrawal' && this.source && false === sourceIsLiability) {
for (const key in this.currencies) {
if (this.currencies.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
if (this.source.currency_id !== this.currencies[key].id) {
this.enabledCurrencies.push(this.currencies[key]);
}
}
}
return;
}
// if type is deposit, list all but skip the source account ID.
if (tType === 'deposit' && this.destination) {
for (const key in this.currencies) {
if (this.currencies.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
if (this.destination.currency_id !== this.currencies[key].id) {
this.enabledCurrencies.push(this.currencies[key]);
}
}
}
return;
}
for (const key in this.currencies) {
if (this.currencies.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
this.enabledCurrencies.push(this.currencies[key]);
}
}
},
loadCurrencies: function () {
// reset list of currencies:
this.currencies = [
{
id: 0,
attributes: {
name: this.no_currency,
enabled: true
},
}
];
this.enabledCurrencies = [
{
attributes: {
name: this.no_currency,
enabled: true
},
id: 0,
}
];
this.getCurrencies(1);
},
getCurrencies: function(page) {
// console.log('loadCurrencies on page ' + page);
let url = document.getElementsByTagName('base')[0].href + "api/v1/currencies?page=" + page;
axios.get(url, {}).then((res) => {
for (const key in res.data.data) {
if (res.data.data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
if (res.data.data[key].attributes.enabled) {
// console.log(res.data.data[key].attributes);
this.currencies.push(res.data.data[key]);
this.enabledCurrencies.push(res.data.data[key]);
}
}
}
if(res.data.meta.pagination.current_page < res.data.meta.pagination.total_pages) {
this.getCurrencies(res.data.meta.pagination.current_page + 1);
}
});
}
}
} }
</script> </script>