Lines 60-65
sub lowest_ratio_library {
Link Here
|
60 |
my $branch = $limit->get_column('branchcode'); |
60 |
my $branch = $limit->get_column('branchcode'); |
61 |
my $float_limit_val = $limit->get_column('float_limit'); |
61 |
my $float_limit_val = $limit->get_column('float_limit'); |
62 |
|
62 |
|
|
|
63 |
#don't try to transfer something to where it already is |
64 |
next if $branch eq $branchcode; |
65 |
|
63 |
my $item_count; |
66 |
my $item_count; |
64 |
|
67 |
|
65 |
if ($use_item_level) { |
68 |
if ($use_item_level) { |
Lines 72-78
sub lowest_ratio_library {
Link Here
|
72 |
)->count; |
75 |
)->count; |
73 |
|
76 |
|
74 |
# Count items in transit TO this branch |
77 |
# Count items in transit TO this branch |
75 |
my $in_transit_count = Koha::Items->search( |
78 |
my $in_transit_to_count = Koha::Items->search( |
76 |
{ |
79 |
{ |
77 |
itype => $item->effective_itemtype, |
80 |
itype => $item->effective_itemtype, |
78 |
|
81 |
|
Lines 88-94
sub lowest_ratio_library {
Link Here
|
88 |
distinct => 1 |
91 |
distinct => 1 |
89 |
} |
92 |
} |
90 |
)->count; |
93 |
)->count; |
91 |
$item_count = $at_branch_count + $in_transit_count; |
94 |
|
|
|
95 |
my $in_transit_from_count = Koha::Items->search( |
96 |
{ itype => $item->effective_itemtype }, |
97 |
{ |
98 |
join => 'branchtransfers', |
99 |
where => { |
100 |
'branchtransfers.frombranch' => $branch, |
101 |
'branchtransfers.datearrived' => undef, |
102 |
'branchtransfers.datecancelled' => undef, |
103 |
}, |
104 |
distinct => 1 |
105 |
} |
106 |
)->count; |
107 |
$item_count = $at_branch_count + $in_transit_to_count - $in_transit_from_count; |
92 |
} else { |
108 |
} else { |
93 |
my $at_branch_count = Koha::Items->search( |
109 |
my $at_branch_count = Koha::Items->search( |
94 |
{ |
110 |
{ |
Lines 99-105
sub lowest_ratio_library {
Link Here
|
99 |
)->count; |
115 |
)->count; |
100 |
|
116 |
|
101 |
# Count items in transit TO this branch |
117 |
# Count items in transit TO this branch |
102 |
my $in_transit_count = Koha::Items->search( |
118 |
my $in_transit_to_count = Koha::Items->search( |
103 |
{ |
119 |
{ |
104 |
itype => $item->effective_itemtype, |
120 |
itype => $item->effective_itemtype, |
105 |
}, |
121 |
}, |
Lines 113-121
sub lowest_ratio_library {
Link Here
|
113 |
distinct => 1 |
129 |
distinct => 1 |
114 |
} |
130 |
} |
115 |
)->count; |
131 |
)->count; |
116 |
$item_count = $at_branch_count + $in_transit_count; |
132 |
|
|
|
133 |
my $in_transit_from_count = Koha::Items->search( |
134 |
{ |
135 |
itype => $item->effective_itemtype, |
136 |
}, |
137 |
{ |
138 |
join => 'branchtransfers', |
139 |
where => { |
140 |
'branchtransfers.frombranch' => $branch, |
141 |
'branchtransfers.datearrived' => undef, # Still in transit |
142 |
'branchtransfers.datecancelled' => undef, #Not cancelled |
143 |
}, |
144 |
distinct => 1 |
145 |
} |
146 |
)->count; |
147 |
$item_count = $at_branch_count + $in_transit_to_count - $in_transit_from_count; |
117 |
} |
148 |
} |
118 |
|
149 |
|
|
|
150 |
#don't transfer to branches that are already at their float limit |
151 |
next if $item_count >= $float_limit_val; |
152 |
|
119 |
my $ratio = $item_count / $float_limit_val; |
153 |
my $ratio = $item_count / $float_limit_val; |
120 |
push @candidates, { |
154 |
push @candidates, { |
121 |
branchcode => $branch, |
155 |
branchcode => $branch, |
122 |
- |
|
|