View | Details | Raw Unified | Return to bug 28530
Collapse All | Expand All

(-)a/Koha/Library/FloatLimits.pm (-2 / +17 lines)
Lines 41-47 Koha::Library::FloatLimits - Koha Library::FloatLimit object set class Link Here
41
41
42
sub lowest_ratio_library {
42
sub lowest_ratio_library {
43
    my ( $self, $item, $branchcode ) = @_;
43
    my ( $self, $item, $branchcode ) = @_;
44
45
    my $schema = Koha::Database->new->schema;
44
    my $schema = Koha::Database->new->schema;
46
45
47
    my @float_limits = $schema->resultset('LibraryFloatLimit')->search(
46
    my @float_limits = $schema->resultset('LibraryFloatLimit')->search(
Lines 51-56 sub lowest_ratio_library { Link Here
51
        }
50
        }
52
    )->all;
51
    )->all;
53
52
53
    # check the items return policy
54
    my $hbr = Koha::CirculationRules->get_return_branch_policy($item);
55
56
    # if item only floats in the library group we must eliminate all other candidates
57
    if ( $hbr && $hbr eq 'returnbylibrarygroup' ) {
58
        my $current_library = Koha::Libraries->find($branchcode);
59
        my $float_libraries = $current_library->get_float_libraries;
60
61
        if ( $float_libraries->count > 0 ) {
62
            my @allowed_branchcodes = $float_libraries->get_column('branchcode');
63
            my %allowed_branches    = map { $_ => 1 } @allowed_branchcodes;
64
            @float_limits = grep { $allowed_branches{ $_->get_column('branchcode') } } @float_limits;
65
        }
66
    }
67
54
    return unless @float_limits;
68
    return unless @float_limits;
55
69
56
    my @candidates;
70
    my @candidates;
Lines 162-173 sub lowest_ratio_library { Link Here
162
176
163
    my $transfer_branch;
177
    my $transfer_branch;
164
    for my $candidate (@candidates) {
178
    for my $candidate (@candidates) {
179
165
        if ($UseBranchTransferLimits) {
180
        if ($UseBranchTransferLimits) {
166
            my $allowed = C4::Circulation::IsBranchTransferAllowed(
181
            my $allowed = C4::Circulation::IsBranchTransferAllowed(
167
                $candidate->{branchcode},
182
                $candidate->{branchcode},
168
                $branchcode,
183
                $branchcode,
169
                $item->$BranchTransferLimitsType
184
                $item->$BranchTransferLimitsType
170
            );
185
            );
186
171
            $transfer_branch = Koha::Libraries->find( $candidate->{branchcode} ) if $allowed;
187
            $transfer_branch = Koha::Libraries->find( $candidate->{branchcode} ) if $allowed;
172
            last;
188
            last;
173
        } else {
189
        } else {
174
- 

Return to bug 28530