From 7fb9840166f036f4d0ab1f937213abcf199f819f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 26 Jul 2017 15:46:42 +0200 Subject: [PATCH] DeliveryValueReport: Auf ShppedQty Helper umgestellt. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Leider fällt geht dabei die Information verloren, wieviel davon in geschlossenen Lieferscheinen ist. Wenn benötigt, muss das nachgebaut werden. --- SL/Controller/DeliveryValueReport.pm | 55 +++++++++------------------- locale/de/all | 2 - 2 files changed, 18 insertions(+), 39 deletions(-) diff --git a/SL/Controller/DeliveryValueReport.pm b/SL/Controller/DeliveryValueReport.pm index 6af57e815..20e02869e 100644 --- a/SL/Controller/DeliveryValueReport.pm +++ b/SL/Controller/DeliveryValueReport.pm @@ -9,6 +9,7 @@ use SL::DB::Business; use SL::Controller::Helper::GetModels; use SL::Controller::Helper::ReportGenerator; use SL::Locale::String; +use SL::Helper::ShippedQty; use SL::AM; use SL::DBUtils (); use Carp; @@ -37,8 +38,6 @@ my %sort_columns = ( netto_shipped_qty => t8('Net Value in delivery orders'), delivered_qty => t8('transferred in / out'), netto_delivered_qty => t8('Net value transferred in / out'), - do_closed_qty => t8('Qty in closed delivery orders'), - netto_do_closed_qty => t8('Net value in closed delivery orders') ); @@ -69,7 +68,7 @@ sub prepare_report { my @columns = qw(reqdate customer vendor ordnumber partnumber description unit qty netto_qty not_shipped_qty netto_not_shipped_qty shipped_qty netto_shipped_qty delivered_qty - netto_delivered_qty do_closed_qty netto_do_closed_qty); + netto_delivered_qty); my @sortable = qw(reqdate customer vendor ordnumber partnumber description); @@ -103,9 +102,6 @@ sub prepare_report { $_[0]{shipped_qty} - $_[0]{delivered_qty} - $_[0]{do_closed_qty}) * ($_[0]->sellprice * (1 - $_[0]->discount) / ($_[0]->price_factor || 1)), 2)) },}, - do_closed_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]{do_closed_qty}, 2) . - ($rp_csv_mod ? '' : ' ' . $_[0]->unit) },}, - netto_do_closed_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]{netto_do_closed_qty}, 2) },}, ordnumber => { sub => sub { $_[0]->order->ordnumber }, obj_link => sub { $self->link_to($_[0]->order) } }, vendor => { sub => sub { $_[0]->order->vendor->name }, @@ -255,42 +251,27 @@ sub link_to { sub calc_qtys_price { my ($self, $orderitems) = @_; - # using $orderitem->shipped_qty 40 times is far too slow. need to do it manually - # also for calc net values return unless scalar @$orderitems; - my %orderitems_by_id = map { $_->id => $_ } @$orderitems; + SL::Helper::ShippedQty + ->new(require_stock_out => 1) + ->calculate($orderitems) + ->write_to_objects; - my $query = <get_standard_dbh, $query, map { $_->id } @$orderitems); - - for my $row (@$result) { - my $item = $orderitems_by_id{ $row->{id} }; - $item->{shipped_qty} ||= 0; - $item->{delivered_qty} ||= 0; - $item->{do_closed_qty} ||= 0; - $item->{shipped_qty} += AM->convert_unit($row->{unit} => $item->unit) * $row->{qty} unless ($row->{delivered} || $row->{closed}); - $item->{delivered_qty} += AM->convert_unit($row->{unit} => $item->unit) * $row->{qty} if ($row->{delivered} && !$row->{closed}); - $item->{do_closed_qty} += AM->convert_unit($row->{unit} => $item->unit) * $row->{qty} if ($row->{closed}); - $item->{not_shipped_qty} += AM->convert_unit($row->{unit} => $item->unit) * $row->{qty} unless ($row->{delivered}); - - my $price_factor = $row->{price_factor} || 1; - $item->{netto_shipped_qty} = $item->{shipped_qty} * $row->{sellprice} * (1 - $row->{discount} ) / $price_factor; - $item->{netto_delivered_qty} = $item->{delivered_qty} * $row->{sellprice} * (1 - $row->{discount} ) / $price_factor; - $item->{netto_do_closed_qty} = $item->{do_closed_qty} * $row->{sellprice} * (1 - $row->{discount} ) / $price_factor; + $_->{delivered_qty} = delete $_->{shipped_qty} for @$orderitems; + + SL::Helper::ShippedQty + ->new(require_stock_out => 0) + ->calculate($orderitems) + ->write_to_objects; + + for my $item (@$orderitems) { + $item->{not_shipped_qty} = $item->qty - $item->{shipped_qty}; + my $price_factor = $item->price_factor || 1; + $item->{netto_shipped_qty} = $item->{shipped_qty} * $item->sellprice * (1 - $item->discount) / $price_factor; + $item->{netto_delivered_qty} = $item->{delivered_qty} * $item->sellprice * (1 - $item->discount) / $price_factor; } } diff --git a/locale/de/all b/locale/de/all index 93190badf..e567c75a6 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1829,7 +1829,6 @@ $self->{texts} = { 'Net amount (for verification)' => 'Nettobetrag (zur Überprüfung)', 'Net amounts differ too much' => 'Nettobeträge weichen zu sehr ab.', 'Net value in Order' => 'Netto Auftrag', - 'Net value in closed delivery orders' => 'Netto in geschlossenen Lieferscheinen', 'Net value transferred in / out' => 'Netto ein- /ausgelagert', 'Net value without delivery orders' => 'Netto ohne Lieferschein', 'Netherlands' => 'Niederlande', @@ -2315,7 +2314,6 @@ $self->{texts} = { 'Qty equals #1' => 'Menge ist #1', 'Qty in Order' => 'Menge Auftrag', 'Qty in Selected Records' => 'Menge in gewählten Belegen', - 'Qty in closed delivery orders' => 'Menge in geschlossenen Lieferscheinen', 'Qty in delivery orders' => 'Menge mit Lieferschein', 'Qty in stock' => 'Lagerbestand', 'Qty less than #1' => 'Menge weniger als #1', -- 2.20.1