From 1c89950cbedd712a078d6302ea882798436716e2 Mon Sep 17 00:00:00 2001 From: Sam Lau <samalau@gmail.com> Date: Wed, 26 Jun 2024 20:17:04 +0000 Subject: [PATCH] Bug 23674: Add ability to add note to void payment To test: 1) From patron accounting page -> Create manual credit. Put in some amount and press add credit. 2) Under the actions column, select "Void" 3) Notice no option for a note. Press cancel 4) Apply patch, restart_all 5) Press void again. This time, you should see a modal that gives you the option to type in a note. 6) Type something in and select submit. 7) Ensure the note shows up in the note column. Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> --- Koha/Account/Line.pm | 4 +- .../prog/en/modules/members/boraccount.tt | 60 +++++++++++++------ members/boraccount.pl | 2 + 3 files changed, 47 insertions(+), 19 deletions(-) diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index 516b1fe461..08cb01995a 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -236,7 +236,8 @@ sub debits { $payment_accountline->void({ interface => $interface, - [ staff_id => $staff_id, branch => $branchcode ] + [ staff_id => $staff_id, branch => $branchcode ], + note => $note }); Used to 'void' (or reverse) a payment/credit. It will roll back any offsets @@ -301,6 +302,7 @@ sub void { manager_id => $params->{staff_id}, interface => $params->{interface}, branchcode => $params->{branch}, + note => $params->{note} } )->store(); 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 0b2b1d7f49..b3938bd33e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -176,16 +176,7 @@ </form> [% END %] [% IF account.is_credit && account.status != 'VOID' %] - <form method="post" action="/cgi-bin/koha/members/boraccount.pl"> - [% INCLUDE 'csrf-token.inc' %] - <input type="hidden" name="op" value="cud-void" /> - <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]"> - <input type="hidden" name="accountlines_id" value="[% account.accountlines_id | html %]"> - <button type="submit" class="btn btn-default btn-xs void-action"> - <i class="fa fa-ban"></i> - Void payment - </button> - </form> + <button type="button" data-toggle="modal" data-target="#voidPaymentModal" data-accountline="[% account.accountlines_id | html %]" data-member="[% account.borrowernumber | html %]" class="btn btn-default btn-xs void-action"><i class="fa fa-ban"></i> Void payment</button> [% END %] [% IF account.is_debit && account.amount == account.amountoutstanding && account.status != 'CANCELLED' && !(account.debit_type_code == 'PAYOUT') %] <form method="post" action="/cgi-bin/koha/members/cancel-charge.pl"> @@ -399,6 +390,39 @@ </form> <!-- /#discount_form --> </div> <!-- /#applyDiscountModal --> + <!-- Void payment modal --> + <div class="modal" id="voidPaymentModal" tabindex="-1" role="dialog" aria-labelledby="voidPaymentLabel"> + <form id="void_form" action="/cgi-bin/koha/members/boraccount.pl" method="post" enctype="multipart/form-data" class="validated"> + [% INCLUDE 'csrf-token.inc' %] + <input type="hidden" name="accountlines_id" value="" id="voidline"> + <input type="hidden" name="op" value="cud-void"> + <input type="hidden" name="borrowernumber" value="[% account.borrowernumber | html %]"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title" id="voidPaymentLabel">Void payment</h4> + </div> + <div class="modal-body"> + <fieldset class="rows"> + <ol> + <li> + <label for="apply_discount_note">Note: </label> + <input type="text" id="void_note" name="void_note"> + </li> + </ol> + </fieldset> <!-- /.rows --> + </div> <!-- /.modal-body --> + <div class="modal-footer"> + <button type="submit" class="btn btn-default">Confirm</button> + <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> + </div> <!-- /.modal-footer --> + </div> <!-- /.modal-content --> + </div> <!-- /.modal-dialog --> + </form> <!-- /#void_form --> + </div> <!-- /#voidPaymentModal --> + + [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'format_price.inc' %] @@ -433,14 +457,6 @@ $(this).toggleClass('filtered'); }); - $(".void-action").on("click",function(e){ - if( confirm( _("Are you sure you want to void this credit?") ) ) { - return true; - } else { - e.preventDefault(); - } - }); - $("#issuePayoutModal").on("shown.bs.modal", function(e){ var button = $(e.relatedTarget); var accountline = button.data('accountline'); @@ -483,6 +499,14 @@ $("#discount").focus(); }); + $("#voidPaymentModal").on("shown.bs.modal", function(e){ + var button = $(e.relatedTarget); + var item = button.data('item'); + $("#item + span").replaceWith(item); + var accountline = button.data('accountline'); + $('#voidline').val(accountline); + }); + $(".receipt-email-action").on("click", function(e){ e.preventDefault(); return $(this).siblings('form').submit(); diff --git a/members/boraccount.pl b/members/boraccount.pl index ee6ab273b6..2f3bbdf8db 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -73,11 +73,13 @@ if ( $op eq 'cud-void' ) { output_and_exit_if_error($input, $cookie, $template, { check => 'csrf_token' }); my $payment_id = scalar $input->param('accountlines_id'); my $payment = Koha::Account::Lines->find( $payment_id ); + my $note = scalar $input->param('void_note'); $payment->void( { branch => $library_id, staff_id => $logged_in_user->id, interface => 'intranet', + note => $note } ); } -- 2.39.2