[freeside-commits] branch master updated. 6f8edbafb0401dd2224d3698397bcb16ffad1580

Ivan ivan at 420.am
Tue Aug 12 16:41:20 PDT 2014


The branch, master has been updated
       via  6f8edbafb0401dd2224d3698397bcb16ffad1580 (commit)
      from  e03f1de6578f009f306d92ec713b533e799330cd (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 6f8edbafb0401dd2224d3698397bcb16ffad1580
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Aug 12 16:41:11 2014 -0700

    svc_cable unique serialnum and mac_addr, RT#

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 54c84f7..2aba2ea 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -6352,7 +6352,7 @@ sub tables_hashref {
         'mac_addr',  'varchar', 'NULL',      12, '', '', 
       ],
       'primary_key'  => 'svcnum',
-      'unique'       => [],
+      'unique'       => [ ['serialnum'] , ['mac_addr'] ],
       'index'        => [],
       'foreign_keys' => [
                           { columns    => [ 'svcnum' ],
diff --git a/FS/FS/svc_cable.pm b/FS/FS/svc_cable.pm
index 4dd4543..122d8c6 100644
--- a/FS/FS/svc_cable.pm
+++ b/FS/FS/svc_cable.pm
@@ -53,7 +53,7 @@ points to.  You can ask the object for a copy with the I<hash> method.
 
 sub table { 'svc_cable'; }
 
-sub table_dupcheck_fields { ( 'mac_addr' ); }
+sub table_dupcheck_fields { ( 'serialnum', 'mac_addr' ); }
 
 sub search_sql {
   my( $class, $string ) = @_;
@@ -168,6 +168,27 @@ sub check {
   $self->SUPER::check;
 }
 
+sub _check_duplicate {
+  my $self = shift;
+
+  # Not reliable checks because the table isn't locked, but that's why we have
+  # unique indices.  These are just to give friendlier error messages.
+
+  my @dup_mac;
+  @dup_mac = $self->find_duplicates('global', 'mac_addr');
+  if ( @dup_mac ) {
+    return "MAC address in use (svcnum ".$dup_mac[0]->svcnum.")";
+  }
+
+  my @dup_serial;
+  @dup_serial = $self->find_duplicates('global', 'serialnum');
+  if ( @dup_serial ) {
+    return "Serial number in use (svcnum ".$dup_serial[0]->svcnum.")";
+  }
+
+  '';
+}
+
 =item cable_provider
 
 Returns the cable_provider object for this record.

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Schema.pm    |    2 +-
 FS/FS/svc_cable.pm |   23 ++++++++++++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list