[open-ils-commits] r10819 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Oct 10 17:02:19 EDT 2008


Author: erickson
Date: 2008-10-10 17:02:15 -0400 (Fri, 10 Oct 2008)
New Revision: 10819

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
Log:
added support for deposit/rental exempt groups via org setting

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2008-10-10 17:44:05 UTC (rev 10818)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2008-10-10 21:02:15 UTC (rev 10819)
@@ -172,7 +172,7 @@
     $circulator->is_checkin(1) if $api =~ /checkin/;
     $circulator->check_penalty_on_renew(1) if
         $circulator->is_renewal and $U->ou_ancestor_setting_value(
-            $circulator->editor->requestor->ws_ou, 'circ.renew.check_penalty', $circulator->editor);
+            $circulator->circ_lib, 'circ.renew.check_penalty', $circulator->editor);
 
     if($legacy_script_support and not $circulator->is_checkin) {
         $circulator->mk_script_runner();
@@ -427,8 +427,7 @@
     my $self = bless( {}, $class );
 
     $self->events([]);
-    $self->editor( 
-        new_editor(xact => 1, authtoken => $auth) );
+    $self->editor(new_editor(xact => 1, authtoken => $auth));
 
     unless( $self->editor->checkauth ) {
         $self->bail_on_events($self->editor->event);
@@ -686,10 +685,34 @@
 
 sub check_item_deposit_events {
     my $self = shift;
-    $self->push_events(OpenILS::Event->new('ITEM_DEPOSIT_REQUIRED')) if $self->is_deposit;
-    $self->push_events(OpenILS::Event->new('ITEM_RENTAL_FEE_REQUIRED')) if $self->is_rental;
+    $self->push_events(OpenILS::Event->new('ITEM_DEPOSIT_REQUIRED')) 
+        if $self->is_deposit and not $self->is_deposit_exempt;
+    $self->push_events(OpenILS::Event->new('ITEM_RENTAL_FEE_REQUIRED')) 
+        if $self->is_rental and not $self->is_rental_exempt;
 }
 
+# returns true if the user is not required to pay deposits
+sub is_deposit_exempt {
+    my $self = shift;
+    my $pid = (ref $self->patron->profile) ?
+        $self->patron->profile->id : $self->patron->profile;
+    my $groups = $U->ou_ancestor_setting_value(
+        $self->circ_lib, 'circ.deposit.exempt_groups', $self->editor);
+    return 1 if $groups and grep {$_ == $pid} @$groups;
+    return 0;
+}
+
+# returns true if the user is not required to pay rental fees
+sub is_rental_exempt {
+    my $self = shift;
+    my $pid = (ref $self->patron->profile) ?
+        $self->patron->profile->id : $self->patron->profile;
+    my $groups = $U->ou_ancestor_setting_value(
+        $self->circ_lib, 'circ.rental.exempt_groups', $self->editor);
+    return 1 if $groups and grep {$_ == $pid} @$groups;
+    return 0;
+}
+
 sub check_captured_holds {
    my $self    = shift;
    my $copy    = $self->copy;
@@ -1188,7 +1211,9 @@
 sub apply_deposit_fee {
     my $self = shift;
     my $copy = $self->copy;
-    return unless $self->is_deposit or $self->is_rental;
+    return unless 
+        ($self->is_deposit and not $self->is_deposit_exempt) or 
+        ($self->is_rental and not $self->is_rental_exempt);
 
 	my $bill = Fieldmapper::money::billing->new;
     my $amount = $copy->deposit_amount;



More information about the open-ils-commits mailing list