Bug 23507: Add ability to show change given on auto-popup fee receipt from FinePaymentAutoPopup

Some libraries would like to show the amount of change given on print reciepts triggered by FinePaymentAutoPopup
so the patron can verify he or she has recieved the correct amount of change.

1) Apply this patch
2) Edit ACCOUNT_CREDIT slip and add "[% IF change_given %]<h1>CHANGE: [% change_given %]</h1>[% END %]" at the top
3) Enable FinePaymentAutoPopup
4) Make a payment
5) Note the change given is shown on the popup receipt
6) Note the change given is *not* shown on subsequent prints of the same receipt using the "print" button for the payment

Signed-off-by: Kyle Hall <kyle@bywatersolutions.com>
Signed-off-by: Hasina Akhte <hasinaa@pascolibraries.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Kyle M Hall 2019-08-26 14:33:29 -04:00 committed by Martin Renvoize
parent 6d9bc489a2
commit 1feb110d05
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
7 changed files with 21 additions and 6 deletions

View File

@ -121,7 +121,7 @@
<script>
$(document).ready(function() {
[% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&change_given=[% change_given | html %]&accountlines_id=[% payment_id | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
[% END %]
var txtActivefilter = _("Filter paid transactions");

View File

@ -180,7 +180,7 @@
}
$(document).ready(function(){
[% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id | html %]&change_given=[% change_given | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
[% END %]
$('#pay-fines-form').preventDoubleFormSubmit();

View File

@ -78,6 +78,7 @@
<input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
<input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
<input type="hidden" name="title" id="title" value="[% title | html %]" />
<input type="hidden" name="change_given" id="change_given" />
<fieldset class="rows">
<legend>Pay an individual fine</legend>
@ -167,6 +168,7 @@
<input type="hidden" name="payment_note" id="payment_note" value="[% payment_note | html %]" />
<input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
<input type="hidden" name="confirm_writeoff" id="confirm_writeoff" value="1" />
<input type="hidden" name="change_given" id="change_given" />
<table>
<thead><tr>
<th>Description</th>
@ -209,6 +211,7 @@
<input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts | html %]" />
<input type="hidden" name="total" id="total" value="[% total | html %]" />
<input type="hidden" name="type" value="[% type | html %]" />
<input type="hidden" name="change_given" id="change_given" />
<fieldset class="rows">
[% IF ( selected_accts ) %]
@ -324,7 +327,7 @@
<script>
$(document).ready(function() {
[% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id | html %]&change_given=[% change_given | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
[% END %]
var forms = $('#payindivfine, #payfine');
@ -431,10 +434,12 @@
change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
if (change.innerHTML <= 0) {
change.innerHTML = "0.00";
$('input[name="change_given"]').val('0.00');
} else {
change.value = change.innerHTML;
moneyFormat(change);
change.innerHTML = change.value;
$('input[name="change_given"]').val(change.value);
}
$('#modal_change').html(change.innerHTML);

View File

@ -49,6 +49,7 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user(
my $borrowernumber = $input->param('borrowernumber');
my $payment_id = $input->param('payment_id');
my $change_given = $input->param('change_given');
my $action = $input->param('action') || '';
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
@ -86,6 +87,7 @@ $template->param(
totalcredit => $totalcredit,
accounts => \@accountlines,
payment_id => $payment_id,
change_given => $change_given,
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -64,6 +64,7 @@ if ( !$borrowernumber ) {
}
my $payment_id = $input->param('payment_id');
our $change_given = $input->param('change_given');
# get borrower details
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
@ -77,7 +78,7 @@ our $branch = C4::Context->userenv->{'branch'};
if ( $input->param('paycollect') ) {
print $input->redirect(
"/cgi-bin/koha/members/paycollect.pl?borrowernumber=$borrowernumber");
"/cgi-bin/koha/members/paycollect.pl?borrowernumber=$borrowernumber&change_given=$change_given");
}
elsif ( $input->param('payselected') ) {
payselected({ params => \@names });
@ -105,6 +106,7 @@ elsif ( $input->param('confirm_writeoff') ) {
. "&amountoutstanding=" . $accountline->amountoutstanding
. "&accounttype=" . $accountline->accounttype
. "&accountlines_id=" . $accountlines_id
. "&change_given=" . $change_given
. "&writeoff_individual=1"
. "&error_over=1" );
@ -135,6 +137,7 @@ for (@names) {
$template->param(
finesview => 1,
payment_id => $payment_id,
change_given => $change_given,
);
add_accounts_to_template();
@ -198,6 +201,7 @@ sub redirect_to_paycollect {
$redirect .= get_for_redirect( 'accountlines_id', "accountlines_id$line_no", 0 );
$redirect .= q{&} . 'payment_note' . q{=} . uri_escape_utf8( scalar $input->param("payment_note_$line_no") );
$redirect .= '&remote_user=';
$redirect .= "change_given=$change_given";
$redirect .= $user;
return print $input->redirect($redirect);
}

View File

@ -39,6 +39,7 @@ my $input = CGI->new();
my $payment_id = $input->param('payment_id');
my $writeoff_individual = $input->param('writeoff_individual');
my $change_given = $input->param('change_given');
my $type = scalar $input->param('type') || 'payment';
my $updatecharges_permissions = ($writeoff_individual || $type eq 'writeoff') ? 'writeoff' : 'remaining_permissions';
@ -162,7 +163,7 @@ if ( $total_paid and $total_paid ne '0.00' ) {
}
);
print $input->redirect(
"/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber&payment_id=$payment_id");
"/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=$change_given");
} else {
if ($select) {
if ( $select =~ /^([\d,]*).*/ ) {
@ -208,7 +209,7 @@ if ( $total_paid and $total_paid ne '0.00' ) {
);
}
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber&payment_id=$payment_id");
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=$change_given");
}
}
} else {

View File

@ -50,6 +50,7 @@ my ($template, $loggedinuser, $cookie)
my $borrowernumber=$input->param('borrowernumber');
my $action = $input->param('action') || '';
my $accountlines_id = $input->param('accountlines_id');
my $change_given = $input->param('change_given');
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
my $patron = Koha::Patrons->find( $borrowernumber );
@ -92,6 +93,8 @@ $template->param(
total => $total,
totalcredit => $totalcredit,
accounts => [$accountline], # FIXME There is always only 1 row!
change_given => $change_given,
);
output_html_with_http_headers $input, $cookie, $template->output;