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

(-)a/C4/Members.pm (-2 / +6 lines)
Lines 181-187 sub patronflags { Link Here
181
    my %flags;
181
    my %flags;
182
    my ( $patroninformation) = @_;
182
    my ( $patroninformation) = @_;
183
    my $dbh=C4::Context->dbh;
183
    my $dbh=C4::Context->dbh;
184
    my ($balance, $owing) = GetMemberAccountBalance( $patroninformation->{'borrowernumber'});
184
185
    my $patron = Koha::Patrons->find( $patroninformation->{borrowernumber} );
186
    my $account = $patron->account;
187
    my $owing = $account->non_issues_charges;
188
185
    if ( $owing > 0 ) {
189
    if ( $owing > 0 ) {
186
        my %flaginfo;
190
        my %flaginfo;
187
        my $noissuescharge = C4::Context->preference("noissuescharge") || 5;
191
        my $noissuescharge = C4::Context->preference("noissuescharge") || 5;
Lines 192-198 sub patronflags { Link Here
192
        }
196
        }
193
        $flags{'CHARGES'} = \%flaginfo;
197
        $flags{'CHARGES'} = \%flaginfo;
194
    }
198
    }
195
    elsif ( $balance < 0 ) {
199
    elsif ( ( my $balance = $account->balance ) < 0 ) {
196
        my %flaginfo;
200
        my %flaginfo;
197
        $flaginfo{'message'} = sprintf 'Patron has credit of %.02f', -$balance;
201
        $flaginfo{'message'} = sprintf 'Patron has credit of %.02f', -$balance;
198
        $flaginfo{'amount'}  = sprintf "%.02f", $balance;
202
        $flaginfo{'amount'}  = sprintf "%.02f", $balance;
(-)a/Koha/Account.pm (+38 lines)
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 286-291 sub balance { Link Here
286
      : 0;
287
      : 0;
287
}
288
}
288
289
290
sub non_issues_charges {
291
    my ($self) = @_;
292
293
    # FIXME REMOVE And add a warning in the about page + update DB if length(MANUAL_INV) > 5
294
    my $ACCOUNT_TYPE_LENGTH = 5;    # this is plain ridiculous...
295
296
    my @not_fines;
297
    push @not_fines, 'Res'
298
      unless C4::Context->preference('HoldsInNoissuesCharge');
299
    push @not_fines, 'Rent'
300
      unless C4::Context->preference('RentalsInNoissuesCharge');
301
    unless ( C4::Context->preference('ManInvInNoissuesCharge') ) {
302
        my $dbh = C4::Context->dbh;
303
        push @not_fines,
304
          @{
305
            $dbh->selectcol_arrayref(q|
306
                SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'
307
            |)
308
          };
309
    }
310
    @not_fines = map { substr( $_, 0, $ACCOUNT_TYPE_LENGTH ) } uniq(@not_fines);
311
312
    my $non_issues_charges = Koha::Account::Lines->search(
313
        {
314
            borrowernumber => $self->{patron_id},
315
            accounttype    => { -not_in => \@not_fines }
316
        },
317
        {
318
            select => [ { sum => 'amountoutstanding' } ],
319
            as     => ['non_issues_charges'],
320
        }
321
    );
322
    return $non_issues_charges->count
323
      ? $non_issues_charges->next->get_column('non_issues_charges') + 0
324
      : 0;
325
}
326
289
1;
327
1;
290
328
291
=head1 AUTHOR
329
=head1 AUTHOR
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 543-549 foreach my $flag ( sort keys %$flags ) { Link Here
543
my $amountold = $flags ? $flags->{'CHARGES'}->{'message'} || 0 : 0;
543
my $amountold = $flags ? $flags->{'CHARGES'}->{'message'} || 0 : 0;
544
$amountold =~ s/^.*\$//;    # remove upto the $, if any
544
$amountold =~ s/^.*\$//;    # remove upto the $, if any
545
545
546
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
546
my $total = $patron ? $patron->account->balance : 0;
547
547
548
if ( $patron && $patron->category->category_type eq 'C') {
548
if ( $patron && $patron->category->category_type eq 'C') {
549
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
549
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
(-)a/opac/opac-main.pl (-1 / +3 lines)
Lines 29-34 use C4::Members; Link Here
29
use C4::Overdues;
29
use C4::Overdues;
30
use Koha::Checkouts;
30
use Koha::Checkouts;
31
use Koha::Holds;
31
use Koha::Holds;
32
use Koha::Patrons;
32
33
33
my $input = new CGI;
34
my $input = new CGI;
34
my $dbh   = C4::Context->dbh;
35
my $dbh   = C4::Context->dbh;
Lines 72-78 if ( defined $borrowernumber ){ Link Here
72
    my ( $overdues_count, $overdues ) = checkoverdues($borrowernumber);
73
    my ( $overdues_count, $overdues ) = checkoverdues($borrowernumber);
73
    my $holds_pending = Koha::Holds->search({ borrowernumber => $borrowernumber, found => undef })->count;
74
    my $holds_pending = Koha::Holds->search({ borrowernumber => $borrowernumber, found => undef })->count;
74
    my $holds_waiting = Koha::Holds->search({ borrowernumber => $borrowernumber })->waiting->count;
75
    my $holds_waiting = Koha::Holds->search({ borrowernumber => $borrowernumber })->waiting->count;
75
    my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
76
    my $patron = Koha::Patrons->find( $borrowernumber );
77
    my $total = $patron ? $patron->account->balance : 0;
76
78
77
    if  ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 ) {
79
    if  ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 ) {
78
        $template->param( dashboard_info => 1 );
80
        $template->param( dashboard_info => 1 );
(-)a/opac/opac-reserve.pl (-1 / +2 lines)
Lines 329-335 if ( $query->param('place_reserve') ) { Link Here
329
my $noreserves     = 0;
329
my $noreserves     = 0;
330
my $maxoutstanding = C4::Context->preference("maxoutstanding");
330
my $maxoutstanding = C4::Context->preference("maxoutstanding");
331
$template->param( noreserve => 1 ) unless $maxoutstanding;
331
$template->param( noreserve => 1 ) unless $maxoutstanding;
332
my ( $amountoutstanding ) = GetMemberAccountRecords($borrowernumber);
332
my $amountoutstanding = $patron ? $patron->account->balance : 0;
333
333
if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
334
if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
334
    my $amount = sprintf "%.02f", $amountoutstanding;
335
    my $amount = sprintf "%.02f", $amountoutstanding;
335
    $template->param( message => 1 );
336
    $template->param( message => 1 );
(-)a/opac/opac-user.pl (-1 / +3 lines)
Lines 116-122 if ( $userdebarred || $borr->{'gonenoaddress'} || $borr->{'lost'} ) { Link Here
116
    $canrenew = 0;
116
    $canrenew = 0;
117
}
117
}
118
118
119
my ( $amountoutstanding ) = GetMemberAccountRecords($borrowernumber);
119
my $patron = Koha::Patrons->find( $borrowernumber );
120
my $amountoutstanding = $patron ? $patron->account->balance : 0;
121
120
if ( $amountoutstanding > 5 ) {
122
if ( $amountoutstanding > 5 ) {
121
    $borr->{'amountoverfive'} = 1;
123
    $borr->{'amountoverfive'} = 1;
122
}
124
}
(-)a/reserve/request.pl (-2 / +1 lines)
Lines 198-204 if ($borrowernumber_hold && !$action) { Link Here
198
                messages            => $messages,
198
                messages            => $messages,
199
                warnings            => $warnings,
199
                warnings            => $warnings,
200
                restricted          => $is_debarred,
200
                restricted          => $is_debarred,
201
                amount_outstanding  => GetMemberAccountRecords($patron->borrowernumber),
201
                amount_outstanding  => $patron->account->balance,
202
    );
202
    );
203
}
203
}
204
204
205
- 

Return to bug 12001