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

Evergreen Git git at git.evergreen-ils.org
Tue Nov 13 15:47:48 EST 2012


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  eabc8c689151b27f7d2d421775f19dbaa82dbe42 (commit)
       via  f233ad8dc5fdc1f2b783948072e59da9d68ee41b (commit)
      from  c411a9d5745bb3e587d8e43da3d4c5110c645b26 (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 eabc8c689151b27f7d2d421775f19dbaa82dbe42
Author: Dan Wells <dbw2 at calvin.edu>
Date:   Tue Nov 13 15:45:07 2012 -0500

    Stamping upgrade script for lost xact_finish opt.
    
    Signed-off-by: Dan Wells <dbw2 at calvin.edu>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index e722361..7b5b2c3 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -87,7 +87,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 ('0743', :eg_version); -- dbs/tsbere
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0744', :eg_version); -- Dyrcona/dbwells
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_lost_xact_finish_on_zero.sql b/Open-ILS/src/sql/Pg/upgrade/0744.data.coust_lost_xact_finish_on_zero.sql
similarity index 91%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_lost_xact_finish_on_zero.sql
rename to Open-ILS/src/sql/Pg/upgrade/0744.data.coust_lost_xact_finish_on_zero.sql
index 5397ef1..f43cc75 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_lost_xact_finish_on_zero.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0744.data.coust_lost_xact_finish_on_zero.sql
@@ -1,6 +1,6 @@
 BEGIN;
 
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0744', :eg_version);
 
 INSERT INTO config.org_unit_setting_type
     (name, grp, label, description, datatype)

commit f233ad8dc5fdc1f2b783948072e59da9d68ee41b
Author: Jason Stephenson <jstephenson at mvlc.org>
Date:   Sat Nov 3 12:04:34 2012 -0400

    Address Launchpad Bug 793550.
    
    Check for stop fines reason of CHECKIN or RENEW before closing a circulation
    transaction when the balance reaches zero.
    
    Also, if the stop fines reason is LOST, then check a new ou setting,
    circ.lost.xact_open_on_zero, to determine if the transaction is closed or
    kept open.  The setting is checked for the circulation copy's circ_lib.
    
    Add CircCommon->can_close_circ.
    
    Following up on Dan Wells' comments on Launchpad Bug 793550, I have moved
    the logic to check if the circ transaction can be closed to its own utility
    function in OpenILS::Application::Circ::CircCommon.  This potentially
    consolidates the logic in one place in case we need to use it elsewhere.
    
    Instead of checking for stop fines reasons of CHECKIN and RENEW and
    checking for checkin time on the circ, we just check for checkin time.
    Both CHECKIN and RENEW should set the checkin time.
    
    Also, use the constant for stop fines reason of LOST, rather than the
    literal string "LOST".
    
    Signed-off-by: Jason Stephenson <jason at sigio.com>
    Signed-off-by: Dan Wells <dbw2 at calvin.edu>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm
index 613447f..79df59d 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm
@@ -209,4 +209,34 @@ sub extend_grace_period {
     return $grace_period;
 }
 
+# check if a circulation transaction can be closed
+# takes a CStoreEditor and a circ transaction.
+# Returns 1 if the circ should be closed, 0 if not.
+sub can_close_circ {
+    my ($class, $e, $circ) = @_;
+    my $can_close = 0;
+
+    my $reason = $circ->stop_fines;
+
+    # We definitely want to close if this circulation was
+    # checked in or renewed.
+    if ($circ->checkin_time) {
+        $can_close = 1;
+    } elsif ($reason eq OILS_STOP_FINES_LOST) {
+        # Check the copy circ_lib to see if they close
+        # transactions when lost are paid.
+        my $copy = $e->retrieve_asset_copy($circ->target_copy);
+        if ($copy) {
+            $can_close = !$U->is_true(
+                $U->ou_ancestor_setting_value(
+                    $copy->circ_lib,
+                    'circ.lost.xact_open_on_zero',
+                    $e
+                )
+            );
+        }
+    }
+    return $can_close;
+}
+
 1;
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
index f8c276d..eb1ac40 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
@@ -333,9 +333,11 @@ sub make_payments {
             $credit += $cred;
             my $circ = $e->retrieve_action_circulation($transid);
 
-            if(!$circ || $circ->stop_fines) {
-                # If this is a circulation, we can't close the transaction
-                # unless stop_fines is set.
+            # Whether or not we close the transaction. We definitely
+            # close is no circulation transaction is present,
+            # otherwise we check if the circulation is in a state that
+            # allows itself to be closed.
+            if (!$circ || OpenILS::Application::Circ::CircCommon->can_close_circ($e, $circ)) {
                 $trans = $e->retrieve_money_billable_transaction($transid);
                 $trans->xact_finish("now");
                 if (!$e->update_money_billable_transaction($trans)) {
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 5668078..394e7bc 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -11840,3 +11840,22 @@ INSERT into config.org_unit_setting_type
         'bool'
     );
 
+INSERT INTO config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES (
+        'circ.lost.xact_open_on_zero',
+        'finance',
+        oils_i18n_gettext(
+            'circ.lost.xact_open_on_zero',
+            'Leave transaction open when lost balance equals zero',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.lost.xact_open_on_zero',
+            'Leave transaction open when lost balance equals zero.  This leaves the lost copy on the patron record when it is paid',
+            'coust',
+            'description'
+        ),
+        'bool'
+    );
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_lost_xact_finish_on_zero.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_lost_xact_finish_on_zero.sql
new file mode 100644
index 0000000..5397ef1
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.coust_lost_xact_finish_on_zero.sql
@@ -0,0 +1,25 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES (
+        'circ.lost.xact_open_on_zero',
+        'finance',
+        oils_i18n_gettext(
+            'circ.lost.xact_open_on_zero',
+            'Leave transaction open when lost balance equals zero',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.lost.xact_open_on_zero',
+            'Leave transaction open when lost balance equals zero.  This leaves the lost copy on the patron record when it is paid',
+            'coust',
+            'description'
+        ),
+        'bool'
+    );
+
+COMMIT;

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

Summary of changes:
 .../lib/OpenILS/Application/Circ/CircCommon.pm     |   30 ++++++++++++++++++++
 .../perlmods/lib/OpenILS/Application/Circ/Money.pm |    8 +++--
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |   19 ++++++++++++
 .../0744.data.coust_lost_xact_finish_on_zero.sql   |   25 ++++++++++++++++
 5 files changed, 80 insertions(+), 4 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0744.data.coust_lost_xact_finish_on_zero.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list