this should fix the barfing about default radius groups on the new customer screen...
[freeside.git] / httemplate / edit / process / cust_main.cgi
index 85dbb97..4ba30c4 100755 (executable)
@@ -1,7 +1,5 @@
 <%
 
-warn join('', map { "$_ => ". $cgi->param($_). "\n" } $cgi->param );
-
 my $error = '';
 
 #unmunge stuff
@@ -55,6 +53,9 @@ if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) {
   );
 }
 
+$new->setfield('paid', $cgi->param('paid') )
+  if $cgi->param('paid');
+
 #perhaps this stuff should go to cust_main.pm
 my $cust_pkg = '';
 my $svc_acct = '';
@@ -102,8 +103,6 @@ if ( $new->custnum eq '' ) {
                                      'popnum'    => $cgi->param('popnum'),
                                    } );
 
-    my $y = $svc_acct->setdefault; # arguably should be in new method
-    $error ||= $y unless ref($y);
     #and just in case you were silly
     $svc_acct->svcpart($svcpart);
     $svc_acct->username($cgi->param('username'));
@@ -120,7 +119,20 @@ if ( $new->custnum eq '' ) {
   tie my %hash, 'Tie::RefHash';
   %hash = ( $cust_pkg => [ $svc_acct ] ) if $cust_pkg;
   $error ||= $new->insert( \%hash, \@invoicing_list );
+
+  my $conf = new FS::Conf;
+  if ( $conf->exists('backend-realtime') && ! $error ) {
+
+    my $berror = $new->bill;
+    $new->apply_payments;
+    $new->apply_credits;
+    $berror ||= $new->collect;
+    warn "Warning, error billing during backend-realtime: $berror" if $berror;
+
+  }
+  
 } else { #create old record object
+
   my $old = qsearchs( 'cust_main', { 'custnum' => $new->custnum } ); 
   $error ||= "Old record not found!" unless $old;
   if ( defined dbdef->table('cust_main')->column('paycvv')
@@ -129,6 +141,7 @@ if ( $new->custnum eq '' ) {
     $new->paycvv($old->paycvv);
   }
   $error ||= $new->replace($old, \@invoicing_list);
+  
 }
 
 if ( $error ) {