[Koha-bugs] [Bug 8236] Prevent renewing if overdue or restriction

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Feb 14 11:17:12 CET 2013


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8236

Koha Team Lyon 3 <koha at univ-lyon3.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |koha at univ-lyon3.fr

--- Comment #29 from Koha Team Lyon 3 <koha at univ-lyon3.fr> ---
(En réponse au commentaire 28)
> Hi Koha Team Lyon 3,
> 
> I'm under the impression that some duplicated code could be factorized into
> the CanBookBeRenewed routine. Is there a reason for this code not being in
> it?

As you suggest it, I first considered putting the following block in
CanBookBeRenewed :
# Check if any of patron's documents is late
my ($memberblocked) = C4::Members::IsMemberBlocked($borrowernumber);
# and if renewal is allowed in that case
my $overduesblockrenew = C4::Context->preference('OverduesBlockRenew');
my $norenewal = 1 if $overduesblockrenew eq 'blockall' and $memberblocked ==
-1;

But as this block is there to check if no renewal at all is allowed, one
checking by borrower is enough and it would be redundant checking again for
each item. So I choose to put it outside the @$issueslist loop (sub
build_issue_data) and keep the result in $norenewal variable. So when
$norenewal is true, I have not to call for CanBookBeRenewed, I can straightly
affect the value to $renewokay and $renewerror :
my ( $renewokay, $renewerror ) = $norenewal ? (0, 'overdue') :
CanBookBeRenewed( $borrowernumber, $issue->{itemnumber}...

At the end, I am not sure that it's a great economy but that's the reason why.

May be I could make a function out of this block and put it in Circulation.pm :

sub CanOverduesBlockRenewal {
    my $borrowernumber = shift;
    # Check if any of patron's documents is late
    my ($memberblocked) = C4::Members::IsMemberBlocked($borrowernumber);
    # the option selected for the syspref 
    my $overduesblockrenew = C4::Context->preference('OverduesBlockRenew');
    # and if renewal is blocked for all the patron's documents on loan
    my $norenewal = 1 if $overduesblockrenew eq 'blockall' and $memberblocked
== -1;

    return ($norenewal,$overduesblockrenew);
}



Olivier Crouzet

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list