Skip to content

Commit 496e34f

Browse files
authored
Add a check for a recall to determine if item is available (#29)
1 parent c718924 commit 496e34f

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

Koha/Plugin/Fi/KohaSuomi/DI/Koha/Availability/Checks/Item.pm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,5 +567,18 @@ sub _pickup_location_allowed {
567567
return $context_cache->{items_available_by_location}->{$location} ? 0 : 1;
568568
}
569569

570+
=head3 recalled
571+
572+
Returns Koha::Plugin::Fi::KohaSuomi::DI::Koha::Exceptions::Item::Recalled if item has been recalled.
573+
574+
=cut
575+
576+
sub recalled {
577+
my ($self) = @_;
578+
579+
if ($self->item->recall) {
580+
return Koha::Plugin::Fi::KohaSuomi::DI::Koha::Exceptions::Item::Recalled->new;
581+
}
582+
}
570583

571584
1;

Koha/Plugin/Fi/KohaSuomi/DI/Koha/Exceptions/Item.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ use Exception::Class (
8787
'Koha::Plugin::Fi::KohaSuomi::DI::Koha::Exceptions::Item::Withdrawn' => {
8888
isa => 'Koha::Plugin::Fi::KohaSuomi::DI::Koha::Exceptions::Item',
8989
description => "Item is marked as withdrawn.",
90+
},
91+
'Koha::Plugin::Fi::KohaSuomi::DI::Koha::Exceptions::Item::Recalled' => {
92+
isa => 'Koha::Plugin::Fi::KohaSuomi::DI::Koha::Exceptions::Item',
93+
description => "Item has been recalled.",
9094
}
9195

9296
);

Koha/Plugin/Fi/KohaSuomi/DI/Koha/Item/Availability/Search.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package Koha::Plugin::Fi::KohaSuomi::DI::Koha::Item::Availability::Search;
1919
# along with Koha; if not, see <http://www.gnu.org/licenses>.
2020

2121
use Modern::Perl;
22+
use C4::Context;
2223

2324
use base qw(Koha::Plugin::Fi::KohaSuomi::DI::Koha::Item::Availability);
2425

@@ -58,6 +59,9 @@ sub in_opac {
5859
if (!$params->{'ignore_transfer'}) {
5960
$self->unavailable($reason) if $reason = $itemcalc->transfer;
6061
}
62+
if (C4::Context->preference('UseRecalls')) {
63+
$self->unavailable($reason) if $reason = $itemcalc->recalled;
64+
}
6165

6266
return $self;
6367
}

Koha/Plugin/Fi/KohaSuomi/DI/openapi/definitions/availability/reason.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ properties:
281281
- integer
282282
- "null"
283283
type: object
284+
Item::Recalled:
285+
description: Item has been recalled.
286+
properties: {}
287+
type: object
284288
Patron::AgeRestricted:
285289
description: An age restriction applies for this patron.
286290
properties:

0 commit comments

Comments
 (0)