Browse Source

updates to circulation

master
olwen 22 years ago
parent
commit
59e7b66479
  1. 4
      C4/Accounts.pm
  2. 15
      C4/Circulation/Borrower.pm
  3. 33
      C4/Circulation/Issues.pm
  4. 17
      C4/Circulation/Returns.pm

4
C4/Accounts.pm

@ -82,18 +82,20 @@ sub checkaccount {
sub reconcileaccount {
#print put money owing give person opportunity to pay it off
my ($env,$dbh,$bornumber,$total)=@_;
debug_msg($env,$dbh);
#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');
#&helptext('F11 quits');
output(20,0,"Accounts");
my @accountlines;
my $row=4;

15
C4/Circulation/Borrower.pm

@ -98,17 +98,17 @@ sub findborrower {
}
}
}
my $issuesallowed;
my ($issuesallowed,$owing);
if ($reason eq "") {
$env->{'bornum'} = $bornum;
$env->{'bcard'} = $borrower->{'cardnumber'};
my $borrowers=join(' ',($borrower->{'title'},$borrower->{'firstname'},$borrower->{'surname'}));
my $odues;
($issuesallowed,$odues) = &checktraps($env,$dbh,$bornum,$borrower);
#debug_msg ($env,"issuesallowed1 = $env->{'IssuesAllowed'}");
($issuesallowed,$odues,$owing) = &checktraps($env,$dbh,$bornum,$borrower);
debug_msg ($env,"owing = $owing");
}
#debug_msg ($env,"issuesallowed2 = $env->{'IssuesAllowed'}");
return ($bornum, $issuesallowed,$borrower,$reason);
#debug_msg ($env,"2 = $env->{'IssuesAllowed'}");
return ($bornum, $issuesallowed,$borrower,$reason,$owing);
};
@ -174,10 +174,11 @@ sub checktraps {
#check amountowing
my $traps_done;
my $odues;
my $amount;
while ($traps_done ne "DONE") {
my @traps_set;
#debug_msg($env,"entering traps");
my $amount=checkaccount($env,$bornum,$dbh); #from C4::Accounts
$amount=checkaccount($env,$bornum,$dbh); #from C4::Accounts
if ($amount > 0) { push (@traps_set,"FINES");}
if ($borrower->{'gonenoaddress'} == 1){ push (@traps_set,"GNA");}
#check if member has a card reported as lost
@ -199,7 +200,7 @@ sub checktraps {
}
}
#debug_msg($env,"returning issuesallowed $env->{'IssuesAllowed'}");
return ($issuesallowed, $odues);
return ($issuesallowed, $odues,$amount);
}
sub process_traps {

33
C4/Circulation/Issues.pm

@ -70,7 +70,7 @@ sub Issue {
$env->{'sysarea'} = "Issues";
$done = "Issues";
while ($done eq "Issues") {
my ($bornum,$issuesallowed,$borrower,$reason) = &findborrower($env,$dbh);
my ($bornum,$issuesallowed,$borrower,$reason,$amountdue) = &findborrower($env,$dbh);
#C4::Circulation::Borrowers
$env->{'loanlength'}="";
@ -89,7 +89,7 @@ sub Issue {
$done = "No";
my $it2p=0;
while ($done eq 'No'){
($done,$items2,$it2p) =
($done,$items2,$it2p,$amountdue) =
&processitems($env,$bornum,$borrower,$items,
$items2,$it2p,$amountdue);
}
@ -104,9 +104,8 @@ sub Issue {
sub processitems {
#process a users items
my ($env,$bornum,$borrower,$items,$items2,$it2p,$amountdue)=@_;
my ($env,$bornum,$borrower,$items,$items2,$it2p,$amountdue,$odues)=@_;
my $dbh=&C4Connect;
# my $amountdue = 0;
my ($itemnum,$reason) =
issuewindow($env,'Issues',$dbh,$items,$items2,$borrower,fmtdec($env,$amountdue,"32"));
if ($itemnum ne ""){
@ -123,15 +122,18 @@ sub processitems {
#check to see if more books to process for this user
my @done;
if ($reason eq 'Finished user'){
remoteprint($env,$items2,$borrower);
@done = ("Issues");
remoteprint($env,$items2,$borrower);
if ($amountdue > 0) {
&reconcileaccount($env,$dbh,$borrower->{'borrowernumber'},$amountdue);
}
@done = ("Issues");
} elsif ($reason eq "Print"){
remoteprint($env,$items2,$borrower);
@done = ("No",$items2,$it2p);
} else {
if ($reason ne 'Finished issues'){
#return No to let them know that we wish to process more Items for borrower
@done = ("No",$items2,$it2p);
@done = ("No",$items2,$it2p,$amountdue);
} else {
@done = ("Circ");
}
@ -213,6 +215,9 @@ sub issueitem{
$datedue=&updateissues($env,$item->{'itemnumber'},$item->{'biblioitemnumber'},$dbh,$bornum);
#debug_msg("","date $datedue");
&UpdateStats($env,$env->{'branchcode'},'issue');
if ($charge > 0) {
createcharge($env,$dbh,$item->{'itemnumber'},$bornum,$charge);
}
} elsif ($canissue == 0) {
debug_msg($env,"can't issue");
}
@ -224,6 +229,20 @@ sub issueitem{
return($item,$charge,$datedue);
}
sub createcharge {
my ($env,$dbh,$itemno,$bornum,$charge) = @_;
my $nextaccntno = getnextacctno($env,$bornum,$dbh);
my $query = "insert into accountlines
(borrowernumber,itemnumber,accountno,date,amount,
description,accounttype,amountoutstanding)
values ($bornum,$itemno,$nextaccntno,now(),$charge,'Rental','Rent',$charge)";
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
}
sub updateissues{
# issue the book
my ($env,$itemno,$bitno,$dbh,$bornum)=@_;

17
C4/Circulation/Returns.pm

@ -132,6 +132,7 @@ sub checkissue {
$reason = "Returned";
} else {
$sth->finish;
updatelastseen($env,$dbh,$itemrec->{'itemnumber'});
$reason = "Item not issued";
}
my ($resfound,$issrec) = find_reserves($env,$dbh,$itemrec->{'itemnumber'});
@ -159,18 +160,19 @@ sub returnrecord {
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
updatelastseen($env,$dbh,$itemno);
# check for overdue fine
my $oduecharge;
my $query = "select * from accountlines
where (borrowernumber = '$bornum')
and (itemnumber = '$itemno')
and (accounttype = 'F')";
and (accounttype = 'FU')";
my $sth = $dbh->prepare($query);
$sth->execute;
if (my $data = $sth->fetchrow_hashref) {
# alter fine to show that the book has been returned.
my $uquery = "update accountlines
set accounttype = 'FR'
set accounttype = 'F'
where (borrowernumber = '$bornum')
and (itemnumber = '$itemno')
and (accountno = '$data->{'accountno'}') ";
@ -235,6 +237,17 @@ sub calc_odues {
return($amt_owing);
}
sub updatelastseen {
my ($env,$dbh,$itemnumber)= @_;
my $br = $env->{'branchcode'};
my $query = "update items
set datelastseen = now(), holdingbranch = '$br'
where (itemnumber = '$itemnumber')";
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
}
sub find_reserves {
my ($env,$dbh,$itemno) = @_;
my $itemdata = itemnodata($env,$dbh,$itemno);

Loading…
Cancel
Save