@@ -, +, @@
Code will also respect notes when using the "Writeoff All" button but WILL NOT when using either the "Pay Amount" or "Pay Selected" buttons
---
C4/Accounts.pm | 18 ++++++++++--------
.../intranet-tmpl/prog/en/modules/members/pay.tt | 2 ++
.../prog/en/modules/members/paycollect.tt | 2 ++
members/pay.pl | 16 ++++++++++------
members/paycollect.pl | 8 +++++---
5 files changed, 29 insertions(+), 17 deletions(-)
--- a/C4/Accounts.pm
+++ a/C4/Accounts.pm
@@ -157,7 +157,7 @@ sub makepayment {
#here we update both the accountoffsets and the account lines
#updated to check, if they are paying off a lost item, we return the item
# from their card, and put a note on the item record
- my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
+ my ( $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
my $dbh = C4::Context->dbh;
my $manager_id = 0;
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
@@ -197,14 +197,15 @@ sub makepayment {
# create new line
my $payment = 0 - $amount;
+ $payment_note = "" unless defined $payment_note;
my $ins =
$dbh->prepare(
"INSERT
- INTO accountlines (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding)
- VALUES ( ?, ?, now(), ?, 'Payment,thanks', 'Pay', 0)"
+ INTO accountlines (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, note)
+ VALUES ( ?, ?, now(), ?, 'Payment,thanks', 'Pay', 0, ?)"
);
- $ins->execute($borrowernumber, $nextaccntno, $payment);
+ $ins->execute($borrowernumber, $nextaccntno, $payment, $payment_note);
$ins->finish;
}
@@ -724,10 +725,11 @@ sub recordpayment_selectaccts {
# makepayment needs to be fixed to handle partials till then this separate subroutine
# fills in
sub makepartialpayment {
- my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
+ my ( $borrowernumber, $accountno, $amount, $user, $branchm, $payment_note ) = @_;
if (!$amount || $amount < 0) {
return;
}
+ $payment_note = "" unless defined $payment_note;
my $dbh = C4::Context->dbh;
my $nextaccntno = getnextacctno($borrowernumber);
@@ -743,11 +745,11 @@ sub makepartialpayment {
# create new line
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
- . 'description, accounttype, amountoutstanding) '
- . ' VALUES (?, ?, now(), ?, ?, ?, 0)';
+ . 'description, accounttype, amountoutstanding, note) '
+ . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?)';
$dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount,
- "Payment, thanks - $user", 'Pay');
+ "Payment, thanks - $user", 'Pay', $payment_note);
UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt
@@ -34,6 +34,7 @@
Fines & Charges |
Sel |
Description |
+ Payment Note |
Account Type |
Notify id |
Level |
@@ -66,6 +67,7 @@
[% END %]
[% line.description %] [% line.title |html_entity %] |
+ |
[% line.accounttype %] |
[% line.notify_id %] |
[% line.notify_level %] |
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt
@@ -102,6 +102,7 @@ function moneyFormat(textObj) {
+
Description |
@@ -156,6 +157,7 @@ function moneyFormat(textObj) {
+
Description |
--- a/members/pay.pl
+++ a/members/pay.pl
@@ -90,7 +90,8 @@ if ($writeoff_all) {
my $itemno = $input->param('itemnumber');
my $account_type = $input->param('accounttype');
my $amount = $input->param('amount');
- writeoff( $accountno, $itemno, $account_type, $amount );
+ my $payment_note = $input->param("payment_note");
+ writeoff( $accountno, $itemno, $account_type, $amount, $payment_note );
}
for (@names) {
@@ -108,7 +109,8 @@ add_accounts_to_template();
output_html_with_http_headers $input, $cookie, $template->output;
sub writeoff {
- my ( $accountnum, $itemnum, $accounttype, $amount ) = @_;
+ my ( $accountnum, $itemnum, $accounttype, $amount, $payment_note ) = @_;
+ $payment_note = "" unless defined $payment_note;
# if no item is attached to fine, make sure to store it as a NULL
$itemnum ||= undef;
@@ -116,7 +118,7 @@ sub writeoff {
$writeoff_sth->execute( $accountnum, $borrowernumber );
my $acct = getnextacctno($borrowernumber);
- $add_writeoff_sth->execute( $borrowernumber, $acct, $itemnum, $amount );
+ $add_writeoff_sth->execute( $borrowernumber, $acct, $itemnum, $amount, $payment_note);
UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber );
@@ -183,6 +185,7 @@ sub redirect_to_paycollect {
$redirect .= get_for_redirect( 'itemnumber', "itemnumber$line_no", 0 );
$redirect .= get_for_redirect( 'notify_id', "notify_id$line_no", 0 );
$redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
+ $redirect .= get_for_redirect( 'payment_note', "payment_note_$line_no", 0);
$redirect .= '&remote_user=';
$redirect .= $user;
return print $input->redirect($redirect);
@@ -200,7 +203,8 @@ sub writeoff_all {
my $itemno = $input->param("itemnumber$value");
my $amount = $input->param("amount$value");
my $accountno = $input->param("accountno$value");
- writeoff( $accountno, $itemno, $accounttype, $amount );
+ my $payment_note = $input->param("payment_note_$value");
+ writeoff( $accountno, $itemno, $accounttype, $amount, $payment_note );
}
}
@@ -280,8 +284,8 @@ sub get_writeoff_sth {
. 'WHERE accountno=? and borrowernumber=?';
$writeoff_sth = $dbh->prepare($sql);
my $insert =
-q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)}
- . q{values (?,?,?,now(),?,'Writeoff','W')};
+q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,note)}
+ . q{values (?,?,?,now(),?,'Writeoff','W',?)};
$add_writeoff_sth = $dbh->prepare($insert);
}
return;
--- a/members/paycollect.pl
+++ a/members/paycollect.pl
@@ -55,6 +55,7 @@ my $individual = $input->param('pay_individual');
my $writeoff = $input->param('writeoff_individual');
my $select_lines = $input->param('selected');
my $select = $input->param('selected_accts');
+my $payment_note = $input->param('payment_note');
my $accountno;
if ( $individual || $writeoff ) {
@@ -81,6 +82,7 @@ if ( $individual || $writeoff ) {
description => $description,
notify_id => $notify_id,
notify_level => $notify_level,
+ payment_note => $payment_note,
);
} elsif ($select_lines) {
$total_due = $input->param('amt');
@@ -98,12 +100,12 @@ if ( $total_paid and $total_paid ne '0.00' ) {
);
} else {
if ($individual) {
- if ( $total_paid == $total_due ) {
+ if ( $total_paid == $total_due ) {
makepayment( $borrowernumber, $accountno, $total_paid, $user,
- $branch );
+ $branch, $payment_note );
} else {
makepartialpayment( $borrowernumber, $accountno, $total_paid,
- $user, $branch );
+ $user, $branch, $payment_note );
}
print $input->redirect(
"/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
--