Bugzilla – Attachment 71152 Details for
Bug 20120
Prevent writeoffs of more than the amount owed for a fee
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20120 - Writeoffs for individual fees allows an amount to be written off more than the amount of the fee
Bug-20120---Writeoffs-for-individual-fees-allows-a.patch (text/plain), 5.00 KB, created by
Biblibre Sandboxes
on 2018-02-02 16:19:34 UTC
(
hide
)
Description:
Bug 20120 - Writeoffs for individual fees allows an amount to be written off more than the amount of the fee
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2018-02-02 16:19:34 UTC
Size:
5.00 KB
patch
obsolete
>From 9851837bd90f1f0292b5a00be26b27e635f0cd08 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatetsolutions.com> >Date: Thu, 1 Feb 2018 09:50:06 -0500 >Subject: [PATCH] Bug 20120 - Writeoffs for individual fees allows an amount to > be written off more than the amount of the fee > >In short, it is possible to 'over-writeoff' a fee such that the value of the fee is now a credit. > >Test Plan: >1) Attempt to writeoff a single fee, set the amount input to more than > the amount of the fee. >2) Note the writeoff makes the fee go negative >3) Apply this patch >4) Attempt to repeat step 1, you should not be able to over-writeoff the > fee > >Signed-off-by: George Williams <george@nekls.org> >--- > .../intranet-tmpl/prog/en/modules/members/pay.tt | 6 ++++++ > .../prog/en/modules/members/paycollect.tt | 24 ++++++++++++++++++++-- > members/pay.pl | 10 +++++++++ > 3 files changed, 38 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt >index c9a5a30..304a95d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt >@@ -66,6 +66,12 @@ function enableCheckboxActions(){ > <li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual credit</a></li> > </ul> > <div class="tabs-container"> >+ [% IF ( error_over ) %] >+ <div id="error_message" class="dialog alert"> >+ The writeoff submitted was more than the value of the fee being written off. >+ The amount of the writeoff has been reduced from [% error_amount | format('%.2f') %] to [% error_amount_outstanding | format('%.2f') %]. >+ </div> >+ [% END %] > > [% IF ( accounts ) %] > <form action="/cgi-bin/koha/members/pay.pl" method="post" id="pay-fines-form"> >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 7629874..c56111f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >@@ -6,10 +6,28 @@ > <script type= "text/javascript"> > //<![CDATA[ > $(document).ready(function() { >- $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit(); >+ $('#payindivfine, #payfine').preventDoubleFormSubmit(); > $("#paid").on("change",function(){ > moneyFormat( this ); > }); >+ >+ prevent_default = 1; >+ $('#woindivfine').on('submit', function(e){ >+ if ( prevent_default ) { >+ e.preventDefault(); >+ >+ let amount_outstanding = $('#amountoutstanding').attr('value'); >+ let amount_writeoff = $('#amountwrittenoff').attr('value');; >+ if ( amount_writeoff > amount_outstanding ) { >+ alert(_("You are attemping to writeoff more than the value of the fee.")); >+ $('#woindivfine').beenSubmitted = false; >+ } else { >+ prevent_default = 0; >+ $('#woindivfine').preventDoubleFormSubmit(); >+ $('#woindivfine').submit(); >+ } >+ } >+ }); > }); > > function moneyFormat(textObj) { >@@ -162,6 +180,7 @@ function moneyFormat(textObj) { > <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" /> > <input type="hidden" name="title" id="title" value="[% title %]" /> > <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" /> >+ <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" /> > <table> > <thead><tr> > <th>Description</th> >@@ -186,7 +205,8 @@ function moneyFormat(textObj) { > </li> > </ol> > </fieldset> >- <div class="action"><input type="submit" name="confirm_writeoff" id="confirm_writeoff" value="Write off this charge" /> >+ <input type="hidden" name="confirm_writeoff" value="1" /> >+ <div class="action"><input type="submit" value="Write off this charge" /> > <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a></div> > </form> > [% ELSE %] >diff --git a/members/pay.pl b/members/pay.pl >index a248db0..7714b9e 100755 >--- a/members/pay.pl >+++ b/members/pay.pl >@@ -98,8 +98,18 @@ if ($writeoff_all) { > } elsif ($writeoff_item) { > my $accountlines_id = $input->param('accountlines_id'); > my $amount = $input->param('amountwrittenoff'); >+ my $amount_outstanding = $input->param('amountoutstanding'); > my $payment_note = $input->param("payment_note"); > >+ if ( $amount > $amount_outstanding ) { >+ $template->param( >+ error_over => 1, >+ error_amount => $amount, >+ error_amount_outstanding => $amount_outstanding, >+ ); >+ $amount = $amount_outstanding; >+ } >+ > Koha::Account->new( { patron_id => $borrowernumber } )->pay( > { > amount => $amount, >-- >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 20120
:
71113
|
71152
|
71176
|
71177
|
71358
|
72598
|
72984
|
74713
|
74732
|
74910
|
74920
|
74921
|
75016
|
75917