From 8249544156921c634ae91e4970cb82111e81fece Mon Sep 17 00:00:00 2001 From: Chris Hall Date: Thu, 26 Jan 2012 16:04:53 +1300 Subject: [PATCH] Bug 6413 Added ability to add a note when paying or writing off a fine Code will also respect notes when using the "Writeoff All" button but WILL NOT when using either the "Pay Amount" or "Pay Selected" buttons Fixed uri encoding of arguments Signed-off-by: Nicole C. Engard Signed-off-by: Paul Poulain Signed-off-by: Galen Charlton --- C4/Accounts.pm | 34 +++++++++++-------- .../prog/en/modules/members/pay.tt | 2 ++ .../prog/en/modules/members/paycollect.tt | 2 ++ members/pay.pl | 9 +++-- members/paycollect.pl | 7 ++-- 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index a39ca54485..08545025d5 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -191,7 +191,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 ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch ) = @_; + my ( $accountlines_id, $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; @@ -227,15 +227,16 @@ sub makepayment { $udp->finish; # create new line - $payment = 0 - $amount; + my $payment = 0 - $amount; + $payment_note //= ""; my $ins = $dbh->prepare( "INSERT - INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id) - VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?)" + INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note) + VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?)" ); - $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id); + $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note); $ins->finish; } @@ -872,12 +873,13 @@ sub recordpayment_selectaccts { # makepayment needs to be fixed to handle partials till then this separate subroutine # fills in sub makepartialpayment { - my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch ) = @_; + my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; my $manager_id = 0; $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; if (!$amount || $amount < 0) { return; } + $payment_note //= ""; my $dbh = C4::Context->dbh; my $nextaccntno = getnextacctno($borrowernumber); @@ -905,11 +907,11 @@ sub makepartialpayment { # create new line my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' - . 'description, accounttype, amountoutstanding, itemnumber, manager_id) ' - . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?)'; + . 'description, accounttype, amountoutstanding, itemnumber, manager_id, note) ' + . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)'; - $dbh->do( $insert, undef, $borrowernumber, $nextaccntno, 0 - $amount, - "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id); + $dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, + "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note); UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); @@ -931,7 +933,7 @@ sub makepartialpayment { =head2 WriteOffFee - WriteOff( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch ); + WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note ); Write off a fine for a patron. C<$borrowernumber> is the patron's borrower number. @@ -940,11 +942,13 @@ C<$itemnum> is the itemnumber of of item whose fine is being written off. C<$accounttype> is the account type of the fine being written off. C<$amount> is a floating-point number, giving the amount that is being written off. C<$branch> is the branchcode of the library where the writeoff occurred. +C<$payment_note> is the note to attach to this payment =cut sub WriteOffFee { - my ( $borrowernumber, $accountlines_id, $itemnum, $accounttype, $amount, $branch ) = @_; + my ( $borrowernumber, $accountlines_id, $itemnum, $accounttype, $amount, $branch, $payment_note ) = @_; + $payment_note //= ""; $branch ||= C4::Context->userenv->{branch}; my $manager_id = 0; $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; @@ -973,12 +977,12 @@ sub WriteOffFee { $query =" INSERT INTO accountlines - ( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id ) - VALUES ( ?, ?, ?, NOW(), ?, 'Writeoff', 'W', ? ) + ( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id, note ) + VALUES ( ?, ?, ?, NOW(), ?, 'Writeoff', 'W', ?, ? ) "; $sth = $dbh->prepare( $query ); my $acct = getnextacctno($borrowernumber); - $sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id ); + $sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id, $payment_note ); if ( C4::Context->preference("FinesLog") ) { logaction("FINES", 'CREATE',$borrowernumber,Dumper({ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt index e575df81fa..af08c6af7e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt @@ -51,6 +51,7 @@   Fines & charges Description + Payment Note Account type Notify id Level @@ -91,6 +92,7 @@ [% line.description %] ([% line.title |html_entity %]) + [% line.accounttype %] [% line.notify_id %] [% line.notify_level %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt index f38d20c1c8..e80e6daa82 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -114,6 +114,7 @@ function moneyFormat(textObj) {
Pay an individual fine + @@ -167,6 +168,7 @@ function moneyFormat(textObj) { +
Description
diff --git a/members/pay.pl b/members/pay.pl index 7dbe3eb138..67350b4577 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -29,6 +29,7 @@ use strict; use warnings; +use URI::Escape; use C4::Context; use C4::Auth; use C4::Output; @@ -87,7 +88,8 @@ if ($writeoff_all) { my $itemno = $input->param('itemnumber'); my $account_type = $input->param('accounttype'); my $amount = $input->param('amountoutstanding'); - WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $account_type, $amount ); + my $payment_note = $input->param("payment_note"); + WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $account_type, $amount, $branch, $payment_note ); } for (@names) { @@ -164,12 +166,12 @@ sub redirect_to_paycollect { $redirect .= get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 ); $redirect .= get_for_redirect( 'accountno', "accountno$line_no", 0 ); - $redirect .= get_for_redirect( 'description', "description$line_no", 0 ); $redirect .= get_for_redirect( 'title', "title$line_no", 0 ); $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( 'accountlines_id', "accountlines_id$line_no", 0 ); + $redirect .= q{&} . 'payment_note' . q{=} . uri_escape( $input->param("payment_note_$line_no") ); $redirect .= '&remote_user='; $redirect .= $user; return print $input->redirect($redirect); @@ -188,7 +190,8 @@ sub writeoff_all { my $amount = $input->param("amountoutstanding$value"); my $accountno = $input->param("accountno$value"); my $accountlines_id = $input->param("accountlines_id$value"); - WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $accounttype, $amount ); + my $payment_note = $input->param("payment_note_$value"); + WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $accounttype, $amount, $branch, $payment_note ); } } diff --git a/members/paycollect.pl b/members/paycollect.pl index 9828fb3acb..5ed6b862be 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -19,6 +19,7 @@ use strict; use warnings; +use URI::Escape; use C4::Context; use C4::Auth; use C4::Output; @@ -55,6 +56,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 = uri_unescape $input->param('payment_note'); my $accountno; my $accountlines_id; if ( $individual || $writeoff ) { @@ -85,6 +87,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'); @@ -104,10 +107,10 @@ if ( $total_paid and $total_paid ne '0.00' ) { if ($individual) { if ( $total_paid == $total_due ) { makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user, - $branch ); + $branch, $payment_note ); } else { makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, - $user, $branch ); + $user, $branch, $payment_note ); } print $input->redirect( "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber"); -- 2.39.5
Description