X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/f3a02fb642b3320d29955474c733cc953e557293..refs/heads/b_3.4.1:/SL/OE.pm diff --git a/SL/OE.pm b/SL/OE.pm index 3666f7d90..31b3067f5 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -658,8 +658,12 @@ SQL dbh => $dbh); # link previous items with orderitems - foreach (qw(orderitems invoice)) { - if (!$form->{saveasnew} && !$form->{useasnew} && $form->{"converted_from_${_}_id_$i"}) { + # assume we have a new workflow if we link from invoice or order to quotation + # unluckily orderitems are used for quotation and orders - therefore one more + # check to be sure NOT to link from order to quotation + foreach (qw(orderitems)) { + if (!$form->{saveasnew} && !$form->{useasnew} && $form->{"converted_from_${_}_id_$i"} + && $form->{type} !~ 'quotation') { RecordLinks->create_links('dbh' => $dbh, 'mode' => 'ids', 'from_table' => $_, @@ -762,7 +766,7 @@ SQL $form->{convert_from_oe_ids} =~ s/\s+$//; my @convert_from_oe_ids = split m/\s+/, $form->{convert_from_oe_ids}; delete $form->{convert_from_oe_ids}; - if (scalar @convert_from_oe_ids) { + if (!$form->{useasnew} && scalar @convert_from_oe_ids) { RecordLinks->create_links('dbh' => $dbh, 'mode' => 'ids', 'from_table' => 'oe', @@ -920,7 +924,7 @@ sub retrieve { # if called in multi id mode, and still only got one id, switch back to single id if ($form->{"rowcount"} and $#ids == 0) { - $form->{"id"} = $ids[0]; + $form->{"id"} = $ids[0]; undef @ids; delete $form->{convert_from_oe_ids}; } @@ -1572,9 +1576,15 @@ sub order_details { $form->{subtotal_nofmt} = $form->{ordtotal}; } - $form->{ordtotal} = ($form->{taxincluded}) ? $form->{ordtotal} : $form->{ordtotal} + $tax; + my $grossamount = ($form->{taxincluded}) ? $form->{ordtotal} : $form->{ordtotal} + $tax; + $form->{ordtotal} = $form->round_amount( $grossamount, 2, 1); + $form->{rounding} = $form->round_amount( + $form->{ordtotal} - $form->round_amount($grossamount, 2), + 2 + ); # format amounts + $form->{rounding} = $form->format_amount($myconfig, $form->{rounding}, 2); $form->{quototal} = $form->{ordtotal} = $form->format_amount($myconfig, $form->{ordtotal}, 2); $form->set_payment_options($myconfig, $form->{$form->{type} =~ /_quotation/ ? 'quodate' : 'orddate'}, $form->{type});