use FS::part_pkg_report_option;
use Text::CSV;
-adminsuidsetup($user) or die "invalid user '$user'";
-$FS::UID::AutoCommit = 1;
-$FS::Record::nowarn_classload = 1;
+if (!$user) {
+ print "
+Usage: bin/convert-477-options <username>
-print "This script will convert your per-package FCC 477 report options
+This script will convert your per-package FCC 477 report options
from the classic style (part IA, IB, IIA...) to the 2014 style.
This is an approximate conversion, and you should review the
resulting package settings for accuracy. In particular:
- Broadband technologies for ADSL and cable modem will be set
to 'other ADSL' and 'other cable modem'. You should set
them to the specific ADSL or cable encapsulation in use.
- - The 'consumer grade' vs. 'business grade' classification
- was introduced in 2014 and will not be set.
-
-Configuring packages...
+ - All packages will be set to 'business grade'. The 'consumer grade'
+ category did not exist in previous versions of the report.
";
+ exit(1);
+}
+
+adminsuidsetup($user) or die "invalid user '$user'";
+$FS::UID::AutoCommit = 1;
+$FS::Record::nowarn_classload = 1;
+
+print "Configuring packages...\n";
my @min_download_speed = ( 0.2, 0.768, 1.5, 3, 6, 10, 25, 100 );
my @min_upload_speed = ( 0.1, @min_download_speed );
'media:Other'
);
-my %num_to_formkey = map { $_->formvalue => $_->formkey }
- qsearch('fcc477map', {});
+my %num_to_formkey; # o2m
+foreach ( qsearch('fcc477map', {}) ) {
+ push @{ $num_to_formkey{$_->formvalue} ||= [] }, $_->formkey;
+}
sub report_option_to_fcc_option {
my $report_option_num = shift;
- my $formkey = $num_to_formkey{$report_option_num}
+ my $formkeys = $num_to_formkey{$report_option_num}
or return;
- if ($formkey =~ /^part1_column_option_(\d+)/) {
- #download speed
- return (broadband_downstream => $min_download_speed[$1]);
- } elsif ($formkey =~ /^part1_row_option_(\d+)/) {
- #upload speed
- return (broadband_upstream => $min_upload_speed[$1]);
- } elsif ($formkey =~ /^part1_technology_option_(\d+)/) {
- #broadband tech
- return (is_broadband => 1,
- media => $media_type[$1],
- technology => $technology[$1]);
- } elsif ($formkey =~ /^part2a_row_option_(\d+)/) {
- #local phone options
- return (split(':', $phone_option[$1]));
- } elsif ($formkey =~ /^part2b_row_option_(\d+)/) {
- #VoIP options (are all media types)
- return (split(':', $voip_option[$1]));
- } else {
- warn "can't parse option with formkey '$formkey'\n";
- return;
+ my @return;
+ foreach my $formkey (@$formkeys) {
+ if ($formkey =~ /^part1_column_option_(\d+)/) {
+ #download speed
+ push @return, (broadband_downstream => $min_download_speed[$1]);
+ } elsif ($formkey =~ /^part1_row_option_(\d+)/) {
+ #upload speed
+ push @return, (broadband_upstream => $min_upload_speed[$1]);
+ } elsif ($formkey =~ /^part1_technology_option_(\d+)/) {
+ #broadband tech
+ push @return,
+ (is_broadband => 1,
+ media => $media_type[$1],
+ technology => $technology[$1]);
+ } elsif ($formkey =~ /^part2a_row_option_(\d+)/) {
+ #local phone options
+ push @return,
+ (media => 'Copper', # sensible default
+ split(':', $phone_option[$1])
+ );
+ } elsif ($formkey =~ /^part2b_row_option_(\d+)/) {
+ #VoIP options (are all media types)
+ push @return, (split(':', $voip_option[$1]));
+ } else {
+ warn "can't parse option with formkey '$formkey'\n";
+ }
}
+ @return;
}
for my $part_pkg (qsearch('part_pkg', { freq => {op => '!=', value => '0'}})) {
my $pkgpart = $part_pkg->pkgpart;
- print "#$pkgpart\n";
+ #print "#$pkgpart\n";
my %report_opts = $part_pkg->options;
my @fcc_opts;
foreach my $optionname (keys(%report_opts)) {
if ($part_pkg->fcc_voip_class) {
# there's no such thing as a VoIP DS0 equivalent, but this is
# what we used the field for
- push @fcc_opts, 'voip_lines' => $part_pkg->fcc_ds0s;
+ push @fcc_opts, 'voip_sessions' => $part_pkg->fcc_ds0s;
} else {
push @fcc_opts, 'phone_lines' => $part_pkg->fcc_ds0s, 'is_phone' => 1;
}
}
my %fcc_opts = @fcc_opts;
- print map {"\t$_\t".$fcc_opts{$_}."\n"} keys %fcc_opts;
- my $error = $part_pkg->process_fcc_options(\%fcc_opts);
+ #print map {"\t$_\t".$fcc_opts{$_}."\n"} keys %fcc_opts;
+ my $error = $part_pkg->set_fcc_options(\%fcc_opts);
if ( $error ) {
die "$error\n";
}
- print "\n";
+ #print "\n";
}
print "Finished.\n";