Martin Renvoize
11c73ed5b8
This patch copies the $fee_ack field into the generated
::Transaction::Renew|All objects such that the fee acknowldegement flag
is respected for renewals.
Test plan
To test:
1) Add a rental charge to an itemtype
2) Checkout an item of that itemtype to a user
3) Attempt a renewal of that item via SIP2 and note that it fails
sip_cli_emulator.pl -a localhost -p 6001 -su term1 -sp term1 -l CPL --patron 23529000035676 --item 39999000007756 -m renew
4) Pass the fee_acknowledgement bit in renewal and note the renewal
still fails.
sip_cli_emulator.pl -a localhost -p 6001 -su term1 -sp term1 -l CPL --fee-acknowledged Y --patron 23529000035676 --item 39999000007756 -m renew
5) Apply patch and note the above now succeeds
sip_cli_emulator.pl -a localhost -p 6001 -su term1 -sp term1 -l CPL --fee-acknowledged Y --patron 23529000035676 --item 39999000007756 -m renew
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 3a2dcf0733
)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
74 lines
2.2 KiB
Perl
74 lines
2.2 KiB
Perl
#
|
|
# Status of a Renew Transaction
|
|
#
|
|
|
|
package C4::SIP::ILS::Transaction::Renew;
|
|
|
|
use warnings;
|
|
use strict;
|
|
use C4::SIP::Sip qw( siplog );
|
|
|
|
use C4::Circulation qw( CanBookBeRenewed GetIssuingCharges AddIssue );
|
|
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 $patron = shift;
|
|
my $checkout = Koha::Checkouts->find({ itemnumber => $self->{item}->{itemnumber} });
|
|
my ($renewokay,$renewerror) = CanBookBeRenewed($patron, $checkout);
|
|
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( $patron->unblessed, $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/too_unseen/Item has reached maximum consecutive renewals without being seen/;
|
|
$renewerror=~s/item_denied_renewal/Item renewal is not allowed/;
|
|
$renewerror=~s/item_issued_to_other_patron/Item already issued to other borrower/;
|
|
$self->screen_msg($renewerror);
|
|
$self->renewal_ok(0);
|
|
}
|
|
$self->ok(1);
|
|
return;
|
|
}
|
|
|
|
sub do_renew {
|
|
my $self = shift;
|
|
siplog('LOG_DEBUG', "ILS::Transaction::Renew performing renewal...");
|
|
my $patron = Koha::Patrons->find( $self->{patron}->borrowernumber );
|
|
$patron or return; # FIXME we should log that
|
|
return $self->do_renew_for($patron);
|
|
}
|
|
|
|
1;
|