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

Evergreen Git git at git.evergreen-ils.org
Tue Aug 20 12:22:05 EDT 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  59dadd1a4ce3a213e0a2367ef0ce2f0accdd480b (commit)
      from  4a171d1b07ad533ceb44a0cef4193b2f9ec315ad (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 59dadd1a4ce3a213e0a2367ef0ce2f0accdd480b
Author: Jason Stephenson <jstephenson at mvlc.org>
Date:   Tue Jun 11 13:22:33 2013 -0400

    Fix Lp bug 965656 WRT back dated checkins with fines.
    
    * Move _check_open_xact from OpenILS::Application::Circ::Money
      to OpenILS::Application::AppUtils so it can be called from
      wherever.
    
    * Modify OpenILS::Application::Circ::Money to use check_open_xact
      from OpenILS::Application::AppUtils.
    
    * Modify finish_fines_and_voiding in OpenILS::Application::Circ::Circulate
      to use check_open_xact instead of reopen_xact.
    
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Ben Shum <bshum at biblio.org>
    
    Conflicts:
    	Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
index e9f1a2c..00d7bf2 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
@@ -2138,5 +2138,47 @@ sub unique_unnested_numbers {
     );
 }
 
+# Check if a transaction should be left open or closed. Close the
+# transaction if it should be closed or open it otherwise. Returns
+# undef on success or a failure event.
+sub check_open_xact {
+    my( $self, $editor, $xactid, $xact ) = @_;
+
+    # Grab the transaction
+    $xact ||= $editor->retrieve_money_billable_transaction($xactid);
+    return $editor->event unless $xact;
+    $xactid ||= $xact->id;
+
+    # grab the summary and see how much is owed on this transaction
+    my ($summary) = $self->fetch_mbts($xactid, $editor);
+
+    # grab the circulation if it is a circ;
+    my $circ = $editor->retrieve_action_circulation($xactid);
+
+    # If nothing is owed on the transaction but it is still open
+    # and this transaction is not an open circulation, close it
+    if(
+        ( $summary->balance_owed == 0 and ! $xact->xact_finish ) and
+        ( !$circ or $circ->stop_fines )) {
+
+        $logger->info("closing transaction ".$xact->id. ' because balance_owed == 0');
+        $xact->xact_finish('now');
+        $editor->update_money_billable_transaction($xact)
+            or return $editor->event;
+        return undef;
+    }
+
+    # If money is owed or a refund is due on the xact and xact_finish
+    # is set, clear it (to reopen the xact) and update
+    if( $summary->balance_owed != 0 and $xact->xact_finish ) {
+        $logger->info("re-opening transaction ".$xact->id. ' because balance_owed != 0');
+        $xact->clear_xact_finish;
+        $editor->update_money_billable_transaction($xact)
+            or return $editor->event;
+        return undef;
+    }
+    return undef;
+}
+
 1;
 
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 2e5924e..fd90e27 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
@@ -2779,8 +2779,8 @@ sub finish_fines_and_voiding {
 
     return $self->bail_on_events($evt) if $evt;
 
-    # make sure the circ isn't closed if we just voided some fines
-    $evt = OpenILS::Application::Circ::CircCommon->reopen_xact($self->editor, $self->circ->id);
+    # Make sure the circ is open or closed as necessary.
+    $evt = $U->check_open_xact($self->editor, $self->circ->id);
     return $self->bail_on_events($evt) if $evt;
 
     return undef;
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 eb1ac40..ec9f052 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
@@ -599,7 +599,7 @@ sub create_grocery_bill {
     $apputils->commit_db_session($session);
 
     my $e = new_editor(xact=>1);
-    $evt = _check_open_xact($e, $transid);
+    $evt = $U->check_open_xact($e, $transid);
     return $evt if $evt;
     $e->commit;
 
@@ -706,7 +706,7 @@ sub billing_items_create {
     my $evt = OpenILS::Utils::Penalty->calculate_penalties($e, $xact->usr, $U->xact_org($xact->id,$e));
     return $evt if $evt;
 
-    $evt = _check_open_xact($e, $xact->id, $xact);
+    $evt = $U->check_open_xact($e, $xact->id, $xact);
     return $evt if $evt;
 
     $e->commit;
@@ -755,7 +755,7 @@ sub void_bill {
         $bill->void_time('now');
     
         $e->update_money_billing($bill) or return $e->die_event;
-        my $evt = _check_open_xact($e, $bill->xact, $xact);
+        my $evt = $U->check_open_xact($e, $bill->xact, $xact);
         return $evt if $evt;
     }
 
@@ -836,45 +836,6 @@ sub edit_payment_note {
     return 1;
 }
 
-sub _check_open_xact {
-    my( $editor, $xactid, $xact ) = @_;
-
-    # Grab the transaction
-    $xact ||= $editor->retrieve_money_billable_transaction($xactid);
-    return $editor->event unless $xact;
-    $xactid ||= $xact->id;
-
-    # grab the summary and see how much is owed on this transaction
-    my ($summary) = $U->fetch_mbts($xactid, $editor);
-
-    # grab the circulation if it is a circ;
-    my $circ = $editor->retrieve_action_circulation($xactid);
-
-    # If nothing is owed on the transaction but it is still open
-    # and this transaction is not an open circulation, close it
-    if( 
-        ( $summary->balance_owed == 0 and ! $xact->xact_finish ) and
-        ( !$circ or $circ->stop_fines )) {
-
-        $logger->info("closing transaction ".$xact->id. ' becauase balance_owed == 0');
-        $xact->xact_finish('now');
-        $editor->update_money_billable_transaction($xact)
-            or return $editor->event;
-        return undef;
-    }
-
-    # If money is owed or a refund is due on the xact and xact_finish
-    # is set, clear it (to reopen the xact) and update
-    if( $summary->balance_owed != 0 and $xact->xact_finish ) {
-        $logger->info("re-opening transaction ".$xact->id. ' becauase balance_owed != 0');
-        $xact->clear_xact_finish;
-        $editor->update_money_billable_transaction($xact)
-            or return $editor->event;
-        return undef;
-    }
-    return undef;
-}
-
 
 __PACKAGE__->register_method (
     method => 'fetch_mbts',

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

Summary of changes:
 .../perlmods/lib/OpenILS/Application/AppUtils.pm   |   42 ++++++++++++++++++
 .../lib/OpenILS/Application/Circ/Circulate.pm      |    4 +-
 .../perlmods/lib/OpenILS/Application/Circ/Money.pm |   45 +------------------
 3 files changed, 47 insertions(+), 44 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list