View | Details | Raw Unified | Return to bug 31735
Collapse All | Expand All

(-)a/C4/Circulation.pm (-7 / +6 lines)
Lines 832-838 sub CanBookBeIssued { Link Here
832
        $issuingimpossible{DEBARRED} = 1;
832
        $issuingimpossible{DEBARRED} = 1;
833
    }
833
    }
834
834
835
    if ( $patron->is_expired ) {
835
    if ( $patron->is_expired({ cache => 1 }) ) {
836
        $issuingimpossible{EXPIRED} = 1;
836
        $issuingimpossible{EXPIRED} = 1;
837
    }
837
    }
838
838
Lines 918-924 sub CanBookBeIssued { Link Here
918
        else {
918
        else {
919
            $issuingimpossible{USERBLOCKEDWITHENDDATE} = $debarred_date;
919
            $issuingimpossible{USERBLOCKEDWITHENDDATE} = $debarred_date;
920
        }
920
        }
921
    } elsif ( my $num_overdues = $patron->has_overdues ) {
921
    } elsif ( my $num_overdues = $patron->has_overdues({ cache => 1 }) ) {
922
        ## patron has outstanding overdue loans
922
        ## patron has outstanding overdue loans
923
        if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){
923
        if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){
924
            $issuingimpossible{USERBLOCKEDOVERDUE} = $num_overdues;
924
            $issuingimpossible{USERBLOCKEDOVERDUE} = $num_overdues;
Lines 1716-1722 sub AddIssue { Link Here
1716
                if ( $accumulate_charge > 0 ) {
1716
                if ( $accumulate_charge > 0 ) {
1717
                    AddIssuingCharge( $issue, $accumulate_charge, 'RENT_DAILY' );
1717
                    AddIssuingCharge( $issue, $accumulate_charge, 'RENT_DAILY' );
1718
                    $charge += $accumulate_charge;
1718
                    $charge += $accumulate_charge;
1719
                    $item_unblessed->{charge} = $charge;
1720
                }
1719
                }
1721
            }
1720
            }
1722
1721
Lines 2522-2528 sub MarkIssueReturned { Link Here
2522
        # Remove any OVERDUES related debarment if the borrower has no overdues
2521
        # Remove any OVERDUES related debarment if the borrower has no overdues
2523
        if ( C4::Context->preference('AutoRemoveOverduesRestrictions')
2522
        if ( C4::Context->preference('AutoRemoveOverduesRestrictions')
2524
          && $patron->debarred
2523
          && $patron->debarred
2525
          && !$patron->has_overdues
2524
          && !$patron->has_overdues({ cache => 1 })
2526
          && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) }
2525
          && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) }
2527
        ) {
2526
        ) {
2528
            DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
2527
            DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
Lines 2879-2885 sub CanBookBeRenewed { Link Here
2879
        my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
2878
        my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
2880
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
2879
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
2881
        my $restricted  = $patron->is_debarred;
2880
        my $restricted  = $patron->is_debarred;
2882
        my $hasoverdues = $patron->has_overdues;
2881
        my $hasoverdues = $patron->has_overdues({ cache => 1 });
2883
2882
2884
        if ( $restricted and $restrictionblockrenewing ) {
2883
        if ( $restricted and $restrictionblockrenewing ) {
2885
            return ( 0, 'restriction');
2884
            return ( 0, 'restriction');
Lines 3156-3162 sub AddRenewal { Link Here
3156
        # Remove any OVERDUES related debarment if the borrower has no overdues
3155
        # Remove any OVERDUES related debarment if the borrower has no overdues
3157
        if ( $patron
3156
        if ( $patron
3158
          && $patron->is_debarred
3157
          && $patron->is_debarred
3159
          && ! $patron->has_overdues
3158
          && ! $patron->has_overdues({ cache => 1 })
3160
          && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) }
3159
          && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) }
3161
        ) {
3160
        ) {
3162
            DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
3161
            DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
Lines 4371-4377 sub _CanBookBeAutoRenewed { Link Here
4371
        }
4370
        }
4372
    );
4371
    );
4373
4372
4374
    if ( $patron->is_expired && $patron->category->effective_BlockExpiredPatronOpacActions ) {
4373
    if ( $patron->is_expired({ cache => 1 }) && $patron->category->effective_BlockExpiredPatronOpacActions ) {
4375
        return 'auto_account_expired';
4374
        return 'auto_account_expired';
4376
    }
4375
    }
4377
4376
(-)a/Koha/Patron.pm (-8 / +24 lines)
Lines 770-780 Returns 1 if the patron is expired or 0; Link Here
770
=cut
770
=cut
771
771
772
sub is_expired {
772
sub is_expired {
773
    my ($self) = @_;
773
    my ($self, $params) = @_;
774
    return 0 unless $self->dateexpiry;
774
    $params //= {};
775
    return 0 if $self->dateexpiry =~ '^9999';
775
    if ($params->{cache} && defined $self->{is_expired_cache}) {
776
    return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string->truncate( to => 'day' );
776
        return $self->{is_expired_cache};
777
    return 0;
777
    }
778
    my $is_expired =
779
        $self->dateexpiry &&
780
        $self->dateexpiry !~ '^9999' &&
781
        dt_from_string( $self->dateexpiry ) < dt_from_string->truncate( to => 'day' );
782
    if ($params->{cache}) {
783
        $self->{is_expired_cache} = $is_expired;
784
    }
785
    return $is_expired;
778
}
786
}
779
787
780
=head3 password_expired
788
=head3 password_expired
Lines 945-953 Returns the number of patron's overdues Link Here
945
=cut
953
=cut
946
954
947
sub has_overdues {
955
sub has_overdues {
948
    my ($self) = @_;
956
    my ($self, $params) = @_;
957
    $params //= {};
958
959
    if ($params->{cache} && defined $self->{has_overdues_cache}) {
960
        return $self->{has_overdues_cache};
961
    }
949
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
962
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
950
    return $self->_result->issues->search({ date_due => { '<' => $dtf->format_datetime( dt_from_string() ) } })->count;
963
    my $has_overdues = $self->_result->issues->search({ date_due => { '<' => $dtf->format_datetime( dt_from_string() ) } })->count;
964
    if ($params->{cache}) {
965
        $self->{has_overdues_cache} = $has_overdues;
966
    }
967
    return $has_overdues;
951
}
968
}
952
969
953
=head3 track_login
970
=head3 track_login
954
- 

Return to bug 31735