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

(-)a/C4/Members.pm (-3 / +1 lines)
Lines 188-196 sub GetMemberDetails { Link Here
188
    }
188
    }
189
    my $borrower = $sth->fetchrow_hashref;
189
    my $borrower = $sth->fetchrow_hashref;
190
    return unless $borrower;
190
    return unless $borrower;
191
    my ($amount) = GetMemberAccountRecords($borrower->{borrowernumber});
191
192
    $borrower->{'amountoutstanding'} = $amount;
193
    # FIXME - patronflags calls GetMemberAccountRecords... just have patronflags return $amount
194
    my $flags = patronflags( $borrower);
192
    my $flags = patronflags( $borrower);
195
    $borrower->{'flags'}     = $flags;
193
    $borrower->{'flags'}     = $flags;
196
194
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-6 / +6 lines)
Lines 129-137 Using this account is not recommended because some parts of Koha will not functi Link Here
129
                            [% IF relatives %]<li><a href="#opac-user-relative-issues">Relatives' checkouts</a></li>[% END %]
129
                            [% IF relatives %]<li><a href="#opac-user-relative-issues">Relatives' checkouts</a></li>[% END %]
130
                            [% IF ( overdues_count ) %]<li><a href="#opac-user-overdues">Overdue ([% overdues_count %])</a></li>[% END %]
130
                            [% IF ( overdues_count ) %]<li><a href="#opac-user-overdues">Overdue ([% overdues_count %])</a></li>[% END %]
131
                            [% IF ( OPACFinesTab ) %]
131
                            [% IF ( OPACFinesTab ) %]
132
                                [% IF ( BORROWER_INFO.amountoverfive ) %]<li><a href="#opac-user-fines">Fines ([% BORROWER_INFO.amountoutstanding | $Price %])</a></li>[% END %]
132
                                [% IF ( BORROWER_INFO.amountoverfive ) %]<li><a href="#opac-user-fines">Fines ([% amountoutstanding | $Price %])</a></li>[% END %]
133
                                [% IF ( BORROWER_INFO.amountoverzero ) %]<li><a href="#opac-user-fines">Fines ([% BORROWER_INFO.amountoutstanding | $Price %])</a></li>[% END %]
133
                                [% IF ( BORROWER_INFO.amountoverzero ) %]<li><a href="#opac-user-fines">Fines ([% amountoutstanding | $Price %])</a></li>[% END %]
134
                                [% IF ( BORROWER_INFO.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% BORROWER_INFO.amountoutstanding | $Price %])</a></li>[% END %]
134
                                [% IF ( BORROWER_INFO.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% amountoutstanding | $Price %])</a></li>[% END %]
135
                            [% END %]
135
                            [% END %]
136
                            [% IF ( RESERVES.count ) %]<li><a href="#opac-user-holds">Holds ([% RESERVES.count %])</a></li>[% END %]
136
                            [% IF ( RESERVES.count ) %]<li><a href="#opac-user-holds">Holds ([% RESERVES.count %])</a></li>[% END %]
137
                            [% IF Koha.Preference('ArticleRequests') && borrower.article_requests_current %]<li><a href="#opac-user-article-requests">Article requests ([% borrower.article_requests_current.count %])</a></li>[% END %]
137
                            [% IF Koha.Preference('ArticleRequests') && borrower.article_requests_current %]<li><a href="#opac-user-article-requests">Article requests ([% borrower.article_requests_current.count %])</a></li>[% END %]
Lines 319-325 Using this account is not recommended because some parts of Koha will not functi Link Here
319
                                        <tbody>
319
                                        <tbody>
320
                                            <tr>
320
                                            <tr>
321
                                                <td>You currently owe fines and charges amounting to:</td>
321
                                                <td>You currently owe fines and charges amounting to:</td>
322
                                                <td><a href="/cgi-bin/koha/opac-account.pl">[% BORROWER_INFO.amountoutstanding | $Price %]</a></td>
322
                                                <td><a href="/cgi-bin/koha/opac-account.pl">[% amountoutstanding | $Price %]</a></td>
323
                                            </tr>
323
                                            </tr>
324
                                        </tbody>
324
                                        </tbody>
325
                                    </table>
325
                                    </table>
Lines 333-339 Using this account is not recommended because some parts of Koha will not functi Link Here
333
                                        <tbody>
333
                                        <tbody>
334
                                            <tr>
334
                                            <tr>
335
                                                <td>You currently owe fines and charges amounting to:</td>
335
                                                <td>You currently owe fines and charges amounting to:</td>
336
                                                <td><a href="/cgi-bin/koha/opac-account.pl">[% BORROWER_INFO.amountoutstanding %]</a></td>
336
                                                <td><a href="/cgi-bin/koha/opac-account.pl">[% amountoutstanding %]</a></td>
337
                                            </tr>
337
                                            </tr>
338
                                        </tbody>
338
                                        </tbody>
339
                                    </table>
339
                                    </table>
Lines 346-352 Using this account is not recommended because some parts of Koha will not functi Link Here
346
                                        <thead><tr><th colspan="2">Amount</th></tr></thead>
346
                                        <thead><tr><th colspan="2">Amount</th></tr></thead>
347
                                        <tbody>
347
                                        <tbody>
348
                                            <tr>
348
                                            <tr>
349
                                                <td>You have a credit of:</td><td><a href="/cgi-bin/koha/opac-account.pl">[% BORROWER_INFO.amountoutstanding %]</a></td>
349
                                                <td>You have a credit of:</td><td><a href="/cgi-bin/koha/opac-account.pl">[% amountoutstanding %]</a></td>
350
                                            </tr>
350
                                            </tr>
351
                                        </tbody>
351
                                        </tbody>
352
                                    </table>
352
                                    </table>
(-)a/opac/opac-reserve.pl (-2 / +3 lines)
Lines 305-312 if ( $query->param('place_reserve') ) { Link Here
305
my $noreserves     = 0;
305
my $noreserves     = 0;
306
my $maxoutstanding = C4::Context->preference("maxoutstanding");
306
my $maxoutstanding = C4::Context->preference("maxoutstanding");
307
$template->param( noreserve => 1 ) unless $maxoutstanding;
307
$template->param( noreserve => 1 ) unless $maxoutstanding;
308
if ( $borr->{'amountoutstanding'} && ($borr->{'amountoutstanding'} > $maxoutstanding) ) {
308
my $amountoutstanding = GetMemberAccountRecords($borrowernumber);
309
    my $amount = sprintf "%.02f", $borr->{'amountoutstanding'};
309
if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
310
    my $amount = sprintf "%.02f", $amountoutstanding;
310
    $template->param( message => 1 );
311
    $template->param( message => 1 );
311
    $noreserves = 1;
312
    $noreserves = 1;
312
    $template->param( too_much_oweing => $amount );
313
    $template->param( too_much_oweing => $amount );
(-)a/opac/opac-user.pl (-6 / +8 lines)
Lines 113-122 if ( $userdebarred || $borr->{'gonenoaddress'} || $borr->{'lost'} ) { Link Here
113
    $canrenew = 0;
113
    $canrenew = 0;
114
}
114
}
115
115
116
if ( $borr->{'amountoutstanding'} > 5 ) {
116
my ( $amountoutstanding ) = GetMemberAccountRecords($borrowernumber);
117
if ( $amountoutstanding > 5 ) {
117
    $borr->{'amountoverfive'} = 1;
118
    $borr->{'amountoverfive'} = 1;
118
}
119
}
119
if ( 5 >= $borr->{'amountoutstanding'} && $borr->{'amountoutstanding'} > 0 ) {
120
if ( 5 >= $amountoutstanding && $amountoutstanding > 0 ) {
120
    $borr->{'amountoverzero'} = 1;
121
    $borr->{'amountoverzero'} = 1;
121
}
122
}
122
my $no_renewal_amt = C4::Context->preference( 'OPACFineNoRenewals' );
123
my $no_renewal_amt = C4::Context->preference( 'OPACFineNoRenewals' );
Lines 124-142 $no_renewal_amt = undef unless looks_like_number( $no_renewal_amt ); Link Here
124
125
125
if (   C4::Context->preference('OpacRenewalAllowed')
126
if (   C4::Context->preference('OpacRenewalAllowed')
126
    && defined($no_renewal_amt)
127
    && defined($no_renewal_amt)
127
    && $borr->{amountoutstanding} > $no_renewal_amt )
128
    && $amountoutstanding > $no_renewal_amt )
128
{
129
{
129
    $borr->{'flagged'} = 1;
130
    $borr->{'flagged'} = 1;
130
    $canrenew = 0;
131
    $canrenew = 0;
131
    $template->param(
132
    $template->param(
132
        renewal_blocked_fines => $no_renewal_amt,
133
        renewal_blocked_fines => $no_renewal_amt,
133
        renewal_blocked_fines_amountoutstanding => $borr->{amountoutstanding},
134
        renewal_blocked_fines_amountoutstanding => $amountoutstanding,
134
    );
135
    );
135
}
136
}
136
137
137
if ( $borr->{'amountoutstanding'} < 0 ) {
138
if ( $amountoutstanding < 0 ) {
138
    $borr->{'amountlessthanzero'} = 1;
139
    $borr->{'amountlessthanzero'} = 1;
139
    $borr->{'amountoutstanding'} = -1 * ( $borr->{'amountoutstanding'} );
140
    $amountoutstanding = -1 * ( $amountoutstanding );
140
}
141
}
141
142
142
# Warningdate is the date that the warning starts appearing
143
# Warningdate is the date that the warning starts appearing
Lines 158-163 if ( $borr->{'dateexpiry'} && C4::Context->preference('NotifyBorrowerDeparture') Link Here
158
my $renew_error = $query->param('renew_error');
159
my $renew_error = $query->param('renew_error');
159
160
160
$template->param(   BORROWER_INFO     => $borr,
161
$template->param(   BORROWER_INFO     => $borr,
162
                    amountoutstanding => $amountoutstanding,
161
                    borrowernumber    => $borrowernumber,
163
                    borrowernumber    => $borrowernumber,
162
                    patron_flagged    => $borr->{flagged},
164
                    patron_flagged    => $borr->{flagged},
163
                    OPACMySummaryHTML => (C4::Context->preference("OPACMySummaryHTML")) ? 1 : 0,
165
                    OPACMySummaryHTML => (C4::Context->preference("OPACMySummaryHTML")) ? 1 : 0,
(-)a/t/db_dependent/Members.t (-15 / +1 lines)
Lines 412-418 subtest 'GetMemberAccountRecords' => sub { Link Here
412
412
413
subtest 'GetMemberAccountBalance' => sub {
413
subtest 'GetMemberAccountBalance' => sub {
414
414
415
    plan tests => 10;
415
    plan tests => 6;
416
416
417
    my $members_mock = new Test::MockModule('C4::Members');
417
    my $members_mock = new Test::MockModule('C4::Members');
418
    $members_mock->mock( 'GetMemberAccountRecords', sub {
418
    $members_mock->mock( 'GetMemberAccountRecords', sub {
Lines 430-448 subtest 'GetMemberAccountBalance' => sub { Link Here
430
        }
430
        }
431
    });
431
    });
432
432
433
    my $person = GetMemberDetails(undef,undef);
434
    ok( !$person , 'Expected no member details from undef,undef' );
435
    $person = GetMemberDetails(undef,'987654321');
436
    is( $person->{amountoutstanding}, 15,
437
        'Expected 15 outstanding for cardnumber.');
438
    $borrowernumber = $person->{borrowernumber};
439
    $person = GetMemberDetails($borrowernumber,undef);
440
    is( $person->{amountoutstanding}, 15,
441
        'Expected 15 outstanding for borrowernumber.');
442
    $person = GetMemberDetails($borrowernumber,'987654321');
443
    is( $person->{amountoutstanding}, 15,
444
        'Expected 15 outstanding for both borrowernumber and cardnumber.');
445
446
    # do not count holds charges
433
    # do not count holds charges
447
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', '1' );
434
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', '1' );
448
    t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', '0' );
435
    t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', '0' );
449
- 

Return to bug 17578