fix RADIUS attribute capitalization
[freeside.git] / bin / fs-setup
index faa0e07..dc597cc 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: fs-setup,v 1.44 2001-08-29 08:45:04 ivan Exp $
+# $Id: fs-setup,v 1.55 2001-09-07 20:17:50 ivan Exp $
 
 #to delay loading dbdef until we're ready
 BEGIN { $FS::Record::setup_hack = 1; }
@@ -15,9 +15,13 @@ use DBIx::DBSchema::ColGroup::Index;
 use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets);
 use FS::Record;
 use FS::cust_main_county;
+use FS::raddb;
 
 die "Not running uid freeside!" unless checkeuid();
 
+my %attrib2db =
+  map { $FS::raddb::attrib{lc($_)} => $_ } keys %FS::raddb::attrib;
+
 my $user = shift or die &usage;
 getsecrets($user);
 
@@ -35,13 +39,15 @@ reply attribute Framed-IP-Address for each user.  You can specify additional
 check and reply attributes.  First enter any additional RADIUS check attributes
 you need to track for each user, separated by whitespace.
 END
-my @check_attributes = map { s/\-/_/g; $_; } split(" ",&getvalue);
+my @check_attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; }
+                         split(" ",&getvalue);
 
 print "\n\n", <<END, ":";
 Now enter any additional reply attributes you need to track for each user,
 separated by whitespace.
 END
-my @attributes = map { s/\-/_/g; $_; } split(" ",&getvalue);
+my @attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; }
+                   split(" ",&getvalue);
 
 print "\n\n", <<END, ":";
 Do you wish to enable the tracking of a second, separate shipping/service
@@ -122,32 +128,32 @@ foreach $attribute (@check_attributes) {
   ));
 }
 
-#make part_svc table (but now as object)
-
-my($part_svc)=$dbdef->table('part_svc');
-
-#because of svc_acct_pop
-#foreach (grep /^svc_/, $dbdef->tables) { 
-#foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) {
-foreach (qw(svc_acct svc_domain svc_forward svc_www)) {
-  my($table)=$dbdef->table($_);
-  my($col);
-  foreach $col ( $table->columns ) {
-    next if $col =~ /^svcnum$/;
-    $part_svc->addcolumn( new DBIx::DBSchema::Column (
-      $table->name. '__' . $table->column($col)->name,
-      'varchar', #$table->column($col)->type, 
-      'NULL',
-      $char_d, #$table->column($col)->length,
-    ));
-    $part_svc->addcolumn ( new DBIx::DBSchema::Column (
-      $table->name. '__'. $table->column($col)->name . "_flag",
-      'char',
-      'NULL',
-      1,
-    ));
-  }
-}
+##make part_svc table (but now as object)
+#
+#my($part_svc)=$dbdef->table('part_svc');
+#
+##because of svc_acct_pop
+##foreach (grep /^svc_/, $dbdef->tables) { 
+##foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) {
+#foreach (qw(svc_acct svc_domain svc_forward svc_www)) {
+#  my($table)=$dbdef->table($_);
+#  my($col);
+#  foreach $col ( $table->columns ) {
+#    next if $col =~ /^svcnum$/;
+#    $part_svc->addcolumn( new DBIx::DBSchema::Column (
+#      $table->name. '__' . $table->column($col)->name,
+#      'varchar', #$table->column($col)->type, 
+#      'NULL',
+#      $char_d, #$table->column($col)->length,
+#    ));
+#    $part_svc->addcolumn ( new DBIx::DBSchema::Column (
+#      $table->name. '__'. $table->column($col)->name . "_flag",
+#      'char',
+#      'NULL',
+#      1,
+#    ));
+#  }
+#}
 
 #important
 $dbdef->save($dbdef_file);
@@ -317,6 +323,19 @@ sub tables_hash_hack {
       'index' => [ ['custnum'] ],
     },
 
+    'cust_credit_bill' => {
+      'columns' => [
+        'creditbillnum', 'int', '', '',
+        'crednum',  'int', '', '',
+        'invnum',  'int', '', '',
+        '_date',    @date_type,
+        'amount',   @money_type,
+      ],
+      'primary_key' => 'creditbillnum',
+      'unique' => [ [] ],
+      'index' => [ ['crednum'], ['invnum'] ],
+    },
+
     'cust_main' => {
       'columns' => [
         'custnum',  'int',  '',     '',
@@ -398,7 +417,8 @@ sub tables_hash_hack {
     'cust_pay' => {
       'columns' => [
         'paynum',   'int',    '',   '',
-        'invnum',   'int',    '',   '',
+        #now cust_bill_pay #'invnum',   'int',    '',   '',
+        'custnum',  'int',    '',   '',
         'paid',     @money_type,
         '_date',    @date_type,
         'payby',    'char',   '',     4, # CARD/BILL/COMP, should be index into
@@ -408,7 +428,20 @@ sub tables_hash_hack {
       ],
       'primary_key' => 'paynum',
       'unique' => [ [] ],
-      'index' => [ ['invnum'] ],
+      'index' => [ [] ],
+    },
+
+    'cust_bill_pay' => {
+      'columns' => [
+        'billpaynum', 'int',     '',   '',
+        'invnum',  'int',     '',   '',
+        'paynum',  'int',     '',   '',
+        'amount',  @money_type,
+        '_date',   @date_type
+      ],
+      'primary_key' => 'billpaynum',
+      'unique' => [ [] ],
+      'index' => [ [ 'paynum', 'invnum' ] ],
     },
 
     'cust_pay_batch' => { #what's this used for again?  list of customers
@@ -456,7 +489,8 @@ sub tables_hash_hack {
     'cust_refund' => {
       'columns' => [
         'refundnum',    'int',    '',   '',
-        'crednum',      'int',    '',   '',
+        #now cust_credit_refund #'crednum',      'int',    '',   '',
+        'custnum',  'int',    '',   '',
         '_date',        @date_type,
         'refund',       @money_type,
         'otaker',       'varchar',   '',   8,
@@ -464,12 +498,27 @@ sub tables_hash_hack {
         'payby',        'char',   '',     4, # CARD/BILL/COMP, should be index
                                              # into payment type table.
         'payinfo',      'varchar',   'NULL', 16,  #see cust_main above
+        'paybatch',     'varchar',   'NULL', $char_d,
       ],
       'primary_key' => 'refundnum',
       'unique' => [ [] ],
-      'index' => [ ['crednum'] ],
+      'index' => [ [] ],
+    },
+
+    'cust_credit_refund' => {
+      'columns' => [
+        'creditrefundnum', 'int',     '',   '',
+        'crednum',  'int',     '',   '',
+        'refundnum',  'int',     '',   '',
+        'amount',  @money_type,
+        '_date',   @date_type
+      ],
+      'primary_key' => 'creditrefundnum',
+      'unique' => [ [] ],
+      'index' => [ [ 'crednum', 'refundnum' ] ],
     },
 
+
     'cust_svc' => {
       'columns' => [
         'svcnum',    'int',    '',   '',
@@ -537,6 +586,19 @@ sub tables_hash_hack {
       'index' => [ [] ],
     },
 
+    'part_svc_column' => {
+      'columns' => [
+        'columnnum',   'int',         '', '',
+        'svcpart',     'int',         '', '',
+        'columnname',  'varchar',     '', 64,
+        'columnvalue', 'varchar', 'NULL', $char_d,
+        'columnflag',  'char',    'NULL', 1, 
+      ],
+      'primary_key' => 'columnnum',
+      'unique' => [ [ 'svcpart', 'columnname' ] ],
+      'index' => [ [ 'svcpart' ] ],
+    }
+
     #(this should be renamed to part_pop)
     'svc_acct_pop' => {
       'columns' => [