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

(-)a/C4/Circulation.pm (-53 / +8 lines)
Lines 52-58 use Koha::Database; Link Here
52
use Koha::Libraries;
52
use Koha::Libraries;
53
use Koha::Account::Lines;
53
use Koha::Account::Lines;
54
use Koha::Holds;
54
use Koha::Holds;
55
use Koha::RefundLostItemFeeRules;
56
use Koha::Account::Lines;
55
use Koha::Account::Lines;
57
use Koha::Account::Offsets;
56
use Koha::Account::Offsets;
58
use Koha::Config::SysPrefs;
57
use Koha::Config::SysPrefs;
Lines 1457-1488 sub AddIssue { Link Here
1457
1456
1458
            ## If item was lost, it has now been found, reverse any list item charges if necessary.
1457
            ## If item was lost, it has now been found, reverse any list item charges if necessary.
1459
            if ( $item_object->itemlost ) {
1458
            if ( $item_object->itemlost ) {
1460
                my $refund = 1;
1459
                $item_object->set_found;
1461
                my $no_refund_after_days = C4::Context->preference('NoRefundOnLostReturnedItemsAge');
1462
                if ($no_refund_after_days) {
1463
                    my $today = dt_from_string();
1464
                    my $lost_age_in_days =
1465
                      dt_from_string( $item_object->itemlost_on )
1466
                      ->delta_days($today)
1467
                      ->in_units('days');
1468
1469
                    $refund = 0 unless ( $lost_age_in_days < $no_refund_after_days );
1470
                }
1471
1472
                if (
1473
                    $refund
1474
                    && Koha::RefundLostItemFeeRules->should_refund(
1475
                        {
1476
                            current_branch   => C4::Context->userenv->{branch},
1477
                            item_home_branch => $item_object->homebranch,
1478
                            item_holding_branch => $item_object->holdingbranch,
1479
                        }
1480
                    )
1481
                  )
1482
                {
1483
                    _FixAccountForLostAndFound( $item_object->itemnumber, undef,
1484
                        $item_object->barcode );
1485
                }
1486
            }
1460
            }
1487
1461
1488
            $item_object->issues( ( $item_object->issues || 0 ) + 1);
1462
            $item_object->issues( ( $item_object->issues || 0 ) + 1);
Lines 2060-2092 sub AddReturn { Link Here
2060
    if ( $item->itemlost ) {
2034
    if ( $item->itemlost ) {
2061
        $messages->{'WasLost'} = 1;
2035
        $messages->{'WasLost'} = 1;
2062
        unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
2036
        unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
2063
            my $refund = 1;
2037
            my $refunded = $item->set_found(
2064
            my $no_refund_after_days = C4::Context->preference('NoRefundOnLostReturnedItemsAge');
2038
                {
2065
            if ($no_refund_after_days) {
2039
                    holdingbranch  => $item_holding_branch,
2066
                my $today = dt_from_string();
2040
                    borrowernumber => $borrowernumber
2067
                my $lost_age_in_days =
2041
                }
2068
                  dt_from_string( $item->itemlost_on )
2042
            );
2069
                  ->delta_days($today)
2070
                  ->in_units('days');
2071
2072
                $refund = 0 unless ( $lost_age_in_days < $no_refund_after_days );
2073
            }
2074
2043
2075
            if (
2044
            $messages->{'LostItemFeeRefunded'} = $refunded;
2076
                $refund &&
2077
                Koha::RefundLostItemFeeRules->should_refund(
2078
                    {
2079
                        current_branch      => C4::Context->userenv->{branch},
2080
                        item_home_branch    => $item->homebranch,
2081
                        item_holding_branch => $item_holding_branch
2082
                    }
2083
                )
2084
              )
2085
            {
2086
                _FixAccountForLostAndFound( $item->itemnumber,
2087
                    $borrowernumber, $barcode );
2088
                $messages->{'LostItemFeeRefunded'} = 1;
2089
            }
2090
        }
2045
        }
2091
    }
2046
    }
2092
2047
(-)a/Koha/Item.pm (-1 / +39 lines)
Lines 41-46 use Koha::Item::Transfers; Link Here
41
use Koha::Patrons;
41
use Koha::Patrons;
42
use Koha::Plugins;
42
use Koha::Plugins;
43
use Koha::Libraries;
43
use Koha::Libraries;
44
use Koha::RefundLostItemFeeRules;
44
use Koha::StockRotationItem;
45
use Koha::StockRotationItem;
45
use Koha::StockRotationRotas;
46
use Koha::StockRotationRotas;
46
47
Lines 762-767 sub renewal_branchcode { Link Here
762
    return $branchcode;
763
    return $branchcode;
763
}
764
}
764
765
766
sub set_found {
767
    my ($self, $params) = @_;
768
769
    my $holdingbranch = $params->{holdingbranch} || $self->holdingbranch;
770
    my $borrowernumber = $params->{borrowernumber} || undef;
771
772
    ## If item was lost, it has now been found, reverse any list item charges if necessary.
773
    my $refund = 1;
774
    my $no_refund_after_days =
775
      C4::Context->preference('NoRefundOnLostReturnedItemsAge');
776
    if ($no_refund_after_days) {
777
        my $today = dt_from_string();
778
        my $lost_age_in_days =
779
          dt_from_string( $self->itemlost_on )->delta_days($today)
780
          ->in_units('days');
781
782
        $refund = 0 unless ( $lost_age_in_days < $no_refund_after_days );
783
    }
784
785
    my $refunded;
786
    if (
787
        $refund
788
        && Koha::RefundLostItemFeeRules->should_refund(
789
            {
790
                current_branch      => C4::Context->userenv->{branch},
791
                item_home_branch    => $self->homebranch,
792
                item_holding_branch => $holdingbranch,
793
            }
794
        )
795
      )
796
    {
797
        _FixAccountForLostAndFound( $self->itemnumber, borrowernumber, $self->barcode );
798
        $refunded = 1;
799
    }
800
801
    return $refunded;
802
}
803
765
=head3 to_api_mapping
804
=head3 to_api_mapping
766
805
767
This method returns the mapping for representing a Koha::Item object
806
This method returns the mapping for representing a Koha::Item object
768
- 

Return to bug 18501