From 655caa61e64af3c1fdb12a3a01f28f8d07752609 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Fri, 26 Oct 2018 10:05:11 +0000 Subject: [PATCH] Bug 21681: Remove C4::Accounts::getcharges Test plan: 0) Do not apply the patch 1) Enable ILS-DI 2) Go to /cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=51&show_fines=1 use patron with some paid and unpaid fines 3) Save the page for later usage 4) Apply the patch 5) Repeat 2 with same patron and compare the saved result with the new one, they should be same 6) git grep getcharges should return no occurance 7) prove t/db_dependent/Accounts.t Co-authored-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens --- C4/Accounts.pm | 18 ------------------ C4/ILSDI/Services.pm | 8 ++++---- t/db_dependent/Accounts.t | 1 - 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index 6281becbe8..f03752c543 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -39,7 +39,6 @@ BEGIN { @EXPORT = qw( &manualinvoice &getnextacctno - &getcharges &chargelostitem &ReversePayment &purge_zero_balance_fees @@ -280,23 +279,6 @@ sub manualinvoice { return 0; } -sub getcharges { - my ( $borrowerno, $timestamp, $accountno ) = @_; - my $dbh = C4::Context->dbh; - my $timestamp2 = $timestamp - 1; - my $query = ""; - my $sth = $dbh->prepare( - "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" - ); - $sth->execute( $borrowerno, $accountno ); - - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - push @results,$data; - } - return (@results); -} - #FIXME: ReversePayment should be replaced with a Void Payment feature sub ReversePayment { my ($accountlines_id) = @_; diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 4e0877a551..53465caa9d 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -425,11 +425,11 @@ sub GetPatronInfo { # Fines management if ( $cgi->param('show_fines') && $cgi->param('show_fines') eq "1" ) { - my @charges; - for ( my $i = 1 ; my @charge = getcharges( $borrowernumber, undef, $i ) ; $i++ ) { - push( @charges, @charge ); + + my $account_lines = $patron->account->lines; + while (my $line = $account_lines->next ) { + push @{ $borrower->{fines}{fine} }, $line->unblessed; } - $borrower->{'fines'}->{'fine'} = \@charges; } # Reserves management diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index 26a2957706..4c40012604 100644 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -44,7 +44,6 @@ can_ok( 'C4::Accounts', getnextacctno chargelostitem manualinvoice - getcharges ReversePayment purge_zero_balance_fees ) ); -- 2.39.5