my @values = map { $_ } @{ $form->{ALL_CURRENCIES} };
my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
$form->{currency} = $form->{defaultcurrency} unless $form->{currency};
- $TMPL_VAR{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
+ # show_exchangerate is also later needed in another template
+ $form->{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
$TMPL_VAR{currencies} = NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
'-values' => \@values, '-labels' => \%labels,
'-onchange' => "document.getElementById('update_button').click();"
for my $i (1 .. $form->{paidaccounts}) {
next unless $form->{"paid_$i"};
map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate);
+ if (!$form->{"forex_$i"}) { #read exchangerate from input field (not hidden)
+ $form->{exchangerate} = $form->{"exchangerate_$i"};
+ }
$form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy');
$form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"};
}
<td align="center">
[% SET forex = 'forex_' _ i %]
[% SET exchangerate = 'exchangerate_' _ i %]
- [% IF forex %]
+ [% IF $forex %]
<input type="hidden" name="exchangerate_[% i %]" value="[% LxERP.format_amount($exchangerate, 2) %]">
- [% LxERP.format_amount(exchangerate, 2) %]
+ [% LxERP.format_amount($forex, 2) %]
[% ELSE %]
[% IF $changeable %]
<input name="exchangerate_[% i %]" size="10" value="[% LxERP.format_amount($exchangerate, 2, 1) %]">
[% LxERP.format_amount($exchangerate, 2, 1) %]
[% END %]
[% END %]
- <input type="hidden" name="forex_[% i %]" value="[% $forex %]">;
+ <input type="hidden" name="forex_[% i %]" value="[% $forex %]">
</td>
[% END %]
<td align="center">
[% SET forex = 'forex_' _ i %]
[% SET exchangerate = 'exchangerate_' _ i %]
- [% IF forex %]
+ [% IF $forex %]
<input type="hidden" name="exchangerate_[% i %]" value="[% LxERP.format_amount($exchangerate, 2) %]">
[% LxERP.format_amount($forex, 2) %]
[% ELSE %]