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

(-)a/C4/Circulation.pm (-49 / +8 lines)
Lines 1492-1521 sub AddIssue { Link Here
1492
1492
1493
            ## If item was lost, it has now been found, reverse any list item charges if necessary.
1493
            ## If item was lost, it has now been found, reverse any list item charges if necessary.
1494
            if ( $item_object->itemlost ) {
1494
            if ( $item_object->itemlost ) {
1495
                my $refund = 1;
1495
                $item_object->set_found;
1496
                my $no_refund_after_days = C4::Context->preference('NoRefundOnLostReturnedItemsAge');
1497
                if ($no_refund_after_days) {
1498
                    my $today = dt_from_string();
1499
                    my $lost_age_in_days =
1500
                      dt_from_string( $item_object->itemlost_on )
1501
                      ->delta_days($today)
1502
                      ->in_units('days');
1503
1504
                    $refund = 0 unless ( $lost_age_in_days < $no_refund_after_days );
1505
                }
1506
1507
                if (
1508
                    $refund && Koha::CirculationRules->get_lostreturn_policy(
1509
                        {
1510
                            return_branch => C4::Context->userenv->{branch},
1511
                            item          => $item_object
1512
                        }
1513
                    )
1514
                  )
1515
                {
1516
                    _FixAccountForLostAndFound( $item_object->itemnumber, undef,
1517
                        $item_object->barcode );
1518
                }
1519
            }
1496
            }
1520
1497
1521
            $item_object->issues( ( $item_object->issues || 0 ) + 1);
1498
            $item_object->issues( ( $item_object->issues || 0 ) + 1);
Lines 2093-2124 sub AddReturn { Link Here
2093
    if ( $item->itemlost ) {
2070
    if ( $item->itemlost ) {
2094
        $messages->{'WasLost'} = 1;
2071
        $messages->{'WasLost'} = 1;
2095
        unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
2072
        unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
2096
            my $refund = 1;
2073
            my $refunded = $item->set_found(
2097
            my $no_refund_after_days = C4::Context->preference('NoRefundOnLostReturnedItemsAge');
2074
                {
2098
            if ($no_refund_after_days) {
2075
                    holdingbranch  => $item_holding_branch,
2099
                my $today = dt_from_string();
2076
                    borrowernumber => $borrowernumber
2100
                my $lost_age_in_days =
2077
                }
2101
                  dt_from_string( $item->itemlost_on )
2078
            );
2102
                  ->delta_days($today)
2103
                  ->in_units('days');
2104
2105
                $refund = 0 unless ( $lost_age_in_days < $no_refund_after_days );
2106
            }
2107
2079
2108
            if (
2080
            $messages->{'LostItemFeeRefunded'} = $refunded;
2109
                $refund &&
2110
                Koha::CirculationRules->get_lostreturn_policy(
2111
                    {
2112
                        return_branch => C4::Context->userenv->{branch},
2113
                        item          => $item,
2114
                    }
2115
                  )
2116
              )
2117
            {
2118
                _FixAccountForLostAndFound( $item->itemnumber,
2119
                    $borrowernumber, $barcode );
2120
                $messages->{'LostItemFeeRefunded'} = 1;
2121
            }
2122
        }
2081
        }
2123
    }
2082
    }
2124
2083
(-)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