From 5074cc502811728e2bbaf42cfd5ea39974ba6e2a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 2 Sep 2011 16:05:38 +0200 Subject: [PATCH] =?utf8?q?Artikelauswahl=20gefixt:=20das=20Ausgew=C3=A4hlt?= =?utf8?q?e=20nehmen,=20nicht=20den=20ersten=20Treffer?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Hintergrund: Suche in SL/IS.pm hat (sehr außergewöhnlich) ein Suchkriterium nach EAN mit "OR" verknüpft. Dadurch, dass die Suche nach ID schlicht ans Ende mit "AND" gestellt wurde, ergab sich grob "(NOT OBSOLETE) OR (ean = ? AND id = ?)", wodurch wieder mehr als ein Treffer gefunden wurde. Bug wurde in Revision cb253140 eingebaut. --- SL/IC.pm | 11 ++++++----- SL/IR.pm | 11 ++++++----- SL/IS.pm | 7 ++++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/SL/IC.pm b/SL/IC.pm index c07227f54..e3b33d7c7 100644 --- 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 { diff --git a/SL/IR.pm b/SL/IR.pm index 0fe19877d..909a3b07d 100644 --- 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"}) { diff --git a/SL/IS.pm b/SL/IS.pm index 35a902e8b..6c23f2d64 100644 --- 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"}) { -- 2.20.1