|
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 |
my @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 |
if ( $total_paid < 0 or $total_paid > $total_due ) { |
161 |
if ( $total_paid < 0 or $total_paid > $total_due ) { |
| 141 |
$template->param( |
162 |
$template->param( |
|
Lines 166-198
if ( $total_paid and $total_paid ne '0.00' ) {
Link Here
|
| 166 |
"/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=$change_given"); |
187 |
"/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=$change_given"); |
| 167 |
} else { |
188 |
} else { |
| 168 |
if ($selected_accts) { |
189 |
if ($selected_accts) { |
| 169 |
if ( $selected_accts =~ /^([\d,]*).*/ ) { |
190 |
if ( $total_paid > $total_due ) { |
| 170 |
$selected_accts = $1; # ensure passing no junk |
191 |
$template->param( |
|
|
192 |
error_over => 1, |
| 193 |
total_due => $total_due |
| 194 |
); |
| 195 |
} else { |
| 196 |
my $note = $input->param('selected_accts_notes'); |
| 197 |
|
| 198 |
$payment_id = $account->pay( |
| 199 |
{ |
| 200 |
type => $type, |
| 201 |
amount => $total_paid, |
| 202 |
library_id => $library_id, |
| 203 |
lines => \@selected_accountlines, |
| 204 |
note => $note, |
| 205 |
interface => C4::Context->interface, |
| 206 |
payment_type => $payment_type, |
| 207 |
cash_register => $registerid |
| 208 |
} |
| 209 |
); |
| 171 |
} |
210 |
} |
| 172 |
my @acc = split /,/, $selected_accts; |
|
|
| 173 |
my $note = $input->param('selected_accts_notes'); |
| 174 |
|
| 175 |
my @lines = Koha::Account::Lines->search( |
| 176 |
{ |
| 177 |
borrowernumber => $borrowernumber, |
| 178 |
amountoutstanding => { '<>' => 0 }, |
| 179 |
accountlines_id => { 'IN' => \@acc }, |
| 180 |
}, |
| 181 |
{ order_by => 'date' } |
| 182 |
); |
| 183 |
|
| 184 |
$payment_id = $account->pay( |
| 185 |
{ |
| 186 |
type => $type, |
| 187 |
amount => $total_paid, |
| 188 |
library_id => $library_id, |
| 189 |
lines => \@lines, |
| 190 |
note => $note, |
| 191 |
interface => C4::Context->interface, |
| 192 |
payment_type => $payment_type, |
| 193 |
cash_register => $registerid |
| 194 |
} |
| 195 |
); |
| 196 |
} |
211 |
} |
| 197 |
else { |
212 |
else { |
| 198 |
my $note = $input->param('selected_accts_notes'); |
213 |
my $note = $input->param('selected_accts_notes'); |
| 199 |
- |
|
|