Einkaufsrechnungen: Suche nach Artikelnummer/-beschreibung in Positionen
[kivitendo-erp.git] / SL / AP.pm
index 9e108a1..92dc733 100644 (file)
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -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;