Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision bdb4582b

Von Moritz Bunkus vor fast 10 Jahren hinzugefügt

  • ID bdb4582b57fcb6b7a8a1a966f3241cce48163f46
  • Vorgänger 9f1c7dc2
  • Nachfolger 1f024d69

Finanzcontrolling: Aufträge mit wiedRech für jedes angefangene Jahr berechnen

Unterschiede anzeigen:

SL/Controller/FinancialControllingReport.pm
3 3
use strict;
4 4
use parent qw(SL::Controller::Base);
5 5

  
6
use List::Util qw(sum);
6
use List::Util qw(min sum);
7 7

  
8 8
use SL::DB::Order;
9 9
use SL::DB::ProjectType;
......
121 121
    $order->{billable_amount}   = $order->{delivered_amount} - $order->{billed_amount};
122 122

  
123 123
    if ($order->periodic_invoices_config) {
124
      my @dates = $order->periodic_invoices_config->calculate_invoice_dates(past_dates => 1, end_date => DateTime->today_local);
125
      $order->{net_amount} = $order->netamount * (12 / $order->periodic_invoices_config->get_period_length);
124
      $order->{net_amount} = $self->calculate_periodic_invoices_order_netamount($order);
126 125

  
127 126
    } else {
128 127
      $order->{net_amount} = $order->netamount;
......
134 133
  }
135 134
}
136 135

  
136
sub calculate_periodic_invoices_order_netamount {
137
  my ($self, $order) = @_;
138

  
139
  my $cfg        = $order->periodic_invoices_config;
140
  my $num_years  = 0;
141
  my $cur_date   = $cfg->start_date->clone;
142
  my $end_date   = $cfg->terminated ? $self->end_date : undef;
143
  $end_date    //= DateTime->today_local;
144
  $end_date      = min($end_date, DateTime->today_local);
145

  
146
  while ($cur_date <= $end_date) {
147
    $num_years++;
148
    $cur_date->add(years => 1);
149
  }
150

  
151
  return $num_years * $order->netamount * (12 / $order->periodic_invoices_config->get_period_length);
152
}
153

  
137 154
sub sum_items {
138 155
  my ($self, %params) = @_;
139 156

  

Auch abrufbar als: Unified diff