Koha/C4/SIP/ILS/Transaction/Renew.pm
Colin Campbell 9929c52a57 Bug 8216: Allow SIP modules to pass critic tests
Add C4/SIP to perlcritic tests. Fix those issues that were
generating perlcritic errors

Signed-off-by: Stacey Walker <stacey@catalyst-eu.net>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
2012-06-20 11:14:00 +02:00

56 lines
1.1 KiB
Perl

#
# Status of a Renew Transaction
#
package ILS::Transaction::Renew;
use warnings;
use strict;
use ILS;
use ILS::Transaction;
use C4::Circulation;
use C4::Members;
our @ISA = qw(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){
$self->{due} = AddIssue( $borrower, $self->{item}->id, undef, 0 );
$self->renewal_ok(1);
} else {
$self->screen_msg(($self->screen_msg || '') . " " . $renewerror);
$self->renewal_ok(0);
}
$! and warn "do_renew_for error: $!";
$self->ok(1) unless $!;
return $self;
}
sub do_renew {
my $self = shift;
my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
return $self->do_renew_for($borrower);
}
1;