[Koha-devel] CVS: koha/C4 Accounts2.pm,1.6,1.7

Chris Cormack rangi at users.sourceforge.net
Thu May 10 01:22:12 CEST 2001


Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv19677/C4

Modified Files:
	Accounts2.pm 
Log Message:
Added facility to do a cash refund.
Also HLT allows ppl to work off their bill,so added a facility to do manual
credit for that


Index: Accounts2.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Accounts2.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** Accounts2.pm	2001/05/02 21:13:15	1.6
--- Accounts2.pm	2001/05/09 23:22:10	1.7
***************
*** 16,20 ****
      
  @ISA = qw(Exporter);
! @EXPORT = qw(&recordpayment &fixaccounts &makepayment &manualinvoice);
  %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
  		  
--- 16,21 ----
      
  @ISA = qw(Exporter);
! @EXPORT = qw(&recordpayment &fixaccounts &makepayment &manualinvoice
! &getnextacctno);
  %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
  		  
***************
*** 225,228 ****
--- 226,232 ----
      $desc="Lost Item";
    }
+   if ($type eq 'REF'){
+     $amountleft=refund('',$bornum,$amount);    
+   }
    if ($itemnum ne ''){
      my $sth=$dbh->prepare("Select * from items where barcode='$itemnum'");
***************
*** 262,265 ****
--- 266,270 ----
    my $sth = $dbh->prepare($query);
    $sth->execute;
+ #  print $query;
    # offset transactions
    while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){
***************
*** 268,274 ****
--- 273,327 ----
  	$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 {
          $newamtos = $accdata->{'amountoutstanding'} - $amountleft;
  	$amountleft = 0;
       }
+ #     print $amountleft;
       my $thisacct = $accdata->{accountno};
       $updquery = "update accountlines set amountoutstanding= '$newamtos'





More information about the Koha-devel mailing list