From 883ee12560f11fc2fbf35c72bbf63520ce0e4762 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 18 Jun 2021 16:34:00 -0300 Subject: [PATCH] Bug 28588: (follow-up) Make the API use the new method This patch adapts the controller method for resolving a return claim so it uses the Koha::Checkouts::ReturnClaim method instead. To test: 1. Run: $ kshell k$ prove t/db_dependent/api/v1/return_claims.t => SUCCESS: Tests pass! 2. Apply this patch 3. Repeat 1 => SUCCESS: Tests pass! 4. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- Koha/REST/V1/ReturnClaims.pm | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Koha/REST/V1/ReturnClaims.pm b/Koha/REST/V1/ReturnClaims.pm index bcc210902a..c9fa833387 100644 --- a/Koha/REST/V1/ReturnClaims.pm +++ b/Koha/REST/V1/ReturnClaims.pm @@ -152,10 +152,8 @@ sub resolve_claim { my $claim = Koha::Checkouts::ReturnClaims->find($claim_id); return $c->render( - status => 404, - openapi => { - error => "Claim not found" - } + status => 404, + openapi => { error => "Claim not found" } ) unless $claim; return try { @@ -167,19 +165,13 @@ sub resolve_claim { my $user = $c->stash('koha.user'); $resolved_by //= $user->borrowernumber; - $claim->set( + $claim->resolve( { - resolution => $resolution, - resolved_by => $resolved_by, - resolved_on => \'NOW()', - updated_by => $resolved_by, + resolution => $resolution, + resolved_by => $resolved_by, + new_lost_status => $new_lost_status, } - )->store; - - if ( defined $new_lost_status ) { - $claim->checkout->item->itemlost($new_lost_status)->store; - } - $claim->discard_changes; + )->discard_changes; return $c->render( status => 200, -- 2.39.5