Lines 1124-1129
Check whether the item can be returned to the provided branch
Link Here
|
1124 |
|
1124 |
|
1125 |
=item C<$branch> is the branchcode where the return is taking place |
1125 |
=item C<$branch> is the branchcode where the return is taking place |
1126 |
|
1126 |
|
|
|
1127 |
=item C<$itemtype> is the document type of the item |
1128 |
|
1127 |
=back |
1129 |
=back |
1128 |
|
1130 |
|
1129 |
Returns: |
1131 |
Returns: |
Lines 1139-1151
Returns:
Link Here
|
1139 |
=cut |
1141 |
=cut |
1140 |
|
1142 |
|
1141 |
sub CanBookBeReturned { |
1143 |
sub CanBookBeReturned { |
1142 |
my ($item, $branch) = @_; |
1144 |
my ($item, $branch, $itemtype) = @_; |
1143 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
|
|
1144 |
|
1145 |
|
1145 |
# assume return is allowed to start |
1146 |
# assume return is allowed to start |
1146 |
my $allowed = 1; |
1147 |
my $allowed = 1; |
1147 |
my $message; |
1148 |
my $message; |
1148 |
|
1149 |
|
|
|
1150 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
1151 |
if ($allowreturntobranch eq 'anywhere') { |
1152 |
# if we try a checkin that would result in a forbidden branchtransfer, refuse the return as well |
1153 |
# first, find branchtransferlimit value for this item |
1154 |
my $branchtransferlimitvalue = (C4::Context->preference("item-level_itypes") && C4::Context->preference("BranchTransferLimitsType") eq 'ccode') ? $item->{ccode} : $itemtype; |
1155 |
if ( $item->{'homebranch'} ne $branch |
1156 |
&& ( C4::Context->preference("IndependentBranches") |
1157 |
or ( C4::Context->preference("UseBranchTransferLimits") and not IsBranchTransferAllowed($item->{'homebranch'}, $branch, $branchtransferlimitvalue) ) |
1158 |
) |
1159 |
) |
1160 |
{ |
1161 |
$allowed = 0; |
1162 |
$message = $item->{'homebranch'}; |
1163 |
return ($allowed, $message); |
1164 |
} |
1165 |
} |
1166 |
|
1149 |
# identify all cases where return is forbidden |
1167 |
# identify all cases where return is forbidden |
1150 |
if ($allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'}) { |
1168 |
if ($allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'}) { |
1151 |
$allowed = 0; |
1169 |
$allowed = 0; |
Lines 1924-1930
sub AddReturn {
Link Here
|
1924 |
} |
1942 |
} |
1925 |
|
1943 |
|
1926 |
# check if the return is allowed at this branch |
1944 |
# check if the return is allowed at this branch |
1927 |
my ($returnallowed, $message) = CanBookBeReturned($item_unblessed, $branch); |
1945 |
my ($returnallowed, $message) = CanBookBeReturned($item, $branch, $itemtype); |
1928 |
unless ($returnallowed){ |
1946 |
unless ($returnallowed){ |
1929 |
$messages->{'Wrongbranch'} = { |
1947 |
$messages->{'Wrongbranch'} = { |
1930 |
Wrongbranch => $branch, |
1948 |
Wrongbranch => $branch, |
1931 |
- |
|
|