From 9b3bb4d5123a1afdafb779f329a98e596c755940 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 1 May 2020 12:16:48 -0400 Subject: [PATCH] Bug 25347: Add support for circulation status 11 ( claimed returned ) Now that we have return claims in Koha, we should support the SIP2 "circulation status" value 11, "claimed returned". 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 ca44a3f2ca82371bd6a2d731b7b4fd185d9fd93a) Signed-off-by: Lucas Gass --- C4/SIP/ILS/Item.pm | 16 ++++++++++------ t/db_dependent/SIP/Transaction.t | 16 +++++++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/C4/SIP/ILS/Item.pm b/C4/SIP/ILS/Item.pm index d5e61362bd..0950864aa2 100644 --- a/C4/SIP/ILS/Item.pm +++ b/C4/SIP/ILS/Item.pm @@ -16,20 +16,21 @@ use Template; use C4::SIP::ILS::Transaction; use C4::SIP::Sip qw(add_field); -use C4::Debug; -use C4::Context; use C4::Biblio; -use C4::Items; use C4::Circulation; +use C4::Context; +use C4::Debug; +use C4::Items; use C4::Members; use C4::Reserves; -use Koha::Database; use Koha::Biblios; +use Koha::Checkouts::ReturnClaims; use Koha::Checkouts; +use Koha::Database; use Koha::DateUtils; -use Koha::Patrons; -use Koha::Items; use Koha::Holds; +use Koha::Items; +use Koha::Patrons; =encoding UTF-8 @@ -261,6 +262,9 @@ sub sip_circulation_status { if ( $self->{_object}->get_transfer ) { return '10'; # in transit between libraries } + elsif ( Koha::Checkouts::ReturnClaims->search({ itemnumber => $self->{_object}->id, resolution => undef })->count ) { + return '11'; # claimed returned + } elsif ( $self->{borrowernumber} ) { return '04'; # charged } diff --git a/t/db_dependent/SIP/Transaction.t b/t/db_dependent/SIP/Transaction.t index a09cd347a5..770bcc1a14 100755 --- a/t/db_dependent/SIP/Transaction.t +++ b/t/db_dependent/SIP/Transaction.t @@ -399,7 +399,7 @@ subtest checkin_withdrawn => sub { }; subtest item_circulation_status => sub { - plan tests => 2; + plan tests => 3; my $library = $builder->build_object( { class => 'Koha::Libraries' } ); my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); @@ -436,5 +436,19 @@ subtest item_circulation_status => sub { $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); $status = $sip_item->sip_circulation_status; is( $status, '10', "Item circulation status is in transit" ); + + $transfer->delete; + + my $claim = Koha::Checkouts::ReturnClaim->new({ + itemnumber => $item->id, + borrowernumber => $patron->id, + created_by => $patron->id, + })->store(); + + $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); + $status = $sip_item->sip_circulation_status; + is( $status, '11', "Item circulation status is claimed returned" ); + + $claim->delete; }; $schema->storage->txn_rollback; -- 2.39.5