sub total_outstanding {
my ( $self ) = @_;
- my $total = sum0( $self->get_column('amountoutstanding') );
-
- return $total;
+ my $lines = $self->search(
+ {},
+ {
+ select => [ { sum => 'amountoutstanding' } ],
+ as => ['total_amountoutstanding'],
+ }
+ );
+
+ return $lines->count
+ ? $lines->next->get_column('total_amountoutstanding') + 0
+ : 0;
}
=head2 Internal methods