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

(-)a/C4/Circulation.pm (-14 / +17 lines)
Lines 763-791 sub CanBookBeIssued { Link Here
763
    #
763
    #
764
764
765
    # DEBTS
765
    # DEBTS
766
    my ($amount) =
766
    my ($ballance, $non_issue_ballance, $other_charges) =
767
      C4::Members::GetMemberAccountRecords( $borrower->{'borrowernumber'}, '' && $duedate->ymd() );
767
      C4::Members::GetMemberAccountBallance( $borrower->{'borrowernumber'} );
768
    my $amountlimit = C4::Context->preference("noissuescharge");
768
    my $amountlimit = C4::Context->preference("noissuescharge");
769
    my $allowfineoverride = C4::Context->preference("AllowFineOverride");
769
    my $allowfineoverride = C4::Context->preference("AllowFineOverride");
770
    my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride");
770
    my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride");
771
    if ( C4::Context->preference("IssuingInProcess") ) {
771
    if ( C4::Context->preference("IssuingInProcess") ) {
772
        if ( $amount > $amountlimit && !$inprocess && !$allowfineoverride) {
772
        if ( $non_issue_ballance > $amountlimit && !$inprocess && !$allowfineoverride) {
773
            $issuingimpossible{DEBT} = sprintf( "%.2f", $amount );
773
            $issuingimpossible{DEBT} = sprintf( "%.2f", $non_issue_ballance );
774
        } elsif ( $amount > $amountlimit && !$inprocess && $allowfineoverride) {
774
        } elsif ( $non_issue_ballance > $amountlimit && !$inprocess && $allowfineoverride) {
775
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
775
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
776
        } elsif ( $allfinesneedoverride && $amount > 0 && $amount <= $amountlimit && !$inprocess ) {
776
        } elsif ( $allfinesneedoverride && $non_issue_ballance > 0 && $non_issue_ballance <= $amountlimit && !$inprocess ) {
777
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
777
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
778
        }
778
        }
779
    }
779
    }
780
    else {
780
    else {
781
        if ( $amount > $amountlimit && $allowfineoverride ) {
781
        if ( $non_issue_ballance > $amountlimit && $allowfineoverride ) {
782
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
782
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
783
        } elsif ( $amount > $amountlimit && !$allowfineoverride) {
783
        } elsif ( $non_issue_ballance > $amountlimit && !$allowfineoverride) {
784
            $issuingimpossible{DEBT} = sprintf( "%.2f", $amount );
784
            $issuingimpossible{DEBT} = sprintf( "%.2f", $non_issue_ballance );
785
        } elsif ( $amount > 0 && $allfinesneedoverride ) {
785
        } elsif ( $non_issue_ballance > 0 && $allfinesneedoverride ) {
786
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
786
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
787
        }
787
        }
788
    }
788
    }
789
    if ($ballance > 0 && $other_charges > 0) {
790
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
791
    }
789
792
790
    my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'});
793
    my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'});
791
    if ($blocktype == -1) {
794
    if ($blocktype == -1) {
(-)a/C4/Members.pm (-16 / +47 lines)
Lines 430-450 sub patronflags { Link Here
430
    my %flags;
430
    my %flags;
431
    my ( $patroninformation) = @_;
431
    my ( $patroninformation) = @_;
432
    my $dbh=C4::Context->dbh;
432
    my $dbh=C4::Context->dbh;
433
    my ($amount) = GetMemberAccountRecords( $patroninformation->{'borrowernumber'});
433
    my ($ballance, $owing) = GetMemberAccountBallance( $patroninformation->{'borrowernumber'});
434
    if ( $amount > 0 ) {
434
    if ( $owing > 0 ) {
435
        my %flaginfo;
435
        my %flaginfo;
436
        my $noissuescharge = C4::Context->preference("noissuescharge") || 5;
436
        my $noissuescharge = C4::Context->preference("noissuescharge") || 5;
437
        $flaginfo{'message'} = sprintf "Patron owes \$%.02f", $amount;
437
        $flaginfo{'message'} = sprintf "Patron owes \$%.02f", $owing;
438
        $flaginfo{'amount'}  = sprintf "%.02f", $amount;
438
        $flaginfo{'amount'}  = sprintf "%.02f", $owing;
439
        if ( $amount > $noissuescharge && !C4::Context->preference("AllowFineOverride") ) {
439
        if ( $owing > $noissuescharge && !C4::Context->preference("AllowFineOverride") ) {
440
            $flaginfo{'noissues'} = 1;
440
            $flaginfo{'noissues'} = 1;
441
        }
441
        }
442
        $flags{'CHARGES'} = \%flaginfo;
442
        $flags{'CHARGES'} = \%flaginfo;
443
    }
443
    }
444
    elsif ( $amount < 0 ) {
444
    elsif ( $ballance < 0 ) {
445
        my %flaginfo;
445
        my %flaginfo;
446
        $flaginfo{'message'} = sprintf "Patron has credit of \$%.02f", -$amount;
446
        $flaginfo{'message'} = sprintf "Patron has credit of \$%.02f", -$ballance;
447
        $flaginfo{'amount'}  = sprintf "%.02f", $amount;
447
        $flaginfo{'amount'}  = sprintf "%.02f", $ballance;
448
        $flags{'CREDITS'} = \%flaginfo;
448
        $flags{'CREDITS'} = \%flaginfo;
449
    }
449
    }
450
    if (   $patroninformation->{'gonenoaddress'}
450
    if (   $patroninformation->{'gonenoaddress'}
Lines 1119-1127 total amount outstanding for all of the account lines. Link Here
1119
1119
1120
=cut
1120
=cut
1121
1121
1122
#'
1123
sub GetMemberAccountRecords {
1122
sub GetMemberAccountRecords {
1124
    my ($borrowernumber,$date) = @_;
1123
    my ($borrowernumber) = @_;
1125
    my $dbh = C4::Context->dbh;
1124
    my $dbh = C4::Context->dbh;
1126
    my @acctlines;
1125
    my @acctlines;
1127
    my $numlines = 0;
1126
    my $numlines = 0;
Lines 1129-1142 sub GetMemberAccountRecords { Link Here
1129
                        SELECT * 
1128
                        SELECT * 
1130
                        FROM accountlines 
1129
                        FROM accountlines 
1131
                        WHERE borrowernumber=?);
1130
                        WHERE borrowernumber=?);
1132
    my @bind = ($borrowernumber);
1133
    if ($date && $date ne ''){
1134
            $strsth.=" AND date < ? ";
1135
            push(@bind,$date);
1136
    }
1137
    $strsth.=" ORDER BY date desc,timestamp DESC";
1131
    $strsth.=" ORDER BY date desc,timestamp DESC";
1138
    my $sth= $dbh->prepare( $strsth );
1132
    my $sth= $dbh->prepare( $strsth );
1139
    $sth->execute( @bind );
1133
    $sth->execute( $borrowernumber );
1134
     
1140
    my $total = 0;
1135
    my $total = 0;
1141
    while ( my $data = $sth->fetchrow_hashref ) {
1136
    while ( my $data = $sth->fetchrow_hashref ) {
1142
        if ( $data->{itemnumber} ) {
1137
        if ( $data->{itemnumber} ) {
Lines 1152-1157 sub GetMemberAccountRecords { Link Here
1152
    return ( $total, \@acctlines,$numlines);
1147
    return ( $total, \@acctlines,$numlines);
1153
}
1148
}
1154
1149
1150
=head2 GetMemberAccountBallance
1151
1152
  ($total_ballance, $non_issue_ballance, $other_charges) = &GetMemberAccountBallance($borrowernumber);
1153
1154
Calculates amount immediately owing by the patron - non-issue charges.
1155
Based on GetMemberAccountRecords.
1156
Charges exempt from non-issue are:
1157
* Res (reserves)
1158
* Rent (rental) if RentalsInNoissueCharges syspref is set to false
1159
* Manual invoices if ManInvInNoissueCharges syspref is set to false
1160
1161
=cut
1162
1163
my $ACCOUNT_TYPE_LENGTH = 5; # this is plain ridiculous...
1164
1165
my @not_fines = ('Res');
1166
push @not_fines, 'Rent' unless C4::Context->preference('RentalsInNoissueCharges');
1167
unless ( C4::Context->preference('ManInvInNoissueCharges') ) {
1168
    my $dbh = C4::Context->dbh;
1169
    my $man_inv_types = $dbh->selectcol_arrayref(qq{SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'});
1170
    push @not_fines, map substr($_, 0, $ACCOUNT_TYPE_LENGTH), @$man_inv_types;
1171
}
1172
my %not_fine = map {$_ => 1} @not_fines;
1173
1174
sub GetMemberAccountBallance {
1175
    my ($borrowernumber) = @_;
1176
1177
    my ($total, $acctlines) = GetMemberAccountRecords($borrowernumber);
1178
    my $other_charges = 0;
1179
    foreach (@$acctlines) {
1180
        $other_charges += $_->{amountoutstanding} if $not_fine{ substr($_->{accounttype}, 0, $ACCOUNT_TYPE_LENGTH) };
1181
    }
1182
     
1183
    return ( $total, $total - $other_charges, $other_charges);
1184
}
1185
1155
=head2 GetBorNotifyAcctRecord
1186
=head2 GetBorNotifyAcctRecord
1156
1187
1157
  ($total, $acctlines, $count) = &GetBorNotifyAcctRecord($params,$notifyid);
1188
  ($total, $acctlines, $count) = &GetBorNotifyAcctRecord($params,$notifyid);
(-)a/circ/circulation.pl (-11 / +6 lines)
Lines 186-193 if ( $print eq 'yes' && $borrowernumber ne '' ) { Link Here
186
my $borrowerslist;
186
my $borrowerslist;
187
my $message;
187
my $message;
188
if ($findborrower) {
188
if ($findborrower) {
189
    my $borrowers = Search($findborrower, 'cardnumber');
189
    my $borrowers = Search($findborrower, 'cardnumber') || [];
190
    my @borrowers = @$borrowers;
191
    if (C4::Context->preference("AddPatronLists")) {
190
    if (C4::Context->preference("AddPatronLists")) {
192
        $template->param(
191
        $template->param(
193
            "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
192
            "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
Lines 198-214 if ($findborrower) { Link Here
198
            $template->param(categories=>$categories);
197
            $template->param(categories=>$categories);
199
        }
198
        }
200
    }
199
    }
201
    if ( $#borrowers == -1 ) {
200
    if ( @$borrowers == 0 ) {
202
        $query->param( 'findborrower', '' );
201
        $query->param( 'findborrower', '' );
203
        $message = "'$findborrower'";
202
        $message = "'$findborrower'";
204
    }
203
    }
205
    elsif ( $#borrowers == 0 ) {
204
    elsif ( @$borrowers == 1 ) {
206
        $query->param( 'borrowernumber', $borrowers[0]->{'borrowernumber'} );
205
        $borrowernumber = $borrowers->[0]->{'borrowernumber'};
206
        $query->param( 'borrowernumber', $borrowernumber );
207
        $query->param( 'barcode',           '' );
207
        $query->param( 'barcode',           '' );
208
        $borrowernumber = $borrowers[0]->{'borrowernumber'};
209
    }
208
    }
210
    else {
209
    else {
211
        $borrowerslist = \@borrowers;
210
        $borrowerslist = $borrowers;
212
    }
211
    }
213
}
212
}
214
213
Lines 536-542 foreach my $flag ( sort keys %$flags ) { Link Here
536
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
535
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
537
    if ( $flags->{$flag}->{'noissues'} ) {
536
    if ( $flags->{$flag}->{'noissues'} ) {
538
        $template->param(
537
        $template->param(
539
            flagged  => 1,
540
            noissues => 'true',
538
            noissues => 'true',
541
        );
539
        );
542
        if ( $flag eq 'GNA' ) {
540
        if ( $flag eq 'GNA' ) {
Lines 568-574 foreach my $flag ( sort keys %$flags ) { Link Here
568
        if ( $flag eq 'CHARGES' ) {
566
        if ( $flag eq 'CHARGES' ) {
569
            $template->param(
567
            $template->param(
570
                charges    => 'true',
568
                charges    => 'true',
571
                flagged    => 1,
572
                chargesmsg => $flags->{'CHARGES'}->{'message'},
569
                chargesmsg => $flags->{'CHARGES'}->{'message'},
573
                chargesamount => $flags->{'CHARGES'}->{'amount'},
570
                chargesamount => $flags->{'CHARGES'}->{'amount'},
574
            );
571
            );
Lines 583-589 foreach my $flag ( sort keys %$flags ) { Link Here
583
        elsif ( $flag eq 'ODUES' ) {
580
        elsif ( $flag eq 'ODUES' ) {
584
            $template->param(
581
            $template->param(
585
                odues    => 'true',
582
                odues    => 'true',
586
                flagged  => 1,
587
                oduesmsg => $flags->{'ODUES'}->{'message'}
583
                oduesmsg => $flags->{'ODUES'}->{'message'}
588
            );
584
            );
589
585
Lines 595-601 foreach my $flag ( sort keys %$flags ) { Link Here
595
        elsif ( $flag eq 'NOTES' ) {
591
        elsif ( $flag eq 'NOTES' ) {
596
            $template->param(
592
            $template->param(
597
                notes    => 'true',
593
                notes    => 'true',
598
                flagged  => 1,
599
                notesmsg => $flags->{'NOTES'}->{'message'}
594
                notesmsg => $flags->{'NOTES'}->{'message'}
600
            );
595
            );
601
        }
596
        }
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 325-330 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
325
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('EasyAnalyticalRecords','0','If on, display in the catalogue screens tools to easily setup analytical record relationships','','YesNo');
325
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('EasyAnalyticalRecords','0','If on, display in the catalogue screens tools to easily setup analytical record relationships','','YesNo');
326
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowRecentComments',0,'If ON a link to recent comments will appear in the OPAC masthead',NULL,'YesNo');
326
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowRecentComments',0,'If ON a link to recent comments will appear in the OPAC masthead',NULL,'YesNo');
327
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CircAutoPrintQuickSlip', '1', 'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window or Clear the screen.',NULL,'YesNo');
327
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CircAutoPrintQuickSlip', '1', 'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window or Clear the screen.',NULL,'YesNo');
328
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('RentalsInNoissueCharges', '1', 'Include rental charges when summing up charges for NoissueCharge.',NULL,'YesNo');
329
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ManInvInNoissueCharges', '1', 'Include MAN_INV charges when summing up charges for NoissueCharge.',NULL,'YesNo');
328
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NoticeCSS','','Notices CSS url.',NULL,'free');
330
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NoticeCSS','','Notices CSS url.',NULL,'free');
329
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SlipCSS','','Slips CSS url.',NULL,'free');
331
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SlipCSS','','Slips CSS url.',NULL,'free');
330
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('TransferWhenCancelAllWaitingHolds','0','Transfer items when cancelling all waiting holds',NULL,'YesNo');
332
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('TransferWhenCancelAllWaitingHolds','0','Transfer items when cancelling all waiting holds',NULL,'YesNo');
(-)a/installer/data/mysql/updatedatabase.pl (+10 lines)
Lines 5657-5662 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5657
    SetVersion ($DBversion);
5657
    SetVersion ($DBversion);
5658
}
5658
}
5659
5659
5660
5661
5662
$DBversion = "3.09.00.XXX";
5663
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5664
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('RentalsInNoissueCharges', '1', 'Include rental charges when summing up charges for NoissueCharge.',NULL,'YesNo');");
5665
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ManInvInNoissueCharges', '1', 'Include MAN_INV charges when summing up charges for NoissueCharge.',NULL,'YesNo');");
5666
    print "Upgrade to $DBversion done (Add sysprefs RentalsInNoissueCharges and ManInvInNoissueCharges.)\n";
5667
    SetVersion($DBversion);
5668
}
5669
5660
=head1 FUNCTIONS
5670
=head1 FUNCTIONS
5661
5671
5662
=head2 TableExists($table)
5672
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+12 lines)
Lines 220-225 Circulation: Link Here
220
              class: integer
220
              class: integer
221
            - '[% local_currency %] in fines.'
221
            - '[% local_currency %] in fines.'
222
        -
222
        -
223
            - pref: RentalsInNoissueCharges
224
              choices:
225
                  yes: Include
226
                  no: "Don't include"
227
            - rental charges when summing up charges for NoissueCharge.
228
        -
229
            - pref: ManInvInNoissueCharges
230
              choices:
231
                  yes: Include
232
                  no: "Don't include"
233
            - MAN_INV charges when summing up charges for NoissueCharge.
234
        -
223
            - pref: ReturnBeforeExpiry
235
            - pref: ReturnBeforeExpiry
224
              choices:
236
              choices:
225
                  yes: Require
237
                  yes: Require
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+4 lines)
Lines 243-248 function validate1(date) { Link Here
243
    <div class="dialog message">This item has been lost with a status of "[% alert.ITEM_LOST %]".</div>
243
    <div class="dialog message">This item has been lost with a status of "[% alert.ITEM_LOST %]".</div>
244
[% END %]
244
[% END %]
245
245
246
[% IF ( alert.OTHER_CHARGES ) %]
247
    <div class="dialog message">The patron has unpaid charges for reserves, rentals etc of [% alert.OTHER_CHARGES %]</div>
248
[% END %]
249
246
[% IF ( NEEDSCONFIRMATION ) %]
250
[% IF ( NEEDSCONFIRMATION ) %]
247
<div class="yui-g">
251
<div class="yui-g">
248
252
(-)a/opac/opac-user.pl (-1 lines)
Lines 141-147 $template->param( BORROWER_INFO => \@bordat, Link Here
141
                    OPACMySummaryHTML => (C4::Context->preference("OPACMySummaryHTML")) ? 1 : 0,
141
                    OPACMySummaryHTML => (C4::Context->preference("OPACMySummaryHTML")) ? 1 : 0,
142
                    surname           => $borr->{surname},
142
                    surname           => $borr->{surname},
143
                    showname          => $borr->{showname},
143
                    showname          => $borr->{showname},
144
145
                );
144
                );
146
145
147
#get issued items ....
146
#get issued items ....
(-)a/t/db_dependent/lib/KohaTest/Members.pm (-1 / +1 lines)
Lines 27-32 sub methods : Test( 1 ) { Link Here
27
                      GetPendingIssues 
27
                      GetPendingIssues 
28
                      GetAllIssues 
28
                      GetAllIssues 
29
                      GetMemberAccountRecords 
29
                      GetMemberAccountRecords 
30
                      GetMemberAccountBallance
30
                      GetBorNotifyAcctRecord 
31
                      GetBorNotifyAcctRecord 
31
                      checkuniquemember 
32
                      checkuniquemember 
32
                      checkcardnumber 
33
                      checkcardnumber 
33
- 

Return to bug 7243