well, don't make things worse when debugging...
[freeside.git] / FS / FS / cust_main.pm
index 125332c..ae6155a 100644 (file)
@@ -512,7 +512,7 @@ and repalce methods.
 sub check {
   my $self = shift;
 
-  warn "BEFORE: \n". $self->_dump;
+  #warn "BEFORE: \n". $self->_dump;
 
   my $error =
     $self->ut_numbern('custnum')
@@ -586,8 +586,9 @@ sub check {
   );
 
   if ( defined $self->dbdef_table->column('ship_last') ) {
-    if ( grep { $self->getfield($_) ne $self->getfield("ship_$_") } @addfields
-         && grep { $self->getfield("ship_$_") ne '' } @addfields
+    if ( scalar ( grep { $self->getfield($_) ne $self->getfield("ship_$_") }
+                       @addfields )
+         && scalar ( grep { $self->getfield("ship_$_") ne '' } @addfields )
        )
     {
       my $error =
@@ -698,7 +699,7 @@ sub check {
 
   $self->otaker(getotaker);
 
-  warn "AFTER: \n". $self->_dump;
+  #warn "AFTER: \n". $self->_dump;
 
   ''; #no error
 }
@@ -1101,7 +1102,7 @@ sub collect {
   my $dbh = dbh;
 
   my $balance = $self->balance;
-  warn "collect: balance $balance" if $Debug;
+  warn "collect customer". $self->custnum. ": balance $balance" if $Debug;
   unless ( $balance > 0 ) { #redundant?????
     $dbh->rollback if $oldAutoCommit; #hmm
     return '';
@@ -1139,10 +1140,16 @@ sub collect {
           qsearch('part_bill_event', { 'payby'    => $self->payby,
                                        'disabled' => '',           } )
     ) {
-      #run callback
+      warn "calling invoice event (". $part_bill_event->eventcode. ")\n"
+        if $Debug;
       my $cust_main = $self; #for callback
       my $error = eval $part_bill_event->eventcode;
 
+      if ( $@ ) {
+        warn "fatal error running invoice event (". $part_bill_event->eventcode.
+             "): $@";
+      }
+
       if ( $error ) {
 
         warn "Error running invoice event (". $part_bill_event->eventcode.