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;
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} } ) {
# 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;
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;
$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;