&recordpayment &makepayment &manualinvoice
&getnextacctno &reconcileaccount &getcharges &getcredits
&getrefunds &chargelostitem
+ &ReversePayment
); # removed &fixaccounts
}
sub returnlost{
my ( $borrowernumber, $itemnum ) = @_;
C4::Circulation::MarkIssueReturned( $borrowernumber, $itemnum );
- my $borrower = C4::Members::GetMember( $borrowernumber, 'borrowernumber' );
+ my $borrower = C4::Members::GetMember( 'borrowernumber'=>$borrowernumber );
my @datearr = localtime(time);
my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3];
my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}";
#FIXME : Should probably have a way to distinguish this from an item that really was returned.
warn " $issues->{'borrowernumber'} / $itemnumber ";
C4::Circulation::MarkIssueReturned($issues->{borrowernumber},$itemnumber);
+ # Shouldn't MarkIssueReturned do this?
+ ModItem({ onloan => undef }, undef, $itemnumber);
}
$sth->finish;
}
}
return (@results);
}
+
+sub ReversePayment {
+ my ( $borrowernumber, $accountno ) = @_;
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE borrowernumber = ? AND accountno = ?');
+ $sth->execute( $borrowernumber, $accountno );
+ my $row = $sth->fetchrow_hashref();
+ my $amount_outstanding = $row->{'amountoutstanding'};
+
+ if ( $amount_outstanding <= 0 ) {
+ $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?');
+ $sth->execute( $borrowernumber, $accountno );
+ } else {
+ $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?');
+ $sth->execute( $borrowernumber, $accountno );
+ }
+}
+
END { } # module clean-up code here (global destructor)
1;