Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 61d88e69

Von Moritz Bunkus vor fast 10 Jahren hinzugefügt

  • ID 61d88e69bd686dcc00bc3cb0cbfa37bc808cebeb
  • Vorgänger 4f25607a
  • Nachfolger 9c79e857

Finanzcontrolling: Refactor Accessors, Warnungen vermeiden

Unterschiede anzeigen:

SL/Controller/FinancialControllingReport.pm
12 12
use SL::Locale::String;
13 13

  
14 14
use Rose::Object::MakeMethods::Generic (
15
  scalar => [ qw(project_types) ],
16
  'scalar --get_set_init' => [ qw(models) ],
15
  scalar                  => [ qw(orders) ],
16
  'scalar --get_set_init' => [ qw(project_types models) ],
17 17
);
18 18

  
19 19
__PACKAGE__->run_before(sub { $::auth->assert('sales_order_edit'); });
......
29 29
sub action_list {
30 30
  my ($self) = @_;
31 31

  
32
  $self->project_types(SL::DB::Manager::ProjectType->get_all_sorted);
33

  
34 32
  $self->make_filter_summary;
35 33

  
36 34
  $self->prepare_report;
37 35

  
38
  $self->{orders} = $self->models->get;
36
  $self->orders($self->models->get);
39 37

  
40 38
  $self->calculate_data;
41 39

  
......
104 102
sub calculate_data {
105 103
  my ($self) = @_;
106 104

  
107
  foreach my $order (@{ $self->{orders} }) {
105
  foreach my $order (@{ $self->orders }) {
108 106
    my @delivery_orders = @{ $order->linked_records(direction => 'to', to => 'DeliveryOrder', via => 'Order', query => [ '!customer_id' => undef ]) };
109 107
    my @invoices        = @{ $order->linked_records(direction => 'to', to => 'Invoice',       via => [ 'Order', 'DeliveryOrder' ])                  };
110 108

  
......
113 111
      map({ @{ $_->storno_invoices } } grep { $_->storno && !$_->storno_id } @invoices),
114 112
    );
115 113

  
116
    $order->{delivered_amount}  = sum map { $self->sum_relevant_items(order => $order, other => $_, by_order => 1)    } @delivery_orders;
117
    $order->{billed_amount}     = sum map { $self->sum_relevant_items(order => $order, other => $_)                   } @invoices;
118
    $order->{paid_amount}       = sum map { $_->paid * $_->netamount / (($_->amount * 1) || ($_->netamount * 1) || 1) } @invoices;
119
    my $billed_amount           = sum map { $_->netamount                                                             } @invoices;
114
    $order->{delivered_amount}  = sum(map { $self->sum_relevant_items(order => $order, other => $_, by_order => 1)    } @delivery_orders) // 0;
115
    $order->{billed_amount}     = sum(map { $self->sum_relevant_items(order => $order, other => $_)                   } @invoices)        // 0;
116
    $order->{paid_amount}       = sum(map { $_->paid * $_->netamount / (($_->amount * 1) || ($_->netamount * 1) || 1) } @invoices)        // 0;
117
    my $billed_amount           = sum(map { $_->netamount                                                             } @invoices)        // 0;
120 118
    $order->{other_amount}      = $billed_amount             - $order->{billed_amount};
121 119
    $order->{billable_amount}   = $order->{delivered_amount} - $order->{billed_amount};
122 120

  
......
207 205
    $data->{$_}->{data} = $::form->format_amount(\%::myconfig, $data->{$_}->{data}, 2) for grep { !m/_p$/ } @{ $self->{number_columns} };
208 206
  };
209 207

  
210
  return $self->report_generator_list_objects(report => $self->{report}, objects => $self->{orders}, data_callback => $modify_data);
208
  return $self->report_generator_list_objects(report => $self->{report}, objects => $self->orders, data_callback => $modify_data);
211 209
}
212 210

  
213 211
sub make_filter_summary {
......
227 225
  $self->{filter_summary} = join ', ', @filter_strings;
228 226
}
229 227

  
228
sub init_project_types { SL::DB::Manager::ProjectType->get_all_sorted }
229

  
230 230
sub init_models {
231 231
  my ($self) = @_;
232 232

  

Auch abrufbar als: Unified diff