handing of suppressed LOST and LONGOVERDUE events
authorGalen Charlton <gmc@esilibrary.com>
Wed, 31 Aug 2016 21:52:11 +0000 (17:52 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 27 Mar 2017 20:28:29 +0000 (16:28 -0400)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
Open-ILS/src/sql/Pg/upgrade/ZZZZ.data.yaous_for_open_circ_exists_fine_handling.sql [new file with mode: 0644]

index 49e3cb9..3f58e15 100644 (file)
@@ -44,6 +44,8 @@ my $MK_ENV_FLESH = {
 # should generate an override of an old-style event
 my %COPY_ALERT_OVERRIDES = (
     "CLAIMSRETURNED\tCHECKOUT" => 'CIRC_CLAIMS_RETURNED',
+    "LOST\tCHECKOUT" => 'OPEN_CIRCULATION_EXISTS',
+    "LONGOVERDUE\tCHECKOUT" => 'OPEN_CIRCULATION_EXISTS',
 );
 
 sub initialize {}
@@ -826,11 +828,31 @@ sub generate_system_copy_alerts {
 
 sub add_overrides_from_system_copy_alerts {
     my $self = shift;
+    my $e = $self->editor;
 
     foreach my $condition (keys %{$self->overrides_per_copy_alerts()}) {
         if (exists $COPY_ALERT_OVERRIDES{$condition}) {
             $self->override(1);
             push @{$self->override_args->{events}}, $COPY_ALERT_OVERRIDES{$condition};
+            # special handling for long-overdue and lost checkouts
+            if ($COPY_ALERT_OVERRIDES{$condition} eq 'OPEN_CIRCULATION_EXISTS') {
+                my $state = (split /\t/, $condition, -1)[0];
+                my $setting;
+                if ($state eq 'LOST') {
+                    $setting = 'circ.copy_alerts.forgive_fines_on_lost_checkin';
+                } elsif ($state eq 'LONGOVERDUE') {
+                    $setting = 'circ.copy_alerts.forgive_fines_on_long_overdue_checkin';
+                } else {
+                    next;
+                }
+                my $forgive = $U->ou_ancestor_setting_value(
+                    $self->circ_lib, $setting, $e
+                );
+                if ($U->is_true($forgive)) {
+                    $self->void_overdues(1);
+                }
+                $self->do_checkin();
+            }
         }
     }
 }
diff --git a/Open-ILS/src/sql/Pg/upgrade/ZZZZ.data.yaous_for_open_circ_exists_fine_handling.sql b/Open-ILS/src/sql/Pg/upgrade/ZZZZ.data.yaous_for_open_circ_exists_fine_handling.sql
new file mode 100644 (file)
index 0000000..4235527
--- /dev/null
@@ -0,0 +1,35 @@
+BEGIN;
+
+--- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES
+        ('circ.copy_alerts.forgive_fines_on_lost_checkin',
+         'circ',
+         oils_i18n_gettext('circ.copy_alerts.forgive_fines_on_lost_checkin',
+            'Forgive fines when checking out a lost item and copy alert is suppressed?',
+            'coust', 'label'),
+         oils_i18n_gettext('circ.copy_alerts.forgive_fines_on_lost_checkin',
+            'Controls whether fines are automatically forgiven when checking out an '||
+            'item that has been marked as lost, and the corresponding copy alert has been '||
+            'suppressed.',
+            'coust', 'description'),
+        'bool');
+
+INSERT INTO config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES
+        ('circ.copy_alerts.forgive_fines_on_long_overdue_checkin',
+         'circ',
+         oils_i18n_gettext('circ.copy_alerts.forgive_fines_on_long_overdue_checkin',
+            'Forgive fines when checking out a long-overdue item and copy alert is suppressed?',
+            'coust', 'label'),
+         oils_i18n_gettext('circ.copy_alerts.forgive_fines_on_lost_checkin',
+            'Controls whether fines are automatically forgiven when checking out an '||
+            'item that has been marked as lost, and the corresponding copy alert has been '||
+            'suppressed.',
+            'coust', 'description'),
+        'bool');
+
+COMMIT;