X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fvitelity.pm;h=574592ff84837e70910290f995d53ca9bb64b3fe;hp=089e1093da52f72316571acf695d606505142da2;hb=0c7672759a3254c4bd7317edb23f40d8880d99d6;hpb=884d54765a4709bee112d7204b127670648b7a55 diff --git a/FS/FS/part_export/vitelity.pm b/FS/FS/part_export/vitelity.pm index 089e1093d..574592ff8 100644 --- a/FS/FS/part_export/vitelity.pm +++ b/FS/FS/part_export/vitelity.pm @@ -1,8 +1,10 @@ package FS::part_export::vitelity; use base qw( FS::part_export ); +use strict; use vars qw( %info ); use Tie::IxHash; +use Data::Dumper; use Geo::StreetAddress::US; use Net::Vitelity 0.05; use FS::Record qw( qsearch dbh ); @@ -282,6 +284,20 @@ sub _export_insert { #porting a number in? different code path if ( $svc_phone->lnp_status eq 'portingin' ) { + my $cust_main = $svc_phone->cust_svc->cust_pkg->cust_main; + + return 'Customer company is required' + unless $cust_main->company; + + return 'Customer day phone (for contact, not porting) is required' + unless $cust_main->daytime; + + return 'LNP Other Provider is required' + unless $svc_phone->lnp_other_provider; + + return 'LNP Other Provider Account # is required' + unless $svc_phone->lnp_other_provider_account; + my %location = $svc_phone->location_hash; my $sa = Geo::StreetAddress::US->parse_location( $location{'address1'} ); @@ -290,12 +306,12 @@ sub _export_insert { 'partial' => 'no', 'wireless' => 'no', 'carrier' => $svc_phone->lnp_other_provider, - 'company' => $svc_phone->cust_svc->cust_pkg->cust_main->company, + 'company' => $cust_main->company, 'accnumber' => $svc_phone->lnp_other_provider_account, 'name' => $svc_phone->phone_name_or_cust, 'streetnumber' => $sa->{number}, 'streetprefix' => $sa->{prefix}, - 'streetname' => $sa->{street}. ' '. $street{type}, + 'streetname' => $sa->{street}. ' '. $sa->{type}, 'streetsuffix' => $sa->{suffix}, 'unit' => ( $sa->{sec_unit_num} ? $sa->{sec_unit_type}. ' '. $sa->{sec_unit_num} @@ -305,14 +321,16 @@ sub _export_insert { 'state' => $location{'state'}, 'zip' => $location{'zip'}, 'billnumber' => $svc_phone->phonenum, #?? do we need a new field for this? - 'contactnumber' => $svc_phone->cust_svc->cust_pkg->cust_main->daytime, + 'contactnumber' => $cust_main->daytime, ); + warn "Vitelity response: $result" if $self->option('debug'); if ( $result =~ /^ok:/i ) { my($ok, $portid, $sig, $bill) = split(':', $result); $svc_phone->lnp_portid($portid); $svc_phone->lnp_signature('Y') if $sig =~ /y/i; $svc_phone->lnp_bill('Y') if $bill =~ /y/i; + local($FS::svc_Common::noexport_hack) = 1; return $svc_phone->replace; } else { return "Error initiating Vitelity port: $result"; @@ -345,6 +363,8 @@ sub _export_insert { if ( $result ne $success ) { return "Error running Vitelity $command: $result"; + } elsif ( $self->option('debug') ) { + warn "Vitelity response: $result"; } ### @@ -354,9 +374,11 @@ sub _export_insert { my $cnam_result = $self->vitelity_command('cnamenable', 'did'=>$svc_phone->phonenum, ); - if ( $result ne 'ok' ) { + if ( $result !~ /^(ok|success)/i ) { #we already provisioned the DID, so... warn "Vitelity error enabling CNAM for ". $svc_phone->phonenum. ": $result"; + } elsif ( $self->option('debug') ) { + warn "Vitelity response: $result"; } ### @@ -365,7 +387,13 @@ sub _export_insert { my $e911_error = $self->e911_send($svc_phone); - if ( $e911_error =~ /^(missingdata|invalid)/i ) { + if ( $e911_error =~ /status=(missingdata|invalid)/i ) { + + my $status = $1; + if ( $e911_error =~ /error=(.*)/ ) { + $e911_error = "status=$status, error=$1"; + } + #but we already provisioned the DID, so: $self->vitelity_command('removedid', 'did'=> $svc_phone->phonenum,); #and check the results? if it failed, then what? @@ -376,12 +404,13 @@ sub _export_insert { ''; } -sub e911send { +sub e911_send { my($self, $svc_phone) = (shift, shift); return '' if $self->option('disable_e911'); my %location = $svc_phone->location_hash; + $location{'zip'} =~ s/\-\d{4}$//; my %e911send = ( 'did' => $svc_phone->phonenum, 'name' => $svc_phone->phone_name_or_cust, @@ -397,35 +426,42 @@ sub e911send { my $e911_result = $self->vitelity_command('e911send', %e911send); - return '' unless $result =~ /^(missingdata|invalid)/i; + unless ( $e911_result =~ /status=(missingdata|invalid)/i ) { + warn "Vitelity response: $e911_result" if $self->option('debug'); + return ''; + } return "Vitelity error provisioning E911 for". $svc_phone->phonenum. - ": $result"; + ": $e911_result"; } sub _export_replace { my( $self, $new, $old ) = (shift, shift, shift); # Call Forwarding - if( $old->forwarddst ne $new->forwarddst ) { - my $result = $self->vitelity_command('callfw', - 'did' => $old->phonenum, - 'forward' => $new->forwarddst ? $new->forwarddst : 'none', - ); - if ( $result ne 'ok' ) { - return "Error running Vitelity callfw: $result"; - } + if ( $old->forwarddst ne $new->forwarddst ) { + my $result = $self->vitelity_command('callfw', + 'did' => $old->phonenum, + 'forward' => $new->forwarddst ? $new->forwarddst : 'none', + ); + if ( $result ne 'ok' ) { + return "Error running Vitelity callfw: $result"; + } elsif ( $self->option('debug') ) { + warn "Vitelity response: $result"; + } } # vfax forwarding emails - if( $old->email ne $new->email && $self->option('fax') ) { - my $result = $self->vitelity_command('changeemail', - 'did' => $old->phonenum, - 'emails' => $new->email ? $new->email : '', - ); - if ( $result ne 'ok' ) { - return "Error running Vitelity changeemail: $result"; - } + if ( $old->email ne $new->email && $self->option('fax') ) { + my $result = $self->vitelity_command('changeemail', + 'did' => $old->phonenum, + 'emails' => $new->email ? $new->email : '', + ); + if ( $result ne 'ok' ) { + return "Error running Vitelity changeemail: $result"; + } elsif ( $self->option('debug') ) { + warn "Vitelity response: $result"; + } } $self->e911_send($new); @@ -447,10 +483,10 @@ sub _export_delete { if ( $result ne 'success' ) { return "Error running Vitelity removedid: $result"; + } elsif ( $self->option('debug') ) { + warn "Vitelity response: $result"; } - return '' if $self->option('disable_e911'); - ''; } @@ -495,6 +531,7 @@ sub check_lnp { # properly warn "ERROR provisioning ported-in DID ". $svc_phone->phonenum. ": $error"; } else { + local($FS::svc_Common::noexport_hack) = 1; $error = $svc_phone->replace; #to set the lnp_status #XXX log this using our internal log instead, so we can alert on it warn "ERROR setting lnp_status for DID ". $svc_phone->phonenum. ": $error" if $error; @@ -502,7 +539,8 @@ sub check_lnp { } elsif ( $result ne $svc_phone->lnp_reject_reason ) { $svc_phone->lnp_reject_reason($result); - $error = $svc_phone->replace; + local($FS::svc_Common::noexport_hack) = 1; + my $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;