Bug 21738: check items count in C4:ILSDI::HoldTitle
authorAlex Arnaud <alex.arnaud@biblibre.com>
Tue, 13 Nov 2018 08:44:51 +0000 (09:44 +0100)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 8 Feb 2019 20:44:06 +0000 (20:44 +0000)
Test plan:
  - Try holding a title without items via ILS-DI
    (cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=1&bib_id=1),
  - you get an error,
  - apply this patch,
  - try again,
  - you should get the code "Notitems"Bug 21738: check items count in
    C4:ILSDI::HoldTitle

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/ILSDI/Services.pm

index 89b8dab..1ffdc14 100644 (file)
@@ -660,6 +660,18 @@ sub HoldTitle {
     my $biblio = Koha::Biblios->find( $biblionumber );
     return { code => 'RecordNotFound' } unless $biblio;
 
+    my @hostitems = get_hostitemnumbers_of($biblionumber);
+    my @itemnumbers;
+    if (@hostitems){
+        push(@itemnumbers, @hostitems);
+    }
+
+    my $items = Koha::Items->search({ -or => { biblionumber => $biblionumber, itemnumber => { in => \@itemnumbers } } });
+
+    unless ( $items->count ) {
+        return { code => 'NoItems' };
+    }
+
     my $title = $biblio ? $biblio->title : '';
 
     # Check if the biblio can be reserved