From e529f18ea59b9e078dbd8be695328f220ffb7cc1 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Fri, 24 Sep 2021 21:43:03 +0200 Subject: [PATCH] epic-ts --- SL/Controller/Mebil.pm | 116 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 2 deletions(-) diff --git a/SL/Controller/Mebil.pm b/SL/Controller/Mebil.pm index ced266f10..f16f6cb10 100644 --- a/SL/Controller/Mebil.pm +++ b/SL/Controller/Mebil.pm @@ -4,11 +4,17 @@ use strict; use parent qw(SL::Controller::Base); +use SL::Controller::Helper::ReportGenerator; use SL::DBUtils; #use Data::Dumper; #use SL::ClientJS; +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) ], +); + sub action_map { $::lxdebug->enter_sub; $::lxdebug->message(5, 'controller=mebil/action=map'); @@ -18,12 +24,118 @@ sub action_map { print "

Mebil running

"; - my $sql = "SELECT * from mebil_mapping"; + my $sql = "SELECT chart_id,xbrl_tag from mebil_mapping"; my $result = SL::DBUtils::do_query($::form, $::form->get_standard_dbh, $sql); $::lxdebug->message(5, "result= $result"); - print "$result\n"; + print "$result
\n"; + + my @r = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql); + print ref($r[1])||"SCALAR"; + print "
"; + my $fst = $r[1]; + while (my($k,$v) = each(%$fst)) { + print $k, " : ", $v, "
\n"; + } + print "
"; + print scalar @r; + print "
"; + print @r; print "

Mebil ready

"; $::lxdebug->leave_sub; } +sub action_showmap { + $::lxdebug->enter_sub; + my ($self) = @_; + + my $sql = "SELECT chart_id,xbrl_tag from mebil_mapping"; + $self->{data} = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql); + +# $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:"; + + + print "\n"; + foreach my $mapping (@{ $self->{data} }) { + print "\n"; + } + print "
KontoZiel
",$mapping->{chart_id},"",$mapping->{xbrl_tag},"
\n"; +=cut + $::lxdebug->leave_sub; +} +sub prepare_report { + my ($self) = @_; + + $self->report(SL::ReportGenerator->new(\%::myconfig, $::form)); + + my @columns = (qw(chart_id xbrl_tag)); + + #$self->number_columns([ grep { !m/^(?:month|year|quarter)$/ } @columns ]); + + my %column_defs = ( + chart_id => { text => 'Kontonummer' }, + xbrl_tag => { text => 'XBRL' }, + ); + + $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, + ); + $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; +} +sub list_data { + my ($self) = @_; + +# my @visible_columns = $self->report->get_visible_columns; +# my @type_columns = @{ $self->types }; +# my @non_type_columns = grep { my $c = $_; none { $c eq $_ } @type_columns } @visible_columns; + + foreach my $mapping (@{ $self->{data} }) { + my %data = ( + chart_id => { data => $mapping->{chart_id}}, + xbrl_tag => { data => $mapping->{xbrl_tag}}, + ); + $self->report->add_data(\%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; -- 2.20.1