Bug 30636: Show notforloan availability correctly in ILS-DI
This patch adds the Koha::Item->is_notforloan() method which checks the item status of "notforloan" and it checks the effective item type to see if it's marked as "notforloan". This change brings ILS-DI in line with the catalogue which displays "Not for loan" for both those scenarios. 0. Don't apply patch yet 1. Enable ILS-DI system preference http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=ILS-DI 2. Change Item types to "Not for Loan" for Books http://localhost:8081/cgi-bin/koha/admin/itemtypes.pl?op=add_form&itemtype=BK 3. Note that book is listed as "Not for loan" in catalogue http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=29&searchid=scs_1651115075364 4. Note that book is listed as "available" via ILS-DI http://localhost:8080/cgi-bin/koha/ilsdi.pl?service=GetAvailability&id=29&id_type=bib 5. Apply patch and restart starman (ie koha-plack --restart kohadev) 6. Note that book is listed as "not available" and "Not for loan" via ILS-DI http://localhost:8080/cgi-bin/koha/ilsdi.pl?service=GetAvailability&id=29&id_type=bib -- 7. prove t/db_dependent/Koha/Item.t Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
71f54a7571
commit
3b0505247a
3 changed files with 48 additions and 2 deletions
|
@ -972,7 +972,7 @@ sub _availability {
|
|||
my $location = $library ? $library->branchname : '';
|
||||
my $itemcallnumber = $item->itemcallnumber;
|
||||
|
||||
if ( $item->notforloan ) {
|
||||
if ( $item->is_notforloan ) {
|
||||
return ( $biblionumber, __('not available'), __('Not for loan'), $location, $itemcallnumber );
|
||||
} elsif ( $item->onloan ) {
|
||||
return ( $biblionumber, __('not available'), __('Checked out'), $location, $itemcallnumber );
|
||||
|
|
28
Koha/Item.pm
28
Koha/Item.pm
|
@ -1651,6 +1651,34 @@ sub check_recalls {
|
|||
return $recall;
|
||||
}
|
||||
|
||||
=head3 is_notforloan
|
||||
|
||||
my $is_notforloan = $item->is_notforloan;
|
||||
|
||||
Determine whether or not this item is "notforloan" based on
|
||||
the item's notforloan status or its item type
|
||||
|
||||
=cut
|
||||
|
||||
sub is_notforloan {
|
||||
my ( $self ) = @_;
|
||||
my $is_notforloan = 0;
|
||||
|
||||
if ( $self->notforloan ){
|
||||
$is_notforloan = 1;
|
||||
}
|
||||
else {
|
||||
my $itemtype = $self->itemtype;
|
||||
if ($itemtype){
|
||||
if ( $itemtype->notforloan ){
|
||||
$is_notforloan = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $is_notforloan;
|
||||
}
|
||||
|
||||
=head3 _type
|
||||
|
||||
=cut
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
use Modern::Perl;
|
||||
use utf8;
|
||||
|
||||
use Test::More tests => 15;
|
||||
use Test::More tests => 16;
|
||||
use Test::Exception;
|
||||
use Test::MockModule;
|
||||
|
||||
|
@ -1454,3 +1454,21 @@ subtest 'Recalls tests' => sub {
|
|||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'Notforloan tests' => sub {
|
||||
|
||||
plan tests => 3;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $item1 = $builder->build_sample_item;
|
||||
$item1->update({ notforloan => 0 });
|
||||
$item1->itemtype->notforloan(0);
|
||||
is ( $item1->is_notforloan, 0, 'Notforloan is correctly false by item status and item type');
|
||||
$item1->update({ notforloan => 1 });
|
||||
is ( $item1->is_notforloan, 1, 'Notforloan is correctly true by item status');
|
||||
$item1->update({ notforloan => 0 });
|
||||
$item1->itemtype->update({ notforloan => 1 });
|
||||
is ( $item1->is_notforloan, 1, 'Notforloan is correctly true by item type');
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue