Bugzilla – Attachment 147884 Details for
Bug 32684
Implement SIP patron status field "too many items lost"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32684: (follow-up) Move logic to SIP::ILS::Patron
Bug-32684-follow-up-Move-logic-to-SIPILSPatron.patch (text/plain), 7.63 KB, created by
Kyle M Hall
on 2023-03-07 20:02:38 UTC
(
hide
)
Description:
Bug 32684: (follow-up) Move logic to SIP::ILS::Patron
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2023-03-07 20:02:38 UTC
Size:
7.63 KB
patch
obsolete
>From 537b458ad1327de7c5edb8a7e6cba1bbfecb68b8 Mon Sep 17 00:00:00 2001 >From: Kyle Hall <kyle@bywatersolutions.com> >Date: Tue, 7 Mar 2023 15:02:02 -0500 >Subject: [PATCH] Bug 32684: (follow-up) Move logic to SIP::ILS::Patron > >--- > C4/SIP/ILS/Patron.pm | 10 +++++++++- > C4/SIP/Sip/MsgType.pm | 17 +++++------------ > t/db_dependent/SIP/Message.t | 7 +++++++ > 3 files changed, 21 insertions(+), 13 deletions(-) > >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index e5542bfb2b..05e1701386 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -34,7 +34,7 @@ our $kp; # koha patron > =cut > > sub new { >- my ($class, $patron_id) = @_; >+ my ($class, $patron_id, $server) = @_; > my $type = ref($class) || $class; > my $self; > >@@ -97,6 +97,13 @@ sub new { > $fines_msg .= " -- " . "Patron blocked by fines ($fines_amount) on guaranteed accounts" if $fine_blocked; > } > >+ my $too_many_lost = 0; >+ if ( my $lost_block_checkout = $server->{account}->{lost_block_checkout} ) { >+ my $lost_block_checkout_value = $server->{account}->{lost_block_checkout_value} // 1; >+ my $lost_checkouts = Koha::Checkouts->search({ borrowernumber => $patron->borrowernumber, 'itemlost' => { '>=', $lost_block_checkout_value } }, { join => 'item'} )->count; >+ $too_many_lost = $lost_checkouts >= $lost_block_checkout; >+ } >+ > 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 >@@ -140,6 +147,7 @@ sub new { > fine_blocked => $fine_blocked, > fee_limit => $fee_limit, > userid => $kp->{userid}, >+ too_many_lost => $too_many_lost, > ); > } > >diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm >index 658eb5eb91..0201a028da 100644 >--- a/C4/SIP/Sip/MsgType.pm >+++ b/C4/SIP/Sip/MsgType.pm >@@ -501,7 +501,7 @@ sub handle_patron_status { > my $fields = $self->{fields}; > > $ils->check_inst_id( $fields->{ (FID_INST_ID) }, "handle_patron_status" ); >- $patron = $ils->find_patron( $fields->{ (FID_PATRON_ID) } ); >+ $patron = $ils->find_patron( $fields->{ (FID_PATRON_ID) }, $server ); > $resp = build_patron_status( $patron, $lang, $fields, $server ); > $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} ); > return (PATRON_STATUS_REQ); >@@ -769,7 +769,7 @@ sub handle_block_patron { > # FIXME ??? > > $ils->check_inst_id( $inst_id, "block_patron" ); >- $patron = $ils->find_patron($patron_id); >+ $patron = $ils->find_patron( $patron_id, $server ); > > # The correct response for a "Block Patron" message is a > # "Patron Status Response", so use that handler to generate >@@ -988,7 +988,7 @@ sub handle_patron_info { > > Koha::Plugins->call('patron_barcode_transform', \$patron_id ); > >- $patron = $ils->find_patron($patron_id); >+ $patron = $ils->find_patron( $patron_id, $server ); > > $resp = (PATRON_INFO_RESP); > if ($patron) { >@@ -1359,7 +1359,7 @@ sub handle_patron_enable { > > siplog( "LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", $patron_id, $patron_pwd ); > >- $patron = $ils->find_patron($patron_id); >+ $patron = $ils->find_patron( $patron_id, $server ); > > if ( !defined($patron) ) { > >@@ -1717,13 +1717,6 @@ sub patron_status_string { > > my $patron_status; > >- my $too_many_lost = 0; >- if ( my $lost_block_checkout = $server->{account}->{lost_block_checkout} ) { >- my $lost_block_checkout_value = $server->{account}->{lost_block_checkout_value} // 1; >- my $lost_checkouts = Koha::Checkouts->search({ borrowernumber => $patron->borrowernumber, 'itemlost' => { '>=', $lost_block_checkout_value } }, { join => 'item'} )->count; >- $too_many_lost = $lost_checkouts >= $lost_block_checkout; >- } >- > siplog( "LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok ); > $patron_status = sprintf( > '%s%s%s%s%s%s%s%s%s%s%s%s%s%s', >@@ -1736,7 +1729,7 @@ sub patron_status_string { > $server->{account}->{overdues_block_checkout} ? boolspace( $patron->too_many_overdue ) : q{ }, > boolspace( $patron->too_many_renewal ), > boolspace( $patron->too_many_claim_return ), >- boolspace( $too_many_lost ), >+ boolspace( $patron->too_many_lost ), > boolspace( $patron->excessive_fines ), > boolspace( $patron->excessive_fees ), > boolspace( $patron->recall_overdue ), >diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t >index 4c6fe1326c..b03919af70 100755 >--- a/t/db_dependent/SIP/Message.t >+++ b/t/db_dependent/SIP/Message.t >@@ -289,32 +289,39 @@ subtest "Test patron_status_string" => sub { > is( Koha::Checkouts->search({ borrowernumber => $patron->{borrowernumber}, 'itemlost' => { '>', 0 } }, { join => 'item'} )->count, 2, "Found 2 lost checkouts for this patron" ); > > my $server->{account}->{lost_block_checkout} = undef; >+ $sip_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber}, $server ); > my $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); > is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 0 does not block checkouts with 2 lost checkouts" );; > > $server->{account}->{lost_block_checkout} = 0; >+ $sip_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber}, $server ); > $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); > is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 0 does not block checkouts with 2 lost checkouts" );; > > $server->{account}->{lost_block_checkout} = 1; >+ $sip_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber}, $server ); > $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); > is( substr($patron_status_string, 9, 1), q{Y}, "lost_block_checkout = 1 does block checkouts with 2 lost checkouts" );; > > $server->{account}->{lost_block_checkout} = 2; >+ $sip_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber}, $server ); > $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); > is( substr($patron_status_string, 9, 1), q{Y}, "lost_block_checkout = 2 does block checkouts with 2 lost checkouts" );; > > $server->{account}->{lost_block_checkout} = 3; >+ $sip_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber}, $server ); > $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); > is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 3 does not block checkouts with 2 lost checkouts" );; > > $server->{account}->{lost_block_checkout} = 2; > $server->{account}->{lost_block_checkout_value} = 2; >+ $sip_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber}, $server ); > $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); > is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 2, lost_block_checkout_value = 2 does not block checkouts with 2 lost checkouts where only 1 has itemlost = 2" ); > > $server->{account}->{lost_block_checkout} = 1; > $server->{account}->{lost_block_checkout_value} = 2; >+ $sip_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber}, $server ); > $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); > is( substr($patron_status_string, 9, 1), q{Y}, "lost_block_checkout = 2, lost_block_checkout_value = 2 does block checkouts with 2 lost checkouts where only 1 has itemlost = 2" ); > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32684
:
145491
|
145492
|
145493
|
145494
|
145786
|
147883
|
147884
|
147919
|
147920
|
147924
|
147969