From 363d458ace8ec5680974f89e2a7cc30cdc487ab3 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 11 Mar 2013 13:29:31 -0400 Subject: [PATCH] Bug 7560 - SIP Self Checkout Ignoring Fines Thresholds for Not Being able to Check Out Books - QA Followup --- C4/Accounts.pm | 21 +++++++++++++++++++++ C4/Overdues.pm | 19 ------------------- C4/SIP/ILS/Transaction/Renew.pm | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index f087b7a..8c6c448 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -50,6 +50,7 @@ BEGIN { &makepartialpayment &recordpayment_selectaccts &WriteOffFee + &GetTotalFines ); } @@ -1001,6 +1002,26 @@ sub WriteOffFee { } +=head2 GetTotalFines + + my $total_fines_owed = GetTotalFines( $borrowernumber ); + + Returns the total amount owed by the given borrower. + +=cut + +sub GetTotalFines { + my ( $borrowernumber ) = @_; + my $dbh = C4::Context->dbh(); + my $query = "SELECT SUM( amountoutstanding ) AS total FROM accountlines WHERE borrowernumber = ?"; + my $sth = $dbh->prepare( $query ); + $sth->execute( $borrowernumber ); + my $row = $sth->fetchrow_hashref(); + my $total = $row->{'total'}; + $total = $total || 0; + return $total; +} + END { } # module clean-up code here (global destructor) 1; diff --git a/C4/Overdues.pm b/C4/Overdues.pm index 20496d9..18993b4 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -658,25 +658,6 @@ sub GetFine { return 0; } -=head2 GetTotalFines - - my $total_fines_owed = GetTotalFines( $borrowernumber ); - - Returns the total amount owed by the given borrower. - -=cut - -sub GetTotalFines { - my ( $borrowernumber ) = @_; - my $dbh = C4::Context->dbh(); - my $query = "SELECT SUM( amountoutstanding ) AS total FROM accountlines WHERE borrowernumber = ?"; - my $sth = $dbh->prepare( $query ); - $sth->execute( $borrowernumber ); - my $row = $sth->fetchrow_hashref(); - my $total = $row->{'total'}; - $total = $total || 0; - return $total; -} =head2 NumberNotifyId diff --git a/C4/SIP/ILS/Transaction/Renew.pm b/C4/SIP/ILS/Transaction/Renew.pm index 7d1269b..47cda6c 100644 --- a/C4/SIP/ILS/Transaction/Renew.pm +++ b/C4/SIP/ILS/Transaction/Renew.pm @@ -35,7 +35,7 @@ sub do_renew_for { my $borrower = shift; my ($renewokay,$renewerror) = CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber}); - unless ( C4::Overdues::GetTotalFines($borrower->{borrowernumber}) < C4::Context->preference('OPACFineNoRenewals') ) { + unless ( C4::Accounts::GetTotalFines($borrower->{borrowernumber}) < C4::Context->preference('OPACFineNoRenewals') ) { $renewokay = 0; $renewerror = 'too_many_fines' } -- 1.7.2.5