X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/247a26dc4b5b0d73c03fc6f05fb17daace0835d9..ca12e8dfc4773aabc13818a0398e06e44028e2bc:/SL/IS.pm diff --git a/SL/IS.pm b/SL/IS.pm index bf52d5223..b782fef26 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -130,6 +130,8 @@ sub invoice_details { my $subtotal_header = 0; my $subposition = 0; + $form->{discount} = []; + my @arrays = qw(runningnumber number description longdescription qty ship unit bin deliverydate_oe ordnumber_oe transdate_oe licensenumber validuntil @@ -210,8 +212,11 @@ sub invoice_details { my ($dec) = ($sellprice =~ /\.(\d+)/); my $decimalplaces = max 2, length($dec); - my $discount = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100 / $price_factor->{factor}, $decimalplaces); - my $linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100 / $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 $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); $form->{"netprice_$i"} = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2); @@ -219,7 +224,7 @@ sub invoice_details { $linetotal = ($linetotal != 0) ? $linetotal : ''; - push @{ $form->{discount} }, ($discount != 0) ? $form->format_amount($myconfig, $discount * -1, $decimalplaces) : ''; + push @{ $form->{discount} }, ($discount != 0) ? $form->format_amount($myconfig, $discount * -1, 2) : ''; push @{ $form->{p_discount} }, $form->{"discount_$i"}; $form->{total} += $linetotal; @@ -1523,7 +1528,7 @@ sub get_customer { # get customer $query = qq|SELECT - c.name AS customer, c.discount, c.creditlimit, c.terms, + c.id AS customer_id, c.name AS customer, c.discount, c.creditlimit, c.terms, c.email, c.cc, c.bcc, c.language_id, c.payment_id, c.street, c.zipcode, c.city, c.country, c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id,