Browse Source

Bug 28271: Add the ability to set a new lost status when a claim is resolved

When a claim is resolved the librarian should be able to edit the lost
status of the item.

It is also letting a way out when BlockReturnOfLostItems is set (the
lost status is stuck on ClaimReturnedLostValue as we remove the
option to edit itemlost on the item edit form).

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.11.x
Jonathan Druart 1 year ago
parent
commit
58db137c0a
  1. 9
      Koha/REST/V1/ReturnClaims.pm
  2. 9
      koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc
  3. 6
      koha-tmpl/intranet-tmpl/prog/js/checkouts.js
  4. 19
      t/db_dependent/api/v1/return_claims.t

9
Koha/REST/V1/ReturnClaims.pm

@ -160,8 +160,9 @@ sub resolve_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;
@ -174,6 +175,10 @@ sub resolve_claim {
updated_by => $resolved_by,
}
)->store;
if ( defined $new_lost_status ) {
$claim->checkout->item->itemlost($new_lost_status)->store;
}
$claim->discard_changes;
return $c->render(

9
koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc

@ -145,6 +145,15 @@
<option value="[% r.authorised_value | html %]">[% r.lib | html %]</option>
[% END %]
</select>
<label for="new_lost_status">New item lost value:</label>
[% SET itemlost = AuthorisedValues.GetAuthValueDropbox('LOST') %]
<select class="form-control" id="new_lost_status">
<option value="0"></option>
[% FOREACH lost IN itemlost %]
<option value="[% lost.authorised_value | html %]">[% lost.lib | html %]</option>
[% END %]
</select>
</div>
<input type="hidden" id="claims-returned-resolved-modal-id"/>

6
koha-tmpl/intranet-tmpl/prog/js/checkouts.js

@ -1142,14 +1142,16 @@ $(document).ready(function() {
$(document).on('click', '#claims-returned-resolved-modal-btn-submit', function(e) {
let resolution = $('#claims-returned-resolved-modal-resolved-code').val();
let new_lost_status = $('#new_lost_status').val();
let id = $('#claims-returned-resolved-modal-id').val();
$('#claims-returned-resolved-modal-btn-submit-spinner').show();
$('#claims-returned-resolved-modal-btn-submit-icon').hide();
params = {
resolution: resolution,
resolved_by: logged_in_user_borrowernumber
resolution: resolution,
resolved_by: logged_in_user_borrowernumber,
new_lost_status: new_lost_status
};
$.ajax({

19
t/db_dependent/api/v1/return_claims.t

@ -175,7 +175,7 @@ subtest 'update_notes() tests' => sub {
subtest 'resolve_claim() tests' => sub {
plan tests => 9;
plan tests => 13;
$schema->storage->txn_begin;
@ -193,6 +193,10 @@ subtest 'resolve_claim() tests' => sub {
t::lib::Mocks::mock_userenv( { branchcode => $item->homebranch } ); # needed by AddIssue
# Picking 1 that should exist
my $ClaimReturnedLostValue = 1;
t::lib::Mocks::mock_preference('ClaimReturnedLostValue', $ClaimReturnedLostValue);
my $issue = AddIssue( $librarian->unblessed, $item->barcode, dt_from_string->add( weeks => 2 ) );
my $claim = $issue->claim_returned(
@ -225,6 +229,19 @@ subtest 'resolve_claim() tests' => sub {
is( $claim->updated_by, $librarian->id );
ok( $claim->resolved_on );
is( $claim->checkout->item->itemlost, $ClaimReturnedLostValue );
$claim->update({resolution => undef, resolved_by => undef, resolved_on => undef });
$t->put_ok(
"//$userid:$password@/api/v1/return_claims/$claim_id/resolve" => json => {
resolved_by => $librarian->id,
resolution => "FOUNDINLIB",
new_lost_status => 0,
}
)->status_is(200);
is( $claim->get_from_storage->checkout->item->itemlost, 0 );
# Make sure the claim doesn't exist on the DB anymore
$claim->delete;

Loading…
Cancel
Save