X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIC.pm;h=da83c33b8ed18fc9ef1593b8f849ef140f4c4982;hb=10c5bcd8845b264febd0c7bfd1a690e287703b54;hp=46f0f542cebecac4c7b079fcf6bf20d8c5d25b43;hpb=0b36b2259c1300ee5360a9c8d5aee1f321abd364;p=kivitendo-erp.git diff --git a/SL/IC.pm b/SL/IC.pm index 46f0f542c..da83c33b8 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -272,10 +272,6 @@ sub all_parts { insertdate => 'itime::DATE', ); - if ($form->{l_assembly} && $form->{l_lastcost}) { - @simple_l_switches = grep { $_ ne 'lastcost' } @simple_l_switches; - } - my $make_token_builder = sub { my $joins_needed = shift; sub { @@ -402,7 +398,7 @@ sub all_parts { FROM assembly a_lc LEFT JOIN parts p_lc ON (a_lc.parts_id = p_lc.id) LEFT JOIN price_factors pfac_lc ON (p_lc.price_factor_id = pfac_lc.id) - WHERE (a_lc.id = p.id)) AS lastcost|; + WHERE (a_lc.id = p.id)) AS assembly_lastcost|; $table_prefix{$q_assembly_lastcost} = ' '; # special case makemodel search @@ -485,7 +481,7 @@ sub all_parts { my $token_builder = $make_token_builder->(\%joins_needed); - my @sort_cols = (@simple_filters, qw(id priceupdate onhand invnumber ordnumber quonumber name serialnumber soldtotal deliverydate insertdate shop)); + my @sort_cols = (@simple_filters, qw(id onhand invnumber ordnumber quonumber name serialnumber soldtotal deliverydate insertdate shop)); $form->{sort} = 'id' unless grep { $form->{"l_$_"} } grep { $form->{sort} eq $_ } @sort_cols; # sort by id if unknown or invisible column my $sort_order = ($form->{revers} ? ' DESC' : ' ASC'); my $order_clause = " ORDER BY " . $token_builder->($form->{sort}) . ($form->{revers} ? ' DESC' : ' ASC'); @@ -528,15 +524,17 @@ sub all_parts { # simple search for assemblies by items used in assemblies if ($form->{bom} eq '2' && $form->{l_assembly}) { + # assembly_qty is the column name + $form->{l_assembly_qty} = 1; # nuke where clause and bind vars $where_clause = ' 1=1 AND p.id in (SELECT id from assembly where parts_id IN ' . - ' (select id from parts where 1=1 AND '; + ' (select id from parts where 1=1'; @bind_vars = (); # use only like filter for items used in assemblies foreach (@like_filters) { next unless $form->{$_}; $form->{"l_$_"} = '1'; # show the column - $where_clause .= " $_ ILIKE ? "; + $where_clause .= " AND $_ ILIKE ? "; push @bind_vars, like($form->{$_}); } $where_clause .='))'; @@ -551,7 +549,6 @@ sub all_parts { $order_clause $limit_clause SQL - $form->{parts} = selectall_hashref_query($form, $dbh, $query, @bind_vars); map { $_->{onhand} *= 1 } @{ $form->{parts} }; @@ -568,10 +565,10 @@ sub all_parts { my @assemblies; if ($form->{l_assembly} && $form->{bom}) { $query = - qq|SELECT p.id, p.partnumber, p.description, a.qty AS onhand, + qq|SELECT p.id, p.partnumber, p.description, a.qty AS assembly_qty, p.unit, p.notes, p.itime::DATE as insertdate, p.sellprice, p.listprice, p.lastcost, - p.rop, p.weight, p.priceupdate, + p.rop, p.weight, p.image, p.drawing, p.microfiche, pfac.factor FROM parts p @@ -744,7 +741,9 @@ sub retrieve_accounts { # also use deliverydate for credit notes $transdate = $form->{tax_point} || $form->{deliverydate} || $form->{invdate}; } else { - $transdate = $form->{tax_point} || $form->{transdate}; + my $deliverydate; + $deliverydate = $form->{reqdate} if any { $_ eq $form->{type} } qw(sales_order request_quotation purchase_order); + $transdate = $form->{tax_point} || $deliverydate || $form->{transdate}; } if ($transdate eq "") {