From 77d722b8fc765927d70c197dab11bc3facd4fdde Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 29 Sep 2009 18:56:38 +0000 Subject: [PATCH] added API call for back-dating a circulation after it's already been checked in git-svn-id: svn://svn.open-ils.org/ILS/trunk@14209 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Circ.pm | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index 840111823..fa3f1995e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -361,6 +361,52 @@ sub set_circ_claims_returned { } +__PACKAGE__->register_method( + method => "post_checkin_backdate_circ", + api_name => "open-ils.circ.post_checkin_backdate", + signature => { + desc => q/Back-date an already checked in circulation/, + params => [ + {desc => 'Authentication token', type => 'string'}, + {desc => 'Circ ID', type => 'number'}, + {desc => 'ISO8601 backdate', type => 'string'}, + ], + return => {desc => q/1 on success, failure event on error/} + } +); + +sub post_checkin_backdate_circ { + my( $self, $conn, $auth, $circ_id, $backdate ) = @_; + + my $e = new_editor(authtoken=>$auth, xact=>1); + return $e->die_event unless $e->checkauth; + + my $circ = $e->retrieve_action_circulation($circ_id) + or return $e->die_event; + + # anyone with checkin perms can backdate (more restrictive?) + return $e->die_event unless $e->allowed('COPY_CHECKIN', $circ->circ_lib); + + # don't allow back-dating an open circulation + return OpenILS::Event->new('BAD_PARAMS') unless + $backdate and $circ->checkin_time; + + # update the checkin and stop_fines times to reflect the new backdate + $circ->stop_fines_time(clense_ISO8601($backdate)); + $circ->checkin_time(clense_ISO8601($backdate)); + $e->update_action_circulation($circ) or return $e->die_event; + + # now void the overdues "erased" by the back-dating + my $evt = OpenILS::Application::Circ::CircCommon->void_overdues($e, $circ, $backdate); + return $evt if $evt; + + # If the circ was closed before and the balance owned !=0, re-open the transaction + $evt = OpenILS::Application::Circ::CircCommon->reopen_xact($e, $circ->id); + return $evt if $evt; + + $e->commit; + return 1; +} -- 2.11.0