[freeside-commits] freeside/FS/FS/part_event/Condition has_referral_custnum.pm, 1.1, 1.2

Ivan,,, ivan at wavetail.420.am
Fri Sep 18 15:41:27 PDT 2009


Update of /home/cvs/cvsroot/freeside/FS/FS/part_event/Condition
In directory wavetail.420.am:/tmp/cvs-serv15638/FS/FS/part_event/Condition

Modified Files:
	has_referral_custnum.pm 
Log Message:
add active option to has_referral_custnum condition, RT#6150

Index: has_referral_custnum.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_event/Condition/has_referral_custnum.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- has_referral_custnum.pm	22 Nov 2008 22:17:28 -0000	1.1
+++ has_referral_custnum.pm	18 Sep 2009 22:41:25 -0000	1.2
@@ -7,18 +7,42 @@
 
 sub description { 'Customer has a referring customer'; }
 
+sub option_fields {
+  (
+    'active' => { 'label' => 'Referring customer is active',
+                  'type'  => 'checkbox',
+                  'value' => 'Y',
+                },
+  );
+}
+
 sub condition {
   my($self, $object) = @_;
 
   my $cust_main = $self->cust_main($object);
 
-  $cust_main->referral_custnum;
+  if ( $self->option('active') ) {
+
+    return 0 unless $cust_main->referral_custnum;
+
+    #check for no cust_main for referral_custnum? (deleted?)
+
+    $cust_main->referral_custnum_cust_main->status eq 'active';
+
+  } else {
+
+    $cust_main->referral_custnum; # ? 1 : 0;
+
+  }
+
 }
 
 sub condition_sql {
   #my( $class, $table ) = @_;
 
   "cust_main.referral_custnum IS NOT NULL";
+
+  #XXX a bit harder to check active status here
 }
 
 1;



More information about the freeside-commits mailing list