From 82498fb730310873bc3011070b6249034255354e Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 12 Dec 2008 15:43:41 +0000 Subject: [PATCH] =?utf8?q?Lagerbestandswert=20zum=20Lagerbericht=20erg?= =?utf8?q?=C3=A4nzt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/WH.pm | 12 +++++ bin/mozilla/wh.pl | 46 ++++++++++++++----- locale/de/all | 2 + locale/de/wh | 2 + templates/webpages/wh/report_filter_de.html | 6 +++ .../webpages/wh/report_filter_master.html | 6 +++ 6 files changed, 63 insertions(+), 11 deletions(-) diff --git a/SL/WH.pm b/SL/WH.pm index 70f1037c2..3428b91bc 100644 --- a/SL/WH.pm +++ b/SL/WH.pm @@ -433,6 +433,7 @@ sub get_warehouse_report { "chargeid" => "c.id", "warehousedescription" => "w.description", "partunit" => "p.unit", + "stock_value" => "p.lastcost / COALESCE(pfac.factor, 1)", ); my $select_clause = join ', ', map { +/^l_/; "$select_tokens{$'} AS $'" } ( grep( { !/qty/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), @@ -442,6 +443,14 @@ sub get_warehouse_report { ( grep( { !/qty/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), qw(l_parts_id l_partunit) ); + my %join_tokens = ( + "stock_value" => "LEFT JOIN price_factors pfac ON (p.price_factor_id = pfac.id)", + ); + + my $joins = join ' ', grep { $_ } map { +/^l_/; $join_tokens{"$'"} } + ( grep( { !/qty/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), + qw(l_parts_id l_qty l_partunit) ); + my $query = qq|SELECT $select_clause $columns @@ -449,6 +458,7 @@ sub get_warehouse_report { LEFT JOIN parts p ON i.parts_id = p.id LEFT JOIN bin b ON i.bin_id = b.id LEFT JOIN warehouse w ON i.warehouse_id = w.id + $joins WHERE $where_clause GROUP BY $group_clause $group_by ORDER BY $form->{sort}|; @@ -477,6 +487,8 @@ sub get_warehouse_report { @all_fields = keys %{ $ref } unless (@all_fields); } + $ref->{stock_value} *= $ref->{qty}; + push @contents, $ref; } diff --git a/bin/mozilla/wh.pl b/bin/mozilla/wh.pl index 5326cfb52..415ed39be 100644 --- a/bin/mozilla/wh.pl +++ b/bin/mozilla/wh.pl @@ -625,7 +625,7 @@ sub generate_report { my $sort_col = $form->{sort}; my %filter; - my @columns = qw(warehousedescription bindescription partnumber partdescription chargenumber qty); + my @columns = qw(warehousedescription bindescription partnumber partdescription chargenumber qty stock_value); # filter stuff map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber); @@ -655,12 +655,13 @@ sub generate_report { 'partdescription' => { 'text' => $locale->text('Description'), }, 'chargenumber' => { 'text' => $locale->text('Charge Number'), }, 'qty' => { 'text' => $locale->text('Qty'), }, + 'stock_value' => { 'text' => $locale->text('Stock value'), }, ); my $href = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables); map { $column_defs{$_}->{link} = $href . "&sort=${_}&order=" . Q($_ eq $sort_col ? 1 - $form->{order} : $form->{order}) } @columns; - my %column_alignment = map { $_ => 'right' } qw(qty); + my %column_alignment = map { $_ => 'right' } qw(qty stock_value); map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns; @@ -679,14 +680,21 @@ sub generate_report { my $all_units = AM->retrieve_units(\%myconfig, $form); my @contents = WH->get_warehouse_report(%filter); - my $subtotal = 0; my $idx = 0; + my @subtotals_columns = qw(qty stock_value); + my %subtotals = map { $_ => 0 } @subtotals_columns; + + my $total_stock_value = 0; + foreach $entry (@contents) { - $subtotal += $entry->{qty}; - $entry->{qty} = $form->format_amount_units('amount' => $entry->{qty}, - 'part_unit' => $entry->{partunit}, - 'conv_units' => 'convertible'); + map { $subtotals{$_} += $entry->{$_} } @subtotals_columns; + $total_stock_value += $entry->{stock_value} * 1; + + $entry->{qty} = $form->format_amount_units('amount' => $entry->{qty}, + 'part_unit' => $entry->{partunit}, + 'conv_units' => 'convertible'); + $entry->{stock_value} = $form->format_amount(\%myconfig, $entry->{stock_value} * 1, 2); $row_set = [ { map { $_ => { 'data' => $entry->{$_}, 'align' => $column_alignment{$_} } } @columns } ]; @@ -695,10 +703,12 @@ sub generate_report { || ($entry->{$sort_col} ne $contents[$idx + 1]->{$sort_col}))) { my $row = { map { $_ => { 'data' => '', 'class' => 'listsubtotal', 'align' => $column_alignment{$_}, } } @columns }; - $row->{qty}->{data} = $form->format_amount_units('amount' => $subtotal, - 'part_unit' => $entry->{partunit}, - 'conv_units' => 'convertible'); - $subtotal = 0; + $row->{qty}->{data} = $form->format_amount_units('amount' => $subtotals{qty} * 1, + 'part_unit' => $entry->{partunit}, + 'conv_units' => 'convertible'); + $row->{stock_value}->{data} = $form->format_amount(\%myconfig, $subtotals{stock_value} * 1, 2); + + %subtotals = map { $_ => 0 } @subtotals_columns; push @{ $row_set }, $row; } @@ -708,6 +718,20 @@ sub generate_report { $idx++; } + if ($column_defs{stock_value}->{visible}) { + $report->add_separator(); + + my $row = { map { $_ => { 'data' => '', 'class' => 'listsubtotal', } } @columns }; + + my $left_col = first { $column_defs{$_}->{visible} } @columns; + + $row->{$left_col}->{data} = $locale->text('Total stock value'); + $row->{stock_value}->{data} = $form->format_amount(\%myconfig, $total_stock_value, 2); + $row->{stock_value}->{align} = 'right'; + + $report->add_data($row); + } + $report->generate_with_headers(); $lxdebug->leave_sub(); diff --git a/locale/de/all b/locale/de/all index b24628009..e1a346d30 100644 --- a/locale/de/all +++ b/locale/de/all @@ -1299,6 +1299,7 @@ $self->{texts} = { 'Step 3 of 3: Default units' => 'Schritt 3 von 3: Standardeinheiten', 'Steuersatz' => 'Steuersatz', 'Stock' => 'Einlagern', + 'Stock value' => 'Bestandswert', 'Storno' => 'Storno', 'Storno (one letter abbreviation)' => 'S', 'Storno Invoice' => 'Stornorechnung', @@ -1498,6 +1499,7 @@ $self->{texts} = { 'Top Level' => 'Hauptartikelbezeichnung', 'Total' => 'Summe', 'Total Fees' => 'Kumulierte Gebühren', + 'Total stock value' => 'Gesamter Bestandswert', 'Trade Discount' => 'Rabatt', 'Trans Id' => 'Trans-ID', 'Trans Type' => 'Transfertyp', diff --git a/locale/de/wh b/locale/de/wh index 05cb2607e..369284554 100644 --- a/locale/de/wh +++ b/locale/de/wh @@ -124,6 +124,7 @@ $self->{texts} = { 'Select a part' => 'Artikel auswählen', 'Select a vendor' => 'Einen Lieferanten auswählen', 'Stock' => 'Einlagern', + 'Stock value' => 'Bestandswert', 'Storno Invoice' => 'Stornorechnung', 'Storno Packing List' => 'Stornolieferschein', 'Subject' => 'Betreff', @@ -147,6 +148,7 @@ $self->{texts} = { 'The warehouse or the bin is missing.' => 'Das Lager oder der Lagerplatz fehlen.', 'There is not enough left of \'#1\' in bin \'#2\' for the removal of #3.' => 'In Lagerplatz \'#2\' ist nicht genug von \'#1\' vorhanden, um #3 zu entnehmen.', 'To (email)' => 'An', + 'Total stock value' => 'Gesamter Bestandswert', 'Trans Id' => 'Trans-ID', 'Trans Type' => 'Transfertyp', 'Transactions, AR transactions, AP transactions' => 'Dialogbuchen, Debitorenrechnungen, Kreditorenrechnungen', diff --git a/templates/webpages/wh/report_filter_de.html b/templates/webpages/wh/report_filter_de.html index c59a87417..c399e6caf 100644 --- a/templates/webpages/wh/report_filter_de.html +++ b/templates/webpages/wh/report_filter_de.html @@ -157,6 +157,12 @@ + + + + + + diff --git a/templates/webpages/wh/report_filter_master.html b/templates/webpages/wh/report_filter_master.html index 860b4e1e1..30a9e5209 100644 --- a/templates/webpages/wh/report_filter_master.html +++ b/templates/webpages/wh/report_filter_master.html @@ -157,6 +157,12 @@ + + + + + + -- 2.20.1