Bugzilla – Attachment 134201 Details for
Bug 30636
ILS-DI shows incorrect availability when not for loan by item type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30636: Show notforloan availability correctly in ILS-DI
Bug-30636-Show-notforloan-availability-correctly-i.patch (text/plain), 3.97 KB, created by
David Cook
on 2022-04-28 05:51:28 UTC
(
hide
)
Description:
Bug 30636: Show notforloan availability correctly in ILS-DI
Filename:
MIME Type:
Creator:
David Cook
Created:
2022-04-28 05:51:28 UTC
Size:
3.97 KB
patch
obsolete
>From 326e7e350267caab2b962757c32dd1d80bbc34e4 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Thu, 28 Apr 2022 05:48:33 +0000 >Subject: [PATCH] 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 >--- > C4/ILSDI/Services.pm | 2 +- > Koha/Item.pm | 28 ++++++++++++++++++++++++++++ > t/db_dependent/Koha/Item.t | 21 ++++++++++++++++++++- > 3 files changed, 49 insertions(+), 2 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 76632283c6..03ded3675c 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -967,7 +967,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 ); >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 5760ebc05c..46436d5886 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -1638,6 +1638,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 >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 38d3f2234d..de0d69e9df 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -20,7 +20,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 15; >+use Test::More tests => 16; > use Test::Exception; > > use C4::Biblio qw( GetMarcSubfieldStructure ); >@@ -1420,3 +1420,22 @@ 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; >+}; >+ >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30636
:
134200
|
134201
|
134566
|
135729