From 7d53bdc9bf5a5beef8d135078299806a3a6d0f48 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 26 Apr 2006 14:59:36 +0000 Subject: [PATCH] added auto-billing for lost items fixed some bugs in the circ.. git-svn-id: svn://svn.open-ils.org/ILS/trunk@3890 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Circ.pm | 48 +++++++++++++++++-- .../OpenILS/Application/Circ/Circulate.pm | 6 +++ 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index 7403038aa3..e029090e35 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -22,6 +22,7 @@ use OpenILS::Utils::ModsParser; use OpenILS::Event; use OpenSRF::EX qw(:try); use OpenSRF::Utils::Logger qw(:logger); +use OpenILS::Utils::Fieldmapper; #my $logger = "OpenSRF::Utils::Logger"; @@ -210,6 +211,8 @@ sub set_circ_lost { return $evt if $evt; $circ->stop_fines("CLAIMSRETURNED"); + $logger->activity("user ".$user->id." marking circ". $circ->id. " as claims returned"); + # allow the caller to backdate the circulation and void any fines # that occurred after the backdate if($backdate) { @@ -229,15 +232,53 @@ sub set_circ_lost { sub _set_circ_lost { my( $copy, $circ, $reqr, $session ) = @_; + + my $evt = $U->check_perms($reqr->id, $circ->circ_lib, 'SET_CIRC_LOST'); + return $evt if $evt; + + $logger->activity("user ".$reqr->id." marking copy ".$copy->id. + " lost for circ ". $circ->id. " and checking for necessary charges"); + my $newstat = $U->copy_status_from_name('lost'); if( $copy->status ne $newstat->id ) { + $copy->status($newstat); - $U->update_copy(copy => $copy, editor => $user->id, session => $session); + $U->update_copy( + copy => $copy, + editor => $reqr->id, + session => $session); + } + + # if the copy has a price defined and/or a processing fee, bill the patron + my $amount = $copy->price || 0; + my $owner = $U->fetch_copy_owner($copy->id); + $logger->info("circ fetching org settings for $owner to determine processing fee"); + my $settings = $U->simplereq( + 'open-ils.actor', + 'open-ils.actor.org_unit.settings.retrieve', $owner ); + my $f = $settings->{'circ.processing_fee'} || 0; + $amount += $f; + + if( $amount > 0 ) { + + $logger->activity("The system is charging $amount ". + "for lost materials on circulation ".$circ->id); + + my $bill = Fieldmapper::money::billing->new; + + $bill->xact( $circ->id ); + $bill->amount( $amount ); + $bill->billing_type('Lost materials'); # - these strings should be configurable some day + $bill->note('SYSTEM GENERATED'); + + my $id = $session->request( + 'open-ils.storage.direct.money.billing.create', $bill )->gather(1); + + return $U->DB_UPDATE_FAILED($bill) unless defined $id; } - $evt = $U->check_perms($user->id, $circ->circ_lib, 'SET_CIRC_LOST'); - return $evt if $evt; $circ->stop_fines("LOST"); + return undef; } @@ -479,6 +520,7 @@ sub create_copy_note { return $evt if $evt; $note->create_date('now'); + $note->creator($requestor->id); $note->pub( ($note->pub) ? 't' : 'f' ); my $id = $U->storagereq( diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index efa740d17d..b819e19f08 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -1185,6 +1185,11 @@ sub checkin_do_receive { } else { + # Transit has been closed, now let's see if the copy's original + # status is something the staff should be warned of + my $e = _checkin_check_copy_status($ctx); + $evt = $e if $e; + if($holdtrans) { # copy was received as a hold transit. Copy is at target lib @@ -1432,6 +1437,7 @@ sub _checkin_check_copy_status { return undef if( $status == $U->copy_status_from_name('available')->id || $status == $U->copy_status_from_name('checked out')->id || + $status == $U->copy_status_from_name('in process')->id || $status == $U->copy_status_from_name('in transit')->id || $status == $U->copy_status_from_name('reshelving')->id ); -- 2.43.2