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

(-)a/C4/Circulation.pm (-3 / +1 lines)
Lines 2073-2079 sub AddReturn { Link Here
2073
            my $refunded = $item->set_found(
2073
            my $refunded = $item->set_found(
2074
                {
2074
                {
2075
                    holdingbranch  => $item_holding_branch,
2075
                    holdingbranch  => $item_holding_branch,
2076
                    borrowernumber => $borrowernumber
2077
                }
2076
                }
2078
            );
2077
            );
2079
2078
Lines 2515-2521 sub _FixOverduesOnReturn { Link Here
2515
2514
2516
=head2 _FixAccountForLostAndFound
2515
=head2 _FixAccountForLostAndFound
2517
2516
2518
  &_FixAccountForLostAndFound($itemnumber, [$borrowernumber, $barcode]);
2517
  &_FixAccountForLostAndFound($itemnumber, [$barcode]);
2519
2518
2520
Finds the most recent lost item charge for this item and refunds the borrower
2519
Finds the most recent lost item charge for this item and refunds the borrower
2521
appropriatly, taking into account any payments or writeoffs already applied
2520
appropriatly, taking into account any payments or writeoffs already applied
Lines 2527-2533 Internal function, not exported, called only by AddReturn. Link Here
2527
2526
2528
sub _FixAccountForLostAndFound {
2527
sub _FixAccountForLostAndFound {
2529
    my $itemnumber     = shift or return;
2528
    my $itemnumber     = shift or return;
2530
    my $borrowernumber = @_ ? shift : undef;
2531
    my $item_id        = @_ ? shift : $itemnumber;  # Send the barcode if you want that logged in the description
2529
    my $item_id        = @_ ? shift : $itemnumber;  # Send the barcode if you want that logged in the description
2532
2530
2533
    my $credit;
2531
    my $credit;
(-)a/Koha/Item.pm (-2 / +1 lines)
Lines 766-772 sub set_found { Link Here
766
    my ($self, $params) = @_;
766
    my ($self, $params) = @_;
767
767
768
    my $holdingbranch = $params->{holdingbranch} || $self->holdingbranch;
768
    my $holdingbranch = $params->{holdingbranch} || $self->holdingbranch;
769
    my $borrowernumber = $params->{borrowernumber} || undef;
770
769
771
    ## If item was lost, it has now been found, reverse any list item charges if necessary.
770
    ## If item was lost, it has now been found, reverse any list item charges if necessary.
772
    my $refund = 1;
771
    my $refund = 1;
Lines 792-798 sub set_found { Link Here
792
        )
791
        )
793
      )
792
      )
794
    {
793
    {
795
        _FixAccountForLostAndFound( $self->itemnumber, borrowernumber, $self->barcode );
794
        C4::Circulation::_FixAccountForLostAndFound( $self->itemnumber, $self->barcode );
796
        $refunded = 1;
795
        $refunded = 1;
797
    }
796
    }
798
797
(-)a/t/db_dependent/Circulation.t (-7 / +6 lines)
Lines 2746-2752 subtest '_FixAccountForLostAndFound' => sub { Link Here
2746
        );
2746
        );
2747
        $credit->apply( { debits => [ $debts->as_list ], offset_type => 'Writeoff' } );
2747
        $credit->apply( { debits => [ $debts->as_list ], offset_type => 'Writeoff' } );
2748
2748
2749
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
2749
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
2750
        is( $credit_return_id, undef, 'No LOST_FOUND account line added' );
2750
        is( $credit_return_id, undef, 'No LOST_FOUND account line added' );
2751
2751
2752
        $lost_fee_line->discard_changes; # reload from DB
2752
        $lost_fee_line->discard_changes; # reload from DB
Lines 2808-2814 subtest '_FixAccountForLostAndFound' => sub { Link Here
2808
        );
2808
        );
2809
        $credit->apply( { debits => [ $debts->as_list ], offset_type => 'Payment' } );
2809
        $credit->apply( { debits => [ $debts->as_list ], offset_type => 'Payment' } );
2810
2810
2811
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
2811
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
2812
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2812
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2813
2813
2814
        is( $credit_return->credit_type_code, 'LOST_FOUND', 'An account line of type LOST_FOUND is added' );
2814
        is( $credit_return->credit_type_code, 'LOST_FOUND', 'An account line of type LOST_FOUND is added' );
Lines 2866-2872 subtest '_FixAccountForLostAndFound' => sub { Link Here
2866
        is( $lost_fee_line->amountoutstanding + 0,
2866
        is( $lost_fee_line->amountoutstanding + 0,
2867
            $replacement_amount, 'The right LOST amountountstanding is generated' );
2867
            $replacement_amount, 'The right LOST amountountstanding is generated' );
2868
2868
2869
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
2869
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
2870
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2870
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2871
2871
2872
        is( $credit_return->credit_type_code, 'LOST_FOUND', 'An account line of type LOST_FOUND is added' );
2872
        is( $credit_return->credit_type_code, 'LOST_FOUND', 'An account line of type LOST_FOUND is added' );
Lines 2952-2958 subtest '_FixAccountForLostAndFound' => sub { Link Here
2952
        $lost_fee_line->discard_changes;
2952
        $lost_fee_line->discard_changes;
2953
        my $outstanding = $lost_fee_line->amountoutstanding;
2953
        my $outstanding = $lost_fee_line->amountoutstanding;
2954
2954
2955
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
2955
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
2956
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2956
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2957
2957
2958
        is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PROCESSING - PAYMENT (LOST_FOUND)' );
2958
        is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PROCESSING - PAYMENT (LOST_FOUND)' );
Lines 3049-3055 subtest '_FixAccountForLostAndFound' => sub { Link Here
3049
3049
3050
        t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 1 );
3050
        t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 1 );
3051
3051
3052
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
3052
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
3053
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
3053
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
3054
3054
3055
        is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_FOUND)' );
3055
        is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_FOUND)' );
Lines 3180-3186 subtest '_FixAccountForLostAndFound returns undef if patron is deleted' => sub { Link Here
3180
3180
3181
    $patron->delete();
3181
    $patron->delete();
3182
3182
3183
    my $return_value = C4::Circulation::_FixAccountForLostAndFound( $patron->id, $item->itemnumber );
3183
    my $return_value = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
3184
3184
3185
    is( $return_value, undef, "_FixAccountForLostAndFound returns undef if patron is deleted" );
3185
    is( $return_value, undef, "_FixAccountForLostAndFound returns undef if patron is deleted" );
3186
3186
3187
- 

Return to bug 18501