From 610818f6cc755a2addf3167071be60501ccbc2c9 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 Signed-off-by: David Nind Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart (cherry picked from commit be719f30e4142e92d23f3a0566eca93f75224fc3) Signed-off-by: Lucas Gass --- 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 340fc67cc3..d5e61362bd 100644 --- a/C4/SIP/ILS/Item.pm +++ b/C4/SIP/ILS/Item.pm @@ -83,10 +83,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; $self->{object} = $item; @@ -257,7 +258,10 @@ sub title_id { sub sip_circulation_status { my $self = shift; - if ( $self->{borrowernumber} ) { + if ( $self->{_object}->get_transfer ) { + return '10'; # in transit between libraries + } + elsif ( $self->{borrowernumber} ) { 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 cb10003c42..a09cd347a5 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; @@ -396,4 +397,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( $status, '10', "Item circulation status is in transit" ); +}; $schema->storage->txn_rollback; -- 2.39.5