From 71b2f602b01a1b25b0175909c24b950a712ec4e9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 22 May 2017 12:02:20 -0300 Subject: [PATCH] Bug 18651: Update issue_id in AddReturn Content-Type: text/plain; charset=utf-8 1. AddReturn returns a $issue hashref with the old issue_id value => At first glance it does not affect anything, but would be good to fix it for future uses. Signed-off-by: Kyle M Hall Signed-off-by: Chris Cormack Signed-off-by: Marcel de Rooy --- C4/Circulation.pm | 5 ++++- t/db_dependent/Circulation/Returns.t | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index a439021..41f6c70 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1939,8 +1939,9 @@ sub AddReturn { } eval { - MarkIssueReturned( $borrowernumber, $item->{'itemnumber'}, + my $issue_id = MarkIssueReturned( $borrowernumber, $item->{'itemnumber'}, $circControlBranch, $return_date, $borrower->{'privacy'} ); + $issue->{issue_id} = $issue_id; }; if ( $@ ) { $messages->{'Wrongbranch'} = { @@ -2205,6 +2206,8 @@ sub MarkIssueReturned { $item->last_returned_by( $patron ); } }); + + return $issue_id; } =head2 _debar_user_on_return diff --git a/t/db_dependent/Circulation/Returns.t b/t/db_dependent/Circulation/Returns.t index de7bf64..fe98452 100644 --- a/t/db_dependent/Circulation/Returns.t +++ b/t/db_dependent/Circulation/Returns.t @@ -263,7 +263,7 @@ subtest "AddReturn logging on statistics table (item-level_itypes=0)" => sub { }; subtest 'Handle ids duplication' => sub { - plan tests => 1; + plan tests => 2; my $biblio = $builder->build( { source => 'Biblio' } ); my $item = $builder->build( @@ -283,8 +283,10 @@ subtest 'Handle ids duplication' => sub { my $checkout = AddIssue( $patron, $item->{barcode} ); $builder->build({ source => 'OldIssue', value => { issue_id => $checkout->issue_id } }); - my @a = AddReturn( $item->{barcode} ); + my ($doreturn, $messages, $issue, $borrower) = AddReturn( $item->{barcode} ); my $old_checkout = Koha::Old::Checkouts->find( $checkout->issue_id ); + + isnt( $checkout->issue_id, $issue->{issue_id}, 'AddReturn should return the issue with the new issue_id' ); isnt( $old_checkout->itemnumber, $item->{itemnumber}, 'If an item is checked-in, it should be moved to old_issues even if the issue_id already existed in the table' ); }; -- 2.1.4