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

(-)a/C4/Accounts.pm (-14 / +18 lines)
Lines 165-171 sub makepayment { Link Here
165
    #here we update both the accountoffsets and the account lines
165
    #here we update both the accountoffsets and the account lines
166
    #updated to check, if they are paying off a lost item, we return the item
166
    #updated to check, if they are paying off a lost item, we return the item
167
    # from their card, and put a note on the item record
167
    # from their card, and put a note on the item record
168
    my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
168
    my ( $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
169
    my $dbh = C4::Context->dbh;
169
    my $dbh = C4::Context->dbh;
170
    my $manager_id = 0;
170
    my $manager_id = 0;
171
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
171
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
Lines 205-218 sub makepayment { Link Here
205
205
206
         # create new line
206
         # create new line
207
        my $payment = 0 - $amount;
207
        my $payment = 0 - $amount;
208
        $payment_note //= "";
208
        
209
        
209
        my $ins = 
210
        my $ins = 
210
            $dbh->prepare( 
211
            $dbh->prepare( 
211
                "INSERT 
212
                "INSERT 
212
                    INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id)
213
                    INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note)
213
                    VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?)"
214
                    VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?)"
214
            );
215
            );
215
        $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id);
216
        $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note);
216
        $ins->finish;
217
        $ins->finish;
217
    }
218
    }
218
219
Lines 732-743 sub recordpayment_selectaccts { Link Here
732
# makepayment needs to be fixed to handle partials till then this separate subroutine
733
# makepayment needs to be fixed to handle partials till then this separate subroutine
733
# fills in
734
# fills in
734
sub makepartialpayment {
735
sub makepartialpayment {
735
    my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
736
    my ( $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
736
    my $manager_id = 0;
737
    my $manager_id = 0;
737
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
738
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
738
    if (!$amount || $amount < 0) {
739
    if (!$amount || $amount < 0) {
739
        return;
740
        return;
740
    }
741
    }
742
    $payment_note //= "";
741
    my $dbh = C4::Context->dbh;
743
    my $dbh = C4::Context->dbh;
742
744
743
    my $nextaccntno = getnextacctno($borrowernumber);
745
    my $nextaccntno = getnextacctno($borrowernumber);
Lines 753-772 sub makepartialpayment { Link Here
753
755
754
    # create new line
756
    # create new line
755
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
757
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
756
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id) '
758
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '
757
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?)';
759
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';
758
760
759
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
761
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
760
        "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id);
762
        "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note);
761
763
762
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
764
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
763
765
764
    return;
766
    return;
765
}
767
}
766
768
767
=head2 WriteOff
769
=head2 WriteOffFee
768
770
769
  WriteOff( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount, $branch );
771
  WriteOffFee( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount, $branch, $payment_note );
770
772
771
Write off a fine for a patron.
773
Write off a fine for a patron.
772
C<$borrowernumber> is the patron's borrower number.
774
C<$borrowernumber> is the patron's borrower number.
Lines 775-785 C<$itemnum> is the itemnumber of of item whose fine is being written off. Link Here
775
C<$accounttype> is the account type of the fine being written off.
777
C<$accounttype> is the account type of the fine being written off.
776
C<$amount> is a floating-point number, giving the amount that is being written off.
778
C<$amount> is a floating-point number, giving the amount that is being written off.
777
C<$branch> is the branchcode of the library where the writeoff occurred.
779
C<$branch> is the branchcode of the library where the writeoff occurred.
780
C<$payment_note> is the note to attach to this payment
778
781
779
=cut
782
=cut
780
783
781
sub WriteOffFee {
784
sub WriteOffFee {
782
    my ( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount, $branch ) = @_;
785
    my ( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount, $branch, $payment_note ) = @_;
786
    $payment_note //= "";
783
    $branch ||= C4::Context->userenv->{branch};
787
    $branch ||= C4::Context->userenv->{branch};
784
    my $manager_id = 0;
788
    my $manager_id = 0;
785
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
789
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
Lines 799-810 sub WriteOffFee { Link Here
799
803
800
    $query ="
804
    $query ="
801
        INSERT INTO accountlines
805
        INSERT INTO accountlines
802
        ( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id )
806
        ( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id, note )
803
        VALUES ( ?, ?, ?, NOW(), ?, 'Writeoff', 'W', ? )
807
        VALUES ( ?, ?, ?, NOW(), ?, 'Writeoff', 'W', ?, ? )
804
    ";
808
    ";
805
    $sth = $dbh->prepare( $query );
809
    $sth = $dbh->prepare( $query );
806
    my $acct = getnextacctno($borrowernumber);
810
    my $acct = getnextacctno($borrowernumber);
807
    $sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id );
811
    $sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id, $payment_note );
808
812
809
    UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber );
813
    UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber );
810
814
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (-1 / +3 lines)
Lines 47-53 Link Here
47
    <th>Fines &amp; charges</th>
47
    <th>Fines &amp; charges</th>
48
    <th>Sel</th>
48
    <th>Sel</th>
49
	<th>Description</th>
49
	<th>Description</th>
50
    <th>Account type</th>
50
    <th>Payment note</th>
51
	<th>Account ype</th>
51
	<th>Notify id</th>
52
	<th>Notify id</th>
52
	<th>Level</th>
53
	<th>Level</th>
53
	<th>Amount</th>
54
	<th>Amount</th>
Lines 86-91 Link Here
86
    [% END %]
87
    [% END %]
87
    </td>
88
    </td>
88
    <td>[% line.description %] [% line.title |html_entity %]</td>
89
    <td>[% line.description %] [% line.title |html_entity %]</td>
90
    <td><input type="text" name="payment_note_[% line.accountno %]"></input></td>
89
    <td>[% line.accounttype %]</td>
91
    <td>[% line.accounttype %]</td>
90
    <td>[% line.notify_id %]</td>
92
    <td>[% line.notify_id %]</td>
91
    <td>[% line.notify_level %]</td>
93
    <td>[% line.notify_level %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+2 lines)
Lines 106-111 function moneyFormat(textObj) { Link Here
106
106
107
<fieldset class="rows">
107
<fieldset class="rows">
108
    <legend>Pay an individual fine</legend>
108
    <legend>Pay an individual fine</legend>
109
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
109
    <table>
110
    <table>
110
    <thead><tr>
111
    <thead><tr>
111
            <th>Description</th>
112
            <th>Description</th>
Lines 158-163 function moneyFormat(textObj) { Link Here
158
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
159
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
159
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
160
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
160
    <input type="hidden" name="title" id="title" value="[% title %]" />
161
    <input type="hidden" name="title" id="title" value="[% title %]" />
162
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
161
    <table>
163
    <table>
162
    <thead><tr>
164
    <thead><tr>
163
            <th>Description</th>
165
            <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, $accountno, $itemno, $account_type, $amount, $branch );
91
    my $payment_note = $input->param("payment_note");
92
    WriteOffFee( $borrowernumber, $accountno, $itemno, $account_type, $amount, $branch, $payment_note );
91
}
93
}
92
94
93
for (@names) {
95
for (@names) {
Lines 162-172 sub redirect_to_paycollect { Link Here
162
    $redirect .=
164
    $redirect .=
163
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
165
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
164
    $redirect .= get_for_redirect( 'accountno',    "accountno$line_no",    0 );
166
    $redirect .= get_for_redirect( 'accountno',    "accountno$line_no",    0 );
165
    $redirect .= get_for_redirect( 'description',  "description$line_no",  0 );
166
    $redirect .= get_for_redirect( 'title',        "title$line_no",        0 );
167
    $redirect .= get_for_redirect( 'title',        "title$line_no",        0 );
167
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
168
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
168
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
169
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
169
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
170
    $redirect .= get_for_redirect( 'notify_level', "notify_level$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 184-190 sub writeoff_all { Link Here
184
            my $itemno    = $input->param("itemnumber$value");
186
            my $itemno    = $input->param("itemnumber$value");
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
            WriteOffFee( $borrowernumber, $accountno, $itemno, $accounttype, $amount, $branch );
189
            my $payment_note = $input->param("payment_note_$value");
190
            WriteOffFee( $borrowernumber, $accountno, $itemno, $accounttype, $amount, $branch, $payment_note );
188
        }
191
        }
189
    }
192
    }
190
193
(-)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
61
60
if ( $individual || $writeoff ) {
62
if ( $individual || $writeoff ) {
Lines 83-88 if ( $individual || $writeoff ) { Link Here
83
        description       => $description,
85
        description       => $description,
84
        notify_id         => $notify_id,
86
        notify_id         => $notify_id,
85
        notify_level      => $notify_level,
87
        notify_level      => $notify_level,
88
        payment_note    => $payment_note,
86
    );
89
    );
87
} elsif ($select_lines) {
90
} elsif ($select_lines) {
88
    $total_due = $input->param('amt');
91
    $total_due = $input->param('amt');
Lines 102-111 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
102
        if ($individual) {
105
        if ($individual) {
103
            if ( $total_paid == $total_due ) {
106
            if ( $total_paid == $total_due ) {
104
                makepayment( $borrowernumber, $accountno, $total_paid, $user,
107
                makepayment( $borrowernumber, $accountno, $total_paid, $user,
105
                    $branch );
108
                    $branch, $payment_note );
106
            } else {
109
            } else {
107
                makepartialpayment( $borrowernumber, $accountno, $total_paid,
110
                makepartialpayment( $borrowernumber, $accountno, $total_paid,
108
                    $user, $branch );
111
                    $user, $branch, $payment_note );
109
            }
112
            }
110
            print $input->redirect(
113
            print $input->redirect(
111
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
114
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
112
- 

Return to bug 6413