fix freeside-daily error checking LNP status, RT#75736, RT#73618
[freeside.git] / FS / FS / part_export / vitelity.pm
index fe56ce2..22f9ba7 100644 (file)
@@ -45,6 +45,7 @@ sub rebless { shift; }
 
 sub can_get_dids { 1; }
 sub get_dids_can_tollfree { 1; };
+sub can_lnp { 1; }
 
 sub get_dids {
   my $self = shift;
@@ -477,6 +478,7 @@ sub check_lnp {
 
   foreach my $svc_phone (
     qsearch({ 'table'     => 'svc_phone',
+              'addl_from' => 'LEFT JOIN cust_svc USING (svcnum)',
               'hashref'   => {lnp_status=>'portingin'},
               'extra_sql' => "AND svcpart $in_svcpart",
            })
@@ -486,9 +488,7 @@ sub check_lnp {
                                                'portid'=>$svc_phone->lnp_portid,
                                             );
 
-    #XXX what $result values mean the port is done?
-
-    if ( $result =~ /^complete$/ ) { #"complete"?  nfi
+    if ( $result =~ /^Complete/i ) {
 
       $svc_phone->lnp_status('portedin');
       my $error = $self->_export_insert($svc_phone);
@@ -502,6 +502,12 @@ sub check_lnp {
         warn "ERROR setting lnp_status for DID ". $svc_phone->phonenum. ": $error" if $error;
       }
 
+    } elsif ( $result ne $svc_phone->lnp_reject_reason ) {
+      $svc_phone->lnp_reject_reason($result);
+      $error = $svc_phone->replace;
+      #XXX log this using our internal log instead, so we can alert on it
+      warn "ERROR setting lnp_reject_reason for DID ". $svc_phone->phonenum. ": $error" if $error;
+
     }
 
   }