From 2acbe8c6c3c8a988e712deb438adf0dc40c3daaf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Tue, 25 Nov 2014 12:51:57 +0100 Subject: [PATCH] =?utf8?q?Neuer=20Bericht:=20Lieferwertbericht=20Erweiteru?= =?utf8?q?ng=20DeliveryPlan.pm=20um=20Modusweiche=20Lieferplan=20oder=20Li?= =?utf8?q?eferwertbericht=20Implementierungstand=20Lieferwertbericht:=20?= =?utf8?q?=20-=20Alle=20offenen=20Verkaufsauftr=C3=A4ge=20werden=20ber?= =?utf8?q?=C3=BCcksichtigt=20=20-=20Beim=20CSV-Export=20wird=20die=20Einhe?= =?utf8?q?it=20als=20Extra-Spalte=20exportiert=20und=20die=20=20=20=20Einh?= =?utf8?q?eiten=20bei=20allen=20anderen=20Spalten=20ausgeblendet=20Ferner?= =?utf8?q?=20neues=20Recht=20Lieferwertbericht=20umgesetzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Auth.pm | 1 + SL/Controller/DeliveryPlan.pm | 51 +++++++++++++------ menus/erp.ini | 17 +++++++ .../delivery_process_value.pl | 26 ++++++++++ templates/webpages/delivery_plan/_filter.html | 1 + 5 files changed, 81 insertions(+), 15 deletions(-) create mode 100644 sql/Pg-upgrade2-auth/delivery_process_value.pl diff --git a/SL/Auth.pm b/SL/Auth.pm index 7fb260d54..f0f58d8d8 100644 --- a/SL/Auth.pm +++ b/SL/Auth.pm @@ -1069,6 +1069,7 @@ sub all_rights_full { ["edit_prices", $locale->text("Edit prices and discount (if not used, textfield is ONLY set readonly)")], ["show_ar_transactions", $locale->text("Show AR transactions as part of AR invoice report")], ["delivery_plan", $locale->text("Show delivery plan")], + ["delivery_value_report", $locale->text("Show delivery value report")], ["--ap", $locale->text("AP")], ["request_quotation_edit", $locale->text("Create and edit RFQs")], ["purchase_order_edit", $locale->text("Create and edit purchase orders")], diff --git a/SL/Controller/DeliveryPlan.pm b/SL/Controller/DeliveryPlan.pm index 5d83c5b7e..c68cc4c32 100644 --- a/SL/Controller/DeliveryPlan.pm +++ b/SL/Controller/DeliveryPlan.pm @@ -12,7 +12,7 @@ use Carp; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(db_args flat_filter) ], - 'scalar --get_set_init' => [ qw(models all_edit_right vc) ], + 'scalar --get_set_init' => [ qw(models all_edit_right mode vc) ], ); __PACKAGE__->run_before(sub { $::auth->assert('delivery_plan'); }); @@ -22,6 +22,7 @@ my %sort_columns = ( description => t8('Description'), partnumber => t8('Part Number'), qty => t8('Qty'), + unit => t8('Unit'), shipped_qty => t8('shipped'), delivered_qty => t8('transferred in / out'), not_shipped_qty => t8('not shipped'), @@ -48,12 +49,15 @@ sub prepare_report { my ($self) = @_; my $vc = $self->vc; + my $mode = $self->mode; my $report = SL::ReportGenerator->new(\%::myconfig, $::form); + my $csv_option = $::form->{report_generator_output_format}; $self->{report} = $report; my @columns = qw(reqdate customer vendor ordnumber partnumber description qty shipped_qty not_shipped_qty delivered_qty value_of_goods); my @sortable = qw(reqdate customer vendor ordnumber partnumber description); + my $rp_csv_mod = ($csv_option eq 'CSV' && $mode eq 'delivery_value_report') ? 1 : ''; my %column_defs = ( reqdate => { sub => sub { $_[0]->reqdate_as_date || $_[0]->order->reqdate_as_date } }, @@ -61,10 +65,16 @@ sub prepare_report { obj_link => sub { $self->link_to($_[0]->part) } }, partnumber => { sub => sub { $_[0]->part->partnumber }, obj_link => sub { $self->link_to($_[0]->part) } }, - qty => { sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit } }, - shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } }, - not_shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty - $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } }, - delivered_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->delivered_qty, 2) . ' ' . $_[0]->unit } }, + qty => { sub => sub { $_[0]->qty_as_number . + ($rp_csv_mod ? '' : ' ' . $_[0]->unit) } }, + unit => { sub => sub { $_[0]->unit }, + visible => $rp_csv_mod }, + shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty, 2) . + ($rp_csv_mod ? '' : ' ' . $_[0]->unit) } }, + not_shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty - $_[0]->shipped_qty, 2) . + ($rp_csv_mod ? '' : ' ' . $_[0]->unit) } }, + delivered_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->delivered_qty, 2) . + ($rp_csv_mod ? '' : ' ' . $_[0]->unit) } }, ordnumber => { sub => sub { $_[0]->order->ordnumber }, obj_link => sub { $self->link_to($_[0]->order) } }, vendor => { sub => sub { $_[0]->order->vendor->name }, @@ -74,7 +84,7 @@ sub prepare_report { visible => $vc eq 'customer', obj_link => sub { $self->link_to($_[0]->order->customer) } }, value_of_goods => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->value_of_goods, 2) . ' ' . $_[0]->taxincluded }, - visible => $::auth->assert('sales_order_edit', 1) && $::instance_conf->get_delivery_plan_show_value_of_goods, }, + visible => $::auth->assert('sales_order_edit', 1) && $mode eq 'delivery_value_report' && $::instance_conf->get_delivery_plan_show_value_of_goods, }, ); $column_defs{$_}->{text} = $sort_columns{$_} for keys %column_defs; @@ -83,21 +93,23 @@ sub prepare_report { std_column_visibility => 1, controller_class => 'DeliveryPlan', output_format => 'HTML', - top_info_text => ($vc eq 'customer') ? $::locale->text('Delivery Plan for currently outstanding sales orders') : + top_info_text => ($vc eq 'customer') ? (($mode eq 'delivery_plan') ? $::locale->text('Delivery Plan for currently outstanding sales orders') : + $::locale->text('Delivery Value Report for currently open sales orders')) : + ($mode eq 'delivery_value_report') ? $::locale->text('Delivery Value Report for currently outstanding purchase orders') : $::locale->text('Delivery Plan for currently outstanding purchase orders'), - title => $::locale->text('Delivery Plan'), + title => ($mode eq 'delivery_plan') ? $::locale->text('Delivery Plan') : $::locale->text('Delivery Value Report'), allow_pdf_export => 1, allow_csv_export => 1, ); $report->set_columns(%column_defs); $report->set_column_order(@columns); - $report->set_export_options(qw(list filter vc)); + $report->set_export_options(qw(list filter vc mode)); $report->set_options_from_form; $self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i; $self->models->finalize; # for filter laundering $self->models->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable); $report->set_options( - raw_top_info_text => $self->render('delivery_plan/report_top', { output => 0 }, vc => $vc), + raw_top_info_text => $self->render('delivery_plan/report_top', { output => 0 }), raw_bottom_info_text => $self->render('delivery_plan/report_bottom', { output => 0 }, models => $self->models), ); } @@ -105,6 +117,7 @@ sub prepare_report { sub make_filter_summary { my ($self) = @_; my $vc = $self->vc; + my $mode = $self->mode; my $filter = $::form->{filter} || {}; my @filter_strings; @@ -142,11 +155,16 @@ sub make_filter_summary { sub delivery_plan_query { my ($self) = @_; my $vc = $self->vc; + my $mode = $self->mode; 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 - my $filter_delivered = $::instance_conf->get_delivery_plan_calculate_transferred_do ? - "AND (SELECT delivered from delivery_orders where id = doi.delivery_order_id)" : ''; + # OR if we are delivery_value_report mode + my $filter_delivered = ($::instance_conf->get_delivery_plan_calculate_transferred_do || + $mode eq 'delivery_value_report' ) ? + "AND (SELECT delivered from delivery_orders where id = doi.delivery_order_id)" : ''; + # Show ALL open orders in delivery_value_report mode + my $comment_show_all_open_orders = ($mode eq 'delivery_value_report' ) ? "-- " : ""; [ "order.${vc}_id" => { gt => 0 }, 'order.closed' => 0, @@ -239,7 +257,7 @@ sub delivery_plan_query { FROM record_links rl WHERE oi.trans_id = rl.from_id AND rl.from_table = 'oe' AND rl.to_table = 'delivery_orders' ) AND - coalesce(sum, 0) < oi.qty AND + $comment_show_all_open_orders coalesce(sum, 0) < oi.qty AND oe.${vc}_id IS NOT NULL AND $oe_owner (oe.quotation = 'f' OR oe.quotation IS NULL) AND NOT oe.closed @@ -250,7 +268,7 @@ sub delivery_plan_query { sub init_models { my ($self) = @_; my $vc = $self->vc; - + my $mode = $self->mode; SL::Controller::Helper::GetModels->new( controller => $self, model => 'OrderItem', @@ -263,7 +281,7 @@ sub init_models { }, query => $self->delivery_plan_query, with_objects => [ 'order', "order.$vc", 'part' ], - additional_url_params => { vc => $vc }, + additional_url_params => { vc => $vc, mode => $mode}, ); } @@ -273,6 +291,9 @@ sub init_all_edit_right { sub init_vc { return $::form->{vc} if ($::form->{vc} eq 'customer' || $::form->{vc} eq 'vendor') || croak "self (DeliveryPlan) has no vc defined"; } +sub init_mode { + return $::form->{mode} if ($::form->{mode} eq 'delivery_value_report' || $::form->{mode} eq 'delivery_plan') || croak "self (DeliveryPlan) has no mode defined"; +} sub link_to { my ($self, $object, %params) = @_; diff --git a/menus/erp.ini b/menus/erp.ini index 0dab6fb16..3d782ac9b 100644 --- a/menus/erp.ini +++ b/menus/erp.ini @@ -193,6 +193,15 @@ ACCESS=delivery_plan module=controller.pl action=DeliveryPlan/list vc=customer +mode=delivery_plan + +[AR--Reports--Delivery Value Report] +ACCESS=delivery_value_report +module=controller.pl +action=DeliveryPlan/list +vc=customer +mode=delivery_value_report + [AR--Reports--Financial Controlling] ACCESS=sales_order_edit @@ -262,6 +271,14 @@ ACCESS=delivery_plan module=controller.pl action=DeliveryPlan/list vc=vendor +mode=delivery_plan + +[AP--Reports--Delivery Value Report] +ACCESS=delivery_value_report +module=controller.pl +action=DeliveryPlan/list +vc=vendor +mode=delivery_value_report [Warehouse] diff --git a/sql/Pg-upgrade2-auth/delivery_process_value.pl b/sql/Pg-upgrade2-auth/delivery_process_value.pl new file mode 100644 index 000000000..5adf9c2b0 --- /dev/null +++ b/sql/Pg-upgrade2-auth/delivery_process_value.pl @@ -0,0 +1,26 @@ +# @tag: delivery_process_value +# @description: Setzt das neue Recht den Lieferstatus mit Warenwert zu sehen +# @depends: release_3_0_0 +package SL::DBUpgrade2::delivery_process_value; + +use strict; +use utf8; + +use parent qw(SL::DBUpgrade2::Base); + +use SL::DBUtils; + +sub run { + my ($self) = @_; + + my $groups = $main::auth->read_groups(); + + foreach my $group (values %{$groups}) { + $group->{rights}->{delivery_value_report} = $group->{rights}->{sales_order_edit}; + $main::auth->save_group($group); + } + + return 1; +} # end run + +1; diff --git a/templates/webpages/delivery_plan/_filter.html b/templates/webpages/delivery_plan/_filter.html index 402da6341..fef7c31dc 100644 --- a/templates/webpages/delivery_plan/_filter.html +++ b/templates/webpages/delivery_plan/_filter.html @@ -67,6 +67,7 @@ [% L.hidden_tag('sort_dir', FORM.sort_dir) %] [% L.hidden_tag('page', FORM.page) %] [% L.hidden_tag('vc', SELF.vc) %] +[% L.hidden_tag('mode', SELF.mode) %] [% L.input_tag('action_list', LxERP.t8('Continue'), type = 'submit', class='submit')%] -- 2.20.1