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

@ -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:
@ -528,6 +540,15 @@ export default {
allowed_types: window.expectedSourceTypes.destination[this.ucFirst(transaction.type)] allowed_types: window.expectedSourceTypes.destination[this.ucFirst(transaction.type)]
} }
}; };
// 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) { if (null === transaction.foreign_amount) {
result.foreign_amount.amount = ''; result.foreign_amount.amount = '';
} }
@ -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

@ -42,7 +42,8 @@
</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"
:title="this.title" :value="value.amount" autocomplete="off"
class="form-control" name="foreign_amount[]" class="form-control" name="foreign_amount[]"
step="any" type="number" @input="handleInput"> step="any" type="number" @input="handleInput">
<span class="input-group-btn"> <span class="input-group-btn">
@ -67,15 +68,16 @@ export default {
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;
// console.log('I am mounted with a ' + this.transactionType + ' transaction type and currency id!');
// console.log(this.value);
this.loadCurrencies(); this.loadCurrencies();
}, },
data() { data() {
return { return {
currencies: [], currencies: [],
enabledCurrencies: [], enabledCurrencies: [],
exclude: null, exclude: null,
// liability overrules the drop down list if the source or dest is a liability // liability overrules the drop-down list if the source or dest is a liability
liability: false liability: false
} }
}, },
@ -126,7 +128,7 @@ export default {
// console.log(srcType + ' (source) is a liability: ' + sourceIsLiability); // console.log(srcType + ' (source) is a liability: ' + sourceIsLiability);
// console.log(destType + ' (dest) is a liability: ' + destIsLiability); // console.log(destType + ' (dest) is a liability: ' + destIsLiability);
// console.log('tType: ' + tType);
if (tType === 'transfer' || destIsLiability || sourceIsLiability) { if (tType === 'transfer' || destIsLiability || sourceIsLiability) {
// console.log('Source is liability OR dest is liability, OR transfer. Lock list on currency of destination.'); // 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('Length of currencies is ' + this.currencies.length);
@ -135,9 +137,13 @@ export default {
// lock dropdown list on currencyID of destination. // lock dropdown list on currencyID of destination.
for (const key in this.currencies) { for (const key in this.currencies) {
if (this.currencies.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) { 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 (
if (parseInt(this.currencies[key].id) === parseInt(this.destination.currency_id)) { 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]); this.enabledCurrencies.push(this.currencies[key]);
} }
} }
@ -176,6 +182,7 @@ export default {
} }
}, },
loadCurrencies: function () { loadCurrencies: function () {
// console.log('loadCurrencies');
// reset list of currencies: // reset list of currencies:
this.currencies = [ this.currencies = [
{ {
@ -200,7 +207,6 @@ export default {
this.getCurrencies(1); this.getCurrencies(1);
}, },
getCurrencies: function (page) { getCurrencies: function (page) {
// console.log('loadCurrencies on page ' + page);
let url = document.getElementsByTagName('base')[0].href + "api/v1/currencies?page=" + page; let url = document.getElementsByTagName('base')[0].href + "api/v1/currencies?page=" + page;
axios.get(url, {}).then((res) => { axios.get(url, {}).then((res) => {
@ -215,7 +221,9 @@ export default {
} }
if (res.data.meta.pagination.current_page < res.data.meta.pagination.total_pages) { if (res.data.meta.pagination.current_page < res.data.meta.pagination.total_pages) {
this.getCurrencies(res.data.meta.pagination.current_page + 1); this.getCurrencies(res.data.meta.pagination.current_page + 1);
return;
} }
this.changeData();
}); });
} }
} }