From 785efd98fd99697b136a035e1d6abc7a18b233bd Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 1 May 2020 12:04:37 -0400 Subject: [PATCH] Bug 25344: Add support for circulation status 10 ( item in transit ) We should support the SIP2 "circulation status" value 10, "in transit between library locations" Test Plan: 1) Apply this patch 2) prove t/db_dependent/SIP/Transaction.t --- C4/SIP/ILS/Item.pm | 14 +++++++---- t/db_dependent/SIP/Transaction.t | 43 +++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/C4/SIP/ILS/Item.pm b/C4/SIP/ILS/Item.pm index 37c9c6986a..13440ad702 100644 --- a/C4/SIP/ILS/Item.pm +++ b/C4/SIP/ILS/Item.pm @@ -82,10 +82,11 @@ sub new { return; } my $self = $item->unblessed; - $self->{ 'id' } = $item->barcode; # to SIP, the barcode IS the id. - $self->{permanent_location}= $item->homebranch; - $self->{'collection_code'} = $item->ccode; - $self->{ 'call_number' } = $item->itemcallnumber; + $self->{_object} = $item; + $self->{id} = $item->barcode; # to SIP, the barcode IS the id. + $self->{permanent_location} = $item->homebranch; + $self->{collection_code} = $item->ccode; + $self->{call_number} = $item->itemcallnumber; my $it = $item->effective_itemtype; my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it ); @@ -254,7 +255,10 @@ sub title_id { sub sip_circulation_status { my $self = shift; - if ( $self->{patron} ) { + if ( $self->{_object}->get_transfer ) { + return '10'; # in transit between libraries + } + elsif ( $self->{patron} ) { return '04'; # charged } elsif ( grep { $_->{itemnumber} == $self->{itemnumber} } @{ $self->{hold_shelf} } ) { diff --git a/t/db_dependent/SIP/Transaction.t b/t/db_dependent/SIP/Transaction.t index 6c38ecad49..786d6d9483 100755 --- a/t/db_dependent/SIP/Transaction.t +++ b/t/db_dependent/SIP/Transaction.t @@ -4,7 +4,7 @@ # Current state is very rudimentary. Please help to extend it! use Modern::Perl; -use Test::More tests => 10; +use Test::More tests => 11; use Koha::Database; use t::lib::TestBuilder; @@ -20,6 +20,7 @@ use C4::SIP::ILS::Transaction::Checkin; use C4::Reserves; use Koha::CirculationRules; +use Koha::Item::Transfer; use Koha::DateUtils qw( dt_from_string output_pref ); my $schema = Koha::Database->new->schema; @@ -394,4 +395,44 @@ subtest checkin_withdrawn => sub { $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp ); is( $circ->{screen_msg}, 'Item not checked out', "Got 'Item not checked out' screen message" ); }; + +subtest item_circulation_status => sub { + plan tests => 2; + + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); + + my $patron = $builder->build_object( + { + class => 'Koha::Patrons', + value => { + branchcode => $library->branchcode, + } + } + ); + + t::lib::Mocks::mock_userenv( + { branchcode => $library->branchcode, flags => 1 } ); + + my $item = $builder->build_sample_item( + { + library => $library->branchcode, + } + ); + + my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); + my $status = $sip_item->sip_circulation_status; + is( $status, '03', "Item circulation status is available"); + + my $transfer = Koha::Item::Transfer->new({ + itemnumber => $item->id, + datesent => '2020-01-01', + frombranch => $library->branchcode, + tobranch => $library2->branchcode, + })->store(); + + $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); + $status = $sip_item->sip_circulation_status; + is( '10', '10', "Item circulation status is in transit" ); +}; $schema->storage->txn_rollback; -- 2.24.2 (Apple Git-127)