X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/7e2f7d89d77305ba071fe4f09bc158b711b00738..9d2ac13b7b318be0540c6fc5d96b412e8c7bab02:/SL/IC.pm diff --git a/SL/IC.pm b/SL/IC.pm index dd4790943..f691a354f 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -914,6 +914,7 @@ sub all_parts { if ($form->{l_soldtotal}) { push @where_tokens, 'ioi.qty >= 0'; push @group_tokens, @select_tokens; + map { s/.*\sAS\s+//si } @group_tokens; push @select_tokens, 'SUM(ioi.qty)'; } @@ -927,10 +928,13 @@ sub all_parts { ordnumber => 'apoe.', make => 'mm.', quonumber => 'apoe.', model => 'mm.', invnumber => 'apoe.', partsgroup => 'pg.', + lastcost => ' ', factor => 'pfac.', 'SUM(ioi.qty)' => ' ', ); + $table_prefix{$q_assembly_lastcost} = ' '; + my %renamed_columns = ( 'factor' => 'price_factor', 'SUM(ioi.qty)' => 'soldtotal', @@ -939,7 +943,7 @@ sub all_parts { map { $table_prefix{$_} = 'ioi.' } qw(description serialnumber qty unit) if $joins_needed{invoice_oi}; map { $renamed_columns{$_} = ' AS ' . $renamed_columns{$_} } keys %renamed_columns; - my $select_clause = join ', ', map { ((substr($_, 0, 1) eq '(') ? '' : $table_prefix{$_} || "p.") . $_ . $renamed_columns{$_} } @select_tokens; + my $select_clause = join ', ', map { ($table_prefix{$_} || "p.") . $_ . $renamed_columns{$_} } @select_tokens; my $join_clause = join ' ', @joins{ grep $joins_needed{$_}, @join_order }; my $where_clause = join ' AND ', map { "($_)" } @where_tokens; my $group_clause = ' GROUP BY ' . join ', ', map { ($table_prefix{$_} || "p.") . $_ } @group_tokens if scalar @group_tokens;