Bug 27071: Code simplification

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-11-23 15:52:56 +01:00
parent 4b445425eb
commit c6606d4a65
2 changed files with 4 additions and 18 deletions

View file

@ -566,10 +566,10 @@ sub CanItemBeReserved {
unless ($item->can_be_transferred({ to => $destination })) {
return { status => 'cannotBeTransferred' };
}
unless ($branchitemrule->{hold_fulfillment_policy} ne 'holdgroup' || $item_library->validate_hold_sibling( {branchcode => $pickup_branchcode} )) {
if ($branchitemrule->{hold_fulfillment_policy} eq 'holdgroup' && !$item_library->validate_hold_sibling( {branchcode => $pickup_branchcode} )) {
return { status => 'pickupNotInHoldGroup' };
}
unless ($branchitemrule->{hold_fulfillment_policy} ne 'patrongroup' || Koha::Libraries->find({branchcode => $borrower->{branchcode}})->validate_hold_sibling({branchcode => $pickup_branchcode})) {
if ($branchitemrule->{hold_fulfillment_policy} eq 'patrongroup' && !Koha::Libraries->find({branchcode => $borrower->{branchcode}})->validate_hold_sibling({branchcode => $pickup_branchcode})) {
return { status => 'pickupNotInHoldGroup' };
}
}

View file

@ -243,23 +243,9 @@ sub validate_hold_sibling {
return 1 if $params->{branchcode} eq $self->id;
my $branchcode = $params->{branchcode};
my @hold_libraries = $self->get_hold_libraries;
foreach (@hold_libraries) {
my $hold_library = $_;
my $is_valid = 0;
foreach my $key (keys %$params) {
if ($hold_library->$key eq $params->{$key}) {
$is_valid=1;
last;
}
}
if($is_valid) {
#Found one library that meets all search parameters
return 1;
}
}
return 0;
return grep {$_->branchcode eq $branchcode} @hold_libraries;
}
=head2 Internal methods