]> wagnertech.de Git - mfinanz.git/blobdiff - SL/AP.pm
BankTransaction: Filter aus letztem Commit auch nicht vorbelegen
[mfinanz.git] / SL / AP.pm
index 9e108a1caaa2312fd656cc413f66b5b689a90d65..e8dd4958a6a15083f7c41bbadf44f37396ba74a8 100644 (file)
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -482,7 +482,7 @@ sub ap_transactions {
   }
   if ($form->{project_id}) {
     $where .=
   }
   if ($form->{project_id}) {
     $where .=
-      qq|AND ((a.globalproject_id = ?) OR EXISTS | .
+      qq| AND ((a.globalproject_id = ?) OR EXISTS | .
       qq|  (SELECT * FROM invoice i | .
       qq|   WHERE i.project_id = ? AND i.trans_id = a.id) | .
       qq| OR EXISTS | .
       qq|  (SELECT * FROM invoice i | .
       qq|   WHERE i.project_id = ? AND i.trans_id = a.id) | .
       qq| OR EXISTS | .
@@ -507,6 +507,33 @@ sub ap_transactions {
     }
   }
 
     }
   }
 
+  if ($form->{parts_partnumber}) {
+    $where .= <<SQL;
+ AND EXISTS (
+        SELECT invoice.trans_id
+        FROM invoice
+        LEFT JOIN parts ON (invoice.parts_id = parts.id)
+        WHERE (invoice.trans_id = a.id)
+          AND (parts.partnumber ILIKE ?)
+        LIMIT 1
+      )
+SQL
+    push @values, like($form->{parts_partnumber});
+  }
+
+  if ($form->{parts_description}) {
+    $where .= <<SQL;
+ AND EXISTS (
+        SELECT invoice.trans_id
+        FROM invoice
+        WHERE (invoice.trans_id = a.id)
+          AND (invoice.description ILIKE ?)
+        LIMIT 1
+      )
+SQL
+    push @values, like($form->{parts_description});
+  }
+
   if ($where) {
     substr($where, 0, 4, " WHERE ");
     $query .= $where;
   if ($where) {
     substr($where, 0, 4, " WHERE ");
     $query .= $where;
@@ -719,7 +746,7 @@ sub setup_form {
           }
 
           $index                 = $form->{acc_trans}{$key}->[$i - 1]->{index};
           }
 
           $index                 = $form->{acc_trans}{$key}->[$i - 1]->{index};
-          $form->{"tax_$index"}  = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
+          $form->{"tax_$index"}  = $form->round_amount($form->{acc_trans}{$key}->[$i - 1]->{amount} * -1 / $exchangerate, 2);
           $totaltax             += $form->{"tax_$index"};
 
         } else {
           $totaltax             += $form->{"tax_$index"};
 
         } else {