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
# --------------------------------------------------------------------
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'
|| $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'
+ );
}
}
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'
|| $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'
+ );
}
}
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'
|| $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'
+ );
}
}