From 1aed0f17ab8ae7541b8e819350a6d4bc941a88ef Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 27 Jul 2005 22:46:20 +0000 Subject: [PATCH] more circ love git-svn-id: svn://svn.open-ils.org/ILS/trunk@1565 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Circ/Rules.pm | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm index 5931f3e4f2..ca5258aecb 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm @@ -767,12 +767,32 @@ sub transit_receive { my($status, $status_text) = (0, "Transit Complete"); my $circ; + if($transit->copy_status eq "3") { #if copy is lost $status = 2; $status_text = "Copy is marked as LOST"; + $circ = $session->request( "open-ils.storage.direct.action.circulation.search_where", - { target_copy => $copy->id, xact_finish => undef } )->gather(1); + { target_copy => $copy->id, xact_finish => undef }, + { order_by => "xact_start desc", limit => 1 } )->gather(1); + + + if($circ) { + + my $transaction = $session->request( + "open-ils.storage.direct.money.billable_transaction_summary.retrieve", $circ->id)->gather(1); + + $circ->xact_finish("now") if($transaction->balance_owed <= 0); + + my $s = $session->request( + "open-ils.storage.direct.action.circulation.update", $circ )->gather(1); + + if(!$s) { + throw OpenSRF::EX::ERROR ("Error updating circulation " . $circ->id); + } + } + } $apputils->commit_db_session($session); @@ -891,7 +911,8 @@ sub checkin { warn "Retrieving circ for checkin\n"; my $circ_req = $session->request( "open-ils.storage.direct.action.circulation.search.atomic", - { target_copy => $copy->id, xact_finish => undef } ); + { target_copy => $copy->id, xact_finish => undef }, + { order_by => "xact_start desc", limit => 1 } ); $circ = $circ_req->gather(1)->[0]; @@ -908,7 +929,8 @@ sub checkin { $circ->stop_fines("CHECKIN"); $circ->stop_fines("RENEW") if($isrenewal); - $circ->xact_finish("now") if($transaction->balance_owed <= 0 ); + $circ->stop_fines("LOST") if($iamlost); + $circ->xact_finish("now") if($transaction->balance_owed <= 0 and !$iamlost); if($backdate) { $circ->xact_finish($backdate); -- 2.43.2