RT# 83450 - fixed rateplan export
[freeside.git] / FS / FS / part_export / test.pm
index 126897c..392fc4f 100644 (file)
@@ -18,6 +18,7 @@ tie %options, 'Tie::IxHash',
   'replace' => { label    => 'Replace',type => 'checkbox', default => 1, },
   'suspend' => { label    => 'Suspend',type => 'checkbox', default => 1, },
   'unsuspend'=>{ label => 'Unsuspend', type => 'checkbox', default => 1, },
+  'get_dids_npa_select' => { label => 'DIDs by NPA', type => 'checkbox' },
 ;
 
 %info = (
@@ -31,6 +32,8 @@ or always dies, according to the "Result" option.  It does nothing else; the
 purpose is purely to simulate success or failure within an export module.</P>
 <P>The checkbox options can be used to turn the export off for certain
 actions, if this is needed.</P>
+<P>This export will produce a small set of DIDs, in either Alabama (if the
+"DIDs by NPA" option is on) or California (if not).</P>
 END
 );
 
@@ -72,4 +75,79 @@ sub run {
   }
 }
 
+sub can_get_dids { 1 }
+
+sub get_dids_npa_select {
+  my $self = shift;
+  $self->option('get_dids_npa_select') ? 1 : 0;
+}
+
+# we don't yet have tollfree
+
+my $dids_by_npa = {
+  'states' => [ 'AK', 'AL' ],
+  # states
+  'AK' => [],
+  'AL' => [ '205', '998', '999' ],
+  # NPAs
+  '205' => [ 'ALABASTER (205-555-XXXX)', # an NPA-NXX
+             'EMPTY (205-998-XXXX)',
+             'INVALID (205-999-XXXX)',
+             'ALBERTVILLE, AL', # a ratecenter
+           ],
+  '998' => [],
+  '999' => undef,
+  # exchanges
+  '205555' => 
+    [
+      '2055550101',
+      '2055550102'
+    ],
+  '205998' => [],
+  '205999' => undef,
+  # ratecenters
+  'ALBERTVILLE' => [
+    '2055550111',
+    '2055550112',
+  ],
+},
+
+my $dids_by_region = {
+  'states' => [ 'CA', 'CO' ],
+  'CA' => [ 'CALIFORNIA',
+            'EMPTY',
+            'INVALID'
+          ],
+  'CO' => [],
+  # regions
+  'CALIFORNIA' => [
+    '4155550200',
+    '4155550201',
+  ],
+  'EMPTY' => [],
+  'INVALID' => undef,
+};
+
+sub get_dids {
+  my $self = shift;
+  my %opt = @_;
+  my $data = $self->get_dids_npa_select ? $dids_by_npa : $dids_by_region;
+
+  my $key;
+  if ( $opt{'exchange'} ) {
+    $key = $opt{'areacode'} . $opt{'exchange'};
+  } else {
+    $key =    $opt{'ratecenter'}
+          ||  $opt{'areacode'}
+          ||  $opt{'region'}
+          ||  $opt{'state'}
+          ||  'states';
+  }
+  if ( defined $data->{ $key } ) {
+    return $data->{ $key };
+  } else {
+    die "[test] '$key' is invalid\n";
+  }
+}
+
 1;