Wechselkurse.
authorSven Schöling <s.schoeling@linet-services.de>
Wed, 27 Feb 2008 12:21:35 +0000 (12:21 +0000)
committerSven Schöling <s.schoeling@linet-services.de>
Wed, 27 Feb 2008 12:21:35 +0000 (12:21 +0000)
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.

14 files changed:
SL/AP.pm
SL/Form.pm
SL/IS.pm
SL/OE.pm
bin/mozilla/ap.pl
bin/mozilla/ar.pl
bin/mozilla/cp.pl
bin/mozilla/do.pl
bin/mozilla/io.pl
bin/mozilla/ir.pl
bin/mozilla/is.pl
bin/mozilla/oe.pl
templates/webpages/oe/form_header_de.html
templates/webpages/oe/form_header_master.html

index 6602093..7629381 100644 (file)
--- 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;
 
index 552738c..bded794 100644 (file)
@@ -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;
index 0f36f23..961746f 100644 (file)
--- 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
index 18daae1..2e0ac42 100644 (file)
--- 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';
 
index 08c2ae2..25c2196 100644 (file)
@@ -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"};
     }
   }
 
index 88a9b97..31c9cff 100644 (file)
@@ -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"};
     }
   }
 
index 58c9a73..553c838 100644 (file)
@@ -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});
 
index ade606b..911c90e 100644 (file)
@@ -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();
 
index b48671b..da89296 100644 (file)
@@ -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,
index 90ebbfd..2858e22 100644 (file)
@@ -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};
index f5f7797..5b70c48 100644 (file)
@@ -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});
 
index aea613f..a70ab23 100644 (file)
@@ -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});
 
index 8d92710..255add3 100644 (file)
                     <th align="right">Wechselkurs</th>
                     <td>
                      [%- IF forex %]
-                      [% LxERP.format_amount(exchangerate, 0) %]
+                      [% LxERP.format_amount(exchangerate, 2) %]
                      [%- ELSE %]
                       <input name="exchangerate" size="10" value="[% HTML.escape(LxERP.format_amount(exchangerate)) %]">
                      [%- END %]
index 64636b2..5a242b2 100644 (file)
                     <th align="right"><translate>Exchangerate</translate></th>
                     <td>
                      [%- IF forex %]
-                      [% LxERP.format_amount(exchangerate, 0) %]
+                      [% LxERP.format_amount(exchangerate, 2) %]
                      [%- ELSE %]
                       <input name="exchangerate" size="10" value="[% HTML.escape(LxERP.format_amount(exchangerate)) %]">
                      [%- END %]