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

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Kyle Hall 2023-04-21 07:09:34 -04:00 committed by Tomas Cohen Arazi
parent 7d9e4cf415
commit fbd4d3a9fe
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
4 changed files with 26 additions and 3 deletions

View file

@ -17,6 +17,7 @@ use C4::SIP::Sip::Checksum qw(verify_cksum);
use Data::Dumper; use Data::Dumper;
use CGI qw ( -utf8 ); use CGI qw ( -utf8 );
use C4::Auth qw(&check_api_auth); use C4::Auth qw(&check_api_auth);
use C4::Items qw(ModDateLastSeen);
use Koha::Patrons; use Koha::Patrons;
use Koha::Patron::Attributes; use Koha::Patron::Attributes;
@ -1232,6 +1233,8 @@ sub handle_item_information {
# title id is required, but we don't have one # title id is required, but we don't have one
$resp .= add_field( FID_TITLE_ID, '', $server ); $resp .= add_field( FID_TITLE_ID, '', $server );
} else { } else {
my $seen = $account->{seen_on_item_information};
ModDateLastSeen( $item->itemnumber, $seen eq 'keep_lost' ) if $seen;
# Valid Item ID, send the good stuff # Valid Item ID, send the good stuff
my $circulation_status = $item->sip_circulation_status; my $circulation_status = $item->sip_circulation_status;

View file

@ -57,7 +57,8 @@
overdues_block_checkout="1" overdues_block_checkout="1"
format_due_date="0" format_due_date="0"
inhouse_item_types="" inhouse_item_types=""
inhouse_patron_categories=""> inhouse_patron_categories=""
seen_on_item_information="mark_found"> <!-- could be "keep_lost", empty to disable -->
<screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" /> <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
<screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" /> <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
</login> </login>

View file

@ -77,7 +77,8 @@
show_outstanding_amount="1" show_outstanding_amount="1"
format_due_date="0" format_due_date="0"
inhouse_item_types="" inhouse_item_types=""
inhouse_patron_categories=""> inhouse_patron_categories=""
seen_on_item_information="mark_found"> <!-- could be "keep_lost", empty to disable -->
<!-- lost_block_checkout sets flag if patron has more than the given current checkouts that are lost ( itemlost > 0 by default ) --> <!-- lost_block_checkout sets flag if patron has more than the given current checkouts that are lost ( itemlost > 0 by default ) -->
<!-- lost_block_checkout_value determines the minimum lost item value to count ( that is, the value in items.itemlost ) --> <!-- lost_block_checkout_value determines the minimum lost item value to count ( that is, the value in items.itemlost ) -->
<!-- Refer to syspref SIP2SortBinMapping for full explanation of sort bin mapping --> <!-- Refer to syspref SIP2SortBinMapping for full explanation of sort bin mapping -->

View file

@ -380,7 +380,7 @@ subtest "Test build_custom_field_string" => sub {
}; };
subtest "Test cr_item_field" => sub { subtest "Test cr_item_field" => sub {
plan tests => 3; plan tests => 8;
my $builder = t::lib::TestBuilder->new(); my $builder = t::lib::TestBuilder->new();
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
@ -405,6 +405,7 @@ subtest "Test cr_item_field" => sub {
restricted => 0, restricted => 0,
homebranch => $branchcode, homebranch => $branchcode,
holdingbranch => $branchcode, holdingbranch => $branchcode,
datelastseen => '1900-01-01',
}); });
my $mockILS = $mocks->{ils}; my $mockILS = $mocks->{ils};
@ -448,7 +449,24 @@ subtest "Test cr_item_field" => sub {
$server->{account}->{cr_item_field} = 'itype'; $server->{account}->{cr_item_field} = 'itype';
$server->{account}->{seen_on_item_information} = '';
$msg->handle_item_information( $server ); $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; my $itype = $item_object->itype;
ok( $response =~ m/CR$itype/, "Found correct CR field in response"); ok( $response =~ m/CR$itype/, "Found correct CR field in response");