From 2b914a999a4393d71bad38f4fcbf1b0a496cf6b2 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Fri, 23 Mar 2012 12:23:59 -0400 Subject: [PATCH] Allow fines to accrue during closings Evergreen skips fines during scheduled closings. With this commit, a new Org Unit Setting labeled 'Charge fines on overdue circulations when closed' is available to force fines to accrue during closures. Logic repiars and out-of-scope (strict) variable repairs from Bill Erickson. This work is sponsored by the NC Cardinal consortium in North Carolina. Signed-off-by: Mike Rylander Signed-off-by: Bill Erickson --- .../Application/Storage/Publisher/action.pm | 35 ++++++++++++------- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 20 +++++++++++ .../Pg/upgrade/XXXX.data.fine-when-closed.sql | 21 +++++++++++ 3 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.fine-when-closed.sql diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index f6a4515a2d..cc61ba48a1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -14,6 +14,9 @@ use DateTime::Format::ISO8601; use OpenILS::Utils::Penalty; use POSIX qw(ceil); use OpenILS::Application::Circ::CircCommon; +use OpenILS::Application::AppUtils; +my $U = "OpenILS::Application::AppUtils"; + sub isTrue { my $v = shift; @@ -901,6 +904,10 @@ sub generate_fines { my $recurring_fine = int($c->$recurring_fine_method * 100); my $max_fine = int($c->max_fine * 100); + my $skip_closed_check = $U->ou_ancestor_setting_value( + $c->$circ_lib_method->to_fieldmapper->id, 'circ.fines.charge_when_closed'); + $skip_closed_check = $U->is_true($skip_closed_check); + my ($latest_billing_ts, $latest_amount) = ('',0); for (my $bill = 1; $bill <= $pending_fine_count; $bill++) { @@ -921,22 +928,24 @@ sub generate_fines { $current_bill_count--; } - my $dow = $billing_ts->day_of_week_0(); - my $dow_open = "dow_${dow}_open"; - my $dow_close = "dow_${dow}_close"; + my $timestamptz = $billing_ts->strftime('%FT%T%z'); + if (!$skip_closed_check) { + my $dow = $billing_ts->day_of_week_0(); + my $dow_open = "dow_${dow}_open"; + my $dow_close = "dow_${dow}_close"; - if (my $h = $hoo{$c->$circ_lib_method}) { - next if ( $h->$dow_open eq '00:00:00' and $h->$dow_close eq '00:00:00'); + if (my $h = $hoo{$c->$circ_lib_method}) { + next if ( $h->$dow_open eq '00:00:00' and $h->$dow_close eq '00:00:00'); + } + + my @cl = actor::org_unit::closed_date->search_where( + { close_start => { '<=' => $timestamptz }, + close_end => { '>=' => $timestamptz }, + org_unit => $c->$circ_lib_method } + ); + next if (@cl); } - my $timestamptz = $billing_ts->strftime('%FT%T%z'); - my @cl = actor::org_unit::closed_date->search_where( - { close_start => { '<=' => $timestamptz }, - close_end => { '>=' => $timestamptz }, - org_unit => $c->$circ_lib_method } - ); - next if (@cl); - $current_fine_total += $recurring_fine; $latest_amount += $recurring_fine; $latest_billing_ts = $timestamptz; diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index bc3321f756..aa98c2e6d5 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -11406,6 +11406,26 @@ INSERT INTO config.usr_activity_type (id, ewho, ewhat, ehow, egroup, label) VALU -- reserve the first 1000 slots SELECT SETVAL('config.usr_activity_type_id_seq'::TEXT, 1000); +INSERT INTO config.org_unit_setting_type + (name, label, description, grp, datatype) + VALUES ( + 'circ.fines.charge_when_closed', + oils_i18n_gettext( + 'circ.fines.charge_when_closed', + 'Charge fines on overdue circulations when closed', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.fines.charge_when_closed', + 'Normally, fines are not charged when a library is closed. When set to True, fines will be charged during scheduled closings and normal weekly closed days.', + 'coust', + 'description' + ), + 'circ', + 'bool' + ); + INSERT INTO config.org_unit_setting_type (name, label, description, grp, datatype) VALUES ( diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.fine-when-closed.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.fine-when-closed.sql new file mode 100644 index 0000000000..e3989cd105 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.fine-when-closed.sql @@ -0,0 +1,21 @@ + +INSERT INTO config.org_unit_setting_type + (name, label, description, grp, datatype) + VALUES ( + 'circ.fines.charge_when_closed', + oils_i18n_gettext( + 'circ.fines.charge_when_closed', + 'Charge fines on overdue circulations when closed', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.fines.charge_when_closed', + 'Normally, fines are not charged when a library is closed. When set to True, fines will be charged during scheduled closings and normal weekly closed days.', + 'coust', + 'description' + ), + 'circ', + 'bool' + ); + -- 2.43.2