Koha/C4/SIP/ILS/Transaction/Renew.pm
Jonathan Druart 23dd6651f8
Bug 23403: Remove cardnumber from SIP
== Test plan ==
1 - Have two patrons with userids and no cardnumber
2 - Note which of these has the higher borrower number
3 - Use the SIP cli emulator to connect and checkout a book to the patron with higher borrowernumber
      See example after
4 - Note the book may checkout to the wrong patron!
5 - Apply patch
6 - Checkout to both patrons via sip
7 - The patrons get the correct checkouts

=== SIP CLI emulator ===
./misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1 \
-l CPL --patron 23529001000463 -m checkout --item 39999000001259

translation: via the koha user term1, checkout item 39999000001259 to
patron 23529001000463

Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2020-05-15 09:48:20 +01:00

69 lines
1.8 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/;
$renewerror=~s/item_denied_renewal/Item renewal is not allowed/;
$self->screen_msg($renewerror);
$self->renewal_ok(0);
}
$self->ok(1);
return;
}
sub do_renew {
my $self = shift;
my $patron = Koha::Patrons->find( $self->{patron}->borrowernumber );
$patron or return; # FIXME we should log that
return $self->do_renew_for($patron->unblessed);
}
1;