# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Mojo::Base 'Mojolicious::Controller';
-use Try::Tiny;
+use Try::Tiny qw( catch try );
use Koha::Checkouts::ReturnClaims;
use Koha::Checkouts;
-use Koha::DateUtils qw( dt_from_string output_pref );
=head1 NAME
openapi => { error => "Mandatory attribute created_by missing" }
);
}
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- if ( $_->isa('Koha::Exceptions::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}
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 {
- my $resolved_by = $body->{resolved_by};
- my $resolution = $body->{resolution};
+ my $resolved_by = $body->{resolved_by};
+ my $resolution = $body->{resolution};
+ my $new_lost_status = $body->{new_lost_status};
my $user = $c->stash('koha.user');
$resolved_by //= $user->borrowernumber;
- $claim->set(
+ $claim->resolve(
{
- resolution => $resolution,
- resolved_by => $resolved_by,
- resolved_on => \'NOW()',
+ resolution => $resolution,
+ resolved_by => $resolved_by,
+ new_lost_status => $new_lost_status,
}
- )->store;
- $claim->discard_changes;
+ )->discard_changes;
return $c->render(
status => 200,
);
}
catch {
- if ( $_->isa('Koha::Exceptions::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- if ( $_->isa('Koha::Exceptions::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}