From ab86751f7caf435c657b535efc3177374f911965 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 10 Feb 2026 14:38:40 +0000 Subject: [PATCH] Bug 3492: (follow-up) Replace GetReserveFee with holds_fee method GetReserveFee was removed as part of the migration to circulation rules-based hold fees, but reserve/request.pl still imported and used it, causing compilation errors. This patch replaces the two usages of GetReserveFee with the modern approach using Koha::Item->holds_fee($patron), matching the implementation in opac-reserve.pl. The fee is calculated by iterating through available items and using the first non-zero fee found, which provides backward compatibility with the legacy reserve_charge template variable. This implementation uses ReservesControlBranch to determine which branch's circulation rules apply (either item home library or patron home library), consistent with the existing Koha policy framework. Test plan: 1. Apply patch 2. Verify reserve/request.pl compiles: perl -wc reserve/request.pl 3. Navigate to staff interface holds page with patron and biblio 4. Verify hold fee is displayed correctly if configured in circulation rules 5. Place a hold and verify fee is charged correctly --- reserve/request.pl | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/reserve/request.pl b/reserve/request.pl index 22463bde8ec..fbc08a08269 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -33,7 +33,7 @@ use Date::Calc qw( Date_to_Days ); use C4::Output qw( output_html_with_http_headers ); use C4::Auth qw( get_template_and_user ); use C4::Reserves - qw( AlterPriority ToggleLowestPriority CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest GetReserveFee ); + qw( AlterPriority ToggleLowestPriority CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest ); use C4::Items qw( get_hostitemnumbers_of ); use C4::Koha qw( getitemtypeimagelocation ); use C4::Serials qw( CountSubscriptionFromBiblionumber ); @@ -772,7 +772,19 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) # Pass through any reserve charge if ($patron) { - $biblioloopiter{reserve_charge} = GetReserveFee( $patron->borrowernumber, $biblionumber ); + + # Calculate hold fee using first available item + my $reserve_charge = 0; + if (@items) { + foreach my $item_object (@items) { + my $fee = $item_object->holds_fee($patron); + if ( defined $fee && $fee > 0 ) { + $reserve_charge = $fee; + last; + } + } + } + $biblioloopiter{reserve_charge} = $reserve_charge; } if (@reserveloop) { @@ -807,7 +819,19 @@ unless ($multi_hold) { # Pass through any reserve charge for single holds if ($borrowernumber_hold) { - $template->param( reserve_charge => GetReserveFee( $borrowernumber_hold, $biblionumbers[0] ) ); + my $patron = Koha::Patrons->find($borrowernumber_hold); + my $reserve_charge = 0; + if ( $patron && $biblio ) { + my @items = $biblio->items->as_list; + foreach my $item (@items) { + my $fee = $item->holds_fee($patron); + if ( defined $fee && $fee > 0 ) { + $reserve_charge = $fee; + last; + } + } + } + $template->param( reserve_charge => $reserve_charge ); } } $template->param( biblionumbers => \@biblionumbers ); -- 2.53.0