Bugzilla – Attachment 72598 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-an-.patch (text/plain), 5.98 KB, created by
Kyle M Hall (khall)
on 2018-03-09 14:21:00 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:
Kyle M Hall (khall)
Created:
2018-03-09 14:21:00 UTC
Size:
5.98 KB
patch
obsolete
>From 664bd5b35b66f3d3a183256308cdcd8f867a195d 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: Writeoffs for individual fees allows an amount to > be written off more than the amount of the fee > >--- > .../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 39df143..215aee8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >@@ -1,5 +1,6 @@ > [% USE Koha %] > [% USE Branches %] >+[% USE Price %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Patrons › Collect fine payment for [% patron.firstname %] [% patron.surname %]</title> >@@ -105,6 +106,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> >@@ -125,12 +128,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 %] > >@@ -175,12 +180,30 @@ > <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script> > <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 7c16a0a..c7121b5 100755 >--- a/members/paycollect.pl >+++ b/members/paycollect.pl >@@ -174,6 +174,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.10.2
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