Bug 21673: Use Koha::Account::Lines->total_amountoutstanding when needed
[koha.git] / Koha / Account / Lines.pm
index fde90cd..66a91c9 100644 (file)
@@ -46,9 +46,17 @@ empty it returns 0.
 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