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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 2696-2702 sub CanBookBeRenewed { Link Here
2696
2696
2697
        if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2697
        if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2698
            my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2698
            my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2699
            my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($patron->borrowernumber);
2699
            my $amountoutstanding = $patron->account->balance;
2700
            if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2700
            if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2701
                return ( 0, "auto_too_much_oweing" );
2701
                return ( 0, "auto_too_much_oweing" );
2702
            }
2702
            }
(-)a/C4/Members.pm (-53 / +11 lines)
Lines 26-31 use C4::Context; Link Here
26
use String::Random qw( random_string );
26
use String::Random qw( random_string );
27
use Scalar::Util qw( looks_like_number );
27
use Scalar::Util qw( looks_like_number );
28
use Date::Calc qw/Today check_date Date_to_Days/;
28
use Date::Calc qw/Today check_date Date_to_Days/;
29
use List::MoreUtils qw( uniq );
29
use C4::Log; # logaction
30
use C4::Log; # logaction
30
use C4::Overdues;
31
use C4::Overdues;
31
use C4::Reserves;
32
use C4::Reserves;
Lines 64-71 BEGIN { Link Here
64
        &GetPendingIssues
65
        &GetPendingIssues
65
        &GetAllIssues
66
        &GetAllIssues
66
67
67
        &GetMemberAccountRecords
68
69
        &GetBorrowersToExpunge
68
        &GetBorrowersToExpunge
70
69
71
        &IssueSlip
70
        &IssueSlip
Lines 736-784 sub GetAllIssues { Link Here
736
}
735
}
737
736
738
737
739
=head2 GetMemberAccountRecords
740
741
  ($total, $acctlines, $count) = &GetMemberAccountRecords($borrowernumber);
742
743
Looks up accounting data for the patron with the given borrowernumber.
744
745
C<&GetMemberAccountRecords> returns a three-element array. C<$acctlines> is a
746
reference-to-array, where each element is a reference-to-hash; the
747
keys are the fields of the C<accountlines> table in the Koha database.
748
C<$count> is the number of elements in C<$acctlines>. C<$total> is the
749
total amount outstanding for all of the account lines.
750
751
=cut
752
753
sub GetMemberAccountRecords {
754
    my ($borrowernumber) = @_;
755
    my $dbh = C4::Context->dbh;
756
    my @acctlines;
757
    my $numlines = 0;
758
    my $strsth      = qq(
759
                        SELECT * 
760
                        FROM accountlines 
761
                        WHERE borrowernumber=?);
762
    $strsth.=" ORDER BY accountlines_id desc";
763
    my $sth= $dbh->prepare( $strsth );
764
    $sth->execute( $borrowernumber );
765
766
    my $total = 0;
767
    while ( my $data = $sth->fetchrow_hashref ) {
768
        if ( $data->{itemnumber} ) {
769
            my $item = Koha::Items->find( $data->{itemnumber} );
770
            my $biblio = $item->biblio;
771
            $data->{biblionumber} = $biblio->biblionumber;
772
            $data->{title}        = $biblio->title;
773
        }
774
        $acctlines[$numlines] = $data;
775
        $numlines++;
776
        $total += sprintf "%.0f", 1000*$data->{amountoutstanding}; # convert float to integer to avoid round-off errors
777
    }
778
    $total /= 1000;
779
    return ( $total, \@acctlines,$numlines);
780
}
781
782
=head2 GetMemberAccountBalance
738
=head2 GetMemberAccountBalance
783
739
784
  ($total_balance, $non_issue_balance, $other_charges) = &GetMemberAccountBalance($borrowernumber);
740
  ($total_balance, $non_issue_balance, $other_charges) = &GetMemberAccountBalance($borrowernumber);
Lines 795-800 Charges exempt from non-issue are: Link Here
795
sub GetMemberAccountBalance {
751
sub GetMemberAccountBalance {
796
    my ($borrowernumber) = @_;
752
    my ($borrowernumber) = @_;
797
753
754
    # FIXME REMOVE And add a warning in the about page + update DB if length(MANUAL_INV) > 5
798
    my $ACCOUNT_TYPE_LENGTH = 5; # this is plain ridiculous...
755
    my $ACCOUNT_TYPE_LENGTH = 5; # this is plain ridiculous...
799
756
800
    my @not_fines;
757
    my @not_fines;
Lines 802-817 sub GetMemberAccountBalance { Link Here
802
    push @not_fines, 'Rent' unless C4::Context->preference('RentalsInNoissuesCharge');
759
    push @not_fines, 'Rent' unless C4::Context->preference('RentalsInNoissuesCharge');
803
    unless ( C4::Context->preference('ManInvInNoissuesCharge') ) {
760
    unless ( C4::Context->preference('ManInvInNoissuesCharge') ) {
804
        my $dbh = C4::Context->dbh;
761
        my $dbh = C4::Context->dbh;
805
        my $man_inv_types = $dbh->selectcol_arrayref(qq{SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'});
762
        push @not_fines, @{ $dbh->selectcol_arrayref(qq{SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'}) };
806
        push @not_fines, map substr($_, 0, $ACCOUNT_TYPE_LENGTH), @$man_inv_types;
807
    }
763
    }
808
    my %not_fine = map {$_ => 1} @not_fines;
764
    @not_fines = map { substr($_, 0, $ACCOUNT_TYPE_LENGTH) } uniq (@not_fines);
809
765
810
    my ($total, $acctlines) = GetMemberAccountRecords($borrowernumber);
766
    my $patron = Koha::Patrons->find( $borrowernumber );
811
    my $other_charges = 0;
767
    my $total = $patron->account->balance;
812
    foreach (@$acctlines) {
768
    my $other_charges = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber, accounttype => { -in => \@not_fines } }, {
813
        $other_charges += $_->{amountoutstanding} if $not_fine{ substr($_->{accounttype}, 0, $ACCOUNT_TYPE_LENGTH) };
769
            select => [ { sum => 'amountoutstanding' } ],
814
    }
770
            as => ['total_other_charges'],
771
        });
772
    $other_charges = $other_charges->count ? $other_charges->next->get_column('total_other_charges') : 0;
815
773
816
    return ( $total, $total - $other_charges, $other_charges);
774
    return ( $total, $total - $other_charges, $other_charges);
817
}
775
}
(-)a/C4/SIP/ILS/Patron.pm (-1 / +1 lines)
Lines 88-94 sub new { Link Here
88
        hold_ok         => ( !$debarred && !$expired && !$fine_blocked),
88
        hold_ok         => ( !$debarred && !$expired && !$fine_blocked),
89
        card_lost       => ( $kp->{lost} || $kp->{gonenoaddress} || $flags->{LOST} ),
89
        card_lost       => ( $kp->{lost} || $kp->{gonenoaddress} || $flags->{LOST} ),
90
        claims_returned => 0,
90
        claims_returned => 0,
91
        fines           => $fines_amount, # GetMemberAccountRecords($kp->{borrowernumber})
91
        fines           => $fines_amount,
92
        fees            => 0,             # currently not distinct from fines
92
        fees            => 0,             # currently not distinct from fines
93
        recall_overdue  => 0,
93
        recall_overdue  => 0,
94
        items_billed    => 0,
94
        items_billed    => 0,
(-)a/Koha/Account.pm (-1 / +2 lines)
Lines 279-285 sub balance { Link Here
279
            as => ['total_amountoutstanding'],
279
            as => ['total_amountoutstanding'],
280
        }
280
        }
281
    );
281
    );
282
    return $fines->count
282
283
    my $total = $fines->count
283
      ? $fines->next->get_column('total_amountoutstanding')
284
      ? $fines->next->get_column('total_amountoutstanding')
284
      : 0;
285
      : 0;
285
}
286
}
(-)a/Koha/Account/Line.pm (-1 / +14 lines)
Lines 20-25 use Modern::Perl; Link Here
20
use Carp;
20
use Carp;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Items;
23
24
24
use base qw(Koha::Object);
25
use base qw(Koha::Object);
25
26
Lines 33-39 Koha::Account::Lines - Koha accountline Object class Link Here
33
34
34
=cut
35
=cut
35
36
36
=head3 type
37
=head3 item
38
39
Return the item linked to this account line if exists
40
41
=cut
42
43
sub item {
44
    my ( $self ) = @_;
45
    my $rs = $self->_result->itemnumber;
46
    return Koha::Item->_new_from_dbic( $rs );
47
}
48
49
=head3 _type
37
50
38
=cut
51
=cut
39
52
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 555-561 foreach my $flag ( sort keys %$flags ) { Link Here
555
my $amountold = $flags ? $flags->{'CHARGES'}->{'message'} || 0 : 0;
555
my $amountold = $flags ? $flags->{'CHARGES'}->{'message'} || 0 : 0;
556
$amountold =~ s/^.*\$//;    # remove upto the $, if any
556
$amountold =~ s/^.*\$//;    # remove upto the $, if any
557
557
558
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
558
my $total = $patron ? $patron->account->balance : 0;
559
559
560
if ( $patron && $patron->is_child) {
560
if ( $patron && $patron->is_child) {
561
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
561
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-1 / +1 lines)
Lines 78-84 Link Here
78
          [% CASE %][% account.accounttype %]
78
          [% CASE %][% account.accounttype %]
79
        [%- END -%]
79
        [%- END -%]
80
        [%- IF account.description %], [% account.description %][% END %]
80
        [%- IF account.description %], [% account.description %][% END %]
81
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% account.title |html %]</a>[% END %]</td>
81
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% account.item.biblio.title |html %]</a>[% END %]</td>
82
      <td>[% account.note | html_line_break %]</td>
82
      <td>[% account.note | html_line_break %]</td>
83
      [% IF ( account.amountcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amount | $Price %]</td>
83
      [% IF ( account.amountcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amount | $Price %]</td>
84
      [% IF ( account.amountoutstandingcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amountoutstanding | $Price %]</td>
84
      [% IF ( account.amountoutstandingcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amountoutstanding | $Price %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-print.tt (-3 / +2 lines)
Lines 103-113 Link Here
103
            </tr>
103
            </tr>
104
104
105
            [% FOREACH account IN accounts %]
105
            [% FOREACH account IN accounts %]
106
                [% NEXT IF account.amountoutstanding == 0 %]
107
                <tr>
106
                <tr>
108
                    <td>
107
                    <td>
109
                        [% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% END %]
108
                        [% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% END %]
110
                        [% account.description %]&nbsp;[% IF ( account.printtitle ) %] [% account.title |html %][% END %]
109
                        [% account.description %]&nbsp;[% IF account.item AND account.accounttype != 'F' AND account.accounttype != 'FU' %] [% account.item.biblio.title |html %][% END %]
111
                        [% IF ( account.itemnumber ) %]</a>[% END %]
110
                        [% IF ( account.itemnumber ) %]</a>[% END %]
112
                    </td>
111
                    </td>
113
                    <td>[% account.date | $KohaDates %]</td>
112
                    <td>[% account.date | $KohaDates %]</td>
(-)a/members/boraccount.pl (-3 / +18 lines)
Lines 71-84 if ( $patron->is_child ) { Link Here
71
}
71
}
72
72
73
#get account details
73
#get account details
74
my ($total,$accts,undef)=GetMemberAccountRecords($borrowernumber);
74
my $total = $patron->account->balance;
75
76
my $accts = Koha::Account::Lines->search(
77
    { borrowernumber => $patron->borrowernumber },
78
    { order_by       => { -desc => 'accountlines_id' } }
79
);
80
75
my $totalcredit;
81
my $totalcredit;
76
if($total <= 0){
82
if($total <= 0){
77
        $totalcredit = 1;
83
        $totalcredit = 1;
78
}
84
}
79
85
80
my $reverse_col = 0; # Flag whether we need to show the reverse column
86
my $reverse_col = 0; # Flag whether we need to show the reverse column
81
foreach my $accountline ( @{$accts}) {
87
my @accountlines;
88
while ( my $line = $accts->next ) {
89
    # FIXME We should pass the $accts iterator to the template and do this formatting part there
90
    my $accountline = $line->unblessed;
82
    $accountline->{amount} += 0.00;
91
    $accountline->{amount} += 0.00;
83
    if ($accountline->{amount} <= 0 ) {
92
    if ($accountline->{amount} <= 0 ) {
84
        $accountline->{amountcredit} = 1;
93
        $accountline->{amountcredit} = 1;
Lines 94-99 foreach my $accountline ( @{$accts}) { Link Here
94
        $accountline->{payment} = 1;
103
        $accountline->{payment} = 1;
95
        $reverse_col = 1;
104
        $reverse_col = 1;
96
    }
105
    }
106
107
    if ( $accountline->{itemnumber} ) {
108
        # Because we will not have access to the object from the template
109
        $accountline->{item} = { biblionumber => $line->item->biblionumber, };
110
    }
111
    push @accountlines, $accountline;
97
}
112
}
98
113
99
if (C4::Context->preference('ExtendedPatronAttributes')) {
114
if (C4::Context->preference('ExtendedPatronAttributes')) {
Lines 110-116 $template->param( Link Here
110
    total               => sprintf("%.2f",$total),
125
    total               => sprintf("%.2f",$total),
111
    totalcredit         => $totalcredit,
126
    totalcredit         => $totalcredit,
112
    reverse_col         => $reverse_col,
127
    reverse_col         => $reverse_col,
113
    accounts            => $accts,
128
    accounts            => \@accountlines,
114
);
129
);
115
130
116
output_html_with_http_headers $input, $cookie, $template->output;
131
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/moremember.pl (-10 / +6 lines)
Lines 50-55 use C4::Biblio; Link Here
50
use C4::Form::MessagingPreferences;
50
use C4::Form::MessagingPreferences;
51
use List::MoreUtils qw/uniq/;
51
use List::MoreUtils qw/uniq/;
52
use C4::Members::Attributes qw(GetBorrowerAttributes);
52
use C4::Members::Attributes qw(GetBorrowerAttributes);
53
use Koha::Account::Lines;
53
use Koha::AuthorisedValues;
54
use Koha::AuthorisedValues;
54
use Koha::CsvProfiles;
55
use Koha::CsvProfiles;
55
use Koha::Patron::Debarments qw(GetDebarments);
56
use Koha::Patron::Debarments qw(GetDebarments);
Lines 214-231 else { Link Here
214
my $library = Koha::Libraries->find( $data->{branchcode})->unblessed;
215
my $library = Koha::Libraries->find( $data->{branchcode})->unblessed;
215
@{$data}{keys %$library} = values %$library; # merge in all branch columns # FIXME This is really ugly, we should pass the library instead
216
@{$data}{keys %$library} = values %$library; # merge in all branch columns # FIXME This is really ugly, we should pass the library instead
216
217
217
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
218
219
# If printing a page, send the account informations to the template
218
# If printing a page, send the account informations to the template
220
if ($print eq "page") {
219
if ($print eq "page") {
221
    foreach my $accountline (@$accts) {
220
    my $accts = Koha::Account::Lines->search(
222
        $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
221
        { borrowernumber => $patron->borrowernumber, amountoutstanding => { '>' => 0 } },
223
        $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding};
222
        { order_by       => { -desc => 'accountlines_id' } }
224
223
    );
225
        if ($accountline->{accounttype} ne 'F' && $accountline->{accounttype} ne 'FU'){
226
            $accountline->{printtitle} = 1;
227
        }
228
    }
229
    $template->param( accounts => $accts );
224
    $template->param( accounts => $accts );
230
}
225
}
231
226
Lines 339-344 my $patron_messages = Koha::Patron::Messages->search( Link Here
339
my ( $subtag, $region ) = split '-', $patron->lang;
334
my ( $subtag, $region ) = split '-', $patron->lang;
340
my $translated_language = C4::Languages::language_get_description( $subtag, $subtag, 'language' );
335
my $translated_language = C4::Languages::language_get_description( $subtag, $subtag, 'language' );
341
336
337
my $total = $patron->account->balance;
342
$template->param(
338
$template->param(
343
    patron          => $patron,
339
    patron          => $patron,
344
    translated_language => $translated_language,
340
    translated_language => $translated_language,
(-)a/members/pay.pl (-1 / +2 lines)
Lines 124-130 output_html_with_http_headers $input, $cookie, $template->output; Link Here
124
124
125
sub add_accounts_to_template {
125
sub add_accounts_to_template {
126
126
127
    my ( $total, undef, undef ) = GetMemberAccountRecords($borrowernumber);
127
    my $patron = Koha::Patrons->find( $borrowernumber );
128
    my $total = $patron->account->balance;
128
    my $account_lines = Koha::Account::Lines->search({ borrowernumber => $borrowernumber, amountoutstanding => { '!=' => 0 } }, { order_by => ['accounttype'] });
129
    my $account_lines = Koha::Account::Lines->search({ borrowernumber => $borrowernumber, amountoutstanding => { '!=' => 0 } }, { order_by => ['accounttype'] });
129
    my @accounts;
130
    my @accounts;
130
    while ( my $account_line = $account_lines->next ) {
131
    while ( my $account_line = $account_lines->next ) {
(-)a/members/paycollect.pl (-1 / +1 lines)
Lines 58-64 my $user = $input->remote_user; Link Here
58
58
59
my $branch         = C4::Context->userenv->{'branch'};
59
my $branch         = C4::Context->userenv->{'branch'};
60
60
61
my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
61
my $total_due = $patron->account->balance;
62
my $total_paid = $input->param('paid');
62
my $total_paid = $input->param('paid');
63
63
64
my $individual   = $input->param('pay_individual');
64
my $individual   = $input->param('pay_individual');
(-)a/members/printfeercpt.pl (-43 / +31 lines)
Lines 29-34 use C4::Output; Link Here
29
use CGI qw ( -utf8 );
29
use CGI qw ( -utf8 );
30
use C4::Members;
30
use C4::Members;
31
use C4::Accounts;
31
use C4::Accounts;
32
use Koha::Account::Lines;
32
use Koha::DateUtils;
33
use Koha::DateUtils;
33
use Koha::Patrons;
34
use Koha::Patrons;
34
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
Lines 64-122 if ( $patron->is_child ) { Link Here
64
}
65
}
65
66
66
#get account details
67
#get account details
67
my ($total,$accts,$numaccts)=GetMemberAccountRecords($borrowernumber);
68
my $total = $patron->account->balance;
69
70
# FIXME This whole stuff is ugly and should be rewritten
71
# FIXME We should pass the $accts iterator to the template and do this formatting part there
72
my $accountline = Koha::Account::Lines->find($accountlines_id)->unblessed;
68
my $totalcredit;
73
my $totalcredit;
69
if($total <= 0){
74
if($total <= 0){
70
        $totalcredit = 1;
75
        $totalcredit = 1;
71
}
76
}
72
my @accountrows; # this is for the tmpl-loop
77
73
78
$accountline->{'amount'} += 0.00;
74
my $toggle;
79
if ( $accountline->{'amount'} <= 0 ) {
75
for (my $i=0;$i<$numaccts;$i++){
80
    $accountline->{'amountcredit'} = 1;
76
    next if ( $accts->[$i]{'accountlines_id'} ne $accountlines_id );
81
    $accountline->{'amount'} *= -1.00;
77
    if($i%2){
82
}
78
            $toggle = 0;
83
$accountline->{'amountoutstanding'} += 0.00;
79
    } else {
84
if ( $accountline->{'amountoutstanding'} <= 0 ) {
80
            $toggle = 1;
85
    $accountline->{'amountoutstandingcredit'} = 1;
81
    }
82
    $accts->[$i]{'toggle'} = $toggle;
83
    $accts->[$i]{'amount'}+=0.00;
84
    if($accts->[$i]{'amount'} <= 0){
85
        $accts->[$i]{'amountcredit'} = 1;
86
	$accts->[$i]{'amount'}*=-1.00;
87
    }
88
    $accts->[$i]{'amountoutstanding'}+=0.00;
89
    if($accts->[$i]{'amountoutstanding'} <= 0){
90
        $accts->[$i]{'amountoutstandingcredit'} = 1;
91
    }
92
93
    my %row = ( 'date'         => dt_from_string( $accts->[$i]{'date'} ),
94
                'amountcredit' => $accts->[$i]{'amountcredit'},
95
                'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
96
                'toggle' => $accts->[$i]{'toggle'},
97
                'description'       => $accts->[$i]{'description'},
98
				'itemnumber'       => $accts->[$i]{'itemnumber'},
99
				'biblionumber'       => $accts->[$i]{'biblionumber'},
100
                'amount'            => sprintf("%.2f",$accts->[$i]{'amount'}),
101
                'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}),
102
                'accountno' => $accts->[$i]{'accountno'},
103
                accounttype => $accts->[$i]{accounttype},
104
                'note' => $accts->[$i]{'note'},
105
                );
106
107
    if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
108
        $row{'printtitle'}=1;
109
        $row{'title'} = $accts->[$i]{'title'};
110
    }
111
112
    push(@accountrows, \%row);
113
}
86
}
114
87
88
my %row = (
89
    'date'                    => dt_from_string( $accountline->{'date'} ),
90
    'amountcredit'            => $accountline->{'amountcredit'},
91
    'amountoutstandingcredit' => $accountline->{'amountoutstandingcredit'},
92
    'description'             => $accountline->{'description'},
93
    'amount'                  => sprintf( "%.2f", $accountline->{'amount'} ),
94
    'amountoutstanding' =>
95
      sprintf( "%.2f", $accountline->{'amountoutstanding'} ),
96
    'accountno' => $accountline->{'accountno'},
97
    accounttype => $accountline->{accounttype},
98
    'note'      => $accountline->{'note'},
99
);
100
101
115
$template->param(
102
$template->param(
116
    patron               => $patron,
103
    patron               => $patron,
117
    finesview           => 1,
104
    finesview           => 1,
118
    total               => sprintf("%.2f",$total),
105
    total               => sprintf("%.2f",$total),
119
    totalcredit         => $totalcredit,
106
    totalcredit         => $totalcredit,
120
    accounts            => \@accountrows );
107
    accounts            => [$accountline], # FIXME There is always only 1 row!
108
);
121
109
122
output_html_with_http_headers $input, $cookie, $template->output;
110
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/printinvoice.pl (-46 / +26 lines)
Lines 29-34 use CGI qw ( -utf8 ); Link Here
29
use C4::Members;
29
use C4::Members;
30
use C4::Accounts;
30
use C4::Accounts;
31
31
32
use Koha::Account::Lines;
32
use Koha::Patrons;
33
use Koha::Patrons;
33
use Koha::Patron::Categories;
34
use Koha::Patron::Categories;
34
35
Lines 59-123 if ( $patron->is_child ) { Link Here
59
}
60
}
60
61
61
#get account details
62
#get account details
62
my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
63
my $total = $patron->account->balance;
64
my $accountline = Koha::Account::Lines->find($accountlines_id)->unblessed;
65
63
my $totalcredit;
66
my $totalcredit;
64
if ( $total <= 0 ) {
67
if ( $total <= 0 ) {
65
    $totalcredit = 1;
68
    $totalcredit = 1;
66
}
69
}
67
70
68
my @accountrows;    # this is for the tmpl-loop
69
70
my $toggle;
71
for ( my $i = 0 ; $i < $numaccts ; $i++ ) {
72
    next if ( $accts->[$i]{'accountlines_id'} ne $accountlines_id );
73
74
    if ( $i % 2 ) {
75
        $toggle = 0;
76
    } else {
77
        $toggle = 1;
78
    }
79
80
    $accts->[$i]{'toggle'} = $toggle;
81
    $accts->[$i]{'amount'} += 0.00;
82
83
    if ( $accts->[$i]{'amount'} <= 0 ) {
84
        $accts->[$i]{'amountcredit'} = 1;
85
    }
86
87
    $accts->[$i]{'amountoutstanding'} += 0.00;
88
    if ( $accts->[$i]{'amountoutstanding'} <= 0 ) {
89
        $accts->[$i]{'amountoutstandingcredit'} = 1;
90
    }
91
92
    my %row = (
93
        'date'                    => output_pref({ dt => dt_from_string( $accts->[$i]{'date'} ), dateonly => 1 }),
94
        'amountcredit'            => $accts->[$i]{'amountcredit'},
95
        'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
96
        'toggle'                  => $accts->[$i]{'toggle'},
97
        'description'             => $accts->[$i]{'description'},
98
        'itemnumber'              => $accts->[$i]{'itemnumber'},
99
        'biblionumber'            => $accts->[$i]{'biblionumber'},
100
        'amount'                  => sprintf( "%.2f", $accts->[$i]{'amount'} ),
101
        'amountoutstanding'       => sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} ),
102
        'accountno'               => $accts->[$i]{'accountno'},
103
        accounttype               => $accts->[$i]{accounttype},
104
        'note'                    => $accts->[$i]{'note'},
105
    );
106
107
    if ( $accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU' ) {
108
        $row{'printtitle'} = 1;
109
        $row{'title'}      = $accts->[$i]{'title'};
110
    }
111
71
112
    push( @accountrows, \%row );
72
$accountline->{'amount'} += 0.00;
73
if ( $accountline->{'amount'} <= 0 ) {
74
    $accountline->{'amountcredit'} = 1;
75
    $accountline->{'amount'} *= -1.00;
113
}
76
}
77
$accountline->{'amountoutstanding'} += 0.00;
78
if ( $accountline->{'amountoutstanding'} <= 0 ) {
79
    $accountline->{'amountoutstandingcredit'} = 1;
80
}
81
82
my %row = (
83
    'date'                    => dt_from_string( $accountline->{'date'}, dateonly => 1 ),
84
    'amountcredit'            => $accountline->{'amountcredit'},
85
    'amountoutstandingcredit' => $accountline->{'amountoutstandingcredit'},
86
    'description'             => $accountline->{'description'},
87
    'amount'                  => sprintf( "%.2f", $accountline->{'amount'} ),
88
    'amountoutstanding' =>
89
      sprintf( "%.2f", $accountline->{'amountoutstanding'} ),
90
    'accountno' => $accountline->{'accountno'},
91
    accounttype => $accountline->{accounttype},
92
    'note'      => $accountline->{'note'},
93
);
114
94
115
$template->param(
95
$template->param(
116
    patron         => $patron,
96
    patron         => $patron,
117
    finesview      => 1,
97
    finesview      => 1,
118
    total          => sprintf( "%.2f", $total ),
98
    total          => sprintf( "%.2f", $total ),
119
    totalcredit    => $totalcredit,
99
    totalcredit    => $totalcredit,
120
    accounts       => \@accountrows
100
    accounts       => [$accountline], # FIXME There is always only 1 row!
121
);
101
);
122
102
123
output_html_with_http_headers $input, $cookie, $template->output;
103
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/summary-print.pl (-8 / +5 lines)
Lines 47-60 my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in" Link Here
47
my $patron         = Koha::Patrons->find( $borrowernumber );
47
my $patron         = Koha::Patrons->find( $borrowernumber );
48
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
48
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
49
49
50
my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
50
my $total = $patron->account->balance;
51
foreach my $accountline (@$accts) {
51
my $accts = Koha::Account::Lines->search(
52
    if (   $accountline->{accounttype} ne 'F'
52
    { borrowernumber => $patron->borrowernumber },
53
        && $accountline->{accounttype} ne 'FU' )
53
    { order_by       => { -desc => 'accountlines_id' } }
54
    {
54
);
55
        $accountline->{printtitle} = 1;
56
    }
57
}
58
55
59
our $totalprice = 0;
56
our $totalprice = 0;
60
57
(-)a/opac/opac-account.pl (-20 / +19 lines)
Lines 24-29 use CGI qw ( -utf8 ); Link Here
24
use C4::Members;
24
use C4::Members;
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Output;
26
use C4::Output;
27
use Koha::Account::Lines;
27
use Koha::Patrons;
28
use Koha::Patrons;
28
use Koha::Plugins;
29
use Koha::Plugins;
29
30
Lines 45-76 $borrower->{description} = $category->description; Link Here
45
$borrower->{category_type} = $category->category_type;
46
$borrower->{category_type} = $category->category_type;
46
$template->param( BORROWER_INFO => $borrower );
47
$template->param( BORROWER_INFO => $borrower );
47
48
48
#get account details
49
my $total = $patron->account->balance;
49
my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
50
my $accts = Koha::Account::Lines->search(
51
    { borrowernumber => $patron->borrowernumber },
52
    { order_by       => { -desc => 'accountlines_id' } }
53
);
50
54
51
for ( my $i = 0 ; $i < $numaccts ; $i++ ) {
55
my @accountlines;
52
    $accts->[$i]{'amount'} = sprintf( "%.2f", $accts->[$i]{'amount'} || '0.00');
56
while ( my $line = $accts->next ) {
53
    if ( $accts->[$i]{'amount'} >= 0 ) {
57
    my $accountline = $line->unblessed;
54
        $accts->[$i]{'amountcredit'} = 1;
58
    $accountline->{'amount'} = sprintf( "%.2f", $accountline->{'amount'} || '0.00');
59
    if ( $accountline->{'amount'} >= 0 ) {
60
        $accountline->{'amountcredit'} = 1;
55
    }
61
    }
56
    $accts->[$i]{'amountoutstanding'} =
62
    $accountline->{'amountoutstanding'} =
57
      sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} || '0.00' );
63
      sprintf( "%.2f", $accountline->{'amountoutstanding'} || '0.00' );
58
    if ( $accts->[$i]{'amountoutstanding'} >= 0 ) {
64
    if ( $accountline->{'amountoutstanding'} >= 0 ) {
59
        $accts->[$i]{'amountoutstandingcredit'} = 1;
65
        $accountline->{'amountoutstandingcredit'} = 1;
60
    }
66
    }
61
}
67
    push @accountlines, $accountline;
62
63
# add the row parity
64
my $num = 0;
65
foreach my $row (@$accts) {
66
    $row->{'even'} = 1 if $num % 2 == 0;
67
    $row->{'odd'}  = 1 if $num % 2 == 1;
68
    $num++;
69
}
68
}
70
69
71
$template->param(
70
$template->param(
72
    ACCOUNT_LINES => $accts,
71
    ACCOUNT_LINES => \@accountlines,
73
    total         => sprintf( "%.2f", $total ),
72
    total         => sprintf( "%.2f", $total ), # FIXME Use TT plugin Price
74
    accountview   => 1,
73
    accountview   => 1,
75
    message       => scalar $query->param('message') || q{},
74
    message       => scalar $query->param('message') || q{},
76
    message_value => scalar $query->param('message_value') || q{},
75
    message_value => scalar $query->param('message_value') || q{},
(-)a/opac/opac-main.pl (-11 / +13 lines)
Lines 67-90 my $koha_news_count = scalar @$all_koha_news; Link Here
67
my $quote = GetDailyQuote();   # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha
67
my $quote = GetDailyQuote();   # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha
68
68
69
# For dashboard
69
# For dashboard
70
if ( defined $borrowernumber ){
70
my $patron = Koha::Patrons->find( $borrowernumber );
71
72
if ( $patron ) {
71
    my $checkouts = Koha::Checkouts->search({ borrowernumber => $borrowernumber })->count;
73
    my $checkouts = Koha::Checkouts->search({ borrowernumber => $borrowernumber })->count;
72
    my ( $overdues_count, $overdues ) = checkoverdues($borrowernumber);
74
    my ( $overdues_count, $overdues ) = checkoverdues($borrowernumber);
73
    my $holds_pending = Koha::Holds->search({ borrowernumber => $borrowernumber, found => undef })->count;
75
    my $holds_pending = Koha::Holds->search({ borrowernumber => $borrowernumber, found => undef })->count;
74
    my $holds_waiting = Koha::Holds->search({ borrowernumber => $borrowernumber })->waiting->count;
76
    my $holds_waiting = Koha::Holds->search({ borrowernumber => $borrowernumber })->waiting->count;
75
    my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
77
78
    my $total = $patron->account->balance;
76
79
77
    if  ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 ) {
80
    if  ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 ) {
78
        $template->param( dashboard_info => 1 );
81
        $template->param(
82
            dashboard_info => 1,
83
            checkouts           => $checkouts,
84
            overdues            => $overdues_count,
85
            holds_pending       => $holds_pending,
86
            holds_waiting       => $holds_waiting,
87
            total_owing         => $total,
88
        );
79
    }
89
    }
80
81
    $template->param(
82
        checkouts           => $checkouts,
83
        overdues            => $overdues_count,
84
        holds_pending       => $holds_pending,
85
        holds_waiting       => $holds_waiting,
86
        total_owing         => $total,
87
    );
88
}
90
}
89
91
90
$template->param(
92
$template->param(
(-)a/opac/opac-reserve.pl (-1 / +1 lines)
Lines 330-336 if ( $query->param('place_reserve') ) { Link Here
330
my $noreserves     = 0;
330
my $noreserves     = 0;
331
my $maxoutstanding = C4::Context->preference("maxoutstanding");
331
my $maxoutstanding = C4::Context->preference("maxoutstanding");
332
$template->param( noreserve => 1 ) unless $maxoutstanding;
332
$template->param( noreserve => 1 ) unless $maxoutstanding;
333
my ( $amountoutstanding ) = GetMemberAccountRecords($borrowernumber);
333
my $amountoutstanding = $patron->account->balance;
334
if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
334
if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
335
    my $amount = sprintf "%.02f", $amountoutstanding;
335
    my $amount = sprintf "%.02f", $amountoutstanding;
336
    $template->param( message => 1 );
336
    $template->param( message => 1 );
(-)a/opac/opac-user.pl (-18 / +29 lines)
Lines 33-38 use C4::Output; Link Here
33
use C4::Biblio;
33
use C4::Biblio;
34
use C4::Items;
34
use C4::Items;
35
use C4::Letters;
35
use C4::Letters;
36
use Koha::Account::Lines;
36
use Koha::Libraries;
37
use Koha::Libraries;
37
use Koha::DateUtils;
38
use Koha::DateUtils;
38
use Koha::Holds;
39
use Koha::Holds;
Lines 88-94 if (!$borrowernumber) { Link Here
88
}
89
}
89
90
90
# get borrower information ....
91
# get borrower information ....
91
my $borr = Koha::Patrons->find( $borrowernumber )->unblessed;
92
my $patron = Koha::Patrons->find( $borrowernumber );
93
my $borr = $patron->unblessed;
92
94
93
my (  $today_year,   $today_month,   $today_day) = Today();
95
my (  $today_year,   $today_month,   $today_day) = Today();
94
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
96
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
Lines 116-122 if ( $userdebarred || $borr->{'gonenoaddress'} || $borr->{'lost'} ) { Link Here
116
    $canrenew = 0;
118
    $canrenew = 0;
117
}
119
}
118
120
119
my ( $amountoutstanding ) = GetMemberAccountRecords($borrowernumber);
121
my $amountoutstanding = $patron->account->balance;
120
if ( $amountoutstanding > 5 ) {
122
if ( $amountoutstanding > 5 ) {
121
    $borr->{'amountoverfive'} = 1;
123
    $borr->{'amountoverfive'} = 1;
122
}
124
}
Lines 187-209 if ($issues){ Link Here
187
            $issue->{'reserved'} = 1;
189
            $issue->{'reserved'} = 1;
188
        }
190
        }
189
191
190
        my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
192
        # Must be moved in a module if reused
191
        my $charges = 0;
193
        my $charges = Koha::Account::Lines->search(
192
        my $rentalfines = 0;
194
            {
193
        foreach my $ac (@$accts) {
195
                borrowernumber    => $patron->borrowernumber,
194
            if ( $ac->{'itemnumber'} == $issue->{'itemnumber'} ) {
196
                amountoutstanding => { '>' => 0 },
195
                $charges += $ac->{'amountoutstanding'}
197
                accounttype       => [ 'F', 'FU', 'L' ],
196
                  if $ac->{'accounttype'} eq 'F';
198
                itemnumber        => $issue->{itemnumber}
197
                $charges += $ac->{'amountoutstanding'}
199
            },
198
                  if $ac->{'accounttype'} eq 'FU';
200
            { select => [ { sum => 'amountoutstanding' } ], as => ['charges'] }
199
                $charges += $ac->{'amountoutstanding'}
201
        );
200
                  if $ac->{'accounttype'} eq 'L';
202
        $issue->{charges} = $charges->count ? $charges->next->get_column('charges') : 0;
201
                $rentalfines += $ac->{'amountoutstanding'}
203
202
                  if $ac->{'accounttype'} eq 'Rent';
204
        my $rental_fines = Koha::Account::Lines->search(
205
            {
206
                borrowernumber    => $patron->borrowernumber,
207
                amountoutstanding => { '>' => 0 },
208
                accounttype       => 'Rent',
209
                itemnumber        => $issue->{itemnumber}
210
            },
211
            {
212
                select => [ { sum => 'amountoutstanding' } ],
213
                as     => ['rental_fines']
203
            }
214
            }
204
        }
215
        );
205
        $issue->{'charges'} = $charges;
216
        $issue->{rentalfines} = $charges->count ? $charges->next->get_column('rental_fines') : 0;
206
        $issue->{'rentalfines'} = $rentalfines;
217
207
        my $marcrecord = GetMarcBiblio({ biblionumber => $issue->{'biblionumber'} });
218
        my $marcrecord = GetMarcBiblio({ biblionumber => $issue->{'biblionumber'} });
208
        $issue->{'subtitle'} = GetRecordValue('subtitle', $marcrecord, GetFrameworkCode($issue->{'biblionumber'}));
219
        $issue->{'subtitle'} = GetRecordValue('subtitle', $marcrecord, GetFrameworkCode($issue->{'biblionumber'}));
209
        # check if item is renewable
220
        # check if item is renewable
(-)a/reserve/request.pl (-1 / +2 lines)
Lines 179-190 if ($borrowernumber_hold && !$action) { Link Here
179
        $diffbranch = 1;
179
        $diffbranch = 1;
180
    }
180
    }
181
181
182
    my $amount_outstanding = $patron->account->balance;
182
    $template->param(
183
    $template->param(
183
                expiry              => $expiry,
184
                expiry              => $expiry,
184
                diffbranch          => $diffbranch,
185
                diffbranch          => $diffbranch,
185
                messages            => $messages,
186
                messages            => $messages,
186
                warnings            => $warnings,
187
                warnings            => $warnings,
187
                amount_outstanding  => GetMemberAccountRecords($patron->borrowernumber),
188
                amount_outstanding  => $amount_outstanding,
188
    );
189
    );
189
}
190
}
190
191
(-)a/t/db_dependent/Koha/Patrons.t (-10 / +10 lines)
Lines 396-409 subtest 'add_enrolment_fee_if_needed' => sub { Link Here
396
    my $borrowernumber = C4::Members::AddMember(%borrower_data);
396
    my $borrowernumber = C4::Members::AddMember(%borrower_data);
397
    $borrower_data{borrowernumber} = $borrowernumber;
397
    $borrower_data{borrowernumber} = $borrowernumber;
398
398
399
    my ($total) = C4::Members::GetMemberAccountRecords($borrowernumber);
399
    my $patron = Koha::Patrons->find( $borrowernumber );
400
    is( $total, $enrolmentfee_K, "New kid pay $enrolmentfee_K" );
400
    my $total = $patron->account->balance;
401
    is( int($total), int($enrolmentfee_K), "New kid pay $enrolmentfee_K" );
401
402
402
    t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 0 );
403
    t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 0 );
403
    $borrower_data{categorycode} = 'J';
404
    $borrower_data{categorycode} = 'J';
404
    C4::Members::ModMember(%borrower_data);
405
    C4::Members::ModMember(%borrower_data);
405
    ($total) = C4::Members::GetMemberAccountRecords($borrowernumber);
406
    $total = $patron->account->balance;
406
    is( $total, $enrolmentfee_K, "Kid growing and become a juvenile, but shouldn't pay for the upgrade " );
407
    is( int($total), int($enrolmentfee_K), "Kid growing and become a juvenile, but shouldn't pay for the upgrade " );
407
408
408
    $borrower_data{categorycode} = 'K';
409
    $borrower_data{categorycode} = 'K';
409
    C4::Members::ModMember(%borrower_data);
410
    C4::Members::ModMember(%borrower_data);
Lines 411-426 subtest 'add_enrolment_fee_if_needed' => sub { Link Here
411
412
412
    $borrower_data{categorycode} = 'J';
413
    $borrower_data{categorycode} = 'J';
413
    C4::Members::ModMember(%borrower_data);
414
    C4::Members::ModMember(%borrower_data);
414
    ($total) = C4::Members::GetMemberAccountRecords($borrowernumber);
415
    $total = $patron->account->balance;
415
    is( $total, $enrolmentfee_K + $enrolmentfee_J, "Kid growing and become a juvenile, they should pay " . ( $enrolmentfee_K + $enrolmentfee_J ) );
416
    is( int($total), int($enrolmentfee_K + $enrolmentfee_J), "Kid growing and become a juvenile, they should pay " . ( $enrolmentfee_K + $enrolmentfee_J ) );
416
417
417
    # Check with calling directly Koha::Patron->get_enrolment_fee_if_needed
418
    # Check with calling directly Koha::Patron->get_enrolment_fee_if_needed
418
    my $patron = Koha::Patrons->find($borrowernumber);
419
    $patron->categorycode('YA')->store;
419
    $patron->categorycode('YA')->store;
420
    my $fee = $patron->add_enrolment_fee_if_needed;
420
    my $fee = $patron->add_enrolment_fee_if_needed;
421
    ($total) = C4::Members::GetMemberAccountRecords($borrowernumber);
421
    $total = $patron->account->balance;
422
    is( $total,
422
    is( int($total),
423
        $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA,
423
        int($enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA),
424
        "Juvenile growing and become an young adult, they should pay " . ( $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA )
424
        "Juvenile growing and become an young adult, they should pay " . ( $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA )
425
    );
425
    );
426
426
(-)a/t/db_dependent/Members.t (-31 / +1 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 62;
20
use Test::More tests => 61;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Exception;
22
use Test::Exception;
23
23
Lines 373-407 ok( $borrower->{userid}, 'A userid should have been generated correctly' ); Link Here
373
is( Check_Userid( C4::Context->config('user'), '' ), 0,
373
is( Check_Userid( C4::Context->config('user'), '' ), 0,
374
    'Check_Userid should return 0 for the DB user (Bug 12226)');
374
    'Check_Userid should return 0 for the DB user (Bug 12226)');
375
375
376
subtest 'GetMemberAccountRecords' => sub {
377
378
    plan tests => 2;
379
380
    my $borrowernumber = $builder->build({ source => 'Borrower' })->{ borrowernumber };
381
    my $accountline_1  = $builder->build({
382
        source => 'Accountline',
383
        value  => {
384
            borrowernumber    => $borrowernumber,
385
            amountoutstanding => 64.60
386
        }
387
    });
388
389
    my ($total,undef,undef) = GetMemberAccountRecords( $borrowernumber );
390
    is( $total , 64.60, "Rounding works correctly in total calculation (single value)" );
391
392
    my $accountline_2 = $builder->build({
393
        source => 'Accountline',
394
        value  => {
395
            borrowernumber    => $borrowernumber,
396
            amountoutstanding => 10.65
397
        }
398
    });
399
400
    ($total,undef,undef) = GetMemberAccountRecords( $borrowernumber );
401
    is( $total , 75.25, "Rounding works correctly in total calculation (multiple values)" );
402
403
};
404
405
subtest 'GetMemberAccountBalance' => sub {
376
subtest 'GetMemberAccountBalance' => sub {
406
377
407
    plan tests => 6;
378
    plan tests => 6;
408
- 

Return to bug 12001