From: Sven Schöling Date: Wed, 27 Feb 2008 12:21:35 +0000 (+0000) Subject: Wechselkurse. X-Git-Tag: release-2.6.0beta1~210 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a53233e56a9d4001b47bcf412b4bfe46910d3117;p=kivitendo-erp.git Wechselkurse. Zum einen den unsaeglichen Algorithmus zum setzen von exchangerate und forex im ganzen Porgramm geaendert. Dann einen Bug mit der Angzeige der Wechselkurseingabe in oe.pl gefixt. Ausserdem Bug 666 gefixt. --- diff --git a/SL/AP.pm b/SL/AP.pm index 66020933c..7629381b0 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -56,14 +56,8 @@ sub post_transaction { if ($form->{currency} eq $form->{defaultcurrency}) { $form->{exchangerate} = 1; } else { - $exchangerate = - $form->check_exchangerate($myconfig, $form->{currency}, - $form->{transdate}, 'sell'); - - $form->{exchangerate} = - ($exchangerate) - ? $exchangerate - : $form->parse_amount($myconfig, $form->{exchangerate}); + $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, 'sell'); + $form->{exchangerate} = $exchangerate || $form->parse_amount($myconfig, $form->{exchangerate}); } for $i (1 .. $form->{rowcount}) { @@ -271,14 +265,8 @@ sub post_transaction { if ($form->{currency} eq $form->{defaultcurrency}) { $form->{"exchangerate_$i"} = 1; } else { - $exchangerate = - $form->check_exchangerate($myconfig, $form->{currency}, - $form->{"datepaid_$i"}, 'sell'); - - $form->{"exchangerate_$i"} = - ($exchangerate) - ? $exchangerate - : $form->parse_amount($myconfig, $form->{"exchangerate_$i"}); + $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); + $form->{"exchangerate_$i"} = $exchangerate || $form->parse_amount($myconfig, $form->{"exchangerate_$i"}); } $form->{"AP_paid_$i"} =~ s/\"//g; diff --git a/SL/Form.pm b/SL/Form.pm index 552738c98..bded79435 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1578,8 +1578,6 @@ sub check_exchangerate { my ($exchangerate) = selectrow_query($self, $dbh, $query, $currency, $transdate); - $exchangerate = 1 if ($exchangerate eq ""); - $main::lxdebug->leave_sub(); return $exchangerate; diff --git a/SL/IS.pm b/SL/IS.pm index 0f36f2363..961746ff6 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -524,9 +524,7 @@ sub post_invoice { if ($form->{currency} eq $defaultcurrency) { $form->{exchangerate} = 1; } else { - $exchangerate = - $form->check_exchangerate($myconfig, $form->{currency}, - $form->{transdate}, 'buy'); + $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, 'buy'); } $form->{exchangerate} = @@ -820,13 +818,8 @@ sub post_invoice { if ($form->{currency} eq $defaultcurrency) { $form->{"exchangerate_$i"} = 1; } else { - $exchangerate = - $form->check_exchangerate($myconfig, $form->{currency}, - $form->{"datepaid_$i"}, 'buy'); - - $form->{"exchangerate_$i"} = - $exchangerate ? $exchangerate - : $form->parse_amount($myconfig, $form->{"exchangerate_$i"}); + $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'); + $form->{"exchangerate_$i"} = $exchangerate || $form->parse_amount($myconfig, $form->{"exchangerate_$i"}); } # record AR diff --git a/SL/OE.pm b/SL/OE.pm index 18daae128..2e0ac4212 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -415,7 +415,7 @@ sub save { $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, ($form->{vc} eq 'customer') ? 'buy' : 'sell'); } - $form->{exchangerate} = ($exchangerate) ? $exchangerate : $form->parse_amount($myconfig, $form->{exchangerate}); + $form->{exchangerate} = $exchangerate || $form->parse_amount($myconfig, $form->{exchangerate}); my $quotation = $form->{type} =~ /_order$/ ? 'f' : 't'; diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 08c2ae2cf..25c219665 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -223,17 +223,11 @@ sub form_header { } $readonly = ($form->{id}) ? "readonly" : ""; - $form->{radier} = - ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; - $readonly = ($form->{radier}) ? "" : $readonly; + $form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; + $readonly = ($form->{radier}) ? "" : $readonly; - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{transdate}, 'sell' - ))); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'sell'); + $form->{exchangerate} = $form->{forex} if $form->{forex}; # format amounts @@ -898,13 +892,8 @@ sub update { map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount}); - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{transdate}, 'sell' - ))); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'sell'); + $form->{exchangerate} = $form->{forex} if $form->{forex}; $form->{invdate} = $form->{transdate}; $save_AP = $form->{AP}; @@ -925,13 +914,8 @@ sub update { $totalpaid += $form->{"paid_$i"}; - $form->{"exchangerate_$i"} = $exchangerate - if ( - $form->{"forex_$i"} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell' - ))); + $form->{"forex_$i"} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); + $form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"}; } } diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 88a9b97bf..31c9cfff4 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -261,13 +261,8 @@ sub form_header { s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; } - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{transdate}, 'buy' - ))); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'buy'); + $form->{exchangerate} = $form->{forex} if $form->{forex}; # format amounts $form->{exchangerate} = @@ -961,13 +956,8 @@ sub update { $form->{rowcount} = $count + 1; map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount}); - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{transdate}, 'buy' - ))); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'buy'); + $form->{exchangerate} = $form->{forex} if $form->{forex}; $form->{invdate} = $form->{transdate}; my $save_AR = $form->{AR}; @@ -986,13 +976,8 @@ sub update { $totalpaid += $form->{"paid_$i"}; - $form->{"exchangerate_$i"} = $exchangerate - if ( - $form->{"forex_$i"} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy' - ))); + $form->{"forex_$i"} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'); + $form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"}; } } diff --git a/bin/mozilla/cp.pl b/bin/mozilla/cp.pl index 58c9a73aa..553c8383f 100644 --- a/bin/mozilla/cp.pl +++ b/bin/mozilla/cp.pl @@ -579,13 +579,8 @@ sub update { } } - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{datepaid}, $buysell - ))); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{datepaid}, $buysell); + $form->{exchangerate} = $form->{forex} if $form->{forex}; $amount = $form->{amount} = $form->parse_amount(\%myconfig, $form->{amount}); diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index ade606bbd..911c90edb 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -671,8 +671,8 @@ sub invoice { $form->{currency} = $currency; $form->{exchangerate} = ""; - $form->{forex} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, $buysell)); - $form->{exchangerate} = $exchangerate if ($form->{forex}); + $form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, $buysell); + $form->{exchangerate} = $form->{forex} if ($form->{forex}); prepare_invoice(); diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index b48671bae..da8929667 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -854,19 +854,11 @@ sub order { &order_links; $form->{currency} = $currency; - $form->{exchangerate} = ""; - $form->{forex} = ""; - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{transdate}, $buysell - ))); + $form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell); + $form->{exchangerate} = $form->{forex} || ''; for $i (1 .. $form->{rowcount}) { - map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, - $form->{"${_}_${i}"}) + map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice basefactor)); } @@ -917,15 +909,8 @@ sub quotation { &order_links; $form->{currency} = $currency; - $form->{exchangerate} = ""; - $form->{forex} = ""; - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{transdate}, $buysell - ))); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, $buysell); + $form->{exchangerate} = $form->{forex} || ''; for $i (1 .. $form->{rowcount}) { map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 90ebbfd65..2858e221b 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -893,14 +893,14 @@ sub update { &check_name(vendor); - $form->{exchangerate} = $exchangerate if - $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); + $form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); + $form->{exchangerate} = $form->{forex} if $form->{forex}; for $i (1 .. $form->{paidaccounts}) { next unless $form->{"paid_$i"}; map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); - $form->{"exchangerate_$i"} = $exchangerate if - $form->{"forex_$i"} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); + $form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); + $form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"}; } $i = $form->{rowcount}; diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index f5f77974c..5b70c4816 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -1230,14 +1230,14 @@ sub update { $form->{taxincluded} ||= $taxincluded; - $form->{exchangerate} = $exchangerate if - $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy'); + $form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy'); + $form->{exchangerate} = $form->{forex} if $form->{forex}; for $i (1 .. $form->{paidaccounts}) { next unless $form->{"paid_$i"}; map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); - $form->{"exchangerate_$i"} = $exchangerate if - $form->{"forex_$i"} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'); + $form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'); + $form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"}; } $i = $form->{rowcount}; @@ -1618,15 +1618,8 @@ sub credit_note { &invoice_links; $form->{currency} = $currency; - $form->{exchangerate} = ""; - $form->{forex} = ""; - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{invdate}, $buysell - ))); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{invdate}, $buysell); + $form->{exchangerate} = $form->{forex} || ''; $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal}); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index aea613faa..a70ab237e 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -336,7 +336,7 @@ sub form_header { @values = map { $_ } @{ $form->{ALL_CURRENCIES} }; %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} }; $form->{currency} = $form->{defaultcurrency} unless $form->{currency}; - $TMPL_VAR{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency} && $form->{exchangerate}; + $TMPL_VAR{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency}; $TMPL_VAR{currencies} = NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"}, '-values' => \@values, '-labels' => \%labels)) if scalar @values; push @custom_hiddens, "forex"; @@ -492,8 +492,8 @@ sub update { $buysell = 'buy'; $buysell = 'sell' if ($form->{vc} eq 'vendor'); - $form->{exchangerate} = $exchangerate if - $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell); + $form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell); + $form->{exchangerate} = $form->{forex} if $form->{forex}; $exchangerate = $form->{exchangerate} || 1; @@ -1494,15 +1494,8 @@ sub invoice { &invoice_links; $form->{currency} = $currency; - $form->{exchangerate} = ""; - $form->{forex} = ""; - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{invdate}, $buysell - ))); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{invdate}, $buysell); + $form->{exchangerate} = $form->{forex} || ''; $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal}); diff --git a/templates/webpages/oe/form_header_de.html b/templates/webpages/oe/form_header_de.html index 8d9271017..255add38e 100644 --- a/templates/webpages/oe/form_header_de.html +++ b/templates/webpages/oe/form_header_de.html @@ -132,7 +132,7 @@ Wechselkurs [%- IF forex %] - [% LxERP.format_amount(exchangerate, 0) %] + [% LxERP.format_amount(exchangerate, 2) %] [%- ELSE %] [%- END %] diff --git a/templates/webpages/oe/form_header_master.html b/templates/webpages/oe/form_header_master.html index 64636b25a..5a242b245 100644 --- a/templates/webpages/oe/form_header_master.html +++ b/templates/webpages/oe/form_header_master.html @@ -132,7 +132,7 @@ Exchangerate [%- IF forex %] - [% LxERP.format_amount(exchangerate, 0) %] + [% LxERP.format_amount(exchangerate, 2) %] [%- ELSE %] [%- END %]