Merge branch 'master' of lx-office.linet-services.de:lx-office-erp
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 2 Sep 2011 14:05:47 +0000 (16:05 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 2 Sep 2011 14:05:47 +0000 (16:05 +0200)
SL/IC.pm
SL/IR.pm
SL/IS.pm

index c07227f..e3b33d7 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -702,16 +702,17 @@ sub assembly_item {
     push(@values, '%' . $form->{"${column}_$i"} . '%');
   }
 
-  if ($form->{"id_${i}"}) {
-    $where .= qq| AND p.id = ?|;
-    push @values, $form->{"id_${i}"};
-  }
-
   if ($form->{id}) {
     $where .= qq| AND NOT (p.id = ?)|;
     push(@values, conv_i($form->{id}));
   }
 
+  # Search for part ID overrides all other criteria.
+  if ($form->{"id_${i}"}) {
+    $where  = qq|p.id = ?|;
+    @values = ($form->{"id_${i}"});
+  }
+
   if ($form->{partnumber}) {
     $where .= qq| ORDER BY p.partnumber|;
   } else {
index 0fe1987..909a3b0 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -106,7 +106,7 @@ sub post_invoice {
     if ( $::instance_conf->get_inventory_system eq 'periodic') {
       # inventory account number is overwritten with expense account number, so
       # never book incoming to inventory account but always to expense account
-      $form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"} 
+      $form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"}
     };
 
     # get item baseunit
@@ -226,14 +226,14 @@ sub post_invoice {
            # ORDER BY transdate guarantees FIFO
 
 # sold two items without having bought them yet, example result of query:
-# id | qty | allocated | trans_id | inventory_accno_id | expense_accno_id | transdate  
+# id | qty | allocated | trans_id | inventory_accno_id | expense_accno_id | transdate
 # ---+-----+-----------+----------+--------------------+------------------+------------
 #  9 |   2 |         0 |        9 |                 15 |              151 | 2011-01-05
 
 # base_qty + allocated > 0 if article has already been sold but not bought yet
 
 # select qty,allocated,base_qty,sellprice from invoice where trans_id = 9;
-#  qty | allocated | base_qty | sellprice  
+#  qty | allocated | base_qty | sellprice
 # -----+-----------+----------+------------
 #    2 |         0 |        2 | 1000.00000
 
@@ -1093,9 +1093,10 @@ sub retrieve_item {
       push @values, $form->{"partnumber_$i"};
    }
 
+  # Search for part ID overrides all other criteria.
   if ($form->{"id_${i}"}) {
-    $where .= qq| AND p.id = ?|;
-    push @values, $form->{"id_${i}"};
+    $where  = qq|p.id = ?|;
+    @values = ($form->{"id_${i}"});
   }
 
   if ($form->{"description_$i"}) {
index 35a902e..6c23f2d 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -1261,7 +1261,7 @@ sub cogs {
 
 # all invoice entries of an example part:
 
-# id | trans_id | base_qty | allocated | sellprice | inventory_accno | income_accno | expense_accno 
+# id | trans_id | base_qty | allocated | sellprice | inventory_accno | income_accno | expense_accno
 # ---+----------+----------+-----------+-----------+-----------------+--------------+---------------
 #  4 |        4 |       -5 |         5 |  20.00000 | 1140            | 4400         | 5400     bought 5 for 20
 #  5 |        5 |        4 |        -4 |  50.00000 | 1140            | 4400         | 5400     sold   4 for 50
@@ -1771,9 +1771,10 @@ sub retrieve_item {
     push @values, $form->{"partnumber_$i"};
   }
 
+  # Search for part ID overrides all other criteria.
   if ($form->{"id_${i}"}) {
-    $where .= qq| AND p.id = ?|;
-    push @values, $form->{"id_${i}"};
+    $where  = qq|p.id = ?|;
+    @values = ($form->{"id_${i}"});
   }
 
   if ($form->{"description_$i"}) {