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>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Sam Lau 2024-06-26 20:17:04 +00:00 committed by Katrin Fischer
parent a4d1e9e093
commit c77a3e4da5
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
3 changed files with 66 additions and 19 deletions

View file

@ -231,7 +231,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
@ -290,6 +291,7 @@ sub void {
manager_id => $params->{staff_id},
interface => $params->{interface},
branchcode => $params->{branch},
note => $params->{note}
}
)->store();

View file

@ -182,16 +182,15 @@
</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">
@ -435,6 +434,45 @@
</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">&times;</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' %]
@ -471,14 +509,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');
@ -520,6 +550,19 @@
$("#discount").attr({ "value": (0).format_price(), "max": amountoutstanding, "min": 0 });
$("#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();
});
});
</script>
[% END %]

View file

@ -75,11 +75,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
}
);
}