tax engine refactoring for Avalara and Billsoft tax vendors, #25718
[freeside.git] / FS / FS / Schema.pm
index ae34bba..53e78de 100644 (file)
@@ -691,6 +691,8 @@ sub tables_hashref {
         'statementnum', 'int', 'NULL', '', '', '', #invoice aggregate statements
         'agent_invid',  'int', 'NULL', '', '', '', #(varchar?) importing legacy
         'promised_date', @date_type,       '', '',
+        
+        'pending',     'char', 'NULL',  1, '', '',
       ],
       'primary_key'  => 'invnum',
       'unique'       => [ [ 'custnum', 'agent_invid' ] ], #agentnum?  huh
@@ -1026,7 +1028,8 @@ sub tables_hashref {
 
     'cust_bill_pkg_detail' => {
       'columns' => [
-        'detailnum', 'serial', '', '', '', '',
+        'detailnum', 'serial', '', '', '', '', 
+          # bigserial? this table will eventually be as big as cdr...
         'billpkgnum', 'int', 'NULL', '', '', '',        # should not be nullable
         'pkgnum',  'int', 'NULL', '', '', '',           # deprecated
         'invnum',  'int', 'NULL', '', '', '',           # deprecated
@@ -1038,7 +1041,7 @@ sub tables_hashref {
         'accountcode', 'varchar',  'NULL',      20, '', '',
         'startdate',  @date_type, '', '', 
         'regionname', 'varchar', 'NULL', $char_d, '', '',
-        'detail',  'varchar', '', 255, '', '', 
+        'detail',  'varchar', '', 255, '', '',
       ],
       'primary_key'  => 'detailnum',
       'unique'       => [],
@@ -1625,6 +1628,7 @@ sub tables_hashref {
         'message_noemail', 'char', 'NULL', 1, '', '',
         'bill_locationnum', 'int', 'NULL', '', '', '',
         'ship_locationnum', 'int', 'NULL', '', '', '',
+        'taxstatusnum',   'char', 'NULL',      32, '', '',
       ],
       'primary_key'  => 'custnum',
       'unique'       => [ [ 'agentnum', 'agent_custid' ] ],
@@ -1929,6 +1933,7 @@ sub tables_hashref {
         'location_type',   'varchar', 'NULL',      20, '', '',
         'location_number', 'varchar', 'NULL',      20, '', '',
         'location_kind',      'char', 'NULL',       1, '', '',
+        'incorporated',       'char', 'NULL',       1, '', '',
         'disabled',           'char', 'NULL',       1, '', '', 
       ],
       'primary_key'  => 'locationnum',
@@ -2158,7 +2163,7 @@ sub tables_hashref {
         'geocode',     'varchar', 'NULL', $char_d, '', '',#cch provides 10 char
         'data_vendor', 'varchar', 'NULL', $char_d, '', '',#auto update source
         'location',    'varchar', 'NULL', $char_d, '', '',#provided by tax authority
-        'taxclassnum', 'int',      '',      '', '', '', 
+        'taxclassnum', 'int',     'NULL',      '', '', '', 
         'effective_date', @date_type, '', '', 
         'tax',        @taxrate_type,      '', '',        # tax %
         'excessrate', @taxrate_typen,     '', '',        # second tax %
@@ -2202,6 +2207,7 @@ sub tables_hashref {
         'city',               'varchar', 'NULL', $char_d, '', '',
         'county',             'varchar', 'NULL', $char_d, '', '',
         'state',              'char',    'NULL',       2, '', '', 
+        'country',            'char',    'NULL',       2, '', '',
         'disabled',           'char',    'NULL', 1, '', '',
       ],
       'primary_key' => 'taxratelocationnum',
@@ -2216,8 +2222,11 @@ sub tables_hashref {
         'city',            'varchar', 'NULL', $char_d, '', '',
         'postalcity',      'varchar', 'NULL', $char_d, '', '',
         'county',          'varchar', 'NULL', $char_d, '', '',
-        'zip',             'char',    '',     5,  '', '', 
+        'zip',             'char',    'NULL', 5,  '', '', 
         'state',           'char',    '',     2,  '', '', 
+        'country',         'char',    'NULL', 2,  '', '', # should not actually be NULL, but cch...
+        'ziphi',           'char',    'NULL', 10, '', '',
+        'ziplo',           'char',    'NULL', 10, '', '',
         'plus4hi',         'char',    'NULL', 4,  '', '', 
         'plus4lo',         'char',    'NULL', 4,  '', '', 
         'default_location','char',    'NULL', 1,  '', '', # Y = default for zip
@@ -2226,7 +2235,7 @@ sub tables_hashref {
       ],
       'primary_key' => 'custlocationnum',
       'unique' => [],
-      'index' => [ [ 'zip', 'plus4lo', 'plus4hi' ] ],
+      'index' => [ [ 'zip', 'plus4lo', 'plus4hi', 'ziphi', 'ziplo' ] ],
     },
 
     'tax_class' => { 
@@ -2241,6 +2250,18 @@ sub tables_hashref {
       'index' => [],
     },
 
+    'tax_status' => {
+      'columns' => [
+        'taxstatusnum', 'serial', '',             '', '', '',
+        'data_vendor',  'varchar', 'NULL',   $char_d, '', '',
+        'taxstatus',    'varchar', '',       $char_d, '', '',          
+        'description',  'varchar', '',       $char_d, '', '',
+      ],
+      'primary_key' => 'taxstatusnum',
+      'unique'      => [ [ 'data_vendor', 'taxstatus' ] ],
+      'index' => [],
+    },
+
     'cust_pay_pending' => {
       'columns' => [
         'paypendingnum',      'serial',     '',      '', '', '',
@@ -3312,6 +3333,7 @@ sub tables_hashref {
         'data_vendor',   'varchar', 'NULL',   $char_d, '', '', 
         'taxproduct',    'varchar',     '',   $char_d, '', '', 
         'description',   'varchar',     '', 3*$char_d, '', '', 
+        'note',             'text', 'NULL',        '', '', '',
       ],
       'primary_key' => 'taxproductnum',
       'unique'      => [ [ 'data_vendor', 'taxproduct' ] ],
@@ -5285,6 +5307,9 @@ sub tables_hashref {
         #new
         'cdrbatchnum',      'int',    'NULL',      '', '', '',
 
+        # FK to cust_bill_pkg_detail; having a value here absolutely means
+        # that the CDR appears on an invoice
+        'detailnum',     'bigint',    'NULL',      '', '', '',
       ],
       'primary_key' => 'acctid',
       'unique' => [],