View | Details | Raw Unified | Return to bug 28271
Collapse All | Expand All

(-)a/Koha/REST/V1/ReturnClaims.pm (-2 / +7 lines)
Lines 160-167 sub resolve_claim { Link Here
160
160
161
    return try {
161
    return try {
162
162
163
        my $resolved_by = $body->{resolved_by};
163
        my $resolved_by     = $body->{resolved_by};
164
        my $resolution  = $body->{resolution};
164
        my $resolution      = $body->{resolution};
165
        my $new_lost_status = $body->{new_lost_status};
165
166
166
        my $user = $c->stash('koha.user');
167
        my $user = $c->stash('koha.user');
167
        $resolved_by //= $user->borrowernumber;
168
        $resolved_by //= $user->borrowernumber;
Lines 174-179 sub resolve_claim { Link Here
174
                updated_by  => $resolved_by,
175
                updated_by  => $resolved_by,
175
            }
176
            }
176
        )->store;
177
        )->store;
178
179
        if ( defined $new_lost_status ) {
180
            $claim->checkout->item->itemlost($new_lost_status)->store;
181
        }
177
        $claim->discard_changes;
182
        $claim->discard_changes;
178
183
179
        return $c->render(
184
        return $c->render(
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc (+9 lines)
Lines 145-150 Link Here
145
                  <option value="[% r.authorised_value | html %]">[% r.lib | html %]</option>
145
                  <option value="[% r.authorised_value | html %]">[% r.lib | html %]</option>
146
              [% END %]
146
              [% END %]
147
            </select>
147
            </select>
148
149
            <label for="new_lost_status">New item lost value:</label>
150
            [% SET itemlost = AuthorisedValues.GetAuthValueDropbox('LOST') %]
151
            <select class="form-control" id="new_lost_status">
152
              <option value="0"></option>
153
              [% FOREACH lost IN itemlost %]
154
                  <option value="[% lost.authorised_value | html %]">[% lost.lib | html %]</option>
155
              [% END %]
156
            </select>
148
          </div>
157
          </div>
149
158
150
          <input type="hidden" id="claims-returned-resolved-modal-id"/>
159
          <input type="hidden" id="claims-returned-resolved-modal-id"/>
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-2 / +4 lines)
Lines 1142-1155 $(document).ready(function() { Link Here
1142
1142
1143
    $(document).on('click', '#claims-returned-resolved-modal-btn-submit', function(e) {
1143
    $(document).on('click', '#claims-returned-resolved-modal-btn-submit', function(e) {
1144
        let resolution = $('#claims-returned-resolved-modal-resolved-code').val();
1144
        let resolution = $('#claims-returned-resolved-modal-resolved-code').val();
1145
        let new_lost_status = $('#new_lost_status').val();
1145
        let id = $('#claims-returned-resolved-modal-id').val();
1146
        let id = $('#claims-returned-resolved-modal-id').val();
1146
1147
1147
        $('#claims-returned-resolved-modal-btn-submit-spinner').show();
1148
        $('#claims-returned-resolved-modal-btn-submit-spinner').show();
1148
        $('#claims-returned-resolved-modal-btn-submit-icon').hide();
1149
        $('#claims-returned-resolved-modal-btn-submit-icon').hide();
1149
1150
1150
        params = {
1151
        params = {
1151
          resolution:  resolution,
1152
            resolution: resolution,
1152
          resolved_by: logged_in_user_borrowernumber
1153
            resolved_by: logged_in_user_borrowernumber,
1154
            new_lost_status: new_lost_status
1153
        };
1155
        };
1154
1156
1155
        $.ajax({
1157
        $.ajax({
(-)a/t/db_dependent/api/v1/return_claims.t (-2 / +18 lines)
Lines 175-181 subtest 'update_notes() tests' => sub { Link Here
175
175
176
subtest 'resolve_claim() tests' => sub {
176
subtest 'resolve_claim() tests' => sub {
177
177
178
    plan tests => 9;
178
    plan tests => 13;
179
179
180
    $schema->storage->txn_begin;
180
    $schema->storage->txn_begin;
181
181
Lines 193-198 subtest 'resolve_claim() tests' => sub { Link Here
193
193
194
    t::lib::Mocks::mock_userenv( { branchcode => $item->homebranch } ); # needed by AddIssue
194
    t::lib::Mocks::mock_userenv( { branchcode => $item->homebranch } ); # needed by AddIssue
195
195
196
    # Picking 1 that should exist
197
    my $ClaimReturnedLostValue = 1;
198
    t::lib::Mocks::mock_preference('ClaimReturnedLostValue', $ClaimReturnedLostValue);
199
196
    my $issue = AddIssue( $librarian->unblessed, $item->barcode, dt_from_string->add( weeks => 2 ) );
200
    my $issue = AddIssue( $librarian->unblessed, $item->barcode, dt_from_string->add( weeks => 2 ) );
197
201
198
    my $claim = $issue->claim_returned(
202
    my $claim = $issue->claim_returned(
Lines 225-230 subtest 'resolve_claim() tests' => sub { Link Here
225
    is( $claim->updated_by, $librarian->id );
229
    is( $claim->updated_by, $librarian->id );
226
    ok( $claim->resolved_on );
230
    ok( $claim->resolved_on );
227
231
232
    is( $claim->checkout->item->itemlost, $ClaimReturnedLostValue );
233
234
    $claim->update({resolution => undef, resolved_by => undef, resolved_on => undef });
235
    $t->put_ok(
236
        "//$userid:$password@/api/v1/return_claims/$claim_id/resolve" => json => {
237
            resolved_by => $librarian->id,
238
            resolution  => "FOUNDINLIB",
239
            new_lost_status => 0,
240
        }
241
    )->status_is(200);
242
    is( $claim->get_from_storage->checkout->item->itemlost, 0 );
243
244
228
    # Make sure the claim doesn't exist on the DB anymore
245
    # Make sure the claim doesn't exist on the DB anymore
229
    $claim->delete;
246
    $claim->delete;
230
247
231
- 

Return to bug 28271