Lines 21-26
use Modern::Perl;
Link Here
|
21 |
|
21 |
|
22 |
use Carp; |
22 |
use Carp; |
23 |
use Data::Dumper; |
23 |
use Data::Dumper; |
|
|
24 |
use List::MoreUtils qw(uniq); |
24 |
|
25 |
|
25 |
use C4::Log qw( logaction ); |
26 |
use C4::Log qw( logaction ); |
26 |
use C4::Stats qw( UpdateStats ); |
27 |
use C4::Stats qw( UpdateStats ); |
Lines 284-289
sub balance {
Link Here
|
284 |
: 0; |
285 |
: 0; |
285 |
} |
286 |
} |
286 |
|
287 |
|
|
|
288 |
sub non_issues_charges { |
289 |
my ($self) = @_; |
290 |
|
291 |
# FIXME REMOVE And add a warning in the about page + update DB if length(MANUAL_INV) > 5 |
292 |
my $ACCOUNT_TYPE_LENGTH = 5; # this is plain ridiculous... |
293 |
|
294 |
my @not_fines; |
295 |
push @not_fines, 'Res' |
296 |
unless C4::Context->preference('HoldsInNoissuesCharge'); |
297 |
push @not_fines, 'Rent' |
298 |
unless C4::Context->preference('RentalsInNoissuesCharge'); |
299 |
unless ( C4::Context->preference('ManInvInNoissuesCharge') ) { |
300 |
my $dbh = C4::Context->dbh; |
301 |
push @not_fines, |
302 |
@{ |
303 |
$dbh->selectcol_arrayref(q| |
304 |
SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV' |
305 |
|) |
306 |
}; |
307 |
} |
308 |
@not_fines = map { substr( $_, 0, $ACCOUNT_TYPE_LENGTH ) } uniq(@not_fines); |
309 |
|
310 |
my $non_issues_charges = Koha::Account::Lines->search( |
311 |
{ |
312 |
borrowernumber => $self->{patron_id}, |
313 |
accounttype => { -not_in => \@not_fines } |
314 |
}, |
315 |
{ |
316 |
select => [ { sum => 'amountoutstanding' } ], |
317 |
as => ['non_issues_charges'], |
318 |
} |
319 |
); |
320 |
return $non_issues_charges->count |
321 |
? $non_issues_charges->next->get_column('non_issues_charges') + 0 |
322 |
: 0; |
323 |
} |
324 |
|
287 |
1; |
325 |
1; |
288 |
|
326 |
|
289 |
=head1 AUTHOR |
327 |
=head1 AUTHOR |