[freeside-commits] freeside/FS/FS Schema.pm, 1.239.2.29, 1.239.2.30 did_order.pm, 1.1.2.4, 1.1.2.5 did_order_item.pm, 1.1.2.2, 1.1.2.3 rate_center.pm, NONE, 1.1.2.2

Erik Levinson levinse at wavetail.420.am
Thu Apr 14 20:09:53 PDT 2011


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv15204/FS/FS

Modified Files:
      Tag: FREESIDE_2_1_BRANCH
	Schema.pm did_order.pm did_order_item.pm 
Added Files:
      Tag: FREESIDE_2_1_BRANCH
	rate_center.pm 
Log Message:
bulk DID orders/inventory enhancements, RT11291

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.239.2.29
retrieving revision 1.239.2.30
diff -u -w -d -r1.239.2.29 -r1.239.2.30
--- Schema.pm	11 Apr 2011 23:03:32 -0000	1.239.2.29
+++ Schema.pm	15 Apr 2011 03:09:50 -0000	1.239.2.30
@@ -2873,6 +2873,26 @@
       'index'  => [],
     },
     
+    'msa' => {
+      'columns' => [
+        'msanum',    'int',      '',      '', '', '', 
+        'description',   'varchar',    '',      $char_d, '', '', 
+      ],
+      'primary_key' => 'msanum',
+      'unique' => [],
+      'index'  => [],
+    },
+    
+    'rate_center' => {
+      'columns' => [
+        'ratecenternum',    'serial',      '',      '', '', '', 
+        'description',   'varchar',    '',      $char_d, '', '', 
+      ],
+      'primary_key' => 'ratecenternum',
+      'unique' => [],
+      'index'  => [],
+    },
+
     'did_vendor' => {
       'columns' => [
         'vendornum',    'serial',      '',      '', '', '', 
@@ -2887,10 +2907,10 @@
       'columns' => [
         'orderitemnum',    'serial',      '',      '', '', '', 
         'ordernum',    'int',      '',      '', '', '', 
-        'msa',        'varchar', 'NULL', $char_d, '', '',
+        'msanum',      'int',     'NULL',      '', '', '',
         'npa',      'int',     'NULL',      '', '', '',
         'latanum',      'int',     'NULL',      '', '', '',
-        'ratecenter',        'varchar', 'NULL', $char_d, '', '',
+        'ratecenternum',      'int',     'NULL',      '', '', '',
         'state',       'char',    'NULL',       2, '', '', 
         'quantity',      'int',     '',      '', '', '',
       ],

Index: did_order_item.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/did_order_item.pm,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -w -d -r1.1.2.2 -r1.1.2.3
--- did_order_item.pm	6 Apr 2011 08:28:37 -0000	1.1.2.2
+++ did_order_item.pm	15 Apr 2011 03:09:50 -0000	1.1.2.3
@@ -37,33 +37,18 @@
 
 =item ordernum
 
-ordernum
-
-=item msa
-
-msa
+=item msanum - foreign key to msa table
 
 =item npa
 
-npa
-
-=item latanum
-
-latanum
-
-=item rate_center
+=item latanum - foreign key to lata table
 
-rate_center
+=item ratecenternum - foreign key to rate_center table
 
 =item state
 
-state
-
 =item quantity
 
-quantity
-
-
 =back
 
 =head1 METHODS
@@ -126,10 +111,10 @@
   my $error = 
     $self->ut_numbern('orderitemnum')
     || $self->ut_number('ordernum')
-    || $self->ut_textn('msa')
+    || $self->ut_foreign_keyn('msanum', 'msa', 'msanum')
     || $self->ut_numbern('npa')
     || $self->ut_foreign_keyn('latanum', 'lata', 'latanum')
-    || $self->ut_textn('rate_center')
+    || $self->ut_foreign_keyn('ratecenternum', 'rate_center', 'ratecenternum')
     || $self->ut_textn('state')
     || $self->ut_number('quantity')
   ;

Index: did_order.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/did_order.pm,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -w -d -r1.1.2.4 -r1.1.2.5
--- did_order.pm	11 Apr 2011 23:03:32 -0000	1.1.2.4
+++ did_order.pm	15 Apr 2011 03:09:50 -0000	1.1.2.5
@@ -2,7 +2,7 @@
 
 use strict;
 use base qw( FS::o2m_Common FS::Record );
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearch qsearchs dbh );
 
 =head1 NAME
 
@@ -89,7 +89,43 @@
 
 =cut
 
-# the delete method can be inherited from FS::Record
+sub delete {
+  my $self = shift;
+
+  return "Can't delete a DID order which has DIDs received"
+    if qsearch( 'phone_avail', { 'ordernum' => $self->ordernum } );
+
+  local $SIG{HUP} = 'IGNORE';
+  local $SIG{INT} = 'IGNORE';
+  local $SIG{QUIT} = 'IGNORE';
+  local $SIG{TERM} = 'IGNORE';
+  local $SIG{TSTP} = 'IGNORE';
+  local $SIG{PIPE} = 'IGNORE';
+
+  my $oldAutoCommit = $FS::UID::AutoCommit;
+  local $FS::UID::AutoCommit = 0;
+  my $dbh = dbh;
+
+  my @did_order_item = $self->did_order_item;
+
+  foreach my $did_order_item ( @did_order_item ) {
+    my $error = $did_order_item->delete;
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return "can't delete DID order item "
+                                . $did_order_item->orderitemnum . ": $error";
+    }
+  }
+
+  my $error = $self->SUPER::delete(@_);
+  if ( $error ) {
+    $dbh->rollback if $oldAutoCommit;
+    return $error;
+  }
+
+  $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+}
+
 
 =item replace OLD_RECORD
 

--- NEW FILE: rate_center.pm ---
package FS::rate_center;

use strict;
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs );

=head1 NAME

FS::rate_center - Object methods for rate_center records

=head1 SYNOPSIS

  use FS::rate_center;

  $record = new FS::rate_center \%hash;
  $record = new FS::rate_center { 'column' => 'value' };

  $error = $record->insert;

  $error = $new_record->replace($old_record);

  $error = $record->delete;

  $error = $record->check;

=head1 DESCRIPTION

An FS::rate_center object represents an rate center.  FS::rate_center inherits from
FS::Record.  The following fields are currently supported:

=over 4

=item ratecenternum

primary key

=item description

description


=back

=head1 METHODS

=over 4

=item new HASHREF

Creates a new rate center.  To add the rate center 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 { 'rate_center'; }

=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 rate center.  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('ratecenternum')
    || $self->ut_text('description')
  ;
  return $error if $error;

  $self->SUPER::check;
}

=back

=head1 SEE ALSO

L<FS::Record>, schema.html from the base documentation.

=cut

1;




More information about the freeside-commits mailing list