From 0b6537ac86593cf8ffd26a162e419379bf7cd1a7 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 30 Apr 2018 06:57:41 -0400 Subject: [PATCH] Bug 20629: Remove ability to 'reverse' payments --- C4/Accounts.pm | 47 ---------------------- Koha/Account/Line.pm | 16 ++++++++ .../prog/en/modules/members/boraccount.tt | 1 - members/boraccount.pl | 7 +--- members/printfeercpt.pl | 4 -- 5 files changed, 18 insertions(+), 57 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index eef9766b20..279580940e 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -42,7 +42,6 @@ BEGIN { &getnextacctno &getcharges &chargelostitem - &ReversePayment &purge_zero_balance_fees ); } @@ -329,52 +328,6 @@ sub getcharges { return (@results); } -#FIXME: ReversePayment should be replaced with a Void Payment feature -sub ReversePayment { - my ($accountlines_id) = @_; - my $dbh = C4::Context->dbh; - - my $accountline = Koha::Account::Lines->find($accountlines_id); - my $amount_outstanding = $accountline->amountoutstanding; - - my $new_amountoutstanding = - $amount_outstanding <= 0 ? $accountline->amount * -1 : 0; - - $accountline->description( $accountline->description . " Reversed -" ); - $accountline->amountoutstanding($new_amountoutstanding); - $accountline->store(); - - my $account_offset = Koha::Account::Offset->new( - { - credit_id => $accountline->id, - type => 'Reverse Payment', - amount => $amount_outstanding - $new_amountoutstanding, - } - )->store(); - - if ( C4::Context->preference("FinesLog") ) { - my $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - - logaction( - "FINES", 'MODIFY', - $accountline->borrowernumber, - Dumper( - { - action => 'reverse_fee_payment', - borrowernumber => $accountline->borrowernumber, - old_amountoutstanding => $amount_outstanding, - new_amountoutstanding => $new_amountoutstanding, - , - accountlines_id => $accountline->id, - accountno => $accountline->accountno, - manager_id => $manager_id, - } - ) - ); - } -} - =head2 purge_zero_balance_fees purge_zero_balance_fees( $days ); diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index b32f9a7b91..c1be7cd711 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -125,6 +125,22 @@ sub void { } +=head3 is_payment + +$accountline->is_payment(); + +=cut + +sub is_payment { + my ($self) = @_; + + return Koha::Account::Offsets->search( + { + credit_id => $self->id + } + )->count(); +} + =head3 _type =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt index f91f929ff0..8e20600893 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -72,7 +72,6 @@ Details [% IF ( reverse_col) %] [% IF ( account.payment ) %] - Reverse Void [% ELSE %][% SET footerjs = 1 %]   diff --git a/members/boraccount.pl b/members/boraccount.pl index b3d1431e58..f5c6518eb6 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -60,10 +60,7 @@ unless ( $patron ) { output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); -if ( $action eq 'reverse' ) { - ReversePayment( scalar $input->param('accountlines_id') ); -} -elsif ( $action eq 'void' ) { +if ( $action eq 'void' ) { my $payment_id = scalar $input->param('accountlines_id'); my $payment = Koha::Account::Lines->find( $payment_id ); $payment->void(); @@ -104,7 +101,7 @@ while ( my $line = $accts->next ) { $accountline->{amount} = sprintf '%.2f', $accountline->{amount}; $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding}; - if ($accountline->{accounttype} =~ /^Pay/) { + if ( $line->is_payment ) { $accountline->{payment} = 1; $reverse_col = 1; } diff --git a/members/printfeercpt.pl b/members/printfeercpt.pl index c73f8f5bf4..91a4180252 100755 --- a/members/printfeercpt.pl +++ b/members/printfeercpt.pl @@ -54,10 +54,6 @@ my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in" my $patron = Koha::Patrons->find( $borrowernumber ); output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); -if ( $action eq 'print' ) { -# ReversePayment( $borrowernumber, $input->param('accountno') ); -} - if ( $patron->is_child ) { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; -- 2.15.1 (Apple Git-101)