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