Lines 24-29
use C4::Context;
Link Here
|
24 |
use C4::Stats; |
24 |
use C4::Stats; |
25 |
use C4::Members; |
25 |
use C4::Members; |
26 |
use C4::Circulation qw(ReturnLostItem); |
26 |
use C4::Circulation qw(ReturnLostItem); |
|
|
27 |
use C4::Log qw(logaction); |
28 |
|
29 |
use Data::Dumper qw(Dumper); |
27 |
|
30 |
|
28 |
use vars qw($VERSION @ISA @EXPORT); |
31 |
use vars qw($VERSION @ISA @EXPORT); |
29 |
|
32 |
|
Lines 100-107
sub recordpayment {
Link Here
|
100 |
# get lines with outstanding amounts to offset |
103 |
# get lines with outstanding amounts to offset |
101 |
my $sth = $dbh->prepare( |
104 |
my $sth = $dbh->prepare( |
102 |
"SELECT * FROM accountlines |
105 |
"SELECT * FROM accountlines |
103 |
WHERE (borrowernumber = ?) AND (amountoutstanding<>0) |
106 |
WHERE (borrowernumber = ?) AND (amountoutstanding<>0) |
104 |
ORDER BY date" |
107 |
ORDER BY date" |
105 |
); |
108 |
); |
106 |
$sth->execute($borrowernumber); |
109 |
$sth->execute($borrowernumber); |
107 |
|
110 |
|
Lines 118-147
sub recordpayment {
Link Here
|
118 |
my $thisacct = $accdata->{accountlines_id}; |
121 |
my $thisacct = $accdata->{accountlines_id}; |
119 |
my $usth = $dbh->prepare( |
122 |
my $usth = $dbh->prepare( |
120 |
"UPDATE accountlines SET amountoutstanding= ? |
123 |
"UPDATE accountlines SET amountoutstanding= ? |
121 |
WHERE (accountlines_id = ?)" |
124 |
WHERE (accountlines_id = ?)" |
122 |
); |
125 |
); |
123 |
$usth->execute( $newamtos, $thisacct ); |
126 |
$usth->execute( $newamtos, $thisacct ); |
124 |
$usth->finish; |
127 |
|
125 |
# $usth = $dbh->prepare( |
128 |
if ( C4::Context->preference("FinesLog") ) { |
126 |
# "INSERT INTO accountoffsets |
129 |
$accdata->{'amountoutstanding_new'} = $newamtos; |
127 |
# (borrowernumber, accountno, offsetaccount, offsetamount) |
130 |
logaction("FINES", 'MODIFY',$borrowernumber,Dumper( $accdata )); |
128 |
# VALUES (?,?,?,?)" |
131 |
} |
129 |
# ); |
|
|
130 |
# $usth->execute( $borrowernumber, $accdata->{'accountno'}, |
131 |
# $nextaccntno, $newamtos ); |
132 |
$usth->finish; |
133 |
} |
132 |
} |
134 |
|
133 |
|
135 |
# create new line |
134 |
# create new line |
136 |
my $usth = $dbh->prepare( |
135 |
my $usth = $dbh->prepare( |
137 |
"INSERT INTO accountlines |
136 |
"INSERT INTO accountlines |
138 |
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id) |
137 |
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id) |
139 |
VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?)" |
138 |
VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?)" |
140 |
); |
139 |
); |
141 |
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft, $manager_id ); |
140 |
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft, $manager_id ); |
142 |
$usth->finish; |
141 |
|
143 |
UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno ); |
142 |
UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno ); |
144 |
$sth->finish; |
143 |
|
|
|
144 |
if ( C4::Context->preference("FinesLog") ) { |
145 |
$accdata->{'amountoutstanding_new'} = $newamtos; |
146 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
147 |
accountno => $nextaccntno, |
148 |
amount => $data * -1, |
149 |
amountleft => $amountleft * -1, |
150 |
accounttype => 'Pay', |
151 |
})); |
152 |
} |
153 |
|
145 |
} |
154 |
} |
146 |
|
155 |
|
147 |
=head2 makepayment |
156 |
=head2 makepayment |
Lines 180-186
sub makepayment {
Link Here
|
180 |
my $data = $sth->fetchrow_hashref; |
189 |
my $data = $sth->fetchrow_hashref; |
181 |
$sth->finish; |
190 |
$sth->finish; |
182 |
|
191 |
|
183 |
if($data->{'accounttype'} eq "Pay"){ |
192 |
my $payment; |
|
|
193 |
if ( $data->{'accounttype'} eq "Pay" ){ |
184 |
my $udp = |
194 |
my $udp = |
185 |
$dbh->prepare( |
195 |
$dbh->prepare( |
186 |
"UPDATE accountlines |
196 |
"UPDATE accountlines |
Lines 190-196
sub makepayment {
Link Here
|
190 |
); |
200 |
); |
191 |
$udp->execute($accountlines_id); |
201 |
$udp->execute($accountlines_id); |
192 |
$udp->finish; |
202 |
$udp->finish; |
193 |
}else{ |
203 |
} else { |
194 |
my $udp = |
204 |
my $udp = |
195 |
$dbh->prepare( |
205 |
$dbh->prepare( |
196 |
"UPDATE accountlines |
206 |
"UPDATE accountlines |
Lines 201-208
sub makepayment {
Link Here
|
201 |
$udp->execute($accountlines_id); |
211 |
$udp->execute($accountlines_id); |
202 |
$udp->finish; |
212 |
$udp->finish; |
203 |
|
213 |
|
204 |
# create new line |
214 |
# create new line |
205 |
my $payment = 0 - $amount; |
215 |
$payment = 0 - $amount; |
206 |
|
216 |
|
207 |
my $ins = |
217 |
my $ins = |
208 |
$dbh->prepare( |
218 |
$dbh->prepare( |
Lines 214-225
sub makepayment {
Link Here
|
214 |
$ins->finish; |
224 |
$ins->finish; |
215 |
} |
225 |
} |
216 |
|
226 |
|
|
|
227 |
if ( C4::Context->preference("FinesLog") ) { |
228 |
$data->{'amountoutstanding_new'} = '0'; |
229 |
logaction("FINES", 'MODIFY', $borrowernumber, Dumper( $data )); |
230 |
|
231 |
logaction("FINES", 'CREATE', $borrowernumber, Dumper({ |
232 |
accountno => $nextaccntno, |
233 |
amount => $payment, |
234 |
amountoutstanding => '0', |
235 |
accounttype => 'Pay', |
236 |
})); |
237 |
} |
238 |
|
239 |
|
217 |
# FIXME - The second argument to &UpdateStats is supposed to be the |
240 |
# FIXME - The second argument to &UpdateStats is supposed to be the |
218 |
# branch code. |
241 |
# branch code. |
219 |
# UpdateStats is now being passed $accountno too. MTJ |
242 |
# UpdateStats is now being passed $accountno too. MTJ |
220 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, |
243 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, |
221 |
$accountno ); |
244 |
$accountno ); |
222 |
#from perldoc: for SELECT only #$sth->finish; |
|
|
223 |
|
245 |
|
224 |
#check to see what accounttype |
246 |
#check to see what accounttype |
225 |
if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) { |
247 |
if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) { |
Lines 314-320
sub chargelostitem{
Link Here
|
314 |
$sth2->execute($borrowernumber,$accountno,$amount, |
336 |
$sth2->execute($borrowernumber,$accountno,$amount, |
315 |
$description,$amount,$itemnumber,$manager_id); |
337 |
$description,$amount,$itemnumber,$manager_id); |
316 |
$sth2->finish; |
338 |
$sth2->finish; |
317 |
# FIXME: Log this ? |
339 |
|
|
|
340 |
if ( C4::Context->preference("FinesLog") ) { |
341 |
logaction("FINES", 'CREATE', $borrowernumber, Dumper({ |
342 |
borrowernumber => $borrowernumber, |
343 |
accountno => $accountno, |
344 |
amount => $amount, |
345 |
description => $description, |
346 |
accounttype => 'L', |
347 |
amountoutstanding => $amount, |
348 |
itemnumber => $itemnumber, |
349 |
})); |
350 |
} |
351 |
|
318 |
} |
352 |
} |
319 |
} |
353 |
} |
320 |
|
354 |
|
Lines 396-414
sub manualinvoice {
Link Here
|
396 |
|
430 |
|
397 |
if ( $itemnum ) { |
431 |
if ( $itemnum ) { |
398 |
$desc .= ' ' . $itemnum; |
432 |
$desc .= ' ' . $itemnum; |
399 |
my $sth = $dbh->prepare( |
433 |
my $sth = $dbh->prepare(" |
400 |
'INSERT INTO accountlines |
434 |
INSERT INTO accountlines |
401 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id) |
435 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id) |
402 |
VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)'); |
436 |
VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?) |
403 |
$sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr; |
437 |
"); |
404 |
} else { |
438 |
$sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr; |
405 |
my $sth=$dbh->prepare("INSERT INTO accountlines |
439 |
} else { |
|
|
440 |
my $sth=$dbh->prepare(" |
441 |
INSERT INTO accountlines |
406 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id) |
442 |
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id) |
407 |
VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)" |
443 |
VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?) |
408 |
); |
444 |
"); |
409 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, |
445 |
$sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $notifyid, $note, $manager_id ); |
410 |
$amountleft, $notifyid, $note, $manager_id ); |
|
|
411 |
} |
446 |
} |
|
|
447 |
|
448 |
if ( C4::Context->preference("FinesLog") ) { |
449 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
450 |
accountno => $accountno, |
451 |
amount => $amount, |
452 |
description => $desc, |
453 |
accounttype => $type, |
454 |
amountoutstanding => $amountleft, |
455 |
notify_id => $notifyid, |
456 |
note => $note, |
457 |
itemnumber => $itemnum |
458 |
})); |
459 |
} |
460 |
|
412 |
return 0; |
461 |
return 0; |
413 |
} |
462 |
} |
414 |
|
463 |
|
Lines 665-670
sub ReversePayment {
Link Here
|
665 |
$sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE accountlines_id = ?'); |
714 |
$sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE accountlines_id = ?'); |
666 |
$sth->execute( $accountlines_id ); |
715 |
$sth->execute( $accountlines_id ); |
667 |
} |
716 |
} |
|
|
717 |
|
718 |
if ( C4::Context->preference("FinesLog") ) { |
719 |
if ( $amount_outstanding <= 0 ) { |
720 |
$row->{'amountoutstanding'} *= -1; |
721 |
} else { |
722 |
$row->{'amountoutstanding'} = '0'; |
723 |
} |
724 |
$row->{'description'} .= ' Reversed -'; |
725 |
logaction("FINES", 'MODIFY', undef, Dumper($row)); |
726 |
} |
727 |
|
668 |
} |
728 |
} |
669 |
|
729 |
|
670 |
=head2 recordpayment_selectaccts |
730 |
=head2 recordpayment_selectaccts |
Lines 707-714
sub recordpayment_selectaccts {
Link Here
|
707 |
my $rows = $dbh->selectall_arrayref($sql, { Slice => {} }, $borrowernumber); |
767 |
my $rows = $dbh->selectall_arrayref($sql, { Slice => {} }, $borrowernumber); |
708 |
|
768 |
|
709 |
# offset transactions |
769 |
# offset transactions |
710 |
my $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding= ? ' . |
770 |
my $sth = $dbh->prepare(" |
711 |
'WHERE accountlines_id=?'); |
771 |
UPDATE accountlines SET amountoutstanding = ? |
|
|
772 |
WHERE accountlines_id = ? |
773 |
"); |
774 |
|
712 |
for my $accdata ( @{$rows} ) { |
775 |
for my $accdata ( @{$rows} ) { |
713 |
if ($amountleft == 0) { |
776 |
if ($amountleft == 0) { |
714 |
last; |
777 |
last; |
Lines 726-736
sub recordpayment_selectaccts {
Link Here
|
726 |
} |
789 |
} |
727 |
|
790 |
|
728 |
# create new line |
791 |
# create new line |
729 |
$sql = 'INSERT INTO accountlines ' . |
792 |
$sql = " |
730 |
'(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id) ' . |
793 |
INSERT INTO accountlines |
731 |
q|VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?)|; |
794 |
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id) |
|
|
795 |
VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?) |
796 |
"; |
732 |
$dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id ); |
797 |
$dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id ); |
733 |
UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno ); |
798 |
UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno ); |
|
|
799 |
|
800 |
if ( C4::Context->preference("FinesLog") ) { |
801 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
802 |
accountno => $nextaccntno, |
803 |
amount => $amount * -1, |
804 |
description => 'Payment,thanks', |
805 |
accounttype => 'Pay', |
806 |
amountoutstanding => $amountleft * -1, |
807 |
})); |
808 |
} |
809 |
|
734 |
return; |
810 |
return; |
735 |
} |
811 |
} |
736 |
|
812 |
|
Lines 748-760
sub makepartialpayment {
Link Here
|
748 |
my $nextaccntno = getnextacctno($borrowernumber); |
824 |
my $nextaccntno = getnextacctno($borrowernumber); |
749 |
my $newamtos = 0; |
825 |
my $newamtos = 0; |
750 |
|
826 |
|
751 |
my $data = $dbh->selectrow_hashref( |
827 |
my $data = $dbh->selectrow_hashref('SELECT * FROM accountlines WHERE accountlines_id=?',undef,$accountlines_id); |
752 |
'SELECT * FROM accountlines WHERE accountlines_id=?',undef,$accountlines_id); |
|
|
753 |
my $new_outstanding = $data->{amountoutstanding} - $amount; |
828 |
my $new_outstanding = $data->{amountoutstanding} - $amount; |
754 |
|
829 |
|
755 |
my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? '; |
830 |
my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? '; |
756 |
$dbh->do( $update, undef, $new_outstanding, $accountlines_id); |
831 |
$dbh->do( $update, undef, $new_outstanding, $accountlines_id); |
757 |
|
832 |
|
|
|
833 |
if ( C4::Context->preference("FinesLog") ) { |
834 |
$data->{amountoutstanding_new} = $new_outstanding; |
835 |
logaction("FINES", 'MODIFY',$borrowernumber,Dumper( $data )); |
836 |
} |
837 |
|
758 |
# create new line |
838 |
# create new line |
759 |
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' |
839 |
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' |
760 |
. 'description, accounttype, amountoutstanding, itemnumber, manager_id) ' |
840 |
. 'description, accounttype, amountoutstanding, itemnumber, manager_id) ' |
Lines 765-770
sub makepartialpayment {
Link Here
|
765 |
|
845 |
|
766 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); |
846 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); |
767 |
|
847 |
|
|
|
848 |
if ( C4::Context->preference("FinesLog") ) { |
849 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
850 |
borrowernumber => $user, |
851 |
accountno => $nextaccntno, |
852 |
amount => $amount * -1, |
853 |
description => "Payment, thanks - $user", |
854 |
accounttype => 'Pay', |
855 |
amountoutstanding => '0', |
856 |
itemnumber => $data->{'itemnumber'}, |
857 |
})); |
858 |
} |
859 |
|
768 |
return; |
860 |
return; |
769 |
} |
861 |
} |
770 |
|
862 |
|
Lines 801-806
sub WriteOffFee {
Link Here
|
801 |
$sth = $dbh->prepare( $query ); |
893 |
$sth = $dbh->prepare( $query ); |
802 |
$sth->execute( $accountline_id, $borrowernumber ); |
894 |
$sth->execute( $accountline_id, $borrowernumber ); |
803 |
|
895 |
|
|
|
896 |
if ( C4::Context->preference("FinesLog") ) { |
897 |
logaction("FINES", 'MODIFY',$borrowernumber,Dumper({ |
898 |
accountlines_id => $accountline_id, |
899 |
amountoutstanding => '0', |
900 |
why => 'writeoff', |
901 |
})); |
902 |
} |
903 |
|
804 |
$query =" |
904 |
$query =" |
805 |
INSERT INTO accountlines |
905 |
INSERT INTO accountlines |
806 |
( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id ) |
906 |
( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id ) |
Lines 810-815
sub WriteOffFee {
Link Here
|
810 |
my $acct = getnextacctno($borrowernumber); |
910 |
my $acct = getnextacctno($borrowernumber); |
811 |
$sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id ); |
911 |
$sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id ); |
812 |
|
912 |
|
|
|
913 |
if ( C4::Context->preference("FinesLog") ) { |
914 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
915 |
accountno => $acct, |
916 |
itemnumber => $itemnum, |
917 |
amount => $amount, |
918 |
description => 'Writeoff', |
919 |
accounttype => 'W', |
920 |
})); |
921 |
} |
922 |
|
813 |
UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber ); |
923 |
UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber ); |
814 |
|
924 |
|
815 |
} |
925 |
} |