Lines 93-99
sub recordpayment {
Link Here
|
93 |
my $dbh = C4::Context->dbh; |
93 |
my $dbh = C4::Context->dbh; |
94 |
my $newamtos = 0; |
94 |
my $newamtos = 0; |
95 |
my $accdata = ""; |
95 |
my $accdata = ""; |
96 |
my $branch = C4::Context->userenv->{'branch'}; |
96 |
my $branch = C4::Context->userenv ? |
|
|
97 |
C4::Context->userenv->{'branch'} : undef; |
97 |
my $amountleft = $data; |
98 |
my $amountleft = $data; |
98 |
my $manager_id = 0; |
99 |
my $manager_id = 0; |
99 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
100 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
Lines 149-161
sub recordpayment {
Link Here
|
149 |
# create new line |
150 |
# create new line |
150 |
my $usth = $dbh->prepare( |
151 |
my $usth = $dbh->prepare( |
151 |
"INSERT INTO accountlines |
152 |
"INSERT INTO accountlines |
152 |
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id, note) |
153 |
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id, note,branchcode) |
153 |
VALUES (?,?,now(),?,'',?,?,?,?)" |
154 |
VALUES (?,?,now(),?,'',?,?,?,?,?)" |
154 |
); |
155 |
); |
155 |
|
156 |
|
156 |
my $paytype = "Pay"; |
157 |
my $paytype = "Pay"; |
157 |
$paytype .= $sip_paytype if defined $sip_paytype; |
158 |
$paytype .= $sip_paytype if defined $sip_paytype; |
158 |
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, $paytype, 0 - $amountleft, $manager_id, $payment_note ); |
159 |
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, $paytype, 0 - $amountleft, $manager_id, $payment_note, $branch ); |
159 |
$usth->finish; |
160 |
$usth->finish; |
160 |
|
161 |
|
161 |
UpdateStats({ |
162 |
UpdateStats({ |
Lines 244-253
sub makepayment {
Link Here
|
244 |
my $ins = |
245 |
my $ins = |
245 |
$dbh->prepare( |
246 |
$dbh->prepare( |
246 |
"INSERT |
247 |
"INSERT |
247 |
INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note) |
248 |
INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note, branchcode) |
248 |
VALUES ( ?, ?, now(), ?, ?, '', 'Pay', 0, ?, ?)" |
249 |
VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?, ?)" |
249 |
); |
250 |
); |
250 |
$ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note); |
251 |
$ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note, C4::Context->userenv->{'branch'}); |
251 |
} |
252 |
} |
252 |
|
253 |
|
253 |
if ( C4::Context->preference("FinesLog") ) { |
254 |
if ( C4::Context->preference("FinesLog") ) { |
Lines 370-379
sub chargelostitem{
Link Here
|
370 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
371 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
371 |
my $accountno = getnextacctno($borrowernumber); |
372 |
my $accountno = getnextacctno($borrowernumber); |
372 |
my $sth2=$dbh->prepare("INSERT INTO accountlines |
373 |
my $sth2=$dbh->prepare("INSERT INTO accountlines |
373 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id) |
374 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id,branchcode) |
374 |
VALUES (?,?,now(),?,?,'L',?,?,?)"); |
375 |
VALUES (?,?,now(),?,?,'L',?,?,?,?)"); |
375 |
$sth2->execute($borrowernumber,$accountno,$amount, |
376 |
my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
376 |
$description,$amount,$itemnumber,$manager_id); |
377 |
$sth2->execute( $borrowernumber, $accountno, $amount, $description, |
|
|
378 |
$amount, $itemnumber, $manager_id, $branchcode ); |
377 |
|
379 |
|
378 |
if ( C4::Context->preference("FinesLog") ) { |
380 |
if ( C4::Context->preference("FinesLog") ) { |
379 |
logaction("FINES", 'CREATE', $borrowernumber, Dumper({ |
381 |
logaction("FINES", 'CREATE', $borrowernumber, Dumper({ |
Lines 422-427
sub manualinvoice {
Link Here
|
422 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; |
424 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; |
423 |
my $manager_id = 0; |
425 |
my $manager_id = 0; |
424 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
426 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
|
|
427 |
my $branchcode = C4::Context->userenv->{'branch'}; |
425 |
my $dbh = C4::Context->dbh; |
428 |
my $dbh = C4::Context->dbh; |
426 |
my $notifyid = 0; |
429 |
my $notifyid = 0; |
427 |
my $insert; |
430 |
my $insert; |
Lines 441-456
sub manualinvoice {
Link Here
|
441 |
$desc .= ' ' . $itemnum; |
444 |
$desc .= ' ' . $itemnum; |
442 |
my $sth = $dbh->prepare( |
445 |
my $sth = $dbh->prepare( |
443 |
'INSERT INTO accountlines |
446 |
'INSERT INTO accountlines |
444 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id) |
447 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, branchcode) |
445 |
VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)'); |
448 |
VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?,?)'); |
446 |
$sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr; |
449 |
$sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id, $branchcode) || return $sth->errstr; |
447 |
} else { |
450 |
} else { |
448 |
my $sth=$dbh->prepare("INSERT INTO accountlines |
451 |
my $sth=$dbh->prepare("INSERT INTO accountlines |
449 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id) |
452 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, branchcode) |
450 |
VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)" |
453 |
VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?,?)" |
451 |
); |
454 |
); |
452 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, |
455 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, |
453 |
$amountleft, $notifyid, $note, $manager_id ); |
456 |
$amountleft, $notifyid, $note, $manager_id, $branchcode ); |
454 |
} |
457 |
} |
455 |
|
458 |
|
456 |
if ( C4::Context->preference("FinesLog") ) { |
459 |
if ( C4::Context->preference("FinesLog") ) { |
Lines 655-663
sub recordpayment_selectaccts {
Link Here
|
655 |
|
658 |
|
656 |
# create new line |
659 |
# create new line |
657 |
$sql = 'INSERT INTO accountlines ' . |
660 |
$sql = 'INSERT INTO accountlines ' . |
658 |
'(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note) ' . |
661 |
'(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note,branchcode) ' . |
659 |
q|VALUES (?,?,now(),?,'','Pay',?,?,?)|; |
662 |
q|VALUES (?,?,now(),?,'','Pay',?,?,?,?)|; |
660 |
$dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note ); |
663 |
$dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note, $branch ); |
661 |
UpdateStats({ |
664 |
UpdateStats({ |
662 |
branch => $branch, |
665 |
branch => $branch, |
663 |
type => 'payment', |
666 |
type => 'payment', |
Lines 701-707
sub makepartialpayment {
Link Here
|
701 |
'SELECT * FROM accountlines WHERE accountlines_id=?',undef,$accountlines_id); |
704 |
'SELECT * FROM accountlines WHERE accountlines_id=?',undef,$accountlines_id); |
702 |
my $new_outstanding = $data->{amountoutstanding} - $amount; |
705 |
my $new_outstanding = $data->{amountoutstanding} - $amount; |
703 |
|
706 |
|
704 |
my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? '; |
707 |
my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? '; |
705 |
$dbh->do( $update, undef, $new_outstanding, $accountlines_id); |
708 |
$dbh->do( $update, undef, $new_outstanding, $accountlines_id); |
706 |
|
709 |
|
707 |
if ( C4::Context->preference("FinesLog") ) { |
710 |
if ( C4::Context->preference("FinesLog") ) { |
Lines 719-729
sub makepartialpayment {
Link Here
|
719 |
|
722 |
|
720 |
# create new line |
723 |
# create new line |
721 |
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' |
724 |
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' |
722 |
. 'description, accounttype, amountoutstanding, itemnumber, manager_id, note) ' |
725 |
. 'description, accounttype, amountoutstanding, itemnumber, manager_id, note, branchcode) ' |
723 |
. ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)'; |
726 |
. ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?, ?)'; |
724 |
|
727 |
|
725 |
$dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, |
728 |
$dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, |
726 |
'', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note); |
729 |
'', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note, C4::Context->userenv->{'branch'}); |
727 |
|
730 |
|
728 |
UpdateStats({ |
731 |
UpdateStats({ |
729 |
branch => $user, |
732 |
branch => $user, |