Bug 19943: Koha::Biblio - Replace GetBiblioItemData with Koha::Biblio->biblioitem
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 9 Jan 2018 17:37:20 +0000 (14:37 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 23 Mar 2018 15:31:58 +0000 (12:31 -0300)
The biblioitem's info can be retrieved with Koha::Biblio->biblioitem

Test plan:
1. Use the age restriction to restrict checkouts for a given patron
2. Check some items of a biblio out, go to "Items" tab, then "View
item's checkout history" link. Compare views with and without patches

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

C4/Circulation.pm
circ/bookcount.pl
t/db_dependent/Biblio.t

index f2e4f90..3e711cd 100644 (file)
@@ -669,7 +669,8 @@ sub CanBookBeIssued {
 
     my $item = GetItem(undef, $barcode );
     my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
-       my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
+    my $biblio = Koha::Biblios->find( $item->{biblionumber} );
+    my $biblioitem = $biblio->biblioitem;
     my $effective_itemtype = $item->{itype}; # GetItem deals with that
     my $dbh             = C4::Context->dbh;
     my $patron_unblessed = $patron->unblessed;
@@ -927,7 +928,7 @@ sub CanBookBeIssued {
                 }
             }
         }
-        elsif ($biblioitem->{'notforloan'} == 1){
+        elsif ($biblioitem->notforloan == 1){
             if (!C4::Context->preference("AllowNotForLoanOverride")) {
                 $issuingimpossible{NOT_FOR_LOAN} = 1;
                 $issuingimpossible{itemtype_notforloan} = $effective_itemtype;
@@ -1009,7 +1010,7 @@ sub CanBookBeIssued {
     }
 
     ## CHECK AGE RESTRICTION
-    my $agerestriction  = $biblioitem->{'agerestriction'};
+    my $agerestriction  = $biblioitem->agerestriction;
     my ($restriction_age, $daysToAgeRestriction) = GetAgeRestriction( $agerestriction, $patron->unblessed );
     if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) {
         if ( C4::Context->preference('AgeRestrictionOverride') ) {
index 3543d92..3d20aac 100755 (executable)
@@ -28,7 +28,7 @@ use C4::Circulation;
 use C4::Output;
 use C4::Koha;
 use C4::Auth;
-use C4::Biblio; # GetBiblioItemData
+use Koha::Biblios;
 use Koha::DateUtils;
 use Koha::Libraries;
 
@@ -38,7 +38,8 @@ my $bi           = $input->param('bi');
 my $biblionumber = $input->param('biblionumber');
 
 my $idata = itemdatanum($itm);
-my $data  = GetBiblioItemData($bi);
+my $biblio = Koha::Biblios->find( $biblionumber );
+die "No valid biblionumber passed" unless $biblio; # FIXME A bit rude!
 
 my $lastmove = lastmove($itm);
 
@@ -73,8 +74,8 @@ for my $library ( @$libraries ) {
 
 $template->param(
     biblionumber            => $biblionumber,
-    title                   => $data->{'title'},
-    author                  => $data->{'author'},
+    title                   => $biblio->title,
+    author                  => $biblio->author,
     barcode                 => $idata->{'barcode'},
     biblioitemnumber        => $bi,
     homebranch              => $idata->{homebranch},
index 4c4e72d..12dc25b 100755 (executable)
@@ -197,10 +197,10 @@ sub run_tests {
     my ( $title_field, $title_subfield ) = get_title_field();
     is( $marc->subfield( $title_field, $title_subfield ), $title, );
 
-    my $itemdata = GetBiblioItemData( $biblioitemnumber );
-    is( $itemdata->{ title }, $title,
-        'First test of GetBiblioItemData to get same result of previous two GetBiblioData tests.');
-    is( $itemdata->{ isbn }, $isbn,
+    my $biblioitem = Koha::Biblioitems->find( $biblioitemnumber );
+    is( $biblioitem->_result->biblio->title, $title, # Should be $biblioitem->biblio instead, but not needed elsewhere for now
+        'Do not know if this makes sense - compare result of previous two GetBiblioData tests.');
+    is( $biblioitem->isbn, $isbn,
         'Second test checking it returns the correct isbn.');
 
     my $success = 0;