@@ -, +, @@ to show the change in the form. - 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. --- .../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(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ a/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 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ a/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 @@
[% END %] -[% IF (give_change) %] -
- The amount collected is greater than the total amount paid.
- Change to give back: [% give_change | $Price %]

- - Cancel -
-[% END %] - [% IF ( pay_individual ) %] @@ -117,31 +107,25 @@
    - [% IF ( give_change ) %] + [% IF FineChange %]
  1. - - - [% amount_paid | $Price %] +
  2. - - [% amount_collected | $Price %] + +
  3. - [% give_change | $Price %] +
  4. [% ELSE %]
  5. - - - [% amount_paid | $Price %] -
  6. -
  7. - - + +
  8. + [% END %] [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %] [% IF payment_types %]
  9. @@ -154,7 +138,6 @@
  10. [% END %] - [% END %]
@@ -231,35 +214,35 @@ Total amount outstanding: [% total | $Price %] - [% IF ( give_change ) %] + [% IF FineChange %]
  • - - - [% amount_paid | $Price %] + +
  • - - - [% amount_collected | $Price %] + [% IF type == 'writeoff' %] + + [% ELSE %] + + [% END %] + +
  • - [% give_change | $Price %] +
  • [% ELSE %]
  • - - -
  • -
  • [% IF type == 'writeoff' %] - + [% ELSE %] - + [% END %] - +
  • + [% END %] [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %] [% IF payment_types %]
  • @@ -272,7 +255,6 @@
  • [% END %] - [% END %]
  • @@ -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); + } + } [% END %] --- a/members/paycollect.pl +++ a/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') }), ); --