]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Kein Runden des Rabatts vor der Berechnung im Angebot/Auftrag.
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 4 Apr 2014 09:35:46 +0000 (11:35 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 4 Apr 2014 09:35:46 +0000 (11:35 +0200)
Das Vorgehen etwas an da von SL/IS.pm post_invoice() angeglichen.
Problem war, dass in Angebot/Auftrag bei Vergabe eines Rabatts das
Frontend richtig grechnet hat, aber das Backend nicht (durch Runden
des Rabatts). Dadurch unterschieden sich die Summen in der Belegmaske
von den Summe im Bericht.

SL/OE.pm

index 266945ce37da7aa69fd1a211cbf3ada3ff0300d5..e37dae47daa8e57e70a11d7ba1084ee26b937094 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -415,25 +415,27 @@ sub save {
 
       $form->{"lastcost_$i"} = $form->parse_amount($myconfig, $form->{"lastcost_$i"});
 
 
       $form->{"lastcost_$i"} = $form->parse_amount($myconfig, $form->{"lastcost_$i"});
 
-      # set values to 0 if nothing entered
-      $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
-
-      $form->{"sellprice_$i"} = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
-      $fxsellprice = $form->{"sellprice_$i"};
+      # keep entered selling price
+      my $fxsellprice =
+        $form->parse_amount($myconfig, $form->{"sellprice_$i"});
 
 
-      my ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
-      $dec = length($dec);
+      my ($dec) = ($fxsellprice =~ /\.(\d+)/);
+      $dec = length $dec;
       my $decimalplaces = ($dec > 2) ? $dec : 2;
 
       my $decimalplaces = ($dec > 2) ? $dec : 2;
 
-      $discount = $form->round_amount($form->{"sellprice_$i"} * $form->{"discount_$i"}, $decimalplaces);
-      $form->{"sellprice_$i"} = $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
+      # undo discount formatting
+      $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
 
 
-      $form->{"inventory_accno_$i"} *= 1;
-      $form->{"expense_accno_$i"}   *= 1;
+      # deduct discount
+      $form->{"sellprice_$i"} = $fxsellprice * (1 - $form->{"discount_$i"});
 
 
+      # round linetotal at least to 2 decimal places
       $price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1;
       $linetotal    = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
 
       $price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1;
       $linetotal    = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
 
+      $form->{"inventory_accno_$i"} *= 1;
+      $form->{"expense_accno_$i"}   *= 1;
+
       @taxaccounts = split(/ /, $form->{"taxaccounts_$i"});
       $taxrate     = 0;
       $taxdiff     = 0;
       @taxaccounts = split(/ /, $form->{"taxaccounts_$i"});
       $taxrate     = 0;
       $taxdiff     = 0;