]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/IC.pm
aliased subqueries müssen mit ihrem alias im group by stehen.
[kivitendo-erp.git] / SL / IC.pm
index dd47909432f95b26efef15ca3a5a134ed8356e8b..f691a354f2e32e6a810a5ab4f9f5c6cbe09e588a 100644 (file)
--- 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;