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

(-)a/C4/Circulation.pm (-22 / +27 lines)
Lines 2134-2162 sub AddReturn { Link Here
2134
    if ($item_was_lost) {
2134
    if ($item_was_lost) {
2135
        $messages->{'WasLost'} = 1;
2135
        $messages->{'WasLost'} = 1;
2136
        unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
2136
        unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
2137
            $messages->{'LostItemFeeRefunded'} = $updated_item->{_refunded};
2137
            my @object_messages = @{ $updated_item->messages };
2138
            $messages->{'LostItemFeeRestored'} = $updated_item->{_restored};
2138
            for my $message (@object_messages) {
2139
2139
                $messages->{'LostItemFeeRefunded'} = 1
2140
            if ( $updated_item->{_charge} ) {
2140
                  if $message->message eq 'lost_refunded';
2141
                $issue //= Koha::Old::Checkouts->search(
2141
                $messages->{'LostItemFeeRestored'} = 1
2142
                    { itemnumber => $item->itemnumber },
2142
                  if $message->message eq 'lost_restored';
2143
                    { order_by   => { '-desc' => 'returndate' }, rows => 1 } )
2143
2144
                  ->single;
2144
                if ( $message->message eq 'lost_charge' ) {
2145
                unless ( exists( $patron_unblessed->{branchcode} ) ) {
2145
                    $issue //= Koha::Old::Checkouts->search(
2146
                    my $patron = $issue->patron;
2146
                        { itemnumber => $item->itemnumber },
2147
                    $patron_unblessed = $patron->unblessed;
2147
                        { order_by   => { '-desc' => 'returndate' }, rows => 1 }
2148
                }
2148
                    )->single;
2149
                _CalculateAndUpdateFine(
2149
                    unless ( exists( $patron_unblessed->{branchcode} ) ) {
2150
                    {
2150
                        my $patron = $issue->patron;
2151
                        issue       => $issue,
2151
                        $patron_unblessed = $patron->unblessed;
2152
                        item        => $item->unblessed,
2153
                        borrower    => $patron_unblessed,
2154
                        return_date => $return_date
2155
                    }
2152
                    }
2156
                );
2153
                    _CalculateAndUpdateFine(
2157
                _FixOverduesOnReturn( $patron_unblessed->{borrowernumber},
2154
                        {
2158
                    $item->itemnumber, undef, 'RETURNED' );
2155
                            issue       => $issue,
2159
                $messages->{'LostItemFeeCharged'} = 1;
2156
                            item        => $item->unblessed,
2157
                            borrower    => $patron_unblessed,
2158
                            return_date => $return_date
2159
                        }
2160
                    );
2161
                    _FixOverduesOnReturn( $patron_unblessed->{borrowernumber},
2162
                        $item->itemnumber, undef, 'RETURNED' );
2163
                    $messages->{'LostItemFeeCharged'} = 1;
2164
                }
2160
            }
2165
            }
2161
        }
2166
        }
2162
    }
2167
    }
(-)a/Koha/Item.pm (-4 / +20 lines)
Lines 1039-1045 sub _set_found_trigger { Link Here
1039
                    );
1039
                    );
1040
1040
1041
                    $credit->apply( { debits => [$lost_charge] } );
1041
                    $credit->apply( { debits => [$lost_charge] } );
1042
                    $self->{_refunded} = 1;
1042
                    $self->add_message(
1043
                        {
1044
                            type    => 'info',
1045
                            message => 'lost_refunded',
1046
                            payload => { credit_id => $credit->id }
1047
                        }
1048
                    );
1043
                }
1049
                }
1044
1050
1045
                # Update the account status
1051
                # Update the account status
Lines 1089-1095 sub _set_found_trigger { Link Here
1089
                    if ( $refund ) {
1095
                    if ( $refund ) {
1090
                        # Revert the forgive credit
1096
                        # Revert the forgive credit
1091
                        $refund->void({ interface => 'trigger' });
1097
                        $refund->void({ interface => 'trigger' });
1092
                        $self->{_restored} = 1;
1098
                        $self->add_message(
1099
                            {
1100
                                type    => 'info',
1101
                                message => 'lost_restored',
1102
                                payload => { refund_id => $refund->id }
1103
                            }
1104
                        );
1093
                    }
1105
                    }
1094
1106
1095
                    # Reconcile balances if required
1107
                    # Reconcile balances if required
Lines 1099-1105 sub _set_found_trigger { Link Here
1099
                }
1111
                }
1100
            }
1112
            }
1101
        } elsif ( $lostreturn_policy eq 'charge' ) {
1113
        } elsif ( $lostreturn_policy eq 'charge' ) {
1102
            $self->{_charge} = 1;
1114
            $self->add_message(
1115
                {
1116
                    type    => 'info',
1117
                    message => 'lost_charge',
1118
                }
1119
            );
1103
        }
1120
        }
1104
    }
1121
    }
1105
1122
1106
- 

Return to bug 26704