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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (+10 lines)
Lines 51-57 Link Here
51
<tfoot>
51
<tfoot>
52
<tr>
52
<tr>
53
    <td class="total" colspan="6">Total due:</td>
53
    <td class="total" colspan="6">Total due:</td>
54
[% IF outstanding_credits.total_outstanding < 0 %]
55
    <td style="text-align: right;">[% total + outstanding_credits.total_outstanding | $Price %]</td>
56
[% ELSE %]
54
    <td style="text-align: right;">[% total | $Price %]</td>
57
    <td style="text-align: right;">[% total | $Price %]</td>
58
[% END %]
55
</tr>
59
</tr>
56
</tfoot>
60
</tfoot>
57
<tbody>
61
<tbody>
Lines 108-113 Link Here
108
    <td class="debit" style="text-align: right;">[% line.amountoutstanding | $Price %]</td>
112
    <td class="debit" style="text-align: right;">[% line.amountoutstanding | $Price %]</td>
109
</tr>
113
</tr>
110
[% END %]
114
[% END %]
115
[% IF outstanding_credits.total_outstanding < 0 %]
116
<tr>
117
    <td class="total" colspan="6">Outstanding credits could be applied <input type="submit" id="apply_credits" name="apply_credits"  value="Apply credits" class="submit" /></td>
118
    <td class="credit" style="text-align: right;">[% outstanding_credits.total_outstanding | $Price %]</td>
119
</tr>
120
[% END %]
111
[% IF ( account_grp.total ) %]
121
[% IF ( account_grp.total ) %]
112
<tr>
122
<tr>
113
123
(-)a/members/pay.pl (-2 / +19 lines)
Lines 88-93 if ($payselected) { Link Here
88
my $writeoff_all = $input->param('woall');    # writeoff all fines
88
my $writeoff_all = $input->param('woall');    # writeoff all fines
89
if ($writeoff_all) {
89
if ($writeoff_all) {
90
    writeoff_all(@names);
90
    writeoff_all(@names);
91
} elsif ( $input->param('apply_credits') ) {
92
    apply_credits({ patron => $patron, cgi => $input });
91
} elsif ($writeoff_item) {
93
} elsif ($writeoff_item) {
92
    my $accountlines_id = $input->param('accountlines_id');
94
    my $accountlines_id = $input->param('accountlines_id');
93
    my $amount       = $input->param('amountwrittenoff');
95
    my $amount       = $input->param('amountwrittenoff');
Lines 141-147 output_html_with_http_headers $input, $cookie, $template->output; Link Here
141
sub add_accounts_to_template {
143
sub add_accounts_to_template {
142
144
143
    my $patron = Koha::Patrons->find( $borrowernumber );
145
    my $patron = Koha::Patrons->find( $borrowernumber );
144
    my $account_lines = $patron->account->outstanding_debits;
146
    my $account = $patron->account;
147
    my $outstanding_credits = $account->outstanding_credits;
148
    my $account_lines = $account->outstanding_debits;
145
    my $total = $account_lines->total_outstanding;
149
    my $total = $account_lines->total_outstanding;
146
    my @accounts;
150
    my @accounts;
147
    while ( my $account_line = $account_lines->next ) {
151
    while ( my $account_line = $account_lines->next ) {
Lines 160-166 sub add_accounts_to_template { Link Here
160
        patron   => $patron,
164
        patron   => $patron,
161
        accounts => \@accounts,
165
        accounts => \@accounts,
162
        total    => $total,
166
        total    => $total,
167
        outstanding_credits => $outstanding_credits
163
    );
168
    );
169
164
    return;
170
    return;
165
171
166
}
172
}
Lines 279-281 sub payselected { Link Here
279
    print $input->redirect($redirect);
285
    print $input->redirect($redirect);
280
    return;
286
    return;
281
}
287
}
282
- 
288
289
sub apply_credits {
290
    my ($args) = @_;
291
292
    my $patron = $args->{patron};
293
    my $cgi    = $args->{cgi};
294
295
    $patron->account->reconcile_balance();
296
297
    print $cgi->redirect("/cgi-bin/koha/members/pay.pl?borrowernumber=" . $patron->borrowernumber );
298
    return;
299
}

Return to bug 18805