[open-ils-commits] r16831 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Jun 29 16:29:31 EDT 2010


Author: senator
Date: 2010-06-29 16:29:26 -0400 (Tue, 29 Jun 2010)
New Revision: 16831

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
Log:
Booking: forward-porting bit-by-bit; see commit msg for r16827


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2010-06-29 18:20:02 UTC (rev 16830)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2010-06-29 20:29:26 UTC (rev 16831)
@@ -743,7 +743,7 @@
 	for my $c (@circs) {
 
         my $ctype = ref($c);
-        $ctype =~ s/^.*([^:]+)$/$1/o;
+        $ctype =~ s/^.+::(\w+)$/$1/;
 	
         my $due_date_method = 'due_date';
         my $target_copy_method = 'target_copy';
@@ -765,7 +765,11 @@
 				$self->method_lookup('open-ils.storage.transaction.rollback')->run;
 			}
 			$self->method_lookup('open-ils.storage.transaction.begin')->run( $client );
-			$log->info("Processing circ ".$c->id."...\n");
+			$log->info(
+				sprintf("Processing %s %d...",
+					($is_reservation ? "reservation" : "circ"), $c->id
+				)
+			);
 
 
 			my $due_dt = $parser->parse_datetime( cleanse_ISO8601( $c->$due_date_method ) );
@@ -1500,6 +1504,7 @@
 
 
             my @good_resources = ();
+            my %conflicts = ();
             for my $res (@$all_resources) {
                 unless (isTrue($res->type->catalog_item)) {
                     push @good_resources, $res;
@@ -1519,16 +1524,20 @@
                 }
 
                 if ($copy->status->id == 1) {
-                    my $circs = action::circulation->search_where(
+                    my $circs = [ action::circulation->search_where(
                         {target_copy => $copy->id, checkin_time => undef },
                         { order_by => 'id DESC' }
-                    );
+                    ) ];
 
                     if (@$circs) {
                         my $due_date = $circs->[0]->due_date;
 			            $due_date = $parser->parse_datetime( cleanse_ISO8601( $due_date ) );
 			            my $start_time = $parser->parse_datetime( cleanse_ISO8601( $bresv->start_time ) );
-                        next if (DateTime->compare($start_time, $due_date) < 0);
+                        if (DateTime->compare($start_time, $due_date) < 0) {
+                            $conflicts{$res->id} = $circs->[0]->to_fieldmapper;
+                            next;
+                        }
+
                         push @good_resources, $res;
                     }
 
@@ -1544,8 +1553,9 @@
 			# if we have no copies ...
 			if (!@good_resources) {
 				$log->info("\tNo resources available for targeting at all!\n");
-				push @successes, { reservation => $bresv->id, eligible_copies => 0, error => 'NO_COPIES' };
+				push @successes, { reservation => $bresv->id, eligible_copies => 0, error => 'NO_COPIES', conflicts => \%conflicts };
 
+
 				$self->method_lookup('open-ils.storage.transaction.commit')->run;
 				die "OK\n";
 			}



More information about the open-ils-commits mailing list