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

(-)a/C4/Circulation.pm (+37 lines)
Lines 53-58 use Koha::Borrower::Debarments; Link Here
53
use Koha::Database;
53
use Koha::Database;
54
use Carp;
54
use Carp;
55
use List::MoreUtils qw( uniq );
55
use List::MoreUtils qw( uniq );
56
use Scalar::Util qw( looks_like_number );
56
use Date::Calc qw(
57
use Date::Calc qw(
57
  Today
58
  Today
58
  Today_and_Now
59
  Today_and_Now
Lines 840-848 sub CanBookBeIssued { Link Here
840
    # DEBTS
841
    # DEBTS
841
    my ($balance, $non_issue_charges, $other_charges) =
842
    my ($balance, $non_issue_charges, $other_charges) =
842
      C4::Members::GetMemberAccountBalance( $borrower->{'borrowernumber'} );
843
      C4::Members::GetMemberAccountBalance( $borrower->{'borrowernumber'} );
844
843
    my $amountlimit = C4::Context->preference("noissuescharge");
845
    my $amountlimit = C4::Context->preference("noissuescharge");
844
    my $allowfineoverride = C4::Context->preference("AllowFineOverride");
846
    my $allowfineoverride = C4::Context->preference("AllowFineOverride");
845
    my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride");
847
    my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride");
848
849
    # Check the debt of this patrons guarantees
850
    my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees");
851
    $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
852
    if ( defined $no_issues_charge_guarantees ) {
853
        my $b = Koha::Borrowers->find( $borrower->{borrowernumber} );
854
        my @guarantees = $b->guarantees();
855
        my $guarantees_non_issues_charges;
856
        foreach my $g ( @guarantees ) {
857
            my ( $b, $n, $o ) = C4::Members::GetMemberAccountBalance( $g->id );
858
            $guarantees_non_issues_charges += $n;
859
        }
860
861
        if ( C4::Context->preference("IssuingInProcess") ) {
862
            if ( $guarantees_non_issues_charges > $no_issues_charge_guarantees && !$inprocess && !$allowfineoverride) {
863
                $issuingimpossible{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges );
864
            } elsif ( $guarantees_non_issues_charges > $no_issues_charge_guarantees && !$inprocess && $allowfineoverride) {
865
                $needsconfirmation{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges );
866
            } elsif ( $allfinesneedoverride && $guarantees_non_issues_charges > 0 && $guarantees_non_issues_charges <= $no_issues_charge_guarantees && !$inprocess ) {
867
                $needsconfirmation{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges );
868
            }
869
        }
870
        else {
871
            if ( $guarantees_non_issues_charges > $no_issues_charge_guarantees && $allowfineoverride ) {
872
                $needsconfirmation{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges );
873
            } elsif ( $guarantees_non_issues_charges > $no_issues_charge_guarantees && !$allowfineoverride) {
874
                $issuingimpossible{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges );
875
            } elsif ( $guarantees_non_issues_charges > 0 && $allfinesneedoverride ) {
876
                $needsconfirmation{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges );
877
            }
878
        }
879
880
    }
881
846
    if ( C4::Context->preference("IssuingInProcess") ) {
882
    if ( C4::Context->preference("IssuingInProcess") ) {
847
        if ( $non_issue_charges > $amountlimit && !$inprocess && !$allowfineoverride) {
883
        if ( $non_issue_charges > $amountlimit && !$inprocess && !$allowfineoverride) {
848
            $issuingimpossible{DEBT} = sprintf( "%.2f", $non_issue_charges );
884
            $issuingimpossible{DEBT} = sprintf( "%.2f", $non_issue_charges );
Lines 861-866 sub CanBookBeIssued { Link Here
861
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_charges );
897
            $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_charges );
862
        }
898
        }
863
    }
899
    }
900
864
    if ($balance > 0 && $other_charges > 0) {
901
    if ($balance > 0 && $other_charges > 0) {
865
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
902
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
866
    }
903
    }
(-)a/C4/Members.pm (-4 / +27 lines)
Lines 24-29 use strict; Link Here
24
#use warnings; FIXME - Bug 2505
24
#use warnings; FIXME - Bug 2505
25
use C4::Context;
25
use C4::Context;
26
use String::Random qw( random_string );
26
use String::Random qw( random_string );
27
use Scalar::Util qw( looks_like_number );
27
use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/;
28
use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/;
28
use C4::Log; # logaction
29
use C4::Log; # logaction
29
use C4::Overdues;
30
use C4::Overdues;
Lines 326-338 sub patronflags { Link Here
326
    my ($balance, $owing) = GetMemberAccountBalance( $patroninformation->{'borrowernumber'});
327
    my ($balance, $owing) = GetMemberAccountBalance( $patroninformation->{'borrowernumber'});
327
    if ( $owing > 0 ) {
328
    if ( $owing > 0 ) {
328
        my %flaginfo;
329
        my %flaginfo;
329
        my $noissuescharge = C4::Context->preference("noissuescharge") || 5;
330
        my $noissuescharge = c4::context->preference("noissuescharge") || 5;
330
        $flaginfo{'message'} = sprintf 'Patron owes %.02f', $owing;
331
        $flaginfo{'message'} = sprintf 'patron owes %.02f', $owing;
331
        $flaginfo{'amount'}  = sprintf "%.02f", $owing;
332
        $flaginfo{'amount'}  = sprintf "%.02f", $owing;
332
        if ( $owing > $noissuescharge && !C4::Context->preference("AllowFineOverride") ) {
333
        if ( $owing > $noissuescharge && !c4::context->preference("allowfineoverride") ) {
333
            $flaginfo{'noissues'} = 1;
334
            $flaginfo{'noissues'} = 1;
334
        }
335
        }
335
        $flags{'CHARGES'} = \%flaginfo;
336
        $flags{'charges'} = \%flaginfo;
336
    }
337
    }
337
    elsif ( $balance < 0 ) {
338
    elsif ( $balance < 0 ) {
338
        my %flaginfo;
339
        my %flaginfo;
Lines 340-345 sub patronflags { Link Here
340
        $flaginfo{'amount'}  = sprintf "%.02f", $balance;
341
        $flaginfo{'amount'}  = sprintf "%.02f", $balance;
341
        $flags{'CREDITS'} = \%flaginfo;
342
        $flags{'CREDITS'} = \%flaginfo;
342
    }
343
    }
344
345
    # Check the debt of the guarntees of this patron
346
    my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees");
347
    $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
348
    if ( defined $no_issues_charge_guarantees ) {
349
        my $b = Koha::Borrowers->find( $patroninformation->{borrowernumber} );
350
        my @guarantees = $b->guarantees();
351
        my $guarantees_non_issues_charges;
352
        foreach my $g ( @guarantees ) {
353
            my ( $b, $n, $o ) = C4::Members::GetMemberAccountBalance( $g->id );
354
            $guarantees_non_issues_charges += $n;
355
        }
356
357
        if ( $guarantees_non_issues_charges > $no_issues_charge_guarantees ) {
358
            my %flaginfo;
359
            $flaginfo{'message'} = sprintf 'patron guarantees owe %.02f', $guarantees_non_issues_charges;
360
            $flaginfo{'amount'}  = sprintf "%.02f", $guarantees_non_issues_charges;
361
            $flaginfo{'noissues'} = 1 unless C4::Context->preference("allowfineoverride");
362
            $flags{'CHARGES_GUARANTEES'} = \%flaginfo;
363
        }
364
    }
365
343
    if (   $patroninformation->{'gonenoaddress'}
366
    if (   $patroninformation->{'gonenoaddress'}
344
        && $patroninformation->{'gonenoaddress'} == 1 )
367
        && $patroninformation->{'gonenoaddress'} == 1 )
345
    {
368
    {
(-)a/Koha/Borrower.pm (+6 lines)
Lines 47-52 sub guarantor { Link Here
47
    return Koha::Borrowers->find( $self->guarantorid() );
47
    return Koha::Borrowers->find( $self->guarantorid() );
48
}
48
}
49
49
50
sub guarantees {
51
    my ( $self ) = @_;
52
53
    return Koha::Borrowers->search( { guarantorid => $self->id } );
54
}
55
50
=head3 type
56
=head3 type
51
57
52
=cut
58
=cut
(-)a/circ/circulation.pl (+15 lines)
Lines 500-505 foreach my $flag ( sort keys %$flags ) { Link Here
500
                charges_is_blocker => 1
500
                charges_is_blocker => 1
501
            );
501
            );
502
        }
502
        }
503
        elsif ( $flag eq 'CHARGES_GUARANTEES' ) {
504
            $template->param(
505
                charges_guarantees    => 'true',
506
                chargesmsg_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'message'},
507
                chargesamount_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'amount'},
508
                charges_guarantees_is_blocker => 1
509
            );
510
        }
503
        elsif ( $flag eq 'CREDITS' ) {
511
        elsif ( $flag eq 'CREDITS' ) {
504
            $template->param(
512
            $template->param(
505
                credits    => 'true',
513
                credits    => 'true',
Lines 516-521 foreach my $flag ( sort keys %$flags ) { Link Here
516
                chargesamount => $flags->{'CHARGES'}->{'amount'},
524
                chargesamount => $flags->{'CHARGES'}->{'amount'},
517
            );
525
            );
518
        }
526
        }
527
        elsif ( $flag eq 'CHARGES_GUARANTEES' ) {
528
            $template->param(
529
                charges_guarantees    => 'true',
530
                chargesmsg_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'message'},
531
                chargesamount_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'amount'},
532
            );
533
        }
519
        elsif ( $flag eq 'CREDITS' ) {
534
        elsif ( $flag eq 'CREDITS' ) {
520
            $template->param(
535
            $template->param(
521
                credits    => 'true',
536
                credits    => 'true',
(-)a/installer/data/mysql/atomicupdate/bug_14577.sql (+2 lines)
Line 0 Link Here
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
2
('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before check outs are blocked','Integer');
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 231-236 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
231
('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''),
231
('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''),
232
('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'),
232
('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'),
233
('noissuescharge','5','','Define maximum amount withstanding before check outs are blocked','Integer'),
233
('noissuescharge','5','','Define maximum amount withstanding before check outs are blocked','Integer'),
234
('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before check outs are blocked','Integer'),
234
('noItemTypeImages','0',NULL,'If ON, disables item-type images','YesNo'),
235
('noItemTypeImages','0',NULL,'If ON, disables item-type images','YesNo'),
235
('NoLoginInstructions', '', '60|10', 'Instructions to display on the OPAC login form when a patron is not logged in', 'Textarea'),
236
('NoLoginInstructions', '', '60|10', 'Instructions to display on the OPAC login form when a patron is not logged in', 'Textarea'),
236
('NorwegianPatronDBEnable','0',NULL,'Enable communication with the Norwegian national patron database.', 'YesNo'),
237
('NorwegianPatronDBEnable','0',NULL,'Enable communication with the Norwegian national patron database.', 'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+5 lines)
Lines 291-296 Circulation: Link Here
291
              class: integer
291
              class: integer
292
            - '[% local_currency %] in fines.'
292
            - '[% local_currency %] in fines.'
293
        -
293
        -
294
            - Prevent patrons from checking out books if the have guarantees owing in total more than
295
            - pref: NoIssuesChargeGuarantees
296
              class: integer
297
            - '[% local_currency %] in fines.'
298
        -
294
            - pref: RentalsInNoissuesCharge
299
            - pref: RentalsInNoissuesCharge
295
              choices:
300
              choices:
296
                  yes: Include
301
                  yes: Include
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-15 / +30 lines)
Lines 229-234 $(document).ready(function() { Link Here
229
[% IF ( DEBT ) %]
229
[% IF ( DEBT ) %]
230
    <li>The patron has a debt of [% DEBT %].</li>
230
    <li>The patron has a debt of [% DEBT %].</li>
231
[% END %]
231
[% END %]
232
233
[% IF ( DEBT_GUARANTEES ) %]
234
    <li>The patron's guarantees collectively have a debt of [% DEBT_GUARANTEES %].</li>
235
[% END %]
236
232
[% IF ( RENTALCHARGE && RENTALCHARGE > 0 ) %]
237
[% IF ( RENTALCHARGE && RENTALCHARGE > 0 ) %]
233
    <li>Rental charge for this item: [% RENTALCHARGE %]</li>
238
    <li>Rental charge for this item: [% RENTALCHARGE %]</li>
234
[% END %]
239
[% END %]
Lines 787-807 No patron matched <span class="ex">[% message %]</span> Link Here
787
                [% IF ( odues ) %]<li>[% IF ( nonreturns ) %]<span class="circ-hlt">Overdues: Patron has ITEMS OVERDUE</span>. See highlighted items <a href="#checkouts">below</a>[% END %]</li>
792
                [% IF ( odues ) %]<li>[% IF ( nonreturns ) %]<span class="circ-hlt">Overdues: Patron has ITEMS OVERDUE</span>. See highlighted items <a href="#checkouts">below</a>[% END %]</li>
788
            [% END %]
793
            [% END %]
789
794
790
        	[% IF ( charges ) %]
795
            [% IF ( charges ) %]
791
			    <li>
796
                <li>
792
            <span class="circ-hlt">Fees &amp; Charges:</span> Patron has  <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Outstanding fees &amp; charges[% IF ( chargesamount ) %] of [% chargesamount %][% END %]</a>.
797
                    <span class="circ-hlt">Fees &amp; Charges:</span> Patron has  <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Outstanding fees &amp; charges[% IF ( chargesamount ) %] of [% chargesamount %][% END %]</a>.
793
                [% IF ( charges_is_blocker ) %]
798
                        [% IF ( charges_is_blocker ) %]
794
                    <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
799
                            <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
795
                [% END %]
800
                        [% END %]
796
            <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]">Make payment</a> or
801
                    <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]">Make payment</a> or
797
            <a href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% borrowernumber %]">Pay all fines</a></li>
802
                    <a href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% borrowernumber %]">Pay all fines</a>
798
			[% END %]
803
                </li>
804
            [% END %]
799
805
800
        	[% IF ( credits ) %]
806
            [% IF ( charges_guarantees ) %]
801
			<li>
807
                <li>
802
                <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of [% creditsamount %][% END %]
808
                    <span class="circ-hlt">Fees &amp; Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees %].
803
            </li>
809
                        [% IF ( charges_guarantees_is_blocker ) %]
804
			[% END %]
810
                            <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
811
                        [% END %]
812
                </li>
813
            [% END %]
814
815
816
            [% IF ( credits ) %]
817
                <li>
818
                    <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of [% creditsamount %][% END %]
819
                </li>
820
            [% END %]
805
821
806
			</ul>
822
			</ul>
807
        </div>
823
        </div>
808
- 

Return to bug 14577