Browse Source

Bug 22394: Remove C4::Accounts::manualinvoice

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ä <joonas.kylmala@helsinki.fi>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Martin Renvoize 4 years ago
committed by Jonathan Druart
parent
commit
c65e7ba177
  1. 76
      C4/Accounts.pm
  2. 30
      t/db_dependent/Accounts.t

76
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 );

30
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' --

Loading…
Cancel
Save