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

(-)a/C4/Accounts.pm (-1 / +6 lines)
Lines 70-76 FIXME : if no replacement price, borrower just doesn't get charged? Link Here
70
sub chargelostitem {
70
sub chargelostitem {
71
    my $dbh = C4::Context->dbh();
71
    my $dbh = C4::Context->dbh();
72
    my ($borrowernumber, $itemnumber, $amount, $description) = @_;
72
    my ($borrowernumber, $itemnumber, $amount, $description) = @_;
73
    my $itype = Koha::ItemTypes->find({ itemtype => Koha::Items->find($itemnumber)->effective_itemtype() });
73
    my $item  = Koha::Items->find($itemnumber);
74
    my $itype = Koha::ItemTypes->find({ itemtype => $item->effective_itemtype() });
74
    my $replacementprice = $amount;
75
    my $replacementprice = $amount;
75
    my $defaultreplacecost = $itype->defaultreplacecost;
76
    my $defaultreplacecost = $itype->defaultreplacecost;
76
    my $processfee = $itype->processfee;
77
    my $processfee = $itype->processfee;
Lines 80-85 sub chargelostitem { Link Here
80
        $replacementprice = $defaultreplacecost;
81
        $replacementprice = $defaultreplacecost;
81
    }
82
    }
82
    my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber });
83
    my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber });
84
    if ( !$checkout && $item->in_bundle ) {
85
        my $host = $item->bundle_host;
86
        $checkout = $host->checkout;
87
    }
83
    my $issue_id = $checkout ? $checkout->issue_id : undef;
88
    my $issue_id = $checkout ? $checkout->issue_id : undef;
84
89
85
    my $account = Koha::Account->new({ patron_id => $borrowernumber });
90
    my $account = Koha::Account->new({ patron_id => $borrowernumber });
(-)a/Koha/Item.pm (-1 / +15 lines)
Lines 417-422 sub checkout { Link Here
417
    return Koha::Checkout->_new_from_dbic( $checkout_rs );
417
    return Koha::Checkout->_new_from_dbic( $checkout_rs );
418
}
418
}
419
419
420
=head3 return_claims
421
422
  my $return_claims = $item->return_claims;
423
424
Return any return_claims associated with this item
425
426
=cut
427
428
sub return_claims {
429
    my ( $self, $params, $attrs ) = @_;
430
    my $claims_rs = $self->_result->return_claims->search($params, $attrs);
431
    return Koha::Checkouts::ReturnClaims->_new_from_dbic( $claims_rs );
432
}
433
420
=head3 holds
434
=head3 holds
421
435
422
my $holds = $item->holds();
436
my $holds = $item->holds();
Lines 1090-1096 Internal function, not exported, called only by Koha::Item->store. Link Here
1090
sub _set_found_trigger {
1104
sub _set_found_trigger {
1091
    my ( $self, $pre_mod_item ) = @_;
1105
    my ( $self, $pre_mod_item ) = @_;
1092
1106
1093
    ## If item was lost, it has now been found, reverse any list item charges if necessary.
1107
    # Reverse any lost item charges if necessary.
1094
    my $no_refund_after_days =
1108
    my $no_refund_after_days =
1095
      C4::Context->preference('NoRefundOnLostReturnedItemsAge');
1109
      C4::Context->preference('NoRefundOnLostReturnedItemsAge');
1096
    if ($no_refund_after_days) {
1110
    if ($no_refund_after_days) {
(-)a/circ/returns.pl (-37 / +72 lines)
Lines 391-433 if ($barcode) { Link Here
391
            }
391
            }
392
        }
392
        }
393
393
394
        # Mark missing bundle items as lost and report unexpected items
395
        if ( $item->is_bundle ) {
396
            my $BundleLostValue = C4::Context->preference('BundleLostValue');
397
            my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
398
            my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
399
            my $expected_items = { map { $_->barcode => $_ } $item->bundle_items->as_list };
400
            my $verify_items = Koha::Items->search( { barcode => { 'in' => \@barcodes } } );
401
            my @unexpected_items;
402
            my @missing_items;
403
            my @bundle_items;
404
            while ( my $verify_item = $verify_items->next ) {
405
                # Fix and lost statuses
406
                $verify_item->itemlost(0);
407
408
                # Expected item, remove from lookup table
409
                if ( delete $expected_items->{$verify_item->barcode} ) {
410
                    push @bundle_items, $verify_item;
411
                }
412
                # Unexpected item, warn and remove from bundle
413
                else {
414
                    $verify_item->remove_from_bundle;
415
                    push @unexpected_items, $verify_item;
416
                }
417
                # Store results
418
                $verify_item->store();
419
            }
420
            for my $missing_item ( keys %{$expected_items} ) {
421
                my $bundle_item = $expected_items->{$missing_item};
422
                $bundle_item->itemlost($BundleLostValue)->store();
423
                push @missing_items, $bundle_item;
424
            }
425
            $template->param(
426
                unexpected_items => \@unexpected_items,
427
                missing_items    => \@missing_items,
428
                bundle_items     => \@bundle_items
429
            );
430
        }
431
    } elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} and !$needs_confirm and !$bundle_confirm ) {
394
    } elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} and !$needs_confirm and !$bundle_confirm ) {
432
        $input{duedate}   = 0;
395
        $input{duedate}   = 0;
433
        $returneditems{0} = $barcode;
396
        $returneditems{0} = $barcode;
Lines 445-450 if ($barcode) { Link Here
445
            items_bundle_return_confirmation => 1,
408
            items_bundle_return_confirmation => 1,
446
        );
409
        );
447
    }
410
    }
411
412
    # Mark missing bundle items as lost and report unexpected items
413
    if ( $item->is_bundle && $query->param('confirm_items_bundle_return') ) {
414
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
415
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
416
        my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
417
        my $expected_items = { map { $_->barcode => $_ } $item->bundle_items->as_list };
418
        my $verify_items = Koha::Items->search( { barcode => { 'in' => \@barcodes } } );
419
        my @unexpected_items;
420
        my @missing_items;
421
        my @bundle_items;
422
        while ( my $verify_item = $verify_items->next ) {
423
            # Fix and lost statuses
424
            $verify_item->itemlost(0);
425
426
            # Update last_seen
427
            $verify_item->datelastseen( dt_from_string()->ymd() );
428
429
            # Update last_borrowed if actual checkin
430
            $verify_item->datelastborrowed( dt_from_string()->ymd() ) if $issue;
431
432
            # Expected item, remove from lookup table
433
            if ( delete $expected_items->{$verify_item->barcode} ) {
434
                push @bundle_items, $verify_item;
435
            }
436
            # Unexpected item, warn and remove from bundle
437
            else {
438
                $verify_item->remove_from_bundle;
439
                push @unexpected_items, $verify_item;
440
            }
441
442
            # Store results
443
            $verify_item->store();
444
        }
445
        for my $missing_item ( keys %{$expected_items} ) {
446
            my $bundle_item = $expected_items->{$missing_item};
447
            $bundle_item->itemlost($BundleLostValue)->store();
448
            # Add return_claim record if this is an actual checkin
449
            if ($issue) {
450
                $bundle_item->_result->create_related(
451
                    'return_claims',
452
                    {
453
                        issue_id       => $issue->issue_id,
454
                        itemnumber     => $bundle_item->itemnumber,
455
                        borrowernumber => $issue->borrowernumber,
456
                        created_by     => C4::Context->userenv()->{number},
457
                        created_on     => dt_from_string
458
                    }
459
                );
460
            }
461
            push @missing_items, $bundle_item;
462
            # NOTE: We cannot use C4::LostItem here because the item itself doesn't have a checkout
463
            # and thus would not get charged.. it's checked out as part of the bundle.
464
            if ( C4::Context->preference('WhenLostChargeReplacementFee') && $issue ) {
465
                C4::Accounts::chargelostitem(
466
                    $issue->borrowernumber,
467
                    $bundle_item->itemnumber,
468
                    $bundle_item->replacementprice,
469
                    sprintf( "%s %s %s",
470
                        $bundle_item->biblio->title  || q{},
471
                        $bundle_item->barcode        || q{},
472
                        $bundle_item->itemcallnumber || q{},
473
                    ),
474
                );
475
            }
476
        }
477
        $template->param(
478
            unexpected_items => \@unexpected_items,
479
            missing_items    => \@missing_items,
480
            bundle_items     => \@bundle_items
481
        );
482
    }
448
}
483
}
449
$template->param( inputloop => \@inputloop );
484
$template->param( inputloop => \@inputloop );
450
485
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (+2 lines)
Lines 115-120 Link Here
115
                            [% ELSE %]
115
                            [% ELSE %]
116
                                [% IF subfield.IS_LOST_AV && Koha.Preference("ClaimReturnedLostValue") && aval == Koha.Preference("ClaimReturnedLostValue") %]
116
                                [% IF subfield.IS_LOST_AV && Koha.Preference("ClaimReturnedLostValue") && aval == Koha.Preference("ClaimReturnedLostValue") %]
117
                                    <option disabled="disabled" value="[%- aval | html -%]" title="Return claims must be processed from the patron details page">[%- mv.labels.$aval | html -%]</option>
117
                                    <option disabled="disabled" value="[%- aval | html -%]" title="Return claims must be processed from the patron details page">[%- mv.labels.$aval | html -%]</option>
118
                                [% ELSIF subfield.IS_LOST_AV && Koha.Preference("BundleLostValue") && aval == Koha.Preference("BundleLostValue") %]
119
                                    <option disabled="disabled" value="[%- aval | html -%]" title="Bundle losses are set at checkin automatically">[%- mv.labels.$aval | html -%]</option>
118
                                [%  ELSE %]
120
                                [%  ELSE %]
119
                                    <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
121
                                    <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
120
                                [% END %]
122
                                [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-3 / +4 lines)
Lines 1414-1419 Note that permanent location is a code, and location may be an authval. Link Here
1414
1414
1415
        [% IF bundlesEnabled %]
1415
        [% IF bundlesEnabled %]
1416
        var bundle_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail','bundle_tables','json') | $raw %];
1416
        var bundle_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail','bundle_tables','json') | $raw %];
1417
        var bundle_lost_value = [% Koha.Preference('BundleLostValue') %];
1417
        [% END %]
1418
        [% END %]
1418
        $(document).ready(function() {
1419
        $(document).ready(function() {
1419
1420
Lines 1505-1514 Note that permanent location is a code, and location may be an authval. Link Here
1505
                            "searchable": false,
1506
                            "searchable": false,
1506
                            "orderable": true,
1507
                            "orderable": true,
1507
                            "render": function(data, type, row, meta) {
1508
                            "render": function(data, type, row, meta) {
1508
                                if ( row.lost_status ) {
1509
                                if ( row.lost_status == bundle_lost_value ) {
1509
                                    return "Lost: " + row.lost_status;
1510
                                    return "Last seen: " + row.last_seen_date;
1510
                                }
1511
                                }
1511
                                return "";
1512
                                return "Present";
1512
                            }
1513
                            }
1513
                        },
1514
                        },
1514
                        {
1515
                        {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-1 / +19 lines)
Lines 429-439 Link Here
429
                                                        <th>[% t('Author') | html %]</th>
429
                                                        <th>[% t('Author') | html %]</th>
430
                                                        <th>[% t('Item type') | html %]</th>
430
                                                        <th>[% t('Item type') | html %]</th>
431
                                                        <th>[% t('Barcode') | html %]</th>
431
                                                        <th>[% t('Barcode') | html %]</th>
432
                                                        [% IF !item.onloan %]
432
                                                        <th>[% t('Status') | html %]</th>
433
                                                        <th>[% t('Status') | html %]</th>
434
                                                        [% END %]
433
                                                    </tr>
435
                                                    </tr>
434
                                                </thead>
436
                                                </thead>
435
                                                <tbody>
437
                                                <tbody>
436
                                                    [% FOREACH bundle_item IN item.bundle_items %]
438
                                                    [% FOREACH bundle_item IN item.bundle_items %]
439
                                                    [% IF !item.onloan %]
437
                                                    <tr data-barcode="[% bundle_item.barcode | html %]">
440
                                                    <tr data-barcode="[% bundle_item.barcode | html %]">
438
                                                        <td>[% INCLUDE 'biblio-title.inc' biblio=bundle_item.biblio link = 1 %]</td>
441
                                                        <td>[% INCLUDE 'biblio-title.inc' biblio=bundle_item.biblio link = 1 %]</td>
439
                                                        <td>[% bundle_item.biblio.author | html %]</td>
442
                                                        <td>[% bundle_item.biblio.author | html %]</td>
Lines 441-446 Link Here
441
                                                        <td>[% bundle_item.barcode | html %]</td>
444
                                                        <td>[% bundle_item.barcode | html %]</td>
442
                                                        <td>[% INCLUDE 'item-status.inc' item=bundle_item %]</td>
445
                                                        <td>[% INCLUDE 'item-status.inc' item=bundle_item %]</td>
443
                                                    </tr>
446
                                                    </tr>
447
                                                    [% ELSIF !bundle_item.itemlost %]
448
                                                    <tr data-barcode="[% bundle_item.barcode | html %]">
449
                                                        <td>[% INCLUDE 'biblio-title.inc' biblio=bundle_item.biblio link = 1 %]</td>
450
                                                        <td>[% bundle_item.biblio.author | html %]</td>
451
                                                        <td>[% ItemTypes.GetDescription(bundle_item.itype) | html %]</td>
452
                                                        <td>[% bundle_item.barcode | html %]</td>
453
                                                    </tr>
454
                                                    [% END %]
444
                                                    [% END %]
455
                                                    [% END %]
445
                                                </tbody>
456
                                                </tbody>
446
                                            </table>
457
                                            </table>
Lines 448-454 Link Here
448
                                            <div class="form-group">
459
                                            <div class="form-group">
449
                                                <label for="verify-items-bundle-contents-barcodes">Barcodes</label>
460
                                                <label for="verify-items-bundle-contents-barcodes">Barcodes</label>
450
                                                <textarea autocomplete="off" id="verify-items-bundle-contents-barcodes" name="verify-items-bundle-contents-barcodes" class="form-control"></textarea>
461
                                                <textarea autocomplete="off" id="verify-items-bundle-contents-barcodes" name="verify-items-bundle-contents-barcodes" class="form-control"></textarea>
462
                                                [% IF item.onloan %]
451
                                                <div class="help-block">[% t('Scan all barcodes of items found in the items bundle. If any items are missing, they will be marked as lost') | html %]</div>
463
                                                <div class="help-block">[% t('Scan all barcodes of items found in the items bundle. If any items are missing, they will be marked as lost') | html %]</div>
464
                                                [% ELSE %]
465
                                                <div class="help-block">[% t('Optionally scan all barcodes of items found in the items bundle to perform an inventory check. If any items are missing, they will be marked as lost') | html %]</div>
466
                                                [% END %]
452
                                            </div>
467
                                            </div>
453
468
454
                                        </div>
469
                                        </div>
Lines 460-466 Link Here
460
                                            <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" />
475
                                            <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" />
461
                                            <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" />
476
                                            <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" />
462
                                            [% END %]
477
                                            [% END %]
478
                                            [% IF item.onloan %]
463
                                            <button type="submit" class="btn btn-default"><i class="fa fa-check"></i> [% t('Confirm checkin and mark missing items as lost') | html %]</button>
479
                                            <button type="submit" class="btn btn-default"><i class="fa fa-check"></i> [% t('Confirm checkin and mark missing items as lost') | html %]</button>
480
                                            [% ELSE %]
481
                                            <button type="submit" class="btn btn-default"><i class="fa fa-check"></i> [% t('Confirm inventory check and mark items as lost') | html %]</button>
482
                                            [% END %]
464
                                            <button type="button" data-dismiss="modal" class="btn btn-default"><i class="fa fa-close"></i> [% t('Cancel') | html %]</button>
483
                                            <button type="button" data-dismiss="modal" class="btn btn-default"><i class="fa fa-close"></i> [% t('Cancel') | html %]</button>
465
                                        </div>
484
                                        </div>
466
                                    </form>
485
                                    </form>
467
- 

Return to bug 28854