From 7e2f7d89d77305ba071fe4f09bc158b711b00738 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 14 May 2009 09:43:33 +0000 Subject: [PATCH] =?utf8?q?Beim=20Bericht=20=C3=BCber=20Erzeugnisse=20den?= =?utf8?q?=20Einkaufspreis=20auch=20anzeigen,=20wenn=20er=20ausgew=C3=A4hl?= =?utf8?q?t=20ist.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Der Einkaufspreis berechnet sich dann aus der Summe der Einkaufspreise der Einzelartikel, wobei dieser wiederum das Produkt aus Einzeleinkaufspreis und Anzahl ist. Fix für Bug 978. --- SL/IC.pm | 13 ++++++++++++- bin/mozilla/ic.pl | 5 ----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/SL/IC.pm b/SL/IC.pm index f9315f42a..dd4790943 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -793,6 +793,10 @@ sub all_parts { my @join_order = qw(partsgroup makemodel invoice_oi apoe cv pfac); my %joins_needed; + if (($form->{searchitems} eq 'assembly') && $form->{l_lastcost}) { + @simple_l_switches = grep { $_ ne 'lastcost' } @simple_l_switches; + } + #===== switches and simple filters ========# my @select_tokens = qw(id factor); @@ -845,6 +849,12 @@ sub all_parts { push @where_tokens, 'p.onhand < p.rop', if /short/; } + my $q_assembly_lastcost = + qq|(SELECT SUM(a_lc.qty * p_lc.lastcost / COALESCE(pfac_lc.factor, 1)) + 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|; my @sort_cols = (@simple_filters, qw(id bin priceupdate onhand invnumber ordnumber quonumber name serialnumber soldtotal deliverydate)); $form->{sort} = 'id' unless grep { $form->{"l_$_"} } grep { $form->{sort} eq $_ } @sort_cols; @@ -871,6 +881,7 @@ sub all_parts { my @bsooqr; push @select_tokens, @qsooqr_flags if $bsooqr; push @select_tokens, @deliverydate_flags if $bsooqr && $form->{l_deliverydate}; + push @select_tokens, $q_assembly_lastcost if ($form->{searchitems} eq 'assembly') && $form->{l_lastcost}; push @bsooqr_tokens, q|module = 'ir' AND NOT ioi.assemblyitem| if $form->{bought}; push @bsooqr_tokens, q|module = 'is' AND NOT ioi.assemblyitem| if $form->{sold}; push @bsooqr_tokens, q|module = 'oe' AND NOT quotation AND cv = 'customer'| if $form->{ordered}; @@ -928,7 +939,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 { ($table_prefix{$_} || "p.") . $_ . $renamed_columns{$_} } @select_tokens; + my $select_clause = join ', ', map { ((substr($_, 0, 1) eq '(') ? '' : $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; diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index 5aa9e2c6a..3a34b2b14 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -574,9 +574,6 @@ sub addtop100 { } } - $form->{l_lastcost} = "" - if ($form->{searchitems} eq 'assembly' && !$form->{bom}); - foreach my $item (@columns) { if ($form->{"l_$item"} eq "Y") { push @column_index, $item; @@ -1114,8 +1111,6 @@ sub generate_report { } } - $form->{l_lastcost} = "" if ($form->{searchitems} eq 'assembly' && !$form->{bom}); - IC->all_parts(\%myconfig, \%$form); my @columns = -- 2.20.1