Revision b2becee7
Von Moritz Bunkus vor fast 10 Jahren hinzugefügt
SL/Controller/FinancialControllingReport.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
use parent qw(SL::Controller::Base); |
5 | 5 |
|
6 |
use List::Util qw(min sum); |
|
6 |
use List::Util qw(max min sum);
|
|
7 | 7 |
|
8 | 8 |
use SL::DB::Order; |
9 | 9 |
use SL::DB::ProjectType; |
... | ... | |
136 | 136 |
sub calculate_periodic_invoices_order_netamount { |
137 | 137 |
my ($self, $order) = @_; |
138 | 138 |
|
139 |
my $year = DateTime->today_local->year; |
|
140 |
my $year_start = DateTime->new_local(day => 1, month => 1, year => $year); |
|
141 |
my $year_end = DateTime->new_local(day => 31, month => 12, year => $year); |
|
142 |
|
|
139 | 143 |
my $cfg = $order->periodic_invoices_config; |
140 |
my $num_years = 0; |
|
144 |
my $period_len = $cfg->get_billing_period_length; |
|
145 |
my $num_months = 0; |
|
141 | 146 |
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);
|
|
147 |
my $end_date = $cfg->terminated ? $cfg->end_date : undef;
|
|
148 |
$end_date //= $year_end;
|
|
149 |
$end_date = min $end_date, $year_end;
|
|
145 | 150 |
|
146 | 151 |
while ($cur_date <= $end_date) { |
147 |
$num_years++;
|
|
148 |
$cur_date->add(years => 1);
|
|
152 |
$num_months += $period_len if $cur_date >= $year_start;
|
|
153 |
$cur_date->add(months => $period_len);
|
|
149 | 154 |
} |
150 | 155 |
|
151 |
return $num_years * $order->netamount * (12 / $order->periodic_invoices_config->get_billing_period_length);
|
|
156 |
return $num_months * $order->netamount / $order->periodic_invoices_config->get_order_value_period_length;
|
|
152 | 157 |
} |
153 | 158 |
|
154 | 159 |
sub sum_items { |
Auch abrufbar als: Unified diff
Finanzcontrolling: Auftragswertperiodizität berücksichtigen