X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FOE.pm;h=b8250123f9e7aaec75b1754b7cc6183b2a9cf119;hb=fdee0091f00479361820f0f98fe896a14e605b18;hp=3c10dd38ee7a6b987d313d7467e7c91d125fe9f9;hpb=af59820cb06ba396ba10ecd88f43a92c331a6066;p=kivitendo-erp.git diff --git a/SL/OE.pm b/SL/OE.pm index 3c10dd38e..b8250123f 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -39,6 +39,7 @@ use List::Util qw(max); use SL::AM; use SL::Common; use SL::DBUtils; +use SL::IC; sub transactions { $main::lxdebug->enter_sub(); @@ -201,10 +202,13 @@ sub transactions_for_todo_list { $query = qq|SELECT oe.id, oe.transdate, oe.reqdate, oe.quonumber, oe.transaction_description, oe.amount, + CASE WHEN (COALESCE(oe.customer_id, 0) = 0) THEN 'vendor' ELSE 'customer' END AS vc, c.name AS customer, + v.name AS vendor, e.name AS employee FROM oe LEFT JOIN customer c ON (oe.customer_id = c.id) + LEFT JOIN vendor v ON (oe.vendor_id = v.id) LEFT JOIN employee e ON (oe.employee_id = e.id) WHERE (COALESCE(quotation, FALSE) = TRUE) AND (COALESCE(closed, FALSE) = FALSE) @@ -433,7 +437,7 @@ sub save { globalproject_id = ?, employee_id = ?, salesman_id = ?, cp_id = ?, transaction_description = ?, marge_total = ?, marge_percent = ? WHERE id = ?|; - @values = ($form->{ordnumber}, $form->{quonumber}, + @values = ($form->{ordnumber} || '', $form->{quonumber}, $form->{cusordnumber}, conv_date($form->{transdate}), conv_i($form->{vendor_id}), conv_i($form->{customer_id}), $amount, $netamount, conv_date($reqdate), @@ -947,12 +951,14 @@ sub order_details { $form->{discount} = []; + IC->prepare_parts_for_printing(); + my @arrays = qw(runningnumber number description longdescription qty ship unit bin partnotes serialnumber reqdate sellprice listprice netprice discount p_discount discount_sub nodiscount_sub linetotal nodiscount_linetotal tax_rate projectnumber - price_factor price_factor_name); + price_factor price_factor_name partsgroup); my $sameitem = ""; foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) { @@ -1002,13 +1008,17 @@ sub order_details { push @{ $form->{listprice} }, $form->{"listprice_$i"}; push @{ $form->{price_factor} }, $price_factor->{formatted_factor}; push @{ $form->{price_factor_name} }, $price_factor->{description}; + push @{ $form->{partsgroup} }, $form->{"partsgroup_$i"}; my $sellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); 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); @@ -1016,7 +1026,7 @@ sub order_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->{ordtotal} += $linetotal; @@ -1066,9 +1076,9 @@ sub order_details { } if ($taxamount != 0) { - foreach my $item (split / /, $form->{"taxaccounts_$i"}) { - $taxaccounts{$item} += $taxamount * $form->{"${item}_rate"} / $taxrate; - $taxbase{$item} += $taxbase; + foreach my $accno (split / /, $form->{"taxaccounts_$i"}) { + $taxaccounts{$accno} += $taxamount * $form->{"${accno}_rate"} / $taxrate; + $taxbase{$accno} += $taxbase; } }