acq search : support acqlisum and gte/lte on non-date fields
authorBill Erickson <berick@esilibrary.com>
Thu, 19 Jul 2012 21:23:10 +0000 (17:23 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 19 Jul 2012 21:23:10 +0000 (17:23 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm

index fce6604..e181303 100644 (file)
@@ -229,7 +229,7 @@ sub prepare_terms {
     my $conj = $is_and ? "-and" : "-or";
     my $outer_clause = {};
 
-    foreach my $class (qw/acqpo acqpl acqinv jub acqlid/) {
+    foreach my $class (qw/acqpo acqpl acqinv jub acqlid acqlisum/) {
         next if not exists $terms->{$class};
 
         $outer_clause->{$conj} = [] unless $outer_clause->{$conj};
@@ -243,7 +243,12 @@ sub prepare_terms {
             } elsif ($between and could_be_range($v)) {
                 $term_clause = {$k => {"between" => $v}};
             } elsif (check_1d_max($v)) {
-                $v = castdate($v, $gte, $lte) if $castdate;
+                if ($castdate) {
+                    $v = castdate($v, $gte, $lte) if $castdate;
+                } elsif ($gte or $lte) {
+                    my $op = $gte ? '>=' : '<=';
+                    $v = {$op => $v};
+                }
                 $term_clause = {$k => $v};
             } else {
                 next;
@@ -339,6 +344,10 @@ sub build_from_clause_and_joins {
         } else {
             $graft_map{$class} = $query->{from}{$core}{$class} ||= {};
             $graft_map{$class}{type} = $join_type;
+
+            # without this, the SQL attempts to join on 
+            # jub.order_summary, which is a virtual field.
+            $graft_map{$class}{field} = 'lineitem' if $class eq 'acqlisum'; 
         }
     }