Lines 38-44
BEGIN {
Link Here
|
38 |
@ISA = qw(Exporter); |
38 |
@ISA = qw(Exporter); |
39 |
@EXPORT = qw( |
39 |
@EXPORT = qw( |
40 |
&manualinvoice |
40 |
&manualinvoice |
41 |
&getnextacctno |
|
|
42 |
&chargelostitem |
41 |
&chargelostitem |
43 |
&ReversePayment |
42 |
&ReversePayment |
44 |
&purge_zero_balance_fees |
43 |
&purge_zero_balance_fees |
Lines 61-89
patron.
Link Here
|
61 |
|
60 |
|
62 |
=head1 FUNCTIONS |
61 |
=head1 FUNCTIONS |
63 |
|
62 |
|
64 |
=head2 getnextacctno |
|
|
65 |
|
66 |
$nextacct = &getnextacctno($borrowernumber); |
67 |
|
68 |
Returns the next unused account number for the patron with the given |
69 |
borrower number. |
70 |
|
71 |
=cut |
72 |
|
73 |
#' |
74 |
# FIXME - Okay, so what does the above actually _mean_? |
75 |
sub getnextacctno { |
76 |
my ($borrowernumber) = shift or return; |
77 |
my $sth = C4::Context->dbh->prepare( |
78 |
"SELECT accountno+1 FROM accountlines |
79 |
WHERE (borrowernumber = ?) |
80 |
ORDER BY accountno DESC |
81 |
LIMIT 1" |
82 |
); |
83 |
$sth->execute($borrowernumber); |
84 |
return ($sth->fetchrow || 1); |
85 |
} |
86 |
|
87 |
=head2 chargelostitem |
63 |
=head2 chargelostitem |
88 |
|
64 |
|
89 |
In a default install of Koha the following lost values are set |
65 |
In a default install of Koha the following lost values are set |
Lines 129-135
sub chargelostitem{
Link Here
|
129 |
my $accountline = Koha::Account::Line->new( |
105 |
my $accountline = Koha::Account::Line->new( |
130 |
{ |
106 |
{ |
131 |
borrowernumber => $borrowernumber, |
107 |
borrowernumber => $borrowernumber, |
132 |
accountno => getnextacctno($borrowernumber), |
|
|
133 |
date => \'NOW()', |
108 |
date => \'NOW()', |
134 |
amount => $processfee, |
109 |
amount => $processfee, |
135 |
description => $description, |
110 |
description => $description, |
Lines 154-160
sub chargelostitem{
Link Here
|
154 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
129 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
155 |
action => 'create_fee', |
130 |
action => 'create_fee', |
156 |
borrowernumber => $accountline->borrowernumber,, |
131 |
borrowernumber => $accountline->borrowernumber,, |
157 |
accountno => $accountline->accountno, |
|
|
158 |
amount => $accountline->amount, |
132 |
amount => $accountline->amount, |
159 |
description => $accountline->description, |
133 |
description => $accountline->description, |
160 |
accounttype => $accountline->accounttype, |
134 |
accounttype => $accountline->accounttype, |
Lines 170-176
sub chargelostitem{
Link Here
|
170 |
my $accountline = Koha::Account::Line->new( |
144 |
my $accountline = Koha::Account::Line->new( |
171 |
{ |
145 |
{ |
172 |
borrowernumber => $borrowernumber, |
146 |
borrowernumber => $borrowernumber, |
173 |
accountno => getnextacctno($borrowernumber), |
|
|
174 |
date => \'NOW()', |
147 |
date => \'NOW()', |
175 |
amount => $replacementprice, |
148 |
amount => $replacementprice, |
176 |
description => $description, |
149 |
description => $description, |
Lines 194-200
sub chargelostitem{
Link Here
|
194 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
167 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
195 |
action => 'create_fee', |
168 |
action => 'create_fee', |
196 |
borrowernumber => $accountline->borrowernumber,, |
169 |
borrowernumber => $accountline->borrowernumber,, |
197 |
accountno => $accountline->accountno, |
|
|
198 |
amount => $accountline->amount, |
170 |
amount => $accountline->amount, |
199 |
description => $accountline->description, |
171 |
description => $accountline->description, |
200 |
accounttype => $accountline->accounttype, |
172 |
accounttype => $accountline->accounttype, |
Lines 240-246
sub manualinvoice {
Link Here
|
240 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
212 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
241 |
my $dbh = C4::Context->dbh; |
213 |
my $dbh = C4::Context->dbh; |
242 |
my $insert; |
214 |
my $insert; |
243 |
my $accountno = getnextacctno($borrowernumber); |
|
|
244 |
my $amountleft = $amount; |
215 |
my $amountleft = $amount; |
245 |
|
216 |
|
246 |
my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
217 |
my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
Lines 248-254
sub manualinvoice {
Link Here
|
248 |
my $accountline = Koha::Account::Line->new( |
219 |
my $accountline = Koha::Account::Line->new( |
249 |
{ |
220 |
{ |
250 |
borrowernumber => $borrowernumber, |
221 |
borrowernumber => $borrowernumber, |
251 |
accountno => $accountno, |
|
|
252 |
date => \'NOW()', |
222 |
date => \'NOW()', |
253 |
amount => $amount, |
223 |
amount => $amount, |
254 |
description => $desc, |
224 |
description => $desc, |
Lines 273-279
sub manualinvoice {
Link Here
|
273 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
243 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
274 |
action => 'create_fee', |
244 |
action => 'create_fee', |
275 |
borrowernumber => $borrowernumber, |
245 |
borrowernumber => $borrowernumber, |
276 |
accountno => $accountno, |
|
|
277 |
amount => $amount, |
246 |
amount => $amount, |
278 |
description => $desc, |
247 |
description => $desc, |
279 |
accounttype => $type, |
248 |
accounttype => $type, |
Lines 325-331
sub ReversePayment {
Link Here
|
325 |
new_amountoutstanding => $new_amountoutstanding, |
294 |
new_amountoutstanding => $new_amountoutstanding, |
326 |
, |
295 |
, |
327 |
accountlines_id => $accountline->id, |
296 |
accountlines_id => $accountline->id, |
328 |
accountno => $accountline->accountno, |
|
|
329 |
manager_id => $manager_id, |
297 |
manager_id => $manager_id, |
330 |
} |
298 |
} |
331 |
) |
299 |
) |