Lines 167-173
sub makepayment {
Link Here
|
167 |
#here we update both the accountoffsets and the account lines |
167 |
#here we update both the accountoffsets and the account lines |
168 |
#updated to check, if they are paying off a lost item, we return the item |
168 |
#updated to check, if they are paying off a lost item, we return the item |
169 |
# from their card, and put a note on the item record |
169 |
# from their card, and put a note on the item record |
170 |
my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch ) = @_; |
170 |
my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; |
171 |
my $dbh = C4::Context->dbh; |
171 |
my $dbh = C4::Context->dbh; |
172 |
my $manager_id = 0; |
172 |
my $manager_id = 0; |
173 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
173 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
Lines 203-216
sub makepayment {
Link Here
|
203 |
|
203 |
|
204 |
# create new line |
204 |
# create new line |
205 |
my $payment = 0 - $amount; |
205 |
my $payment = 0 - $amount; |
|
|
206 |
$payment_note //= ""; |
206 |
|
207 |
|
207 |
my $ins = |
208 |
my $ins = |
208 |
$dbh->prepare( |
209 |
$dbh->prepare( |
209 |
"INSERT |
210 |
"INSERT |
210 |
INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id) |
211 |
INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note) |
211 |
VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?)" |
212 |
VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?)" |
212 |
); |
213 |
); |
213 |
$ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id); |
214 |
$ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note); |
214 |
$ins->finish; |
215 |
$ins->finish; |
215 |
} |
216 |
} |
216 |
|
217 |
|
Lines 737-748
sub recordpayment_selectaccts {
Link Here
|
737 |
# makepayment needs to be fixed to handle partials till then this separate subroutine |
738 |
# makepayment needs to be fixed to handle partials till then this separate subroutine |
738 |
# fills in |
739 |
# fills in |
739 |
sub makepartialpayment { |
740 |
sub makepartialpayment { |
740 |
my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch ) = @_; |
741 |
my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; |
741 |
my $manager_id = 0; |
742 |
my $manager_id = 0; |
742 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
743 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
743 |
if (!$amount || $amount < 0) { |
744 |
if (!$amount || $amount < 0) { |
744 |
return; |
745 |
return; |
745 |
} |
746 |
} |
|
|
747 |
$payment_note //= ""; |
746 |
my $dbh = C4::Context->dbh; |
748 |
my $dbh = C4::Context->dbh; |
747 |
|
749 |
|
748 |
my $nextaccntno = getnextacctno($borrowernumber); |
750 |
my $nextaccntno = getnextacctno($borrowernumber); |
Lines 757-767
sub makepartialpayment {
Link Here
|
757 |
|
759 |
|
758 |
# create new line |
760 |
# create new line |
759 |
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' |
761 |
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' |
760 |
. 'description, accounttype, amountoutstanding, itemnumber, manager_id) ' |
762 |
. 'description, accounttype, amountoutstanding, itemnumber, manager_id, note) ' |
761 |
. ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?)'; |
763 |
. ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)'; |
762 |
|
764 |
|
763 |
$dbh->do( $insert, undef, $borrowernumber, $nextaccntno, 0 - $amount, |
765 |
$dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, |
764 |
"Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id); |
766 |
"Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note); |
765 |
|
767 |
|
766 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); |
768 |
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); |
767 |
|
769 |
|
Lines 770-776
sub makepartialpayment {
Link Here
|
770 |
|
772 |
|
771 |
=head2 WriteOffFee |
773 |
=head2 WriteOffFee |
772 |
|
774 |
|
773 |
WriteOff( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch ); |
775 |
WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note ); |
774 |
|
776 |
|
775 |
Write off a fine for a patron. |
777 |
Write off a fine for a patron. |
776 |
C<$borrowernumber> is the patron's borrower number. |
778 |
C<$borrowernumber> is the patron's borrower number. |
Lines 779-789
C<$itemnum> is the itemnumber of of item whose fine is being written off.
Link Here
|
779 |
C<$accounttype> is the account type of the fine being written off. |
781 |
C<$accounttype> is the account type of the fine being written off. |
780 |
C<$amount> is a floating-point number, giving the amount that is being written off. |
782 |
C<$amount> is a floating-point number, giving the amount that is being written off. |
781 |
C<$branch> is the branchcode of the library where the writeoff occurred. |
783 |
C<$branch> is the branchcode of the library where the writeoff occurred. |
|
|
784 |
C<$payment_note> is the note to attach to this payment |
782 |
|
785 |
|
783 |
=cut |
786 |
=cut |
784 |
|
787 |
|
785 |
sub WriteOffFee { |
788 |
sub WriteOffFee { |
786 |
my ( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch ) = @_; |
789 |
my ( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note ) = @_; |
|
|
790 |
$payment_note //= ""; |
787 |
$branch ||= C4::Context->userenv->{branch}; |
791 |
$branch ||= C4::Context->userenv->{branch}; |
788 |
my $manager_id = 0; |
792 |
my $manager_id = 0; |
789 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
793 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
Lines 803-814
sub WriteOffFee {
Link Here
|
803 |
|
807 |
|
804 |
$query =" |
808 |
$query =" |
805 |
INSERT INTO accountlines |
809 |
INSERT INTO accountlines |
806 |
( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id ) |
810 |
( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id, note ) |
807 |
VALUES ( ?, ?, ?, NOW(), ?, 'Writeoff', 'W', ? ) |
811 |
VALUES ( ?, ?, ?, NOW(), ?, 'Writeoff', 'W', ?, ? ) |
808 |
"; |
812 |
"; |
809 |
$sth = $dbh->prepare( $query ); |
813 |
$sth = $dbh->prepare( $query ); |
810 |
my $acct = getnextacctno($borrowernumber); |
814 |
my $acct = getnextacctno($borrowernumber); |
811 |
$sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id ); |
815 |
$sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id, $payment_note ); |
812 |
|
816 |
|
813 |
UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber ); |
817 |
UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber ); |
814 |
|
818 |
|