Skip to content

Commit

Permalink
Added facility to do a cash refund.
Browse files Browse the repository at this point in the history
Also HLT allows ppl to work off their bill,so added a facility to do manual
credit for that
  • Loading branch information
rangi committed May 9, 2001
1 parent f72283e commit a254455
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
55 changes: 54 additions & 1 deletion C4/Accounts2.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 0.01; $VERSION = 0.01;


@ISA = qw(Exporter); @ISA = qw(Exporter);
@EXPORT = qw(&recordpayment &fixaccounts &makepayment &manualinvoice); @EXPORT = qw(&recordpayment &fixaccounts &makepayment &manualinvoice
&getnextacctno);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],


# your exported package globals go here, # your exported package globals go here,
Expand Down Expand Up @@ -224,6 +225,9 @@ sub manualinvoice{
if ($type eq 'L' && $desc eq ''){ if ($type eq 'L' && $desc eq ''){
$desc="Lost Item"; $desc="Lost Item";
} }
if ($type eq 'REF'){
$amountleft=refund('',$bornum,$amount);
}
if ($itemnum ne ''){ if ($itemnum ne ''){
my $sth=$dbh->prepare("Select * from items where barcode='$itemnum'"); my $sth=$dbh->prepare("Select * from items where barcode='$itemnum'");
$sth->execute; $sth->execute;
Expand Down Expand Up @@ -261,15 +265,64 @@ sub fixcredit{
order by date"; order by date";
my $sth = $dbh->prepare($query); my $sth = $dbh->prepare($query);
$sth->execute; $sth->execute;
# print $query;
# offset transactions # offset transactions
while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){ while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){
if ($accdata->{'amountoutstanding'} < $amountleft) { if ($accdata->{'amountoutstanding'} < $amountleft) {
$newamtos = 0; $newamtos = 0;
$amountleft = $amountleft - $accdata->{'amountoutstanding'}; $amountleft = $amountleft - $accdata->{'amountoutstanding'};
} else {
$newamtos = $accdata->{'amountoutstanding'} + $amountleft;
$amountleft = 0;
}
my $thisacct = $accdata->{accountno};
$updquery = "update accountlines set amountoutstanding= '$newamtos'
where (borrowernumber = '$bornumber') and (accountno='$thisacct')";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
$updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
values ($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos)";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
}
$sth->finish;
$dbh->disconnect;
return($amountleft);
}

sub refund{
#here we update both the accountoffsets and the account lines
my ($env,$bornumber,$data)=@_;
my $dbh=C4Connect;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
# my $branch=$env->{'branchcode'};
my $amountleft = $data *-1;

# begin transaction
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
# get lines with outstanding amounts to offset
my $query = "select * from accountlines
where (borrowernumber = '$bornumber') and (amountoutstanding<0)
order by date";
my $sth = $dbh->prepare($query);
$sth->execute;
# print $query;
# print $amountleft;
# offset transactions
while (($accdata=$sth->fetchrow_hashref) and ($amountleft<0)){
if ($accdata->{'amountoutstanding'} > $amountleft) {
$newamtos = 0;
$amountleft = $amountleft - $accdata->{'amountoutstanding'};
} else { } else {
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; $newamtos = $accdata->{'amountoutstanding'} - $amountleft;
$amountleft = 0; $amountleft = 0;
} }
# print $amountleft;
my $thisacct = $accdata->{accountno}; my $thisacct = $accdata->{accountno};
$updquery = "update accountlines set amountoutstanding= '$newamtos' $updquery = "update accountlines set amountoutstanding= '$newamtos'
where (borrowernumber = '$bornumber') and (accountno='$thisacct')"; where (borrowernumber = '$bornumber') and (accountno='$thisacct')";
Expand Down
1 change: 1 addition & 0 deletions mancredit.pl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<select name=type> <select name=type>
<option value=C>Credit</option> <option value=C>Credit</option>
<option value=BAY>Baycorp Adjustment</option> <option value=BAY>Baycorp Adjustment</option>
<option value=WORK>Worked off</option>
</select> </select>
</td></tr> </td></tr>
<tr><td><b>Itemnumber</b></td><td><input type=text name=itemnum></td></tr> <tr><td><b>Itemnumber</b></td><td><input type=text name=itemnum></td></tr>
Expand Down
2 changes: 2 additions & 0 deletions maninvoice.pl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
my $data=borrdata('',$bornum); my $data=borrdata('',$bornum);
my $add=$input->param('add'); my $add=$input->param('add');
if ($add){ if ($add){
# print $input->header;
my $itemnum=$input->param('itemnum'); my $itemnum=$input->param('itemnum');
my $desc=$input->param('desc'); my $desc=$input->param('desc');
my $amount=$input->param('amount'); my $amount=$input->param('amount');
Expand All @@ -40,6 +41,7 @@
<option value=A>Account Management Fee</option> <option value=A>Account Management Fee</option>
<option value=N>New Card</option> <option value=N>New Card</option>
<option value=M>Sundry</option> <option value=M>Sundry</option>
<option value=REF>Cash Refund</option>
</select> </select>
</td></tr> </td></tr>
<tr><td><b>Itemnumber</b></td><td><input type=text name=itemnum></td></tr> <tr><td><b>Itemnumber</b></td><td><input type=text name=itemnum></td></tr>
Expand Down

0 comments on commit a254455

Please sign in to comment.