From ced52d7f28326a6a0084c0f094a14d7ec0f118e1 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 | 20 -------------------- C4/SIP/ILS/Transaction/Renew.pm | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index 5aa4fef..8b293d8 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -47,6 +47,7 @@ BEGIN { &makepartialpayment &recordpayment_selectaccts &WriteOffFee + &GetTotalFines ); } @@ -814,6 +815,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 4f2f60d..ac66c36 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -53,7 +53,6 @@ BEGIN { &GetOverdueDelays &GetOverduerules &GetFine - &GetTotalFines &CreateItemAccountLine &ReplacementCost2 @@ -693,25 +692,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 GetIssuingRules diff --git a/C4/SIP/ILS/Transaction/Renew.pm b/C4/SIP/ILS/Transaction/Renew.pm index 46f0869..8c79603 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