X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=e240d979a11e9f6b541bd43c7a944a972410af77;hb=30cdb38fd74eec6e94ccba5f7d978ff581c8bd59;hp=616e2bf6ffec4193dd96762ddb0c7ba1bdad614b;hpb=5829f39dc57db589b830a4adc4053538ddec0ee5;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index 616e2bf6f..e240d979a 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -222,12 +222,18 @@ sub invoice_details { my ($dec) = ($sellprice =~ /\.(\d+)/); my $decimalplaces = max 2, length($dec); - my $parsed_discount = $form->parse_amount($myconfig, $form->{"discount_$i"}); - my $linetotal_exact = $form->{"qty_$i"} * $sellprice * (100 - $parsed_discount) / 100 / $price_factor->{factor}; - my $linetotal = $form->round_amount($linetotal_exact, 2); - my $discount = $form->round_amount($form->{"qty_$i"} * $sellprice * $parsed_discount / 100 / $price_factor->{factor} - ($linetotal - $linetotal_exact), - $decimalplaces); - my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice / $price_factor->{factor}, 2); + my $parsed_discount = $form->parse_amount($myconfig, $form->{"discount_$i"}); + + my $linetotal_exact = $form->{"qty_$i"} * $sellprice * (100 - $parsed_discount) / 100 / $price_factor->{factor}; + my $linetotal = $form->round_amount($linetotal_exact, 2); + + my $nodiscount_exact_linetotal = $form->{"qty_$i"} * $sellprice / $price_factor->{factor}; + my $nodiscount_linetotal = $form->round_amount($nodiscount_exact_linetotal,2); + + my $discount = $nodiscount_linetotal - $linetotal; # is always rounded because $nodiscount_linetotal and $linetotal are rounded + + my $discount_round_error = $discount + ($linetotal_exact - $nodiscount_exact_linetotal); # not used + $form->{"netprice_$i"} = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2); push @{ $form->{TEMPLATE_ARRAYS}->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : ''; @@ -2130,16 +2136,18 @@ sub get_pricegroups_for_parts { $pkr->{selected} = ' selected'; # unless $form->{selected}; # no customer pricesgroup set - if ($pkr->{price_unfmt} == $pkr->{default_sellprice} || $form->{'sellprice_'.$i} * 1 > 1) { + if ($pkr->{price_ufmt} == $pkr->{default_sellprice}) { $pkr->{price} = $form->{"sellprice_$i"}; } else { +# this sub should not set anything and only return. --sschoeling, 20090506 +# is this correct? put in again... -- grichardson 20110119 $form->{"sellprice_$i"} = $pkr->{price}; } - } elsif ($pkr->{price_unfmt} == $pkr->{default_sellprice} and $pkr->{default_sellprice} != 0) { + } elsif ($pkr->{price_ufmt} == $pkr->{default_sellprice} and $pkr->{default_sellprice} != 0) { $pkr->{price} = $form->{"sellprice_$i"}; $pkr->{selected} = ' selected'; }