Lines 35-41
BEGIN {
Link Here
|
35 |
@ISA = qw(Exporter); |
35 |
@ISA = qw(Exporter); |
36 |
@EXPORT = qw( |
36 |
@EXPORT = qw( |
37 |
&recordpayment &makepayment &manualinvoice |
37 |
&recordpayment &makepayment &manualinvoice |
38 |
&getnextacctno &reconcileaccount &getcharges &ModNote &getcredits |
38 |
&getnextacctno &reconcileaccount &getcharges &ModNote &ModMeansOfPayment &ModManagerId &getMeansOfPaymentList &getcredits |
39 |
&getrefunds &chargelostitem |
39 |
&getrefunds &chargelostitem |
40 |
&ReversePayment |
40 |
&ReversePayment |
41 |
); # removed &fixaccounts |
41 |
); # removed &fixaccounts |
Lines 104-113
sub recordpayment {
Link Here
|
104 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
104 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
105 |
$amountleft = 0; |
105 |
$amountleft = 0; |
106 |
} |
106 |
} |
107 |
my $thisacct = $accdata->{accountno}; |
107 |
my $thisacct = $accdata->{id}; |
108 |
my $usth = $dbh->prepare( |
108 |
my $usth = $dbh->prepare( |
109 |
"UPDATE accountlines SET amountoutstanding= ? |
109 |
"UPDATE accountlines SET amountoutstanding= ? |
110 |
WHERE (borrowernumber = ?) AND (accountno=?)" |
110 |
WHERE (id=?)" |
111 |
); |
111 |
); |
112 |
$usth->execute( $newamtos, $borrowernumber, $thisacct ); |
112 |
$usth->execute( $newamtos, $borrowernumber, $thisacct ); |
113 |
$usth->finish; |
113 |
$usth->finish; |
Lines 124-131
sub recordpayment {
Link Here
|
124 |
# create new line |
124 |
# create new line |
125 |
my $usth = $dbh->prepare( |
125 |
my $usth = $dbh->prepare( |
126 |
"INSERT INTO accountlines |
126 |
"INSERT INTO accountlines |
127 |
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding) |
127 |
(borrowernumber, accountno,date,time,amount,description,accounttype,amountoutstanding) |
128 |
VALUES (?,?,now(),?,'Payment,thanks','Pay',?)" |
128 |
VALUES (?,?,now(),CURRENT_TIME,?,'Payment,thanks','Pay',?)" |
129 |
); |
129 |
); |
130 |
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft ); |
130 |
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft ); |
131 |
$usth->finish; |
131 |
$usth->finish; |
Lines 135-141
sub recordpayment {
Link Here
|
135 |
|
135 |
|
136 |
=head2 makepayment |
136 |
=head2 makepayment |
137 |
|
137 |
|
138 |
&makepayment($borrowernumber, $acctnumber, $amount, $branchcode); |
138 |
&makepayment($accountlineid, $borrowernumber, $acctnumber, $amount, $branchcode, $note, $meansofpayment, $manager_id, $partpaymentamount); |
139 |
|
139 |
|
140 |
Records the fact that a patron has paid off the entire amount he or |
140 |
Records the fact that a patron has paid off the entire amount he or |
141 |
she owes. |
141 |
she owes. |
Lines 144-150
C<$borrowernumber> is the patron's borrower number. C<$acctnumber> is
Link Here
|
144 |
the account that was credited. C<$amount> is the amount paid (this is |
144 |
the account that was credited. C<$amount> is the amount paid (this is |
145 |
only used to record the payment. It is assumed to be equal to the |
145 |
only used to record the payment. It is assumed to be equal to the |
146 |
amount owed). C<$branchcode> is the code of the branch where payment |
146 |
amount owed). C<$branchcode> is the code of the branch where payment |
147 |
was made. |
147 |
was made. If $partpaymentamount > 0 it's a part payment. |
148 |
|
148 |
|
149 |
=cut |
149 |
=cut |
150 |
|
150 |
|
Lines 156-162
sub makepayment {
Link Here
|
156 |
#here we update both the accountoffsets and the account lines |
156 |
#here we update both the accountoffsets and the account lines |
157 |
#updated to check, if they are paying off a lost item, we return the item |
157 |
#updated to check, if they are paying off a lost item, we return the item |
158 |
# from their card, and put a note on the item record |
158 |
# from their card, and put a note on the item record |
159 |
my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_; |
159 |
my ( $accountlineid, $borrowernumber, $accountno, $amount, $user, $branch, $note, $meansofpayment, $manager_id, $partpaymentamount ) = @_; |
160 |
my $dbh = C4::Context->dbh; |
160 |
my $dbh = C4::Context->dbh; |
161 |
|
161 |
|
162 |
# begin transaction |
162 |
# begin transaction |
Lines 164-204
sub makepayment {
Link Here
|
164 |
my $newamtos = 0; |
164 |
my $newamtos = 0; |
165 |
my $sth = |
165 |
my $sth = |
166 |
$dbh->prepare( |
166 |
$dbh->prepare( |
167 |
"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?"); |
167 |
"SELECT * FROM accountlines WHERE id=?"); |
168 |
$sth->execute( $borrowernumber, $accountno ); |
168 |
$sth->execute( $accountlineid ); |
169 |
my $data = $sth->fetchrow_hashref; |
169 |
my $data = $sth->fetchrow_hashref; |
170 |
$sth->finish; |
170 |
$sth->finish; |
171 |
|
171 |
|
|
|
172 |
my $newamountoutstanding=0; |
173 |
my $payment = 0 - $amount; |
174 |
$payment = 0-$data->{'amountoutstanding'}; |
175 |
my $finalamount = $amount; |
176 |
my $descriptionpayment="Payment for account n°".$accountno.",thanks - ".$user." : ".$data->{'description'}; |
177 |
if($partpaymentamount!=0) |
178 |
{ |
179 |
$newamountoutstanding=$data->{'amountoutstanding'}-$partpaymentamount; |
180 |
$payment = 0 - $partpaymentamount; |
181 |
$finalamount = $partpaymentamount; |
182 |
$descriptionpayment="Part Payment for account n°".$accountno.",thanks - ".$user." : ".$data->{'description'}; |
183 |
} |
184 |
|
172 |
$dbh->do( |
185 |
$dbh->do( |
173 |
"UPDATE accountlines |
186 |
"UPDATE accountlines |
174 |
SET amountoutstanding = 0 |
187 |
SET amountoutstanding = $newamountoutstanding |
175 |
WHERE borrowernumber = $borrowernumber |
188 |
WHERE id = $accountlineid |
176 |
AND accountno = $accountno |
|
|
177 |
" |
189 |
" |
178 |
); |
190 |
); |
179 |
|
191 |
|
180 |
# print $updquery; |
|
|
181 |
# $dbh->do( " |
182 |
# INSERT INTO accountoffsets |
183 |
# (borrowernumber, accountno, offsetaccount, |
184 |
# offsetamount) |
185 |
# VALUES ($borrowernumber, $accountno, $nextaccntno, $newamtos) |
186 |
# " ); |
187 |
|
188 |
# create new line |
192 |
# create new line |
189 |
my $payment = 0 - $amount; |
|
|
190 |
$dbh->do( " |
193 |
$dbh->do( " |
191 |
INSERT INTO accountlines |
194 |
INSERT INTO accountlines |
192 |
(borrowernumber, accountno, date, amount, |
195 |
(borrowernumber, accountno, date, time, amount, |
193 |
description, accounttype, amountoutstanding) |
196 |
description, accounttype, amountoutstanding, |
194 |
VALUES ($borrowernumber, $nextaccntno, now(), $payment, |
197 |
note, meansofpayment, manager_id) |
195 |
'Payment,thanks - $user', 'Pay', 0) |
198 |
VALUES ($borrowernumber, $nextaccntno, now(), CURRENT_TIME, $payment, |
|
|
199 |
'$descriptionpayment', 'Pay', 0, '$note', '$meansofpayment', '$manager_id') |
196 |
" ); |
200 |
" ); |
197 |
|
201 |
|
198 |
# FIXME - The second argument to &UpdateStats is supposed to be the |
202 |
# FIXME - The second argument to &UpdateStats is supposed to be the |
199 |
# branch code. |
203 |
# branch code. |
200 |
# UpdateStats is now being passed $accountno too. MTJ |
204 |
# UpdateStats is now being passed $accountno too. MTJ |
201 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, |
205 |
UpdateStats( $user, 'payment', $finalamount, '', '', '', $borrowernumber, |
202 |
$accountno ); |
206 |
$accountno ); |
203 |
$sth->finish; |
207 |
$sth->finish; |
204 |
|
208 |
|
Lines 206-211
sub makepayment {
Link Here
|
206 |
if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) { |
210 |
if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) { |
207 |
returnlost( $borrowernumber, $data->{'itemnumber'} ); |
211 |
returnlost( $borrowernumber, $data->{'itemnumber'} ); |
208 |
} |
212 |
} |
|
|
213 |
|
214 |
my $sth = $dbh->prepare("SELECT max(id) AS lastinsertid FROM accountlines"); |
215 |
$sth->execute(); |
216 |
my $datalastinsertid = $sth->fetchrow_hashref; |
217 |
$sth->finish; |
218 |
return $datalastinsertid->{'lastinsertid'}; |
209 |
} |
219 |
} |
210 |
|
220 |
|
211 |
=head2 getnextacctno |
221 |
=head2 getnextacctno |
Lines 233-250
sub getnextacctno ($) {
Link Here
|
233 |
|
243 |
|
234 |
=head2 fixaccounts (removed) |
244 |
=head2 fixaccounts (removed) |
235 |
|
245 |
|
236 |
&fixaccounts($borrowernumber, $accountnumber, $amount); |
246 |
&fixaccounts($accountlineid, $borrowernumber, $accountnumber, $amount); |
237 |
|
247 |
|
238 |
#' |
248 |
#' |
239 |
# FIXME - I don't understand what this function does. |
249 |
# FIXME - I don't understand what this function does. |
240 |
sub fixaccounts { |
250 |
sub fixaccounts { |
241 |
my ( $borrowernumber, $accountno, $amount ) = @_; |
251 |
my ( $accountlineid, $borrowernumber, $accountno, $amount ) = @_; |
242 |
my $dbh = C4::Context->dbh; |
252 |
my $dbh = C4::Context->dbh; |
243 |
my $sth = $dbh->prepare( |
253 |
my $sth = $dbh->prepare( |
244 |
"SELECT * FROM accountlines WHERE borrowernumber=? |
254 |
"SELECT * FROM accountlines WHERE id=?" |
245 |
AND accountno=?" |
|
|
246 |
); |
255 |
); |
247 |
$sth->execute( $borrowernumber, $accountno ); |
256 |
$sth->execute( $accountlineid ); |
248 |
my $data = $sth->fetchrow_hashref; |
257 |
my $data = $sth->fetchrow_hashref; |
249 |
|
258 |
|
250 |
# FIXME - Error-checking |
259 |
# FIXME - Error-checking |
Lines 256-263
sub fixaccounts {
Link Here
|
256 |
UPDATE accountlines |
265 |
UPDATE accountlines |
257 |
SET amount = '$amount', |
266 |
SET amount = '$amount', |
258 |
amountoutstanding = '$outstanding' |
267 |
amountoutstanding = '$outstanding' |
259 |
WHERE borrowernumber = $borrowernumber |
268 |
WHERE id = $accountlineid |
260 |
AND accountno = $accountno |
|
|
261 |
EOT |
269 |
EOT |
262 |
# FIXME: exceedingly bad form. Use prepare with placholders ("?") in query and execute args. |
270 |
# FIXME: exceedingly bad form. Use prepare with placholders ("?") in query and execute args. |
263 |
} |
271 |
} |
Lines 307-314
sub chargelostitem{
Link Here
|
307 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
315 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
308 |
my $accountno = getnextacctno($issues->{'borrowernumber'}); |
316 |
my $accountno = getnextacctno($issues->{'borrowernumber'}); |
309 |
my $sth2=$dbh->prepare("INSERT INTO accountlines |
317 |
my $sth2=$dbh->prepare("INSERT INTO accountlines |
310 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber) |
318 |
(borrowernumber,accountno,date,time,amount,description,accounttype,amountoutstanding,itemnumber) |
311 |
VALUES (?,?,now(),?,?,'L',?,?)"); |
319 |
VALUES (?,?,now(),CURRENT_TIME,?,?,'L',?,?)"); |
312 |
$sth2->execute($issues->{'borrowernumber'},$accountno,$issues->{'replacementprice'}, |
320 |
$sth2->execute($issues->{'borrowernumber'},$accountno,$issues->{'replacementprice'}, |
313 |
"Lost Item $issues->{'title'} $issues->{'barcode'}", |
321 |
"Lost Item $issues->{'title'} $issues->{'barcode'}", |
314 |
$issues->{'replacementprice'},$itemnumber); |
322 |
$issues->{'replacementprice'},$itemnumber); |
Lines 327-333
sub chargelostitem{
Link Here
|
327 |
=head2 manualinvoice |
335 |
=head2 manualinvoice |
328 |
|
336 |
|
329 |
&manualinvoice($borrowernumber, $itemnumber, $description, $type, |
337 |
&manualinvoice($borrowernumber, $itemnumber, $description, $type, |
330 |
$amount, $note); |
338 |
$amount, $note, $meansofpayment); |
331 |
|
339 |
|
332 |
C<$borrowernumber> is the patron's borrower number. |
340 |
C<$borrowernumber> is the patron's borrower number. |
333 |
C<$description> is a description of the transaction. |
341 |
C<$description> is a description of the transaction. |
Lines 351-357
should be the empty string.
Link Here
|
351 |
# |
359 |
# |
352 |
|
360 |
|
353 |
sub manualinvoice { |
361 |
sub manualinvoice { |
354 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; |
362 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $meansofpayment ) = @_; |
355 |
my $manager_id = C4::Context->userenv->{'number'}; |
363 |
my $manager_id = C4::Context->userenv->{'number'}; |
356 |
my $dbh = C4::Context->dbh; |
364 |
my $dbh = C4::Context->dbh; |
357 |
my $notifyid = 0; |
365 |
my $notifyid = 0; |
Lines 404-419
sub manualinvoice {
Link Here
|
404 |
$desc .= " " . $itemnum; |
412 |
$desc .= " " . $itemnum; |
405 |
my $sth = $dbh->prepare( |
413 |
my $sth = $dbh->prepare( |
406 |
"INSERT INTO accountlines |
414 |
"INSERT INTO accountlines |
407 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id) |
415 |
(borrowernumber, accountno, date, time, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, meansofpayment) |
408 |
VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)"); |
416 |
VALUES (?, ?, now(), CURRENT_TIME, ?,?, ?,?,?,?,?,?,?)"); |
409 |
$sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr; |
417 |
$sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id, $meansofpayment) || return $sth->errstr; |
410 |
} else { |
418 |
} else { |
411 |
my $sth=$dbh->prepare("INSERT INTO accountlines |
419 |
my $sth=$dbh->prepare("INSERT INTO accountlines |
412 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id) |
420 |
(borrowernumber, accountno, date, time, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, meansofpayment) |
413 |
VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)" |
421 |
VALUES (?, ?, now(), CURRENT_TIME, ?, ?, ?, ?,?,?,?,?)" |
414 |
); |
422 |
); |
415 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, |
423 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, |
416 |
$amountleft, $notifyid, $note, $manager_id ); |
424 |
$amountleft, $notifyid, $note, $manager_id, $meansofpayment ); |
417 |
} |
425 |
} |
418 |
return 0; |
426 |
return 0; |
419 |
} |
427 |
} |
Lines 465-474
sub fixcredit {
Link Here
|
465 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
473 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
466 |
$amountleft = 0; |
474 |
$amountleft = 0; |
467 |
} |
475 |
} |
468 |
my $thisacct = $accdata->{accountno}; |
476 |
my $thisacct = $accdata->{id}; |
469 |
my $usth = $dbh->prepare( |
477 |
my $usth = $dbh->prepare( |
470 |
"UPDATE accountlines SET amountoutstanding= ? |
478 |
"UPDATE accountlines SET amountoutstanding= ? |
471 |
WHERE (borrowernumber = ?) AND (accountno=?)" |
479 |
WHERE (id=?)" |
472 |
); |
480 |
); |
473 |
$usth->execute( $newamtos, $borrowernumber, $thisacct ); |
481 |
$usth->execute( $newamtos, $borrowernumber, $thisacct ); |
474 |
$usth->finish; |
482 |
$usth->finish; |
Lines 504-515
sub fixcredit {
Link Here
|
504 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
512 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
505 |
$amountleft = 0; |
513 |
$amountleft = 0; |
506 |
} |
514 |
} |
507 |
my $thisacct = $accdata->{accountno}; |
515 |
my $thisacct = $accdata->{id}; |
508 |
my $usth = $dbh->prepare( |
516 |
my $usth = $dbh->prepare( |
509 |
"UPDATE accountlines SET amountoutstanding= ? |
517 |
"UPDATE accountlines SET amountoutstanding= ? |
510 |
WHERE (borrowernumber = ?) AND (accountno=?)" |
518 |
WHERE (id=?)" |
511 |
); |
519 |
); |
512 |
$usth->execute( $newamtos, $borrowernumber, $thisacct ); |
520 |
$usth->execute( $newamtos, $thisacct ); |
513 |
$usth->finish; |
521 |
$usth->finish; |
514 |
$usth = $dbh->prepare( |
522 |
$usth = $dbh->prepare( |
515 |
"INSERT INTO accountoffsets |
523 |
"INSERT INTO accountoffsets |
Lines 557-563
sub refund {
Link Here
|
557 |
); |
565 |
); |
558 |
$sth->execute($borrowernumber); |
566 |
$sth->execute($borrowernumber); |
559 |
|
567 |
|
560 |
# print $amountleft; |
|
|
561 |
# offset transactions |
568 |
# offset transactions |
562 |
while ( ( $accdata = $sth->fetchrow_hashref ) and ( $amountleft < 0 ) ) { |
569 |
while ( ( $accdata = $sth->fetchrow_hashref ) and ( $amountleft < 0 ) ) { |
563 |
if ( $accdata->{'amountoutstanding'} > $amountleft ) { |
570 |
if ( $accdata->{'amountoutstanding'} > $amountleft ) { |
Lines 569-581
sub refund {
Link Here
|
569 |
$amountleft = 0; |
576 |
$amountleft = 0; |
570 |
} |
577 |
} |
571 |
|
578 |
|
572 |
# print $amountleft; |
579 |
my $thisacct = $accdata->{id}; |
573 |
my $thisacct = $accdata->{accountno}; |
|
|
574 |
my $usth = $dbh->prepare( |
580 |
my $usth = $dbh->prepare( |
575 |
"UPDATE accountlines SET amountoutstanding= ? |
581 |
"UPDATE accountlines SET amountoutstanding= ? |
576 |
WHERE (borrowernumber = ?) AND (accountno=?)" |
582 |
WHERE (id=?)" |
577 |
); |
583 |
); |
578 |
$usth->execute( $newamtos, $borrowernumber, $thisacct ); |
584 |
$usth->execute( $newamtos, $thisacct ); |
579 |
$usth->finish; |
585 |
$usth->finish; |
580 |
$usth = $dbh->prepare( |
586 |
$usth = $dbh->prepare( |
581 |
"INSERT INTO accountoffsets |
587 |
"INSERT INTO accountoffsets |
Lines 608-617
sub getcharges {
Link Here
|
608 |
} |
614 |
} |
609 |
|
615 |
|
610 |
sub ModNote { |
616 |
sub ModNote { |
611 |
my ( $borrowernumber, $accountno, $note ) = @_; |
617 |
my ( $accountlineid, $note ) = @_; |
612 |
my $dbh = C4::Context->dbh; |
618 |
my $dbh = C4::Context->dbh; |
613 |
my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE borrowernumber = ? AND accountno = ?'); |
619 |
my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE id = ?'); |
614 |
$sth->execute( $note, $borrowernumber, $accountno ); |
620 |
$sth->execute( $note, $accountlineid ); |
|
|
621 |
} |
622 |
|
623 |
|
624 |
sub ModMeansOfPayment { |
625 |
my ( $accountlineid, $meansofpayment ) = @_; |
626 |
my $dbh = C4::Context->dbh; |
627 |
my $sth = $dbh->prepare('UPDATE accountlines SET meansofpayment = ? WHERE id = ?'); |
628 |
$sth->execute( $meansofpayment, $accountlineid ); |
629 |
} |
630 |
|
631 |
sub ModManagerId { |
632 |
my ( $accountlineid, $manager_id ) = @_; |
633 |
my $dbh = C4::Context->dbh; |
634 |
my $sth = $dbh->prepare('UPDATE accountlines SET manager_id = ? WHERE id = ?'); |
635 |
$sth->execute( $manager_id, $accountlineid ); |
636 |
} |
637 |
|
638 |
sub getMeansOfPaymentList { |
639 |
my ($selectedoption) = @_; |
640 |
my $dbh = C4::Context->dbh; |
641 |
my $sth = $dbh->prepare( "SELECT * FROM `systempreferences` WHERE variable='MeansOfPayment'" ); |
642 |
$sth->execute(); |
643 |
my @options; |
644 |
my $booloption=0; |
645 |
while ( my $data = $sth->fetchrow_hashref ) { |
646 |
foreach my $option ( split( /\|/, $data->{'value'} ) ) { |
647 |
my $selected = ''; |
648 |
if($option eq $selectedoption) |
649 |
{ |
650 |
$selected = ' selected="selected"'; |
651 |
$booloption=1; |
652 |
} |
653 |
push @options, { option => $option, selected => $selected }; |
654 |
} |
655 |
} |
656 |
if($booloption==0 && $selectedoption ne "") |
657 |
{ |
658 |
push @options, { option => $selectedoption, selected => ' selected="selected"' }; |
659 |
} |
660 |
$sth->finish; |
661 |
return \@options; |
615 |
} |
662 |
} |
616 |
|
663 |
|
617 |
sub getcredits { |
664 |
sub getcredits { |
Lines 656-675
sub getrefunds {
Link Here
|
656 |
} |
703 |
} |
657 |
|
704 |
|
658 |
sub ReversePayment { |
705 |
sub ReversePayment { |
659 |
my ( $borrowernumber, $accountno ) = @_; |
706 |
my ( $accountlineid ) = @_; |
660 |
my $dbh = C4::Context->dbh; |
707 |
my $dbh = C4::Context->dbh; |
661 |
|
708 |
|
662 |
my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE borrowernumber = ? AND accountno = ?'); |
709 |
my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE id=?'); |
663 |
$sth->execute( $borrowernumber, $accountno ); |
710 |
$sth->execute( $accountlineid ); |
664 |
my $row = $sth->fetchrow_hashref(); |
711 |
my $row = $sth->fetchrow_hashref(); |
665 |
my $amount_outstanding = $row->{'amountoutstanding'}; |
712 |
my $amount_outstanding = $row->{'amountoutstanding'}; |
666 |
|
713 |
|
667 |
if ( $amount_outstanding <= 0 ) { |
714 |
if ( $amount_outstanding <= 0 ) { |
668 |
$sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?'); |
715 |
$sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE id = ?'); |
669 |
$sth->execute( $borrowernumber, $accountno ); |
716 |
$sth->execute( $accountlineid ); |
670 |
} else { |
717 |
} else { |
671 |
$sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?'); |
718 |
$sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE id = ?'); |
672 |
$sth->execute( $borrowernumber, $accountno ); |
719 |
$sth->execute( $accountlineid ); |
673 |
} |
720 |
} |
674 |
} |
721 |
} |
675 |
|
722 |
|