preserve time component, when appropriate, on edited due dates and backdated circ...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 10 Mar 2010 20:25:55 +0000 (20:25 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 10 Mar 2010 20:25:55 +0000 (20:25 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_0@15779 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm

index e9867b1..e2a46be 100644 (file)
@@ -305,8 +305,14 @@ sub set_circ_claims_returned {
        $circ->stop_fines_time('now') unless $circ->stop_fines_time;
 
     if( $backdate ) {
+        $backdate = clense_ISO8601($backdate);
+
+        my $original_date = DateTime::Format::ISO8601->new->parse_datetime(clense_ISO8601($circ->due_date));
+        my $new_date = DateTime::Format::ISO8601->new->parse_datetime($backdate);
+        $backdate = $new_date->ymd . 'T' . $original_date->strftime('%T%z');
+
         # make it look like the circ stopped at the cliams returned time
-        $circ->stop_fines_time(clense_ISO8601($backdate));
+        $circ->stop_fines_time($backdate);
         my $evt = OpenILS::Application::Circ::CircCommon->void_overdues($e, $circ, $backdate);
         return $evt if $evt;
     }
@@ -341,6 +347,13 @@ sub set_circ_due_date {
 
     return $e->die_event unless $e->allowed('CIRC_OVERRIDE_DUE_DATE', $circ->circ_lib);
        $date = clense_ISO8601($date);
+
+    if (!(interval_to_seconds($circ->duration) % 86400)) { # duration is divisible by days
+        my $original_date = DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($circ->due_date));
+        my $new_date = DateTime::Format::ISO8601->new->parse_datetime($date);
+        $date = $new_date->ymd . 'T' . $original_date->strftime('%T%z');
+    }
+
        $circ->due_date($date);
     $e->update_action_circulation($circ) or return $e->die_event;
     $e->commit;
index d6050cd..09d597f 100644 (file)
@@ -2244,8 +2244,11 @@ sub checkin_handle_backdate {
     # clean up the backdate for date comparison
     # we want any bills created on or after the backdate
     # ------------------------------------------------------------------
-    $bd =~ s/^(\d{4}-\d{2}-\d{2}).*/$1/og;
-    #$bd = "${bd}T23:59:59";
+    my $original_date = DateTime::Format::ISO8601->new->parse_datetime(clense_ISO8601($self->circ->due_date));
+    my $new_date = DateTime::Format::ISO8601->new->parse_datetime($bd);
+    $bd = $new_date->ymd . 'T' . $original_date->strftime('%T%z');
+
+    $self->backdate($bd);
 
     my $bills = $self->editor->search_money_billing(
         {