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

(-)a/C4/Circulation.pm (-14 / +17 lines)
Lines 771-799 sub CanBookBeIssued { Link Here
771
    #
771
    #
772
772
773
    # DEBTS
773
    # DEBTS
774
    my ($amount) =
774
    my ($ballance, $non_issue_ballance, $other_charges) =
775
      C4::Members::GetMemberAccountRecords( $borrower->{'borrowernumber'}, '' && $duedate->ymd() );
775
      C4::Members::GetMemberAccountBallance( $borrower->{'borrowernumber'} );
776
    my $amountlimit = C4::Context->preference("noissuescharge");
776
    my $amountlimit = C4::Context->preference("noissuescharge");
777
    my $allowfineoverride = C4::Context->preference("AllowFineOverride");
777
    my $allowfineoverride = C4::Context->preference("AllowFineOverride");
778
    my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride");
778
    my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride");
779
    if ( C4::Context->preference("IssuingInProcess") ) {
779
    if ( C4::Context->preference("IssuingInProcess") ) {
780
        if ( $amount > $amountlimit && !$inprocess && !$allowfineoverride) {
780
        if ( $non_issue_ballance > $amountlimit && !$inprocess && !$allowfineoverride) {
781
            $issuingimpossible{DEBT} = sprintf( "%.2f", $amount );
781
            $issuingimpossible{DEBT} = sprintf( "%.2f", $non_issue_ballance );
782
        } elsif ( $amount > $amountlimit && !$inprocess && $allowfineoverride) {
782
        } elsif ( $non_issue_ballance > $amountlimit && !$inprocess && $allowfineoverride) {
783
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
783
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
784
        } elsif ( $allfinesneedoverride && $amount > 0 && $amount <= $amountlimit && !$inprocess ) {
784
        } elsif ( $allfinesneedoverride && $non_issue_ballance > 0 && $non_issue_ballance <= $amountlimit && !$inprocess ) {
785
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
785
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
786
        }
786
        }
787
    }
787
    }
788
    else {
788
    else {
789
        if ( $amount > $amountlimit && $allowfineoverride ) {
789
        if ( $non_issue_ballance > $amountlimit && $allowfineoverride ) {
790
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
790
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
791
        } elsif ( $amount > $amountlimit && !$allowfineoverride) {
791
        } elsif ( $non_issue_ballance > $amountlimit && !$allowfineoverride) {
792
            $issuingimpossible{DEBT} = sprintf( "%.2f", $amount );
792
            $issuingimpossible{DEBT} = sprintf( "%.2f", $non_issue_ballance );
793
        } elsif ( $amount > 0 && $allfinesneedoverride ) {
793
        } elsif ( $non_issue_ballance > 0 && $allfinesneedoverride ) {
794
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
794
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
795
        }
795
        }
796
    }
796
    }
797
    if ($ballance > 0 && $other_charges > 0) {
798
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
799
    }
797
800
798
    my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'});
801
    my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'});
799
    if ($blocktype == -1) {
802
    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 1112-1120 total amount outstanding for all of the account lines. Link Here
1112
1112
1113
=cut
1113
=cut
1114
1114
1115
#'
1116
sub GetMemberAccountRecords {
1115
sub GetMemberAccountRecords {
1117
    my ($borrowernumber,$date) = @_;
1116
    my ($borrowernumber) = @_;
1118
    my $dbh = C4::Context->dbh;
1117
    my $dbh = C4::Context->dbh;
1119
    my @acctlines;
1118
    my @acctlines;
1120
    my $numlines = 0;
1119
    my $numlines = 0;
Lines 1122-1135 sub GetMemberAccountRecords { Link Here
1122
                        SELECT * 
1121
                        SELECT * 
1123
                        FROM accountlines 
1122
                        FROM accountlines 
1124
                        WHERE borrowernumber=?);
1123
                        WHERE borrowernumber=?);
1125
    my @bind = ($borrowernumber);
1126
    if ($date && $date ne ''){
1127
            $strsth.=" AND date < ? ";
1128
            push(@bind,$date);
1129
    }
1130
    $strsth.=" ORDER BY date desc,timestamp DESC";
1124
    $strsth.=" ORDER BY date desc,timestamp DESC";
1131
    my $sth= $dbh->prepare( $strsth );
1125
    my $sth= $dbh->prepare( $strsth );
1132
    $sth->execute( @bind );
1126
    $sth->execute( $borrowernumber );
1127
1133
    my $total = 0;
1128
    my $total = 0;
1134
    while ( my $data = $sth->fetchrow_hashref ) {
1129
    while ( my $data = $sth->fetchrow_hashref ) {
1135
        if ( $data->{itemnumber} ) {
1130
        if ( $data->{itemnumber} ) {
Lines 1145-1150 sub GetMemberAccountRecords { Link Here
1145
    return ( $total, \@acctlines,$numlines);
1140
    return ( $total, \@acctlines,$numlines);
1146
}
1141
}
1147
1142
1143
=head2 GetMemberAccountBallance
1144
1145
  ($total_ballance, $non_issue_ballance, $other_charges) = &GetMemberAccountBallance($borrowernumber);
1146
1147
Calculates amount immediately owing by the patron - non-issue charges.
1148
Based on GetMemberAccountRecords.
1149
Charges exempt from non-issue are:
1150
* Res (reserves)
1151
* Rent (rental) if RentalsInNoissueCharges syspref is set to false
1152
* Manual invoices if ManInvInNoissueCharges syspref is set to false
1153
1154
=cut
1155
1156
my $ACCOUNT_TYPE_LENGTH = 5; # this is plain ridiculous...
1157
1158
my @not_fines = ('Res');
1159
push @not_fines, 'Rent' unless C4::Context->preference('RentalsInNoissueCharges');
1160
unless ( C4::Context->preference('ManInvInNoissueCharges') ) {
1161
    my $dbh = C4::Context->dbh;
1162
    my $man_inv_types = $dbh->selectcol_arrayref(qq{SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'});
1163
    push @not_fines, map substr($_, 0, $ACCOUNT_TYPE_LENGTH), @$man_inv_types;
1164
}
1165
my %not_fine = map {$_ => 1} @not_fines;
1166
1167
sub GetMemberAccountBallance {
1168
    my ($borrowernumber) = @_;
1169
1170
    my ($total, $acctlines) = GetMemberAccountRecords($borrowernumber);
1171
    my $other_charges = 0;
1172
    foreach (@$acctlines) {
1173
        $other_charges += $_->{amountoutstanding} if $not_fine{ substr($_->{accounttype}, 0, $ACCOUNT_TYPE_LENGTH) };
1174
    }
1175
1176
    return ( $total, $total - $other_charges, $other_charges);
1177
}
1178
1148
=head2 GetBorNotifyAcctRecord
1179
=head2 GetBorNotifyAcctRecord
1149
1180
1150
  ($total, $acctlines, $count) = &GetBorNotifyAcctRecord($params,$notifyid);
1181
  ($total, $acctlines, $count) = &GetBorNotifyAcctRecord($params,$notifyid);
(-)a/circ/circulation.pl (-11 / +6 lines)
Lines 190-197 if ( $print eq 'yes' && $borrowernumber ne '' ) { Link Here
190
my $borrowerslist;
190
my $borrowerslist;
191
my $message;
191
my $message;
192
if ($findborrower) {
192
if ($findborrower) {
193
    my $borrowers = Search($findborrower, 'cardnumber');
193
    my $borrowers = Search($findborrower, 'cardnumber') || [];
194
    my @borrowers = @$borrowers;
195
    if (C4::Context->preference("AddPatronLists")) {
194
    if (C4::Context->preference("AddPatronLists")) {
196
        $template->param(
195
        $template->param(
197
            "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
196
            "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
Lines 202-218 if ($findborrower) { Link Here
202
            $template->param(categories=>$categories);
201
            $template->param(categories=>$categories);
203
        }
202
        }
204
    }
203
    }
205
    if ( $#borrowers == -1 ) {
204
    if ( @$borrowers == 0 ) {
206
        $query->param( 'findborrower', '' );
205
        $query->param( 'findborrower', '' );
207
        $message = "'$findborrower'";
206
        $message = "'$findborrower'";
208
    }
207
    }
209
    elsif ( $#borrowers == 0 ) {
208
    elsif ( @$borrowers == 1 ) {
210
        $query->param( 'borrowernumber', $borrowers[0]->{'borrowernumber'} );
209
        $borrowernumber = $borrowers->[0]->{'borrowernumber'};
210
        $query->param( 'borrowernumber', $borrowernumber );
211
        $query->param( 'barcode',           '' );
211
        $query->param( 'barcode',           '' );
212
        $borrowernumber = $borrowers[0]->{'borrowernumber'};
213
    }
212
    }
214
    else {
213
    else {
215
        $borrowerslist = \@borrowers;
214
        $borrowerslist = $borrowers;
216
    }
215
    }
217
}
216
}
218
217
Lines 541-547 foreach my $flag ( sort keys %$flags ) { Link Here
541
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
540
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
542
    if ( $flags->{$flag}->{'noissues'} ) {
541
    if ( $flags->{$flag}->{'noissues'} ) {
543
        $template->param(
542
        $template->param(
544
            flagged  => 1,
545
            noissues => 'true',
543
            noissues => 'true',
546
        );
544
        );
547
        if ( $flag eq 'GNA' ) {
545
        if ( $flag eq 'GNA' ) {
Lines 573-579 foreach my $flag ( sort keys %$flags ) { Link Here
573
        if ( $flag eq 'CHARGES' ) {
571
        if ( $flag eq 'CHARGES' ) {
574
            $template->param(
572
            $template->param(
575
                charges    => 'true',
573
                charges    => 'true',
576
                flagged    => 1,
577
                chargesmsg => $flags->{'CHARGES'}->{'message'},
574
                chargesmsg => $flags->{'CHARGES'}->{'message'},
578
                chargesamount => $flags->{'CHARGES'}->{'amount'},
575
                chargesamount => $flags->{'CHARGES'}->{'amount'},
579
            );
576
            );
Lines 588-594 foreach my $flag ( sort keys %$flags ) { Link Here
588
        elsif ( $flag eq 'ODUES' ) {
585
        elsif ( $flag eq 'ODUES' ) {
589
            $template->param(
586
            $template->param(
590
                odues    => 'true',
587
                odues    => 'true',
591
                flagged  => 1,
592
                oduesmsg => $flags->{'ODUES'}->{'message'}
588
                oduesmsg => $flags->{'ODUES'}->{'message'}
593
            );
589
            );
594
590
Lines 600-606 foreach my $flag ( sort keys %$flags ) { Link Here
600
        elsif ( $flag eq 'NOTES' ) {
596
        elsif ( $flag eq 'NOTES' ) {
601
            $template->param(
597
            $template->param(
602
                notes    => 'true',
598
                notes    => 'true',
603
                flagged  => 1,
604
                notesmsg => $flags->{'NOTES'}->{'message'}
599
                notesmsg => $flags->{'NOTES'}->{'message'}
605
            );
600
            );
606
        }
601
        }
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 327-332 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
327
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');
327
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');
328
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');
328
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');
329
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');
329
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');
330
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('RentalsInNoissueCharges', '1', 'Include rental charges when summing up charges for NoissueCharge.',NULL,'YesNo');
331
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ManInvInNoissueCharges', '1', 'Include MAN_INV charges when summing up charges for NoissueCharge.',NULL,'YesNo');
330
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NoticeCSS','','Notices CSS url.',NULL,'free');
332
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NoticeCSS','','Notices CSS url.',NULL,'free');
331
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SlipCSS','','Slips CSS url.',NULL,'free');
333
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SlipCSS','','Slips CSS url.',NULL,'free');
332
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('TransferWhenCancelAllWaitingHolds','0','Transfer items when cancelling all waiting holds',NULL,'YesNo');
334
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 (+8 lines)
Lines 5656-5661 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5656
    SetVersion ($DBversion);
5656
    SetVersion ($DBversion);
5657
}
5657
}
5658
5658
5659
5659
$DBversion = '3.09.00.033';
5660
$DBversion = '3.09.00.033';
5660
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5661
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5661
   $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSuppressionByIPRange','','Restrict the suppression to IP adresses outside of the IP range','','free');");
5662
   $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSuppressionByIPRange','','Restrict the suppression to IP adresses outside of the IP range','','free');");
Lines 5973-5978 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5973
    SetVersion($DBversion);
5974
    SetVersion($DBversion);
5974
}
5975
}
5975
5976
5977
$DBversion = "3.09.00.XXX";
5978
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5979
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('RentalsInNoissueCharges', '1', 'Include rental charges when summing up charges for NoissueCharge.',NULL,'YesNo');");
5980
    $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');");
5981
    print "Upgrade to $DBversion done (Add sysprefs RentalsInNoissueCharges and ManInvInNoissueCharges.)\n";
5982
    SetVersion($DBversion);
5983
}
5976
5984
5977
=head1 FUNCTIONS
5985
=head1 FUNCTIONS
5978
5986
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+12 lines)
Lines 250-255 Circulation: Link Here
250
              class: integer
250
              class: integer
251
            - '[% local_currency %] in fines.'
251
            - '[% local_currency %] in fines.'
252
        -
252
        -
253
            - pref: RentalsInNoissueCharges
254
              choices:
255
                  yes: Include
256
                  no: "Don't include"
257
            - rental charges when summing up charges for NoissueCharge.
258
        -
259
            - pref: ManInvInNoissueCharges
260
              choices:
261
                  yes: Include
262
                  no: "Don't include"
263
            - MAN_INV charges when summing up charges for NoissueCharge.
264
        -
253
            - pref: ReturnBeforeExpiry
265
            - pref: ReturnBeforeExpiry
254
              choices:
266
              choices:
255
                  yes: Require
267
                  yes: Require
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+4 lines)
Lines 310-315 function validate1(date) { Link Here
310
    <div class="dialog message">This item has been lost with a status of "[% alert.ITEM_LOST %]".</div>
310
    <div class="dialog message">This item has been lost with a status of "[% alert.ITEM_LOST %]".</div>
311
[% END %]
311
[% END %]
312
312
313
[% IF ( alert.OTHER_CHARGES ) %]
314
    <div class="dialog message">The patron has unpaid charges for reserves, rentals etc of [% alert.OTHER_CHARGES %]</div>
315
[% END %]
316
313
[% IF ( NEEDSCONFIRMATION ) %]
317
[% IF ( NEEDSCONFIRMATION ) %]
314
<div class="yui-g">
318
<div class="yui-g">
315
319
(-)a/opac/opac-user.pl (-1 lines)
Lines 142-148 $template->param( BORROWER_INFO => \@bordat, Link Here
142
                    OPACMySummaryHTML => (C4::Context->preference("OPACMySummaryHTML")) ? 1 : 0,
142
                    OPACMySummaryHTML => (C4::Context->preference("OPACMySummaryHTML")) ? 1 : 0,
143
                    surname           => $borr->{surname},
143
                    surname           => $borr->{surname},
144
                    showname          => $borr->{showname},
144
                    showname          => $borr->{showname},
145
146
                );
145
                );
147
146
148
#get issued items ....
147
#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