X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FIC.pm;h=c9511b4db52a461718adf4aa95af673948b2874d;hb=0ade2438400535b4b5d969244ff1b23daddaf3fb;hp=ab0c7913596498f1a9160addcb7919409e0440b5;hpb=5f783ffe9c431bf8bf4eed4a23192368aaf8341d;p=kivitendo-erp.git diff --git a/SL/IC.pm b/SL/IC.pm index ab0c79135..c9511b4db 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -819,7 +819,6 @@ sub all_parts { 'SUM(ioi.qty)' => ' ', description => 'p.', qty => 'ioi.', - unit => 'ioi.', serialnumber => 'ioi.', ); @@ -831,6 +830,7 @@ sub all_parts { [ 'description', 'ioi.', 'invoice_oi' ], [ 'deliverydate', 'ioi.', 'invoice_oi' ], [ 'transdate' , 'apoe.', 'apoe' ], + [ 'unit' , 'ioi.', 'invoice_oi' ], ); # careful with renames. these are HARD, and any filters done on the original column will break @@ -847,21 +847,18 @@ sub all_parts { my $joins_needed = shift; sub { my ($col, $group) = @_; - $renamed_columns{$col} ||= $col; - my @coalesce_tokens = - map { ($_->[1] || 'p.') . $_->[0] } + map { ($_->[1] || 'p.') . $_->[0] } grep { !$_->[2] || $joins_needed->{$_->[2]} } grep { $_->[0] eq $col } - @column_override, - [ $col, $table_prefix{$col} ]; + @column_override, [ $col, $table_prefix{$col} ]; - my $coalesce = scalar @coalesce_tokens > 1; + my $coalesce = scalar @coalesce_tokens > 1; return ($coalesce ? sprintf 'COALESCE(%s)', join ', ', @coalesce_tokens : shift @coalesce_tokens) - . ($group && $coalesce - ? " AS $renamed_columns{$col}" + . ($group && ($coalesce || $renamed_columns{$col}) + ? " AS " . ($renamed_columns{$col} || $col) : ''); } };