Bug 8769: Allow SIP2 return backdating
authorKyle M Hall <kyle@bywatersolutions>
Fri, 4 Oct 2013 13:53:11 +0000 (09:53 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 5 May 2014 15:04:38 +0000 (15:04 +0000)
Currently Koha's SIP server ignores the return date part of an 09 ( aka
CHECKIN ) message. Koha should backdate a return, and remove
fines accordingly.

Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no>
Works as notified, second date field in SIP checkin (return date) is
used as return date. Return shows up in history with correct date.

Comments:
 - patron is fined if return date is before issue date, but that
   is largely irrelevant anyway.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/Circulation.pm
C4/SIP/ILS.pm
C4/SIP/ILS/Transaction/Checkin.pm

index 39fbc68..f89bb9a 100644 (file)
@@ -1780,7 +1780,8 @@ sub AddReturn {
     }
 
     # case of a return of document (deal with issues and holdingbranch)
-    my $today = DateTime->now( time_zone => C4::Context->tz() );
+    my $today = dt_from_string( $return_date, 'iso' );
+
     if ($doreturn) {
         my $datedue = $issue->{date_due};
         $borrower or warn "AddReturn without current borrower";
index e2089e8..8086bc6 100644 (file)
@@ -181,7 +181,7 @@ sub checkin {
     $circ->item($item = new ILS::Item $item_id);
 
     if ($item) {
-        $circ->do_checkin($current_loc);
+        $circ->do_checkin($current_loc, $return_date);
     } else {
         $circ->alert(1);
         $circ->alert_type(99);
index db1f102..0c84cbc 100644 (file)
@@ -16,6 +16,7 @@ use C4::Circulation;
 use C4::Reserves qw( ModReserveAffect );
 use C4::Items qw( ModItemTransfer );
 use C4::Debug;
+use Koha::DateUtils;
 
 use parent qw(ILS::Transaction);
 
@@ -47,12 +48,26 @@ sub new {
 sub do_checkin {
     my $self = shift;
     my $branch = shift;
+    my $return_date = shift;
     if (!$branch) {
         $branch = 'SIP2';
     }
     my $barcode = $self->{item}->id;
+
+    $return_date =   substr( $return_date, 0, 4 )
+                   . '-'
+                   . substr( $return_date, 4, 2 )
+                   . '-'
+                   . substr( $return_date, 6, 2 )
+                   . q{ }
+                   . substr( $return_date, 12, 2 )
+                   . ':'
+                   . substr( $return_date, 14, 2 )
+                   . ':'
+                   . substr( $return_date, 16, 2 );
+
     $debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
-    my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch);
+    my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date);
     $self->alert(!$return);
     # ignoring messages: NotIssued, IsPermanent, WasLost, WasTransfered