From ff4f0858950c37eeede38b2f067841602b97d7ba Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 15 Jun 2017 11:07:03 -0400 Subject: [PATCH] Bug 18812 - SIP Patron status does not respect OverduesBlockCirc To test: 1 - Set 'OverduesBlockCirc' to block 2 - Find or create a patron with overdues 3 - Perform a SIP patron lookup on that patron misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1 -l CPL --patron {userid or cardnumber} --password {pass} -m patron_information 4 - Note the first character of response is a ' ' 5 - Apply patch 6 - Restart memcached, apache, and plack 7 - Perform SIP patron lookup 8 - Note the first character of response is 'Y' 9 - prove t/db_dependent/SIP/Patron.t 10 - Test should return green Signed-off-by: Chris Kirby Works as advertised Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- C4/SIP/ILS/Patron.pm | 3 ++- t/db_dependent/SIP/Patron.t | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm index d548a18425..6cd3300eee 100644 --- a/C4/SIP/ILS/Patron.pm +++ b/C4/SIP/ILS/Patron.pm @@ -63,6 +63,7 @@ sub new { $fines_amount = ($fines_amount and $fines_amount > 0) ? $fines_amount : 0; my $fee_limit = _fee_limit(); my $fine_blocked = $fines_amount > $fee_limit; + my $circ_blocked =( C4::Context->preference('OverduesBlockCirc') ne "noblock" && defined $flags->{ODUES}->{itemlist} ) ? 1 : 0; { no warnings; # any of these $kp->{fields} being concat'd could be undef %ilspatron = ( @@ -81,7 +82,7 @@ sub new { address => $adr, home_phone => $kp->{phone}, email_addr => $kp->{email}, - charge_ok => ( !$debarred && !$expired && !$fine_blocked), + charge_ok => ( !$debarred && !$expired && !$fine_blocked && !$circ_blocked), renew_ok => ( !$debarred && !$expired && !$fine_blocked), recall_ok => ( !$debarred && !$expired && !$fine_blocked), hold_ok => ( !$debarred && !$expired && !$fine_blocked), diff --git a/t/db_dependent/SIP/Patron.t b/t/db_dependent/SIP/Patron.t index b089ca0403..28009dffbe 100755 --- a/t/db_dependent/SIP/Patron.t +++ b/t/db_dependent/SIP/Patron.t @@ -4,10 +4,11 @@ # This needs to be extended! Your help is appreciated.. use Modern::Perl; -use Test::More tests => 2; +use Test::More tests => 3; use Koha::Database; use t::lib::TestBuilder; +use t::lib::Mocks; use C4::SIP::ILS::Patron; my $schema = Koha::Database->new->schema; @@ -26,4 +27,35 @@ $schema->resultset('Borrower')->search({ cardnumber => $card })->delete; my $sip_patron2 = C4::SIP::ILS::Patron->new( $card ); is( $sip_patron2, undef, "Patron is not valid (anymore)" ); +subtest "OverduesBlockCirc tests" => sub { + + plan tests => 6; + + my $odue_patron = $builder->build({ source => 'Borrower' }); + my $good_patron = $builder->build({ source => 'Borrower' }); + my $odue = $builder->build({ source => 'Issue', value => { + borrowernumber => $odue_patron->{borrowernumber}, + date_due => '2017-01-01', + } + }); + t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'noblock' ); + my $odue_sip_patron = C4::SIP::ILS::Patron->new( $odue_patron->{cardnumber} ); + is( $odue_sip_patron->{charge_ok}, 1, "Not blocked with overdues when set to 'Don't block'"); + $odue_sip_patron = C4::SIP::ILS::Patron->new( $good_patron->{cardnumber} ); + is( $odue_sip_patron->{charge_ok}, 1, "Not blocked without overdues when set to 'Don't block'"); + + t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); + $odue_sip_patron = C4::SIP::ILS::Patron->new( $odue_patron->{cardnumber} ); + is( $odue_sip_patron->{charge_ok}, '', "Blocked with overdues when set to 'Ask for confirmation'"); + $odue_sip_patron = C4::SIP::ILS::Patron->new( $good_patron->{cardnumber} ); + is( $odue_sip_patron->{charge_ok}, 1, "Not blocked without overdues when set to 'confirmation'"); + + t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); + $odue_sip_patron = C4::SIP::ILS::Patron->new( $odue_patron->{cardnumber} ); + is( $odue_sip_patron->{charge_ok}, '', "Blocked with overdues when set to 'Block'"); + $odue_sip_patron = C4::SIP::ILS::Patron->new( $good_patron->{cardnumber} ); + is( $odue_sip_patron->{charge_ok}, 1, "Not blocked without overdues when set to 'Block'"); + +}; + $schema->storage->txn_rollback; -- 2.39.5