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

(-)a/C4/Circulation.pm (-3 / +1 lines)
Lines 2048-2054 sub AddReturn { Link Here
2048
            my $refunded = $item->set_found(
2048
            my $refunded = $item->set_found(
2049
                {
2049
                {
2050
                    holdingbranch  => $item_holding_branch,
2050
                    holdingbranch  => $item_holding_branch,
2051
                    borrowernumber => $borrowernumber
2052
                }
2051
                }
2053
            );
2052
            );
2054
2053
Lines 2490-2496 sub _FixOverduesOnReturn { Link Here
2490
2489
2491
=head2 _FixAccountForLostAndFound
2490
=head2 _FixAccountForLostAndFound
2492
2491
2493
  &_FixAccountForLostAndFound($itemnumber, [$borrowernumber, $barcode]);
2492
  &_FixAccountForLostAndFound($itemnumber, [$barcode]);
2494
2493
2495
Finds the most recent lost item charge for this item and refunds the borrower
2494
Finds the most recent lost item charge for this item and refunds the borrower
2496
appropriatly, taking into account any payments or writeoffs already applied
2495
appropriatly, taking into account any payments or writeoffs already applied
Lines 2502-2508 Internal function, not exported, called only by AddReturn. Link Here
2502
2501
2503
sub _FixAccountForLostAndFound {
2502
sub _FixAccountForLostAndFound {
2504
    my $itemnumber     = shift or return;
2503
    my $itemnumber     = shift or return;
2505
    my $borrowernumber = @_ ? shift : undef;
2506
    my $item_id        = @_ ? shift : $itemnumber;  # Send the barcode if you want that logged in the description
2504
    my $item_id        = @_ ? shift : $itemnumber;  # Send the barcode if you want that logged in the description
2507
2505
2508
    my $credit;
2506
    my $credit;
(-)a/Koha/Item.pm (-2 / +1 lines)
Lines 767-773 sub set_found { Link Here
767
    my ($self, $params) = @_;
767
    my ($self, $params) = @_;
768
768
769
    my $holdingbranch = $params->{holdingbranch} || $self->holdingbranch;
769
    my $holdingbranch = $params->{holdingbranch} || $self->holdingbranch;
770
    my $borrowernumber = $params->{borrowernumber} || undef;
771
770
772
    ## If item was lost, it has now been found, reverse any list item charges if necessary.
771
    ## If item was lost, it has now been found, reverse any list item charges if necessary.
773
    my $refund = 1;
772
    my $refund = 1;
Lines 793-799 sub set_found { Link Here
793
        )
792
        )
794
      )
793
      )
795
    {
794
    {
796
        _FixAccountForLostAndFound( $self->itemnumber, borrowernumber, $self->barcode );
795
        C4::Circulation::_FixAccountForLostAndFound( $self->itemnumber, $self->barcode );
797
        $refunded = 1;
796
        $refunded = 1;
798
    }
797
    }
799
798
(-)a/t/db_dependent/Circulation.t (-7 / +6 lines)
Lines 2747-2753 subtest '_FixAccountForLostAndFound' => sub { Link Here
2747
        );
2747
        );
2748
        $credit->apply( { debits => [ $debts->as_list ], offset_type => 'Writeoff' } );
2748
        $credit->apply( { debits => [ $debts->as_list ], offset_type => 'Writeoff' } );
2749
2749
2750
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
2750
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
2751
        is( $credit_return_id, undef, 'No LOST_FOUND account line added' );
2751
        is( $credit_return_id, undef, 'No LOST_FOUND account line added' );
2752
2752
2753
        $lost_fee_line->discard_changes; # reload from DB
2753
        $lost_fee_line->discard_changes; # reload from DB
Lines 2809-2815 subtest '_FixAccountForLostAndFound' => sub { Link Here
2809
        );
2809
        );
2810
        $credit->apply( { debits => [ $debts->as_list ], offset_type => 'Payment' } );
2810
        $credit->apply( { debits => [ $debts->as_list ], offset_type => 'Payment' } );
2811
2811
2812
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
2812
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
2813
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2813
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2814
2814
2815
        is( $credit_return->credit_type_code, 'LOST_FOUND', 'An account line of type LOST_FOUND is added' );
2815
        is( $credit_return->credit_type_code, 'LOST_FOUND', 'An account line of type LOST_FOUND is added' );
Lines 2867-2873 subtest '_FixAccountForLostAndFound' => sub { Link Here
2867
        is( $lost_fee_line->amountoutstanding + 0,
2867
        is( $lost_fee_line->amountoutstanding + 0,
2868
            $replacement_amount, 'The right LOST amountountstanding is generated' );
2868
            $replacement_amount, 'The right LOST amountountstanding is generated' );
2869
2869
2870
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
2870
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
2871
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2871
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2872
2872
2873
        is( $credit_return->credit_type_code, 'LOST_FOUND', 'An account line of type LOST_FOUND is added' );
2873
        is( $credit_return->credit_type_code, 'LOST_FOUND', 'An account line of type LOST_FOUND is added' );
Lines 2953-2959 subtest '_FixAccountForLostAndFound' => sub { Link Here
2953
        $lost_fee_line->discard_changes;
2953
        $lost_fee_line->discard_changes;
2954
        my $outstanding = $lost_fee_line->amountoutstanding;
2954
        my $outstanding = $lost_fee_line->amountoutstanding;
2955
2955
2956
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
2956
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
2957
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2957
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2958
2958
2959
        is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PROCESSING - PAYMENT (LOST_FOUND)' );
2959
        is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PROCESSING - PAYMENT (LOST_FOUND)' );
Lines 3050-3056 subtest '_FixAccountForLostAndFound' => sub { Link Here
3050
3050
3051
        t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 1 );
3051
        t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 1 );
3052
3052
3053
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
3053
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
3054
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
3054
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
3055
3055
3056
        is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_FOUND)' );
3056
        is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_FOUND)' );
Lines 3181-3187 subtest '_FixAccountForLostAndFound returns undef if patron is deleted' => sub { Link Here
3181
3181
3182
    $patron->delete();
3182
    $patron->delete();
3183
3183
3184
    my $return_value = C4::Circulation::_FixAccountForLostAndFound( $patron->id, $item->itemnumber );
3184
    my $return_value = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
3185
3185
3186
    is( $return_value, undef, "_FixAccountForLostAndFound returns undef if patron is deleted" );
3186
    is( $return_value, undef, "_FixAccountForLostAndFound returns undef if patron is deleted" );
3187
3187
3188
- 

Return to bug 18501