diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 6cfabeb9b6..6e1e284976 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; @@ -1232,6 +1233,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 4244d8fbe1..c9a1717794 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 908c87c6d6..d17e2ff94b 100644 --- a/etc/SIPconfig.xml +++ b/etc/SIPconfig.xml @@ -77,7 +77,8 @@ show_outstanding_amount="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 4c6fe1326c..878680c277 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");