diff options
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS.pm | 2 | ||||
| -rw-r--r-- | FS/FS/Mason.pm | 1 | ||||
| -rw-r--r-- | FS/FS/Schema.pm | 22 | ||||
| -rw-r--r-- | FS/FS/did_order.pm | 43 | ||||
| -rw-r--r-- | FS/FS/did_order_item.pm | 150 | ||||
| -rw-r--r-- | FS/FS/phone_avail.pm | 7 | ||||
| -rw-r--r-- | FS/MANIFEST | 2 | ||||
| -rw-r--r-- | FS/t/did_order_item.t | 5 | 
8 files changed, 197 insertions, 35 deletions
| @@ -172,6 +172,8 @@ L<FS::did_vendor> - Bulk DID order vendor class  L<FS::did_order> - Bulk DID order class +L<FS::did_order_item> - Bulk DID order item class +  L<FS::cdr> - Call Detail Record class  L<FS::cdr_batch> - Call Detail Record batch class diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index dd1871739..db54ecbd4 100644 --- a/FS/FS/Mason.pm +++ b/FS/FS/Mason.pm @@ -278,6 +278,7 @@ if ( -e $addl_handler_use_file ) {    use FS::hardware_class;    use FS::hardware_type;    use FS::hardware_status; +  use FS::did_order_item;    # Sammath Naur    if ( $FS::Mason::addl_handler_use ) { diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 66847b6c0..06406e636 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -3092,6 +3092,8 @@ sub tables_hashref {          'station',     'char',    'NULL',       4, '', '',          'name',        'varchar', 'NULL', $char_d, '', '',          'rate_center_abbrev', 'varchar', 'NULL', $char_d, '', '', +        'latanum',      'int',     'NULL',      '', '', '', +        'msa',        'varchar', 'NULL', $char_d, '', '',          'ordernum',      'int',     'NULL',      '', '', '',          'svcnum',      'int',     'NULL',      '', '', '',          'availbatch', 'varchar',  'NULL', $char_d, '', '', @@ -3127,16 +3129,28 @@ sub tables_hashref {        'index'  => [],      }, -    'did_order' => { +    'did_order_item' => {        'columns' => [ -        'ordernum',    'serial',      '',      '', '', '',  -        'vendornum',   'int',       '',      '', '', '',  -        'vendor_order_id',   'varchar',  '',   $char_d, '', '',  +        'orderitemnum',    'serial',      '',      '', '', '',  +        'ordernum',    'int',      '',      '', '', '',           'msa',        'varchar', 'NULL', $char_d, '', '', +        'npa',      'int',     'NULL',      '', '', '',          'latanum',      'int',     'NULL',      '', '', '',          'rate_center',        'varchar', 'NULL', $char_d, '', '',          'state',       'char',    'NULL',       2, '', '',           'quantity',      'int',     '',      '', '', '', +      ], +      'primary_key' => 'orderitemnum', +      'unique' => [], +      'index'  => [], +    }, + +    'did_order' => { +      'columns' => [ +        'ordernum',    'serial',      '',      '', '', '',  +        'vendornum',   'int',       '',      '', '', '',  +        'vendor_order_id',   'varchar',  'NULL',   $char_d, '', '',  +        'custnum',   'int', 'NULL', '', '', '',          'submitted',      'int',     '',      '', '', '',          'confirmed',      'int',     'NULL',      '', '', '',          'received',      'int',     'NULL',      '', '', '', diff --git a/FS/FS/did_order.pm b/FS/FS/did_order.pm index 6b199a969..f46d72bf8 100644 --- a/FS/FS/did_order.pm +++ b/FS/FS/did_order.pm @@ -1,7 +1,7 @@  package FS::did_order;  use strict; -use base qw( FS::Record ); +use base qw( FS::o2m_Common FS::Record );  use FS::Record qw( qsearch qsearchs );  =head1 NAME @@ -42,26 +42,6 @@ vendornum  vendor_order_id -=item msa - -msa - -=item latanum - -latanum - -=item rate_center - -rate_center - -=item state - -state - -=item quantity - -quantity -  =item submitted  submitted @@ -137,12 +117,7 @@ sub check {    my $error =       $self->ut_numbern('ordernum')      || $self->ut_foreign_key('vendornum', 'did_vendor', 'vendornum' ) -    || $self->ut_text('vendor_order_id') -    || $self->ut_textn('msa') -    || $self->ut_foreign_keyn('latanum', 'lata', 'latanum') -    || $self->ut_textn('rate_center') -    || $self->ut_textn('state') -    || $self->ut_number('quantity') +    || $self->ut_textn('vendor_order_id')      || $self->ut_number('submitted')      || $self->ut_numbern('confirmed')      || $self->ut_numbern('received') @@ -152,9 +127,19 @@ sub check {    $self->SUPER::check;  } -=back +=item did_order_item + +Returns the did_order_items (see L<FS::did_order_item>) associated with this bulk DID order. -=head1 BUGS +=cut + +sub did_order_item { +  my $self = shift; +  qsearch( 'did_order_item', { 'ordernum' => $self->ordernum } ); +} + + +=back  =head1 SEE ALSO diff --git a/FS/FS/did_order_item.pm b/FS/FS/did_order_item.pm new file mode 100644 index 000000000..4408c50f5 --- /dev/null +++ b/FS/FS/did_order_item.pm @@ -0,0 +1,150 @@ +package FS::did_order_item; + +use strict; +use base qw( FS::Record ); +use FS::Record qw( qsearch qsearchs ); + +=head1 NAME + +FS::did_order_item - Object methods for did_order_item records + +=head1 SYNOPSIS + +  use FS::did_order_item; + +  $record = new FS::did_order_item \%hash; +  $record = new FS::did_order_item { 'column' => 'value' }; + +  $error = $record->insert; + +  $error = $new_record->replace($old_record); + +  $error = $record->delete; + +  $error = $record->check; + +=head1 DESCRIPTION + +An FS::did_order_item object represents an item in a bulk DID order. +FS::did_order_item inherits from FS::Record.   +The following fields are currently supported: + +=over 4 + +=item orderitemnum + +primary key + +=item ordernum + +ordernum + +=item msa + +msa + +=item npa + +npa + +=item latanum + +latanum + +=item rate_center + +rate_center + +=item state + +state + +=item quantity + +quantity + + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Creates a new DID order item.  To add it to the database, see L<"insert">. + +Note that this stores the hash reference, not a distinct copy of the hash it +points to.  You can ask the object for a copy with the I<hash> method. + +=cut + +# the new method can be inherited from FS::Record, if a table method is defined + +sub table { 'did_order_item'; } + +=item insert + +Adds this record to the database.  If there is an error, returns the error, +otherwise returns false. + +=cut + +# the insert method can be inherited from FS::Record + +=item delete + +Delete this record from the database. + +=cut + +# the delete method can be inherited from FS::Record + +=item replace OLD_RECORD + +Replaces the OLD_RECORD with this one in the database.  If there is an error, +returns the error, otherwise returns false. + +=cut + +# the replace method can be inherited from FS::Record + +=item check + +Checks all fields to make sure this is a valid DID order item.  If there is +an error, returns the error, otherwise returns false.  Called by the insert +and replace methods. + +=cut + +# the check method should currently be supplied - FS::Record contains some +# data checking routines + +sub check { +  my $self = shift; + +  my $error =  +    $self->ut_numbern('orderitemnum') +    || $self->ut_number('ordernum') +    || $self->ut_textn('msa') +    || $self->ut_numbern('npa') +    || $self->ut_foreign_keyn('latanum', 'lata', 'latanum') +    || $self->ut_textn('rate_center') +    || $self->ut_textn('state') +    || $self->ut_number('quantity') +  ; +  return $error if $error; + +  $self->SUPER::check; +} + +=back + +=head1 SEE ALSO + +L<FS::Record>, schema.html from the base documentation. + +=cut + +1; + diff --git a/FS/FS/phone_avail.pm b/FS/FS/phone_avail.pm index 8bb6a5cc3..3066ac033 100644 --- a/FS/FS/phone_avail.pm +++ b/FS/FS/phone_avail.pm @@ -4,6 +4,7 @@ use strict;  use vars qw( @ISA $DEBUG $me );  use FS::Record qw( qsearch qsearchs dbh );  use FS::cust_svc; +use FS::Misc::DateTime qw( parse_datetime );  @ISA = qw(FS::cust_main_Mixin FS::Record); @@ -190,9 +191,9 @@ sub process_batch_import {    };    my $opt = { 'table'   => 'phone_avail', -              'params'  => [ 'availbatch', 'exportnum', 'countrycode', 'ordernum' ], +              'params'  => [ 'availbatch', 'exportnum', 'countrycode', 'ordernum', 'vendor_order_id', 'confirmed' ],                'formats' => { 'default' => [ 'state', $numsub, 'name' ], -			     'bulk' => [ 'state', $numsub, 'name', 'rate_center_abbrev' ], +			     'bulk' => [ 'state', $numsub, 'name', 'rate_center_abbrev', 'msa', 'latanum' ],  			   },  	      'postinsert_callback' => sub {    		    my $record = shift; @@ -201,6 +202,8 @@ sub process_batch_import {  						{ 'ordernum' => $record->ordernum } );  			if($did_order && !$did_order->received) {  			    $did_order->received(time); +			    $did_order->confirmed(parse_datetime($record->confirmed)); +			    $did_order->vendor_order_id($record->vendor_order_id);  			    $did_order->replace;  			}  		    } diff --git a/FS/MANIFEST b/FS/MANIFEST index a293451a1..c93f1ffc2 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -588,3 +588,5 @@ FS/hardware_type.pm  t/hardware_type.t  FS/hardware_status.pm  t/hardware_status.t +FS/did_order_item.pm +t/did_order_item.t diff --git a/FS/t/did_order_item.t b/FS/t/did_order_item.t new file mode 100644 index 000000000..cc33c1481 --- /dev/null +++ b/FS/t/did_order_item.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::did_order_item; +$loaded=1; +print "ok 1\n"; | 
