Jonathan Druart
2b90ea2cb0
GetMember returned a patron given a borrowernumber, cardnumber or userid. All of these 3 attributes are defined as a unique key at the DB level and so we can use Koha::Patrons->find to replace this subroutine. Additionaly GetMember set category_type and description. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
67 lines
1.7 KiB
Perl
67 lines
1.7 KiB
Perl
#
|
|
# Status of a Renew Transaction
|
|
#
|
|
|
|
package C4::SIP::ILS::Transaction::Renew;
|
|
|
|
use warnings;
|
|
use strict;
|
|
|
|
use C4::Circulation;
|
|
use Koha::Patrons;
|
|
use Koha::DateUtils;
|
|
|
|
use parent qw(C4::SIP::ILS::Transaction);
|
|
|
|
my %fields = (
|
|
renewal_ok => 0,
|
|
);
|
|
|
|
sub new {
|
|
my $class = shift;
|
|
my $self = $class->SUPER::new();
|
|
|
|
foreach my $element (keys %fields) {
|
|
$self->{_permitted}->{$element} = $fields{$element};
|
|
}
|
|
|
|
@{$self}{keys %fields} = values %fields; # overkill?
|
|
return bless $self, $class;
|
|
}
|
|
|
|
sub do_renew_for {
|
|
my $self = shift;
|
|
my $borrower = shift;
|
|
my ($renewokay,$renewerror) = CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber});
|
|
if ($renewokay) { # ok so far check charges
|
|
my ($fee, undef) = GetIssuingCharges($self->{item}->{itemnumber}, $self->{patron}->{borrowernumber});
|
|
if ($fee > 0) {
|
|
$self->{sip_fee_type} = '06';
|
|
$self->{fee_amount} = sprintf '%.2f',$fee;
|
|
if ($self->{fee_ack} eq 'N') {
|
|
$renewokay = 0;
|
|
}
|
|
}
|
|
|
|
}
|
|
if ($renewokay){
|
|
my $issue = AddIssue( $borrower, $self->{item}->id, undef, 0 );
|
|
$self->{due} = $self->duedatefromissue($issue, $self->{item}->{itemnumber});
|
|
$self->renewal_ok(1);
|
|
} else {
|
|
$renewerror=~s/on_reserve/Item unavailable due to outstanding holds/;
|
|
$renewerror=~s/too_many/Item has reached maximum renewals/;
|
|
$self->screen_msg($renewerror);
|
|
$self->renewal_ok(0);
|
|
}
|
|
$self->ok(1);
|
|
return;
|
|
}
|
|
|
|
sub do_renew {
|
|
my $self = shift;
|
|
my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
|
|
return $self->do_renew_for($patron->unblessed);
|
|
}
|
|
|
|
1;
|