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

(-)a/C4/Circulation.pm (-14 / +17 lines)
Lines 772-800 sub CanBookBeIssued { Link Here
772
    #
772
    #
773
773
774
    # DEBTS
774
    # DEBTS
775
    my ($amount) =
775
    my ($ballance, $non_issue_ballance, $other_charges) =
776
      C4::Members::GetMemberAccountRecords( $borrower->{'borrowernumber'}, '' && $duedate->ymd() );
776
      C4::Members::GetMemberAccountBallance( $borrower->{'borrowernumber'} );
777
    my $amountlimit = C4::Context->preference("noissuescharge");
777
    my $amountlimit = C4::Context->preference("noissuescharge");
778
    my $allowfineoverride = C4::Context->preference("AllowFineOverride");
778
    my $allowfineoverride = C4::Context->preference("AllowFineOverride");
779
    my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride");
779
    my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride");
780
    if ( C4::Context->preference("IssuingInProcess") ) {
780
    if ( C4::Context->preference("IssuingInProcess") ) {
781
        if ( $amount > $amountlimit && !$inprocess && !$allowfineoverride) {
781
        if ( $non_issue_ballance > $amountlimit && !$inprocess && !$allowfineoverride) {
782
            $issuingimpossible{DEBT} = sprintf( "%.2f", $amount );
782
            $issuingimpossible{DEBT} = sprintf( "%.2f", $non_issue_ballance );
783
        } elsif ( $amount > $amountlimit && !$inprocess && $allowfineoverride) {
783
        } elsif ( $non_issue_ballance > $amountlimit && !$inprocess && $allowfineoverride) {
784
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
784
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
785
        } elsif ( $allfinesneedoverride && $amount > 0 && $amount <= $amountlimit && !$inprocess ) {
785
        } elsif ( $allfinesneedoverride && $non_issue_ballance > 0 && $non_issue_ballance <= $amountlimit && !$inprocess ) {
786
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
786
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
787
        }
787
        }
788
    }
788
    }
789
    else {
789
    else {
790
        if ( $amount > $amountlimit && $allowfineoverride ) {
790
        if ( $non_issue_ballance > $amountlimit && $allowfineoverride ) {
791
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
791
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
792
        } elsif ( $amount > $amountlimit && !$allowfineoverride) {
792
        } elsif ( $non_issue_ballance > $amountlimit && !$allowfineoverride) {
793
            $issuingimpossible{DEBT} = sprintf( "%.2f", $amount );
793
            $issuingimpossible{DEBT} = sprintf( "%.2f", $non_issue_ballance );
794
        } elsif ( $amount > 0 && $allfinesneedoverride ) {
794
        } elsif ( $non_issue_ballance > 0 && $allfinesneedoverride ) {
795
            $needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
795
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_ballance );
796
        }
796
        }
797
    }
797
    }
798
    if ($ballance > 0 && $other_charges > 0) {
799
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
800
    }
798
801
799
    my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'});
802
    my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'});
800
    if ($blocktype == -1) {
803
    if ($blocktype == -1) {
(-)a/C4/Members.pm (-16 / +47 lines)
Lines 432-452 sub patronflags { Link Here
432
    my %flags;
432
    my %flags;
433
    my ( $patroninformation) = @_;
433
    my ( $patroninformation) = @_;
434
    my $dbh=C4::Context->dbh;
434
    my $dbh=C4::Context->dbh;
435
    my ($amount) = GetMemberAccountRecords( $patroninformation->{'borrowernumber'});
435
    my ($ballance, $owing) = GetMemberAccountBallance( $patroninformation->{'borrowernumber'});
436
    if ( $amount > 0 ) {
436
    if ( $owing > 0 ) {
437
        my %flaginfo;
437
        my %flaginfo;
438
        my $noissuescharge = C4::Context->preference("noissuescharge") || 5;
438
        my $noissuescharge = C4::Context->preference("noissuescharge") || 5;
439
        $flaginfo{'message'} = sprintf "Patron owes \$%.02f", $amount;
439
        $flaginfo{'message'} = sprintf "Patron owes \$%.02f", $owing;
440
        $flaginfo{'amount'}  = sprintf "%.02f", $amount;
440
        $flaginfo{'amount'}  = sprintf "%.02f", $owing;
441
        if ( $amount > $noissuescharge && !C4::Context->preference("AllowFineOverride") ) {
441
        if ( $owing > $noissuescharge && !C4::Context->preference("AllowFineOverride") ) {
442
            $flaginfo{'noissues'} = 1;
442
            $flaginfo{'noissues'} = 1;
443
        }
443
        }
444
        $flags{'CHARGES'} = \%flaginfo;
444
        $flags{'CHARGES'} = \%flaginfo;
445
    }
445
    }
446
    elsif ( $amount < 0 ) {
446
    elsif ( $ballance < 0 ) {
447
        my %flaginfo;
447
        my %flaginfo;
448
        $flaginfo{'message'} = sprintf "Patron has credit of \$%.02f", -$amount;
448
        $flaginfo{'message'} = sprintf "Patron has credit of \$%.02f", -$ballance;
449
        $flaginfo{'amount'}  = sprintf "%.02f", $amount;
449
        $flaginfo{'amount'}  = sprintf "%.02f", $ballance;
450
        $flags{'CREDITS'} = \%flaginfo;
450
        $flags{'CREDITS'} = \%flaginfo;
451
    }
451
    }
452
    if (   $patroninformation->{'gonenoaddress'}
452
    if (   $patroninformation->{'gonenoaddress'}
Lines 1128-1136 total amount outstanding for all of the account lines. Link Here
1128
1128
1129
=cut
1129
=cut
1130
1130
1131
#'
1132
sub GetMemberAccountRecords {
1131
sub GetMemberAccountRecords {
1133
    my ($borrowernumber,$date) = @_;
1132
    my ($borrowernumber) = @_;
1134
    my $dbh = C4::Context->dbh;
1133
    my $dbh = C4::Context->dbh;
1135
    my @acctlines;
1134
    my @acctlines;
1136
    my $numlines = 0;
1135
    my $numlines = 0;
Lines 1138-1151 sub GetMemberAccountRecords { Link Here
1138
                        SELECT * 
1137
                        SELECT * 
1139
                        FROM accountlines 
1138
                        FROM accountlines 
1140
                        WHERE borrowernumber=?);
1139
                        WHERE borrowernumber=?);
1141
    my @bind = ($borrowernumber);
1142
    if ($date && $date ne ''){
1143
            $strsth.=" AND date < ? ";
1144
            push(@bind,$date);
1145
    }
1146
    $strsth.=" ORDER BY date desc,timestamp DESC";
1140
    $strsth.=" ORDER BY date desc,timestamp DESC";
1147
    my $sth= $dbh->prepare( $strsth );
1141
    my $sth= $dbh->prepare( $strsth );
1148
    $sth->execute( @bind );
1142
    $sth->execute( $borrowernumber );
1143
1149
    my $total = 0;
1144
    my $total = 0;
1150
    while ( my $data = $sth->fetchrow_hashref ) {
1145
    while ( my $data = $sth->fetchrow_hashref ) {
1151
        if ( $data->{itemnumber} ) {
1146
        if ( $data->{itemnumber} ) {
Lines 1161-1166 sub GetMemberAccountRecords { Link Here
1161
    return ( $total, \@acctlines,$numlines);
1156
    return ( $total, \@acctlines,$numlines);
1162
}
1157
}
1163
1158
1159
=head2 GetMemberAccountBallance
1160
1161
  ($total_ballance, $non_issue_ballance, $other_charges) = &GetMemberAccountBallance($borrowernumber);
1162
1163
Calculates amount immediately owing by the patron - non-issue charges.
1164
Based on GetMemberAccountRecords.
1165
Charges exempt from non-issue are:
1166
* Res (reserves)
1167
* Rent (rental) if RentalsInNoissueCharges syspref is set to false
1168
* Manual invoices if ManInvInNoissueCharges syspref is set to false
1169
1170
=cut
1171
1172
my $ACCOUNT_TYPE_LENGTH = 5; # this is plain ridiculous...
1173
1174
my @not_fines = ('Res');
1175
push @not_fines, 'Rent' unless C4::Context->preference('RentalsInNoissueCharges');
1176
unless ( C4::Context->preference('ManInvInNoissueCharges') ) {
1177
    my $dbh = C4::Context->dbh;
1178
    my $man_inv_types = $dbh->selectcol_arrayref(qq{SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'});
1179
    push @not_fines, map substr($_, 0, $ACCOUNT_TYPE_LENGTH), @$man_inv_types;
1180
}
1181
my %not_fine = map {$_ => 1} @not_fines;
1182
1183
sub GetMemberAccountBallance {
1184
    my ($borrowernumber) = @_;
1185
1186
    my ($total, $acctlines) = GetMemberAccountRecords($borrowernumber);
1187
    my $other_charges = 0;
1188
    foreach (@$acctlines) {
1189
        $other_charges += $_->{amountoutstanding} if $not_fine{ substr($_->{accounttype}, 0, $ACCOUNT_TYPE_LENGTH) };
1190
    }
1191
1192
    return ( $total, $total - $other_charges, $other_charges);
1193
}
1194
1164
=head2 GetBorNotifyAcctRecord
1195
=head2 GetBorNotifyAcctRecord
1165
1196
1166
  ($total, $acctlines, $count) = &GetBorNotifyAcctRecord($params,$notifyid);
1197
  ($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 (-1 / +9 lines)
Lines 5658-5663 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5658
    SetVersion ($DBversion);
5658
    SetVersion ($DBversion);
5659
}
5659
}
5660
5660
5661
5661
$DBversion = '3.09.00.033';
5662
$DBversion = '3.09.00.033';
5662
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5663
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5663
   $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSuppressionByIPRange','','Restrict the suppression to IP adresses outside of the IP range','','free');");
5664
   $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 5972-5978 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5972
    SetVersion($DBversion);
5973
    SetVersion($DBversion);
5973
}
5974
}
5974
5975
5975
5976
$DBversion = "3.09.00.057";
5976
$DBversion = "3.09.00.057";
5977
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5977
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5978
    $dbh->do("ALTER TABLE aqbasket ADD deliveryplace VARCHAR(10) default NULL AFTER basketgroupid;");
5978
    $dbh->do("ALTER TABLE aqbasket ADD deliveryplace VARCHAR(10) default NULL AFTER basketgroupid;");
Lines 6339-6344 if ( CheckVersion($DBversion) ) { Link Here
6339
   SetVersion ($DBversion);
6339
   SetVersion ($DBversion);
6340
}
6340
}
6341
6341
6342
$DBversion = "3.11.00.XXX";
6343
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6344
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('RentalsInNoissueCharges', '1', 'Include rental charges when summing up charges for NoissueCharge.',NULL,'YesNo');");
6345
    $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');");
6346
    print "Upgrade to $DBversion done (Add sysprefs RentalsInNoissueCharges and ManInvInNoissueCharges.)\n";
6347
    SetVersion($DBversion);
6348
}
6349
6342
=head1 FUNCTIONS
6350
=head1 FUNCTIONS
6343
6351
6344
=head2 TableExists($table)
6352
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+12 lines)
Lines 265-270 Circulation: Link Here
265
              class: integer
265
              class: integer
266
            - '[% local_currency %] in fines.'
266
            - '[% local_currency %] in fines.'
267
        -
267
        -
268
            - pref: RentalsInNoissueCharges
269
              choices:
270
                  yes: Include
271
                  no: "Don't include"
272
            - rental charges when summing up charges for NoissueCharge.
273
        -
274
            - pref: ManInvInNoissueCharges
275
              choices:
276
                  yes: Include
277
                  no: "Don't include"
278
            - MAN_INV charges when summing up charges for NoissueCharge.
279
        -
268
            - pref: ReturnBeforeExpiry
280
            - pref: ReturnBeforeExpiry
269
              choices:
281
              choices:
270
                  yes: Require
282
                  yes: Require
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+4 lines)
Lines 315-320 function validate1(date) { Link Here
315
    <div class="dialog message">This item has been lost with a status of "[% alert.ITEM_LOST %]".</div>
315
    <div class="dialog message">This item has been lost with a status of "[% alert.ITEM_LOST %]".</div>
316
[% END %]
316
[% END %]
317
317
318
[% IF ( alert.OTHER_CHARGES ) %]
319
    <div class="dialog message">The patron has unpaid charges for reserves, rentals etc of [% alert.OTHER_CHARGES %]</div>
320
[% END %]
321
318
[% IF ( NEEDSCONFIRMATION ) %]
322
[% IF ( NEEDSCONFIRMATION ) %]
319
<div class="yui-g">
323
<div class="yui-g">
320
324
(-)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