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

(-)a/C4/Accounts.pm (-8 / +10 lines)
Lines 157-163 sub makepayment { Link Here
157
    #here we update both the accountoffsets and the account lines
157
    #here we update both the accountoffsets and the account lines
158
    #updated to check, if they are paying off a lost item, we return the item
158
    #updated to check, if they are paying off a lost item, we return the item
159
    # from their card, and put a note on the item record
159
    # from their card, and put a note on the item record
160
    my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
160
    my ( $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
161
    my $dbh = C4::Context->dbh;
161
    my $dbh = C4::Context->dbh;
162
    my $manager_id = 0;
162
    my $manager_id = 0;
163
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
163
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
Lines 197-210 sub makepayment { Link Here
197
197
198
         # create new line
198
         # create new line
199
        my $payment = 0 - $amount;
199
        my $payment = 0 - $amount;
200
        $payment_note = "" unless defined $payment_note;
200
        
201
        
201
        my $ins = 
202
        my $ins = 
202
            $dbh->prepare( 
203
            $dbh->prepare( 
203
                "INSERT 
204
                "INSERT 
204
                    INTO accountlines (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding)
205
                    INTO accountlines (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, note)
205
                    VALUES ( ?, ?, now(), ?, 'Payment,thanks', 'Pay', 0)"
206
                    VALUES ( ?, ?, now(), ?, 'Payment,thanks', 'Pay', 0, ?)"
206
            );
207
            );
207
        $ins->execute($borrowernumber, $nextaccntno, $payment);
208
        $ins->execute($borrowernumber, $nextaccntno, $payment, $payment_note);
208
        $ins->finish;
209
        $ins->finish;
209
    }
210
    }
210
211
Lines 724-733 sub recordpayment_selectaccts { Link Here
724
# makepayment needs to be fixed to handle partials till then this separate subroutine
725
# makepayment needs to be fixed to handle partials till then this separate subroutine
725
# fills in
726
# fills in
726
sub makepartialpayment {
727
sub makepartialpayment {
727
    my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
728
    my ( $borrowernumber, $accountno, $amount, $user, $branchm, $payment_note ) = @_;
728
    if (!$amount || $amount < 0) {
729
    if (!$amount || $amount < 0) {
729
        return;
730
        return;
730
    }
731
    }
732
    $payment_note = "" unless defined $payment_note;
731
    my $dbh = C4::Context->dbh;
733
    my $dbh = C4::Context->dbh;
732
734
733
    my $nextaccntno = getnextacctno($borrowernumber);
735
    my $nextaccntno = getnextacctno($borrowernumber);
Lines 743-753 sub makepartialpayment { Link Here
743
745
744
    # create new line
746
    # create new line
745
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
747
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
746
    .  'description, accounttype, amountoutstanding) '
748
    .  'description, accounttype, amountoutstanding, note) '
747
    . ' VALUES (?, ?, now(), ?, ?, ?, 0)';
749
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?)';
748
750
749
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
751
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
750
        "Payment, thanks - $user", 'Pay');
752
        "Payment, thanks - $user", 'Pay', $payment_note);
751
753
752
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
754
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
753
755
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (+2 lines)
Lines 34-39 Link Here
34
	<th>Fines &amp; Charges</th>
34
	<th>Fines &amp; Charges</th>
35
    <th>Sel</th>
35
    <th>Sel</th>
36
	<th>Description</th>
36
	<th>Description</th>
37
    <th>Payment Note</th>   
37
	<th>Account Type</th>
38
	<th>Account Type</th>
38
	<th>Notify id</th>
39
	<th>Notify id</th>
39
	<th>Level</th>
40
	<th>Level</th>
Lines 66-71 Link Here
66
    [% END %]
67
    [% END %]
67
    </td>
68
    </td>
68
    <td>[% line.description %] [% line.title |html_entity %]</td>
69
    <td>[% line.description %] [% line.title |html_entity %]</td>
70
    <td><input type="text" name="payment_note_[% line.accountno %]"></input></td>
69
    <td>[% line.accounttype %]</td>
71
    <td>[% line.accounttype %]</td>
70
    <td>[% line.notify_id %]</td>
72
    <td>[% line.notify_id %]</td>
71
    <td>[% line.notify_level %]</td>
73
    <td>[% line.notify_level %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+2 lines)
Lines 102-107 function moneyFormat(textObj) { Link Here
102
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
102
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
103
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
103
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
104
    <input type="hidden" name="title" id="title" value="[% title %]" />
104
    <input type="hidden" name="title" id="title" value="[% title %]" />
105
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
105
    <table>
106
    <table>
106
    <tr>
107
    <tr>
107
        <th>Description</th>
108
        <th>Description</th>
Lines 156-161 function moneyFormat(textObj) { Link Here
156
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
157
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
157
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
158
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
158
    <input type="hidden" name="title" id="title" value="[% title %]" />
159
    <input type="hidden" name="title" id="title" value="[% title %]" />
160
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
159
    <table>
161
    <table>
160
    <tr>
162
    <tr>
161
        <th>Description</th>
163
        <th>Description</th>
(-)a/members/pay.pl (-6 / +10 lines)
Lines 90-96 if ($writeoff_all) { Link Here
90
    my $itemno       = $input->param('itemnumber');
90
    my $itemno       = $input->param('itemnumber');
91
    my $account_type = $input->param('accounttype');
91
    my $account_type = $input->param('accounttype');
92
    my $amount       = $input->param('amount');
92
    my $amount       = $input->param('amount');
93
    writeoff( $accountno, $itemno, $account_type, $amount );
93
    my $payment_note = $input->param("payment_note");
94
    writeoff( $accountno, $itemno, $account_type, $amount, $payment_note );
94
}
95
}
95
96
96
for (@names) {
97
for (@names) {
Lines 108-114 add_accounts_to_template(); Link Here
108
output_html_with_http_headers $input, $cookie, $template->output;
109
output_html_with_http_headers $input, $cookie, $template->output;
109
110
110
sub writeoff {
111
sub writeoff {
111
    my ( $accountnum, $itemnum, $accounttype, $amount ) = @_;
112
    my ( $accountnum, $itemnum, $accounttype, $amount, $payment_note ) = @_;
113
    $payment_note = "" unless defined $payment_note;
112
114
113
    # if no item is attached to fine, make sure to store it as a NULL
115
    # if no item is attached to fine, make sure to store it as a NULL
114
    $itemnum ||= undef;
116
    $itemnum ||= undef;
Lines 116-122 sub writeoff { Link Here
116
    $writeoff_sth->execute( $accountnum, $borrowernumber );
118
    $writeoff_sth->execute( $accountnum, $borrowernumber );
117
119
118
    my $acct = getnextacctno($borrowernumber);
120
    my $acct = getnextacctno($borrowernumber);
119
    $add_writeoff_sth->execute( $borrowernumber, $acct, $itemnum, $amount );
121
    $add_writeoff_sth->execute( $borrowernumber, $acct, $itemnum, $amount, $payment_note);
120
122
121
    UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber );
123
    UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber );
122
124
Lines 183-188 sub redirect_to_paycollect { Link Here
183
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
185
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
184
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
186
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
185
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
187
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
188
    $redirect .= get_for_redirect( 'payment_note', "payment_note_$line_no", 0);
186
    $redirect .= '&remote_user=';
189
    $redirect .= '&remote_user=';
187
    $redirect .= $user;
190
    $redirect .= $user;
188
    return print $input->redirect($redirect);
191
    return print $input->redirect($redirect);
Lines 200-206 sub writeoff_all { Link Here
200
            my $itemno    = $input->param("itemnumber$value");
203
            my $itemno    = $input->param("itemnumber$value");
201
            my $amount    = $input->param("amount$value");
204
            my $amount    = $input->param("amount$value");
202
            my $accountno = $input->param("accountno$value");
205
            my $accountno = $input->param("accountno$value");
203
            writeoff( $accountno, $itemno, $accounttype, $amount );
206
            my $payment_note = $input->param("payment_note_$value");
207
            writeoff( $accountno, $itemno, $accounttype, $amount, $payment_note );
204
        }
208
        }
205
    }
209
    }
206
210
Lines 280-287 sub get_writeoff_sth { Link Here
280
          . 'WHERE accountno=? and borrowernumber=?';
284
          . 'WHERE accountno=? and borrowernumber=?';
281
        $writeoff_sth = $dbh->prepare($sql);
285
        $writeoff_sth = $dbh->prepare($sql);
282
        my $insert =
286
        my $insert =
283
q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)}
287
q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,note)}
284
          . q{values (?,?,?,now(),?,'Writeoff','W')};
288
          . q{values (?,?,?,now(),?,'Writeoff','W',?)};
285
        $add_writeoff_sth = $dbh->prepare($insert);
289
        $add_writeoff_sth = $dbh->prepare($insert);
286
    }
290
    }
287
    return;
291
    return;
(-)a/members/paycollect.pl (-4 / +5 lines)
Lines 55-60 my $individual = $input->param('pay_individual'); Link Here
55
my $writeoff     = $input->param('writeoff_individual');
55
my $writeoff     = $input->param('writeoff_individual');
56
my $select_lines = $input->param('selected');
56
my $select_lines = $input->param('selected');
57
my $select       = $input->param('selected_accts');
57
my $select       = $input->param('selected_accts');
58
my $payment_note = $input->param('payment_note');
58
my $accountno;
59
my $accountno;
59
60
60
if ( $individual || $writeoff ) {
61
if ( $individual || $writeoff ) {
Lines 81-86 if ( $individual || $writeoff ) { Link Here
81
        description       => $description,
82
        description       => $description,
82
        notify_id         => $notify_id,
83
        notify_id         => $notify_id,
83
        notify_level      => $notify_level,
84
        notify_level      => $notify_level,
85
        payment_note    => $payment_note,
84
    );
86
    );
85
} elsif ($select_lines) {
87
} elsif ($select_lines) {
86
    $total_due = $input->param('amt');
88
    $total_due = $input->param('amt');
Lines 98-109 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
98
        );
100
        );
99
    } else {
101
    } else {
100
        if ($individual) {
102
        if ($individual) {
101
            if ( $total_paid == $total_due ) {
103
            if ( $total_paid == $total_due ) { 
102
                makepayment( $borrowernumber, $accountno, $total_paid, $user,
104
                makepayment( $borrowernumber, $accountno, $total_paid, $user,
103
                    $branch );
105
                    $branch, $payment_note );
104
            } else {
106
            } else {
105
                makepartialpayment( $borrowernumber, $accountno, $total_paid,
107
                makepartialpayment( $borrowernumber, $accountno, $total_paid,
106
                    $user, $branch );
108
                    $user, $branch, $payment_note );
107
            }
109
            }
108
            print $input->redirect(
110
            print $input->redirect(
109
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
111
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
110
- 

Return to bug 6413