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

Evergreen Git git at git.evergreen-ils.org
Tue Aug 9 13:23:10 EDT 2011


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  9dff0defae38eee78d6dac73cc57dd03de589b50 (commit)
       via  e3c90505d2ad5d65235bb4071ed186fc37c0703e (commit)
       via  ab989cb6e241400d2115fb7b1b28bb963a2d4f44 (commit)
       via  65ca55a8dab817f485e379d7ce1ee2ed5d814e22 (commit)
      from  ff7ea322f7d9010643760f01f201a6329209763c (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 9dff0defae38eee78d6dac73cc57dd03de589b50
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Mon Aug 8 09:07:40 2011 -0400

    Ign Reshelving->Available for status_changed_time
    
    This solves a complication when wanting to check status_changed_time against
    offline xact_time when processing offline transactions.
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql
index ddb116a..4698e3f 100644
--- a/Open-ILS/src/sql/Pg/040.schema.asset.sql
+++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql
@@ -117,7 +117,7 @@ CREATE UNIQUE INDEX opac_visible_copies_once_per_record_idx on asset.opac_visibl
 CREATE OR REPLACE FUNCTION asset.acp_status_changed()
 RETURNS TRIGGER AS $$
 BEGIN
-    IF NEW.status <> OLD.status THEN
+	IF NEW.status <> OLD.status AND NOT (NEW.status = 0 AND OLD.status = 7) THEN
         NEW.status_changed_time := now();
         IF NEW.active_date IS NULL AND NEW.status IN (SELECT id FROM config.copy_status WHERE copy_active = true) THEN
             NEW.active_date := now();
diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.acp_status_date_changed.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.acp_status_date_changed.sql
new file mode 100644
index 0000000..34715d1
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.acp_status_date_changed.sql
@@ -0,0 +1,29 @@
+-- Evergreen DB patch YYYY.schema.acp_status_date_changed.sql
+--
+-- Change trigger which updates copy status_changed_time to ignore the
+-- Reshelving->Available status rollover
+-BEGIN;
+
+-- FIXME: 0039.schema.acp_status_date_changed.sql defines this the first time
+-- around, but along with the column itself, etc.  And it gets modified with
+-- 0562.schema.copy_active_date.sql.  Not sure how to use the supercedes /
+-- deprecate stuff for upgrade scripts, if it's even applicable when a given
+-- upgrade script is doing so much.
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('YYYY', :eg_version);
+
+CREATE OR REPLACE FUNCTION asset.acp_status_changed()
+RETURNS TRIGGER AS $$
+BEGIN
+	IF NEW.status <> OLD.status AND NOT (NEW.status = 0 AND OLD.status = 7) THEN
+        NEW.status_changed_time := now();
+        IF NEW.active_date IS NULL AND NEW.status IN (SELECT id FROM config.copy_status WHERE copy_active = true) THEN
+            NEW.active_date := now();
+        END IF;
+    END IF;
+    RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+COMMIT;

commit e3c90505d2ad5d65235bb4071ed186fc37c0703e
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Thu Aug 4 12:11:49 2011 -0400

    Robustify SKIP_ASSET_CHANGE functionality
    
    by skipping status_changed_time test if a barcode has been encountered in prior
    offline transaction within a given session.  Also return the SKIP_ASSET_CHANGE
    event for a given barcode if a prior test resulted in SKIP_ASSET_CHANGE
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/offline/offline.pl b/Open-ILS/src/offline/offline.pl
index 3ff9126..f7719d5 100755
--- a/Open-ILS/src/offline/offline.pl
+++ b/Open-ILS/src/offline/offline.pl
@@ -26,6 +26,10 @@ my $SES = "${DB}::Session";
 my $SCRIPT = "OpenILS::Utils::OfflineStore::Script";
 my $user_groups;
 
+# Used by the functionality that produces SKIP_ASSET_CHANGED events
+my %seen_barcode = ();
+my %skip_barcode_for_status_changed = ();
+
 # --------------------------------------------------------------------
 # Load the config
 # --------------------------------------------------------------------
@@ -707,7 +711,7 @@ sub ol_handle_checkout {
 
         my $barcode = $args->{barcode};
         # Have to have this config option (or org setting) and a
-        # status_changed_time for skippage
+        # status_changed_time for skippage, and barcode not seen before
         if ((
                 ol_get_org_setting(
                     'circ.offline.skip_checkout_if_newer_status_changed_time'
@@ -715,18 +719,25 @@ sub ol_handle_checkout {
                 || $config{skip_late}
             )
             && length($c->status_changed_time())
+            && ! $seen_barcode{$barcode}
         ) {
+            $seen_barcode{$barcode} = 1;
             my $cts = DateTime::Format::ISO8601->parse_datetime( cleanse_ISO8601($c->status_changed_time()) )->epoch();
             my $xts = $command->{timestamp}; # Transaction Time Stamp
-            $logger->activity("offline: ol_handle_checkout: barcode=$barcode, cts=$cts, xts=$xts");
+            $logger->activity("offline: ol_handle_checkout: considering status_changed_time for barcode=$barcode, cts=$cts, xts=$xts");
 
             # Asset has changed after this transaction, ignore
             if ($cts >= $xts) {
-                return OpenILS::Event->new(
-                    'SKIP_ASSET_CHANGED'
-                );
+                $skip_barcode_for_status_changed{$barcode} = 1;
             }
-    #       $logger->activity("offline: fetch_copy_by_barcode: " . Dumper($c->real_fields()));
+        } else {
+            $logger->activity("No skip check: barcode=$barcode seen_barcode=".$seen_barcode{$1}." status_changed_time=".$c->status_changed_time." ou_setting=".ol_get_org_setting('circ.offline.skip_checkout_if_newer_status_changed_time'));
+        }
+        if ($skip_barcode_for_status_changed{$barcode}) {
+            $logger->activity("offline: ol_handle_checkout: barcode=$barcode has SKIP_ASSET_CHANGED");
+            return OpenILS::Event->new(
+                'SKIP_ASSET_CHANGED'
+            );
         }
     }
 
@@ -763,7 +774,7 @@ sub ol_handle_renew {
 
         my $barcode = $args->{barcode};
         # Have to have this config option (or org setting) and a
-        # status_changed_time for skippage
+        # status_changed_time for skippage, and barcode not seen before
         if ((
                 ol_get_org_setting(
                     'circ.offline.skip_renew_if_newer_status_changed_time'
@@ -771,17 +782,25 @@ sub ol_handle_renew {
                 || $config{skip_late}
             )
             && length($c->status_changed_time())
+            && ! $seen_barcode{$barcode}
         ) {
+            $seen_barcode{$barcode} = 1;
             my $cts = DateTime::Format::ISO8601->parse_datetime( cleanse_ISO8601($c->status_changed_time()) )->epoch();
             my $xts = $command->{timestamp}; # Transaction Time Stamp
-            $logger->activity("offline: ol_handle_renew: barcode=$barcode, cts=$cts, xts=$xts");
+            $logger->activity("offline: ol_handle_renew: considering status_changed_time for barcode=$barcode, cts=$cts, xts=$xts");
 
             # Asset has changed after this transaction, ignore
             if ($cts >= $xts) {
-                return OpenILS::Event->new(
-                    'SKIP_ASSET_CHANGED'
-                );
+                $skip_barcode_for_status_changed{$barcode} = 1;
             }
+        } else {
+            $logger->activity("No skip check: barcode=$barcode seen_barcode=".$seen_barcode{$1}." status_changed_time=".$c->status_changed_time." ou_setting=".ol_get_org_setting('circ.offline.skip_renew_if_newer_status_changed_time'));
+        }
+        if ($skip_barcode_for_status_changed{$barcode}) {
+            $logger->activity("offline: ol_handle_renew: barcode=$barcode has SKIP_ASSET_CHANGED");
+            return OpenILS::Event->new(
+                'SKIP_ASSET_CHANGED'
+            );
         }
     }
 
@@ -812,7 +831,7 @@ sub ol_handle_checkin {
         return $e if $e;
 
         # Have to have this config option (or org setting) and a
-        # status_changed_time for skippage
+        # status_changed_time for skippage, and barcode not seen before
         if ((
                 ol_get_org_setting(
                     'circ.offline.skip_checkin_if_newer_status_changed_time'
@@ -820,17 +839,25 @@ sub ol_handle_checkin {
                 || $config{skip_late}
             )
             && length($c->status_changed_time())
+            && ! $seen_barcode{$barcode}
         ) {
+            $seen_barcode{$barcode} = 1;
             my $cts = DateTime::Format::ISO8601->parse_datetime( cleanse_ISO8601($c->status_changed_time()) )->epoch();
             my $xts = $command->{timestamp}; # Transaction Time Stamp
-            $logger->activity("offline: ol_handle_checkin: barcode=$barcode, cts=$cts, xts=$xts");
+            $logger->activity("offline: ol_handle_checkin: considering status_changed_time for barcode=$barcode, cts=$cts, xts=$xts");
 
             # Asset has changed after this transaction, ignore
             if ($cts >= $xts) {
-                return OpenILS::Event->new(
-                    'SKIP_ASSET_CHANGED'
-                );
+                $skip_barcode_for_status_changed{$barcode} = 1;
             }
+        } else {
+            $logger->activity("No skip check: barcode=$barcode seen_barcode=".$seen_barcode{$1}." status_changed_time=".$c->status_changed_time." ou_setting=".ol_get_org_setting('circ.offline.skip_checkin_if_newer_status_changed_time'));
+        }
+        if ($skip_barcode_for_status_changed{$barcode}) {
+            $logger->activity("offline: ol_handle_checkin: barcode=$barcode has SKIP_ASSET_CHANGED");
+            return OpenILS::Event->new(
+                'SKIP_ASSET_CHANGED'
+            );
         }
     }
 

commit ab989cb6e241400d2115fb7b1b28bb963a2d4f44
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Wed Aug 3 22:32:51 2011 -0400

    Offline checkin & renewal checks, & ou settings
    
    Augmented edoceo's patch for checking an offline checkout against an item's
    Status Changed Time and throwing a SKIP_ASSET_CHANGED event if warranted as
    follows:
    
    1) include checkin and renewal transactions
    2) add org unit settings for each, and a corresponding upgrade script
    3) removed the description from the payload and created a dedicated ils_event
    
    However, there are two issues affecting this functionality, even before my
    meddling:
    
    1) the Reshelving -> Available rollover updates an item's Status Changed Time,
       and can thus trigger this event
    2) if an item is manipulated more than once in an offline session, then its
       Status Changed Time can be updated as the transactions are being processed,
       causing related transactions after the initial transaction to fail
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/extras/ils_events.xml b/Open-ILS/src/extras/ils_events.xml
index ee68f72..0297eff 100644
--- a/Open-ILS/src/extras/ils_events.xml
+++ b/Open-ILS/src/extras/ils_events.xml
@@ -930,6 +930,9 @@
 	<event code='8010' textcode='OFFLINE_SESSION_COMPLETE'>
 		<desc xml:lang="en-US"> No org id was provided </desc>
 	</event>
+	<event code='8011' textcode='SKIP_ASSET_CHANGED'>
+		<desc xml:lang="en-US"> Asset status was changed since the offline transaction was recorded</desc>
+	</event>
 
 	<event code='9000' textcode='REPORT_TEMPLATE_EXISTS'>
 		<desc xml:lang="en-US"> A report template with the given name and folder already exists</desc>
diff --git a/Open-ILS/src/offline/offline.pl b/Open-ILS/src/offline/offline.pl
index d3f5de8..3ff9126 100755
--- a/Open-ILS/src/offline/offline.pl
+++ b/Open-ILS/src/offline/offline.pl
@@ -706,8 +706,16 @@ sub ol_handle_checkout {
         return $e if $e;
 
         my $barcode = $args->{barcode};
-        # Have to have this config option & a status_changed_time for skippage
-        if ( ($config{skip_late}) && (length($c->status_changed_time())) ) {
+        # Have to have this config option (or org setting) and a
+        # status_changed_time for skippage
+        if ((
+                ol_get_org_setting(
+                    'circ.offline.skip_checkout_if_newer_status_changed_time'
+                )
+                || $config{skip_late}
+            )
+            && length($c->status_changed_time())
+        ) {
             my $cts = DateTime::Format::ISO8601->parse_datetime( cleanse_ISO8601($c->status_changed_time()) )->epoch();
             my $xts = $command->{timestamp}; # Transaction Time Stamp
             $logger->activity("offline: ol_handle_checkout: barcode=$barcode, cts=$cts, xts=$xts");
@@ -715,8 +723,7 @@ sub ol_handle_checkout {
             # Asset has changed after this transaction, ignore
             if ($cts >= $xts) {
                 return OpenILS::Event->new(
-                    'SKIP_ASSET_CHANGED',
-                    payload => 'The Asset has been update since this transaction, so it will be ignored'
+                    'SKIP_ASSET_CHANGED'
                 );
             }
     #       $logger->activity("offline: fetch_copy_by_barcode: " . Dumper($c->real_fields()));
@@ -746,6 +753,38 @@ sub ol_handle_renew {
 	my $command = shift;
 	my $args = ol_circ_args_from_command($command);
 	my $t = time;
+
+    if( $args->{barcode} ) {
+
+        # $c becomes the Copy
+        # $e possibily becomes the Exception
+        my( $c, $e ) = $U->fetch_copy_by_barcode($args->{barcode});
+        return $e if $e;
+
+        my $barcode = $args->{barcode};
+        # Have to have this config option (or org setting) and a
+        # status_changed_time for skippage
+        if ((
+                ol_get_org_setting(
+                    'circ.offline.skip_renew_if_newer_status_changed_time'
+                )
+                || $config{skip_late}
+            )
+            && length($c->status_changed_time())
+        ) {
+            my $cts = DateTime::Format::ISO8601->parse_datetime( cleanse_ISO8601($c->status_changed_time()) )->epoch();
+            my $xts = $command->{timestamp}; # Transaction Time Stamp
+            $logger->activity("offline: ol_handle_renew: barcode=$barcode, cts=$cts, xts=$xts");
+
+            # Asset has changed after this transaction, ignore
+            if ($cts >= $xts) {
+                return OpenILS::Event->new(
+                    'SKIP_ASSET_CHANGED'
+                );
+            }
+        }
+    }
+
 	return $U->simplereq(
 		'open-ils.circ', 'open-ils.circ.renew.override', $authtoken, $args );
 }
@@ -765,6 +804,36 @@ sub ol_handle_checkin {
 	$logger->activity("offline: checkin : requestor=". $requestor->id.
 		", realtime=$realtime, ".  "workstation=$ws, barcode=$barcode, backdate=$backdate");
 
+    if( $barcode ) {
+
+        # $c becomes the Copy
+        # $e possibily becomes the Exception
+        my( $c, $e ) = $U->fetch_copy_by_barcode($barcode);
+        return $e if $e;
+
+        # Have to have this config option (or org setting) and a
+        # status_changed_time for skippage
+        if ((
+                ol_get_org_setting(
+                    'circ.offline.skip_checkin_if_newer_status_changed_time'
+                )
+                || $config{skip_late}
+            )
+            && length($c->status_changed_time())
+        ) {
+            my $cts = DateTime::Format::ISO8601->parse_datetime( cleanse_ISO8601($c->status_changed_time()) )->epoch();
+            my $xts = $command->{timestamp}; # Transaction Time Stamp
+            $logger->activity("offline: ol_handle_checkin: barcode=$barcode, cts=$cts, xts=$xts");
+
+            # Asset has changed after this transaction, ignore
+            if ($cts >= $xts) {
+                return OpenILS::Event->new(
+                    'SKIP_ASSET_CHANGED'
+                );
+            }
+        }
+    }
+
 	return $U->simplereq(
 		'open-ils.circ', 
 		'open-ils.circ.checkin', $authtoken,
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 43f9634..29a4f90 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -2783,6 +2783,63 @@ INSERT into config.org_unit_setting_type
         ),
         'bool'
     )
+,( 
+        'circ.offline.skip_checkout_if_newer_status_changed_time',
+        oils_i18n_gettext(
+            'circ.offline.skip_checkout_if_newer_status_changed_time',
+            'Offline: Skip offline checkout if newer item Status Changed Time.',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.offline.skip_checkout_if_newer_status_changed_time',
+            'Skip offline checkout transaction (raise exception when'
+            || ' processing) if item Status Changed Time is newer than the'
+            || ' recorded transaction time.  WARNING: The Reshelving to'
+            || ' Available status rollover will trigger this.',
+            'coust',
+            'description'
+        ),
+        'bool'
+    )
+,( 
+        'circ.offline.skip_renew_if_newer_status_changed_time',
+        oils_i18n_gettext(
+            'circ.offline.skip_renew_if_newer_status_changed_time',
+            'Offline: Skip offline renewal if newer item Status Changed Time.',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.offline.skip_renew_if_newer_status_changed_time',
+            'Skip offline renewal transaction (raise exception when'
+            || ' processing) if item Status Changed Time is newer than the'
+            || ' recorded transaction time.  WARNING: The Reshelving to'
+            || ' Available status rollover will trigger this.',
+            'coust',
+            'description'
+        ),
+        'bool'
+    )
+,( 
+        'circ.offline.skip_checkin_if_newer_status_changed_time',
+        oils_i18n_gettext(
+            'circ.offline.skip_checkin_if_newer_status_changed_time',
+            'Offline: Skip offline checkin if newer item Status Changed Time.',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.offline.skip_checkin_if_newer_status_changed_time',
+            'Skip offline checkin transaction (raise exception when'
+            || ' processing) if item Status Changed Time is newer than the'
+            || ' recorded transaction time.  WARNING: The Reshelving to'
+            || ' Available status rollover will trigger this.',
+            'coust',
+            'description'
+        ),
+        'bool'
+    )
 ;
 
 UPDATE config.org_unit_setting_type
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting-circ.offline.skip_foo_if_newer_status_changed_time.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting-circ.offline.skip_foo_if_newer_status_changed_time.sql
new file mode 100644
index 0000000..0a68459
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting-circ.offline.skip_foo_if_newer_status_changed_time.sql
@@ -0,0 +1,69 @@
+-- Evergreen DB patch XXXX.data.org-setting-circ.offline.skip_foo_if_newer_status_changed_time.sql
+--
+-- New org setting circ.offline.skip_checkout_if_newer_status_changed_time
+-- New org setting circ.offline.skip_renew_if_newer_status_changed_time
+-- New org setting circ.offline.skip_checkin_if_newer_status_changed_time
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) 
+    VALUES ( 
+        'circ.offline.skip_checkout_if_newer_status_changed_time',
+        oils_i18n_gettext(
+            'circ.offline.skip_checkout_if_newer_status_changed_time',
+            'Offline: Skip offline checkout if newer item Status Changed Time.',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.offline.skip_checkout_if_newer_status_changed_time',
+            'Skip offline checkout transaction (raise exception when'
+            || ' processing) if item Status Changed Time is newer than the'
+            || ' recorded transaction time.  WARNING: The Reshelving to'
+            || ' Available status rollover will trigger this.',
+            'coust',
+            'description'
+        ),
+        'bool'
+    ),( 
+        'circ.offline.skip_renew_if_newer_status_changed_time',
+        oils_i18n_gettext(
+            'circ.offline.skip_renew_if_newer_status_changed_time',
+            'Offline: Skip offline renewal if newer item Status Changed Time.',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.offline.skip_renew_if_newer_status_changed_time',
+            'Skip offline renewal transaction (raise exception when'
+            || ' processing) if item Status Changed Time is newer than the'
+            || ' recorded transaction time.  WARNING: The Reshelving to'
+            || ' Available status rollover will trigger this.',
+            'coust',
+            'description'
+        ),
+        'bool'
+    ),( 
+        'circ.offline.skip_checkin_if_newer_status_changed_time',
+        oils_i18n_gettext(
+            'circ.offline.skip_checkin_if_newer_status_changed_time',
+            'Offline: Skip offline checkin if newer item Status Changed Time.',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.offline.skip_checkin_if_newer_status_changed_time',
+            'Skip offline checkin transaction (raise exception when'
+            || ' processing) if item Status Changed Time is newer than the'
+            || ' recorded transaction time.  WARNING: The Reshelving to'
+            || ' Available status rollover will trigger this.',
+            'coust',
+            'description'
+        ),
+        'bool'
+    );
+
+COMMIT;

commit 65ca55a8dab817f485e379d7ce1ee2ed5d814e22
Author: Atom Edoceo <atom at helium.edoceo.lan>
Date:   Mon Aug 1 22:54:37 2011 -0700

    LP#797409: Offline Transaction - Option to Skip Old Records
    
    Skip Copy with later Status Change Time on offline checkout import
    Requires the following option in offline-config.pl
      $main::config{skip_late} = 1;
    
    Signed-off-by: David Busby <code at edoceo.com>
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/offline/offline.pl b/Open-ILS/src/offline/offline.pl
index 637a885..d3f5de8 100755
--- a/Open-ILS/src/offline/offline.pl
+++ b/Open-ILS/src/offline/offline.pl
@@ -10,11 +10,12 @@ use OpenSRF::EX qw/:try/;
 use Data::Dumper;
 use OpenILS::Utils::Fieldmapper;
 use Digest::MD5 qw/md5_hex/;
-use OpenSRF::Utils qw/:daemon/;
+use OpenSRF::Utils qw/:daemon cleanse_ISO8601/;
 use OpenILS::Utils::OfflineStore;
 use OpenSRF::Utils::SettingsClient;
 use OpenSRF::Utils;
 use DateTime;
+use DateTime::Format::ISO8601;
 
 use DBI;
 $DBI::trace = 1;
@@ -698,8 +699,28 @@ sub ol_handle_checkout {
 	}
 
     if( $args->{barcode} ) {
+
+        # $c becomes the Copy
+        # $e possibily becomes the Exception
         my( $c, $e ) = $U->fetch_copy_by_barcode($args->{barcode});
         return $e if $e;
+
+        my $barcode = $args->{barcode};
+        # Have to have this config option & a status_changed_time for skippage
+        if ( ($config{skip_late}) && (length($c->status_changed_time())) ) {
+            my $cts = DateTime::Format::ISO8601->parse_datetime( cleanse_ISO8601($c->status_changed_time()) )->epoch();
+            my $xts = $command->{timestamp}; # Transaction Time Stamp
+            $logger->activity("offline: ol_handle_checkout: barcode=$barcode, cts=$cts, xts=$xts");
+
+            # Asset has changed after this transaction, ignore
+            if ($cts >= $xts) {
+                return OpenILS::Event->new(
+                    'SKIP_ASSET_CHANGED',
+                    payload => 'The Asset has been update since this transaction, so it will be ignored'
+                );
+            }
+    #       $logger->activity("offline: fetch_copy_by_barcode: " . Dumper($c->real_fields()));
+        }
     }
 
     my $evt = $U->simplereq(
diff --git a/Open-ILS/src/support-scripts/test-scripts/offline.pl b/Open-ILS/src/support-scripts/test-scripts/offline.pl
index 80c2dd1..fc056af 100755
--- a/Open-ILS/src/support-scripts/test-scripts/offline.pl
+++ b/Open-ILS/src/support-scripts/test-scripts/offline.pl
@@ -81,6 +81,8 @@ sub build_script {
 			backdate			=> $t1
 		};
 	
+        # Here we need to create an option to test the skip_late feature, ask community
+
 		$json .= OpenSRF::Utils::JSON->perl2JSON($checkout) . "\n";
 		$json .= OpenSRF::Utils::JSON->perl2JSON($renew) . "\n" if $renew;
 		$json .= OpenSRF::Utils::JSON->perl2JSON($checkin) . "\n";

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

Summary of changes:
 Open-ILS/src/extras/ils_events.xml                 |    3 +
 Open-ILS/src/offline/offline.pl                    |  119 +++++++++++++++++++-
 Open-ILS/src/sql/Pg/040.schema.asset.sql           |    2 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |   57 ++++++++++
 ...fline.skip_foo_if_newer_status_changed_time.sql |   69 +++++++++++
 .../YYYY.schema.acp_status_date_changed.sql        |   29 +++++
 .../src/support-scripts/test-scripts/offline.pl    |    2 +
 7 files changed, 279 insertions(+), 2 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting-circ.offline.skip_foo_if_newer_status_changed_time.sql
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/YYYY.schema.acp_status_date_changed.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list