[Koha-patches] [PATCH] Commented out fixaccounts (not used anywhere). Also improved getnextacctno.
Joe Atzberger
joe.atzberger at liblime.com
Wed May 28 01:05:57 CEST 2008
You can test getnextacctno like:
perl -e 'use C4::Accounts; print getnextacctno(33), "\n";'
where 33 is a borrowernumber out of the accountlines table. Get that number like:
mysql> select borrowernumber,accountno from accountlines LIMIT 100;
---
C4/Accounts.pm | 34 +++++++++++++++-------------------
t/lib/KohaTest/Accounts.pm | 3 +--
2 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/C4/Accounts.pm b/C4/Accounts.pm
index 3a648e4..06a86fe 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 1eef7db..703d478 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 );
}
--
1.5.5.GIT
More information about the Koha-patches
mailing list