Lines 191-197
sub makepayment {
Link Here
|
191 |
#here we update both the accountoffsets and the account lines |
191 |
#here we update both the accountoffsets and the account lines |
192 |
#updated to check, if they are paying off a lost item, we return the item |
192 |
#updated to check, if they are paying off a lost item, we return the item |
193 |
# from their card, and put a note on the item record |
193 |
# from their card, and put a note on the item record |
194 |
my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch ) = @_; |
194 |
my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; |
195 |
my $dbh = C4::Context->dbh; |
195 |
my $dbh = C4::Context->dbh; |
196 |
my $manager_id = 0; |
196 |
my $manager_id = 0; |
197 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
197 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
Lines 227-241
sub makepayment {
Link Here
|
227 |
$udp->finish; |
227 |
$udp->finish; |
228 |
|
228 |
|
229 |
# create new line |
229 |
# create new line |
230 |
$payment = 0 - $amount; |
230 |
my $payment = 0 - $amount; |
|
|
231 |
$payment_note //= ""; |
231 |
|
232 |
|
232 |
my $ins = |
233 |
my $ins = |
233 |
$dbh->prepare( |
234 |
$dbh->prepare( |
234 |
"INSERT |
235 |
"INSERT |
235 |
INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id) |
236 |
INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note) |
236 |
VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?)" |
237 |
VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?)" |
237 |
); |
238 |
); |
238 |
$ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id); |
239 |
$ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note); |
239 |
$ins->finish; |
240 |
$ins->finish; |
240 |
} |
241 |
} |
241 |
|
242 |
|
Lines 872-883
sub recordpayment_selectaccts {
Link Here
|
872 |
# makepayment needs to be fixed to handle partials till then this separate subroutine |
873 |
# makepayment needs to be fixed to handle partials till then this separate subroutine |
873 |
# fills in |
874 |
# fills in |
874 |
sub makepartialpayment { |
875 |
sub makepartialpayment { |
875 |
my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch ) = @_; |
876 |
my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; |
876 |
my $manager_id = 0; |
877 |
my $manager_id = 0; |
877 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
878 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
878 |
if (!$amount || $amount < 0) { |
879 |
if (!$amount || $amount < 0) { |
879 |
return; |
880 |
return; |
880 |
} |
881 |
} |
|
|
882 |
$payment_note //= ""; |
881 |
my $dbh = C4::Context->dbh; |
883 |
my $dbh = C4::Context->dbh; |
882 |
|
884 |
|
883 |
my $nextaccntno = getnextacctno($borrowernumber); |
885 |
my $nextaccntno = getnextacctno($borrowernumber); |
Lines 905-915
sub makepartialpayment {
Link Here
|
905 |
|
907 |
|
906 |
# create new line |
908 |
# create new line |
907 |
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' |
909 |
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' |
908 |
. 'description, accounttype, amountoutstanding, itemnumber, manager_id) ' |
910 |
. 'description, accounttype, amountoutstanding, itemnumber, manager_id, note) ' |
909 |
. ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?)'; |
911 |
. ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)'; |
910 |
|
912 |
|
911 |
$dbh->do( $insert, undef, $borrowernumber, $nextaccntno, 0 - $amount, |
913 |
$dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, |
912 |
"Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id); |
914 |
"Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note); |
913 |
|
915 |
|
914 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); |
916 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); |
915 |
|
917 |
|
Lines 931-937
sub makepartialpayment {
Link Here
|
931 |
|
933 |
|
932 |
=head2 WriteOffFee |
934 |
=head2 WriteOffFee |
933 |
|
935 |
|
934 |
WriteOff( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch ); |
936 |
WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note ); |
935 |
|
937 |
|
936 |
Write off a fine for a patron. |
938 |
Write off a fine for a patron. |
937 |
C<$borrowernumber> is the patron's borrower number. |
939 |
C<$borrowernumber> is the patron's borrower number. |
Lines 940-950
C<$itemnum> is the itemnumber of of item whose fine is being written off.
Link Here
|
940 |
C<$accounttype> is the account type of the fine being written off. |
942 |
C<$accounttype> is the account type of the fine being written off. |
941 |
C<$amount> is a floating-point number, giving the amount that is being written off. |
943 |
C<$amount> is a floating-point number, giving the amount that is being written off. |
942 |
C<$branch> is the branchcode of the library where the writeoff occurred. |
944 |
C<$branch> is the branchcode of the library where the writeoff occurred. |
|
|
945 |
C<$payment_note> is the note to attach to this payment |
943 |
|
946 |
|
944 |
=cut |
947 |
=cut |
945 |
|
948 |
|
946 |
sub WriteOffFee { |
949 |
sub WriteOffFee { |
947 |
my ( $borrowernumber, $accountlines_id, $itemnum, $accounttype, $amount, $branch ) = @_; |
950 |
my ( $borrowernumber, $accountlines_id, $itemnum, $accounttype, $amount, $branch, $payment_note ) = @_; |
|
|
951 |
$payment_note //= ""; |
948 |
$branch ||= C4::Context->userenv->{branch}; |
952 |
$branch ||= C4::Context->userenv->{branch}; |
949 |
my $manager_id = 0; |
953 |
my $manager_id = 0; |
950 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
954 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
Lines 973-984
sub WriteOffFee {
Link Here
|
973 |
|
977 |
|
974 |
$query =" |
978 |
$query =" |
975 |
INSERT INTO accountlines |
979 |
INSERT INTO accountlines |
976 |
( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id ) |
980 |
( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id, note ) |
977 |
VALUES ( ?, ?, ?, NOW(), ?, 'Writeoff', 'W', ? ) |
981 |
VALUES ( ?, ?, ?, NOW(), ?, 'Writeoff', 'W', ?, ? ) |
978 |
"; |
982 |
"; |
979 |
$sth = $dbh->prepare( $query ); |
983 |
$sth = $dbh->prepare( $query ); |
980 |
my $acct = getnextacctno($borrowernumber); |
984 |
my $acct = getnextacctno($borrowernumber); |
981 |
$sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id ); |
985 |
$sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id, $payment_note ); |
982 |
|
986 |
|
983 |
if ( C4::Context->preference("FinesLog") ) { |
987 |
if ( C4::Context->preference("FinesLog") ) { |
984 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
988 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |