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 <tomascohen@theke.io>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Tomás Cohen Arazi 2021-06-18 16:34:00 -03:00 committed by Jonathan Druart
parent 9964bd4b58
commit 883ee12560

View file

@ -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,