Browse Source

getting paying accounts working

master
chris 21 years ago
parent
commit
b94e85570f
  1. 35
      C4/Accounts2.pm
  2. 2
      C4/Search.pm
  3. 29
      moremember.pl
  4. 10
      pay.pl
  5. 3
      sec/writeoff.pl

35
C4/Accounts2.pm

@ -14,7 +14,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&recordpayment &fixaccounts);
@EXPORT = qw(&recordpayment &fixaccounts &makepayment);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
@ -105,6 +105,39 @@ sub recordpayment{
$dbh->disconnect;
}
sub makepayment{
#here we update both the accountoffsets and the account lines
my ($bornumber,$accountno,$amount)=@_;
my $env;
my $dbh=C4Connect;
# begin transaction
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
my $newamtos=0;
my $updquery="Update accountlines set amountoutstanding=0 where
borrowernumber=$bornumber and accountno=$accountno";
my $sth=$dbh->prepare($updquery);
$sth->execute;
$sth->finish;
# print $updquery;
$updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
values ($bornumber,$accountno,$nextaccntno,$newamtos)";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
# create new line
my $payment=0-$amount;
$updquery = "insert into accountlines
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding)
values ($bornumber,$nextaccntno,now(),$payment,'Payment,thanks', 'Pay',0)";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
UpdateStats($env,'branch','payment',$amount);
$sth->finish;
$dbh->disconnect;
}
sub getnextacctno {
my ($env,$bornumber,$dbh)=@_;
my $nextaccntno = 1;

2
C4/Search.pm

@ -863,7 +863,7 @@ sub getboracctrecord {
my $dbh=C4Connect;
my @acctlines;
my $numlines=0;
my $query= "Select * from accountlines where borrowernumber=$params->{'borrowernumber'} order by date desc";
my $query= "Select * from accountlines where borrowernumber=$params->{'borrowernumber'} order by timestamp desc";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;

29
moremember.pl

@ -101,27 +101,28 @@ printend
my %bor;
$bor{'borrowernumber'}=$bornum;
my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
if ($numaccts > 10){
$numaccts=10;
}
#if ($numaccts > 10){
# $numaccts=10;
#}
for (my$i=0;$i<$numaccts;$i++){
#if ($accts->[$i]{'accounttype'} ne 'Pay'){
my $amount= $accts->[$i]{'amount'} + 0.00;
my $amount2= $accts->[$i]{'amountoutstanding'} + 0.00;
print "<tr VALIGN=TOP >";
my $item=" &nbsp; ";
@temp=split('-',$accts->[$i]{'date'});
$accts->[$i]{'date'}="$temp[2]/$temp[1]/$temp[0]";
if ($accts->[$i]{'accounttype'} ne 'Res'){
if ($amount2 > 0){
print "<tr VALIGN=TOP >";
my $item=" &nbsp; ";
@temp=split('-',$accts->[$i]{'date'});
$accts->[$i]{'date'}="$temp[2]/$temp[1]/$temp[0]";
if ($accts->[$i]{'accounttype'} ne 'Res'){
#get item data
#$item=
}
print "<td>$accts->[$i]{'date'}</td>";
}
print "<td>$accts->[$i]{'date'}</td>";
# print "<TD>$accts->[$i]{'accounttype'}</td>";
print "<TD>$accts->[$i]{'description'} $accts->[$i]{'title'}</td>
<TD>$amount</td><td>$amount2</td>
</tr>";
#}
print "<TD>$accts->[$i]{'description'} $accts->[$i]{'title'}</td>
<TD>$amount</td><td>$amount2</td>
</tr>";
}
}
print <<printend

10
pay.pl

@ -30,6 +30,13 @@ for (my $i=0;$i<@names;$i++){
$inp{$names[$i]}=$temp;
$check=1;
}
if ($temp eq 'yes'){
my $amount=$input->param($names[$i+4]);
my $bornum=$input->param($names[$i+5]);
my $accountno=$input->param($names[$i+6]);
makepayment($bornum,$accountno,$amount);
$check=2;
}
}
my %env;
my $total=$input->param('total');
@ -66,7 +73,8 @@ print <<printend
<input type=hidden name=itemnumber$i value=$accts->[$i]{'itemnumber'}>
<input type=hidden name=accounttype$i value=$accts->[$i]{'accounttype'}>
<input type=hidden name=amount$i value=$accts->[$i]{'amount'}>
<input type=hidden name=bornum value=$bornum>
<input type=hidden name=out$i value=$accts->[$i]{'amountoutstanding'}>
<input type=hidden name=bornum$i value=$bornum>
<input type=hidden name=accountno$i value=$accts->[$i]{'accountno'}>
</td>
<TD>$accts->[$i]{'description'} $accts->[$i]{'title'}</td>

3
sec/writeoff.pl

@ -22,10 +22,11 @@ for (my $i=0;$i<@name;$i++){
$inp{$name[$i]}=$temp;
}
}
my $bornum=$input->param('bornum');
my $bornum;
while ( my ($key, $value) = each %inp){
# print $key,$value;
my $accounttype=$input->param("accounttype$value");
$bornum=$input->param("bornum$value");
my $itemno=$input->param("itemnumber$value");
my $amount=$input->param("amount$value");
if ($accounttype eq 'Res'){

Loading…
Cancel
Save