[freeside-commits] branch FREESIDE_4_BRANCH updated. 4bc5c3eb442a0ed2a1c2a364d08f4ce8b689902c
Ivan Kohler
ivan at freeside.biz
Mon Aug 5 16:14:46 PDT 2019
The branch, FREESIDE_4_BRANCH has been updated
via 4bc5c3eb442a0ed2a1c2a364d08f4ce8b689902c (commit)
from e56c9ccf3402379423bb800fc8db9b1f718813f0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4bc5c3eb442a0ed2a1c2a364d08f4ce8b689902c
Author: Ivan Kohler <ivan at freeside.biz>
Date: Mon Aug 5 16:14:38 2019 -0700
planet telecom rate import, RT#83146
diff --git a/bin/rate-ptelecom.import b/bin/rate-ptelecom.import
index 83e0fa7db..20724c4a1 100755
--- a/bin/rate-ptelecom.import
+++ b/bin/rate-ptelecom.import
@@ -7,6 +7,7 @@ use FS::Record qw( dbh );
use FS::rate;
use FS::rate_region;
use FS::rate_detail;
+use FS::rate_prefix;
our %opt;
getopts('d');
@@ -76,7 +77,8 @@ while( my $row = $csv->getline($rin) ) {
}
my $rate_region = new FS::rate_region {
- 'regionname' => "$destkey: $destid",
+ 'regionname' => $destid,
+ 'agent_regionid' => $destkey,
};
my $error = $rate_region->insert;
die $error if $error;
@@ -101,10 +103,56 @@ while( my $row = $csv->getline($rin) ) {
}
###
-# ??? import rate_prefix ("destinations?")
+# import rate_prefix ("country")
###
-#???
+my $pfile = shift or usage();
+open my $pin, '<', $pfile or die "$pfile: $!\n";
+
+my $rx = 0;
+while( my $row = $csv->getline($pin) ) {
+ my $destkey = $row->[1];
+ my $prefix = $row->[4];
+ my $countrycode = $row->[20];
+ #my $npa = $row->[21];
+ #my $npa2 = $row->[22];
+ my $pattern = $row->[24];
+
+ #$npa = '' if $npa eq 'NULL';
+ #$npa2 = '' if $npa2 eq 'NULL';
+
+ die "destkey $destkey: $prefix ne $pattern\n"
+ if $prefix ne $pattern;
+
+ if ( $countrycode eq 'NULL' ) {
+ warn "destkey $destkey: countrycode is null for prefix $prefix; skipping\n";
+ next;
+ }
+
+ my $rate_region = $rate_region{$destkey}
+ or do {
+ warn "destkey $destkey: not found for prefix $prefix; skipping\n";
+ next;
+ };
+
+ $prefix =~ s/^\Q$countrycode\E//;
+ $prefix =~ s/ //g;
+ $prefix =~ s/\.$//;
+
+ my $rate_prefix = new FS::rate_prefix {
+ 'regionnum' => $rate_region->regionnum,
+ 'countrycode' => $countrycode,
+ 'npa' => $prefix,
+ };
+ my $error = $rate_prefix->insert;
+ die "error inserting rate_prefix: $error for cc $countrycode prefix $prefix"
+ if $error;
+
+ $rx++;
+
+ #print '.' if $rx % 1000 == 0;
+}
+print "\n";
if ( $opt{d} ) {
dbh->rollback;
@@ -113,11 +161,11 @@ if ( $opt{d} ) {
dbh->commit;
}
-print "Inserted $rd rates for $rr regions in $rp rate plans\n";
+print "Inserted $rd rates for $rr regions with $rx prefixes in $rp rate plans\n";
1;
sub usage {
- die "Usage: rate-ptelecom.import [ -d ] <user> profiles.csv rates.csv\n"
+ die "Usage: rate-ptelecom.import [ -d ] <user> profiledestinationrates.csv callratingprofiles.csv country.csv\n"
}
-----------------------------------------------------------------------
Summary of changes:
bin/rate-ptelecom.import | 58 +++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 53 insertions(+), 5 deletions(-)
More information about the freeside-commits
mailing list