my $refunded = $item->set_found(
{
holdingbranch => $item_holding_branch,
- borrowernumber => $borrowernumber
}
);
=head2 _FixAccountForLostAndFound
- &_FixAccountForLostAndFound($itemnumber, [$borrowernumber, $barcode]);
+ &_FixAccountForLostAndFound($itemnumber, [$barcode]);
Finds the most recent lost item charge for this item and refunds the borrower
appropriatly, taking into account any payments or writeoffs already applied
sub _FixAccountForLostAndFound {
my $itemnumber = shift or return;
- my $borrowernumber = @_ ? shift : undef;
my $item_id = @_ ? shift : $itemnumber; # Send the barcode if you want that logged in the description
my $credit;
my ($self, $params) = @_;
my $holdingbranch = $params->{holdingbranch} || $self->holdingbranch;
- my $borrowernumber = $params->{borrowernumber} || undef;
## If item was lost, it has now been found, reverse any list item charges if necessary.
my $refund = 1;
)
)
{
- _FixAccountForLostAndFound( $self->itemnumber, borrowernumber, $self->barcode );
+ C4::Circulation::_FixAccountForLostAndFound( $self->itemnumber, $self->barcode );
$refunded = 1;
}
);
$credit->apply( { debits => [ $debts->as_list ], offset_type => 'Writeoff' } );
- my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
+ my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
is( $credit_return_id, undef, 'No LOST_FOUND account line added' );
$lost_fee_line->discard_changes; # reload from DB
);
$credit->apply( { debits => [ $debts->as_list ], offset_type => 'Payment' } );
- my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
+ my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
my $credit_return = Koha::Account::Lines->find($credit_return_id);
is( $credit_return->credit_type_code, 'LOST_FOUND', 'An account line of type LOST_FOUND is added' );
is( $lost_fee_line->amountoutstanding + 0,
$replacement_amount, 'The right LOST amountountstanding is generated' );
- my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
+ my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
my $credit_return = Koha::Account::Lines->find($credit_return_id);
is( $credit_return->credit_type_code, 'LOST_FOUND', 'An account line of type LOST_FOUND is added' );
$lost_fee_line->discard_changes;
my $outstanding = $lost_fee_line->amountoutstanding;
- my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
+ my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
my $credit_return = Koha::Account::Lines->find($credit_return_id);
is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PROCESSING - PAYMENT (LOST_FOUND)' );
t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 1 );
- my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
+ my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
my $credit_return = Koha::Account::Lines->find($credit_return_id);
is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_FOUND)' );
$patron->delete();
- my $return_value = C4::Circulation::_FixAccountForLostAndFound( $patron->id, $item->itemnumber );
+ my $return_value = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber );
is( $return_value, undef, "_FixAccountForLostAndFound returns undef if patron is deleted" );