]> wagnertech.de Git - mfinanz.git/blobdiff - SL/IR.pm
Typos
[mfinanz.git] / SL / IR.pm
index 86b1323fdd432710b23db8a64fe5db1cd45c7471..1f30c6b4612aa14fc8f4f5636a788373e0409016 100644 (file)
--- 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
@@ -1067,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 {
@@ -1124,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")) {
 
@@ -1173,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();
@@ -1185,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',