From 2e5f786069ded4f9e72902915ae914f3e67b62fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 4 Apr 2014 11:35:46 +0200 Subject: [PATCH] Kein Runden des Rabatts vor der Berechnung im Angebot/Auftrag. 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 | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/SL/OE.pm b/SL/OE.pm index 266945ce3..e37dae47d 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -415,25 +415,27 @@ sub save { $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; - $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); + $form->{"inventory_accno_$i"} *= 1; + $form->{"expense_accno_$i"} *= 1; + @taxaccounts = split(/ /, $form->{"taxaccounts_$i"}); $taxrate = 0; $taxdiff = 0; -- 2.20.1