View | Details | Raw Unified | Return to bug 6413
Collapse All | Expand All

(-)a/C4/Accounts.pm (-15 / +19 lines)
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({
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (+2 lines)
Lines 51-56 Link Here
51
    <th>&nbsp;</th>
51
    <th>&nbsp;</th>
52
    <th>Fines &amp; charges</th>
52
    <th>Fines &amp; charges</th>
53
	<th>Description</th>
53
	<th>Description</th>
54
    <th>Payment Note</th>
54
    <th>Account type</th>
55
    <th>Account type</th>
55
	<th>Notify id</th>
56
	<th>Notify id</th>
56
	<th>Level</th>
57
	<th>Level</th>
Lines 91-96 Link Here
91
    <input type="hidden" name="totals[% line.accountno %]" value="[% line.totals %]" />
92
    <input type="hidden" name="totals[% line.accountno %]" value="[% line.totals %]" />
92
    </td>
93
    </td>
93
    <td>[% line.description %] ([% line.title |html_entity %])</td>
94
    <td>[% line.description %] ([% line.title |html_entity %])</td>
95
    <td><input type="text" name="payment_note_[% line.accountno %]"></input></td>
94
    <td>[% line.accounttype %]</td>
96
    <td>[% line.accounttype %]</td>
95
    <td>[% line.notify_id %]</td>
97
    <td>[% line.notify_id %]</td>
96
    <td>[% line.notify_level %]</td>
98
    <td>[% line.notify_level %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+2 lines)
Lines 114-119 function moneyFormat(textObj) { Link Here
114
114
115
<fieldset class="rows">
115
<fieldset class="rows">
116
    <legend>Pay an individual fine</legend>
116
    <legend>Pay an individual fine</legend>
117
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
117
    <table>
118
    <table>
118
    <thead><tr>
119
    <thead><tr>
119
            <th>Description</th>
120
            <th>Description</th>
Lines 167-172 function moneyFormat(textObj) { Link Here
167
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
168
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
168
    <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
169
    <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
169
    <input type="hidden" name="title" id="title" value="[% title %]" />
170
    <input type="hidden" name="title" id="title" value="[% title %]" />
171
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
170
    <table>
172
    <table>
171
    <thead><tr>
173
    <thead><tr>
172
            <th>Description</th>
174
            <th>Description</th>
(-)a/members/pay.pl (-3 / +6 lines)
Lines 29-34 Link Here
29
use strict;
29
use strict;
30
use warnings;
30
use warnings;
31
31
32
use URI::Escape;
32
use C4::Context;
33
use C4::Context;
33
use C4::Auth;
34
use C4::Auth;
34
use C4::Output;
35
use C4::Output;
Lines 87-93 if ($writeoff_all) { Link Here
87
    my $itemno       = $input->param('itemnumber');
88
    my $itemno       = $input->param('itemnumber');
88
    my $account_type = $input->param('accounttype');
89
    my $account_type = $input->param('accounttype');
89
    my $amount       = $input->param('amountoutstanding');
90
    my $amount       = $input->param('amountoutstanding');
90
    WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $account_type, $amount );
91
    my $payment_note = $input->param("payment_note");
92
    WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $account_type, $amount, $branch, $payment_note );
91
}
93
}
92
94
93
for (@names) {
95
for (@names) {
Lines 161-172 sub redirect_to_paycollect { Link Here
161
    $redirect .=
163
    $redirect .=
162
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
164
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
163
    $redirect .= get_for_redirect( 'accountno',    "accountno$line_no",    0 );
165
    $redirect .= get_for_redirect( 'accountno',    "accountno$line_no",    0 );
164
    $redirect .= get_for_redirect( 'description',  "description$line_no",  0 );
165
    $redirect .= get_for_redirect( 'title',        "title$line_no",        0 );
166
    $redirect .= get_for_redirect( 'title',        "title$line_no",        0 );
166
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
167
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
167
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
168
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
168
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
169
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
169
    $redirect .= get_for_redirect( 'accountlines_id', "accountlines_id$line_no", 0 );
170
    $redirect .= get_for_redirect( 'accountlines_id', "accountlines_id$line_no", 0 );
171
    $redirect .= q{&} . 'payment_note' . q{=} . uri_escape( $input->param("payment_note_$line_no") );
170
    $redirect .= '&remote_user=';
172
    $redirect .= '&remote_user=';
171
    $redirect .= $user;
173
    $redirect .= $user;
172
    return print $input->redirect($redirect);
174
    return print $input->redirect($redirect);
Lines 185-191 sub writeoff_all { Link Here
185
            my $amount    = $input->param("amountoutstanding$value");
187
            my $amount    = $input->param("amountoutstanding$value");
186
            my $accountno = $input->param("accountno$value");
188
            my $accountno = $input->param("accountno$value");
187
            my $accountlines_id = $input->param("accountlines_id$value");
189
            my $accountlines_id = $input->param("accountlines_id$value");
188
            WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $accounttype, $amount );
190
            my $payment_note = $input->param("payment_note_$value");
191
            WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $accounttype, $amount, $branch, $payment_note );
189
        }
192
        }
190
    }
193
    }
191
194
(-)a/members/paycollect.pl (-3 / +5 lines)
Lines 19-24 Link Here
19
19
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
22
use URI::Escape;
22
use C4::Context;
23
use C4::Context;
23
use C4::Auth;
24
use C4::Auth;
24
use C4::Output;
25
use C4::Output;
Lines 55-60 my $individual = $input->param('pay_individual'); Link Here
55
my $writeoff     = $input->param('writeoff_individual');
56
my $writeoff     = $input->param('writeoff_individual');
56
my $select_lines = $input->param('selected');
57
my $select_lines = $input->param('selected');
57
my $select       = $input->param('selected_accts');
58
my $select       = $input->param('selected_accts');
59
my $payment_note = uri_unescape $input->param('payment_note');
58
my $accountno;
60
my $accountno;
59
my $accountlines_id;
61
my $accountlines_id;
60
if ( $individual || $writeoff ) {
62
if ( $individual || $writeoff ) {
Lines 85-90 if ( $individual || $writeoff ) { Link Here
85
        description       => $description,
87
        description       => $description,
86
        notify_id         => $notify_id,
88
        notify_id         => $notify_id,
87
        notify_level      => $notify_level,
89
        notify_level      => $notify_level,
90
        payment_note    => $payment_note,
88
    );
91
    );
89
} elsif ($select_lines) {
92
} elsif ($select_lines) {
90
    $total_due = $input->param('amt');
93
    $total_due = $input->param('amt');
Lines 104-113 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
104
        if ($individual) {
107
        if ($individual) {
105
            if ( $total_paid == $total_due ) {
108
            if ( $total_paid == $total_due ) {
106
                makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user,
109
                makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user,
107
                    $branch );
110
                    $branch, $payment_note );
108
            } else {
111
            } else {
109
                makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid,
112
                makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid,
110
                    $user, $branch );
113
                    $user, $branch, $payment_note );
111
            }
114
            }
112
            print $input->redirect(
115
            print $input->redirect(
113
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
116
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
114
- 

Return to bug 6413