Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 24597232

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 2459723286f701a341062b054a215a266df74e01
  • Vorgänger 1734e1ad
  • Nachfolger 8a5aa339

Finanzcontrollingbericht: wiederkehrende Rechnungen berücksichtigen

Unterschiede anzeigen:

SL/Controller/FinancialControllingReport.pm
24 24
  transaction_description => t8('Transaction description'),
25 25
  globalprojectnumber     => t8('Project'),
26 26
  globalproject_type      => t8('Project Type'),
27
  netamount               => t8('Order amount'),
28 27
);
29 28

  
30 29
sub action_list {
......
51 50
  my $report      = SL::ReportGenerator->new(\%::myconfig, $::form);
52 51
  $self->{report} = $report;
53 52

  
54
  my @columns     = qw(customer globalprojectnumber globalproject_type ordnumber netamount delivered_amount delivered_amount_p billed_amount billed_amount_p paid_amount paid_amount_p
53
  my @columns     = qw(customer globalprojectnumber globalproject_type ordnumber net_amount delivered_amount delivered_amount_p billed_amount billed_amount_p paid_amount paid_amount_p
55 54
                       billable_amount billable_amount_p other_amount);
56
  my @sortable    = qw(ordnumber transdate customer netamount globalprojectnumber globalproject_type);
57
  $self->{number_columns} = [ qw(netamount billed_amount billed_amount_p delivered_amount delivered_amount_p paid_amount paid_amount_p other_amount billable_amount billable_amount_p) ];
55
  my @sortable    = qw(ordnumber transdate customer globalprojectnumber globalproject_type);
56
  $self->{number_columns} = [ qw(net_amount billed_amount billed_amount_p delivered_amount delivered_amount_p paid_amount paid_amount_p other_amount billable_amount billable_amount_p) ];
58 57

  
59 58
  my %column_defs           = (
60
    netamount               => {                                                                                         },
59
    net_amount              => { text     => $::locale->text('Order amount')                                             },
61 60
    billed_amount           => { text     => $::locale->text('Billed amount')                                            },
62 61
    billed_amount_p         => { text     => $::locale->text('%')                                                        },
63 62
    delivered_amount        => { text     => $::locale->text('Delivered amount')                                         },
......
120 119
    $order->{other_amount}      = $billed_amount             - $order->{billed_amount};
121 120
    $order->{billable_amount}   = $order->{delivered_amount} - $order->{billed_amount};
122 121

  
122
    if ($order->periodic_invoices_config) {
123
      my @dates = $order->periodic_invoices_config->calculate_invoice_dates(past_dates => 1, end_date => $order->periodic_invoices_config->end_date || DateTime->today_local);
124
      $order->{net_amount} = $order->netamount * scalar(@dates);
125

  
126
    } else {
127
      $order->{net_amount} = $order->netamount;
128
    }
129

  
123 130
    foreach (qw(delivered billed paid billable)) {
124
      $order->{"${_}_amount_p"} = $order->netamount * 1 ? $order->{"${_}_amount"} * 100 / $order->netamount : undef;
131
      $order->{"${_}_amount_p"} = $order->{net_amount} * 1 ? $order->{"${_}_amount"} * 100 / $order->{net_amount} : undef;
125 132
    }
126 133
  }
127 134
}
......
219 226
          'globalproject.active' => 1,
220 227
          'globalproject.valid'  => 1,
221 228
        ]],
229
      # keine WR
230
      # oder aber (WR aktiv und (kein enddatum oder enddatum noch nicht überschritten))
231
      or => [
232
        'periodic_invoices_config.id' => undef,
233
        # and => [
234
          'periodic_invoices_config.active' => 1,
235
        #   or => [
236
        #     'periodic_invoices_config.end_date' => undef,
237
        #     'periodic_invoices_config.end_date' => { le => DateTime->today_local },
238
        # ]
239
        # ]
240
      ],
222 241
    ],
223 242
    with_objects => [ 'customer', 'globalproject', 'globalproject.project_type' ],
224 243
  );
SL/DB/PeriodicInvoicesConfig.pm
79 79
sub calculate_invoice_dates {
80 80
  my ($self, %params) = @_;
81 81

  
82
  my $period_len = $self->get_period_length;
82 83
  my $cur_date   = $self->first_billing_date        || $self->start_date;
83
  my $start_date = $self->get_previous_invoice_date || DateTime->new(year => 1970, month => 1, day => 1);
84 84
  my $end_date   = $self->end_date                  || DateTime->today_local->add(years => 10);
85
  my $period_len = $self->get_period_length;
85
  my $start_date = $params{past_dates} ? undef : $self->get_previous_invoice_date;
86
  $start_date  ||= $cur_date->clone->subtract(days => 1);
86 87

  
87 88
  $start_date    = max($start_date, $params{start_date}) if $params{start_date};
88 89
  $end_date      = min($end_date,   $params{end_date})   if $params{end_date};
89 90

  
90 91
  my @dates;
91 92

  
92
  while ($cur_date < $end_date) {
93
  while ($cur_date <= $end_date) {
93 94
    push @dates, $cur_date->clone if $cur_date > $start_date;
94 95

  
95 96
    $cur_date->add(months => $period_len);

Auch abrufbar als: Unified diff