LP1331174 Long Overdue needs org unit settings user/ldw/LP1378829
authorblake <blake@mobiusconsortium.org>
Fri, 3 Oct 2014 15:11:12 +0000 (10:11 -0500)
committerLiam Whalen <liam.whalen@bc.libraries.coop>
Tue, 10 Mar 2015 17:28:05 +0000 (10:28 -0700)
Added a library setting "Assess Billing When Marked Long-Overdue"
Added a few lines of code to respect that setting and skip some
billing matters under the condition. Tested with and without
setting. Lost still functions the same.

Signed-off-by: blake <blake@mobiusconsortium.org>
Signed-off-by: Liam Whalen <liam.whalen@bc.libraries.coop>
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
Open-ILS/src/perlmods/lib/OpenILS/Const.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/0882.data.long-overdue-asses-fines-library-setting.sql [new file with mode: 0644]

index 1cf8cc8..68b27c4 100644 (file)
@@ -666,16 +666,17 @@ sub set_item_long_overdue {
     return $class->set_item_lost_or_lod(
         $e, $copy_id,
         perm => 'SET_CIRC_LONG_OVERDUE',
-        status => 16, # Long Overdue
-        ous_proc_fee => 'circ.longoverdue_materials_processing_fee',
-        ous_void_od => 'circ.void_overdue_on_longoverdue',
+        status => OILS_COPY_STATUS_LONG_OVERDUE,
+        ous_proc_fee => OILS_SETTING_LONG_OVERDUE_PROCESSING_FEE,
+        ous_void_od => OILS_SETTING_VOID_OVERDUE_ON_LONG_OVERDUE,
         bill_type => 10,
         bill_fee_type => 11,
         bill_note => 'Long Overdue Materials',
         bill_fee_note => 'Long Overdue Materials Processing Fee',
         event => 'COPY_MARKED_LONG_OVERDUE',
-        stop_fines => 'LONGOVERDUE',
-        at_hook => 'longoverdue'
+        stop_fines => OILS_STOP_FINES_LONGOVERDUE,
+        at_hook => 'longoverdue',
+        ous_assess_billing => OILS_SETTING_LONG_OVERDUE_ASSESS_BILLING
     );
 }
 
@@ -708,6 +709,9 @@ sub set_item_lost_or_lod {
         $owning_lib, $args{ous_proc_fee}, $e) || 0;
     my $void_overdue = $U->ou_ancestor_setting_value(
         $owning_lib, $args{ous_void_od}, $e) || 0;
+    my $lod_assess_billing = $U->ou_ancestor_setting_value(
+        $owning_lib, $args{ous_assess_billing}, $e);
+    $lod_assess_billing = 1 unless defined $lod_assess_billing;        
 
     # ---------------------------------------------------------------------
     # move the copy into LOST status
@@ -716,35 +720,41 @@ sub set_item_lost_or_lod {
     $copy->edit_date('now');
     $e->update_asset_copy($copy) or return $e->die_event;
 
-    my $price = $U->get_copy_price($e, $copy, $copy->call_number);
-
-    if( $price > 0 ) {
-        my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e, 
-            $price, $args{bill_type}, $args{bill_note}, $circ->id);
-        return $evt if $evt;
-    }
-
-    # ---------------------------------------------------------------------
-    # if there is a processing fee, charge that too
-    if( $proc_fee > 0 ) {
-        my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e, 
-            $proc_fee, $args{bill_fee_type}, $args{bill_fee_note}, $circ->id);
-        return $evt if $evt;
-    }
-
-    # ---------------------------------------------------------------------
-    # mark the circ as lost and stop the fines
-    $circ->stop_fines($args{stop_fines});
-    $circ->stop_fines_time('now') unless $circ->stop_fines_time;
-    $e->update_action_circulation($circ) or return $e->die_event;
-
     # ---------------------------------------------------------------------
-    # void all overdue fines on this circ if configured
-    if( $void_overdue ) {
-        my $evt = OpenILS::Application::Circ::CircCommon->void_overdues($e, $circ);
-        return $evt if $evt;
-    }
-
+    # Asses billing only when proceeding as "Lost"
+    # or if this is lod and circ.longoverdue.assess_billing is true *or null
+    
+    if( !( ($args{status} == OILS_COPY_STATUS_LONG_OVERDUE) && !$lod_assess_billing) ) { 
+
+           my $price = $U->get_copy_price($e, $copy, $copy->call_number);
+       
+           if( $price > 0 ) {
+               my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e, 
+                   $price, $args{bill_type}, $args{bill_note}, $circ->id);
+               return $evt if $evt;
+           }
+       
+           # ---------------------------------------------------------------------
+           # if there is a processing fee, charge that too
+           if( $proc_fee > 0 ) {
+               my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e, 
+                   $proc_fee, $args{bill_fee_type}, $args{bill_fee_note}, $circ->id);
+               return $evt if $evt;
+           }
+       
+           # ---------------------------------------------------------------------
+           # mark the circ as lost and stop the fines
+           $circ->stop_fines($args{stop_fines});
+           $circ->stop_fines_time('now') unless $circ->stop_fines_time;
+           $e->update_action_circulation($circ) or return $e->die_event;
+       
+           # ---------------------------------------------------------------------
+           # void all overdue fines on this circ if configured
+           if( $void_overdue ) {
+               my $evt = OpenILS::Application::Circ::CircCommon->void_overdues($e, $circ);
+               return $evt if $evt;
+           }
+       }
     my $evt = OpenILS::Application::Circ::CircCommon->reopen_xact($e, $circ->id);
     return $evt if $evt;
 
index cd82e83..6d43582 100644 (file)
@@ -77,12 +77,14 @@ econst OILS_UNLIMITED_CIRC_DURATION   => 'unlimited';
 # Settings
 # ---------------------------------------------------------------------
 econst OILS_SETTING_LOST_PROCESSING_FEE => 'circ.lost_materials_processing_fee';
+econst OILS_SETTING_LONG_OVERDUE_PROCESSING_FEE => 'circ.longoverdue_materials_processing_fee';
 econst OILS_SETTING_DEF_ITEM_PRICE => 'cat.default_item_price';
 econst OILS_SETTING_MIN_ITEM_PRICE => 'circ.min_item_price';
 econst OILS_SETTING_MAX_ITEM_PRICE => 'circ.max_item_price';
 econst OILS_SETTING_ORG_BOUNCED_EMAIL => 'org.bounced_emails';
 econst OILS_SETTING_CHARGE_LOST_ON_ZERO => 'circ.charge_lost_on_zero';
 econst OILS_SETTING_VOID_OVERDUE_ON_LOST => 'circ.void_overdue_on_lost';
+econst OILS_SETTING_VOID_OVERDUE_ON_LONG_OVERDUE => 'circ.void_overdue_on_longoverdue';
 econst OILS_SETTING_HOLD_SOFT_STALL => 'circ.hold_stalling.soft';
 econst OILS_SETTING_HOLD_HARD_STALL => 'circ.hold_stalling.hard';
 econst OILS_SETTING_HOLD_SOFT_BOUNDARY => 'circ.hold_boundary.soft';
@@ -96,6 +98,7 @@ econst OILS_SETTING_RESTORE_OVERDUE_ON_LOST_RETURN      => 'circ.restore_overdue
 econst OILS_SETTING_LOST_IMMEDIATELY_AVAILABLE          => 'circ.lost_immediately_available';
 econst OILS_SETTING_BLOCK_HOLD_FOR_EXPIRED_PATRON       => 'circ.holds.expired_patron_block';
 econst OILS_SETTING_GENERATE_OVERDUE_ON_LOST_RETURN     => 'circ.lost.generate_overdue_on_checkin';
+econst OILS_SETTING_LONG_OVERDUE_ASSESS_BILLING => 'circ.longoverdue.assess_billing';
 
 
 
index ee541b2..34df014 100644 (file)
@@ -1591,7 +1591,7 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES
         'When granted, newly added lineitem identifiers will propagate to linked bib records', 'ppl', 'description')),
  ( 548, 'ACQ_SET_LINEITEM_IDENTIFIER', oils_i18n_gettext(548,
         'Allows staff to change the lineitem identifier', 'ppl', 'description')),
- ( 549, 'COPY_STATUS_LONGOVERDUE.override', oils_i18n_gettext(549,
+ ( 549, 'COPY_STATUS_LONG_OVERDUE.override', oils_i18n_gettext(549,
         'Allows the user to check-in long-overdue items, prompting ' ||
             'long-overdue check-in processing', 'ppl', 'code')), 
  ( 550, 'SET_CIRC_LONG_OVERDUE', oils_i18n_gettext(550,
@@ -13732,6 +13732,23 @@ INSERT INTO config.org_unit_setting_type
             'circ.max_accept_return_of_longoverdue',
         'coust',
         'description'
+   )
+), (
+    'circ.longoverdue.assess_billing',
+    'circ', 'bool',
+    oils_i18n_gettext(
+        'circ.longoverdue.assess_billing',
+        'Asses Billing When Marked Long-Overdue',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.longoverdue.assess_billing',
+        'When an item is marked long overdue a bill for the item will be ' ||
+               'assesed unless this setting is false. The default is true. If false ' ||
+               'void overdue setting will be ignored and processing fee will be ignored',
+        'coust',
+        'description'
     )
 );
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/0882.data.long-overdue-asses-fines-library-setting.sql b/Open-ILS/src/sql/Pg/upgrade/0882.data.long-overdue-asses-fines-library-setting.sql
new file mode 100644 (file)
index 0000000..b7a2f6b
--- /dev/null
@@ -0,0 +1,30 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('0882', :eg_version);
+
+INSERT INTO config.org_unit_setting_type ( name, grp, label, description, datatype ) VALUES (   
+    'circ.longoverdue.assess_billing',
+    'circ',
+    oils_i18n_gettext(
+        'circ.longoverdue.assess_billing',
+        'Assess Billing When Marked Long-Overdue',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.longoverdue.assess_billing',
+        'When an item is marked long overdue, a bill for the item will be ' ||
+               'assessed unless this setting is false. The default is true. If false, ' ||
+               '"Void Overdue Fines When Items are Marked Long-Overdue" and "Long-Overdue'||
+               ' Materials Processing Fee" settings will be ignored.',
+        'coust',
+        'description'
+    ), 'bool'
+)
+;
+
+UPDATE PERMISSION.PERM_LIST SET CODE='COPY_STATUS_LONG_OVERDUE.override' WHERE CODE='COPY_STATUS_LONGOVERDUE.override';
+
+
+
+COMMIT;
\ No newline at end of file