|
Lines 117-131
sub lowest_ratio_library {
Link Here
|
| 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 |
|
119 |
|
| 120 |
# artifically adjust counts for the item being checked in |
120 |
# artificially adjust counts for the item being checked in |
| 121 |
if ($from_branch) { |
121 |
if ($from_branch) { |
| 122 |
|
122 |
|
| 123 |
# This is the checkin branch - artifically add 1 |
123 |
# This is the checkin branch - artificially add 1 |
| 124 |
if ( $branch eq $branchcode ) { |
124 |
if ( $branch eq $branchcode ) { |
| 125 |
$item_count++; |
125 |
$item_count++; |
| 126 |
} |
126 |
} |
| 127 |
|
127 |
|
| 128 |
# This is where the item came from - artifically subtract 1 |
128 |
# This is where the item came from - artificially subtract 1 |
| 129 |
if ( $branch eq $from_branch ) { |
129 |
if ( $branch eq $from_branch ) { |
| 130 |
$item_count--; |
130 |
$item_count--; |
| 131 |
} |
131 |
} |
|
Lines 172-186
sub lowest_ratio_library {
Link Here
|
| 172 |
)->count; |
172 |
)->count; |
| 173 |
$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 |
|
174 |
|
| 175 |
# artifically adjust counts for the item being checked in |
175 |
# artificially adjust counts for the item being checked in |
| 176 |
if ($from_branch) { |
176 |
if ($from_branch) { |
| 177 |
|
177 |
|
| 178 |
# This is the checkin branch - artifically add 1 |
178 |
# This is the checkin branch - artificially add 1 |
| 179 |
if ( $branch eq $branchcode ) { |
179 |
if ( $branch eq $branchcode ) { |
| 180 |
$item_count++; |
180 |
$item_count++; |
| 181 |
} |
181 |
} |
| 182 |
|
182 |
|
| 183 |
# This is where the item came from - artifically subtract 1 |
183 |
# This is where the item came from - artificially subtract 1 |
| 184 |
if ( $branch eq $from_branch ) { |
184 |
if ( $branch eq $from_branch ) { |
| 185 |
$item_count--; |
185 |
$item_count--; |
| 186 |
} |
186 |
} |
|
Lines 198-204
sub lowest_ratio_library {
Link Here
|
| 198 |
|
198 |
|
| 199 |
# sort the branches by lowest ratio |
199 |
# sort the branches by lowest ratio |
| 200 |
# in the event of a tie the item should stay where it is, if the current branch is involved in the tie |
200 |
# in the event of a tie the item should stay where it is, if the current branch is involved in the tie |
| 201 |
# when the current branch is not involved in the tie a random branch is choosen from those who tied |
201 |
# when the current branch is not involved in the tie a random branch is chosen from those who tied |
| 202 |
@candidates = sort { |
202 |
@candidates = sort { |
| 203 |
$a->{ratio} <=> $b->{ratio} |
203 |
$a->{ratio} <=> $b->{ratio} |
| 204 |
|| ( $a->{branchcode} eq $branchcode ? -1 : 0 ) - ( $b->{branchcode} eq $branchcode ? -1 : 0 ) |
204 |
|| ( $a->{branchcode} eq $branchcode ? -1 : 0 ) - ( $b->{branchcode} eq $branchcode ? -1 : 0 ) |
| 205 |
- |
|
|