From 363697854a34330933733a61dbc3ce2fa1245b4b Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 22 May 2015 07:27:10 -0400 Subject: [PATCH] [Signed-off] Bug 8055 - reversing fines wonky MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test Plan: 1) Create a fine 2) Make a payment by "Pay amount" 3) Make a partial payment for the fine ( e.g. "Pay" ) 4) Reverse both payments 5) Note the amount owed is now the same as the original fine Patch behaves as advertised. Signed-off-by: Marc VĂ©ron --- C4/Accounts.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index d0709d0..c747791 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -544,13 +544,13 @@ sub ReversePayment { my $sth = $dbh->prepare('SELECT * FROM accountlines WHERE accountlines_id = ?'); $sth->execute( $accountlines_id ); my $row = $sth->fetchrow_hashref(); - my $amount_outstanding = $row->{'amountoutstanding'}; + my $amount = $row->{'amount'}; - if ( $amount_outstanding <= 0 ) { + if ( $amount <= 0 ) { $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE accountlines_id = ?'); $sth->execute( $accountlines_id ); } else { - $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE accountlines_id = ?'); + $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount, description = CONCAT( description, " Reversed -" ) WHERE accountlines_id = ?'); $sth->execute( $accountlines_id ); } @@ -558,17 +558,17 @@ sub ReversePayment { my $manager_id = 0; $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - if ( $amount_outstanding <= 0 ) { - $row->{'amountoutstanding'} *= -1; + if ( $amount <= 0 ) { + $row->{'amountoutstanding'} = $amount * -1; } else { - $row->{'amountoutstanding'} = '0'; + $row->{'amountoutstanding'} = $amount; } $row->{'description'} .= ' Reversed -'; logaction("FINES", 'MODIFY', $row->{'borrowernumber'}, Dumper({ action => 'reverse_fee_payment', borrowernumber => $row->{'borrowernumber'}, - old_amountoutstanding => $row->{'amountoutstanding'}, - new_amountoutstanding => 0 - $amount_outstanding,, + old_amountoutstanding => 0, + new_amountoutstanding => $row->{'amountoutstanding'}, accountlines_id => $row->{'accountlines_id'}, accountno => $row->{'accountno'}, manager_id => $manager_id, -- 1.7.10.4