mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 22:21:42 +00:00
Fix for #1805
This commit is contained in:
2
public/js/ff/transactions/single/common.js
vendored
2
public/js/ff/transactions/single/common.js
vendored
@@ -164,7 +164,9 @@ function getTransferExchangeInstructions() {
|
||||
* When the transaction to create is a transfer some more checks are necessary.
|
||||
*/
|
||||
function validateCurrencyForTransfer() {
|
||||
console.log('in validateCurrencyForTransfer()');
|
||||
if (what !== "transfer") {
|
||||
console.log('is not a transfer, so return.');
|
||||
return;
|
||||
}
|
||||
$('#source_amount_holder').show();
|
||||
|
||||
52
public/js/ff/transactions/single/edit.js
vendored
52
public/js/ff/transactions/single/edit.js
vendored
@@ -37,16 +37,37 @@ $(document).ready(function () {
|
||||
});
|
||||
$('#ffInput_amount').on('change', convertForeignToNative);
|
||||
|
||||
// respond to transfer changes:
|
||||
$('#ffInput_source_id').on('change', function () {
|
||||
// respond to account changes:
|
||||
$('#ffInput_source_id').on('change', function (e) {
|
||||
console.log('Event: #ffInput_source_id::change');
|
||||
|
||||
|
||||
|
||||
validateCurrencyForTransfer();
|
||||
// update the two source account currency ID fields (initial value):
|
||||
initCurrencyIdValues();
|
||||
|
||||
// call to selectsForeignCurrency
|
||||
console.log('Extra call to selectsForeignCurrency()');
|
||||
selectsForeignCurrency();
|
||||
|
||||
// update "source_account_currency".
|
||||
updateSourceAccountCurrency();
|
||||
|
||||
});
|
||||
$('#ffInput_destination_id').on('change', function () {
|
||||
console.log('Event: #ffInput_destination_id::change');
|
||||
validateCurrencyForTransfer();
|
||||
// update the two source account currency ID fields (initial value):
|
||||
initCurrencyIdValues();
|
||||
|
||||
// call to selectsForeignCurrency
|
||||
console.log('Extra call to selectsForeignCurrency()');
|
||||
selectsForeignCurrency();
|
||||
|
||||
// update "destination_account_currency".
|
||||
updateDestinationAccountCurrency();
|
||||
|
||||
});
|
||||
|
||||
// convert source currency to destination currency (slightly different routine for transfers)
|
||||
@@ -57,10 +78,37 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Updates the currency ID of the hidden source account field
|
||||
* to match the selected account.
|
||||
*/
|
||||
function updateSourceAccountCurrency() {
|
||||
var accountId = $('#ffInput_source_id').val();
|
||||
var currency = parseInt(accountInfo[accountId].preferredCurrency);
|
||||
console.log('Now in updateSourceAccountCurrency() for account #' + accountId);
|
||||
console.log('Preferred currency for this account is #' + currency);
|
||||
$('input[name="source_account_currency"]').val(currency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the currency ID of the hidden destination account field
|
||||
* to match the selected account.
|
||||
*/
|
||||
function updateDestinationAccountCurrency() {
|
||||
var accountId = $('#ffInput_destination_id').val();
|
||||
var currency = parseInt(accountInfo[accountId].preferredCurrency);
|
||||
console.log('Now in updateDestinationAccountCurrency() for account #' + accountId);
|
||||
console.log('Preferred currency for this account is #' + currency);
|
||||
$('input[name="destination_account_currency"]').val(currency);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fills two hidden variables with the correct currency ID.
|
||||
*/
|
||||
function initCurrencyIdValues() {
|
||||
console.log('in initCurrencyIdValues()');
|
||||
var currencyId;
|
||||
if (journal.transaction_type.type === "Withdrawal") {
|
||||
// update source from page load info:
|
||||
|
||||
Reference in New Issue
Block a user