Koha/C4/SIP/ILS/Transaction/RenewAll.pm
Martin Renvoize 11c73ed5b8 Bug 34767: Pass fee_ack into ::Transaction::Renew(All)
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>
2023-09-17 22:00:51 -10:00

71 lines
1.7 KiB
Perl

#
# RenewAll: class to manage status of "Renew All" transaction
package C4::SIP::ILS::Transaction::RenewAll;
use strict;
use warnings;
use C4::SIP::Sip qw( siplog );
use C4::SIP::ILS::Item;
use Koha::Patrons;
use parent qw(C4::SIP::ILS::Transaction::Renew);
my %fields = (
renewed => [],
unrenewed => [],
);
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;
return bless $self, $class;
}
sub do_renew_all {
my $self = shift;
siplog('LOG_DEBUG', "ILS::Transaction::RenewAll performing renewals...");
my $patron = Koha::Patrons->find( $self->{patron}->{borrowernumber} );
my $all_ok = 1;
$self->{renewed} = [];
$self->{unrenewed} = [];
foreach my $itemx ( @{ $self->{patron}->{items} } ) {
my $item_id = $itemx->{barcode};
my $item = C4::SIP::ILS::Item->new($item_id);
if ( !defined($item) ) {
siplog(
'LOG_WARNING',
q|renew_all: Invalid item id '%s' associated with patron '%s'|,
$item_id,
$patron->id
);
# $all_ok = 0; Do net set as still ok
push @{ $self->unrenewed }, $item_id;
next;
}
$self->{item} = $item;
$self->do_renew_for($patron);
if ( $self->renewal_ok ) {
$item->{due_date} = $self->{due};
push @{ $self->{renewed} }, $item_id;
}
else {
push @{ $self->{unrenewed} }, $item_id;
}
$self->screen_msg(q{}); # clear indiv message
}
$self->ok($all_ok);
return $self;
}
1;