Bugzilla – Attachment 74732 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: Prevent writeoffs of more than the amount owed for a fee
Bug-20120-Prevent-writeoffs-of-more-than-the-amoun.patch (text/plain), 6.38 KB, created by
Biblibre Sandboxes
on 2018-04-23 14:38:34 UTC
(
hide
)
Description:
Bug 20120: Prevent writeoffs of more than the amount owed for a fee
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2018-04-23 14:38:34 UTC
Size:
6.38 KB
patch
obsolete
>From 4e9d534caaf78f1840b880d114b3869f26176f7e Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatetsolutions.com> >Date: Fri, 9 Mar 2018 09:20:40 -0500 >Subject: [PATCH] Bug 20120: Prevent writeoffs of more than the amount owed for > a 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 be unable to write-off an > amount more than the amount outstanding for the fee! > >Signed-off-by: George Williams <george@nekls.org> > >Signed-off-by: George Williams <george@nekls.org> >--- > .../prog/en/modules/members/paycollect.tt | 31 ++++++++++++++++++--- > members/pay.pl | 32 ++++++++++++++++------ > members/paycollect.pl | 4 +++ > 3 files changed, 54 insertions(+), 13 deletions(-) > >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 a4467b1..22bbf22 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >@@ -2,6 +2,7 @@ > [% USE Koha %] > [% USE Branches %] > [% USE AuthorisedValues %] >+[% USE Price %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Patrons › Collect fine payment for [% patron.firstname %] [% patron.surname %]</title> >@@ -119,6 +120,8 @@ > <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 %]" /> >+ <input type="hidden" name="confirm_writeoff" id="confirm_writeoff" value="1" /> > <table> > <thead><tr> > <th>Description</th> >@@ -139,12 +142,14 @@ > <li> > <label for="paid">Writeoff amount: </label> > <!-- default to writing off all --> >- <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding %]" /> >+ <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding | $Price %]" /> > </li> > </ol> > </fieldset> >- <div class="action"><input type="submit" name="confirm_writeoff" id="confirm_writeoff" value="Write off this charge" /> >- <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></div> >+ <div class="action"> >+ <input type="submit" value="Write off this charge" /> >+ <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a> >+ </div> > </form> > [% ELSE %] > >@@ -201,12 +206,30 @@ > [% Asset.js("js/members-menu.js") %] > <script type= "text/javascript"> > $(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 = parseFloat( $('#amountoutstanding').attr('value') ); >+ let amount_writeoff = parseFloat( $('#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) { > var newValue = textObj.value; > var decAmount = ""; >diff --git a/members/pay.pl b/members/pay.pl >index 05b73e5..3ef1200 100755 >--- a/members/pay.pl >+++ b/members/pay.pl >@@ -93,15 +93,29 @@ if ($writeoff_all) { > my $amount = $input->param('amountwrittenoff'); > my $payment_note = $input->param("payment_note"); > >- Koha::Account->new( { patron_id => $borrowernumber } )->pay( >- { >- amount => $amount, >- lines => [ scalar Koha::Account::Lines->find($accountlines_id) ], >- type => 'writeoff', >- note => $payment_note, >- library_id => $branch, >- } >- ); >+ my $accountline = Koha::Account::Lines->find( $accountlines_id ); >+ >+ if ( $amount > $accountline->amountoutstanding ) { >+ print $input->redirect( "/cgi-bin/koha/members/paycollect.pl?" >+ . "borrowernumber=$borrowernumber" >+ . "&amount=$amount" >+ . "&amountoutstanding=" . $accountline->amountoutstanding >+ . "&accounttype=" . $accountline->accounttype >+ . "&accountlines_id=" . $accountlines_id >+ . "&writeoff_individual=1" >+ . "&error_over=1" ); >+ >+ } else { >+ Koha::Account->new( { patron_id => $borrowernumber } )->pay( >+ { >+ amount => $amount, >+ lines => [ scalar Koha::Account::Lines->find($accountlines_id) ], >+ type => 'writeoff', >+ note => $payment_note, >+ library_id => $branch, >+ } >+ ); >+ } > } > > for (@names) { >diff --git a/members/paycollect.pl b/members/paycollect.pl >index 82b5d27..26ccc7b 100755 >--- a/members/paycollect.pl >+++ b/members/paycollect.pl >@@ -182,6 +182,10 @@ borrower_add_additional_fields($borrower, $template); > > $template->param(%$borrower); > >+if ( $input->param('error_over') ) { >+ $template->param( error_over => 1, total_due => $input->param('amountoutstanding') ); >+} >+ > $template->param( > borrowernumber => $borrowernumber, # some templates require global > patron => $patron, >-- >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