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

(-)a/members/paycollect.pl (-29 / +43 lines)
Lines 69-77 my $total_due = $account->outstanding_debits->total_outstanding; Link Here
69
69
70
my $total_paid = $input->param('paid');
70
my $total_paid = $input->param('paid');
71
71
72
my $selected_lines = $input->param('selected');
72
my $selected_lines = $input->param('selected'); # comes from pay.pl
73
my $pay_individual   = $input->param('pay_individual');
73
my $pay_individual   = $input->param('pay_individual');
74
my $selected_accts   = $input->param('selected_accts');
74
my $selected_accts   = $input->param('selected_accts'); # comes from paycollect.pl
75
my $payment_note = uri_unescape scalar $input->param('payment_note');
75
my $payment_note = uri_unescape scalar $input->param('payment_note');
76
my $payment_type = scalar $input->param('payment_type');
76
my $payment_type = scalar $input->param('payment_type');
77
my $accountlines_id;
77
my $accountlines_id;
Lines 136-141 if ( $pay_individual || $writeoff_individual ) { Link Here
136
    );
136
    );
137
}
137
}
138
138
139
my @selected_accountlines;
140
if ( $selected_accts ) {
141
    if ( $selected_accts =~ /^([\d,]*).*/ ) {
142
        $selected_accts = $1;    # ensure passing no junk
143
    }
144
    my @acc = split /,/, $selected_accts;
145
146
    @selected_accountlines = koha::account::lines->search(
147
        {
148
            borrowernumber    => $borrowernumber,
149
            amountoutstanding => { '<>' => 0 },
150
            accountlines_id   => { 'in' => \@acc },
151
        },
152
        { order_by => 'date' }
153
    );
154
155
    $total_due = 0; # Reset and recalculate total due
156
    map { $total_due += $_->amountoutstanding } @selected_accountlines;
157
}
158
159
139
if ( $total_paid and $total_paid ne '0.00' ) {
160
if ( $total_paid and $total_paid ne '0.00' ) {
140
    $total_paid = $total_due if (abs($total_paid - $total_due) < 0.01) && C4::Context->preference('RoundFinesAtPayment');
161
    $total_paid = $total_due if (abs($total_paid - $total_due) < 0.01) && C4::Context->preference('RoundFinesAtPayment');
141
    if ( $total_paid < 0 or $total_paid > $total_due ) {
162
    if ( $total_paid < 0 or $total_paid > $total_due ) {
Lines 167-199 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
167
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=$change_given");
188
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=$change_given");
168
        } else {
189
        } else {
169
            if ($selected_accts) {
190
            if ($selected_accts) {
170
                if ( $selected_accts =~ /^([\d,]*).*/ ) {
191
                if ( $total_paid > $total_due ) {
171
                    $selected_accts = $1;    # ensure passing no junk
192
                    $template->param(
193
                        error_over => 1,
194
                        total_due => $total_due
195
                    );
196
                } else {
197
                    my $note = $input->param('selected_accts_notes');
198
199
                    $payment_id = $account->pay(
200
                        {
201
                            type         => $type,
202
                            amount       => $total_paid,
203
                            library_id   => $library_id,
204
                            lines        => \@selected_accountlines,
205
                            note         => $note,
206
                            interface    => C4::Context->interface,
207
                            payment_type => $payment_type,
208
                            cash_register => $registerid
209
                        }
210
                      );
172
                }
211
                }
173
                my @acc = split /,/, $selected_accts;
174
                my $note = $input->param('selected_accts_notes');
175
176
                my @lines = Koha::Account::Lines->search(
177
                    {
178
                        borrowernumber    => $borrowernumber,
179
                        amountoutstanding => { '<>' => 0 },
180
                        accountlines_id   => { 'IN' => \@acc },
181
                    },
182
                    { order_by => 'date' }
183
                );
184
185
                $payment_id = $account->pay(
186
                    {
187
                        type         => $type,
188
                        amount       => $total_paid,
189
                        library_id   => $library_id,
190
                        lines        => \@lines,
191
                        note         => $note,
192
                        interface    => C4::Context->interface,
193
                        payment_type => $payment_type,
194
                        cash_register => $registerid
195
                    }
196
                  );
197
            }
212
            }
198
            else {
213
            else {
199
                my $note = $input->param('selected_accts_notes');
214
                my $note = $input->param('selected_accts_notes');
200
- 

Return to bug 23788