From 7ec1e5dbde3b523b5afb7b8fb48c07afa09da02e Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 31 Aug 2016 17:52:11 -0400 Subject: [PATCH] handing of suppressed LOST and LONGOVERDUE events Signed-off-by: Galen Charlton --- .../lib/OpenILS/Application/Circ/Circulate.pm | 22 ++++++++++++++ ...ta.yaous_for_open_circ_exists_fine_handling.sql | 35 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/upgrade/ZZZZ.data.yaous_for_open_circ_exists_fine_handling.sql diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index 49e3cb9942..3f58e15abf 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -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 index 0000000000..4235527112 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/ZZZZ.data.yaous_for_open_circ_exists_fine_handling.sql @@ -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; -- 2.11.0