Bug 16284: Check only item for previous checkout if biblio is serial
authorJosef Moravec <josef.moravec@gmail.com>
Thu, 22 Jun 2017 09:26:53 +0000 (11:26 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 13 Aug 2019 13:35:35 +0000 (14:35 +0100)
Test plan:
1) Set 'CheckPrevCheckout' system preference to 'Do'
2) Make a checkout with item from serial record (942$s is 1 on default
    settings)
3) Return that checkout
4) Try to check it out again, you should see an alert, that the patron
has thi item checked out previously
5) Try to checkout another item from same bibliographic record, you
sholud not see the alert and item should be checked out
6) prove t/db_dependent/Patron/Borrower_PrevCheckout.t

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/Patron.pm

index db04efc..bbacd94 100644 (file)
@@ -556,11 +556,13 @@ $PATRON, 0 otherwise.
 sub do_check_for_previous_checkout {
     my ( $self, $item ) = @_;
 
-    # Find all items for bib and extract item numbers.
-    my @items = Koha::Items->search({biblionumber => $item->{biblionumber}});
     my @item_nos;
-    foreach my $item (@items) {
-        push @item_nos, $item->itemnumber;
+    my $biblio = Koha::Biblios->find( $item->{biblionumber} );
+    if ( $biblio->serial ) {
+        push @item_nos, $item->{itemnumber};
+    } else {
+        # Get all itemnumbers for given bibliographic record.
+        @item_nos = $biblio->items->get_column( 'itemnumber' );
     }
 
     # Create (old)issues search criteria