From fa490dd9c1265b7b22ebb74052f9d1b416b9d33b 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 finesday=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 cehckout) No previous restriction reminder will appear After applying patch: Same steps, but a reminder should appear for step 4) [1] The "finesday" setting is called "Suspension in days" in the web interface, if you're searching for it like I did... Signed-off-by: David Nind --- C4/Circulation.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index f5df973d1d..b4c7ff41aa 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2296,10 +2296,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.30.2