This commit is contained in:
James Cole 2017-07-08 06:09:17 +02:00
parent 19774f32c2
commit de9728895e
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 12 additions and 4 deletions

View File

@ -95,9 +95,9 @@ class SingleController extends Controller
$categoryName = is_null($category) ? '' : $category->name; $categoryName = is_null($category) ? '' : $category->name;
$tags = join(',', $journal->tags()->get()->pluck('tag')->toArray()); $tags = join(',', $journal->tags()->get()->pluck('tag')->toArray());
/** @var Transaction $transaction */ /** @var Transaction $transaction */
$transaction = $journal->transactions()->first(); $transaction = $journal->transactions()->first();
$amount = Steam::positive($transaction->amount); $amount = Steam::positive($transaction->amount);
$foreignAmount = is_null($transaction->foreign_amount) ? null : Steam::positive($transaction->foreign_amount); $foreignAmount = is_null($transaction->foreign_amount) ? null : Steam::positive($transaction->foreign_amount);
$preFilled = [ $preFilled = [
'description' => $journal->description, 'description' => $journal->description,
@ -109,6 +109,7 @@ class SingleController extends Controller
'source_amount' => $amount, 'source_amount' => $amount,
'destination_amount' => $foreignAmount, 'destination_amount' => $foreignAmount,
'foreign_amount' => $foreignAmount, 'foreign_amount' => $foreignAmount,
'native_amount' => $foreignAmount,
'amount_currency_id_amount' => $transaction->foreign_currency_id ?? 0, 'amount_currency_id_amount' => $transaction->foreign_currency_id ?? 0,
'date' => $journal->date->format('Y-m-d'), 'date' => $journal->date->format('Y-m-d'),
'budget_id' => $budgetId, 'budget_id' => $budgetId,

View File

@ -8,6 +8,8 @@
/** global: Modernizr, accountInfo, currencyInfo, accountInfo, transferInstructions, what */ /** global: Modernizr, accountInfo, currencyInfo, accountInfo, transferInstructions, what */
var countConversions = 0;
$(document).ready(function () { $(document).ready(function () {
"use strict"; "use strict";
setCommonAutocomplete(); setCommonAutocomplete();
@ -118,6 +120,12 @@ function convertForeignToNative() {
* @param data * @param data
*/ */
function updateNativeAmount(data) { function updateNativeAmount(data) {
// if native amount is already filled in, even though we do this for the first time:
// don't overrule it.
if(countConversions === 0 && $('#ffInput_native_amount').val().length > 0) {
countConversions++;
return;
}
$('#ffInput_native_amount').val(data.amount); $('#ffInput_native_amount').val(data.amount);
} }

View File

@ -74,7 +74,6 @@ function updateNativeCurrency(useAccountCurrency) {
if (what !== 'transfer') { if (what !== 'transfer') {
$('select[name="source_account_id"]').focus(); $('select[name="source_account_id"]').focus();
} }
validateCurrencyForTransfer(); validateCurrencyForTransfer();
} }