Merge branch 'bug_9332' into 3.12-master
[koha_fer] / C4 / SIP / ILS.pm
index 7dc29a7..5d59850 100644 (file)
@@ -181,7 +181,7 @@ sub checkin {
     $circ->item($item = new ILS::Item $item_id);
 
     if ($item) {
-        $circ->do_checkin($current_loc, $return_date);
+        $circ->do_checkin($current_loc);
     } else {
         $circ->alert(1);
         $circ->alert_type(99);
@@ -190,12 +190,16 @@ sub checkin {
        # It's ok to check it in if it exists, and if it was checked out
        $circ->ok($item && $item->{patron});
 
-    if ($circ->ok) {
-               $circ->patron($patron = new ILS::Patron $item->{patron});
-               delete $item->{patron};
-               delete $item->{due_date};
-               $patron->{items} = [ grep {$_ ne $item_id} @{$patron->{items}} ];
-    }
+       if (!defined($item->{patron})) {
+               $circ->screen_msg("Item not checked out");
+       } else {
+               if ($circ->ok) {
+                       $circ->patron($patron = new ILS::Patron $item->{patron});
+                       delete $item->{patron};
+                       delete $item->{due_date};
+                       $patron->{items} = [ grep {$_ ne $item_id} @{$patron->{items}} ];
+               }
+       }
     # END TRANSACTION
 
     return $circ;
@@ -424,17 +428,12 @@ sub renew {
     if (!defined($item)) {
                $trans->screen_msg("Item not checked out to " . $patron->name);     # not checked out to $patron_id
         $trans->ok(0);
-    } elsif (!$item->available($patron_id)) {
-               $trans->screen_msg("Item unavailable due to outstanding holds");
-        $trans->ok(0);
     } else {
-               $trans->renewal_ok(1);
-               $trans->desensitize(0); # It's already checked out
-               $trans->do_renew();
-               syslog("LOG_DEBUG", "done renew (ok:%s): %s renews %s", $trans->renewal_ok, $patron_id, $item_id);
-
-#              $item->{due_date} = $nb_due_date if $no_block eq 'Y';
-#              $item->{sip_item_properties} = $item_props if $item_props;
+        $trans->do_renew();
+        if ($trans->renewal_ok()) {
+            $item->{due_date} = $trans->{due};
+            $trans->desensitize(0);
+        }
     }
 
     return $trans;