Bug 18812 - SIP Patron status does not respect OverduesBlockCirc
authorNick Clemens <nick@bywatersolutions.com>
Thu, 15 Jun 2017 15:07:03 +0000 (11:07 -0400)
committerMason James <mtj@kohaaloha.com>
Tue, 24 Oct 2017 03:42:11 +0000 (16:42 +1300)
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 <chris.kirby@ilsleypubliclibrary.org>
Works as advertised

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit ff4f0858950c37eeede38b2f067841602b97d7ba)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 4b360f1371a56268458b62e5c8c68da853b4e52d)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

C4/SIP/ILS/Patron.pm
t/db_dependent/SIP/Patron.t

index 93b6c54..7555336 100644 (file)
@@ -62,6 +62,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 = (
@@ -80,7 +81,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),
index b089ca0..28009df 100755 (executable)
@@ -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;