X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fikano.pm;h=68b1a9fded937462db91960c23e182d2fce71be7;hb=ffa18709ee8a4d05e18d2d406cf73afe79e52524;hp=4323d94f3dd2ef66bdd5efdd0190389b4a95c5f5;hpb=3dfc446d8a4d241787c47ff7e2db72483d62ab7a;p=freeside.git diff --git a/FS/FS/part_export/ikano.pm b/FS/FS/part_export/ikano.pm index 4323d94f3..68b1a9fde 100644 --- a/FS/FS/part_export/ikano.pm +++ b/FS/FS/part_export/ikano.pm @@ -10,6 +10,7 @@ use FS::Record qw(qsearch qsearchs dbh); use FS::part_export; use FS::svc_dsl; use Data::Dumper; +use Carp qw(carp); @ISA = qw(FS::part_export); $me= '[' . __PACKAGE__ . ']'; @@ -24,12 +25,14 @@ tie my %options, 'Tie::IxHash', default => 'ATT,BELLCA', }, 'debug' => { label => 'Debug Mode', type => 'checkbox' }, + 'import' => { label => 'Import Mode', type => 'checkbox' }, ; %info = ( 'svc' => 'svc_dsl', 'desc' => 'Provision DSL to Ikano', 'options' => \%options, + 'no_machine' => 1, 'notes' => <<'END' Requires installation of Net::Ikano from CPAN. @@ -69,6 +72,11 @@ sub location_types_parse { ); } +sub import_mode { + my $self = shift; + $self->option('import'); +} + sub dsl_pull { # we distinguish between invalid new data (return error) versus data that # has legitimately changed (may eventually execute hooks; now just update) @@ -78,9 +86,19 @@ sub dsl_pull { # current assumptions of what won't change (from their side): # vendor_order_id, vendor_qual_id, vendor_order_type, pushed, monitored, # last_pull, address (from qual), contact info, ProductCustomId - my($self, $svc_dsl, $threshold) = (shift, shift, shift); - my $result = $self->valid_order($svc_dsl,'pull'); - return $result unless $result eq ''; + my($self, $svc_dsl, $threshold, $import) = (shift, shift, shift, shift); + + return 'Invalid operation - Import Mode is enabled' + if $self->import_mode && !$import; + + return 'invalid arguments' if $import && !$self->import_mode; + + warn "$me dsl_pull: import mode" if $self->option('debug'); + + unless ( $import ) { + my $result = $self->valid_order($svc_dsl,'pull'); + return $result unless $result eq ''; + } my $now = time; if($now - $svc_dsl->last_pull < $threshold) { @@ -90,8 +108,8 @@ sub dsl_pull { return ''; } - $result = $self->ikano_command('ORDERSTATUS', - { OrderId => $svc_dsl->vendor_order_id } ); + my $result = $self->ikano_command('ORDERSTATUS', + { OrderId => $svc_dsl->vendor_order_id } ); return $result unless ref($result); # scalar (string) is an error # now we're getting an OrderResponse which should have one Order in it @@ -142,8 +160,20 @@ sub dsl_pull { return 'Invalid number of products on order' if scalar(@product) != 1; my $product = $result->{'Product'}[0]; + $svc_dsl->vendor_order_type('NEW') if $import; # lame + # 3. phonenum - if($svc_dsl->loop_type eq '') { # line-share + if ( $import ) { + if ( $product->{'PhoneNumber'} eq 'STANDALONE' ) { + $svc_dsl->phonenum($product->{'VirtualPhoneNumber'}); + $svc_dsl->loop_type('0'); + } + else { + $svc_dsl->phonenum($product->{'PhoneNumber'}); + $svc_dsl->loop_type(''); + } + } + elsif($svc_dsl->loop_type eq '') { # line-share # TN may change only if sub changes it and New or Change order in Completed status my $tn = $product->{'PhoneNumber'}; if($tn ne $svc_dsl->phonenum) { @@ -287,6 +317,8 @@ sub ikano2fsnote { # address always required for Ikano qual, TN optional (assume dry if not given) sub qual { my($self,$qual) = (shift,shift); + + return 'Invalid operation - Import Mode is enabled' if $self->import_mode; my %location_hash = $qual->location_hash; return 'No address provided' unless keys %location_hash; @@ -295,13 +327,16 @@ sub qual { my $svctn = $qual->phonenum; + my $zip = $location_hash{zip}; + $zip =~ s/(\d{5})-\d{4}/$1/; + my $result = $self->ikano_command('PREQUAL', { AddressLine1 => $location_hash{address1}, AddressUnitType => $location_hash{location_type}, AddressUnitValue => $location_hash{location_number}, AddressCity => $location_hash{city}, AddressState => $location_hash{state}, - ZipCode => $location_hash{zip}, + ZipCode => $zip, Country => $location_hash{country}, LocationType => $location_hash{location_kind}, PhoneNumber => length($svctn) > 1 ? $svctn : "STANDALONE", @@ -408,24 +443,6 @@ sub quals_by_cust_and_pkg { @filtered_quals; } -sub notes_html { - my($self,$svc_dsl) = (shift,shift); - my $conf = new FS::Conf; - my $date_format = $conf->config('date_format') || '%m/%d/%Y'; - my @notes = $svc_dsl->notes; - my $html = ' - '; - foreach my $note ( @notes ) { - $html .= " - - - - "; - } - $html .= '
DateByPriorityNote
".time2str("$date_format %H:%M",$note->date)."".$note->by."". ($note->priority eq 'N' ? 'Normal' : 'High') ."".$note->note."
'; - $html; -} - sub loop_type_long { # sub, not a method my($svc_dsl) = (shift); return $loopType{$svc_dsl->loop_type}; @@ -528,6 +545,13 @@ sub qual2termsid { sub _export_insert { my( $self, $svc_dsl ) = (shift, shift); + if($self->import_mode) { + warn "$me _export_insert: import mode" if $self->option('debug'); + $svc_dsl->pushed((time)-2); + $svc_dsl->last_pull((time)-1); + return $self->dsl_pull($svc_dsl,0,1); + } + my $result = $self->valid_order($svc_dsl,'insert'); return $result unless $result eq ''; @@ -589,6 +613,9 @@ sub _export_insert { sub _export_replace { my( $self, $new, $old ) = (shift, shift, shift); + + return 'Invalid operation - Import Mode is enabled' if $self->import_mode; + # XXX only supports password changes now, but should return error if # another change is attempted? @@ -612,6 +639,8 @@ sub _export_replace { sub _export_delete { my( $self, $svc_dsl ) = (shift, shift); + return 'Invalid operation - Import Mode is enabled' if $self->import_mode; + my $result = $self->valid_order($svc_dsl,'delete'); return $result unless $result eq ''; @@ -650,7 +679,15 @@ sub _export_delete { sub export_expire { my($self, $svc_dsl, $date) = (shift, shift, shift); - + + if ( $FS::svc_Common::noexport_hack ) { + carp 'export_expire() suppressed by noexport_hack' + if $self->option('debug'); + return; + } + + return 'Invalid operation - Import Mode is enabled' if $self->import_mode; + my $result = $self->valid_order($svc_dsl,'expire'); return $result unless $result eq ''; @@ -728,6 +765,8 @@ sub export_expire { sub statuschg { my( $self, $svc_dsl, $type ) = (shift, shift, shift); + + return 'Invalid operation - Import Mode is enabled' if $self->import_mode; my $result = $self->valid_order($svc_dsl,'statuschg'); return $result unless $result eq '';