From eb552fa485979455c7b14db1dc25a495b7d7cbaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick?= Date: Tue, 10 Dec 2013 16:51:39 -0500 Subject: [PATCH] Bug 11373: Show the difference between the amount collected and the amount paid of a fine payment. This patch adds a feature in the fine payment section. It allows to see the change due to patrons when the amount collected is higher than the amount paid. 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. --- .../prog/en/modules/admin/preferences/patrons.pref | 6 ++ .../prog/en/modules/members/paycollect.tt | 89 ++++++++++++++++++---- members/paycollect.pl | 19 +++-- 3 files changed, 93 insertions(+), 21 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 14384b3..62cd227 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -54,12 +54,22 @@
-[% IF ( error_over ) %] +[% IF (error_negative) %]
- You must pay a value less than or equal to [% total_due | format('%.2f') %]. + The amount paid can't be negative.
[% END %] +[% IF (error_collected_less) %] +
+ The amount collected can't be lower than the amount paid. +
+[% END %] + +[% UNLESS (writeoff_individual) %] +
+[% END %] + [% IF ( pay_individual ) %] @@ -84,25 +94,38 @@ Amount outstanding - Total amount payable:[% amountoutstanding | format('%.2f') %] + Total amount payable:[% amountoutstanding | $Price %] [% individual_description | html %] [% accounttype | html %] - [% amount | format('%.2f') %] - [% amountoutstanding | format('%.2f') %] + [% amount | $Price %] + [% amountoutstanding | $Price %]
    - + [% IF FineChange %] +
  1. + + +
  2. - - - + +
  3. +
  4. + + +
  5. + [% ELSE %] +
  6. + + +
  7. + [% END %] [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %] [% IF payment_types %]
  8. @@ -144,12 +167,12 @@ Amount Amount outstanding - Total amount outstanding:[% amountoutstanding | format('%.2f') %] + Total amount outstanding:[% amountoutstanding | $Price %] [% description | html %] [% title | html %] [% accounttype | html %] - [% amount | format('%.2f') %] - [% amountoutstanding | format('%.2f') %] + [% amount | $Price %] + [% amountoutstanding | $Price %] @@ -189,8 +212,27 @@
    1. Total amount outstanding: - [% total | format('%.2f') %] + [% total | $Price %]
    2. + [% IF FineChange %] +
    3. + + +
    4. +
    5. + [% IF type == 'writeoff' %] + + [% ELSE %] + + [% END %] + + +
    6. +
    7. + + +
    8. + [% ELSE %]
    9. [% IF type == 'writeoff' %] @@ -198,8 +240,9 @@ [% END %] - +
    10. + [% END %] [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %] [% IF payment_types %]
    11. @@ -238,9 +281,14 @@ [% Asset.js("js/members-menu.js") | $raw %] [% END %] diff --git a/members/paycollect.pl b/members/paycollect.pl index a15267f..57290d5 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -61,7 +61,9 @@ 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'); my $individual = $input->param('pay_individual'); my $writeoff = $input->param('writeoff_individual'); @@ -96,20 +98,24 @@ if ( $individual || $writeoff ) { individual_description => $description, payment_note => $payment_note, ); -} elsif ($select_lines) { - $total_due = $input->param('amt'); +} elsif ($select) { + $total_due = ($input->param('amt') || $input->param('total')); $template->param( - selected_accts => $select_lines, + selected_accts => $select, amt => $total_due, selected_accts_notes => scalar $input->param('notes'), ); } if ( $total_paid and $total_paid ne '0.00' ) { - if ( $total_paid < 0 or $total_paid > $total_due ) { + if ( $total_paid < 0 ) { $template->param( - error_over => 1, - total_due => $total_due + error_negative => 1, + ); + } + elsif ($fine_change and ($total_collected - $total_paid) < 0) { + $template->param( + error_collected_less => 1, ); } else { die "Wrong CSRF token" @@ -194,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