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

(-)a/C4/Circulation.pm (-1 / +2 lines)
Lines 2412-2418 sub AddReturn { Link Here
2412
        my $effective_itemtype = $item->effective_itemtype;
2412
        my $effective_itemtype = $item->effective_itemtype;
2413
        my $limit = Koha::Library::FloatLimits->find( { itemtype => $effective_itemtype, branchcode => $branch } );
2413
        my $limit = Koha::Library::FloatLimits->find( { itemtype => $effective_itemtype, branchcode => $branch } );
2414
        if ($limit) {
2414
        if ($limit) {
2415
            my $transfer_library = Koha::Library::FloatLimits->lowest_ratio_library( $item, $branch );
2415
            my $transfer_library =
2416
                Koha::Library::FloatLimits->lowest_ratio_library( $item, $branch, $item->holdingbranch );
2416
            if ( $transfer_library && $transfer_library->branchcode ne $branch ) {
2417
            if ( $transfer_library && $transfer_library->branchcode ne $branch ) {
2417
                $returnbranch     = $transfer_library->branchcode;
2418
                $returnbranch     = $transfer_library->branchcode;
2418
                $transfer_trigger = 'LibraryFloatLimit';
2419
                $transfer_trigger = 'LibraryFloatLimit';
(-)a/Koha/Library/FloatLimits.pm (-2 / +30 lines)
Lines 40-46 Koha::Library::FloatLimits - Koha Library::FloatLimit object set class Link Here
40
=cut
40
=cut
41
41
42
sub lowest_ratio_library {
42
sub lowest_ratio_library {
43
    my ( $self, $item, $branchcode ) = @_;
43
    my ( $self, $item, $branchcode, $from_branch ) = @_;
44
    my $schema = Koha::Database->new->schema;
44
    my $schema = Koha::Database->new->schema;
45
45
46
    my @float_limits = $schema->resultset('LibraryFloatLimit')->search(
46
    my @float_limits = $schema->resultset('LibraryFloatLimit')->search(
Lines 116-121 sub lowest_ratio_library { Link Here
116
                }
116
                }
117
            )->count;
117
            )->count;
118
            $item_count = $at_branch_count + $in_transit_to_count - $in_transit_from_count;
118
            $item_count = $at_branch_count + $in_transit_to_count - $in_transit_from_count;
119
120
            # artifically adjust counts for the item being checked in
121
            if ($from_branch) {
122
123
                # This is the checkin branch - artifically add 1
124
                if ( $branch eq $branchcode ) {
125
                    $item_count++;
126
                }
127
128
                # This is where the item came from - artifically subtract 1
129
                if ( $branch eq $from_branch ) {
130
                    $item_count--;
131
                }
132
            }
133
119
        } else {
134
        } else {
120
            my $at_branch_count = Koha::Items->search(
135
            my $at_branch_count = Koha::Items->search(
121
                {
136
                {
Lines 156-161 sub lowest_ratio_library { Link Here
156
                }
171
                }
157
            )->count;
172
            )->count;
158
            $item_count = $at_branch_count + $in_transit_to_count - $in_transit_from_count;
173
            $item_count = $at_branch_count + $in_transit_to_count - $in_transit_from_count;
174
175
            # artifically adjust counts for the item being checked in
176
            if ($from_branch) {
177
178
                # This is the checkin branch - artifically add 1
179
                if ( $branch eq $branchcode ) {
180
                    $item_count++;
181
                }
182
183
                # This is where the item came from - artifically subtract 1
184
                if ( $branch eq $from_branch ) {
185
                    $item_count--;
186
                }
187
            }
159
        }
188
        }
160
189
161
        my $ratio = $item_count / $float_limit_val;
190
        my $ratio = $item_count / $float_limit_val;
162
- 

Return to bug 28530