proper cdr_batch table, RT#6386
[freeside.git] / FS / FS / Schema.pm
index 80aed82..b7c8679 100644 (file)
@@ -372,18 +372,56 @@ sub tables_hashref {
       'index' => [ ['typenum'] ],
     },
 
+    'cust_attachment' => {
+      'columns' => [
+        'attachnum', 'serial', '', '', '', '',
+        'custnum',   'int', '', '', '', '',
+        '_date',     @date_type, '', '',
+        'otaker',    'varchar', '', 32, '', '',
+        'filename',  'varchar', '', 32, '', '',
+        'mime_type', 'varchar', '', 32, '', '',
+        'body',      'blob', 'NULL', '', '', '',
+        'disabled',  @date_type, '', '',
+      ],
+      'primary_key' => 'attachnum',
+      'unique'      => [],
+      'index'       => [ ['custnum'] ],
+    },
+
     'cust_bill' => {
       'columns' => [
-        'invnum',    'serial',  '', '', '', '', 
-        'custnum',   'int',  '', '', '', '', 
-        '_date',     @date_type, '', '', 
-        'charged',   @money_type, '', '', 
-        'printed',   'int',  '', '', '', '', 
-        'closed',    'char', 'NULL', 1, '', '', 
+        #regular fields
+        'invnum',    'serial',     '', '', '', '', 
+        'custnum',      'int',     '', '', '', '', 
+        '_date',        @date_type,        '', '', 
+        'charged',      @money_type,       '', '', 
+        'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
+
+        #customer balance info at invoice generation time
+        'previous_balance',   @money_typen, '', '',  #eventually not nullable
+        'billing_balance',    @money_typen, '', '',  #eventually not nullable
+
+        #deprecated (unused by now, right?)
+        'printed',      'int',     '', '', '', '', 
+
+        #specific use cases
+        'closed',      'char', 'NULL',  1, '', '', 
+        'statementnum', 'int', 'NULL', '', '', '', #invoice aggregate statements
       ],
       'primary_key' => 'invnum',
       'unique' => [],
-      'index' => [ ['custnum'], ['_date'] ],
+      'index' => [ ['custnum'], ['_date'], ['statementnum'], ],
+    },
+
+    'cust_statement' => {
+      'columns' => [
+        'statementnum', 'serial', '', '', '', '',
+        'custnum',         'int', '', '', '', '',
+        '_date',           @date_type,    '', '',
+      ],
+      'primary_key' => 'statementnum',
+      'unique' => [],
+      'index' => [ ['custnum'], ['_date'], ],
     },
 
     'cust_bill_event' => {
@@ -531,9 +569,10 @@ sub tables_hashref {
         'billpkgnum', 'int', 'NULL', '', '', '',        # should not be nullable
         'pkgnum',  'int', 'NULL', '', '', '',           # deprecated
         'invnum',  'int', 'NULL', '', '', '',           # deprecated
-        'amount',  @money_typen, '', '', 
+        'amount',  'decimal', 'NULL', '10,4', '', '',
         'format',  'char', 'NULL', 1, '', '',
         'classnum', 'int', 'NULL', '', '', '',
+        'phonenum', 'varchar', 'NULL', 15, '', '',
         'detail',  'varchar', '', 255, '', '', 
       ],
       'primary_key' => 'detailnum',
@@ -872,6 +911,8 @@ sub tables_hashref {
         'passflag',    'char', 'NULL', 1, '', '',  # Y = required to list as line item, N = Prohibited
         'setuptax',    'char', 'NULL', 1, '', '',  # Y = setup tax exempt
         'recurtax',    'char', 'NULL', 1, '', '',  # Y = recur tax exempt
+        'inoutcity',   'char', 'NULL', 1, '', '',  # '', 'I', or 'O'
+        'inoutlocal',  'char', 'NULL', 1, '', '',  # '', 'I', or 'O'
         'manual',      'char', 'NULL', 1, '', '',  # Y = manually edited
         'disabled',    'char', 'NULL', 1, '', '',  # Y = tax disabled
       ],
@@ -1412,7 +1453,7 @@ sub tables_hashref {
       'columns' => [
         'svcnum',    'int',    '',   '', '', '', 
         'username',  'varchar',   '',   $username_len, '', '',
-        '_password', 'varchar',   '',  512, '', '',
+        '_password', 'varchar',   'NULL',  512, '', '',
         '_password_encoding', 'varchar', 'NULL', $char_d, '', '',
         'sec_phrase', 'varchar',  'NULL',   $char_d, '', '', 
         'popnum',    'int',    'NULL',   '', '', '', 
@@ -1602,7 +1643,7 @@ sub tables_hashref {
     'queue' => {
       'columns' => [
         'jobnum',      'serial',     '',      '', '', '', 
-        'job',           'text',     '',      '', '', '', 
+        'job',        'varchar',     '',     512, '', '', 
         '_date',          'int',     '',      '', '', '', 
         'status',     'varchar',     '', $char_d, '', '', 
         'statustext',    'text', 'NULL',      '', '', '', 
@@ -2044,6 +2085,7 @@ sub tables_hashref {
       'columns' => [
         'categorynum',   'serial',  '', '', '', '', 
         'categoryname',  'varchar', '', $char_d, '', '', 
+        'weight',         'int', 'NULL',  '', '', '',
         'disabled',      'char', 'NULL',   1, '', '', 
       ],
       'primary_key' => 'categorynum',
@@ -2107,6 +2149,8 @@ sub tables_hashref {
         ###
         # fields for unitel/RSLCOM/convergent that don't map well to asterisk
         # defaults
+        # though these are now used elsewhere:
+        # charged_party, upstream_price, rated_price, carrierid
         ###
 
         #cdr_type: Usage = 1, S&E = 7, OC&C = 8
@@ -2149,19 +2193,36 @@ sub tables_hashref {
         #NULL, done (or something)
         'freesiderewritestatus', 'varchar',   'NULL',     32,   '', '', 
 
+        #an indexed place to put big numbers
+        'cdrid',         'bigint',     'NULL',     '',  '', '', 
+
+        #old
         'cdrbatch', 'varchar', 'NULL', 255, '', '',
+        #new
+        'cdrbatchnum', 'int', 'NULL', '', '', '',
 
       ],
       'primary_key' => 'acctid',
       'unique' => [],
       'index' => [ [ 'calldate' ],
                    [ 'src' ], [ 'dst' ], [ 'dcontext' ], [ 'charged_party' ],
-                   [ 'accountcode' ], [ 'carrierid' ],
+                   [ 'accountcode' ], [ 'carrierid' ], [ 'cdrid' ],
                    [ 'freesidestatus' ], [ 'freesiderewritestatus' ],
                    [ 'cdrbatch' ],
                  ],
     },
 
+    'cdr_batch' => {
+      'columns' => [
+        'cdrbatchnum',   'serial',    '',   '', '', '', 
+        'cdrbatch', 'varchar', 'NULL', 255, '', '',
+        '_date',     @date_type, '', '', 
+      ],
+      'primary_key' => 'cdrbatchnum',
+      'unique' => [ [ 'cdrbatch' ] ],
+      'index' => [],
+    },
+
     'cdr_termination' => {
       'columns' => [
         'cdrtermnum', 'bigserial',     '',      '', '', '',