X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FMebil.pm;h=b8d02a46c67909857be333e987ad6483cd450415;hb=47db6ae13df64092d401896ec476b9335e9ec807;hp=f16f6cb10a4855ed00f495321d212790656675a2;hpb=e529f18ea59b9e078dbd8be695328f220ffb7cc1;p=kivitendo-erp.git diff --git a/SL/Controller/Mebil.pm b/SL/Controller/Mebil.pm index f16f6cb10..b8d02a46c 100644 --- a/SL/Controller/Mebil.pm +++ b/SL/Controller/Mebil.pm @@ -4,12 +4,17 @@ use strict; use parent qw(SL::Controller::Base); -use SL::Controller::Helper::ReportGenerator; +#use SL::Controller::Helper::ReportGenerator; +use SL::ReportGenerator; use SL::DBUtils; +use SL::Locale::String; # t8 + #use Data::Dumper; #use SL::ClientJS; +use SL::mebil::Mapping; + use Rose::Object::MakeMethods::Generic ( scalar => [ qw(report number_columns year current_year objects subtotals_per_quarter salesman_id) ], 'scalar --get_set_init' => [ qw(employees types data) ], @@ -47,54 +52,99 @@ sub action_map { sub action_showmap { $::lxdebug->enter_sub; my ($self) = @_; + + # call model -> diese Zeile ist fraglich, war ein Konflikt + #$self->{data} = DB::MebilMapping::getMappings($::form->get_standard_dbh); + + $::form->{title} = $::locale->text('Mebil Map'); - my $sql = "SELECT chart_id,xbrl_tag from mebil_mapping"; - $self->{data} = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql); + my $mapping = new SL::mebil::Mapping($::form, $::form->get_standard_dbh); + $self->{data} = $mapping->get_mapping(); -# $self->get_objects; -# $self->calculate_one_time_data; -# $self->calculate_periodic_invoices; $self->prepare_report; $self->list_data; -=cut - $::form->header(no_layout => 1); - - print "

Mebil-Mapping

"; - print "

Folgende Zuordnungen sind in der DB hinterlegt:"; + $::lxdebug->leave_sub; +} + +sub action_calcmap { + $::lxdebug->enter_sub; + my ($self) = @_; - print "\n"; - foreach my $mapping (@{ $self->{data} }) { - print "\n"; - } - print "
KontoZiel
",$mapping->{chart_id},"",$mapping->{xbrl_tag},"
\n"; -=cut + $self->year($::form->{year} || DateTime->today->year - 1); + + $::form->{title} = $::locale->text('Mebil Map'); + + my $mapping = new SL::mebil::Mapping($::form, $::form->get_standard_dbh); + + (my $fromacc, my $toacc) = $mapping->calc_mapping($self->{year}); + + $self->report(SL::ReportGenerator->new(\%::myconfig, $::form)); + + my @columns = (qw(name amount)); + + my %column_defs = ( + name => { text => 'Konto', align => 'left' }, + amount => { text => 'Betrag' , align => 'right' }, + ); + + $self->report->set_options( + std_column_visibility => 1, + controller_class => 'Mebil', + output_format => 'HTML', + raw_top_info_text => $self->render('mebil/report_top', { output => 0 }, YEARS_TO_LIST => [ reverse(($self->year - 10)..($self->year + 5)) ]), + title => t8('mebil - Mapping: values for #1', $self->year), +# allow_pdf_export => 1, +# allow_csv_export => 1, + ); + $self->report->set_columns(%column_defs); + $self->report->set_column_order(@columns); +# $self->report->set_export_options(qw(list year subtotals_per_quarter salesman_id)); + $self->report->set_options_from_form; + $self->add_data_sorted($fromacc); + $self->add_data_sorted($toacc); + $::lxdebug->leave_sub; + return $self->report->generate_with_headers; +} +sub add_data_sorted { + my $self = shift; + my $data = shift; # hash reference + + foreach my $key (sort keys %$data) { + my %data = ( + name => { data => $key }, + amount => { data => $::form->format_amount(\%::myconfig, $data->{$key}, 2) }, + ); + $self->report->add_data(\%data); + + } } sub prepare_report { my ($self) = @_; $self->report(SL::ReportGenerator->new(\%::myconfig, $::form)); - my @columns = (qw(chart_id xbrl_tag)); + my @columns = (qw(fromacc typ toacc)); #$self->number_columns([ grep { !m/^(?:month|year|quarter)$/ } @columns ]); my %column_defs = ( - chart_id => { text => 'Kontonummer' }, - xbrl_tag => { text => 'XBRL' }, + fromacc => { text => 'Quelle', align => 'left' }, + typ => { text => 'Typ' , align => 'right' }, + toacc => { text => 'Ziel' , align => 'left' }, ); - $column_defs{$_}->{align} = 'right' for @columns; + #$column_defs{$_}->{align} = 'right' for @columns; $self->report->set_options( std_column_visibility => 1, controller_class => 'Mebil', output_format => 'HTML', # raw_top_info_text => $self->render('financial_overview/report_top', { output => 0 }, YEARS_TO_LIST => [ reverse(($self->current_year - 10)..($self->current_year + 5)) ]), - # title => t8('Financial overview for #1', $self->year), - # allow_pdf_export => 1, - # allow_csv_export => 1, + title => 'mebil - Mapping', +# allow_pdf_export => 1, +# allow_csv_export => 1, ); $self->report->set_columns(%column_defs); $self->report->set_column_order(@columns); @@ -110,8 +160,9 @@ sub list_data { foreach my $mapping (@{ $self->{data} }) { my %data = ( - chart_id => { data => $mapping->{chart_id}}, - xbrl_tag => { data => $mapping->{xbrl_tag}}, + fromacc => { data => $mapping->{fromacc} }, + typ => { data => $mapping->{typ} }, + toacc => { data => $mapping->{toacc} }, ); $self->report->add_data(\%data); } @@ -119,23 +170,4 @@ sub list_data { return $self->report->generate_with_headers; } - -=cut -sub get_objects { - my ($self) = @_; - $self->objects({ - sales_quotations => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('sales_quotation') ]]), - sales_orders => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('sales_order') ]], with_objects => [ qw(periodic_invoices_config) ]), - sales_orders_per_inv => [], - requests_for_quotation => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('request_quotation') ]]), - purchase_orders => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('purchase_order') ]]), - sales_invoices => SL::DB::Manager::Invoice->get_all( where => [ and => [ @f_date, @f_salesman, ]]), - purchase_invoices => SL::DB::Manager::PurchaseInvoice->get_all(where => [ and => \@f_date ]), - periodic_invoices_cfg => SL::DB::Manager::PeriodicInvoicesConfig->get_all(where => [ active => 1, $self->salesman_id ? ('order.salesman_id' => $self->salesman_id) : () ], with_objects => [ qw(order) ]), - }); - - $self->objects->{sales_orders} = [ grep { !$_->periodic_invoices_config || !$_->periodic_invoices_config->active } @{ $self->objects->{sales_orders} } ]; -} -=cut - 1;