diff --git a/C4/Accounts.pm b/C4/Accounts.pm index 3a648e4660..06a86fe1fa 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -29,14 +29,14 @@ use vars qw($VERSION @ISA @EXPORT); BEGIN { # set the version for version checking - $VERSION = 3.02; + $VERSION = 3.03; require Exporter; @ISA = qw(Exporter); @EXPORT = qw( - &recordpayment &fixaccounts &makepayment &manualinvoice + &recordpayment &makepayment &manualinvoice &getnextacctno &reconcileaccount &getcharges &getcredits &getrefunds - ); + ); # removed &fixaccounts } =head1 NAME @@ -217,29 +217,22 @@ borrower number. #' # FIXME - Okay, so what does the above actually _mean_? -sub getnextacctno { - my ($borrowernumber) = @_; - my $nextaccntno = 1; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare( - "SELECT * FROM accountlines - WHERE (borrowernumber = ?) - ORDER BY accountno DESC" +sub getnextacctno ($) { + my ($borrowernumber) = shift or return undef; + my $sth = C4::Context->dbh->prepare( + "SELECT accountno+1 FROM accountlines + WHERE (borrowernumber = ?) + ORDER BY accountno DESC + LIMIT 1" ); $sth->execute($borrowernumber); - if ( my $accdata = $sth->fetchrow_hashref ) { - $nextaccntno = $accdata->{'accountno'} + 1; - } - $sth->finish; - return ($nextaccntno); + return ($sth->fetchrow || 1); } -=head2 fixaccounts +=head2 fixaccounts (removed) &fixaccounts($borrowernumber, $accountnumber, $amount); -=cut - #' # FIXME - I don't understand what this function does. sub fixaccounts { @@ -264,8 +257,11 @@ sub fixaccounts { WHERE borrowernumber = $borrowernumber AND accountno = $accountno EOT + # FIXME: exceedingly bad form. Use prepare with placholders ("?") in query and execute args. } +=cut + sub returnlost { my ( $borrowernumber, $itemnum ) = @_; C4::Circulation::MarkIssueReturned( $borrowernumber, $itemnum ); diff --git a/t/lib/KohaTest/Accounts.pm b/t/lib/KohaTest/Accounts.pm index 1eef7dbc6d..703d478196 100644 --- a/t/lib/KohaTest/Accounts.pm +++ b/t/lib/KohaTest/Accounts.pm @@ -15,7 +15,6 @@ sub methods : Test( 1 ) { my @methods = qw( recordpayment makepayment getnextacctno - fixaccounts returnlost manualinvoice fixcredit @@ -23,7 +22,7 @@ sub methods : Test( 1 ) { getcharges getcredits getrefunds - ); + ); # removed fixaccounts (unused by codebase) can_ok( $self->testing_class, @methods ); }