From a05bb1e36dd8af51dd2a2039593a4303879bb62d Mon Sep 17 00:00:00 2001 From: Shi Yao Wang Date: Mon, 13 Jun 2022 14:05:53 -0400 Subject: [PATCH] Bug 14784: Fix checkin message for restricted patrons Test plan: Before 1) Select a user with active indefinite or definite restrictions (manual restriction works) 2) Make sure finedays=0 for the user category. See [1] 3) Checkout and return an item (not overdue) A previous restriction reminder will appear 4) Checkout and return an overdue item (change the date at checkout) No previous restriction reminder will appear After applying patch: Same steps, but a reminder should appear for step 4) [1] The "finedays" setting is called "Suspension in days" in the web interface, if you're searching for it like I did... Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- C4/Circulation.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 336ce9490a..f2fc96c719 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2301,10 +2301,23 @@ sub AddReturn { if ( $issue and $issue->is_overdue($return_date) ) { # fix fine days my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item->unblessed, dt_from_string($issue->date_due), $return_date ); - if ($reminder){ - $messages->{'PrevDebarred'} = $debardate; - } else { - $messages->{'Debarred'} = $debardate if $debardate; + if ($debardate and $debardate ne "9999-12-31") { + if ($reminder){ + $messages->{'PrevDebarred'} = $debardate; + } else { + $messages->{'Debarred'} = $debardate; + } + } elsif ($patron->debarred) { + if ( $patron->debarred eq "9999-12-31") { + $messages->{'ForeverDebarred'} = $patron->debarred; + } else { + my $borrower_debar_dt = dt_from_string( $patron->debarred ); + $borrower_debar_dt->truncate(to => 'day'); + my $today_dt = $return_date->clone()->truncate(to => 'day'); + if ( DateTime->compare( $borrower_debar_dt, $today_dt ) != -1 ) { + $messages->{'PrevDebarred'} = $patron->debarred; + } + } } # there's no overdue on the item but borrower had been previously debarred } elsif ( $issue->date_due and $patron->debarred ) { -- 2.39.5