Bug 17578: GetMemberDetails - Remove is_expired

The is_expired value is used in 2 places, let's use
Koha::Patron->is_expired instead.

Test plan:
Depending on the different value of BlockExpiredPatronOpacActions for
the patron category, a patron must be blocked if he has expired.
Confirm that behavior from opac-renew and opac-reserve scripts

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2016-11-07 18:14:49 +01:00 committed by Kyle M Hall
parent 41493004f6
commit 5a0a2ce584
4 changed files with 2 additions and 15 deletions

View file

@ -173,13 +173,6 @@ sub GetMemberDetails {
my $borrower = $sth->fetchrow_hashref;
return unless $borrower;
$borrower->{'is_expired'} = 0;
$borrower->{'is_expired'} = 1 if
defined($borrower->{dateexpiry}) &&
$borrower->{'dateexpiry'} ne '0000-00-00' &&
Date_to_Days( Today() ) >
Date_to_Days( split /-/, $borrower->{'dateexpiry'} );
return ($borrower);
}

View file

@ -51,10 +51,9 @@ my $errorstring = q{};
my $renewed = q{};
my $patron = Koha::Patrons->find( $borrowernumber );
my $member_details = GetMemberDetails($borrowernumber);
if ( $patron->category->effective_BlockExpiredPatronOpacActions
&& $member_details->{'is_expired'} )
&& $patron->is_expired )
{
$errorstring = 'card_expired';
}

View file

@ -76,7 +76,7 @@ my $patron = Koha::Patrons->find( $borrowernumber );
# check if this user can place a reserve, -1 means use sys pref, 0 means dont block, 1 means block
if ( $patron->category->effective_BlockExpiredPatronOpacActions ) {
if ( $borr->{'is_expired'} ) {
if ( $patron->is_expired ) {
# cannot reserve, their card has expired and the rules set mean this is not allowed
$template->param( message => 1, expired_patron => 1 );

View file

@ -150,11 +150,6 @@ C4::Context->clear_syspref_cache();
$notice_email = GetNoticeEmailAddress($member->{'borrowernumber'});
is ($notice_email, $EMAILPRO, "GetNoticeEmailAddress returns correct value when AutoEmailPrimaryAddress is emailpro");
ok(!$member->{is_expired}, "GetMemberDetails() indicates that patron is not expired");
ModMember(borrowernumber => $member->{'borrowernumber'}, dateexpiry => '2001-01-1');
$member = GetMemberDetails($member->{'borrowernumber'});
ok($member->{is_expired}, "GetMemberDetails() indicates that patron is expired");
# Check_Userid tests
%data = (
cardnumber => "123456789",