From 2df5aff9f202b9d2fa0cb5d2d63ccfbd358b5495 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Mon, 9 Sep 2013 15:49:47 -0400 Subject: [PATCH] Use xact_start for due date calc instead of now If you don't supply a due date when creating a circulation with the open-ils.circ.checkout family of calls, the due date is currently calculated from now(). This code modification changes that so that if a checkout_date is supplied that is used to calculate the due date instead of now(). This enables some interesting uses of the open-ils.circ module for batch circulation in the cases of offline use from a spreadsheet and not the offline client or in the case of migrating circulations from another ILS into Evergreen. Signed-off-by: Thomas Berezansky Signed-off-by: Jason Stephenson Signed-off-by: Dan Wells --- .../src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index f37c0fbf44..307d962dbf 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -2044,7 +2044,7 @@ sub build_checkout_circ_object { # if a patron is renewing, 'requestor' will be the patron $circ->circ_staff($self->editor->requestor->id); - $circ->due_date( $self->create_due_date($circ->duration, $duration_date_ceiling, $duration_date_ceiling_force) ) if $circ->duration; + $circ->due_date( $self->create_due_date($circ->duration, $duration_date_ceiling, $duration_date_ceiling_force, $circ->xact_start) ) if $circ->duration; $self->circ($circ); } @@ -2252,7 +2252,7 @@ sub apply_modified_due_date { sub create_due_date { - my( $self, $duration, $date_ceiling, $force_date ) = @_; + my( $self, $duration, $date_ceiling, $force_date, $start_time ) = @_; # if there is a raw time component (e.g. from postgres), # turn it into an interval that interval_to_seconds can parse @@ -2260,6 +2260,7 @@ sub create_due_date { # for now, use the server timezone. TODO: use workstation org timezone my $due_date = DateTime->now(time_zone => 'local'); + $due_date = DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($start_time)) if $start_time; # add the circ duration $due_date->add(seconds => OpenSRF::Utils->interval_to_seconds($duration)); -- 2.43.2