summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevinse <levinse>2010-11-28 20:08:51 +0000
committerlevinse <levinse>2010-11-28 20:08:51 +0000
commit53b930cc67361258ea40f793ca1eb0b3d976bd9c (patch)
tree39c61f5cbcc95ecff987b180c3b263665b8409a7
parent143c8af5f8fdd5d573e87a3255a4d003e4453d45 (diff)
ikano, svc_dsl, qual, on-going implementation, RT7111
-rw-r--r--FS/FS/Schema.pm23
-rw-r--r--FS/FS/part_export/ikano.pm77
-rw-r--r--FS/FS/qual.pm34
-rw-r--r--FS/FS/svc_dsl.pm92
-rw-r--r--httemplate/edit/svc_dsl.cgi12
-rw-r--r--httemplate/view/svc_dsl.cgi6
6 files changed, 120 insertions, 124 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 39b1ab7..e95e1f7 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1681,15 +1681,18 @@ sub tables_hashref {
'qual' => {
'columns' => [
'qualnum', 'serial', '', '', '', '',
- 'contactnum', 'int', '', '', '', '',
- 'svctn', 'varchar', 'NULL', 24, '', '',
- 'svcdb', 'varchar', '', $char_d, '', '',
+ 'custnum', 'int', 'NULL', '', '', '',
+ 'prospectnum', 'int', 'NULL', '', '', '',
+ 'locationnum', 'int', 'NULL', '', '', '',
+ 'phonenum', 'varchar', 'NULL', 24, '', '',
+ 'exportnum', 'int', '', '', '', '',
'vendor_qual_id', 'varchar', 'NULL', $char_d, '', '',
'status', 'char', '', 1, '', '',
],
'primary_key' => 'qualnum',
'unique' => [],
- 'index' => [ [ 'contactnum' ] ],
+ 'index' => [ [ 'locationnum' ], ['custnum'], ['prospectnum'],
+ ['phonenum'], ['vendor_qual_id'] ],
},
'qual_option' => {
@@ -1837,8 +1840,8 @@ sub tables_hashref {
'columns' => [
'svcnum', 'int', '', '', '', '',
'pushed', 'int', 'NULL', '', '', '',
- 'desired_dd', 'int', 'NULL', '', '', '',
- 'dd', 'int', 'NULL', '', '', '',
+ 'desired_due_date', 'int', 'NULL', '', '', '',
+ 'due_date', 'int', 'NULL', '', '', '',
'vendor_order_id', 'varchar', 'NULL', $char_d, '', '',
'vendor_qual_id', 'varchar', 'NULL', $char_d, '', '',
'vendor_order_type', 'char', 'NULL', 1, '', '',
@@ -1846,10 +1849,10 @@ sub tables_hashref {
'first', 'varchar', 'NULL', $char_d, '', '',
'last', 'varchar', 'NULL', $char_d, '', '',
'company', 'varchar', 'NULL', $char_d, '', '',
- 'svctn', 'varchar', 'NULL', 24, '', '',
+ 'phonenum', 'varchar', 'NULL', 24, '', '',
'loop_type', 'char', 'NULL', 1, '', '',
- 'lvp', 'varchar', 'NULL', $char_d, '', '',
- 'cktnum', 'varchar', 'NULL', $char_d, '', '',
+ 'local_voice_provider', 'varchar', 'NULL', $char_d, '', '',
+ 'circuitnum', 'varchar', 'NULL', $char_d, '', '',
'rate_band', 'varchar', 'NULL', $char_d, '', '',
'isp_chg', 'char', 'NULL', 1, '', '',
'isp_prev', 'varchar', 'NULL', $char_d, '', '',
@@ -1862,7 +1865,7 @@ sub tables_hashref {
],
'primary_key' => 'svcnum',
'unique' => [ ],
- 'index' => [ ['svctn'] ],
+ 'index' => [ ['phonenum'], ['vendor_order_id'] ],
},
diff --git a/FS/FS/part_export/ikano.pm b/FS/FS/part_export/ikano.pm
index 230764e..50fa292 100644
--- a/FS/FS/part_export/ikano.pm
+++ b/FS/FS/part_export/ikano.pm
@@ -33,12 +33,12 @@ Requires installation of
END
);
-%orderType = ( 'N' => 'New', 'X' => 'Cancel', 'C' => 'Change' );
-%orderStatus = ('N' => 'New',
- 'P' => 'Pending',
- 'X' => 'Cancelled',
- 'C' => 'Completed',
- 'E' => 'Error' );
+%orderType = ( 'N' => 'NEW', 'X' => 'CANCEL', 'C' => 'CHANGE' );
+%orderStatus = ('N' => 'NEW',
+ 'P' => 'PENDING',
+ 'X' => 'CANCELLED',
+ 'C' => 'COMPLETED',
+ 'E' => 'ERROR' );
%loopType = ( '' => 'Line-share', '0' => 'Standalone' );
sub rebless { shift; }
@@ -87,10 +87,10 @@ sub ikano_command {
sub valid_order {
my( $self, $svc_dsl, $action ) = (shift, shift, shift);
- warn "$me valid_order action=$action svc_dsl: ". Dumper($svc_dsl) if $DEBUG;
+ warn "$me valid_order action=$action svc_dsl:\n". Dumper($svc_dsl) if $DEBUG;
# common to all order types/status/loop_type
- my $error = !($svc_dsl->desired_dd
+ my $error = !($svc_dsl->desired_due_date
&& defined $orderType{$svc_dsl->vendor_order_type}
&& $svc_dsl->first
&& $svc_dsl->last
@@ -114,8 +114,8 @@ sub valid_order {
$error = !($action eq 'insert'
&& length($svc_dsl->vendor_order_id) < 1
&& length($svc_dsl->vendor_order_status) < 1
- && ( ($svc_dsl->svctn eq '' && $svc_dsl->loop_type eq '0') # dry
- || ($svc_dsl->svctn ne '' && $svc_dsl->loop_type eq '') # line-share
+ && ( ($svc_dsl->phonenum eq '' && $svc_dsl->loop_type eq '0') # dry
+ || ($svc_dsl->phonenum ne '' && $svc_dsl->loop_type eq '') # line-share
)
);
return 'Invalid order data' if $error;
@@ -130,19 +130,29 @@ sub valid_order {
}
sub qual2termsid {
- my ($self,$vendor_qual_id) = (shift,shift);
+ my ($self,$vendor_qual_id,$ProductCustomId) = (shift,shift,shift);
my $qual = qsearchs( 'qual', { 'vendor_qual_id' => $vendor_qual_id });
return '' unless $qual;
my %qual_options = $qual->options;
- foreach my $optionname ( keys %qual_options ) {
- if ( $optionname =~ /^ikano_network_(\d+)_productgroup_(\d+)_termsid$/ ) {
- return $qual_options{$optionname};
+ while (($optionname, $optionvalue) = each %qual_options) {
+ if ( $optionname =~ /^ikano_Network_(\d+)_ProductGroup_(\d+)_Product_(\d+)_ProductCustomId$/
+ && $optionvalue eq $ProductCustomId ) {
+ my $network = $1;
+ my $productgroup = $2;
+ return $qual->option("ikano_Network_".$network."_ProductGroup_".$productgroup."_TermsId");
}
- # XXX finish this properly - the above is wrong
}
'';
}
+sub orderstatus_long2short {
+ my ($self,$order_status) = (shift,shift);
+ while (($k, $v) = each %orderStatus) {
+ return $k if $v eq $order_status;
+ }
+ return '';
+}
+
sub _export_insert {
my( $self, $svc_dsl ) = (shift, shift);
@@ -153,13 +163,14 @@ sub _export_insert {
my $contactTN = $svc_dsl->cust_svc->cust_pkg->cust_main->daytime;
$contactTN =~ s/[^0-9]//g;
+ my $ProductCustomId = $svc_dsl->cust_svc->cust_pkg->part_pkg->option('externalid',1);
+
my $args = {
orderType => 'NEW',
- ProductCustomId =>
- $svc_dsl->cust_svc->cust_pkg->part_pkg->option('externalid',1),
- TermsId => $self->qual2termsid($svc_dsl->vendor_qual_id),
+ ProductCustomId => $ProductCustomId,
+ TermsId => $self->qual2termsid($svc_dsl->vendor_qual_id,$ProductCustomId),
DSLPhoneNumber => $svc_dsl->loop_type eq '0' ? 'STANDALONE'
- : $svc_dsl->svctn,
+ : $svc_dsl->phonenum,
Password => $svc_dsl->password,
PrequalId => $svc_dsl->vendor_qual_id,
CompanyName => $svc_dsl->company,
@@ -170,7 +181,7 @@ sub _export_insert {
ContactPhoneNumber => $contactTN,
ContactEmail => 'x@x.xx',
ContactFax => '',
- DateToOrder => time2str("%Y-%m-%d",$svc_dsl->desired_dd),
+ DateToOrder => time2str("%Y-%m-%d",$svc_dsl->desired_due_date),
RequestClientIP => '127.0.0.1',
IspChange => $isp_chg,
IspPrevious => $isp_chg eq 'YES' ? $svc_dsl->isp_prev : '',
@@ -181,11 +192,7 @@ sub _export_insert {
return $result unless ref($result); # scalar (string) is an error
# now we're getting an OrderResponse which should have one Order in it
- warn Dumper($result) if $DEBUG;
- my ($pushed,$vendor_order_id,$vendor_order_status,$last_pull);
- $pushed = time;
- $last_pull = time;
- $last_pull++;
+ warn "$me _export_insert OrderResponse hash:\n".Dumper($result) if $DEBUG;
return 'Invalid order response' unless defined $result->{'Order'};
$result = $result->{'Order'};
@@ -193,16 +200,16 @@ sub _export_insert {
return 'No order id or status returned'
unless defined $result->{'Status'} && defined $result->{'OrderId'};
- $vendor_order_id = $result->{'OrderId'};
- $vendor_order_status = $result->{'Status'};
-
-# XXX we need to set all of these values (everything in the last my statement
-# above) in the svc without:
-# a. re-triggering exports
-# b. committing the svc into the db now (because other things in the caller
-# and further up the stack may decide that the svc shouldn't be inserted)
-
- return '';
+ $svc_dsl->pushed(time);
+ $svc_dsl->last_pull((time)+1);
+ $svc_dsl->vendor_order_id($result->{'OrderId'});
+ $svc_dsl->vendor_order_status($self->orderstatus_long2short($result->{'Status'}));
+ $svc_dsl->username($result->{'Username'});
+ local $FS::svc_Common::noexport_hack = 1;
+ local $FS::UID::AutoCommit = 0;
+ $result = $svc_dsl->replace;
+ return 'Error setting DSL fields' if $result;
+ '';
}
sub _export_replace {
diff --git a/FS/FS/qual.pm b/FS/FS/qual.pm
index 55d2ae3..de06334 100644
--- a/FS/FS/qual.pm
+++ b/FS/FS/qual.pm
@@ -32,12 +32,20 @@ FS::Record. The following fields are currently supported:
=item qualnum - primary key
-=item contactnum - Contact (Prospect/Customer) - see L<FS::contact>
+=item prospectnum
-=item svctn - Service Telephone Number
+=item custnum
-=item svcdb - table used for this service. See L<FS::svc_dsl> and
-L<FS::svc_broadband>, among others.
+=item locationnum
+
+Either one of these cases must be true:
+-locationnum is non-null and prospectnum is null and custnum is null
+-locationnum is null and (prospectnum is non-null or custnum is non-null, but not both non-null)
+
+=item phonenum - Service Telephone Number
+
+=item exportnum - export instance providing service-qualification capabilities,
+see L<FS::part_export>
=item vendor_qual_id - qualification id from vendor/telco
@@ -105,14 +113,26 @@ sub check {
my $error =
$self->ut_numbern('qualnum')
- || $self->ut_number('contactnum')
- || $self->ut_numbern('svctn')
- || $self->ut_alpha('svcdb')
+ || $self->ut_foreign_keyn('custnum', 'cust_main', 'qualnum')
+ || $self->ut_foreign_keyn('prospectnum', 'prospect_main', 'prospectnum')
+ || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum')
+ || $self->ut_numbern('phonenum')
+ || $self->ut_foreign_key('exportnum', 'part_export', 'exportnum')
|| $self->ut_textn('vendor_qual_id')
|| $self->ut_alpha('status')
;
return $error if $error;
+#Either one of these cases must be true:
+#1. locationnum is non-null and prospectnum is null and custnum is null
+#2. locationnum is null and (prospectnum is non-null or custnum is non-null, but not both non-null)
+ return "Invalid prospect/customer/location combination" unless (
+ ( $self->locationnum && !$self->prospectcnum && !$self->custnum ) #1
+ ||
+ ( !$self->locationnum && ( $self->prospectnum || $self->custnum )
+ && !( $self->custnum && $self->prospectnum ) ) #2
+ );
+
$self->SUPER::check;
}
diff --git a/FS/FS/svc_dsl.pm b/FS/FS/svc_dsl.pm
index 2fd9570..da62dc6 100644
--- a/FS/FS/svc_dsl.pm
+++ b/FS/FS/svc_dsl.pm
@@ -46,25 +46,15 @@ FS::svc_Common. The following fields are currently supported:
=over 4
-=item svcnum
+=item svcnum - Primary key (assigned automatcially for new DSL))
-Primary key (assigned automatcially for new DSL))
+=item pushed - Time DSL order pushed to vendor/telco, if applicable
-=item pushed
+=item desired_due_date - Desired Due Date
-Time the DSL order was pushed to a vendor, if exporting orders to a vendor/telco
+=item due_date - Due Date
-=item desired_dd
-
-Desired Due Date
-
-=item dd
-
-Due Date (e.g. once order is in Assigned status or similar by the telco)
-
-=item vendor_order_id
-
-Vendor/telco DSL order #
+=item vendor_order_id - Vendor/telco DSL order #
=item vendor_order_type
@@ -75,37 +65,21 @@ Vendor/telco DSL order type (e.g. (M)ove, (A)dd, (C)hange, (D)elete, or similar)
Vendor/telco DSL order status (e.g. (N)ew, (A)ssigned, (R)ejected, (M)revised,
(C)ompleted, (X)cancelled, or similar)
-=item first
-
-End-user first name
-
-=item last
-
-End-user last name
-
-=item company
+=item first - End-user first name
-End-user company name
+=item last - End-user last name
-=item svctn
+=item company - End-user company name
-DSL Telephone Number
+=item phonenum - DSL Telephone Number
-=item loop_type
+=item loop_type - Loop-type - vendor/telco-specific
-Loop-type - vendor/telco-specific
+=item local_voice_provider - Local Voice Provider's name
-=item lvp
+=item circuitnum - Circuit #
-Local Voice Provider's name
-
-=item cktnum
-
-Circuit #
-
-=item rate_band
-
-Rate Band
+=item rate_band - Rate Band
=item isp_chg
@@ -117,21 +91,13 @@ Rate Band
Ikano-specific fields, do not use otherwise
-=item username
-
-If outsourced PPPoE/RADIUS, username
-
-=item password
-
-If outsourced PPPoE/RADIUS, password
-
-=item monitored
+=item username - if outsourced PPPoE/RADIUS, username
-Order is monitored (auto-pull/sync), either Y or blank
+=item password - if outsourced PPPoE/RADIUS, password
-=item last_pull
+=item monitored - Order is monitored (auto-pull/sync), either Y or blank
-Time of last data pull from vendor/telco
+=item last_pull - time of last data pull from vendor/telco
=item notes
@@ -161,14 +127,14 @@ sub table_info {
{
'name' => 'DSL',
- 'sorts' => [ 'svctn' ],
+ 'sorts' => [ 'phonenum' ],
'display_weight' => 55,
'cancel_weight' => 75,
'fields' => {
'pushed' => { label => 'Pushed',
type => 'disabled' },
- 'desired_dd' => { label => 'Desired Due Date', %dis2, },
- 'dd' => { label => 'Due Date', %dis2, },
+ 'desired_due_date' => { label => 'Desired Due Date', %dis2, },
+ 'due_date' => { label => 'Due Date', %dis2, },
'vendor_order_id' => { label => 'Vendor Order Id', %dis2, },
'vendor_qual_id' => { label => 'Vendor Qualification Id',
type => 'disabled' },
@@ -181,14 +147,14 @@ sub table_info {
'first' => { label => 'First Name', %dis2, },
'last' => { label => 'Last Name', %dis2, },
'company' => { label => 'Company Name', %dis2, },
- 'svctn' => { label => 'Service Telephone Number', },
+ 'phonenum' => { label => 'Service Telephone Number', },
'loop_type' => { label => 'Loop Type',
disable_inventory => 1,
},
- 'lvp' => { label => 'Local Voice Provider',
+ 'local_voice_provider' => { label => 'Local Voice Provider',
disable_inventory => 1,
},
- 'cktnum' => { label => 'Circuit #', },
+ 'circuitnum' => { label => 'Circuit #', },
'rate_band' => { label => 'Rate Band',
disable_inventory => 1,
},
@@ -214,7 +180,7 @@ sub table { 'svc_dsl'; }
sub label {
my $self = shift;
- return $self->svctn if $self->svctn;
+ return $self->phonenum if $self->phonenum;
return $self->username if $self->username;
return $self->vendor_order_id if $self->vendor_order_id;
return $self->svcnum;
@@ -263,8 +229,8 @@ sub check {
my $error =
$self->ut_numbern('svcnum')
|| $self->ut_numbern('pushed')
- || $self->ut_number('desired_dd')
- || $self->ut_numbern('dd')
+ || $self->ut_number('desired_due_date')
+ || $self->ut_numbern('due_date')
|| $self->ut_textn('vendor_order_id')
|| $self->ut_textn('vendor_qual_id')
|| $self->ut_alpha('vendor_order_type')
@@ -272,10 +238,10 @@ sub check {
|| $self->ut_text('first')
|| $self->ut_text('last')
|| $self->ut_textn('company')
- || $self->ut_numbern('svctn')
+ || $self->ut_numbern('phonenum')
|| $self->ut_alphasn('loop_type')
- || $self->ut_textn('lvp')
- || $self->ut_textn('cktnum')
+ || $self->ut_textn('local_voice_provider')
+ || $self->ut_textn('circuitnum')
|| $self->ut_textn('rate_band')
|| $self->ut_alphan('isp_chg')
|| $self->ut_textn('isp_prev')
diff --git a/httemplate/edit/svc_dsl.cgi b/httemplate/edit/svc_dsl.cgi
index f086033..4fca0cd 100644
--- a/httemplate/edit/svc_dsl.cgi
+++ b/httemplate/edit/svc_dsl.cgi
@@ -23,12 +23,12 @@ my $html_foot = sub {
<SCRIPT TYPE=\"text/javascript\">
function ikano_loop_type_changed() {
var loop_type = document.getElementById('loop_type').value;
- var svctn = document.getElementById('svctn');
+ var phonenum = document.getElementById('phonenum');
if(loop_type == '0') {
- svctn.value = '';
- svctn.disabled = true;
+ phonenum.value = '';
+ phonenum.disabled = true;
}
- else svctn.disabled = false;
+ else phonenum.disabled = false;
}
</SCRIPT>";
};
@@ -85,7 +85,7 @@ my $new_cb = sub {
value => $cust_main->ship_company ? $cust_main->ship_company
: $cust_main->company,
},
- { field => 'svctn',
+ { field => 'phonenum',
value => $defsvctn,
},
);
@@ -114,7 +114,7 @@ my $new_cb = sub {
{ field => 'vendor_order_type',
type => 'hidden',
value => 'N' },
- { field => 'desired_dd',
+ { field => 'desired_due_date',
type => 'fixed',
formatted_value =>
time2str($date_format,$cust_pkg->start_date),
diff --git a/httemplate/view/svc_dsl.cgi b/httemplate/view/svc_dsl.cgi
index fd998ae..f34e317 100644
--- a/httemplate/view/svc_dsl.cgi
+++ b/httemplate/view/svc_dsl.cgi
@@ -38,12 +38,12 @@ my $svc_cb = sub {
my $export = @exports[0];
$opt->{'disable_unprovision'} = 1;
- @fields = ( 'svctn',
+ @fields = ( 'phonenum',
{ field => 'loop_type',
value => 'FS::part_export::'.$export->exporttype.'::loop_type_long'
},
- { field => 'desired_dd', type => 'date', },
- { field => 'dd', type => 'date', },
+ { field => 'desired_due_date', type => 'date', },
+ { field => 'due_date', type => 'date', },
{ field => 'pushed', type => 'datetime', },
{ field => 'monitored', type => 'checkbox', },
{ field => 'last_pull', type => 'datetime', },