From 7d8de6d3bc1c10309351c115b398d7dc97f5fd3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Mon, 3 Nov 2014 17:43:54 +0100 Subject: [PATCH] Verbesserungen Einkaufs-Lieferplan MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit a) keinen Fallunterschied für $vc im Template, sondern ein einfaches hidden flag vc b) kein copy & paste von action_list(_ap), sondern parameter in erp.ini c) performanteres grep, statt foreach in OrderItem (Details s.a. devel-liste) d) my $vc nicht als statische Klassenvariable gesetzt e) CSV-Export für beide Fälle richtig (filter vc übergeben) --- SL/Controller/DeliveryPlan.pm | 27 +++++++------------ SL/DB/OrderItem.pm | 7 ++--- menus/erp.ini | 4 ++- templates/webpages/delivery_plan/_filter.html | 9 +++---- 4 files changed, 18 insertions(+), 29 deletions(-) diff --git a/SL/Controller/DeliveryPlan.pm b/SL/Controller/DeliveryPlan.pm index b66698d76..6b16634dc 100644 --- a/SL/Controller/DeliveryPlan.pm +++ b/SL/Controller/DeliveryPlan.pm @@ -11,7 +11,7 @@ use SL::Locale::String; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(db_args flat_filter) ], - 'scalar --get_set_init' => [ qw(models all_edit_right) ], + 'scalar --get_set_init' => [ qw(models all_edit_right vc) ], ); __PACKAGE__->run_before(sub { $::auth->assert('delivery_plan'); }); @@ -30,24 +30,9 @@ my %sort_columns = ( value_of_goods => t8('Value of goods'), ); -my $vc; sub action_list { my ($self) = @_; - - $vc = "customer"; - $self->make_filter_summary; - $self->prepare_report; - - my $orderitems = $self->models->get; - - $self->report_generator_list_objects(report => $self->{report}, objects => $orderitems); -} - -sub action_list_ap { - my ($self) = @_; - - $vc = "vendor"; $self->make_filter_summary; $self->prepare_report; @@ -61,6 +46,7 @@ sub action_list_ap { sub prepare_report { my ($self) = @_; + my $vc = $self->vc; my $report = SL::ReportGenerator->new(\%::myconfig, $::form); $self->{report} = $report; @@ -101,7 +87,7 @@ sub prepare_report { ); $report->set_columns(%column_defs); $report->set_column_order(@columns); - $report->set_export_options(qw(list filter)); + $report->set_export_options(qw(list filter vc)); $report->set_options_from_form; $self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i; $self->models->finalize; # for filter laundering @@ -114,6 +100,7 @@ sub prepare_report { sub make_filter_summary { my ($self) = @_; + my $vc = $self->vc; my $filter = $::form->{filter} || {}; my @filter_strings; @@ -147,6 +134,8 @@ sub make_filter_summary { } sub delivery_plan_query { + my ($self) = @_; + my $vc = $self->vc; my $employee_id = SL::DB::Manager::Employee->current->id; my $oe_owner = $_[0]->all_edit_right ? '' : " oe.employee_id = $employee_id AND"; # check delivered state for delivery_orders (transferred out) if enabled @@ -254,6 +243,7 @@ sub delivery_plan_query { sub init_models { my ($self) = @_; + my $vc = $self->vc; SL::Controller::Helper::GetModels->new( controller => $self, @@ -273,6 +263,9 @@ sub init_models { sub init_all_edit_right { $::auth->assert('sales_all_edit', 1) } +sub init_vc { + return $::form->{vc} || croak "self (DeliveryPlan) has no vc defined"; +} sub link_to { my ($self, $object, %params) = @_; diff --git a/SL/DB/OrderItem.pm b/SL/DB/OrderItem.pm index 8e15d31b9..058d04bfe 100644 --- a/SL/DB/OrderItem.pm +++ b/SL/DB/OrderItem.pm @@ -38,11 +38,8 @@ sub delivered_qty { my ($self) = @_; my $d_orders = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder'); - my @d_orders_delivered; - foreach (@$d_orders) { - push (@d_orders_delivered, $_) if $_->delivered; - } + my @d_orders_delivered = grep { $_->delivered } @$d_orders; my @doi_delivered = grep { $_->parts_id == $self->parts_id } map { $_->orderitems } @d_orders_delivered; @@ -53,7 +50,7 @@ sub delivered_qty { sub value_of_goods { my ($self) = @_; - my $price_factor = $self->price_factor ? $self->price_factor : 1; + my $price_factor = $self->price_factor || 1; return ($self->qty * $self->sellprice * (1 - $self->discount ) / $price_factor); } diff --git a/menus/erp.ini b/menus/erp.ini index a324a3152..0dab6fb16 100644 --- a/menus/erp.ini +++ b/menus/erp.ini @@ -192,6 +192,7 @@ action=search ACCESS=delivery_plan module=controller.pl action=DeliveryPlan/list +vc=customer [AR--Reports--Financial Controlling] ACCESS=sales_order_edit @@ -259,7 +260,8 @@ nextsub=ap_transactions [AP--Reports--Delivery Plan] ACCESS=delivery_plan module=controller.pl -action=DeliveryPlan/list_ap +action=DeliveryPlan/list +vc=vendor [Warehouse] diff --git a/templates/webpages/delivery_plan/_filter.html b/templates/webpages/delivery_plan/_filter.html index 46fe2d23a..602c8650c 100644 --- a/templates/webpages/delivery_plan/_filter.html +++ b/templates/webpages/delivery_plan/_filter.html @@ -36,7 +36,7 @@ [% IF vc == 'customer' %] - [% vc | $T8 %] + [% Customer | $T8 %] [% L.input_tag('filter.order.customer.name:substr::ilike', filter.order.customer.name_substr__ilike, size = 20) %] @@ -44,7 +44,7 @@ [% L.input_tag('filter.order.customer.customernumber:substr::ilike', filter.order.customer.customernumber_substr__ilike, size = 20) %] [% ELSE %] - [% vc | $T8 %] + [% Vendor | $T8 %] [% L.input_tag('filter.order.vendor.name:substr::ilike', filter.order.vendor.name_substr__ilike, size = 20) %] @@ -66,11 +66,8 @@ [% L.hidden_tag('sort_by', FORM.sort_by) %] [% L.hidden_tag('sort_dir', FORM.sort_dir) %] [% L.hidden_tag('page', FORM.page) %] -[% IF vc == 'customer' %] +[% L.hidden_tag('vc', vc) %] [% L.input_tag('action_list', LxERP.t8('Continue'), type = 'submit', class='submit')%] -[% ELSE %] - [% L.input_tag('action_list_ap', LxERP.t8('Continue'), type = 'submit', class='submit')%] -[% END %] [% 'Reset' | $T8 %] -- 2.20.1