From 7367ac3273fca6111a61545fa7dbf435201cbc20 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Sun, 22 Mar 2026 23:32:21 +0100 Subject: [PATCH] Bug 23415: (RM follow-up) Add POD coverage for private subs in C4/Circulation.pm Adds POD for _check_max_qty, _calculate_new_debar_dt, _CalculateAndUpdateFine, and _CanBookBeAutoRenewed to fix QA pod_coverage failures. --- C4/Circulation.pm | 135 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 621297d20f..6e34612350 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -631,6 +631,41 @@ sub TooMany { return; } +=head2 _check_max_qty + + my $error = _check_max_qty($params); + +Internal helper used by CanBookBeIssued to determine whether the patron has +reached the maximum number of allowed checkouts (overall or on-site). + +C<$params> is a hashref with the following keys: + +=over 4 + +=item C - total number of current checkouts for the patron/item-type/branch combination + +=item C - number of those that are on-site checkouts + +=item C - boolean; true if the current checkout is an on-site checkout + +=item C - maximum normal checkouts permitted by the circulation rule + +=item C - maximum on-site checkouts permitted by the circulation rule + +=item C - boolean; true if this checkout is switching an existing on-site checkout + +=item C - the Koha::CirculationRule object that set C + +=item C - the Koha::CirculationRule object that set C + +=back + +Returns a hashref with keys C (C or +C), C, C, and +C if the limit is exceeded; returns undef otherwise. + +=cut + sub _check_max_qty { my $params = shift; my $checkout_count = $params->{checkout_count}; @@ -2918,6 +2953,37 @@ to ease testing. =cut +=head2 _calculate_new_debar_dt + + my $new_debar_dt = _calculate_new_debar_dt( $patron, $item, $dt_due, $return_date ); + +Internal helper that calculates the new patron debarment (suspension) expiry +date based on how overdue the item was. + +=over 4 + +=item C<$patron> - a Koha::Patron object + +=item C<$item> - a Koha::Item object + +=item C<$dt_due> - a DateTime object representing the due date + +=item C<$return_date> - a DateTime object representing the actual return date + +=back + +Looks up the applicable circulation rules (C, C, +C, C, C) and computes +the number of suspension days proportional to the overdue period. Respects +C (extends an existing suspension) and +C (skips closed days when enabled). + +Returns a DateTime object representing the end date of the suspension, or +undef if no suspension applies (e.g. C is not set or the item is +within the grace period). + +=cut + sub _calculate_new_debar_dt { my ( $patron, $item, $dt_due, $return_date ) = @_; @@ -4945,6 +5011,34 @@ sub GetTopIssues { =head2 Internal methods +These methods are not part of the public API and should not be called directly. + +=head2 _CalculateAndUpdateFine + + _CalculateAndUpdateFine({ borrower => $borrower, item => $item, issue => $issue, return_date => $return_date }); + +Internal helper called by AddReturn to calculate the overdue fine for a +checkout and persist it via C. + +C<$params> is a hashref with the following keys: + +=over 4 + +=item C - a hashref of borrower data (required) + +=item C - a hashref of item data (required) + +=item C - a Koha::Checkout object (required) + +=item C - an optional DateTime object; defaults to now. When +provided (e.g. for backdated returns) any existing fine that would be reduced +to zero is explicitly set to 0. + +=back + +Only writes fines when the C system preference is set to +C. Returns nothing. + =cut sub _CalculateAndUpdateFine { @@ -5004,6 +5098,47 @@ sub _CalculateAndUpdateFine { } } +=head2 _CanBookBeAutoRenewed + + my ($result, $soonest) = _CanBookBeAutoRenewed({ patron => $patron, item => $item, branchcode => $branchcode, issue => $issue }); + +Internal helper called by CanBookBeRenewed to determine whether a checkout +that has C set is eligible to be automatically renewed. + +C<$params> is a hashref with the following keys: + +=over 4 + +=item C - a Koha::Patron object + +=item C - a Koha::Item object + +=item C - the branch used to look up circulation rules + +=item C - a Koha::Checkout object + +=back + +Returns one of the following string values: + +=over 4 + +=item C<"ok"> - the item may be auto-renewed + +=item C<"no"> - auto-renewal is disabled on the issue or blocked for the patron + +=item C<"auto_too_late"> - past the C or C date + +=item C<"auto_too_soon"> - too early to renew; a second return value contains the earliest renewal DateTime + +=item C<"auto_account_expired"> - patron account is expired and the category blocks renewals for expired patrons + +=item C<"auto_too_much_owing"> - patron has outstanding charges above the C threshold + +=back + +=cut + sub _CanBookBeAutoRenewed { my ($params) = @_; my $patron = $params->{patron};