batch refactor continued
[freeside.git] / FS / FS / Schema.pm
index e23ae73..9f9770c 100644 (file)
@@ -16,14 +16,6 @@ use FS::UID qw(datasrc);
 $DEBUG = 0;
 $me = '[FS::Schema]';
 
-#hardcoded now...
-##ask FS::UID to run this stuff for us later
-#FS::UID->install_callback( sub {
-#  #$conf = new FS::Conf; 
-#  &reload_dbdef("/usr/local/etc/freeside/dbdef.". datasrc)
-#    unless $setup_hack; #$setup_hack needed now?
-#} );
-
 =head1 NAME
 
 FS::Schema - Freeside database schema
@@ -59,7 +51,7 @@ sub reload_dbdef {
   unless ( exists $dbdef_cache{$file} ) {
     warn "[debug]$me loading dbdef for $file\n" if $DEBUG;
     $dbdef_cache{$file} = DBIx::DBSchema->load( $file )
-                            or die "can't load database schema from $file";
+      or die "can't load database schema from $file: $DBIx::DBSchema::errstr\n";
   } else {
     warn "[debug]$me re-using cached dbdef for $file\n" if $DEBUG;
   }
@@ -390,10 +382,24 @@ sub tables_hashref {
       'index' => [ ['crednum'], ['invnum'] ],
     },
 
+    'cust_credit_bill_pkg' => {
+      'columns' => [
+        'creditbillpkgnum', 'serial', '',      '', '', '',
+        'creditbillnum',       'int', '',      '', '', '',
+        'billpkgnum',          'int', '',      '', '', '',
+        'amount',            @money_type,          '', '',
+        'setuprecur',      'varchar', '', $char_d, '', '',
+      ],
+      'primary_key' => 'creditbillpkgnum',
+      'unique'      => [],
+      'index'       => [ [ 'creditbillnum' ], [ 'billpkgnum' ], ],
+    },
+
     'cust_main' => {
       'columns' => [
         'custnum',  'serial',  '',     '', '', '', 
         'agentnum', 'int',  '',     '', '', '', 
+        'agent_custid', 'varchar', 'NULL', $char_d, '', '',
 #        'titlenum', 'int',  'NULL',   '', '', '', 
         'last',     'varchar', '',     $char_d, '', '', 
 #        'middle',   'varchar', 'NULL', $char_d, '', '', 
@@ -443,7 +449,7 @@ sub tables_hashref {
         'spool_cdr','char', 'NULL', 1, '', '', 
       ],
       'primary_key' => 'custnum',
-      'unique' => [],
+      'unique' => [ [ 'agentnum', 'agent_custid' ] ],
       #'index' => [ ['last'], ['company'] ],
       'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ],
                    [ 'daytime' ], [ 'night' ], [ 'fax' ], [ 'refnum' ],
@@ -539,6 +545,32 @@ sub tables_hashref {
       'index' => [ [ 'paynum' ], [ 'invnum' ] ],
     },
 
+    'cust_bill_pay_batch' => {
+      'columns' => [
+        'billpaynum', 'serial',     '',   '', '', '', 
+        'invnum',  'int',     '',   '', '', '', 
+        'paybatchnum',  'int',     '',   '', '', '', 
+        'amount',  @money_type, '', '', 
+        '_date',   @date_type, '', '', 
+      ],
+      'primary_key' => 'billpaynum',
+      'unique' => [],
+      'index' => [ [ 'paybatchnum' ], [ 'invnum' ] ],
+    },
+
+    'cust_bill_pay_pkg' => {
+      'columns' => [
+        'billpaypkgnum', 'serial', '', '', '', '',
+        'billpaynum',       'int', '', '', '', '',
+        'billpkgnum',       'int', '', '', '', '',
+        'amount',         @money_type,     '', '',
+        'setuprecur',      'varchar', '', $char_d, '', '',
+      ],
+      'primary_key' => 'billpaypkgnum',
+      'unique'      => [],
+      'index'       => [ [ 'billpaynum' ], [ 'billpkgnum' ], ],
+    },
+
     'pay_batch' => { #batches of payments to an external processor
       'columns' => [
         'batchnum',   'serial',    '',   '', '', '',