X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/766f5705ecb9cd56adfbffd94c871959bb64c6fd..ac01c25abcbe7d2ede91723ac91d519bd170fd1f:/SL/Controller/FinancialOverview.pm diff --git a/SL/Controller/FinancialOverview.pm b/SL/Controller/FinancialOverview.pm index 49c04698c..cd153d23f 100644 --- a/SL/Controller/FinancialOverview.pm +++ b/SL/Controller/FinancialOverview.pm @@ -61,7 +61,7 @@ sub prepare_report { std_column_visibility => 1, controller_class => 'FinancialOverview', output_format => 'HTML', - raw_top_info_text => $self->render('financial_overview/report_top', { output => 0 }, YEARS_TO_LIST => [ reverse(2000..$self->current_year) ]), + 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, @@ -91,7 +91,7 @@ sub get_objects { 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 ]), + 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} } ]; @@ -145,13 +145,11 @@ sub calculate_periodic_invoices { sub calculate_one_periodic_invoice { my ($self, %params) = @_; - my @dates = $params{config}->calculate_invoice_dates(start_date => $params{start_date}, end_date => $params{end_date}, past_dates => 1); - my $first_date = $dates[0]; + return if $params{config}->start_date > $params{end_date}; - return if !$first_date; - - my $net = $params{config}->order->netamount * scalar(@dates); - my $sord = $self->data->{sales_orders}; + my $first_date = $params{config}->start_date->clone->set_year($self->year); + my $net = $params{config}->order->netamount * (12 / $params{config}->get_period_length); + my $sord = $self->data->{sales_orders}; $sord->{months }->[ $first_date->month - 1 ] += $net; $sord->{quarters}->[ $first_date->quarter - 1 ] += $net;