@@ -, +, @@
item information request
---
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(-)
--- a/C4/SIP/Sip/MsgType.pm
+++ a/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;
--- a/debian/templates/SIPconfig.xml
+++ a/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">
--- a/etc/SIPconfig.xml
+++ a/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">
--- a/t/db_dependent/SIP/Message.t
+++ a/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");
--