From c63d560b041ab67bafc65a6f9e65eee9e43c2a1a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 23 Oct 2017 12:51:50 -0400 Subject: [PATCH] Bug 12768: (QA follow-up) Don't use manualinvoice for non-manual invoices in chargelostitem Signed-off-by: Jonathan Druart --- C4/Accounts.pm | 75 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index 5fcbba057e..b99d936eca 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -159,11 +159,82 @@ sub chargelostitem{ unless ($existing_charges) { #add processing fee if ($processfee && $processfee > 0){ - manualinvoice($borrowernumber, $itemnumber, $description, 'PF', $processfee, $processingfeenote, 1); + my $accountline = Koha::Account::Line->new( + { + borrowernumber => $borrowernumber, + accountno => getnextacctno($borrowernumber), + date => \'NOW()', + amount => $processfee, + description => $description, + accounttype => 'PF', + amountoutstanding => $processfee, + itemnumber => $itemnumber, + note => $processingfeenote, + manager_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : 0, + } + )->store(); + + my $account_offset = Koha::Account::Offset->new( + { + debit_id => $accountline->id, + type => 'Processing Fee', + amount => $accountline->amount, + } + )->store(); + + if ( C4::Context->preference("FinesLog") ) { + logaction("FINES", 'CREATE',$borrowernumber,Dumper({ + action => 'create_fee', + borrowernumber => $accountline->borrowernumber,, + accountno => $accountline->accountno, + amount => $accountline->amount, + description => $accountline->description, + accounttype => $accountline->accounttype, + amountoutstanding => $accountline->amountoutstanding, + note => $accountline->note, + itemnumber => $accountline->itemnumber, + manager_id => $accountline->manager_id, + })); + } } #add replace cost if ($replacementprice > 0){ - manualinvoice($borrowernumber, $itemnumber, $description, 'L', $replacementprice, undef, 1); + my $accountline = Koha::Account::Line->new( + { + borrowernumber => $borrowernumber, + accountno => getnextacctno($borrowernumber), + date => \'NOW()', + amount => $replacementprice, + description => $description, + accounttype => 'L', + amountoutstanding => $replacementprice, + itemnumber => $itemnumber, + manager_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : 0, + } + )->store(); + + my $account_offset = Koha::Account::Offset->new( + { + debit_id => $accountline->id, + type => 'Lost Item', + amount => $accountline->amount, + } + )->store(); + + if ( C4::Context->preference("FinesLog") ) { + logaction("FINES", 'CREATE',$borrowernumber,Dumper({ + action => 'create_fee', + borrowernumber => $accountline->borrowernumber,, + accountno => $accountline->accountno, + amount => $accountline->amount, + description => $accountline->description, + accounttype => $accountline->accounttype, + amountoutstanding => $accountline->amountoutstanding, + note => $accountline->note, + itemnumber => $accountline->itemnumber, + manager_id => $accountline->manager_id, + })); + } } } } -- 2.39.5