Permalink
Browse files

Merge branch 'Bug3498' into ptfs-master

Conflicts:

	koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl
  • Loading branch information...
J. David Bavousett
J. David Bavousett committed Apr 27, 2010
2 parents 55964d4 + fbe6dc4 commit 353a21e6d3c306223a2770a003af0dba7c70aaa0
View
@@ -35,8 +35,8 @@ BEGIN {
@EXPORT = qw(
&recordpayment &makepayment &manualinvoice
&getnextacctno &reconcileaccount &getcharges &getcredits
- &getrefunds &chargelostitem
&ReversePayment
+ &getrefunds &chargelostitem makepartialpayment
); # removed &fixaccounts
}
@@ -207,6 +207,39 @@ sub makepayment {
}
}
+# makepayment needs to be fixed to handle partials till then this separate subroutine
+# fills in
+sub makepartialpayment {
+ my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
+ if (!$amount || $amount < 0) {
+ return;
+ }
+ my $dbh = C4::Context->dbh;
+
+ my $nextaccntno = getnextacctno($borrowernumber);
+ my $newamtos = 0;
+
+ my $data = $dbh->selectrow_hashref(
+ 'SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?',undef,$borrowernumber,$accountno);
+ my $new_outstanding = $data->{amountoutstanding} - $amount;
+
+ my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE borrowernumber = ? '
+ . ' AND accountno = ?';
+ $dbh->do( $update, undef, $new_outstanding, $borrowernumber, $accountno);
+
+ # create new line
+ my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
+ . 'description, accounttype, amountoutstanding) '
+ . ' VALUES (?, ?, now(), ?, ?, ?, 0)';
+
+ $dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount,
+ "Payment, thanks - $user", 'Pay');
+
+ UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
+
+ return;
+}
+
=head2 getnextacctno
$nextacct = &getnextacctno($borrowernumber);
@@ -9,7 +9,7 @@
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo; Pay Fines for <!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR name="surname" --></div>
<div id="doc3" class="yui-t2">
-
+
<div id="bd">
<div id="yui-main">
<div class="yui-b">
@@ -48,15 +48,20 @@
<tr>
<td>
<!-- TMPL_IF NAME="net_balance" -->
- <select name="payfine<!-- TMPL_VAR name="i" -->">
+ <!--<select name="payfine<!-- TMPL_VAR name="i" -->">
<option value="no">Unpaid</option>
- <option value="yes">Paid</option>
+ <option value="yes">Paid</option> -->
+ <input type="submit" name="pay_indiv<!-- TMPL_VAR name="i" -->"i value="Pay" />
<!-- TMPL_IF NAME="CAN_user_updatecharges_writeoff_charges" -->
- <option value="wo">Writeoff</option>
+ <input type="submit" name="wo_indiv<!-- TMPL_VAR name="i" -->"i value="Writeoff" />
+ <!--<option value="wo">Writeoff</option> -->
<!-- /TMPL_IF -->
- </select>
+ <!--</select> -->
<!-- /TMPL_IF -->
+ <input type="hidden" name="line_id<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="i" -->" />
<input type="hidden" name="itemnumber<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="itemnumber" -->" />
+ <input type="hidden" name="description<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="description" -->" />
+ <input type="hidden" name="title<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="title" -->" />
<input type="hidden" name="accounttype<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="accounttype" -->" />
<input type="hidden" name="amount<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="amount" -->" />
<input type="hidden" name="out<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="amountoutstanding" -->" />
@@ -87,7 +92,16 @@
<td><!-- TMPL_VAR name="total" --></td>
</tr>
</table>
-<fieldset class="action"><input type="submit" name="submit" value="Make Payment" class="submit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a></fieldset></form><!-- TMPL_ELSE --><p><!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --> has no outstanding fines.</p><!-- /TMPL_IF -->
+<!-- <p>On All Or Part Of The Total Sum Due:</p> -->
+<fieldset class="action">
+ <input type="submit" name="paycollect" value="Pay Amount" class="submit" />
+<!-- TMPL_IF NAME="CAN_user_updatecharges_writeoff_charges" -->
+ <input type="submit" name="woall" value="Writeoff All" class="submit" />
+<!-- /TMPL_IF -->
+ <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">
+ Cancel</a>
+</fieldset>
+</form><!-- TMPL_ELSE --><p><!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --> has no outstanding fines.</p><!-- /TMPL_IF -->
</div></div>
</div>
@@ -0,0 +1,220 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha &rsaquo; Patrons &rsaquo; Collect Fine Payment for <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --></title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<script type= "text/javascript">
+//<![CDATA[
+function moneyFormat(textObj) {
+ var newValue = textObj.value;
+ var decAmount = "";
+ var dolAmount = "";
+ var decFlag = false;
+ var aChar = "";
+
+ for(i=0; i < newValue.length; i++) {
+ aChar = newValue.substring(i, i+1);
+ if (aChar >= "0" && aChar <= "9") {
+ if(decFlag) {
+ decAmount = "" + decAmount + aChar;
+ }
+ else {
+ dolAmount = "" + dolAmount + aChar;
+ }
+ }
+ if (aChar == ".") {
+ if (decFlag) {
+ dolAmount = "";
+ break;
+ }
+ decFlag = true;
+ }
+ }
+
+ if (dolAmount == "") {
+ dolAmount = "0";
+ }
+// Strip leading 0s
+ if (dolAmount.length > 1) {
+ while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
+ dolAmount = dolAmount.substring(1,dolAmount.length);
+ }
+ }
+ if (decAmount.length > 2) {
+ decAmount = decAmount.substring(0,2);
+ }
+// Pad right side
+ if (decAmount.length == 1) {
+ decAmount = decAmount + "0";
+ }
+ if (decAmount.length == 0) {
+ decAmount = decAmount + "00";
+ }
+
+ textObj.value = dolAmount + "." + decAmount;
+}
+//]]>
+</script>
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="patron-search.inc" -->
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo; Pay Fines for <!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR name="surname" --></div>
+
+<div id="doc3" class="yui-t2">
+
+<div id="bd">
+<div id="yui-main">
+<div class="yui-b">
+<!-- TMPL_INCLUDE NAME="members-toolbar.inc" -->
+
+
+<!-- The manual invoice and credit buttons -->
+<div class="toptabs">
+<ul class="ui-tabs-nav">
+<li><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Account</a></li>
+<li class="ui-tabs-selected"><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->" >Pay fines</a></li>
+<li><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->" >Create Manual Invoice</a></li>
+<li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->" >Create Manual Credit</a></li>
+</ul>
+<div class="tabs-container">
+
+<!--<form action="/cgi-bin/koha/members/paycollect.pl" method="post"> -->
+<!-- TMPL_IF NAME="pay_individual" -->
+<form name="payindivfine" onsubmit="return validatePayment(this);" method="post" action="/cgi-bin/koha/members/paycollect.pl">
+<input type="hidden" name="borrowernumber" id="borrowernumber" value="<!-- TMPL_VAR name="borrowernumber" -->" />
+<input type="hidden" name="pay_individual" id="pay_individual" value="<!-- TMPL_VAR name="pay_individual" -->" />
+<input type="hidden" name="description" id="description" value="<!-- TMPL_VAR name="description" -->" />
+<input type="hidden" name="accounttype" id="accounttype" value="<!-- TMPL_VAR name="accounttype" -->" />
+<input type="hidden" name="notify_id" id="notify_id" value="<!-- TMPL_VAR name="notify_id" -->" />
+<input type="hidden" name="notify_level" id="notify_level" value="<!-- TMPL_VAR name="notify_level" -->" />
+<input type="hidden" name="amount" id="amount" value="<!-- TMPL_VAR name="amount" -->" />
+<input type="hidden" name="amountoutstanding" id="amountoutstanding" value="<!-- TMPL_VAR name="amountoutstanding" -->" />
+<input type="hidden" name="accountno" id="accountno" value="<!-- TMPL_VAR name="accountno" -->" />
+<input type="hidden" name="title" id="title" value="<!-- TMPL_VAR name="title" -->" />
+<table>
+<tr>
+<th>Description</th>
+<th>Account Type</th>
+<th>Notify id</th>
+<th>Level</th>
+<th>Amount</th>
+<th>Amount Outstanding</th>
+</tr>
+<tr>
+<td>
+<!-- TMPL_VAR NAME="description" --> <!-- TMPL_VAR="title" escape="html" -->
+</td>
+<td><!-- TMPL_VAR name="accounttype" --></td>
+<td><!-- TMPL_VAR name="notify_id" --></td>
+<td><!-- TMPL_VAR name="notify_level" --></td>
+<td class="debit"><!-- TMPL_VAR name="amount" --></td>
+<td class="debit"><!-- TMPL_VAR name="amountoutstanding" --></td>
+</tr>
+<tr>
+<td>Total Amount Payable : </td>
+<td>
+<!-- TMPL_VAR NAME="amountoutstanding" -->
+</td>
+</tr>
+<tr><td> </td></tr>
+<tr>
+<td>Collect From Patron: </td>
+<td>
+<!-- default to paying all -->
+<input name="paid" id="paid" value="<!-- TMPL_VAR NAME="amountoutstanding" -->" onchange="moneyFormat(document.payindivfine.paid)"/>
+</td>
+</tr>
+<tr><td> </td></tr>
+<tr>
+<td rowspan="2">
+<input type="submit" name="submitbutton" value="Confirm" />
+<a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a>
+</td>
+</tr>
+
+</table>
+<!-- TMPL_ELSIF NAME="writeoff_individual"-->
+<form name="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
+<input type="hidden" name="borrowernumber" id="borrowernumber" value="<!-- TMPL_VAR name="borrowernumber" -->" />
+<input type="hidden" name="pay_individual" id="pay_individual" value="<!-- TMPL_VAR name="pay_individual" -->" />
+<input type="hidden" name="description" id="description" value="<!-- TMPL_VAR name="description" -->" />
+<input type="hidden" name="accounttype" id="accounttype" value="<!-- TMPL_VAR name="accounttype" -->" />
+<input type="hidden" name="notify_id" id="notify_id" value="<!-- TMPL_VAR name="notify_id" -->" />
+<input type="hidden" name="notify_level" id="notify_level" value="<!-- TMPL_VAR name="notify_level" -->" />
+<input type="hidden" name="amount" id="amount" value="<!-- TMPL_VAR name="amount" -->" />
+<input type="hidden" name="amountoutstanding" id="amountoutstanding" value="<!-- TMPL_VAR name="amountoutstanding" -->" />
+<input type="hidden" name="accountno" id="accountno" value="<!-- TMPL_VAR name="accountno" -->" />
+<input type="hidden" name="title" id="title" value="<!-- TMPL_VAR name="title" -->" />
+<table>
+<tr>
+<th>Description</th>
+<th>Account Type</th>
+<th>Notify id</th>
+<th>Level</th>
+<th>Amount</th>
+<th>Amount Outstanding</th>
+</tr>
+<tr>
+<td>
+<!-- TMPL_VAR NAME="description" --> <!-- TMPL_VAR="title" escape="html" -->
+</td>
+<td><!-- TMPL_VAR name="accounttype" --></td>
+<td><!-- TMPL_VAR name="notify_id" --></td>
+<td><!-- TMPL_VAR name="notify_level" --></td>
+<td class="debit"><!-- TMPL_VAR name="amount" --></td>
+<td class="debit"><!-- TMPL_VAR name="amountoutstanding" --></td>
+</tr>
+<tr><td> </td></tr>
+<tr><td rowspan="2"><strong>Writeoff This Charge?</strong></td></tr>
+<tr><td> </td></tr>
+<tr>
+<td rowspan="2">
+<input type="submit" name="confirm_writeoff" id="confirm_writeoff" value="Confirm" />
+<a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a>
+</td>
+</tr>
+
+</table>
+<!-- TMPL_ELSE -->
+
+<form name="payfine" onsubmit="return validatePayment(this);" method="post" action="/cgi-bin/koha/members/paycollect.pl">
+<input type="hidden" name="borrowernumber" id="borrowernumber" value="<!-- TMPL_VAR name="borrowernumber" -->" />
+<input type="hidden" name="total" id="total" value="<!-- TMPL_VAR name="total" -->" />
+
+<table>
+<!-- TMPL_IF NAME="error" -->
+<tr><td><!-- TMPL_VAR NAME="error" --></td></tr>
+<!-- /TMPL_IF -->
+<tr>
+<td>Total Amount Outstanding : </td>
+<td>
+<!-- TMPL_VAR NAME="total" -->
+</td>
+</tr>
+<tr><td> </td></tr>
+<tr>
+<td>Collect From Patron: </td>
+<td>
+<!-- default to paying all -->
+<input name="paid" id="paid" value="<!-- TMPL_VAR NAME="total" -->" onchange="moneyFormat(document.payfine.paid)"/>
+</td>
+</tr>
+<tr><td> </td></tr>
+<tr>
+<td rowspan="2">
+<input type="submit" name="submitbutton" value="Confirm" />
+<a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a>
+</td>
+</tr>
+</table>
+</form>
+<!-- /TMPL_IF -->
+</div></div>
+
+</div>
+</div>
+
+<div class="yui-b">
+<!-- TMPL_INCLUDE NAME="circ-menu.inc" -->
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
Oops, something went wrong.

0 comments on commit 353a21e

Please sign in to comment.