X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/b256bef1f542bc5f6c1a7aa38854e5a141e57af1..dcfb77f68fefa97bd32e7d9fe828f74f8b6133a0:/SL/IR.pm diff --git a/SL/IR.pm b/SL/IR.pm index 602ffc365..1f30c6b46 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -158,7 +158,7 @@ sub post_invoice { $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2); if ($form->{taxincluded}) { - + $taxamount = $linetotal * ($taxrate / (1 + $taxrate)); $form->{"sellprice_$i"} = $form->{"sellprice_$i"} * (1 / (1 + $taxrate)); @@ -388,7 +388,7 @@ sub post_invoice { # income accounts, it is enough to add the total rounding error to one of # the income accounts, with the one assigned to the last row being used # (lastinventoryaccno) - + # in the purchase invoice case rounding errors may be split between # inventory accounts and expense accounts. After rounding, an error of 1 # cent is introduced if the total rounding error exceeds 0.005. The total @@ -400,12 +400,10 @@ sub post_invoice { # shall receive the total rounding error, and the next time it is rounded # the 1 cent correction will be introduced. - my $total_rounding_diff = $invoicediff+$expensediff; - $form->{amount}{ $form->{id} }{$lastinventoryaccno} -= $invoicediff if $lastinventoryaccno; $form->{amount}{ $form->{id} }{$lastexpenseaccno} -= $expensediff if $lastexpenseaccno; - if ( ($expensediff+$invoicediff) >= 0.005 and $expensediff < 0.005 and $invoicediff < 0.005 ) { + if ( (abs($expensediff)+abs($invoicediff)) >= 0.005 and abs($expensediff) < 0.005 and abs($invoicediff) < 0.005 ) { # in total the rounding error adds up to 1 cent effectively, correct the # larger of the two numbers @@ -1069,6 +1067,11 @@ sub retrieve_item { push @values, $form->{"partnumber_$i"}; } + if ($form->{"id_${i}"}) { + $where .= qq| AND p.id = ?|; + push @values, $form->{"id_${i}"}; + } + if ($form->{"description_$i"}) { $where .= " ORDER BY p.description"; } else { @@ -1126,6 +1129,19 @@ sub retrieve_item { WHERE $where|; my $sth = prepare_execute_query($form, $dbh, $query, @values); + my @translation_queries = ( [ qq|SELECT tr.translation, tr.longdescription + FROM translation tr + WHERE tr.language_id = ? AND tr.parts_id = ?| ], + [ qq|SELECT tr.translation, tr.longdescription + FROM translation tr + WHERE tr.language_id IN + (SELECT id + FROM language + WHERE article_code = (SELECT article_code FROM language WHERE id = ?)) + AND tr.parts_id = ? + LIMIT 1| ] ); + map { push @{ $_ }, prepare_query($form, $dbh, $_->[0]) } @translation_queries; + $form->{item_list} = []; while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { @@ -1175,6 +1191,16 @@ sub retrieve_item { $form->{taxaccounts} .= "$ptr->{accno} "; } + if ($form->{language_id}) { + for my $spec (@translation_queries) { + do_statement($form, $spec->[1], $spec->[0], conv_i($form->{language_id}), conv_i($ref->{id})); + my ($translation, $longdescription) = $spec->[1]->fetchrow_array; + next unless $translation; + $ref->{description} = $translation; + $ref->{longdescription} = $longdescription; + last; + } + } } $stw->finish(); @@ -1187,6 +1213,7 @@ sub retrieve_item { } $sth->finish(); + $_->[1]->finish for @translation_queries; foreach my $item (@{ $form->{item_list} }) { my $custom_variables = CVar->get_custom_variables(module => 'IC',