Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7f82c68c

Von Moritz Bunkus vor etwa 11 Jahren hinzugefügt

  • ID 7f82c68cb99dc3aa01c7fee0d674607d22e17beb
  • Vorgänger bfb68a07
  • Nachfolger 7a452195

Finanzcontrollingbericht: Stornorechnungen berücksichtigen

Unterschiede anzeigen:

SL/Controller/FinancialControllingReport.pm
138 138
  my ($self) = @_;
139 139

  
140 140
  foreach my $order (@{ $self->{orders} }) {
141
    my $delivery_orders = $order->linked_records(direction => 'to', to => 'DeliveryOrder', via => 'Order', query => [ '!customer_id' => undef ]);
142
    my $invoices        = $order->linked_records(direction => 'to', to => 'Invoice',       via => [ 'Order', 'DeliveryOrder' ]);
143

  
144
    $order->{delivered_amount}  = sum map { $self->sum_relevant_items(order => $order, other => $_, by_order => 1) } @{ $delivery_orders };
145
    $order->{billed_amount}     = sum map { $self->sum_relevant_items(order => $order, other => $_)                } @{ $invoices        };
146
    $order->{paid_amount}       = sum map { $_->paid                                                               } @{ $invoices        };
147
    my $billed_amount           = sum map { $_->netamount                                                          } @{ $invoices        };
141
    my @delivery_orders = @{ $order->linked_records(direction => 'to', to => 'DeliveryOrder', via => 'Order', query => [ '!customer_id' => undef ]) };
142
    my @invoices        = @{ $order->linked_records(direction => 'to', to => 'Invoice',       via => [ 'Order', 'DeliveryOrder' ])                  };
143

  
144
    @invoices = (
145
      grep({ !$_->storno_id } @invoices),
146
      map({ @{ $_->storno_invoices } } grep { $_->storno && !$_->storno_id } @invoices),
147
    );
148

  
149
    $order->{delivered_amount}  = sum map { $self->sum_relevant_items(order => $order, other => $_, by_order => 1) } @delivery_orders;
150
    $order->{billed_amount}     = sum map { $self->sum_relevant_items(order => $order, other => $_)                } @invoices;
151
    $order->{paid_amount}       = sum map { $_->paid                                                               } @invoices;
152
    my $billed_amount           = sum map { $_->netamount                                                          } @invoices;
148 153
    $order->{other_amount}      = $billed_amount             - $order->{billed_amount};
149 154
    $order->{billable_amount}   = $order->{delivered_amount} - $order->{billed_amount};
150 155

  

Auch abrufbar als: Unified diff