circ: do not crash when 'returning' item that was not issued
authorGalen Charlton <galen.charlton@liblime.com>
Sun, 23 Dec 2007 01:25:33 +0000 (19:25 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Sun, 23 Dec 2007 02:09:29 +0000 (20:09 -0600)
When attempting to return an item that was not actually
on loan, would crash because GetItemIssue did not return
biblionumber in hash.  Add call to get biblionumber
directly.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Circulation.pm

index 85e47b0..117e0d0 100644 (file)
@@ -1137,6 +1137,7 @@ sub AddReturn {
     
     # get information on item
     my $iteminformation = GetItemIssue( GetItemnumberFromBarcode($barcode));
+    my $biblio = GetBiblioFromItemNumber($iteminformation->{'itemnumber'});
     unless ($iteminformation->{'itemnumber'} ) {
         $messages->{'BadBarcode'} = $barcode;
         $doreturn = 0;
@@ -1189,9 +1190,9 @@ sub AddReturn {
                my $sth = $dbh->prepare("UPDATE items SET onloan = NULL where itemnumber = ?");
                $sth->execute($iteminformation->{'itemnumber'});
                $sth->finish();
-               my $record = GetMarcItem( $iteminformation->{'biblionumber'}, $iteminformation->{'itemnumber'} );
-               my $frameworkcode = GetFrameworkCode( $iteminformation->{'biblionumber'} );
-               ModItemInMarc( $record, $iteminformation->{'biblionumber'}, $iteminformation->{'itemnumber'}, $frameworkcode );
+               my $record = GetMarcItem( $biblio->{'biblionumber'}, $iteminformation->{'itemnumber'} );
+               my $frameworkcode = GetFrameworkCode( $biblio->{'biblionumber'} );
+               ModItemInMarc( $record, $biblio->{'biblionumber'}, $iteminformation->{'itemnumber'}, $frameworkcode );
                
                if ($iteminformation->{borrowernumber}){
                        ($borrower) = C4::Members::GetMemberDetails( $iteminformation->{borrowernumber}, 0 );