From 286a7c72637ecc4be162aa8c9231c9e723cc4e9e Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 19 Nov 2024 16:10:14 +0000 Subject: [PATCH] Bug 38486: For SIP allow noblock checkouts reguardless of normal patron checkout blocks The purpose of no block checkouts in SIP is to indicate that the SIP machine has made an offline ( "store and forward" ) transaction. The patron already has the item. As such, the item must be checked out to the patron or the library risks losing the item do to lack of tracking. As such, no block checkouts should not be blocked under any circumstances. The sub C4::SIP::ILS::Transaction::Checkout::do_checkout already honors this, but it is wrapped by C4::SIP::ILS::checkout which has additional checks that do not. Test Plan: 1) Apply the unit test patch 2) prove t/db_dependent/SIP/Transaction.t will fail 3) Apply the second patch 4) prove t/db_dependent/SIP/Transaction.t will pass! --- C4/SIP/ILS.pm | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index 3e77abf6023..c84a0d7e4b2 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -132,12 +132,36 @@ sub checkout { # BEGIN TRANSACTION $circ->patron( $patron = C4::SIP::ILS::Patron->new($patron_id) ); $circ->item( $item = C4::SIP::ILS::Item->new($item_id) ); + if ($fee_ack) { $circ->fee_ack($fee_ack); } + if ( !$patron ) { $circ->screen_msg("Invalid Patron"); } + elsif ( !$item ) { + $circ->screen_msg("Invalid Item"); + } + elsif ( $no_block_due_date ) { + # A no block due date means we need check this item out to the patron + # regardless if fines, restrictions or any other things that would + # typically prevent a patron from checking out. + # A no block transaction is used for send offline ( store and forward ) + # transaction to Koha. The patron already has possesion of the item + # so it should be checked out to the patron no matter what. + $circ->do_checkout( $account, $no_block_due_date ); + + $item->{borrowernumber} = $patron_id; + $item->{due_date} = $circ->{due}; + push( @{ $patron->{items} }, { barcode => $item_id } ); + $circ->desensitize( !$item->magnetic_media ); + + siplog( + "LOG_DEBUG", "ILS::Checkout: patron %s has checked out %s via a no block checkout", + $patron_id, join( ', ', map { $_->{barcode} } @{ $patron->{items} } ) + ); + } elsif ( !$patron->charge_ok ) { if ($patron->debarred) { $circ->screen_msg("Patron debarred"); @@ -157,9 +181,6 @@ sub checkout { $circ->screen_msg("Patron blocked"); } } - elsif ( !$item ) { - $circ->screen_msg("Invalid Item"); - } elsif ( $item->{borrowernumber} && !_ci_cardnumber_cmp( $item->{borrowernumber}, $patron->borrowernumber ) ) { @@ -169,7 +190,9 @@ sub checkout { $circ->screen_msg("Item type cannot be checked out at this checkout location"); } else { - $circ->do_checkout($account, $no_block_due_date); + # No block checkouts were handled earlier so there is no need + # to bass the no block due date here. + $circ->do_checkout($account); if ( $circ->ok ) { # If the item is already associated with this patron, then -- 2.39.5 (Apple Git-154)