$order->{delivered_amount} = sum map { $self->sum_relevant_items(order => $order, other => $_, by_order => 1) } @delivery_orders;
$order->{billed_amount} = sum map { $self->sum_relevant_items(order => $order, other => $_) } @invoices;
- $order->{paid_amount} = sum map { $_->paid } @invoices;
+ $order->{paid_amount} = sum map { $_->paid * $_->netamount / (($_->amount * 1) || ($_->netamount * 1) || 1) } @invoices;
my $billed_amount = sum map { $_->netamount } @invoices;
$order->{other_amount} = $billed_amount - $order->{billed_amount};
$order->{billable_amount} = $order->{delivered_amount} - $order->{billed_amount};