Kumara - predecessor to Koha
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.8 KiB

  1. #!/usr/bin/perl
  2. #script to calculate fines
  3. use C4::Circulation::Fines;
  4. use Date::Manip;
  5. open (FILE,'>/tmp/fines') || die;
  6. my ($count,$data)=Getoverdues();
  7. #print $count;
  8. my $count2=0;
  9. #$count=1000;
  10. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
  11. $mon++;
  12. $year=$year+1900;
  13. #my $date=Date_DaysSince999($mon,$mday,$year);
  14. my $date=Date_DaysSince999(2,20,2000);
  15. my $bornum;
  16. my $borrower;
  17. my $total=0;
  18. my $max=5;
  19. my $bornum2;
  20. for (my $i=0;$i<$count;$i++){
  21. my @dates=split('-',$data->[$i]->{'date_due'});
  22. my $date2=Date_DaysSince999($dates[1],$dates[2],$dates[0]);
  23. my $due="$dates[2]/$dates[1]/$dates[0]";
  24. if ($date2 <= $date){
  25. $count2++;
  26. my $difference=$date-$date2;
  27. if ($bornum != $data->[$i]->{'borrowernumber'}){
  28. $bornum=$data->[$i]->{'borrowernumber'};
  29. $borrower=BorType($bornum);
  30. }
  31. my ($amount,$type,$printout)=CalcFine($data->[$i]->{'itemnumber'},$borrower->{'categorycode'},$difference);
  32. if ($amount > $max){
  33. $amount=$max;
  34. }
  35. if ($amount > 0){
  36. UpdateFine($data->[$i]->{'itemnumber'},$bornum,$amount,$type,$due);
  37. if ($bornum2 == $data->[$i]->{'borrowernumber'}){
  38. $total=$total+$amount;
  39. } else {
  40. print FILE "\"$borrower->{'cardnumber'}\"\,\"$borrower->{'phone'}\"\,\"Overdue or Extd Rental$total\"\,\"$borrower->{'homebranch'}\"\n";
  41. $total=$amount;
  42. }
  43. if ($amount ==5){
  44. # marklost();
  45. }
  46. print "$printout\t$borrower->{'cardnumber'}\t$borrower->{'firstname'}\t$borrower->{'surname'}\t$data->[$i]->{'date_due'}\t$type\t$difference\t$borrower->{'emailaddress'}\t$borrower->{'phone'}\t$borrower->{'streetaddress'}\t$borrower->{'city'}\n";
  47. } else {
  48. # print "0 fine\n";
  49. }
  50. }
  51. $bornum2=$data->[$i]->{'borrowernumber'};
  52. }
  53. close FILE;