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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 819-825 sub CanBookBeIssued { Link Here
819
    #
819
    #
820
    # BORROWER STATUS
820
    # BORROWER STATUS
821
    #
821
    #
822
    my $patron_borrowing_status = $patron->can_borrow();
822
    my $patron_borrowing_status = $patron->can_checkout();
823
    if ( $patron->category->category_type eq 'X' && (  $item_object->barcode  )) {
823
    if ( $patron->category->category_type eq 'X' && (  $item_object->barcode  )) {
824
        # stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1  .
824
        # stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1  .
825
        C4::Stats::UpdateStats(
825
        C4::Stats::UpdateStats(
(-)a/Koha/Patron.pm (-10 / +11 lines)
Lines 2902-2913 sub consent { Link Here
2902
}
2902
}
2903
2903
2904
2904
2905
=head3 can_borrow
2906
2905
2907
my $patron_borrowing_status = $patron->can_borrow( { patron => $patron } );
2906
=head3 can_checkout
2908
2907
2909
This method determines whether a borrower is able to borrow based on various parameters.
2908
my $patron_borrowing_status = $patron->can_checkout( { patron => $patron } );
2910
- Debarrments
2909
2910
This method determines whether a patron is able to borrow based on various parameters.
2911
- Restrictions
2911
- Expiry
2912
- Expiry
2912
- Charges
2913
- Charges
2913
2914
Lines 2915-2933 If any blockers are found, these are returned in a hash Link Here
2915
2916
2916
=cut
2917
=cut
2917
2918
2918
sub can_borrow {
2919
sub can_checkout {
2919
    my ($self) = @_;
2920
    my ($self) = @_;
2920
2921
2921
    my $status = { can_borrow => 1 };
2922
    my $status = { can_checkout => 1 };
2922
2923
2923
    $status->{debarred}   = 1 if $self->debarred;
2924
    $status->{debarred}     = 1 if $self->debarred;
2924
    $status->{expired}    = 1 if $self->is_expired;
2925
    $status->{expired}      = 1 if $self->is_expired;
2925
    $status->{can_borrow} = 0 if $status->{debarred} || $status->{expired};
2926
    $status->{can_checkout} = 0 if $status->{debarred} || $status->{expired};
2926
2927
2927
    # Patron charges
2928
    # Patron charges
2928
    my $patron_charge_limits = $self->is_patron_inside_charge_limits();
2929
    my $patron_charge_limits = $self->is_patron_inside_charge_limits();
2929
    %$status = ( %$status, %$patron_charge_limits );
2930
    %$status = ( %$status, %$patron_charge_limits );
2930
    $status->{can_borrow} = 0
2931
    $status->{can_checkout} = 0
2931
        if $patron_charge_limits->{noissuescharge}->{overlimit}
2932
        if $patron_charge_limits->{noissuescharge}->{overlimit}
2932
        || $patron_charge_limits->{NoIssuesChargeGuarantees}->{overlimit}
2933
        || $patron_charge_limits->{NoIssuesChargeGuarantees}->{overlimit}
2933
        || $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit};
2934
        || $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit};
(-)a/installer/data/mysql/kohastructure.sql (-3 / +3 lines)
Lines 1806-1814 CREATE TABLE `categories` ( Link Here
1806
  `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category',
1806
  `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category',
1807
  `require_strong_password` tinyint(1) DEFAULT NULL COMMENT 'set required password strength for patrons in this category',
1807
  `require_strong_password` tinyint(1) DEFAULT NULL COMMENT 'set required password strength for patrons in this category',
1808
  `exclude_from_local_holds_priority` tinyint(1) DEFAULT NULL COMMENT 'Exclude patrons of this category from local holds priority',
1808
  `exclude_from_local_holds_priority` tinyint(1) DEFAULT NULL COMMENT 'Exclude patrons of this category from local holds priority',
1809
  `noissuescharge` int(11) DEFAULT NULL COMMENT 'define maximum amount withstanding before checkouts are blocked',
1809
  `noissuescharge` int(11) DEFAULT NULL COMMENT 'define maximum amount outstanding before checkouts are blocked',
1810
  `noissueschargeguarantees` int(11) DEFAULT NULL COMMENT 'define maximum amount withstanding before checkouts are blocked',
1810
  `noissueschargeguarantees` int(11) DEFAULT NULL COMMENT 'define maximum amount that the guarantees of a patron in this category can have outstanding before checkouts are blocked',
1811
  `noissueschargeguarantorswithguarantees` int(11) DEFAULT NULL COMMENT 'define maximum amount withstanding before checkouts are blocked',
1811
  `noissueschargeguarantorswithguarantees` int(11) DEFAULT NULL COMMENT 'define maximum amount that the guarantors with guarantees of a patron in this category can have outstanding before checkouts are blocked',
1812
  PRIMARY KEY (`categorycode`),
1812
  PRIMARY KEY (`categorycode`),
1813
  UNIQUE KEY `categorycode` (`categorycode`)
1813
  UNIQUE KEY `categorycode` (`categorycode`)
1814
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1814
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt (-15 / +18 lines)
Lines 446-461 Link Here
446
                    <div class="hint">If <i>Yes</i>, holds placed by patrons of this category will not be given priority</div>
446
                    <div class="hint">If <i>Yes</i>, holds placed by patrons of this category will not be given priority</div>
447
                </li>
447
                </li>
448
                <li>
448
                <li>
449
                    <label for="noissuescharge">No issues charge: </label>
449
                    <label for="noissuescharge">Checkout charge limit: </label>
450
                    <input type="text" name="noissuescharge" id="noissuescharge" value="[% category.noissuescharge | html %]" size="3" maxlength="3" />
450
                    <input type="text" name="noissuescharge" id="noissuescharge" value="[% category.noissuescharge | $Price on_editing => 1 %]" class="decimal" size="3" maxlength="3" />
451
                    <div class="hint">If set, this will override the global value set in the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=noissuescharge&ok=Search">noissuescharge</a> preference</div>
451
                </li>
452
                </li>
452
                <li>
453
                <li>
453
                    <label for="noissueschargeguarantees">No issues charge guarantees: </label>
454
                    <label for="noissueschargeguarantees">Guarantees checkout charge limit: </label>
454
                    <input type="text" name="noissueschargeguarantees" id="noissueschargeguarantees" value="[% category.noissueschargeguarantees | html %]" size="3" maxlength="3" />
455
                    <input type="text" name="noissueschargeguarantees" id="noissueschargeguarantees" value="[% category.noissueschargeguarantees | $Price on_editing => 1 %]" class="decimal" size="3" maxlength="3" />
456
                    <div class="hint">If set, this will override the global value set in the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=noissuescharge&ok=Search">NoIssuesChargeGuarantees</a> preference</div>
455
                </li>
457
                </li>
456
                <li>
458
                <li>
457
                    <label for="noissueschargeguarantorswithguarantees">No issues charge guarantors with guarantees: </label>
459
                    <label for="noissueschargeguarantorswithguarantees">Guarantors with guarantees checkout charge limit: </label>
458
                    <input type="text" name="noissueschargeguarantorswithguarantees" id="noissueschargeguarantorswithguarantees" value="[% category.noissueschargeguarantorswithguarantees | html %]" size="3" maxlength="3" />
460
                    <input type="text" name="noissueschargeguarantorswithguarantees" id="noissueschargeguarantorswithguarantees" value="[% category.noissueschargeguarantorswithguarantees | $Price on_editing => 1 %]" class="decimal" size="3" maxlength="3" />
461
                    <div class="hint">If set, this will override the global value set in the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=noissuescharge&ok=Search">NoIssuesChargeGuarantorsWithGuarantees</a> preference</div>
459
                </li>
462
                </li>
460
            </ol>
463
            </ol>
461
        </fieldset>
464
        </fieldset>
Lines 602-610 Link Here
602
                    <th scope="col">Can be guarantee</th>
605
                    <th scope="col">Can be guarantee</th>
603
                    <th scope="col">Default privacy</th>
606
                    <th scope="col">Default privacy</th>
604
                    <th scope="col">Exclude from local holds priority</th>
607
                    <th scope="col">Exclude from local holds priority</th>
605
                    <th scope="col">No issues charge</th>
608
                    <th scope="col">Checkout charge limit</th>
606
                    <th scope="col">No issues charge guarantees</th>
609
                    <th scope="col">Guarantees checkout charge limit</th>
607
                    <th scope="col">No issues charge guarantors with guarantees</th>
610
                    <th scope="col">Guarantors with guarantees checkout charge limit</th>
608
                    <th scope="col">Actions</th>
611
                    <th scope="col">Actions</th>
609
                </tr>
612
                </tr>
610
            </thead>
613
            </thead>
Lines 743-761 Link Here
743
                            [% END %]
746
                            [% END %]
744
                        </td>
747
                        </td>
745
                        [% IF (category.noissuescharge) %]
748
                        [% IF (category.noissuescharge) %]
746
                            <td>[% category.noissuescharge | html %]</td>
749
                            <td>[% category.noissuescharge | $Price %]</td>
747
                        [% ELSE %]
750
                        [% ELSE %]
748
                            <td>0.00</td>
751
                            <td>[% 0.00 | $Price %]</td>
749
                        [% END %]
752
                        [% END %]
750
                        [% IF (category.noissueschargeguarantees) %]
753
                        [% IF (category.noissueschargeguarantees) %]
751
                            <td>[% category.noissueschargeguarantees | html %]</td>
754
                            <td>[% category.noissueschargeguarantees | $Price %]</td>
752
                        [% ELSE %]
755
                        [% ELSE %]
753
                            <td>0.00</td>
756
                            <td>[% 0.00 | $Price %]</td>
754
                        [% END %]
757
                        [% END %]
755
                        [% IF (category.noissueschargeguarantorswithguarantees) %]
758
                        [% IF (category.noissueschargeguarantorswithguarantees) %]
756
                            <td>[% category.noissueschargeguarantorswithguarantees | html %]</td>
759
                            <td>[% category.noissueschargeguarantorswithguarantees | $Price %]</td>
757
                        [% ELSE %]
760
                        [% ELSE %]
758
                            <td>0.00</td>
761
                            <td>[% 0.00 | $Price %]</td>
759
                        [% END %]
762
                        [% END %]
760
                        <td class="actions">
763
                        <td class="actions">
761
                            <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/categories.pl?op=add_form&amp;categorycode=[% category.categorycode |uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
764
                            <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/categories.pl?op=add_form&amp;categorycode=[% category.categorycode |uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
(-)a/t/db_dependent/Koha/Patron.t (-12 / +11 lines)
Lines 2250-2256 subtest 'guarantor requirements tests' => sub { Link Here
2250
    $schema->storage->txn_rollback;
2250
    $schema->storage->txn_rollback;
2251
};
2251
};
2252
2252
2253
subtest 'can_borrow() tests' => sub {
2253
subtest 'can_checkout() tests' => sub {
2254
    plan tests => 11;
2254
    plan tests => 11;
2255
    $schema->storage->txn_begin;
2255
    $schema->storage->txn_begin;
2256
2256
Lines 2277-2291 subtest 'can_borrow() tests' => sub { Link Here
2277
    my $patron_borrowing_status;
2277
    my $patron_borrowing_status;
2278
2278
2279
    $patron->debarred(1);
2279
    $patron->debarred(1);
2280
    $patron_borrowing_status = $patron->can_borrow( { patron => $patron } );
2280
    $patron_borrowing_status = $patron->can_checkout( { patron => $patron } );
2281
    is( $patron_borrowing_status->{can_borrow}, 0, 'Debarred patron blocked from borrowing' );
2281
    is( $patron_borrowing_status->{can_checkout}, 0, 'Debarred patron blocked from borrowing' );
2282
    is( $patron_borrowing_status->{debarred},   1, 'Blocker correctly identified and returned' );
2282
    is( $patron_borrowing_status->{debarred},     1, 'Blocker correctly identified and returned' );
2283
    $patron->debarred(0);
2283
    $patron->debarred(0);
2284
2284
2285
    $patron->dateexpiry( dt_from_string->subtract( days => 1 ) );
2285
    $patron->dateexpiry( dt_from_string->subtract( days => 1 ) );
2286
    $patron_borrowing_status = $patron->can_borrow( { patron => $patron } );
2286
    $patron_borrowing_status = $patron->can_checkout( { patron => $patron } );
2287
    is( $patron_borrowing_status->{can_borrow}, 0, 'Expired patron blocked from borrowing' );
2287
    is( $patron_borrowing_status->{can_checkout}, 0, 'Expired patron blocked from borrowing' );
2288
    is( $patron_borrowing_status->{expired},    1, 'Blocker correctly identified and returned' );
2288
    is( $patron_borrowing_status->{expired},      1, 'Blocker correctly identified and returned' );
2289
    $patron->dateexpiry(undef);
2289
    $patron->dateexpiry(undef);
2290
2290
2291
    my $child   = $builder->build_object( { class => 'Koha::Patrons' } );
2291
    my $child   = $builder->build_object( { class => 'Koha::Patrons' } );
Lines 2328-2345 subtest 'can_borrow() tests' => sub { Link Here
2328
        }
2328
        }
2329
    )->store;
2329
    )->store;
2330
2330
2331
    $patron_borrowing_status = $patron->can_borrow( { patron => $patron } );
2331
    $patron_borrowing_status = $patron->can_checkout( { patron => $patron } );
2332
2332
2333
    is( $patron_borrowing_status->{noissuescharge}->{charge},    11, "Only patron's fines are reported in total" );
2333
    is( $patron_borrowing_status->{noissuescharge}->{charge},    11, "Only patron's fines are reported in total" );
2334
    is( $patron_borrowing_status->{noissuescharge}->{limit},     10, "Limit correctly identified at category level" );
2334
    is( $patron_borrowing_status->{noissuescharge}->{limit},     10, "Limit correctly identified at category level" );
2335
    is( $patron_borrowing_status->{noissuescharge}->{overlimit}, 1,  "Patron is over the charge limit" );
2335
    is( $patron_borrowing_status->{noissuescharge}->{overlimit}, 1,  "Patron is over the charge limit" );
2336
    is( $patron_borrowing_status->{can_borrow}, 0, "Patron is over the charge limit and is blocked from borrowing" );
2336
    is( $patron_borrowing_status->{can_checkout}, 0, "Patron is over the charge limit and is blocked from borrowing" );
2337
    $patron->category->noissuescharge(undef);
2337
    $patron->category->noissuescharge(undef);
2338
2338
2339
    $patron_borrowing_status = $patron->can_borrow( { patron => $patron } );
2339
    $patron_borrowing_status = $patron->can_checkout( { patron => $patron } );
2340
    is( $patron_borrowing_status->{noissuescharge}->{limit}, 50, "Limit correctly identified at global syspref level" );
2340
    is( $patron_borrowing_status->{noissuescharge}->{limit}, 50, "Limit correctly identified at global syspref level" );
2341
    is( $patron_borrowing_status->{noissuescharge}->{overlimit}, 0, "Patron is within the charge limit" );
2341
    is( $patron_borrowing_status->{noissuescharge}->{overlimit}, 0, "Patron is within the charge limit" );
2342
    is( $patron_borrowing_status->{can_borrow}, 1, "Patron is within the charge limit and can borrow" );
2342
    is( $patron_borrowing_status->{can_checkout}, 1, "Patron is within the charge limit and can borrow" );
2343
2343
2344
    $schema->storage->txn_rollback;
2344
    $schema->storage->txn_rollback;
2345
};
2345
};
2346
- 

Return to bug 28924