Permalink
Browse files

Initial revision

  • Loading branch information...
0 parents commit d0374d003716dfb40796caad6390a4d69bfb0376 rangi committed Dec 19, 2000
Showing with 15,208 additions and 0 deletions.
  1. +208 −0 C4/Accounts.pm
  2. +176 −0 C4/Accounts2.pm
  3. +894 −0 C4/Acquisitions.pm
  4. +100 −0 C4/Circmain.pm
  5. +227 −0 C4/Circulation.pm
  6. +77 −0 C4/Circulation/Borrissues.pm
  7. +382 −0 C4/Circulation/Borrower.pm
  8. +176 −0 C4/Circulation/Fines.pm
  9. +389 −0 C4/Circulation/Issues.pm
  10. +265 −0 C4/Circulation/Main.pm
  11. +214 −0 C4/Circulation/Renewals.pm
  12. +173 −0 C4/Circulation/Renewals2.pm
  13. +335 −0 C4/Circulation/Returns.pm
  14. +156 −0 C4/Database.pm
  15. +127 −0 C4/Format.pm
  16. +92 −0 C4/Input.pm
  17. +138 −0 C4/Interface/AccountsCDK.pm
  18. +94 −0 C4/Interface/BorrowerCDK.pm
  19. +133 −0 C4/Interface/FlagsCDK.pm
  20. +75 −0 C4/Interface/RenewalsCDK.pm
  21. +244 −0 C4/Interface/ReserveentCDK.pm
  22. +630 −0 C4/InterfaceCDK.pm
  23. +84 −0 C4/Maintainance.pm
  24. +376 −0 C4/Output.pm
  25. +120 −0 C4/Print.pm
  26. +299 −0 C4/Reserves.pm
  27. +295 −0 C4/Reserves2.pm
  28. +54 −0 C4/Scan.pm
  29. +1,157 −0 C4/Search.pm
  30. +102 −0 C4/Security.pm
  31. +243 −0 C4/Stats.pm
  32. +71 −0 C4/Stock.pm
  33. +240 −0 acqui/acquire.pl
  34. +78 −0 acqui/addorder.pl
  35. +126 −0 acqui/basket.pl
  36. +97 −0 acqui/finishreceive.pl
  37. +30 −0 acqui/modorders.pl
  38. +69 −0 acqui/newbasket.pl
  39. +205 −0 acqui/newbasket2.pl
  40. +279 −0 acqui/newbiblio.pl
  41. +79 −0 acqui/order.pl
  42. +140 −0 acqui/receive.pl
  43. +58 −0 acqui/recieveorder.pl
  44. +251 −0 acqui/supplier.pl
  45. +61 −0 acqui/updatesupplier.pl
  46. +91 −0 boraccount.pl
  47. +48 −0 borrwraper.pl
  48. +54 −0 catmaintain.pl
  49. +60 −0 charges.pl
  50. +54 −0 currency.pl
  51. +21 −0 delbiblio.pl
  52. +19 −0 delitem.pl
  53. +231 −0 detail.pl
  54. +61 −0 fines.pl
  55. +148 −0 imemberentry.pl
  56. +66 −0 insertdata.pl
  57. +50 −0 insertidata.pl
  58. +84 −0 insertjdata.pl
  59. +166 −0 jmemberentry.pl
  60. +60 −0 member.pl
  61. +399 −0 memberentry.pl
  62. +220 −0 misc/fixborrower.pl
  63. +21 −0 misc/fixcatalog.pl
  64. +30 −0 misc/fixorders.pl
  65. +14 −0 misc/fixorders.pl2
  66. +21 −0 misc/fixrefs.pl
  67. +27 −0 misc/makebaskets.pl
  68. +35 −0 misc/makeformats.pl
  69. +28 −0 misc/tidyaccounts.pl
  70. +90 −0 modbib.pl
  71. +190 −0 modbibitem.pl
  72. +143 −0 moditem.pl
  73. +40 −0 modrequest.pl
  74. +180 −0 moredetail.pl
  75. +276 −0 moremember.pl
  76. +70 −0 newimember.pl
  77. +110 −0 newjmember.pl
  78. +156 −0 newmember.pl
  79. +151 −0 opac-search.pl
  80. +22 −0 orderbreakdown.pl
  81. +132 −0 pay.pl
  82. +59 −0 placerequest.pl
  83. +33 −0 readingrec.pl
  84. +39 −0 renewscript.pl
  85. +32 −0 reports.pl
  86. +241 −0 request.pl
  87. +27 −0 reservereport.pl
  88. +27 −0 reservereport.xls
  89. +290 −0 search.pl
  90. +70 −0 sec/writeoff.pl
  91. +79 −0 showbudget.pl
  92. +19 −0 simpleredirect.pl
  93. +133 −0 stats.pl
  94. +79 −0 stats2.pl
  95. +96 −0 subjectsearch.pl
  96. +52 −0 telnet/borrwraper.pl
  97. +15 −0 telnet/circ
  98. +66 −0 telnet/doreturns.pl
  99. +20 −0 telnet/issuewrapper.pl
  100. +13 −0 telnet/returnswrapper.pl
  101. +78 −0 telnet/startint.pl
  102. +32 −0 tidyaccounts.pl
  103. +121 −0 updatebibitem.pl
  104. +75 −0 updatebiblio.pl
  105. +39 −0 updatecharges.pl
  106. +86 −0 updateitem.pl
@@ -0,0 +1,208 @@
+package C4::Accounts; #asummes C4/Accounts
+
+#requires DBI.pm to be installed
+#uses DBD:Pg
+
+use strict;
+require Exporter;
+use DBI;
+use C4::Database;
+use C4::Format;
+use C4::Search;
+use C4::Stats;
+use C4::InterfaceCDK;
+use C4::Interface::AccountsCDK;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+
+# set the version for version checking
+$VERSION = 0.01;
+
+@ISA = qw(Exporter);
+@EXPORT = qw(&checkaccount &reconcileaccount &getnextacctno);
+%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
+
+# your exported package globals go here,
+# as well as any optionally exported functions
+
+@EXPORT_OK = qw($Var1 %Hashit);
+
+
+# non-exported package globals go here
+use vars qw(@more $stuff);
+
+# initalize package globals, first exported ones
+
+my $Var1 = '';
+my %Hashit = ();
+
+# then the others (which are still accessible as $Some::Module::stuff)
+my $stuff = '';
+my @more = ();
+
+# all file-scoped lexicals must be created before
+# the functions below that use them.
+
+# file-private lexicals go here
+my $priv_var = '';
+my %secret_hash = ();
+
+# here's a file-private function as a closure,
+# callable as &$priv_func; it cannot be prototyped.
+my $priv_func = sub {
+ # stuff goes here.
+};
+
+# make all your functions, whether exported or not;
+
+sub displayaccounts{
+ my ($env)=@_;
+}
+
+sub checkaccount {
+ #take borrower number
+ #check accounts and list amounts owing
+ my ($env,$bornumber,$dbh)=@_;
+ my $sth=$dbh->prepare("Select sum(amountoutstanding) from accountlines where
+ borrowernumber=$bornumber and amountoutstanding<>0");
+ $sth->execute;
+ my $total=0;
+ while (my $data=$sth->fetchrow_hashref){
+ $total=$total+$data->{'sum(amountoutstanding)'};
+ }
+ $sth->finish;
+ # output(1,2,"borrower owes $total");
+ #if ($total > 0){
+ # # output(1,2,"borrower owes $total");
+ # if ($total > 5){
+ # reconcileaccount($env,$dbh,$bornumber,$total);
+ # }
+ #}
+ # pause();
+ return($total);
+}
+
+sub reconcileaccount {
+ #print put money owing give person opportunity to pay it off
+ my ($env,$dummy,$bornumber,$total)=@_;
+ my $dbh = &C4Connect;
+ #get borrower record
+ my $sth=$dbh->prepare("select * from borrowers
+ where borrowernumber=$bornumber");
+ $sth->execute;
+ my $borrower=$sth->fetchrow_hashref;
+ $sth->finish();
+ #get borrower information
+ $sth=$dbh->prepare("Select * from accountlines where
+ borrowernumber=$bornumber and amountoutstanding<>0 order by date");
+ $sth->execute;
+ #display account information
+ &clearscreen();
+ #&helptext('F11 quits');
+ output(20,0,"Accounts");
+ my @accountlines;
+ my $row=4;
+ my $i=0;
+ my $text;
+ #output (1,2,"Account Info");
+ #output (1,3,"Item\tDate \tAmount\tDescription");
+ while (my $data=$sth->fetchrow_hashref){
+ my $line=$i+1;
+ my $amount=0+$data->{'amountoutstanding'};
+ my $itemdata = itemnodata($env,$dbh,$data->{'itemnumber'});
+ $line= $data->{'accountno'}." ".$data->{'date'}." ".$data->{'accounttype'}." ";
+ my $title = $itemdata->{'title'};
+ if (length($title) > 15 ) {$title = substr($title,0,15);}
+ $line= $line.$itemdata->{'barcode'}." $title ".$data->{'description'};
+ $line = fmtstr($env,$line,"L65")." ".fmtdec($env,$amount,"52");
+ push @accountlines,$line;
+ $i++;
+ }
+ #get amount paid and update database
+ my ($data,$reason)=
+ &accountsdialog($env,"Payment Entry",$borrower,\@accountlines,$total);
+ if ($data>0) {
+ &recordpayment($env,$bornumber,$dbh,$data);
+ #Check if the borrower still owes
+ $total=&checkaccount($env,$bornumber,$dbh);
+ }
+ $dbh->disconnect;
+ return($total);
+
+}
+
+sub recordpayment{
+ #here we update both the accountoffsets and the account lines
+ my ($env,$bornumber,$dbh,$data)=@_;
+ my $updquery = "";
+ my $newamtos = 0;
+ my $accdata = "";
+ my $amountleft = $data;
+ # begin transaction
+# my $sth = $dbh->prepare("begin");
+# $sth->execute;
+ 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;
+ # 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;
+ }
+ 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);
+# print $updquery
+ $usth->execute;
+ $usth->finish;
+ }
+ # create new line
+ #$updquery = "insert into accountlines (borrowernumber,
+ #accountno,date,amount,description,accounttype,amountoutstanding) values
+ #($bornumber,$nextaccntno,datetime('now'::abstime),0-$data,'Payment,thanks',
+ #'Pay',0-$amountleft)";
+ $updquery = "insert into accountlines
+ (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding)
+ values ($bornumber,$nextaccntno,now(),0-$data,'Payment,thanks',
+ 'Pay',0-$amountleft)";
+ my $usth = $dbh->prepare($updquery);
+ $usth->execute;
+ $usth->finish;
+ UpdateStats($env,'branch','payment',$data)
+# $sth->finish;
+# $query = "commit";
+# $sth = $dbh->prepare;
+# $sth->execute;
+# $sth-finish;
+}
+
+sub getnextacctno {
+ my ($env,$bornumber,$dbh)=@_;
+ my $nextaccntno = 1;
+ my $query = "select * from accountlines
+ where (borrowernumber = '$bornumber')
+ order by accountno desc";
+ my $sth = $dbh->prepare($query);
+ $sth->execute;
+ if (my $accdata=$sth->fetchrow_hashref){
+ $nextaccntno = $accdata->{'accountno'} + 1;
+ }
+ $sth->finish;
+ return($nextaccntno);
+}
+
+END { } # module clean-up code here (global destructor)
@@ -0,0 +1,176 @@
+package C4::Accounts2; #asummes C4/Accounts2
+
+#requires DBI.pm to be installed
+#uses DBD:Pg
+
+use strict;
+require Exporter;
+use DBI;
+use C4::Database;
+use C4::Stats;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+
+# set the version for version checking
+$VERSION = 0.01;
+
+@ISA = qw(Exporter);
+@EXPORT = qw(&recordpayment &fixaccounts &makepayment);
+%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
+
+# your exported package globals go here,
+# as well as any optionally exported functions
+
+@EXPORT_OK = qw($Var1 %Hashit);
+
+
+# non-exported package globals go here
+use vars qw(@more $stuff);
+
+# initalize package globals, first exported ones
+
+my $Var1 = '';
+my %Hashit = ();
+
+# then the others (which are still accessible as $Some::Module::stuff)
+my $stuff = '';
+my @more = ();
+
+# all file-scoped lexicals must be created before
+# the functions below that use them.
+
+# file-private lexicals go here
+my $priv_var = '';
+my %secret_hash = ();
+
+# here's a file-private function as a closure,
+# callable as &$priv_func; it cannot be prototyped.
+my $priv_func = sub {
+ # stuff goes here.
+};
+
+# make all your functions, whether exported or not;
+
+sub displayaccounts{
+ my ($env)=@_;
+}
+
+sub recordpayment{
+ #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 $amountleft = $data;
+ # 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;
+ # 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;
+ }
+ 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;
+ }
+ # create new line
+ $updquery = "insert into accountlines
+ (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding)
+ values ($bornumber,$nextaccntno,now(),0-$data,'Payment,thanks',
+ 'Pay',0-$amountleft)";
+ my $usth = $dbh->prepare($updquery);
+ $usth->execute;
+ $usth->finish;
+ UpdateStats($env,'branch','payment',$data);
+ $sth->finish;
+ $dbh->disconnect;
+}
+
+sub makepayment{
+ #here we update both the accountoffsets and the account lines
+ my ($bornumber,$accountno,$amount,$user)=@_;
+ 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 - $user', 'Pay',0)";
+ my $usth = $dbh->prepare($updquery);
+ $usth->execute;
+ $usth->finish;
+ UpdateStats($env,$user,'payment',$amount);
+ $sth->finish;
+ $dbh->disconnect;
+}
+
+sub getnextacctno {
+ my ($env,$bornumber,$dbh)=@_;
+ my $nextaccntno = 1;
+ my $query = "select * from accountlines
+ where (borrowernumber = '$bornumber')
+ order by accountno desc";
+ my $sth = $dbh->prepare($query);
+ $sth->execute;
+ if (my $accdata=$sth->fetchrow_hashref){
+ $nextaccntno = $accdata->{'accountno'} + 1;
+ }
+ $sth->finish;
+ return($nextaccntno);
+}
+
+sub fixaccounts {
+ my ($borrowernumber,$accountno,$amount)=@_;
+ my $dbh=C4Connect;
+ my $query="Select * from accountlines where borrowernumber=$borrowernumber
+ and accountno=$accountno";
+ my $sth=$dbh->prepare($query);
+ $sth->execute;
+ my $data=$sth->fetchrow_hashref;
+ my $diff=$amount-$data->{'amount'};
+ my $outstanding=$data->{'amountoutstanding'}+$diff;
+ $sth->finish;
+ $query="Update accountlines set amount='$amount',amountoutstanding='$outstanding' where
+ borrowernumber=$borrowernumber and accountno=$accountno";
+ $sth=$dbh->prepare($query);
+# print $query;
+ $sth->execute;
+ $sth->finish;
+ $dbh->disconnect;
+ }
+
+END { } # module clean-up code here (global destructor)
Oops, something went wrong.

0 comments on commit d0374d0

Please sign in to comment.