Bug 20287: generate_userid now set the userid
[koha.git] / Koha / Account.pm
index 99d5a60..036b34e 100644 (file)
@@ -351,7 +351,7 @@ sub add_credit {
                     borrowernumber => $self->{patron_id},
                     accountno      => $accountno,
                 }
-            );
+            ) if grep { $type eq $_ } ('payment', 'writeoff') ;
 
             if ( C4::Context->preference("FinesLog") ) {
                 logaction(
@@ -422,6 +422,25 @@ sub outstanding_debits {
     return $lines;
 }
 
+=head3 outstanding_credits
+
+my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_credits;
+
+=cut
+
+sub outstanding_credits {
+    my ($self) = @_;
+
+    my $lines = Koha::Account::Lines->search(
+        {
+            borrowernumber    => $self->{patron_id},
+            amountoutstanding => { '<' => 0 }
+        }
+    );
+
+    return $lines;
+}
+
 =head3 non_issues_charges
 
 my $non_issues_charges = $self->non_issues_charges
@@ -481,7 +500,7 @@ sub non_issues_charges {
 =cut
 
 our $offset_type = {
-    'credit'           => 'Payment',
+    'credit'           => 'Manual Credit',
     'forgiven'         => 'Writeoff',
     'lost_item_return' => 'Lost Item Return',
     'payment'          => 'Payment',