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 {
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
# 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
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"}) {
# 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
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"}) {