From 9387ab4a767de04db16e4f57bbd0aff4a282865e Mon Sep 17 00:00:00 2001
From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Date: Mon, 15 Jul 2024 14:09:10 +0000
Subject: [PATCH] Bug 28924: (QA follow-up) Terminology fixes

---
 C4/Circulation.pm                             |  2 +-
 Koha/Patron.pm                                | 21 ++++++------
 installer/data/mysql/kohastructure.sql        |  6 ++--
 .../prog/en/modules/admin/categories.tt       | 33 ++++++++++---------
 t/db_dependent/Koha/Patron.t                  | 22 ++++++-------
 5 files changed, 44 insertions(+), 40 deletions(-)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 44f48b2e11a..70ccd7fb54d 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -819,7 +819,7 @@ sub CanBookBeIssued {
     #
     # BORROWER STATUS
     #
-    my $patron_borrowing_status = $patron->can_borrow();
+    my $patron_borrowing_status = $patron->can_checkout();
     if ( $patron->category->category_type eq 'X' && (  $item_object->barcode  )) {
         # stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1  .
         C4::Stats::UpdateStats(
diff --git a/Koha/Patron.pm b/Koha/Patron.pm
index 0dc98dc4c9d..2034a6d1378 100644
--- a/Koha/Patron.pm
+++ b/Koha/Patron.pm
@@ -2902,12 +2902,13 @@ sub consent {
 }
 
 
-=head3 can_borrow
 
-my $patron_borrowing_status = $patron->can_borrow( { patron => $patron } );
+=head3 can_checkout
 
-This method determines whether a borrower is able to borrow based on various parameters.
-- Debarrments
+my $patron_borrowing_status = $patron->can_checkout( { patron => $patron } );
+
+This method determines whether a patron is able to borrow based on various parameters.
+- Restrictions
 - Expiry
 - Charges
 
@@ -2915,19 +2916,19 @@ If any blockers are found, these are returned in a hash
 
 =cut
 
-sub can_borrow {
+sub can_checkout {
     my ($self) = @_;
 
-    my $status = { can_borrow => 1 };
+    my $status = { can_checkout => 1 };
 
-    $status->{debarred}   = 1 if $self->debarred;
-    $status->{expired}    = 1 if $self->is_expired;
-    $status->{can_borrow} = 0 if $status->{debarred} || $status->{expired};
+    $status->{debarred}     = 1 if $self->debarred;
+    $status->{expired}      = 1 if $self->is_expired;
+    $status->{can_checkout} = 0 if $status->{debarred} || $status->{expired};
 
     # Patron charges
     my $patron_charge_limits = $self->is_patron_inside_charge_limits();
     %$status = ( %$status, %$patron_charge_limits );
-    $status->{can_borrow} = 0
+    $status->{can_checkout} = 0
         if $patron_charge_limits->{noissuescharge}->{overlimit}
         || $patron_charge_limits->{NoIssuesChargeGuarantees}->{overlimit}
         || $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit};
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index bde40b17591..9d9020fab62 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1806,9 +1806,9 @@ CREATE TABLE `categories` (
   `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category',
   `require_strong_password` tinyint(1) DEFAULT NULL COMMENT 'set required password strength for patrons in this category',
   `exclude_from_local_holds_priority` tinyint(1) DEFAULT NULL COMMENT 'Exclude patrons of this category from local holds priority',
-  `noissuescharge` int(11) DEFAULT NULL COMMENT 'define maximum amount withstanding before checkouts are blocked',
-  `noissueschargeguarantees` int(11) DEFAULT NULL COMMENT 'define maximum amount withstanding before checkouts are blocked',
-  `noissueschargeguarantorswithguarantees` int(11) DEFAULT NULL COMMENT 'define maximum amount withstanding before checkouts are blocked',
+  `noissuescharge` int(11) DEFAULT NULL COMMENT 'define maximum amount outstanding before checkouts are blocked',
+  `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',
+  `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',
   PRIMARY KEY (`categorycode`),
   UNIQUE KEY `categorycode` (`categorycode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt
index 89fa8070ef2..389533b39a9 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt
@@ -446,16 +446,19 @@
                     <div class="hint">If <i>Yes</i>, holds placed by patrons of this category will not be given priority</div>
                 </li>
                 <li>
-                    <label for="noissuescharge">No issues charge: </label>
-                    <input type="text" name="noissuescharge" id="noissuescharge" value="[% category.noissuescharge | html %]" size="3" maxlength="3" />
+                    <label for="noissuescharge">Checkout charge limit: </label>
+                    <input type="text" name="noissuescharge" id="noissuescharge" value="[% category.noissuescharge | $Price on_editing => 1 %]" class="decimal" size="3" maxlength="3" />
+                    <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>
                 </li>
                 <li>
-                    <label for="noissueschargeguarantees">No issues charge guarantees: </label>
-                    <input type="text" name="noissueschargeguarantees" id="noissueschargeguarantees" value="[% category.noissueschargeguarantees | html %]" size="3" maxlength="3" />
+                    <label for="noissueschargeguarantees">Guarantees checkout charge limit: </label>
+                    <input type="text" name="noissueschargeguarantees" id="noissueschargeguarantees" value="[% category.noissueschargeguarantees | $Price on_editing => 1 %]" class="decimal" size="3" maxlength="3" />
+                    <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>
                 </li>
                 <li>
-                    <label for="noissueschargeguarantorswithguarantees">No issues charge guarantors with guarantees: </label>
-                    <input type="text" name="noissueschargeguarantorswithguarantees" id="noissueschargeguarantorswithguarantees" value="[% category.noissueschargeguarantorswithguarantees | html %]" size="3" maxlength="3" />
+                    <label for="noissueschargeguarantorswithguarantees">Guarantors with guarantees checkout charge limit: </label>
+                    <input type="text" name="noissueschargeguarantorswithguarantees" id="noissueschargeguarantorswithguarantees" value="[% category.noissueschargeguarantorswithguarantees | $Price on_editing => 1 %]" class="decimal" size="3" maxlength="3" />
+                    <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>
                 </li>
             </ol>
         </fieldset>
@@ -602,9 +605,9 @@
                     <th scope="col">Can be guarantee</th>
                     <th scope="col">Default privacy</th>
                     <th scope="col">Exclude from local holds priority</th>
-                    <th scope="col">No issues charge</th>
-                    <th scope="col">No issues charge guarantees</th>
-                    <th scope="col">No issues charge guarantors with guarantees</th>
+                    <th scope="col">Checkout charge limit</th>
+                    <th scope="col">Guarantees checkout charge limit</th>
+                    <th scope="col">Guarantors with guarantees checkout charge limit</th>
                     <th scope="col">Actions</th>
                 </tr>
             </thead>
@@ -743,19 +746,19 @@
                             [% END %]
                         </td>
                         [% IF (category.noissuescharge) %]
-                            <td>[% category.noissuescharge | html %]</td>
+                            <td>[% category.noissuescharge | $Price %]</td>
                         [% ELSE %]
-                            <td>0.00</td>
+                            <td>[% 0.00 | $Price %]</td>
                         [% END %]
                         [% IF (category.noissueschargeguarantees) %]
-                            <td>[% category.noissueschargeguarantees | html %]</td>
+                            <td>[% category.noissueschargeguarantees | $Price %]</td>
                         [% ELSE %]
-                            <td>0.00</td>
+                            <td>[% 0.00 | $Price %]</td>
                         [% END %]
                         [% IF (category.noissueschargeguarantorswithguarantees) %]
-                            <td>[% category.noissueschargeguarantorswithguarantees | html %]</td>
+                            <td>[% category.noissueschargeguarantorswithguarantees | $Price %]</td>
                         [% ELSE %]
-                            <td>0.00</td>
+                            <td>[% 0.00 | $Price %]</td>
                         [% END %]
                         <td class="actions">
                             <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>
diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t
index 96f43fa4f8e..bf4aeef0970 100755
--- a/t/db_dependent/Koha/Patron.t
+++ b/t/db_dependent/Koha/Patron.t
@@ -2250,7 +2250,7 @@ subtest 'guarantor requirements tests' => sub {
     $schema->storage->txn_rollback;
 };
 
-subtest 'can_borrow() tests' => sub {
+subtest 'can_checkout() tests' => sub {
     plan tests => 11;
     $schema->storage->txn_begin;
 
@@ -2277,15 +2277,15 @@ subtest 'can_borrow() tests' => sub {
     my $patron_borrowing_status;
 
     $patron->debarred(1);
-    $patron_borrowing_status = $patron->can_borrow( { patron => $patron } );
-    is( $patron_borrowing_status->{can_borrow}, 0, 'Debarred patron blocked from borrowing' );
-    is( $patron_borrowing_status->{debarred},   1, 'Blocker correctly identified and returned' );
+    $patron_borrowing_status = $patron->can_checkout( { patron => $patron } );
+    is( $patron_borrowing_status->{can_checkout}, 0, 'Debarred patron blocked from borrowing' );
+    is( $patron_borrowing_status->{debarred},     1, 'Blocker correctly identified and returned' );
     $patron->debarred(0);
 
     $patron->dateexpiry( dt_from_string->subtract( days => 1 ) );
-    $patron_borrowing_status = $patron->can_borrow( { patron => $patron } );
-    is( $patron_borrowing_status->{can_borrow}, 0, 'Expired patron blocked from borrowing' );
-    is( $patron_borrowing_status->{expired},    1, 'Blocker correctly identified and returned' );
+    $patron_borrowing_status = $patron->can_checkout( { patron => $patron } );
+    is( $patron_borrowing_status->{can_checkout}, 0, 'Expired patron blocked from borrowing' );
+    is( $patron_borrowing_status->{expired},      1, 'Blocker correctly identified and returned' );
     $patron->dateexpiry(undef);
 
     my $child   = $builder->build_object( { class => 'Koha::Patrons' } );
@@ -2328,18 +2328,18 @@ subtest 'can_borrow() tests' => sub {
         }
     )->store;
 
-    $patron_borrowing_status = $patron->can_borrow( { patron => $patron } );
+    $patron_borrowing_status = $patron->can_checkout( { patron => $patron } );
 
     is( $patron_borrowing_status->{noissuescharge}->{charge},    11, "Only patron's fines are reported in total" );
     is( $patron_borrowing_status->{noissuescharge}->{limit},     10, "Limit correctly identified at category level" );
     is( $patron_borrowing_status->{noissuescharge}->{overlimit}, 1,  "Patron is over the charge limit" );
-    is( $patron_borrowing_status->{can_borrow}, 0, "Patron is over the charge limit and is blocked from borrowing" );
+    is( $patron_borrowing_status->{can_checkout}, 0, "Patron is over the charge limit and is blocked from borrowing" );
     $patron->category->noissuescharge(undef);
 
-    $patron_borrowing_status = $patron->can_borrow( { patron => $patron } );
+    $patron_borrowing_status = $patron->can_checkout( { patron => $patron } );
     is( $patron_borrowing_status->{noissuescharge}->{limit}, 50, "Limit correctly identified at global syspref level" );
     is( $patron_borrowing_status->{noissuescharge}->{overlimit}, 0, "Patron is within the charge limit" );
-    is( $patron_borrowing_status->{can_borrow}, 1, "Patron is within the charge limit and can borrow" );
+    is( $patron_borrowing_status->{can_checkout}, 1, "Patron is within the charge limit and can borrow" );
 
     $schema->storage->txn_rollback;
 };
-- 
2.39.3 (Apple Git-146)