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

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

Return to bug 18501