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

(-)a/C4/Circulation.pm (-49 / +8 lines)
Lines 1510-1539 sub AddIssue { Link Here
1510
1510
1511
            ## If item was lost, it has now been found, reverse any list item charges if necessary.
1511
            ## If item was lost, it has now been found, reverse any list item charges if necessary.
1512
            if ( $item_object->itemlost ) {
1512
            if ( $item_object->itemlost ) {
1513
                my $refund = 1;
1513
                $item_object->set_found;
1514
                my $no_refund_after_days = C4::Context->preference('NoRefundOnLostReturnedItemsAge');
1515
                if ($no_refund_after_days) {
1516
                    my $today = dt_from_string();
1517
                    my $lost_age_in_days =
1518
                      dt_from_string( $item_object->itemlost_on )
1519
                      ->delta_days($today)
1520
                      ->in_units('days');
1521
1522
                    $refund = 0 unless ( $lost_age_in_days < $no_refund_after_days );
1523
                }
1524
1525
                if (
1526
                    $refund && Koha::CirculationRules->get_lostreturn_policy(
1527
                        {
1528
                            return_branch => C4::Context->userenv->{branch},
1529
                            item          => $item_object
1530
                        }
1531
                    )
1532
                  )
1533
                {
1534
                    _FixAccountForLostAndFound( $item_object->itemnumber, undef,
1535
                        $item_object->barcode );
1536
                }
1537
            }
1514
            }
1538
1515
1539
            $item_object->issues( ( $item_object->issues || 0 ) + 1);
1516
            $item_object->issues( ( $item_object->issues || 0 ) + 1);
Lines 2068-2099 sub AddReturn { Link Here
2068
    if ( $item->itemlost ) {
2045
    if ( $item->itemlost ) {
2069
        $messages->{'WasLost'} = 1;
2046
        $messages->{'WasLost'} = 1;
2070
        unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
2047
        unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
2071
            my $refund = 1;
2048
            my $refunded = $item->set_found(
2072
            my $no_refund_after_days = C4::Context->preference('NoRefundOnLostReturnedItemsAge');
2049
                {
2073
            if ($no_refund_after_days) {
2050
                    holdingbranch  => $item_holding_branch,
2074
                my $today = dt_from_string();
2051
                    borrowernumber => $borrowernumber
2075
                my $lost_age_in_days =
2052
                }
2076
                  dt_from_string( $item->itemlost_on )
2053
            );
2077
                  ->delta_days($today)
2078
                  ->in_units('days');
2079
2080
                $refund = 0 unless ( $lost_age_in_days < $no_refund_after_days );
2081
            }
2082
2054
2083
            if (
2055
            $messages->{'LostItemFeeRefunded'} = $refunded;
2084
                $refund &&
2085
                Koha::CirculationRules->get_lostreturn_policy(
2086
                    {
2087
                        return_branch => C4::Context->userenv->{branch},
2088
                        item          => $item,
2089
                    }
2090
                  )
2091
              )
2092
            {
2093
                _FixAccountForLostAndFound( $item->itemnumber,
2094
                    $borrowernumber, $barcode );
2095
                $messages->{'LostItemFeeRefunded'} = 1;
2096
            }
2097
        }
2056
        }
2098
    }
2057
    }
2099
2058
(-)a/Koha/Item.pm (-1 / +37 lines)
Lines 763-768 sub renewal_branchcode { Link Here
763
    return $branchcode;
763
    return $branchcode;
764
}
764
}
765
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::CirculationRules->get_lostreturn_policy(
789
            {
790
                current_branch => C4::Context->userenv->{branch},
791
                item           => $self,
792
            }
793
        )
794
      )
795
    {
796
        _FixAccountForLostAndFound( $self->itemnumber, borrowernumber, $self->barcode );
797
        $refunded = 1;
798
    }
799
800
    return $refunded;
801
}
802
766
=head3 to_api_mapping
803
=head3 to_api_mapping
767
804
768
This method returns the mapping for representing a Koha::Item object
805
This method returns the mapping for representing a Koha::Item object
769
- 

Return to bug 18501