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

(-)a/C4/Accounts.pm (-15 / +19 lines)
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-776 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
768
    return;
770
    return;
769
}
771
}
770
772
771
=head2 WriteOff
773
=head2 WriteOffFee
772
774
773
  WriteOff( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount, $branch );
775
  WriteOffFee( $borrowernumber, $accountnum, $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, $accountnum, $itemnum, $accounttype, $amount, $branch ) = @_;
789
    my ( $borrowernumber, $accountnum, $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
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (+2 lines)
Lines 47-52 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>Payment Note</th>
50
    <th>Account type</th>
51
    <th>Account type</th>
51
	<th>Notify id</th>
52
	<th>Notify id</th>
52
	<th>Level</th>
53
	<th>Level</th>
Lines 87-92 Link Here
87
    [% END %]
88
    [% END %]
88
    </td>
89
    </td>
89
    <td>[% line.description %] ([% line.title |html_entity %])</td>
90
    <td>[% line.description %] ([% line.title |html_entity %])</td>
91
    <td><input type="text" name="payment_note_[% line.accountno %]"></input></td>
90
    <td>[% line.accounttype %]</td>
92
    <td>[% line.accounttype %]</td>
91
    <td>[% line.notify_id %]</td>
93
    <td>[% line.notify_id %]</td>
92
    <td>[% line.notify_level %]</td>
94
    <td>[% line.notify_level %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+2 lines)
Lines 107-112 function moneyFormat(textObj) { Link Here
107
107
108
<fieldset class="rows">
108
<fieldset class="rows">
109
    <legend>Pay an individual fine</legend>
109
    <legend>Pay an individual fine</legend>
110
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
110
    <table>
111
    <table>
111
    <thead><tr>
112
    <thead><tr>
112
            <th>Description</th>
113
            <th>Description</th>
Lines 160-165 function moneyFormat(textObj) { Link Here
160
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
161
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
161
    <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
162
    <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
162
    <input type="hidden" name="title" id="title" value="[% title %]" />
163
    <input type="hidden" name="title" id="title" value="[% title %]" />
164
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
163
    <table>
165
    <table>
164
    <thead><tr>
166
    <thead><tr>
165
            <th>Description</th>
167
            <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 89-95 if ($writeoff_all) { Link Here
89
    my $itemno       = $input->param('itemnumber');
90
    my $itemno       = $input->param('itemnumber');
90
    my $account_type = $input->param('accounttype');
91
    my $account_type = $input->param('accounttype');
91
    my $amount       = $input->param('amountoutstanding');
92
    my $amount       = $input->param('amountoutstanding');
92
    WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $account_type, $amount, $branch );
93
    my $payment_note = $input->param("payment_note");
94
    WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $account_type, $amount, $branch, $payment_note );
93
}
95
}
94
96
95
for (@names) {
97
for (@names) {
Lines 181-192 sub redirect_to_paycollect { Link Here
181
    $redirect .=
183
    $redirect .=
182
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
184
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
183
    $redirect .= get_for_redirect( 'accountno',    "accountno$line_no",    0 );
185
    $redirect .= get_for_redirect( 'accountno',    "accountno$line_no",    0 );
184
    $redirect .= get_for_redirect( 'description',  "description$line_no",  0 );
185
    $redirect .= get_for_redirect( 'title',        "title$line_no",        0 );
186
    $redirect .= get_for_redirect( 'title',        "title$line_no",        0 );
186
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
187
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
187
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
188
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
188
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
189
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
189
    $redirect .= get_for_redirect( 'accountlines_id', "accountlines_id$line_no", 0 );
190
    $redirect .= get_for_redirect( 'accountlines_id', "accountlines_id$line_no", 0 );
191
    $redirect .= q{&} . 'payment_note' . q{=} . uri_escape( $input->param("payment_note_$line_no") );
190
    $redirect .= '&remote_user=';
192
    $redirect .= '&remote_user=';
191
    $redirect .= $user;
193
    $redirect .= $user;
192
    return print $input->redirect($redirect);
194
    return print $input->redirect($redirect);
Lines 205-211 sub writeoff_all { Link Here
205
            my $amount    = $input->param("amountoutstanding$value");
207
            my $amount    = $input->param("amountoutstanding$value");
206
            my $accountno = $input->param("accountno$value");
208
            my $accountno = $input->param("accountno$value");
207
            my $accountlines_id = $input->param("accountlines_id$value");
209
            my $accountlines_id = $input->param("accountlines_id$value");
208
            WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $accounttype, $amount, $branch );
210
            my $payment_note = $input->param("payment_note_$value");
211
            WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $accounttype, $amount, $branch, $payment_note );
209
        }
212
        }
210
    }
213
    }
211
214
(-)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