From f270020500ef4956c73c2b9630d70e32ebae6921 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 28 Jul 2017 10:29:51 +0200 Subject: [PATCH] Bug 18996: [16.11.x] Handle data corruption from old_issues at SIP checkin As per bug 18966 AddReturn returns false with a DataCorrupted message when the issue_id at hand already occurs in the old_issues table. This should be handled when returning an item via SIP too. SIP should not pretend that the checkin was successful, since this item needs special care. The following six different situations are handled: [1] An attempt to checkin an invalid barcode is handled as before. The ok flag is false; the screen message shows 'Invalid Item'. [2] We receive a DataCorrupted message: the alert type is set to the unused 98 code to indicate this new error condition. The ok flag is false; the screen message shows 'Checkin failed: data problem'. [3] The item checked in was not checked out AND the option checked_in_ok is active. The ok flag is set to true; no screen message. [4] The item checked in was not checked out AND the option checked_in_ok is not active. The ok flag is not changed (normally false); the screen message shows 'Item not checked out'. [5] (The regular checkin) The item was checked out and AddReturn returned true. The ok flag is true; no screen message. [6] ("Otherwise") The item was checked out, but AddReturn returned false. The ok flag is false; the screen message shows 'Checkin failed'. Note: Currently this case only refers to the Wrongbranch and withdrawn messages from AddReturn (where doreturn==0). Note: Situation 1 and 5 are unchanged. Behavior is slightly changed for situation 3 and 4; the option is only used when the item was not checked out. Situation 2 and situation 6 are changed. After bug 18966 SIP returned OK in case of data corruption (while checkin failed). In the remaining cases under [6] SIP also returned OK while checkin failed. Test plan: [1] Test all six cases listed above. In order to simulate data corruption insert the issue_id at hand in old_issues before you check in. In cases 3 and 4 you need to toggle the option in your SIPconfig.xml and restart the SIP server. Case 6 can be tested by checking out at branch A, adjusting the value of pref AllowReturnToBranch and checking in at branch B. Signed-off-by: Marcel de Rooy Signed-off-by: Colin Campbell Signed-off-by: Kyle M Hall --- C4/SIP/ILS.pm | 37 +++++++++++++++++-------------- C4/SIP/ILS/Transaction/Checkin.pm | 4 +++- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index 7a40777af3..b3816f49ec 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -211,29 +211,32 @@ sub checkin { else { $circ->alert(1); $circ->alert_type(99); + $circ->ok( 0 ); $circ->screen_msg('Invalid Item'); + return $circ; } - # It's ok to check it in if it exists, and if it was checked out - # or it was not checked out but the checked_in_ok flag was set - $circ->ok( ( $checked_in_ok && $item ) || ( $item && $item->{patron} ) ); - syslog("LOG_DEBUG", "C4::SIP::ILS::checkin - using checked_in_ok") if $checked_in_ok; - - if ( !defined( $item->{patron} ) ) { - $circ->screen_msg("Item not checked out") unless $checked_in_ok; - syslog("LOG_DEBUG", "C4::SIP::ILS::checkin - item not checked out"); - } - else { - if ( $circ->ok ) { - $circ->patron( $patron = C4::SIP::ILS::Patron->new( $item->{patron} ) ); - delete $item->{patron}; - delete $item->{due_date}; - $patron->{items} = [ grep { $_ ne $item_id } @{ $patron->{items} } ]; + if( !$circ->ok && $circ->alert_type && $circ->alert_type == 98 ) { # data corruption + $circ->screen_msg("Checkin failed: data problem"); + syslog( "LOG_WARNING", "Problem with issue_id in issues and old_issues; check the about page" ); + } elsif( !$item->{patron} ) { + if( $checked_in_ok ) { # Mark checkin ok although book not checked out + $circ->ok( 1 ); + syslog("LOG_DEBUG", "C4::SIP::ILS::Checkin - using checked_in_ok"); + } else { + $circ->screen_msg("Item not checked out"); + syslog("LOG_DEBUG", "C4::SIP::ILS::Checkin - item not checked out"); } + } elsif( $circ->ok ) { + $circ->patron( $patron = C4::SIP::ILS::Patron->new( $item->{patron} ) ); + delete $item->{patron}; + delete $item->{due_date}; + $patron->{items} = [ grep { $_ ne $item_id } @{ $patron->{items} } ]; + } else { + $circ->screen_msg("Checkin failed"); + syslog( "LOG_WARNING", "Checkin failed: probably for Wrongbranch or withdrawn" ); } - # END TRANSACTION - return $circ; } diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm index 19c82e9a63..1e138bcf6e 100644 --- a/C4/SIP/ILS/Transaction/Checkin.pm +++ b/C4/SIP/ILS/Transaction/Checkin.pm @@ -72,7 +72,9 @@ sub do_checkin { # biblionumber, biblioitemnumber, itemnumber # borrowernumber, reservedate, branchcode # cancellationdate, found, reservenotes, priority, timestamp - + if( $messages->{DataCorrupted} ) { + $self->alert_type('98'); + } if ($messages->{BadBarcode}) { $self->alert_type('99'); } -- 2.39.5