Bugzilla – Attachment 184967 Details for
Bug 28530
Allow configuration of floating limits by item type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28530: If return policy is set to float in library group, remove non group branches
Bug-28530-If-return-policy-is-set-to-float-in-libr.patch (text/plain), 2.99 KB, created by
Lucas Gass (lukeg)
on 2025-08-01 00:22:39 UTC
(
hide
)
Description:
Bug 28530: If return policy is set to float in library group, remove non group branches
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-08-01 00:22:39 UTC
Size:
2.99 KB
patch
obsolete
>From e7262ab2b952bc5843362c65c5d6c91e74e91553 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 31 Jul 2025 22:46:36 +0000 >Subject: [PATCH] Bug 28530: If return policy is set to float in library group, > remove non group branches > >--- > Koha/Library/FloatLimits.pm | 28 +++++++++++++++++++++++++--- > 1 file changed, 25 insertions(+), 3 deletions(-) > >diff --git a/Koha/Library/FloatLimits.pm b/Koha/Library/FloatLimits.pm >index 189c67d6cfe..913f3a65779 100644 >--- a/Koha/Library/FloatLimits.pm >+++ b/Koha/Library/FloatLimits.pm >@@ -41,7 +41,6 @@ Koha::Library::FloatLimits - Koha Library::FloatLimit object set class > > sub lowest_ratio_library { > my ( $self, $item, $branchcode ) = @_; >- > my $schema = Koha::Database->new->schema; > > my @float_limits = $schema->resultset('LibraryFloatLimit')->search( >@@ -51,6 +50,21 @@ sub lowest_ratio_library { > } > )->all; > >+ # check the items return policy >+ my $hbr = Koha::CirculationRules->get_return_branch_policy($item); >+ >+ # if item only floats in the library group we must eliminate all other candidates >+ if ( $hbr && $hbr eq 'returnbylibrarygroup' ) { >+ my $current_library = Koha::Libraries->find($branchcode); >+ my $float_libraries = $current_library->get_float_libraries; >+ >+ if ( $float_libraries->count > 0 ) { >+ my @allowed_branchcodes = $float_libraries->get_column('branchcode'); >+ my %allowed_branches = map { $_ => 1 } @allowed_branchcodes; >+ @float_limits = grep { $allowed_branches{ $_->get_column('branchcode') } } @float_limits; >+ } >+ } >+ > return unless @float_limits; > > my @candidates; >@@ -153,8 +167,14 @@ sub lowest_ratio_library { > }; > } > >- # sort the branches by lowest ratio in the event of a tie choose a random branch >- @candidates = sort { $a->{ratio} <=> $b->{ratio} || rand() <=> rand() } @candidates; >+ # sort the branches by lowest ratio >+ # in the event of a tie the item should stay where it is, if the current branch is involved in the tie >+ # when the current branch is not involved in the tie a random branch is choosen from those who tied >+ @candidates = sort { >+ $a->{ratio} <=> $b->{ratio} >+ || ( $a->{branchcode} eq $branchcode ? -1 : 0 ) - ( $b->{branchcode} eq $branchcode ? -1 : 0 ) >+ || rand() <=> rand() >+ } @candidates; > > my $UseBranchTransferLimits = C4::Context->preference("UseBranchTransferLimits"); > my $BranchTransferLimitsType = >@@ -162,12 +182,14 @@ sub lowest_ratio_library { > > my $transfer_branch; > for my $candidate (@candidates) { >+ > if ($UseBranchTransferLimits) { > my $allowed = C4::Circulation::IsBranchTransferAllowed( > $candidate->{branchcode}, > $branchcode, > $item->$BranchTransferLimitsType > ); >+ > $transfer_branch = Koha::Libraries->find( $candidate->{branchcode} ) if $allowed; > last; > } else { >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28530
:
160038
|
160039
|
160040
|
160041
|
160042
|
160043
|
160044
|
160045
|
160046
|
160047
|
160048
|
160049
|
160050
|
160053
|
160054
|
160055
|
160056
|
160057
|
160058
|
160061
|
160062
|
160063
|
160064
|
160065
|
160066
|
160067
|
160068
|
160071
|
160072
|
160073
|
160074
|
160075
|
160076
|
160077
|
160078
|
160079
|
160080
|
160081
|
160082
|
160083
|
160084
|
163919
|
168343
|
168344
|
168345
|
168346
|
168347
|
168348
|
168349
|
168350
|
178762
|
178763
|
178764
|
178765
|
178766
|
178767
|
178768
|
178769
|
178783
|
178784
|
178785
|
178934
|
178935
|
178936
|
178937
|
178938
|
178939
|
178940
|
178941
|
178942
|
178943
|
178944
|
178945
|
178946
|
179943
|
179944
|
179945
|
179946
|
179947
|
179948
|
179949
|
179950
|
179951
|
179952
|
179953
|
179954
|
179955
|
180028
|
182931
|
184754
|
184755
|
184917
|
184936
|
184951
|
184952
|
184953
|
184954
|
184955
|
184956
|
184957
|
184958
|
184959
|
184960
|
184961
|
184963
|
184965
|
184966
|
184967
|
185038
|
185836
|
185837
|
185838
|
185839
|
185840
|
185841
|
185842
|
185843