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

(-)a/C4/Circulation.pm (-3 / +1 lines)
Lines 2037-2043 sub AddReturn { Link Here
2037
            my $refunded = $item->set_found(
2037
            my $refunded = $item->set_found(
2038
                {
2038
                {
2039
                    holdingbranch  => $item_holding_branch,
2039
                    holdingbranch  => $item_holding_branch,
2040
                    borrowernumber => $borrowernumber
2041
                }
2040
                }
2042
            );
2041
            );
2043
2042
Lines 2479-2485 sub _FixOverduesOnReturn { Link Here
2479
2478
2480
=head2 _FixAccountForLostAndFound
2479
=head2 _FixAccountForLostAndFound
2481
2480
2482
  &_FixAccountForLostAndFound($itemnumber, [$borrowernumber, $barcode]);
2481
  &_FixAccountForLostAndFound($itemnumber, [$barcode]);
2483
2482
2484
Finds the most recent lost item charge for this item and refunds the borrower
2483
Finds the most recent lost item charge for this item and refunds the borrower
2485
appropriatly, taking into account any payments or writeoffs already applied
2484
appropriatly, taking into account any payments or writeoffs already applied
Lines 2491-2497 Internal function, not exported, called only by AddReturn. Link Here
2491
2490
2492
sub _FixAccountForLostAndFound {
2491
sub _FixAccountForLostAndFound {
2493
    my $itemnumber     = shift or return;
2492
    my $itemnumber     = shift or return;
2494
    my $borrowernumber = @_ ? shift : undef;
2495
    my $item_id        = @_ ? shift : $itemnumber;  # Send the barcode if you want that logged in the description
2493
    my $item_id        = @_ ? shift : $itemnumber;  # Send the barcode if you want that logged in the description
2496
2494
2497
    my $credit;
2495
    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