From c65e7ba177e37125de208d9612b74cc9ad3d2b52 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 19 Aug 2020 12:32:08 +0100 Subject: [PATCH] Bug 22394: Remove C4::Accounts::manualinvoice MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch removes C4::Accounts::manualinvoice and it's corresponding test. We have been warning deprecation of this method for 18 months (by the time of 20.11 release). Test plan 1/ Apply patch 2/ Ensure no mention of manualinvoice accross the codebase 3/ Run t/db_dependant/Accounts.t and ensure it still passes Signed-off-by: Joonas Kylmälä Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- C4/Accounts.pm | 76 --------------------------------------- t/db_dependent/Accounts.t | 30 +--------------- 2 files changed, 1 insertion(+), 105 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index bf8076d804..7d7ac76018 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -132,82 +132,6 @@ sub chargelostitem { } } -=head2 manualinvoice - - &manualinvoice($borrowernumber, $itemnumber, $description, $type, - $amount, $note); - -This function is now deprecated and not used anywhere within koha. It is due for complete removal in 19.11 - -=cut - -sub manualinvoice { - my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; - - deprecated "C4::Accounts::manualinvoice is deprecated in favor of Koha::Account->add_debit"; - - my $manager_id = C4::Context->userenv ? C4::Context->userenv->{'number'} : undef; - my $dbh = C4::Context->dbh; - my $amountleft = $amount; - - my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; - - my $issue_id; - if ( $type eq 'LOST' && $itemnum ) { - my $checkouts = Koha::Checkouts->search( - { itemnumber => $itemnum, borrowernumber => $borrowernumber } ); - my $checkout = - $checkouts->count - ? $checkouts->next - : Koha::Old::Checkouts->search( - { itemnumber => $itemnum, borrowernumber => $borrowernumber }, - { order_by => { -desc => 'returndate' }, rows => 1 } - )->next; - $issue_id = $checkout ? $checkout->issue_id : undef; - } - - my $accountline = Koha::Account::Line->new( - { - borrowernumber => $borrowernumber, - date => \'NOW()', - amount => $amount, - description => $desc, - debit_type_code => $type, - amountoutstanding => $amountleft, - itemnumber => $itemnum || undef, - issue_id => $issue_id, - note => $note, - manager_id => $manager_id, - interface => C4::Context->interface, - branchcode => $branchcode, - } - )->store(); - - my $account_offset = Koha::Account::Offset->new( - { - debit_id => $accountline->id, - type => 'Manual Debit', - amount => $amount, - } - )->store(); - - if ( C4::Context->preference("FinesLog") ) { - logaction("FINES", 'CREATE',$borrowernumber,Dumper({ - action => 'create_fee', - borrowernumber => $borrowernumber, - amount => $amount, - description => $desc, - debit_type_code => $type, - amountoutstanding => $amountleft, - note => $note, - itemnumber => $itemnum, - manager_id => $manager_id, - })); - } - - return 0; -} - =head2 purge_zero_balance_fees purge_zero_balance_fees( $days ); diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index 49ada1e445..da4d4c3f95 100755 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -18,7 +18,7 @@ use Modern::Perl; -use Test::More tests => 33; +use Test::More tests => 27; use Test::MockModule; use Test::Warn; @@ -45,7 +45,6 @@ BEGIN { can_ok( 'C4::Accounts', qw( chargelostitem - manualinvoice purge_zero_balance_fees ) ); @@ -73,33 +72,6 @@ $context->mock( 'userenv', sub { $context->mock( 'interface', sub { return "commandline" } ); my $userenv_branchcode = $branchcode; -# Test manualinvoice -my $itemtype = $builder->build( { source => 'Itemtype' } ); -my $item = $builder->build_sample_item( { itype => $itemtype->{itemtype} } ); -my $patron = $builder->build( { source => 'Borrower' } ); -my $amount = 5; -my $description = "Test fee!"; -my $type = 'LOST'; -my $note = 'Test note!'; -warning_like { - C4::Accounts::manualinvoice( $patron->{borrowernumber}, - $item->itemnumber, $description, $type, $amount, $note ) -} -qr/C4::Accounts::manualinvoice is deprecated in favor of Koha::Account->add_debit/, - "deprecation warning received for manualinvoice"; -my ($accountline) = Koha::Account::Lines->search( - { - borrowernumber => $patron->{borrowernumber} - } -); -is( $accountline->debit_type_code, $type, 'Debit type set correctly for manualinvoice' ); -is( $accountline->amount+0, $amount, 'Accountline amount set correctly for manualinvoice' ); -ok( $accountline->description =~ /^$description/, 'Accountline description set correctly for manualinvoice' ); -is( $accountline->note, $note, 'Accountline note set correctly for manualinvoice' ); -is( $accountline->branchcode, $branchcode, 'Accountline branchcode set correctly for manualinvoice' ); - -$dbh->do(q|DELETE FROM accountlines|); - # Testing purge_zero_balance_fees # The 3rd value in the insert is 'days ago' -- -- 2.39.5