|
Lines 17-24
package C4::Accounts;
Link Here
|
| 17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
| 18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
|
19 |
|
| 20 |
|
|
|
| 21 |
use strict; |
20 |
use strict; |
|
|
21 |
|
| 22 |
#use warnings; FIXME - Bug 2505 |
22 |
#use warnings; FIXME - Bug 2505 |
| 23 |
use C4::Context; |
23 |
use C4::Context; |
| 24 |
use C4::Stats; |
24 |
use C4::Stats; |
|
Lines 29-44
use C4::Circulation qw(MarkIssueReturned);
Link Here
|
| 29 |
use vars qw($VERSION @ISA @EXPORT); |
29 |
use vars qw($VERSION @ISA @EXPORT); |
| 30 |
|
30 |
|
| 31 |
BEGIN { |
31 |
BEGIN { |
| 32 |
# set the version for version checking |
32 |
# set the version for version checking |
| 33 |
$VERSION = 3.03; |
33 |
$VERSION = 3.03; |
| 34 |
require Exporter; |
34 |
require Exporter; |
| 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 &getcredits |
38 |
&getnextacctno &reconcileaccount &getcharges |
| 39 |
&getrefunds &chargelostitem |
39 |
&ModNote &ModMeansOfPayment &ModManagerId &getMeansOfPaymentList &getcredits |
| 40 |
&ReversePayment |
40 |
&getrefunds &chargelostitem |
| 41 |
); # removed &fixaccounts |
41 |
&ReversePayment |
|
|
42 |
); # removed &fixaccounts |
| 42 |
} |
43 |
} |
| 43 |
|
44 |
|
| 44 |
=head1 NAME |
45 |
=head1 NAME |
|
Lines 99-131
sub recordpayment {
Link Here
|
| 99 |
if ( $accdata->{'amountoutstanding'} < $amountleft ) { |
100 |
if ( $accdata->{'amountoutstanding'} < $amountleft ) { |
| 100 |
$newamtos = 0; |
101 |
$newamtos = 0; |
| 101 |
$amountleft -= $accdata->{'amountoutstanding'}; |
102 |
$amountleft -= $accdata->{'amountoutstanding'}; |
| 102 |
} |
103 |
} else { |
| 103 |
else { |
|
|
| 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; |
| 114 |
# $usth = $dbh->prepare( |
114 |
|
| 115 |
# "INSERT INTO accountoffsets |
115 |
# $usth = $dbh->prepare( |
| 116 |
# (borrowernumber, accountno, offsetaccount, offsetamount) |
116 |
# "INSERT INTO accountoffsets |
| 117 |
# VALUES (?,?,?,?)" |
117 |
# (borrowernumber, accountno, offsetaccount, offsetamount) |
| 118 |
# ); |
118 |
# VALUES (?,?,?,?)" |
| 119 |
# $usth->execute( $borrowernumber, $accdata->{'accountno'}, |
119 |
# ); |
| 120 |
# $nextaccntno, $newamtos ); |
120 |
# $usth->execute( $borrowernumber, $accdata->{'accountno'}, |
|
|
121 |
# $nextaccntno, $newamtos ); |
| 121 |
$usth->finish; |
122 |
$usth->finish; |
| 122 |
} |
123 |
} |
| 123 |
|
124 |
|
| 124 |
# create new line |
125 |
# create new line |
| 125 |
my $usth = $dbh->prepare( |
126 |
my $usth = $dbh->prepare( |
| 126 |
"INSERT INTO accountlines |
127 |
"INSERT INTO accountlines |
| 127 |
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding) |
128 |
(borrowernumber, accountno,date,time,amount,description,accounttype,amountoutstanding) |
| 128 |
VALUES (?,?,now(),?,'Payment,thanks','Pay',?)" |
129 |
VALUES (?,?,now(),CURRENT_TIME,?,'Payment,thanks','Pay',?)" |
| 129 |
); |
130 |
); |
| 130 |
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft ); |
131 |
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft ); |
| 131 |
$usth->finish; |
132 |
$usth->finish; |
|
Lines 135-141
sub recordpayment {
Link Here
|
| 135 |
|
136 |
|
| 136 |
=head2 makepayment |
137 |
=head2 makepayment |
| 137 |
|
138 |
|
| 138 |
&makepayment($borrowernumber, $acctnumber, $amount, $branchcode); |
139 |
&makepayment($accountlineid, $borrowernumber, $acctnumber, $amount, $branchcode, $note, $meansofpayment, $manager_id, $partpaymentamount); |
| 139 |
|
140 |
|
| 140 |
Records the fact that a patron has paid off the entire amount he or |
141 |
Records the fact that a patron has paid off the entire amount he or |
| 141 |
she owes. |
142 |
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 |
145 |
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 |
146 |
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 |
147 |
amount owed). C<$branchcode> is the code of the branch where payment |
| 147 |
was made. |
148 |
was made. if $partpaymentamount > 0 it's a part payment |
| 148 |
|
149 |
|
| 149 |
=cut |
150 |
=cut |
| 150 |
|
151 |
|
|
Lines 156-211
sub makepayment {
Link Here
|
| 156 |
#here we update both the accountoffsets and the account lines |
157 |
#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 |
158 |
#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 |
159 |
# from their card, and put a note on the item record |
| 159 |
my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_; |
160 |
my ( $accountlineid, $borrowernumber, $accountno, $amount, $user, $branch, $note, $meansofpayment, $manager_id, $partpaymentamount ) = @_; |
| 160 |
my $dbh = C4::Context->dbh; |
161 |
my $dbh = C4::Context->dbh; |
| 161 |
|
162 |
|
| 162 |
# begin transaction |
163 |
# begin transaction |
| 163 |
my $nextaccntno = getnextacctno($borrowernumber); |
164 |
my $nextaccntno = getnextacctno($borrowernumber); |
| 164 |
my $newamtos = 0; |
165 |
my $newamtos = 0; |
| 165 |
my $sth = |
166 |
my $sth = $dbh->prepare("SELECT * FROM accountlines WHERE id=?"); |
| 166 |
$dbh->prepare( |
167 |
$sth->execute( $accountlineid ); |
| 167 |
"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?"); |
|
|
| 168 |
$sth->execute( $borrowernumber, $accountno ); |
| 169 |
my $data = $sth->fetchrow_hashref; |
168 |
my $data = $sth->fetchrow_hashref; |
| 170 |
$sth->finish; |
169 |
$sth->finish; |
| 171 |
|
170 |
my $newamountoutstanding=0; |
|
|
171 |
my $payment = 0 - $amount; |
| 172 |
$payment = 0-$data->{'amountoutstanding'}; |
| 173 |
my $finalamount = $amount; |
| 174 |
my $descriptionpayment="Payment for account n°".$accountno.",thanks - ".$user." : ".$data->{'description'}; |
| 175 |
if($partpaymentamount!=0) |
| 176 |
{ |
| 177 |
$newamountoutstanding=$data->{'amountoutstanding'}-$partpaymentamount; |
| 178 |
$payment = 0 - $partpaymentamount; |
| 179 |
$finalamount = $partpaymentamount; |
| 180 |
$descriptionpayment="Part Payment for account n°".$accountno.",thanks - ".$user." : ".$data->{'description'}; |
| 181 |
} |
| 172 |
$dbh->do( |
182 |
$dbh->do( |
| 173 |
"UPDATE accountlines |
183 |
"UPDATE accountlines |
| 174 |
SET amountoutstanding = 0 |
184 |
SET amountoutstanding = $newamountoutstanding |
| 175 |
WHERE borrowernumber = $borrowernumber |
185 |
WHERE id = $accountlineid |
| 176 |
AND accountno = $accountno |
|
|
| 177 |
" |
186 |
" |
| 178 |
); |
187 |
); |
| 179 |
|
188 |
|
| 180 |
# print $updquery; |
189 |
# print $updquery; |
| 181 |
# $dbh->do( " |
190 |
# $dbh->do( " |
| 182 |
# INSERT INTO accountoffsets |
191 |
# INSERT INTO accountoffsets |
| 183 |
# (borrowernumber, accountno, offsetaccount, |
192 |
# (borrowernumber, accountno, offsetaccount, |
| 184 |
# offsetamount) |
193 |
# offsetamount) |
| 185 |
# VALUES ($borrowernumber, $accountno, $nextaccntno, $newamtos) |
194 |
# VALUES ($borrowernumber, $accountno, $nextaccntno, $newamtos) |
| 186 |
# " ); |
195 |
# " ); |
| 187 |
|
196 |
|
| 188 |
# create new line |
197 |
# create new line |
| 189 |
my $payment = 0 - $amount; |
198 |
|
|
|
199 |
|
| 190 |
$dbh->do( " |
200 |
$dbh->do( " |
| 191 |
INSERT INTO accountlines |
201 |
INSERT INTO accountlines |
| 192 |
(borrowernumber, accountno, date, amount, |
202 |
(borrowernumber, accountno, date, time, amount, |
| 193 |
description, accounttype, amountoutstanding) |
203 |
description, accounttype, amountoutstanding, note, meansofpayment, manager_id) |
| 194 |
VALUES ($borrowernumber, $nextaccntno, now(), $payment, |
204 |
VALUES ($borrowernumber, $nextaccntno, now(), CURRENT_TIME, $payment, |
| 195 |
'Payment,thanks - $user', 'Pay', 0) |
205 |
'$descriptionpayment', 'Pay', 0, '$note', '$meansofpayment', '$manager_id') |
| 196 |
" ); |
206 |
" ); |
| 197 |
|
207 |
|
| 198 |
# FIXME - The second argument to &UpdateStats is supposed to be the |
208 |
# FIXME - The second argument to &UpdateStats is supposed to be the |
| 199 |
# branch code. |
209 |
# branch code. |
| 200 |
# UpdateStats is now being passed $accountno too. MTJ |
210 |
# UpdateStats is now being passed $accountno too. MTJ |
| 201 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, |
211 |
UpdateStats( $user, 'payment', $finalamount, '', '', '', $borrowernumber, $accountno ); |
| 202 |
$accountno ); |
|
|
| 203 |
$sth->finish; |
212 |
$sth->finish; |
| 204 |
|
213 |
|
| 205 |
#check to see what accounttype |
214 |
#check to see what accounttype |
| 206 |
if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) { |
215 |
if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) { |
| 207 |
returnlost( $borrowernumber, $data->{'itemnumber'} ); |
216 |
returnlost( $borrowernumber, $data->{'itemnumber'} ); |
| 208 |
} |
217 |
} |
|
|
218 |
|
| 219 |
my $sth = $dbh->prepare("SELECT max(id) AS lastinsertid FROM accountlines"); |
| 220 |
$sth->execute(); |
| 221 |
my $datalastinsertid = $sth->fetchrow_hashref; |
| 222 |
$sth->finish; |
| 223 |
return $datalastinsertid->{'lastinsertid'}; |
| 209 |
} |
224 |
} |
| 210 |
|
225 |
|
| 211 |
=head2 getnextacctno |
226 |
=head2 getnextacctno |
|
Lines 228-250
sub getnextacctno ($) {
Link Here
|
| 228 |
LIMIT 1" |
243 |
LIMIT 1" |
| 229 |
); |
244 |
); |
| 230 |
$sth->execute($borrowernumber); |
245 |
$sth->execute($borrowernumber); |
| 231 |
return ($sth->fetchrow || 1); |
246 |
return ( $sth->fetchrow || 1 ); |
| 232 |
} |
247 |
} |
| 233 |
|
248 |
|
| 234 |
=head2 fixaccounts (removed) |
249 |
=head2 fixaccounts (removed) |
| 235 |
|
250 |
|
| 236 |
&fixaccounts($borrowernumber, $accountnumber, $amount); |
251 |
&fixaccounts($accountlineid,$borrowernumber, $accountnumber, $amount); |
| 237 |
|
252 |
|
| 238 |
#' |
253 |
#' |
| 239 |
# FIXME - I don't understand what this function does. |
254 |
# FIXME - I don't understand what this function does. |
| 240 |
sub fixaccounts { |
255 |
sub fixaccounts { |
| 241 |
my ( $borrowernumber, $accountno, $amount ) = @_; |
256 |
my ( $accountlineid, $borrowernumber, $accountno, $amount ) = @_; |
| 242 |
my $dbh = C4::Context->dbh; |
257 |
my $dbh = C4::Context->dbh; |
| 243 |
my $sth = $dbh->prepare( |
258 |
my $sth = $dbh->prepare( |
| 244 |
"SELECT * FROM accountlines WHERE borrowernumber=? |
259 |
"SELECT * FROM accountlines WHERE id=?" |
| 245 |
AND accountno=?" |
|
|
| 246 |
); |
260 |
); |
| 247 |
$sth->execute( $borrowernumber, $accountno ); |
261 |
$sth->execute( $accountlineid ); |
| 248 |
my $data = $sth->fetchrow_hashref; |
262 |
my $data = $sth->fetchrow_hashref; |
| 249 |
|
263 |
|
| 250 |
# FIXME - Error-checking |
264 |
# FIXME - Error-checking |
|
Lines 256-325
sub fixaccounts {
Link Here
|
| 256 |
UPDATE accountlines |
270 |
UPDATE accountlines |
| 257 |
SET amount = '$amount', |
271 |
SET amount = '$amount', |
| 258 |
amountoutstanding = '$outstanding' |
272 |
amountoutstanding = '$outstanding' |
| 259 |
WHERE borrowernumber = $borrowernumber |
273 |
WHERE id = $accountlineid |
| 260 |
AND accountno = $accountno |
|
|
| 261 |
EOT |
274 |
EOT |
| 262 |
# FIXME: exceedingly bad form. Use prepare with placholders ("?") in query and execute args. |
275 |
# FIXME: exceedingly bad form. Use prepare with placholders ("?") in query and execute args. |
| 263 |
} |
276 |
} |
| 264 |
|
277 |
|
| 265 |
=cut |
278 |
=cut |
| 266 |
|
279 |
|
| 267 |
sub returnlost{ |
280 |
sub returnlost { |
| 268 |
my ( $borrowernumber, $itemnum ) = @_; |
281 |
my ( $borrowernumber, $itemnum ) = @_; |
| 269 |
C4::Circulation::MarkIssueReturned( $borrowernumber, $itemnum ); |
282 |
C4::Circulation::MarkIssueReturned( $borrowernumber, $itemnum ); |
| 270 |
my $borrower = C4::Members::GetMember( 'borrowernumber'=>$borrowernumber ); |
283 |
my $borrower = C4::Members::GetMember( 'borrowernumber' => $borrowernumber ); |
| 271 |
my @datearr = localtime(time); |
284 |
my @datearr = localtime(time); |
| 272 |
my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3]; |
285 |
my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3]; |
| 273 |
my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}"; |
286 |
my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}"; |
| 274 |
ModItem({ paidfor => "Paid for by $bor $date" }, undef, $itemnum); |
287 |
ModItem( { paidfor => "Paid for by $bor $date" }, undef, $itemnum ); |
| 275 |
} |
288 |
} |
| 276 |
|
289 |
|
|
|
290 |
sub chargelostitem { |
| 277 |
|
291 |
|
| 278 |
sub chargelostitem{ |
292 |
# lost ==1 Lost, lost==2 longoverdue, lost==3 lost and paid for |
| 279 |
# lost ==1 Lost, lost==2 longoverdue, lost==3 lost and paid for |
293 |
# FIXME: itemlost should be set to 3 after payment is made, should be a warning to the interface that |
| 280 |
# FIXME: itemlost should be set to 3 after payment is made, should be a warning to the interface that |
294 |
# a charge has been added |
| 281 |
# a charge has been added |
295 |
# FIXME : if no replacement price, borrower just doesn't get charged? |
| 282 |
# FIXME : if no replacement price, borrower just doesn't get charged? |
296 |
|
| 283 |
|
297 |
my $dbh = C4::Context->dbh(); |
| 284 |
my $dbh = C4::Context->dbh(); |
|
|
| 285 |
my ($itemnumber) = @_; |
298 |
my ($itemnumber) = @_; |
| 286 |
my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title |
299 |
my $sth = $dbh->prepare( |
|
|
300 |
"SELECT issues.*,items.*,biblio.title |
| 287 |
FROM issues |
301 |
FROM issues |
| 288 |
JOIN items USING (itemnumber) |
302 |
JOIN items USING (itemnumber) |
| 289 |
JOIN biblio USING (biblionumber) |
303 |
JOIN biblio USING (biblionumber) |
| 290 |
WHERE issues.itemnumber=?"); |
304 |
WHERE issues.itemnumber=?" |
|
|
305 |
); |
| 291 |
$sth->execute($itemnumber); |
306 |
$sth->execute($itemnumber); |
| 292 |
my $issues=$sth->fetchrow_hashref(); |
307 |
my $issues = $sth->fetchrow_hashref(); |
| 293 |
|
308 |
|
| 294 |
# if a borrower lost the item, add a replacement cost to the their record |
309 |
# if a borrower lost the item, add a replacement cost to the their record |
| 295 |
if ( $issues->{borrowernumber} ){ |
310 |
if ( $issues->{borrowernumber} ) { |
| 296 |
|
311 |
|
| 297 |
# first make sure the borrower hasn't already been charged for this item |
312 |
# first make sure the borrower hasn't already been charged for this item |
| 298 |
my $sth1=$dbh->prepare("SELECT * from accountlines |
313 |
my $sth1 = $dbh->prepare( |
| 299 |
WHERE borrowernumber=? AND itemnumber=? and accounttype='L'"); |
314 |
"SELECT * from accountlines |
| 300 |
$sth1->execute($issues->{'borrowernumber'},$itemnumber); |
315 |
WHERE borrowernumber=? AND itemnumber=? and accounttype='L'" |
| 301 |
my $existing_charge_hashref=$sth1->fetchrow_hashref(); |
316 |
); |
|
|
317 |
$sth1->execute( $issues->{'borrowernumber'}, $itemnumber ); |
| 318 |
my $existing_charge_hashref = $sth1->fetchrow_hashref(); |
| 302 |
|
319 |
|
| 303 |
# OK, they haven't |
320 |
# OK, they haven't |
| 304 |
unless ($existing_charge_hashref) { |
321 |
unless ($existing_charge_hashref) { |
|
|
322 |
|
| 305 |
# This item is on issue ... add replacement cost to the borrower's record and mark it returned |
323 |
# This item is on issue ... add replacement cost to the borrower's record and mark it returned |
| 306 |
# Note that we add this to the account even if there's no replacement price, allowing some other |
324 |
# Note that we add this to the account even if there's no replacement price, allowing some other |
| 307 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
325 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
| 308 |
my $accountno = getnextacctno($issues->{'borrowernumber'}); |
326 |
my $accountno = getnextacctno( $issues->{'borrowernumber'} ); |
| 309 |
my $sth2=$dbh->prepare("INSERT INTO accountlines |
327 |
my $sth2 = $dbh->prepare( |
| 310 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber) |
328 |
"INSERT INTO accountlines |
| 311 |
VALUES (?,?,now(),?,?,'L',?,?)"); |
329 |
(borrowernumber,accountno,date,time,amount,description,accounttype,amountoutstanding,itemnumber) |
| 312 |
$sth2->execute($issues->{'borrowernumber'},$accountno,$issues->{'replacementprice'}, |
330 |
VALUES (?,?,now(),CURRENT_TIME,?,?,'L',?,?)" |
| 313 |
"Lost Item $issues->{'title'} $issues->{'barcode'}", |
331 |
); |
| 314 |
$issues->{'replacementprice'},$itemnumber); |
332 |
$sth2->execute( |
|
|
333 |
$issues->{'borrowernumber'}, |
| 334 |
$accountno, |
| 335 |
$issues->{'replacementprice'}, |
| 336 |
"Lost Item $issues->{'title'} $issues->{'barcode'}", |
| 337 |
$issues->{'replacementprice'}, $itemnumber |
| 338 |
); |
| 315 |
$sth2->finish; |
339 |
$sth2->finish; |
| 316 |
# FIXME: Log this ? |
340 |
|
|
|
341 |
# FIXME: Log this ? |
| 317 |
} |
342 |
} |
|
|
343 |
|
| 318 |
#FIXME : Should probably have a way to distinguish this from an item that really was returned. |
344 |
#FIXME : Should probably have a way to distinguish this from an item that really was returned. |
| 319 |
warn " $issues->{'borrowernumber'} / $itemnumber "; |
345 |
warn " $issues->{'borrowernumber'} / $itemnumber "; |
| 320 |
C4::Circulation::MarkIssueReturned($issues->{borrowernumber},$itemnumber); |
346 |
C4::Circulation::MarkIssueReturned( $issues->{borrowernumber}, $itemnumber ); |
| 321 |
# Shouldn't MarkIssueReturned do this? |
347 |
|
| 322 |
C4::Items::ModItem({ onloan => undef }, undef, $itemnumber); |
348 |
# Shouldn't MarkIssueReturned do this? |
|
|
349 |
C4::Items::ModItem( { onloan => undef }, undef, $itemnumber ); |
| 323 |
} |
350 |
} |
| 324 |
$sth->finish; |
351 |
$sth->finish; |
| 325 |
} |
352 |
} |
|
Lines 327-333
sub chargelostitem{
Link Here
|
| 327 |
=head2 manualinvoice |
354 |
=head2 manualinvoice |
| 328 |
|
355 |
|
| 329 |
&manualinvoice($borrowernumber, $itemnumber, $description, $type, |
356 |
&manualinvoice($borrowernumber, $itemnumber, $description, $type, |
| 330 |
$amount, $user); |
357 |
$amount, $note, $meansofpayment); |
| 331 |
|
358 |
|
| 332 |
C<$borrowernumber> is the patron's borrower number. |
359 |
C<$borrowernumber> is the patron's borrower number. |
| 333 |
C<$description> is a description of the transaction. |
360 |
C<$description> is a description of the transaction. |
|
Lines 340-346
should be the empty string.
Link Here
|
| 340 |
|
367 |
|
| 341 |
#' |
368 |
#' |
| 342 |
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function |
369 |
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function |
| 343 |
# are : |
370 |
# are : |
| 344 |
# 'C' = CREDIT |
371 |
# 'C' = CREDIT |
| 345 |
# 'FOR' = FORGIVEN (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere) |
372 |
# 'FOR' = FORGIVEN (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere) |
| 346 |
# 'N' = New Card fee |
373 |
# 'N' = New Card fee |
|
Lines 351-357
should be the empty string.
Link Here
|
| 351 |
# |
378 |
# |
| 352 |
|
379 |
|
| 353 |
sub manualinvoice { |
380 |
sub manualinvoice { |
| 354 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $user ) = @_; |
381 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $meansofpayment ) = @_; |
|
|
382 |
my $manager_id = C4::Context->userenv->{'number'}; |
| 355 |
my $dbh = C4::Context->dbh; |
383 |
my $dbh = C4::Context->dbh; |
| 356 |
my $notifyid = 0; |
384 |
my $notifyid = 0; |
| 357 |
my $insert; |
385 |
my $insert; |
|
Lines 359-374
sub manualinvoice {
Link Here
|
| 359 |
my $accountno = getnextacctno($borrowernumber); |
387 |
my $accountno = getnextacctno($borrowernumber); |
| 360 |
my $amountleft = $amount; |
388 |
my $amountleft = $amount; |
| 361 |
|
389 |
|
| 362 |
# if ( $type eq 'CS' |
390 |
# if ( $type eq 'CS' |
| 363 |
# || $type eq 'CB' |
391 |
# || $type eq 'CB' |
| 364 |
# || $type eq 'CW' |
392 |
# || $type eq 'CW' |
| 365 |
# || $type eq 'CF' |
393 |
# || $type eq 'CF' |
| 366 |
# || $type eq 'CL' ) |
394 |
# || $type eq 'CL' ) |
| 367 |
# { |
395 |
# { |
| 368 |
# my $amount2 = $amount * -1; # FIXME - $amount2 = -$amount |
396 |
# my $amount2 = $amount * -1; # FIXME - $amount2 = -$amount |
| 369 |
# $amountleft = |
397 |
# $amountleft = |
| 370 |
# fixcredit( $borrowernumber, $amount2, $itemnum, $type, $user ); |
398 |
# fixcredit( $borrowernumber, $amount2, $itemnum, $type, $user ); |
| 371 |
# } |
399 |
# } |
| 372 |
if ( $type eq 'N' ) { |
400 |
if ( $type eq 'N' ) { |
| 373 |
$desc .= " New Card"; |
401 |
$desc .= " New Card"; |
| 374 |
} |
402 |
} |
|
Lines 386-401
sub manualinvoice {
Link Here
|
| 386 |
|
414 |
|
| 387 |
$desc = " Lost Item"; |
415 |
$desc = " Lost Item"; |
| 388 |
} |
416 |
} |
| 389 |
# if ( $type eq 'REF' ) { |
417 |
|
| 390 |
# $desc .= " Cash Refund"; |
418 |
# if ( $type eq 'REF' ) { |
| 391 |
# $amountleft = refund( '', $borrowernumber, $amount ); |
419 |
# $desc .= " Cash Refund"; |
| 392 |
# } |
420 |
# $amountleft = refund( '', $borrowernumber, $amount ); |
|
|
421 |
# } |
| 393 |
if ( ( $type eq 'L' ) |
422 |
if ( ( $type eq 'L' ) |
| 394 |
or ( $type eq 'F' ) |
423 |
or ( $type eq 'F' ) |
| 395 |
or ( $type eq 'A' ) |
424 |
or ( $type eq 'A' ) |
| 396 |
or ( $type eq 'N' ) |
425 |
or ( $type eq 'N' ) |
| 397 |
or ( $type eq 'M' ) ) |
426 |
or ( $type eq 'M' ) ) { |
| 398 |
{ |
|
|
| 399 |
$notifyid = 1; |
427 |
$notifyid = 1; |
| 400 |
} |
428 |
} |
| 401 |
|
429 |
|
|
Lines 403-418
sub manualinvoice {
Link Here
|
| 403 |
$desc .= " " . $itemnum; |
431 |
$desc .= " " . $itemnum; |
| 404 |
my $sth = $dbh->prepare( |
432 |
my $sth = $dbh->prepare( |
| 405 |
"INSERT INTO accountlines |
433 |
"INSERT INTO accountlines |
| 406 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id) |
434 |
(borrowernumber, accountno, date, time, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, meansofpayment) |
| 407 |
VALUES (?, ?, now(), ?,?, ?,?,?,?)"); |
435 |
VALUES (?, ?, now(),CURRENT_TIME, ?,?, ?,?,?,?,?,?,?)" |
| 408 |
$sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid) || return $sth->errstr; |
436 |
); |
| 409 |
} else { |
437 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum, $notifyid, $note, $manager_id, $meansofpayment ) || return $sth->errstr; |
| 410 |
my $sth=$dbh->prepare("INSERT INTO accountlines |
438 |
} else { |
| 411 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id) |
439 |
my $sth = $dbh->prepare( |
| 412 |
VALUES (?, ?, now(), ?, ?, ?, ?,?)" |
440 |
"INSERT INTO accountlines |
|
|
441 |
(borrowernumber, accountno, date, time, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, meansofpayment) |
| 442 |
VALUES (?, ?, now(),CURRENT_TIME, ?, ?, ?, ?,?,?,?,?)" |
| 413 |
); |
443 |
); |
| 414 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, |
444 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $notifyid, $note, $manager_id, $meansofpayment ); |
| 415 |
$amountleft, $notifyid ); |
|
|
| 416 |
} |
445 |
} |
| 417 |
return 0; |
446 |
return 0; |
| 418 |
} |
447 |
} |
|
Lines 442-453
sub fixcredit {
Link Here
|
| 442 |
AND itemnumber=? AND amountoutstanding > 0)"; |
471 |
AND itemnumber=? AND amountoutstanding > 0)"; |
| 443 |
if ( $type eq 'CL' ) { |
472 |
if ( $type eq 'CL' ) { |
| 444 |
$query .= " AND (accounttype = 'L' OR accounttype = 'Rep')"; |
473 |
$query .= " AND (accounttype = 'L' OR accounttype = 'Rep')"; |
| 445 |
} |
474 |
} elsif ( $type eq 'CF' ) { |
| 446 |
elsif ( $type eq 'CF' ) { |
|
|
| 447 |
$query .= " AND (accounttype = 'F' OR accounttype = 'FU' OR |
475 |
$query .= " AND (accounttype = 'F' OR accounttype = 'FU' OR |
| 448 |
accounttype='Res' OR accounttype='Rent')"; |
476 |
accounttype='Res' OR accounttype='Rent')"; |
| 449 |
} |
477 |
} elsif ( $type eq 'CB' ) { |
| 450 |
elsif ( $type eq 'CB' ) { |
|
|
| 451 |
$query .= " and accounttype='A'"; |
478 |
$query .= " and accounttype='A'"; |
| 452 |
} |
479 |
} |
| 453 |
|
480 |
|
|
Lines 459-483
sub fixcredit {
Link Here
|
| 459 |
if ( $accdata->{'amountoutstanding'} < $amountleft ) { |
486 |
if ( $accdata->{'amountoutstanding'} < $amountleft ) { |
| 460 |
$newamtos = 0; |
487 |
$newamtos = 0; |
| 461 |
$amountleft -= $accdata->{'amountoutstanding'}; |
488 |
$amountleft -= $accdata->{'amountoutstanding'}; |
| 462 |
} |
489 |
} else { |
| 463 |
else { |
|
|
| 464 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
490 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
| 465 |
$amountleft = 0; |
491 |
$amountleft = 0; |
| 466 |
} |
492 |
} |
| 467 |
my $thisacct = $accdata->{accountno}; |
493 |
my $thisacct = $accdata->{id}; |
| 468 |
my $usth = $dbh->prepare( |
494 |
my $usth = $dbh->prepare( |
| 469 |
"UPDATE accountlines SET amountoutstanding= ? |
495 |
"UPDATE accountlines SET amountoutstanding= ? |
| 470 |
WHERE (borrowernumber = ?) AND (accountno=?)" |
496 |
WHERE (id = ?)" |
| 471 |
); |
497 |
); |
| 472 |
$usth->execute( $newamtos, $borrowernumber, $thisacct ); |
498 |
$usth->execute( $newamtos, $thisacct ); |
| 473 |
$usth->finish; |
499 |
$usth->finish; |
| 474 |
$usth = $dbh->prepare( |
500 |
$usth = $dbh->prepare( |
| 475 |
"INSERT INTO accountoffsets |
501 |
"INSERT INTO accountoffsets |
| 476 |
(borrowernumber, accountno, offsetaccount, offsetamount) |
502 |
(borrowernumber, accountno, offsetaccount, offsetamount) |
| 477 |
VALUES (?,?,?,?)" |
503 |
VALUES (?,?,?,?)" |
| 478 |
); |
504 |
); |
| 479 |
$usth->execute( $borrowernumber, $accdata->{'accountno'}, |
505 |
$usth->execute( $borrowernumber, $accdata->{'accountno'}, $nextaccntno, $newamtos ); |
| 480 |
$nextaccntno, $newamtos ); |
|
|
| 481 |
$usth->finish; |
506 |
$usth->finish; |
| 482 |
} |
507 |
} |
| 483 |
|
508 |
|
|
Lines 498-522
sub fixcredit {
Link Here
|
| 498 |
if ( $accdata->{'amountoutstanding'} < $amountleft ) { |
523 |
if ( $accdata->{'amountoutstanding'} < $amountleft ) { |
| 499 |
$newamtos = 0; |
524 |
$newamtos = 0; |
| 500 |
$amountleft -= $accdata->{'amountoutstanding'}; |
525 |
$amountleft -= $accdata->{'amountoutstanding'}; |
| 501 |
} |
526 |
} else { |
| 502 |
else { |
|
|
| 503 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
527 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
| 504 |
$amountleft = 0; |
528 |
$amountleft = 0; |
| 505 |
} |
529 |
} |
| 506 |
my $thisacct = $accdata->{accountno}; |
530 |
my $thisacct = $accdata->{id}; |
| 507 |
my $usth = $dbh->prepare( |
531 |
my $usth = $dbh->prepare( |
| 508 |
"UPDATE accountlines SET amountoutstanding= ? |
532 |
"UPDATE accountlines SET amountoutstanding= ? |
| 509 |
WHERE (borrowernumber = ?) AND (accountno=?)" |
533 |
WHERE (id = ?)" |
| 510 |
); |
534 |
); |
| 511 |
$usth->execute( $newamtos, $borrowernumber, $thisacct ); |
535 |
$usth->execute( $newamtos, $thisacct ); |
| 512 |
$usth->finish; |
536 |
$usth->finish; |
| 513 |
$usth = $dbh->prepare( |
537 |
$usth = $dbh->prepare( |
| 514 |
"INSERT INTO accountoffsets |
538 |
"INSERT INTO accountoffsets |
| 515 |
(borrowernumber, accountno, offsetaccount, offsetamount) |
539 |
(borrowernumber, accountno, offsetaccount, offsetamount) |
| 516 |
VALUE (?,?,?,?)" |
540 |
VALUE (?,?,?,?)" |
| 517 |
); |
541 |
); |
| 518 |
$usth->execute( $borrowernumber, $accdata->{'accountno'}, |
542 |
$usth->execute( $borrowernumber, $accdata->{'accountno'}, $nextaccntno, $newamtos ); |
| 519 |
$nextaccntno, $newamtos ); |
|
|
| 520 |
$usth->finish; |
543 |
$usth->finish; |
| 521 |
} |
544 |
} |
| 522 |
$sth->finish; |
545 |
$sth->finish; |
|
Lines 562-588
sub refund {
Link Here
|
| 562 |
if ( $accdata->{'amountoutstanding'} > $amountleft ) { |
585 |
if ( $accdata->{'amountoutstanding'} > $amountleft ) { |
| 563 |
$newamtos = 0; |
586 |
$newamtos = 0; |
| 564 |
$amountleft -= $accdata->{'amountoutstanding'}; |
587 |
$amountleft -= $accdata->{'amountoutstanding'}; |
| 565 |
} |
588 |
} else { |
| 566 |
else { |
|
|
| 567 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
589 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
| 568 |
$amountleft = 0; |
590 |
$amountleft = 0; |
| 569 |
} |
591 |
} |
| 570 |
|
592 |
|
| 571 |
# print $amountleft; |
593 |
# print $amountleft; |
| 572 |
my $thisacct = $accdata->{accountno}; |
594 |
my $thisacct = $accdata->{id}; |
| 573 |
my $usth = $dbh->prepare( |
595 |
my $usth = $dbh->prepare( |
| 574 |
"UPDATE accountlines SET amountoutstanding= ? |
596 |
"UPDATE accountlines SET amountoutstanding= ? |
| 575 |
WHERE (borrowernumber = ?) AND (accountno=?)" |
597 |
WHERE (id = ?)" |
| 576 |
); |
598 |
); |
| 577 |
$usth->execute( $newamtos, $borrowernumber, $thisacct ); |
599 |
$usth->execute( $newamtos, $thisacct ); |
| 578 |
$usth->finish; |
600 |
$usth->finish; |
| 579 |
$usth = $dbh->prepare( |
601 |
$usth = $dbh->prepare( |
| 580 |
"INSERT INTO accountoffsets |
602 |
"INSERT INTO accountoffsets |
| 581 |
(borrowernumber, accountno, offsetaccount, offsetamount) |
603 |
(borrowernumber, accountno, offsetaccount, offsetamount) |
| 582 |
VALUES (?,?,?,?)" |
604 |
VALUES (?,?,?,?)" |
| 583 |
); |
605 |
); |
| 584 |
$usth->execute( $borrowernumber, $accdata->{'accountno'}, |
606 |
$usth->execute( $borrowernumber, $accdata->{'accountno'}, $nextaccntno, $newamtos ); |
| 585 |
$nextaccntno, $newamtos ); |
|
|
| 586 |
$usth->finish; |
607 |
$usth->finish; |
| 587 |
} |
608 |
} |
| 588 |
$sth->finish; |
609 |
$sth->finish; |
|
Lines 590-637
sub refund {
Link Here
|
| 590 |
} |
611 |
} |
| 591 |
|
612 |
|
| 592 |
sub getcharges { |
613 |
sub getcharges { |
| 593 |
my ( $borrowerno, $timestamp, $accountno ) = @_; |
614 |
my ( $borrowerno, $timestamp, $accountno ) = @_; |
| 594 |
my $dbh = C4::Context->dbh; |
615 |
my $dbh = C4::Context->dbh; |
| 595 |
my $timestamp2 = $timestamp - 1; |
616 |
my $timestamp2 = $timestamp - 1; |
| 596 |
my $query = ""; |
617 |
my $query = ""; |
| 597 |
my $sth = $dbh->prepare( |
618 |
my $sth = $dbh->prepare( "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" ); |
| 598 |
"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" |
619 |
$sth->execute( $borrowerno, $accountno ); |
| 599 |
); |
620 |
|
| 600 |
$sth->execute( $borrowerno, $accountno ); |
|
|
| 601 |
|
| 602 |
my @results; |
621 |
my @results; |
| 603 |
while ( my $data = $sth->fetchrow_hashref ) { |
622 |
while ( my $data = $sth->fetchrow_hashref ) { |
| 604 |
push @results,$data; |
623 |
push @results, $data; |
| 605 |
} |
624 |
} |
| 606 |
return (@results); |
625 |
return (@results); |
| 607 |
} |
626 |
} |
| 608 |
|
627 |
|
|
|
628 |
sub ModNote { |
| 629 |
my ( $accountlineid, $note ) = @_; |
| 630 |
my $dbh = C4::Context->dbh; |
| 631 |
my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE id = ?'); |
| 632 |
$sth->execute( $note, $accountlineid ); |
| 633 |
} |
| 634 |
|
| 635 |
sub ModMeansOfPayment { |
| 636 |
my ( $accountlineid, $meansofpayment ) = @_; |
| 637 |
my $dbh = C4::Context->dbh; |
| 638 |
my $sth = $dbh->prepare('UPDATE accountlines SET meansofpayment = ? WHERE id = ?'); |
| 639 |
$sth->execute( $meansofpayment, $accountlineid ); |
| 640 |
} |
| 641 |
|
| 642 |
sub ModManagerId { |
| 643 |
my ( $accountlineid, $manager_id ) = @_; |
| 644 |
my $dbh = C4::Context->dbh; |
| 645 |
my $sth = $dbh->prepare('UPDATE accountlines SET manager_id = ? WHERE id = ?'); |
| 646 |
$sth->execute( $manager_id, $accountlineid ); |
| 647 |
} |
| 648 |
|
| 649 |
sub getMeansOfPaymentList { |
| 650 |
my ($selectedoption) = @_; |
| 651 |
my $dbh = C4::Context->dbh; |
| 652 |
my $sth = $dbh->prepare( "SELECT * FROM `systempreferences` WHERE variable='MeansOfPayment'" ); |
| 653 |
$sth->execute(); |
| 654 |
my @options; |
| 655 |
my $booloption=0; |
| 656 |
while ( my $data = $sth->fetchrow_hashref ) { |
| 657 |
foreach my $option ( split( /\|/, $data->{'value'} ) ) { |
| 658 |
my $selected = ''; |
| 659 |
if($option eq $selectedoption) |
| 660 |
{ |
| 661 |
$selected = ' selected="selected"'; |
| 662 |
$booloption=1; |
| 663 |
} |
| 664 |
push @options, { option => $option, selected => $selected }; |
| 665 |
} |
| 666 |
} |
| 667 |
if($booloption==0 && $selectedoption ne "") |
| 668 |
{ |
| 669 |
push @options, { option => $selectedoption, selected => ' selected="selected"' }; |
| 670 |
} |
| 671 |
$sth->finish; |
| 672 |
return \@options; |
| 673 |
} |
| 609 |
|
674 |
|
| 610 |
sub getcredits { |
675 |
sub getcredits { |
| 611 |
my ( $date, $date2 ) = @_; |
676 |
my ( $date, $date2 ) = @_; |
| 612 |
my $dbh = C4::Context->dbh; |
677 |
my $dbh = C4::Context->dbh; |
| 613 |
my $sth = $dbh->prepare( |
678 |
my $sth = $dbh->prepare( |
| 614 |
"SELECT * FROM accountlines,borrowers |
679 |
"SELECT * FROM accountlines,borrowers |
| 615 |
WHERE amount < 0 AND accounttype <> 'Pay' AND accountlines.borrowernumber = borrowers.borrowernumber |
680 |
WHERE amount < 0 AND accounttype <> 'Pay' AND accountlines.borrowernumber = borrowers.borrowernumber |
| 616 |
AND timestamp >=TIMESTAMP(?) AND timestamp < TIMESTAMP(?)" |
681 |
AND timestamp >=TIMESTAMP(?) AND timestamp < TIMESTAMP(?)" |
| 617 |
); |
682 |
); |
| 618 |
|
683 |
|
| 619 |
$sth->execute( $date, $date2 ); |
684 |
$sth->execute( $date, $date2 ); |
| 620 |
my @results; |
685 |
my @results; |
| 621 |
while ( my $data = $sth->fetchrow_hashref ) { |
686 |
while ( my $data = $sth->fetchrow_hashref ) { |
| 622 |
$data->{'date'} = $data->{'timestamp'}; |
687 |
$data->{'date'} = $data->{'timestamp'}; |
| 623 |
push @results,$data; |
688 |
push @results, $data; |
| 624 |
} |
689 |
} |
| 625 |
return (@results); |
690 |
return (@results); |
| 626 |
} |
691 |
} |
| 627 |
|
|
|
| 628 |
|
692 |
|
| 629 |
sub getrefunds { |
693 |
sub getrefunds { |
| 630 |
my ( $date, $date2 ) = @_; |
694 |
my ( $date, $date2 ) = @_; |
| 631 |
my $dbh = C4::Context->dbh; |
695 |
my $dbh = C4::Context->dbh; |
| 632 |
|
696 |
|
| 633 |
my $sth = $dbh->prepare( |
697 |
my $sth = $dbh->prepare( |
| 634 |
"SELECT *,timestamp AS datetime |
698 |
"SELECT *,timestamp AS datetime |
| 635 |
FROM accountlines,borrowers |
699 |
FROM accountlines,borrowers |
| 636 |
WHERE (accounttype = 'REF' |
700 |
WHERE (accounttype = 'REF' |
| 637 |
AND accountlines.borrowernumber = borrowers.borrowernumber |
701 |
AND accountlines.borrowernumber = borrowers.borrowernumber |
|
Lines 642-669
sub getrefunds {
Link Here
|
| 642 |
|
706 |
|
| 643 |
my @results; |
707 |
my @results; |
| 644 |
while ( my $data = $sth->fetchrow_hashref ) { |
708 |
while ( my $data = $sth->fetchrow_hashref ) { |
| 645 |
push @results,$data; |
709 |
push @results, $data; |
| 646 |
|
710 |
|
| 647 |
} |
711 |
} |
| 648 |
return (@results); |
712 |
return (@results); |
| 649 |
} |
713 |
} |
| 650 |
|
714 |
|
| 651 |
sub ReversePayment { |
715 |
sub ReversePayment { |
| 652 |
my ( $borrowernumber, $accountno ) = @_; |
716 |
my ( $accountlineid ) = @_; |
| 653 |
my $dbh = C4::Context->dbh; |
717 |
my $dbh = C4::Context->dbh; |
| 654 |
|
718 |
|
| 655 |
my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE borrowernumber = ? AND accountno = ?'); |
719 |
my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE id = ?'); |
| 656 |
$sth->execute( $borrowernumber, $accountno ); |
720 |
$sth->execute( $accountlineid ); |
| 657 |
my $row = $sth->fetchrow_hashref(); |
721 |
my $row = $sth->fetchrow_hashref(); |
| 658 |
my $amount_outstanding = $row->{'amountoutstanding'}; |
722 |
my $amount_outstanding = $row->{'amountoutstanding'}; |
| 659 |
|
723 |
|
| 660 |
if ( $amount_outstanding <= 0 ) { |
724 |
if ( $amount_outstanding <= 0 ) { |
| 661 |
$sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?'); |
725 |
$sth = |
| 662 |
$sth->execute( $borrowernumber, $accountno ); |
726 |
$dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE id = ?'); |
| 663 |
} else { |
727 |
$sth->execute( $accountlineid ); |
| 664 |
$sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?'); |
728 |
} else { |
| 665 |
$sth->execute( $borrowernumber, $accountno ); |
729 |
$sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE id = ?'); |
| 666 |
} |
730 |
$sth->execute( $accountlineid ); |
|
|
731 |
} |
| 667 |
} |
732 |
} |
| 668 |
|
733 |
|
| 669 |
END { } # module clean-up code here (global destructor) |
734 |
END { } # module clean-up code here (global destructor) |