From 6ff8343661a86be1e80231340c1cdd779e4a78ca Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 21 Apr 2023 07:09:34 -0400 Subject: [PATCH] Bug 33580 - Bring back ability to mark item as seen via SIP2 item information request Prior to Koha 22.05, the SIP2 item information message had a side affect of updating the datelastseen field for items. This bug has been fixed, but was being utilized by inventory tools that used SIP2. We should bring back this affect and formalize it as an optional SIP2 config account setting. Test Plan: 1) Apply this patch set 2) prove t/db_dependent/SIP/Message.t --- C4/SIP/Sip/MsgType.pm | 3 +++ debian/templates/SIPconfig.xml | 3 ++- etc/SIPconfig.xml | 3 ++- t/db_dependent/SIP/Message.t | 20 +++++++++++++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 3510683d84f..e9fc96d7414 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -17,6 +17,7 @@ use C4::SIP::Sip::Checksum qw(verify_cksum); use Data::Dumper; use CGI qw ( -utf8 ); use C4::Auth qw(&check_api_auth); +use C4::Items qw(ModDateLastSeen); use Koha::Patrons; use Koha::Patron::Attributes; @@ -1231,6 +1232,8 @@ sub handle_item_information { # title id is required, but we don't have one $resp .= add_field( FID_TITLE_ID, '', $server ); } else { + my $seen = $account->{seen_on_item_information}; + ModDateLastSeen( $item->itemnumber, $seen eq 'keep_lost' ) if $seen; # Valid Item ID, send the good stuff my $circulation_status = $item->sip_circulation_status; diff --git a/debian/templates/SIPconfig.xml b/debian/templates/SIPconfig.xml index 4244d8fbe16..c9a1717794e 100644 --- a/debian/templates/SIPconfig.xml +++ b/debian/templates/SIPconfig.xml @@ -57,7 +57,8 @@ overdues_block_checkout="1" format_due_date="0" inhouse_item_types="" - inhouse_patron_categories=""> + inhouse_patron_categories="" + seen_on_item_information="mark_found"> diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml index d64586b209c..c5f3b31dc4c 100644 --- a/etc/SIPconfig.xml +++ b/etc/SIPconfig.xml @@ -76,7 +76,8 @@ overdues_block_checkout="1" format_due_date="0" inhouse_item_types="" - inhouse_patron_categories=""> + inhouse_patron_categories="" + seen_on_item_information="mark_found"> diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t index 4c6fe1326c3..878680c277d 100755 --- a/t/db_dependent/SIP/Message.t +++ b/t/db_dependent/SIP/Message.t @@ -380,7 +380,7 @@ subtest "Test build_custom_field_string" => sub { }; subtest "Test cr_item_field" => sub { - plan tests => 3; + plan tests => 8; my $builder = t::lib::TestBuilder->new(); my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; @@ -405,6 +405,7 @@ subtest "Test cr_item_field" => sub { restricted => 0, homebranch => $branchcode, holdingbranch => $branchcode, + datelastseen => '1900-01-01', }); my $mockILS = $mocks->{ils}; @@ -448,7 +449,24 @@ subtest "Test cr_item_field" => sub { $server->{account}->{cr_item_field} = 'itype'; + $server->{account}->{seen_on_item_information} = ''; + $msg->handle_item_information( $server ); + $item_object->get_from_storage; + is( $item_object->datelastseen, "1900-01-01", "datelastseen remains unchanged" ); + + $item_object->update({ itemlost => 1, datelastseen => '1900-01-01' }); + $server->{account}->{seen_on_item_information} = 'keep_lost'; + $msg->handle_item_information( $server ); + $item_object = Koha::Items->find( $item_object->id ); + isnt( $item_object->datelastseen, "1900-01-01", "datelastseen updated" ); + is( $item_object->itemlost, 1, "item remains lost" ); + + $item_object->update({ itemlost => 1, datelastseen => '1900-01-01' }); + $server->{account}->{seen_on_item_information} = 'mark_found'; $msg->handle_item_information( $server ); + $item_object = Koha::Items->find( $item_object->id ); + isnt( $item_object->datelastseen, "1900-01-01", "datelastseen updated" ); + is( $item_object->itemlost, 0, "item is no longer lost" ); my $itype = $item_object->itype; ok( $response =~ m/CR$itype/, "Found correct CR field in response"); -- 2.30.2