Bugzilla – Attachment 79507 Details for
Bug 11373
Add "change calculation" feature to the fine payment forms
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
System preference added, dialog removed, disabled input added to show the change in the form.
System-preference-added-dialog-removed-disabled-in.patch (text/plain), 10.41 KB, created by
Pierre-Marc Thibault
on 2018-09-27 13:32:08 UTC
(
hide
)
Description:
System preference added, dialog removed, disabled input added to show the change in the form.
Filename:
MIME Type:
Creator:
Pierre-Marc Thibault
Created:
2018-09-27 13:32:08 UTC
Size:
10.41 KB
patch
obsolete
>From a83f82048f8f21b9294f3452ebc72a10b040594a Mon Sep 17 00:00:00 2001 >From: Pierre-Marc Thibault <pierre-marc.thibault@inLibro.com> >Date: Wed, 26 Sep 2018 08:26:52 -0400 >Subject: [PATCH] System preference added, dialog removed, disabled input added > to show the change in the form. > >This patch removes the dialog because it was redundant with the form. As the numbers fields are formated when they are changed, it is convenient to calculate and show the change at the same time. When the change value cannot be calculated (amount collected < amount paid), its value is brought back to 0.00. This includes also a new system preference called FineChange which enables or disables the feature. > >Test plan : >- Apply patch. >- Make sure FineChange is at ENABLE in System preferences > Patrons. >- Select a patron with a fine. >- Go to Fines > Pay fines. >- Click the button pay. >- Choose the amount paid equal to the outstanding amount (exemple : 3$). >- Choose the amount collected to be more than the outstanding amount (exemple : 5$) >- Confirm that the change is correct (example : 5$ - 3$ = 2$) >- Click the button confirm. >- Confirm that the payment has been made. >- Make sure FineChange is at DISABLE in System preferences > Patrons. >- Select a patron with a fine and go to Fines > Pay fines. >- Confirm that the input change is gone. >- Choose an amount collected (exemple : 3$). >- Click the button confirm. >- Confirm that the payment has been made. > >https://bugs.koha-community.org/show_bug.cgi?id=11373 >--- > .../prog/en/modules/admin/preferences/patrons.pref | 6 ++ > .../prog/en/modules/members/paycollect.tt | 80 +++++++++++----------- > members/paycollect.pl | 18 +---- > 3 files changed, 48 insertions(+), 56 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index 8c8227d4..2a6dbaf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -213,6 +213,12 @@ Patrons: > yes: Allow only superlibrarians > no: Allow all permitted users > - "to access/change superlibrarian privileges. Note: A permitted user needs to have the 'permissions' flag (if no superlibrarian)." >+ - >+ - pref: FineChange >+ choices: >+ yes: Enable >+ no: Disable >+ - fine change display when a user pays a fine. > Privacy: > - > - Use the following URL >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 3b85e73..62cd227 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >@@ -1,7 +1,6 @@ > [% USE raw %] > [% USE Asset %] > [% USE Koha %] >-[% USE Price %] > [% USE Branches %] > [% USE AuthorisedValues %] > [% USE Price %] >@@ -71,15 +70,6 @@ > <form name="payform" id="payform" action="/cgi-bin/koha/members/paycollect.pl" method="post"> > [% END %] > >-[% IF (give_change) %] >- <div id="change_message" class="dialog message"> >- <span>The amount collected is greater than the total amount paid.</span><br /> >- <strong>Change to give back: [% give_change | $Price %]</strong><br /><br /> >- <input type="submit" name="submitbutton" value="Confirm payment" /> >- <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a> >- </div> >-[% END %] >- > [% IF ( pay_individual ) %] > <form name="payindivfine" id="payindivfine" method="post" action="/cgi-bin/koha/members/paycollect.pl"> > <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" /> >@@ -117,31 +107,25 @@ > </table> > > <ol> >- [% IF ( give_change ) %] >+ [% IF FineChange %] > <li> > <label for="paid">Amount paid:</label> >- <input type="hidden" name="paid" id="paid" value="[% amount_paid %]" /> >- <input type="hidden" name="collected" id="collected" value="[% amount_paid %]" /> >- [% amount_paid | $Price %] >+ <input name="paid" id="paid" value="[% amountoutstanding | $Price %]"/> > </li> > <li> >- <label>Collect from patron:</label> >- [% amount_collected | $Price %] >+ <label for="collected">Collect from patron:</label> >+ <input name="collected" id="collected" value="[% amountoutstanding | $Price %]"/> > </li> > <li> > <label>Change to give back:</label> >- [% give_change | $Price %] >+ <input id="change" value="0.00" disabled/> > </li> > [% ELSE %] > <li> >- <label for="paid">Amount paid:</label> >- <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" onchange="moneyFormat(document.payform.paid)"/> >- [% amount_paid | $Price %] >- </li> >- <li> >- <label for="collected">Collect from patron:</label> >- <input name="collected" id="collected" value="[% amountoutstanding %]" onchange="moneyFormat(document.payform.collected)" /> >+ <label for="paid">Collect from patron:</label> >+ <input name="paid" id="collected" value="[% amountoutstanding | $Price %]"/> > </li> >+ [% END %] > [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %] > [% IF payment_types %] > <li> >@@ -154,7 +138,6 @@ > </select> > </li> > [% END %] >- [% END %] > </ol> > </fieldset> > >@@ -231,35 +214,35 @@ > <span class="label">Total amount outstanding: </span> > <span class="debit">[% total | $Price %]</span> > </li> >- [% IF ( give_change ) %] >+ [% IF FineChange %] > <li> >- <label for="paid">Amount paid:</label> >- <input type="hidden" name="paid" id="paid" value="[% amount_paid %]" /> >- [% amount_paid | $Price %] >+ <label for="paid">Amount paid :</label> >+ <input name="paid" id="paid" value="[% total | $Price %]"/> > </li> > <li> >- <label>Collected from patron:</label> >- <input type="hidden" name="collected" id="collected" value="[% amount_paid %]" /> >- [% amount_collected | $Price %] >+ [% IF type == 'writeoff' %] >+ <label for="collected">Writeoff amount: </label> >+ [% ELSE %] >+ <label for="collected">Collect from patron: </label> >+ [% END %] >+ <!-- default to paying all --> >+ <input name="collected" id="collected" value="[% total | $Price %]"/> > </li> > <li> > <label>Change to give back:</label> >- [% give_change | $Price %] >+ <input id="change" value="0.00" disabled/> > </li> > [% ELSE %] > <li> >- <label for="paid">Amount paid :</label> >- <input name="paid" id="paid" value="[% total %]" onchange="moneyFormat(document.payform.paid)" /> >- </li> >- <li> > [% IF type == 'writeoff' %] >- <label for="collected">Writeoff amount: </label> >+ <label for="paid">Writeoff amount: </label> > [% ELSE %] >- <label for="collected">Collect from patron: </label> >+ <label for="paid">Collect from patron: </label> > [% END %] > <!-- default to paying all --> >- <input name="collected" id="collected" value="[% total %]" onchange="moneyFormat(document.payform.collected)"/> >+ <input name="paid" id="paid" value="[% total | $Price %]"/> > </li> >+ [% END %] > [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %] > [% IF payment_types %] > <li> >@@ -272,7 +255,6 @@ > </select> > </li> > [% END %] >- [% END %] > <li> > <label for="selected_accts_notes">Note: </label> > <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea> >@@ -302,6 +284,11 @@ > $('#payindivfine, #payfine, #payform').preventDoubleFormSubmit(); > $("#paid").on("change",function(){ > moneyFormat( this ); >+ updateChangeInput(); >+ }); >+ $("#collected").on("change",function(){ >+ moneyFormat( this ); >+ updateChangeInput(); > }); > }); > >@@ -371,6 +358,17 @@ > > textObj.value = dolAmount + "." + decAmount; > } >+ >+ function updateChangeInput() { >+ var change = $('#change')[0]; >+ change.value = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100; >+ >+ if (change.value < 0) { >+ change.value = change.defaultValue; >+ } else { >+ moneyFormat(change); >+ } >+ } > </script> > [% END %] > >diff --git a/members/paycollect.pl b/members/paycollect.pl >index 4296208..57290d5 100755 >--- a/members/paycollect.pl >+++ b/members/paycollect.pl >@@ -61,6 +61,7 @@ my $user = $input->remote_user; > my $branch = C4::Context->userenv->{'branch'}; > my $total_due = $patron->account->outstanding_debits->total_outstanding; > >+my $fine_change = C4::Context->preference('FineChange'); > my $total_paid = $input->param('paid'); > my $total_collected = $input->param('collected'); > >@@ -112,24 +113,10 @@ if ( $total_paid and $total_paid ne '0.00' ) { > error_negative => 1, > ); > } >- elsif (($total_collected - $total_paid) < 0) { >+ elsif ($fine_change and ($total_collected - $total_paid) < 0) { > $template->param( > error_collected_less => 1, > ); >- } >- elsif ($total_paid >= $total_due and $total_collected ne $total_paid) { >- $template->param( >- amount_paid => $total_due, >- amount_collected => $total_collected, >- give_change => $total_collected-$total_due, >- ); >- } >- elsif ($total_paid < $total_due and $total_collected ne $total_paid) { >- $template->param( >- amount_paid => $total_paid, >- amount_collected => $total_collected, >- give_change => $total_collected-$total_paid, >- ); > } else { > die "Wrong CSRF token" > unless Koha::Token->new->check_csrf( { >@@ -213,6 +200,7 @@ $template->param( > patron => $patron, > total => $total_due, > ExtendedPatronAttributes => C4::Context->preference('ExtendedPatronAttributes'), >+ FineChange => $fine_change, > > csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }), > ); >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11373
:
23382
|
26103
|
26108
|
29757
|
29938
|
36875
|
36876
|
36877
|
60528
|
60529
|
61233
|
61234
|
67348
|
68296
|
70043
|
71975
|
71976
|
77584
|
77585
|
79122
|
79171
|
79188
|
79507
|
79509
|
79529
|
79530
|
79538
|
79549
|
79759
|
79944
|
79951
|
80414
|
80986
|
82420
|
82797
|
83804
|
83812
|
83813
|
84653
|
84654