From 3f85c9b16b43a98c75f7344cfa389b38c56be022 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 30 Apr 2018 12:47:26 -0400 Subject: [PATCH] Bug 19617: Allow 'writeoff of selected' This patch adds a writeoff equivilent to 'Pay selected' Test Plan: 1) Apply this patch 2) Find a patron with fines 3) On the "Pay fines" tab, select one or more fines and use the "Write off selected" button. 4) Note the fine amount you used was written off for those fines. Signed-off-by: Kyle M Hall Signed-off-by: Martha Fuerst Signed-off-by: Tomas Cohen Arazi Signed-off-by: Nick Clemens --- .../prog/en/modules/members/pay.tt | 1 + .../prog/en/modules/members/paycollect.tt | 26 ++++++++++++---- members/pay.pl | 30 +++++++++++-------- members/paycollect.pl | 3 ++ 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt index 80abac023e..c234c23eec 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt @@ -121,6 +121,7 @@ [% IF CAN_user_updatecharges_writeoff %][% END %] + Cancel diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt index fb42d4317a..cead73e2f2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -12,7 +12,7 @@ [% INCLUDE 'header.inc' %] [% INCLUDE 'patron-search.inc' %] - +
@@ -158,16 +158,30 @@ +
- [% IF ( selected_accts ) %]Pay an amount toward selected fines[% ELSE %]Pay an amount toward all fines[% END %] + [% IF ( selected_accts ) %] + [% IF type == 'writeoff' %] + Write off an amount toward selected fines + [% ELSE %] + Pay an amount toward selected fines + [% END %] + [% ELSE %] + Pay an amount toward all fines + [% END %] +
  1. Total amount outstanding: [% total | format('%.2f') %]
  2. - + [% IF type == 'writeoff' %] + + [% ELSE %] + + [% END %]
  3. @@ -189,8 +203,10 @@
- +
+ + Cancel +
[% END %]
diff --git a/members/pay.pl b/members/pay.pl index 1d4c5b0c22..c96e67944b 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -74,24 +74,23 @@ $user ||= q{}; our $branch = C4::Context->userenv->{'branch'}; -my $writeoff_item = $input->param('confirm_writeoff'); -my $paycollect = $input->param('paycollect'); -if ($paycollect) { +if ( $input->param('paycollect') ) { print $input->redirect( "/cgi-bin/koha/members/paycollect.pl?borrowernumber=$borrowernumber"); } -my $payselected = $input->param('payselected'); -if ($payselected) { - payselected(@names); +elsif ( $input->param('payselected') ) { + payselected({ params => \@names }); } - -my $writeoff_all = $input->param('woall'); # writeoff all fines -if ($writeoff_all) { +elsif ( $input->param('writeoff_selected') ) { + payselected({ params => \@names, type => 'writeoff' }); +} +elsif ( $input->param('woall') ) { writeoff_all(@names); -} elsif ($writeoff_item) { +} +elsif ( $input->param('confirm_writeoff') ) { my $accountlines_id = $input->param('accountlines_id'); - my $amount = $input->param('amountwrittenoff'); - my $payment_note = $input->param("payment_note"); + my $amount = $input->param('amountwrittenoff'); + my $payment_note = $input->param("payment_note"); my $accountline = Koha::Account::Lines->find( $accountlines_id ); @@ -252,7 +251,11 @@ sub borrower_add_additional_fields { } sub payselected { - my @params = @_; + my $parameters = shift; + + my @params = @{ $parameters->{params} }; + my $type = $parameters->{type} || 'payment'; + my $amt = 0; my @lines_to_pay; foreach (@params) { @@ -267,6 +270,7 @@ sub payselected { my $notes = '¬es=' . join("%0A", map { scalar $input->param("payment_note_$_") } @lines_to_pay ); my $redirect = "/cgi-bin/koha/members/paycollect.pl?borrowernumber=$borrowernumber" + . "&type=$type" . $amt . $sel . $notes; diff --git a/members/paycollect.pl b/members/paycollect.pl index f1f9f16e97..4da6708c2d 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -69,6 +69,7 @@ my $select_lines = $input->param('selected'); my $select = $input->param('selected_accts'); my $payment_note = uri_unescape scalar $input->param('payment_note'); my $payment_type = scalar $input->param('payment_type'); +my $type = scalar $input->param('type') || 'payment', my $accountlines_id; if ( $individual || $writeoff ) { @@ -153,6 +154,7 @@ if ( $total_paid and $total_paid ne '0.00' ) { } )->pay( { + type => $type, amount => $total_paid, lines => \@lines, note => $note, @@ -187,6 +189,7 @@ if ( $input->param('error_over') ) { } $template->param( + type => $type, borrowernumber => $borrowernumber, # some templates require global patron => $patron, total => $total_due, -- 2.39.2