eWay self-signup fixes
[freeside.git] / FS / FS / part_event.pm
index d0ab65e..c98c3f8 100644 (file)
@@ -52,7 +52,7 @@ following fields are currently supported:
 
 =item event - event name
 
-=item eventtable - table name against which this event is triggered; currently "cust_bill" (the traditional invoice events), "cust_main" (customer events) or "cust_pkg (package events)
+=item eventtable - table name against which this event is triggered; currently "cust_bill" (the traditional invoice events), "cust_main" (customer events) or "cust_pkg (package events) (or "cust_statement")
 
 =item check_freq - how often events of this type are checked; currently "1d" (daily) and "1m" (monthly) are recognized.  Note that the apprioriate freeside-daily and/or freeside-monthly cron job needs to be in place.
 
@@ -133,7 +133,7 @@ sub check {
   my $error = 
        $self->ut_numbern('eventpart')
     || $self->ut_text('event')
-    || $self->ut_enum('eventtable', [ 'cust_bill', 'cust_main', 'cust_pkg' ] )
+    || $self->ut_enum('eventtable', [ $self->eventtables ] )
     || $self->ut_enum('check_freq', [ '1d', '1m' ])
     || $self->ut_number('weight')
     || $self->ut_alpha('action')
@@ -273,6 +273,7 @@ sub eventtable_labels {
     'cust_bill'      => 'Invoice',
     'cust_main'      => 'Customer',
     'cust_pay_batch' => 'Batch payment',
+    'cust_statement' => 'Statement',  #too general a name here? "Invoice group"?
   ;
 
   \%hash
@@ -286,18 +287,33 @@ i.e. 'cust_main'=>'cust_main.custnum'
 =cut
 
 sub eventtable_pkey_sql {
-  #my $class = shift;
+  my $class = shift;
 
-  my %hash = (
-    'cust_main'      => 'cust_main.custnum',
-    'cust_bill'      => 'cust_bill.invnum',
-    'cust_pkg'       => 'cust_pkg.pkgnum',
-    'cust_pay_batch' => 'cust_pay_batch.paybatchnum',
-  );
+  my $hashref = $class->eventtable_pkey;
+
+  my %hash = map { $_ => "$_.". $hashref->{$_} } keys %$hashref;
 
   \%hash;
 }
 
+=item eventtable_pkey
+
+Returns a hash reference of full SQL primary key names for eventtable values,
+i.e. 'cust_main'=>'custnum'
+
+=cut
+
+sub eventtable_pkey {
+  #my $class = shift;
+
+  {
+    'cust_main'      => 'custnum',
+    'cust_bill'      => 'invnum',
+    'cust_pkg'       => 'pkgnum',
+    'cust_pay_batch' => 'paybatchnum',
+    'cust_statement' => 'statementnum',
+  };
+}
 
 =item eventtables