@@ -, +, @@ --- C4/Overdues.pm | 22 +++++++++++++++++++++- C4/SIP/ILS/Patron.pm | 4 ++-- C4/SIP/ILS/Transaction/Renew.pm | 6 ++++++ 3 files changed, 29 insertions(+), 3 deletions(-) --- a/C4/Overdues.pm +++ a/C4/Overdues.pm @@ -45,7 +45,7 @@ BEGIN { &AmountNotify &UpdateFine &GetFine - + &GetTotalFines &CheckItemNotify &GetOverduesForBranch &RemoveNotifyLine @@ -658,6 +658,26 @@ 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 (@notify) = &NumberNotifyId($borrowernumber); --- a/C4/SIP/ILS/Patron.pm +++ a/C4/SIP/ILS/Patron.pm @@ -78,8 +78,8 @@ sub new { address => $adr, home_phone => $kp->{phone}, email_addr => $kp->{email}, - charge_ok => ( !$debarred && !$expired ), - renew_ok => ( !$debarred && !$expired ), + charge_ok => ( !$debarred && !$expired && ( $fines_amount < C4::Context->preference('noissuescharge') ) ), + renew_ok => ( !$debarred && !$expired && ( $fines_amount < C4::Context->preference('OPACFineNoRenewals') ) ), recall_ok => ( !$debarred && !$expired ), hold_ok => ( !$debarred && !$expired ), card_lost => ( $kp->{lost} || $kp->{gonenoaddress} || $flags->{LOST} ), --- a/C4/SIP/ILS/Transaction/Renew.pm +++ a/C4/SIP/ILS/Transaction/Renew.pm @@ -34,6 +34,12 @@ sub do_renew_for { my $self = shift; my $borrower = shift; my ($renewokay,$renewerror) = CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber}); + + unless ( C4::Overdues::GetTotalFines($borrower->{borrowernumber}) < C4::Context->preference('OPACFineNoRenewals') ) { + $renewokay = 0; + $renewerror = 'too_many_fines' + } + if ($renewokay){ $self->{due} = undef; my $due_date = AddIssue( $borrower, $self->{item}->id, undef, 0 ); --