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 Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
4b0fcd7e75
commit
fd7cab9c41
|
|
@ -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 );
|
||||
|
|
|
|||
Loading…
Reference in New Issue