Revision 7e2f7d89
Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt
SL/IC.pm | ||
---|---|---|
793 | 793 |
my @join_order = qw(partsgroup makemodel invoice_oi apoe cv pfac); |
794 | 794 |
my %joins_needed; |
795 | 795 |
|
796 |
if (($form->{searchitems} eq 'assembly') && $form->{l_lastcost}) { |
|
797 |
@simple_l_switches = grep { $_ ne 'lastcost' } @simple_l_switches; |
|
798 |
} |
|
799 |
|
|
796 | 800 |
#===== switches and simple filters ========# |
797 | 801 |
|
798 | 802 |
my @select_tokens = qw(id factor); |
... | ... | |
845 | 849 |
push @where_tokens, 'p.onhand < p.rop', if /short/; |
846 | 850 |
} |
847 | 851 |
|
852 |
my $q_assembly_lastcost = |
|
853 |
qq|(SELECT SUM(a_lc.qty * p_lc.lastcost / COALESCE(pfac_lc.factor, 1)) |
|
854 |
FROM assembly a_lc |
|
855 |
LEFT JOIN parts p_lc ON (a_lc.parts_id = p_lc.id) |
|
856 |
LEFT JOIN price_factors pfac_lc ON (p_lc.price_factor_id = pfac_lc.id) |
|
857 |
WHERE (a_lc.id = p.id)) AS lastcost|; |
|
848 | 858 |
|
849 | 859 |
my @sort_cols = (@simple_filters, qw(id bin priceupdate onhand invnumber ordnumber quonumber name serialnumber soldtotal deliverydate)); |
850 | 860 |
$form->{sort} = 'id' unless grep { $form->{"l_$_"} } grep { $form->{sort} eq $_ } @sort_cols; |
... | ... | |
871 | 881 |
my @bsooqr; |
872 | 882 |
push @select_tokens, @qsooqr_flags if $bsooqr; |
873 | 883 |
push @select_tokens, @deliverydate_flags if $bsooqr && $form->{l_deliverydate}; |
884 |
push @select_tokens, $q_assembly_lastcost if ($form->{searchitems} eq 'assembly') && $form->{l_lastcost}; |
|
874 | 885 |
push @bsooqr_tokens, q|module = 'ir' AND NOT ioi.assemblyitem| if $form->{bought}; |
875 | 886 |
push @bsooqr_tokens, q|module = 'is' AND NOT ioi.assemblyitem| if $form->{sold}; |
876 | 887 |
push @bsooqr_tokens, q|module = 'oe' AND NOT quotation AND cv = 'customer'| if $form->{ordered}; |
... | ... | |
928 | 939 |
map { $table_prefix{$_} = 'ioi.' } qw(description serialnumber qty unit) if $joins_needed{invoice_oi}; |
929 | 940 |
map { $renamed_columns{$_} = ' AS ' . $renamed_columns{$_} } keys %renamed_columns; |
930 | 941 |
|
931 |
my $select_clause = join ', ', map { ($table_prefix{$_} || "p.") . $_ . $renamed_columns{$_} } @select_tokens; |
|
942 |
my $select_clause = join ', ', map { ((substr($_, 0, 1) eq '(') ? '' : $table_prefix{$_} || "p.") . $_ . $renamed_columns{$_} } @select_tokens;
|
|
932 | 943 |
my $join_clause = join ' ', @joins{ grep $joins_needed{$_}, @join_order }; |
933 | 944 |
my $where_clause = join ' AND ', map { "($_)" } @where_tokens; |
934 | 945 |
my $group_clause = ' GROUP BY ' . join ', ', map { ($table_prefix{$_} || "p.") . $_ } @group_tokens if scalar @group_tokens; |
Auch abrufbar als: Unified diff
Beim Bericht über Erzeugnisse den Einkaufspreis auch anzeigen, wenn er ausgewählt ist.
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.