|
Lines 126-134
sub recordpayment {
Link Here
|
| 126 |
my $usth = $dbh->prepare( |
126 |
my $usth = $dbh->prepare( |
| 127 |
"INSERT INTO accountlines |
127 |
"INSERT INTO accountlines |
| 128 |
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding) |
128 |
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding) |
| 129 |
VALUES (?,?,now(),?,'Payment,thanks','Pay',?)" |
129 |
VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?)" |
| 130 |
); |
130 |
); |
| 131 |
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft ); |
131 |
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft, $branch ); |
| 132 |
$usth->finish; |
132 |
$usth->finish; |
| 133 |
UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno ); |
133 |
UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno ); |
| 134 |
$sth->finish; |
134 |
$sth->finish; |
|
Lines 201-210
sub makepayment {
Link Here
|
| 201 |
my $ins = |
201 |
my $ins = |
| 202 |
$dbh->prepare( |
202 |
$dbh->prepare( |
| 203 |
"INSERT |
203 |
"INSERT |
| 204 |
INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id) |
204 |
INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, branchcode) |
| 205 |
VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?)" |
205 |
VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?)" |
| 206 |
); |
206 |
); |
| 207 |
$ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id); |
207 |
$ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, C4::Context->userenv->{'branch'}); |
| 208 |
$ins->finish; |
208 |
$ins->finish; |
| 209 |
} |
209 |
} |
| 210 |
|
210 |
|
|
Lines 298-307
sub chargelostitem{
Link Here
|
| 298 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
298 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
| 299 |
my $accountno = getnextacctno($borrowernumber); |
299 |
my $accountno = getnextacctno($borrowernumber); |
| 300 |
my $sth2=$dbh->prepare("INSERT INTO accountlines |
300 |
my $sth2=$dbh->prepare("INSERT INTO accountlines |
| 301 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber) |
301 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,branchcode) |
| 302 |
VALUES (?,?,now(),?,?,'L',?,?)"); |
302 |
VALUES (?,?,now(),?,?,'L',?,?,?)"); |
| 303 |
$sth2->execute($borrowernumber,$accountno,$amount, |
303 |
$sth2->execute($borrowernumber,$accountno,$amount, |
| 304 |
$description,$amount,$itemnumber); |
304 |
$description,$amount,$itemnumber,C4::Context->userenv->{'branch'}); |
| 305 |
$sth2->finish; |
305 |
$sth2->finish; |
| 306 |
# FIXME: Log this ? |
306 |
# FIXME: Log this ? |
| 307 |
} |
307 |
} |
|
Lines 337-342
sub manualinvoice {
Link Here
|
| 337 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; |
337 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; |
| 338 |
my $manager_id = 0; |
338 |
my $manager_id = 0; |
| 339 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
339 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
|
|
340 |
my $branchcode = C4::Context->userenv->{'branch'}; |
| 340 |
my $dbh = C4::Context->dbh; |
341 |
my $dbh = C4::Context->dbh; |
| 341 |
my $notifyid = 0; |
342 |
my $notifyid = 0; |
| 342 |
my $insert; |
343 |
my $insert; |
|
Lines 387-402
sub manualinvoice {
Link Here
|
| 387 |
$desc .= ' ' . $itemnum; |
388 |
$desc .= ' ' . $itemnum; |
| 388 |
my $sth = $dbh->prepare( |
389 |
my $sth = $dbh->prepare( |
| 389 |
'INSERT INTO accountlines |
390 |
'INSERT INTO accountlines |
| 390 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id) |
391 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, branchcode) |
| 391 |
VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)'); |
392 |
VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?,?)'); |
| 392 |
$sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr; |
393 |
$sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id, $branchcode) || return $sth->errstr; |
| 393 |
} else { |
394 |
} else { |
| 394 |
my $sth=$dbh->prepare("INSERT INTO accountlines |
395 |
my $sth=$dbh->prepare("INSERT INTO accountlines |
| 395 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id) |
396 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, branchcode) |
| 396 |
VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)" |
397 |
VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?,?)" |
| 397 |
); |
398 |
); |
| 398 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, |
399 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, |
| 399 |
$amountleft, $notifyid, $note, $manager_id ); |
400 |
$amountleft, $notifyid, $note, $manager_id, $branchcode ); |
| 400 |
} |
401 |
} |
| 401 |
return 0; |
402 |
return 0; |
| 402 |
} |
403 |
} |
|
Lines 713-722
sub recordpayment_selectaccts {
Link Here
|
| 713 |
} |
714 |
} |
| 714 |
|
715 |
|
| 715 |
# create new line |
716 |
# create new line |
| 716 |
$sql = 'INSERT INTO accountlines ' . |
717 |
$sql = " |
| 717 |
'(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding) ' . |
718 |
INSERT INTO accountlines |
| 718 |
q|VALUES (?,?,now(),?,'Payment,thanks','Pay',?)|; |
719 |
( borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, branchcode) |
| 719 |
$dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft ); |
720 |
VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?) |
|
|
721 |
"; |
| 722 |
$dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $branch ); |
| 720 |
UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno ); |
723 |
UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno ); |
| 721 |
return; |
724 |
return; |
| 722 |
} |
725 |
} |
|
Lines 739-755
sub makepartialpayment {
Link Here
|
| 739 |
'SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?',undef,$borrowernumber,$accountno); |
742 |
'SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?',undef,$borrowernumber,$accountno); |
| 740 |
my $new_outstanding = $data->{amountoutstanding} - $amount; |
743 |
my $new_outstanding = $data->{amountoutstanding} - $amount; |
| 741 |
|
744 |
|
| 742 |
my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE borrowernumber = ? ' |
745 |
my $update = " |
| 743 |
. ' AND accountno = ?'; |
746 |
UPDATE accountlines SET amountoutstanding = ? WHERE borrowernumber = ? AND accountno = ? |
|
|
747 |
"; |
| 744 |
$dbh->do( $update, undef, $new_outstanding, $borrowernumber, $accountno); |
748 |
$dbh->do( $update, undef, $new_outstanding, $borrowernumber, $accountno); |
| 745 |
|
749 |
|
| 746 |
# create new line |
750 |
# create new line |
| 747 |
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' |
751 |
my $insert = " |
| 748 |
. 'description, accounttype, amountoutstanding, itemnumber, manager_id) ' |
752 |
INSERT INTO accountlines (borrowernumber, accountno, date, amount, |
| 749 |
. ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?)'; |
753 |
description, accounttype, amountoutstanding, itemnumber, manager_id, branchcode) |
|
|
754 |
VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?) |
| 755 |
"; |
| 750 |
|
756 |
|
| 751 |
$dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, |
757 |
$dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, |
| 752 |
"Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id); |
758 |
"Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, C4::Context->userenv->{'branch'}); |
| 753 |
|
759 |
|
| 754 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); |
760 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); |
| 755 |
|
761 |
|