&recordpayment &makepayment &manualinvoice
&getnextacctno &reconcileaccount &getcharges &getcredits
&getrefunds &chargelostitem
+ &ReversePayment
); # removed &fixaccounts
}
}
return (@results);
}
+
+sub ReversePayment {
+ my ( $borrowernumber, $accountno ) = @_;
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE borrowernumber = ? AND accountno = ?');
+ $sth->execute( $borrowernumber, $accountno );
+ my $row = $sth->fetchrow_hashref();
+ my $amount_outstanding = $row->{'amountoutstanding'};
+
+ if ( $amount_outstanding <= 0 ) {
+ $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?');
+ $sth->execute( $borrowernumber, $accountno );
+ } else {
+ $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?');
+ $sth->execute( $borrowernumber, $accountno );
+ }
+}
+
END { } # module clean-up code here (global destructor)
1;
<th>Description of charges</th>
<th>Amount</th>
<th>Outstanding</th>
+ <th> </th>
</tr>
<!-- FIXME: Shouldn't hardcode dollar signs, since Euro or Pound might be needed -->
<td><!-- TMPL_VAR NAME="description" --> <!-- TMPL_IF NAME="itemnumber" --><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">View item</a> <!-- /TMPL_IF --><!-- TMPL_IF NAME="printtitle" --> <!-- TMPL_VAR NAME="title" escape="html" --><!-- /TMPL_IF --></td>
<!-- TMPL_IF NAME="amountcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amount" --></td>
<!-- TMPL_IF NAME="amountoutstandingcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amountoutstanding" --></td>
+ <td>
+ <!-- TMPL_IF NAME="payment" -->
+ <a href="boraccount.pl?action=reverse&borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&accountno=<!-- TMPL_VAR NAME="accountno" -->">Reverse</a>
+ <!-- TMPL_ELSE -->
+
+ <!-- /TMPL_IF -->
+ </td>
</tr>
<!-- /TMPL_LOOP -->
<tfoot>
<tr>
<td colspan="3">Total due</td>
- <!-- TMPL_IF NAME="totalcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="total" --></td>
+ <!-- TMPL_IF NAME="totalcredit" --><td colspan="2" class="credit"><!-- TMPL_ELSE --><td colspan="2" class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="total" --></td>
</tr>
</tfoot>
</table>
use CGI;
use C4::Members;
use C4::Branch;
+use C4::Accounts;
my $input=new CGI;
#get borrower details
my $data=GetMember($borrowernumber,'borrowernumber');
+if ( $input->param('action') eq 'reverse' ) {
+ ReversePayment( $borrowernumber, $input->param('accountno') );
+}
+
if ( $data->{'category_type'} eq 'C') {
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
my $cnt = scalar(@$catcodes);
'itemnumber' => $accts->[$i]{'itemnumber'},
'biblionumber' => $accts->[$i]{'biblionumber'},
'amount' => sprintf("%.2f",$accts->[$i]{'amount'}),
- 'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}) );
+ 'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}),
+ 'accountno' => $accts->[$i]{'accountno'},
+ 'payment' => ( $accts->[$i]{'accounttype'} eq 'Pay' ),
+
+ );
if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
$row{'printtitle'}=1;