[open-ils-commits] [GIT] Evergreen ILS branch master updated. b5f791d08b4f3b17e1f93e64d6b3555dec27ea16

Evergreen Git git at git.evergreen-ils.org
Tue Mar 5 15:14:29 EST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  b5f791d08b4f3b17e1f93e64d6b3555dec27ea16 (commit)
       via  e902bba4ca0dbb845abb7d7aac47cc5bb91d11f9 (commit)
      from  127baa9fc39d3b0587fe0f6b5c09bd16c3d0f414 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b5f791d08b4f3b17e1f93e64d6b3555dec27ea16
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Mar 5 15:13:32 2013 -0500

    Stamping upgrade for truncate-to-max-fine
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 377e4b9..fd33d42 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -90,7 +90,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0762', :eg_version); -- miker/gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0763', :eg_version); -- jeff/miker
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
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 51d608f..829dafa 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -12030,6 +12030,21 @@ INSERT INTO config.org_unit_setting_type
         'integer'
     );
 
+INSERT INTO config.org_unit_setting_type (
+    name, label, grp, datatype
+) VALUES (
+    'circ.fines.truncate_to_max_fine',
+    oils_i18n_gettext(
+        'circ.fines.truncate_to_max_fine',
+        'Truncate fines to max fine amount',
+        'coust',
+        'label'
+    ),
+    'circ',
+    'bool'
+);
+
+
 INSERT INTO config.settings_group (name, label)
     VALUES (
         'url_verify',
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.truncate-to-max-fine-setting.sql b/Open-ILS/src/sql/Pg/upgrade/0763.data.truncate-to-max-fine-setting.sql
similarity index 76%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.data.truncate-to-max-fine-setting.sql
rename to Open-ILS/src/sql/Pg/upgrade/0763.data.truncate-to-max-fine-setting.sql
index f9fd754..6d04a42 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.truncate-to-max-fine-setting.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0763.data.truncate-to-max-fine-setting.sql
@@ -1,6 +1,6 @@
 BEGIN;
 
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0763', :eg_version);
 
 INSERT INTO config.org_unit_setting_type (
     name, label, grp, datatype

commit e902bba4ca0dbb845abb7d7aac47cc5bb91d11f9
Author: Jeff Davis <jdavis at sitka.bclibraries.ca>
Date:   Mon Mar 4 13:42:08 2013 -0800

    truncate fines to max fine amount (LP#1145284)
    
    When the max fine amount is not a multiple of the recurring fine amount,
    fines will actually max out at an amount greater than the max fine
    value.  This commit adds YAOUS and some simple functionality to
    optionally truncate the final amount billed to the max fine amount.
    
    For example, if max fine is $5.00 and recurring fine is $0.30, the 17th
    billing will bring the total amount billed to $5.10 (17 x $0.30),
    thereby exceeding the max fine amount.  With this commit, if
    circ.fines.truncate_to_max_fine is true, the final billing amount will
    be reduced and the total amount billed will be $5.00.
    
    Signed-off-by: Jeff Davis <jdavis at sitka.bclibraries.ca>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 05dedcf..abe4c46 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
@@ -1111,6 +1111,10 @@ sub generate_fines {
 				$c->$circ_lib_method->to_fieldmapper->id, 'circ.fines.charge_when_closed');
 			$skip_closed_check = $U->is_true($skip_closed_check);
 
+			my $truncate_to_max_fine = $U->ou_ancestor_setting_value(
+				$c->$circ_lib_method->to_fieldmapper->id, 'circ.fines.truncate_to_max_fine');
+			$truncate_to_max_fine = $U->is_true($truncate_to_max_fine);
+
 			my ($latest_billing_ts, $latest_amount) = ('',0);
 			for (my $bill = 1; $bill <= $pending_fine_count; $bill++) {
 	
@@ -1149,8 +1153,15 @@ sub generate_fines {
 					next if (@cl);
 				}
 
-				$current_fine_total += $recurring_fine;
-				$latest_amount += $recurring_fine;
+				# The billing amount for this billing normally ought to be the recurring fine amount.
+				# However, if the recurring fine amount would cause total fines to exceed the max fine amount,
+				# we may wish to reduce the amount for this billing (if circ.fines.truncate_to_max_fine is true).
+				my $this_billing_amount = $recurring_fine;
+				if ( $truncate_to_max_fine && ($current_fine_total + $this_billing_amount) > $max_fine ) {
+					$this_billing_amount = ($max_fine - $current_fine_total);
+				}
+				$current_fine_total += $this_billing_amount;
+				$latest_amount += $this_billing_amount;
 				$latest_billing_ts = $timestamptz;
 
 				money::billing->create(
@@ -1158,7 +1169,7 @@ sub generate_fines {
 					  note		=> "System Generated Overdue Fine",
 					  billing_type	=> "Overdue materials",
 					  btype		=> 1,
-					  amount	=> sprintf('%0.2f', $recurring_fine/100),
+					  amount	=> sprintf('%0.2f', $this_billing_amount/100),
 					  billing_ts	=> $timestamptz,
 					}
 				);
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.truncate-to-max-fine-setting.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.truncate-to-max-fine-setting.sql
new file mode 100644
index 0000000..f9fd754
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.truncate-to-max-fine-setting.sql
@@ -0,0 +1,15 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type (
+    name, label, grp, datatype
+) VALUES (
+    'circ.fines.truncate_to_max_fine',
+    'Truncate fines to max fine amount',
+    'circ',
+    'bool'
+);
+
+COMMIT;
+

-----------------------------------------------------------------------

Summary of changes:
 .../Application/Storage/Publisher/action.pm        |   17 ++++++++++++++---
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |   15 +++++++++++++++
 .../0763.data.truncate-to-max-fine-setting.sql     |   15 +++++++++++++++
 4 files changed, 45 insertions(+), 4 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0763.data.truncate-to-max-fine-setting.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list