rewrite CDRs for forwarded Asterisk calls to be billable, RT#3196
[freeside.git] / FS / FS / Schema.pm
index ecf017e..d59270b 100644 (file)
@@ -396,7 +396,7 @@ sub tables_hashref {
       'primary_key' => 'eventnum',
       #no... there are retries now #'unique' => [ [ 'eventpart', 'invnum' ] ],
       'unique' => [],
-      'index' => [ ['invnum'], ['status'] ],
+      'index' => [ ['invnum'], ['status'], ['eventpart'] ],
     },
 
     'part_bill_event' => {
@@ -498,19 +498,19 @@ sub tables_hashref {
 
     'cust_bill_pkg' => {
       'columns' => [
-        'billpkgnum', 'serial', '', '', '', '', 
-        'pkgnum',  'int', '', '', '', '', 
-        'pkgpart_override',  'int', 'NULL', '', '', '', 
-        'invnum',  'int', '', '', '', '', 
-        'setup',   @money_type, '', '', 
-        'recur',   @money_type, '', '', 
-        'sdate',   @date_type, '', '', 
-        'edate',   @date_type, '', '', 
-        'itemdesc', 'varchar', 'NULL', $char_d, '', '', 
-        'section',  'varchar', 'NULL', $char_d, '', '', 
-        'quantity',  'int', 'NULL', '', '', '',
-        'unitsetup', @money_typen, '', '', 
-        'unitrecur', @money_typen, '', '', 
+        'billpkgnum',        'serial',     '',      '', '', '', 
+        'invnum',               'int',     '',      '', '', '', 
+        'pkgnum',               'int',     '',      '', '', '', 
+        'pkgpart_override',     'int', 'NULL',      '', '', '', 
+        'setup',               @money_type,             '', '', 
+        'recur',               @money_type,             '', '', 
+        'sdate',               @date_type,              '', '', 
+        'edate',               @date_type,              '', '', 
+        'itemdesc',         'varchar', 'NULL', $char_d, '', '', 
+        'section',          'varchar', 'NULL', $char_d, '', '', 
+        'quantity',             'int', 'NULL',      '', '', '',
+        'unitsetup',           @money_typen,            '', '', 
+        'unitrecur',           @money_typen,            '', '', 
       ],
       'primary_key' => 'billpkgnum',
       'unique' => [],
@@ -549,6 +549,21 @@ sub tables_hashref {
       'index' => [ ['billpkgnum'], ],
     },
 
+    'cust_bill_pkg_tax_location' => {
+      'columns' => [
+        'billpkgtaxlocationnum', 'serial',      '', '', '', '',
+        'billpkgnum',               'int',      '', '', '', '',
+        'taxnum',                   'int',      '', '', '', '',
+        'taxtype',              'varchar', $char_d, '', '', '',
+        'pkgnum',                   'int',      '', '', '', '',
+        'locationnum',              'int',      '', '', '', '', #redundant?
+        'amount',                   @money_type,        '', '',
+      ],
+      'primary_key' => 'billpkgtaxlocationnum',
+      'unique' => [],
+      'index'  => [ [ 'billpkgnum' ], [ 'taxnum' ], [ 'pkgnum' ], [ 'locationnum' ] ],
+    },
+
     'cust_credit' => {
       'columns' => [
         'crednum',  'serial', '', '', '', '', 
@@ -661,13 +676,20 @@ sub tables_hashref {
       'primary_key' => 'custnum',
       'unique' => [ [ 'agentnum', 'agent_custid' ] ],
       #'index' => [ ['last'], ['company'] ],
-      'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ],
-                   [ 'daytime' ], [ 'night' ], [ 'fax' ], [ 'refnum' ],
-                   [ 'county' ], [ 'state' ], [ 'country' ], [ 'zip' ],
+      'index' => [
+                   [ 'agentnum' ], [ 'refnum' ], [ 'custbatch' ],
+                   [ 'referral_custnum' ],
+                   [ 'payby' ], [ 'paydate' ],
+                   #billing
+                   [ 'last' ], [ 'company' ],
+                   [ 'county' ], [ 'state' ], [ 'country' ],
+                   [ 'zip' ],
+                   [ 'daytime' ], [ 'night' ], [ 'fax' ],
+                   #shipping
                    [ 'ship_last' ], [ 'ship_company' ],
+                   [ 'ship_county' ], [ 'ship_state' ], [ 'ship_country' ],
+                   [ 'ship_zip' ],
                    [ 'ship_daytime' ], [ 'ship_night' ], [ 'ship_fax' ],
-                   [ 'payby' ], [ 'paydate' ],
-                   [ 'agentnum' ], [ 'custbatch' ],
                  ],
     },
 
@@ -735,7 +757,9 @@ sub tables_hashref {
       'primary_key' => 'taxnum',
       'unique' => [],
   #    'unique' => [ ['taxnum'], ['state', 'county'] ],
-      'index' => [ [ 'county' ], [ 'state' ], [ 'country' ] ],
+      'index' => [ [ 'county' ], [ 'state' ], [ 'country' ],
+                   [ 'taxclass' ],
+                 ],
     },
 
     'tax_rate'    => {
@@ -975,6 +999,7 @@ sub tables_hashref {
         'change_date',    @date_type,             '', '',
         'change_pkgnum',       'int', 'NULL', '', '', '',
         'change_pkgpart',      'int', 'NULL', '', '', '',
+        'change_locationnum',  'int', 'NULL', '', '', '',
         'manual_flag',        'char', 'NULL',  1, '', '', 
         'quantity',            'int', 'NULL', '', '', '',
       ],
@@ -1641,7 +1666,7 @@ sub tables_hashref {
         'vlan_profile', 'varchar', 'NULL', $char_d, '', '', 
       ],
       'primary_key' => 'svcnum',
-      'unique'      => [],
+      'unique'      => [ [ 'mac_addr' ] ],
       'index'       => [],
     },
 
@@ -1762,11 +1787,11 @@ sub tables_hashref {
 
     'rate_prefix' => {
       'columns' => [
-        'prefixnum',   'serial',    '', '', '', '', 
-        'regionnum',   'int',       '', '',, '', '', 
-        'countrycode', 'varchar',     '', 3, '', '', 
-        'npa',         'varchar', 'NULL', 6, '', '', 
-        'nxx',         'varchar', 'NULL', 3, '', '', 
+        'prefixnum',   'serial',      '', '', '', '', 
+        'regionnum',   'int',         '', '', '', '', 
+        'countrycode', 'varchar',     '',  3, '', '', 
+        'npa',         'varchar', 'NULL', 10, '', '', #actually the whole prefix
+        'nxx',         'varchar', 'NULL',  3, '', '', #actually not used
       ],
       'primary_key' => 'prefixnum',
       'unique'      => [],
@@ -1989,12 +2014,15 @@ sub tables_hashref {
         #NULL, done (or something)
         'freesidestatus', 'varchar',   'NULL',     32,   '', '', 
 
+        #NULL, done (or something)
+        'freesiderewritestatus', 'varchar',   'NULL',     32,   '', '', 
+
         'cdrbatch', 'varchar', 'NULL', $char_d, '', '',
 
       ],
       'primary_key' => 'acctid',
       'unique' => [],
-      'index' => [ [ 'calldate' ], [ 'dst' ], [ 'accountcode' ], [ 'freesidestatus' ], [ 'cdrbatch' ], ],
+      'index' => [ [ 'calldate' ], [ 'src' ], [ 'dst' ], [ 'charged_party' ], [ 'accountcode' ], [ 'freesidestatus' ], [ 'freesiderewritestatus' ], [ 'cdrbatch' ], ],
     },
 
     'cdr_calltype' => {
@@ -2039,6 +2067,21 @@ sub tables_hashref {
       'index'  => [],
     },
 
+    #'cdr_file' => {
+    #  'columns' => [
+    #    'filenum',    'serial',     '', '', '', '',
+    #    'filename',  'varchar',     '', '', '', '',
+    #    'status',    'varchar', 'NULL', '', '', '',
+    #  ],
+    #  'primary_key' => 'filenum',
+    #  'unique' => [ [ 'filename' ], ], #just change the index if we need to
+    #                                   # agent-virtualize or have a customer
+    #                                   # with dup-filename needs or something
+    #                                   # (only used by cdr.http_and_import for
+    #                                   #  chrissakes)
+    #  'index'  => [],
+    #},
+
     'inventory_item' => {
       'columns' => [
         'itemnum',  'serial',      '',      '', '', '',