Bug 21909: Make Koha::Account::outstanding_* preserve context
[srvgit] / Koha / Account.pm
index 80e8353..304d0e2 100644 (file)
@@ -428,13 +428,12 @@ my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_debits;
 sub outstanding_debits {
     my ($self) = @_;
 
-    my $lines = $self->lines->search(
+    return $self->lines->search(
         {
+            amount            => { '>' => 0 },
             amountoutstanding => { '>' => 0 }
         }
     );
-
-    return $lines;
 }
 
 =head3 outstanding_credits
@@ -446,13 +445,12 @@ my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_credits
 sub outstanding_credits {
     my ($self) = @_;
 
-    my $lines = $self->lines->search(
+    return $self->lines->search(
         {
+            amount            => { '<' => 0 },
             amountoutstanding => { '<' => 0 }
         }
     );
-
-    return $lines;
 }
 
 =head3 non_issues_charges
@@ -519,7 +517,9 @@ sub lines {
 
 $account->reconcile_balance();
 
-Find outstanding credits and use them to pay outstanding debits
+Find outstanding credits and use them to pay outstanding debits.
+Currently, this implicitly uses the 'First In First Out' rule for
+applying credits against debits.
 
 =cut