better (?) place to put display and taxation data than overloading real line items
[freeside.git] / FS / FS / Schema.pm
index e461fc1..d354561 100644 (file)
@@ -500,8 +500,6 @@ sub tables_hashref {
         'quantity',  'int', 'NULL', '', '', '',
         'unitsetup', @money_typen, '', '', 
         'unitrecur', @money_typen, '', '', 
-        'duplicate',  'char', 'NULL', 1, '', '',  # does this need to be in db?
-        'post_total', 'char', 'NULL', 1, '', '',
       ],
       'primary_key' => 'billpkgnum',
       'unique' => [],
@@ -514,7 +512,9 @@ sub tables_hashref {
         'billpkgnum', 'int', 'NULL', '', '', '',        # should not be nullable
         'pkgnum',  'int', 'NULL', '', '', '',           # deprecated
         'invnum',  'int', 'NULL', '', '', '',           # deprecated
+        'amount',  @money_typen, '', '', 
         'format',  'char', 'NULL', 1, '', '',
+        'classnum', 'char', 'NULL', 1, '', '',
         'detail',  'varchar', '', $char_d, '', '', 
       ],
       'primary_key' => 'detailnum',
@@ -522,6 +522,39 @@ sub tables_hashref {
       'index' => [ [ 'billpkgnum' ], [ 'pkgnum', 'invnum' ] ],
     },
 
+    #instead of 'duplicate',  'char', 'NULL', 1, '', '',
+    # that way we keep display vs *TOTALLY* out of the table for actual
+    #  finanancial line items
+    'cust_bill_pkg_display' => {
+      'columns' => [
+        'billpkgdisplaynum', 'serial', '', '', '', '', 
+        'billpkgnum', 'int', '', '', '', '', 
+        'section',  'varchar', 'NULL', $char_d, '', '', 
+        #override the linked real one?#'unitsetup', @money_typen, '', '', 
+        #this too?#'unitrecur', @money_typen, '', '', 
+        'post_total', 'char', 'NULL', 1, '', '',
+        'type',       'char', 'NULL', 1, '', '',
+        #any other fields we need to control this display-only line item...
+      ],
+      'primary_key' => 'billpkgdisplaynum',
+      'unique' => [],
+      'index' => [ ['billpkgnum'], ],
+    },
+
+    #and this, to break down a line item into slices for taxation purposes
+    #(instead of creating usage line items for each usage class)
+    'cust_bill_pkg_slice' => {
+      'columns' => [
+        'slicenum', 'serial', '', '', '', '', 
+        'billpkgnum', 'int', '', '', '', '',
+        'amount',  @money_typen, '', '', 
+        'classnum', 'int', '', '', '', '',
+      ],
+      'primary_key' => 'slicenum',
+      'unique'      => [],
+      'index'       => [ [ 'billpkgnum' ], [ 'classnum' ], ],
+    },
+
     'cust_credit' => {
       'columns' => [
         'crednum',  'serial', '', '', '', '', 
@@ -942,6 +975,19 @@ sub tables_hashref {
       'index'       => [ [ 'pkgnum' ], [ 'optionname' ] ],
     },
 
+    'cust_pkg_detail' => {
+      'columns' => [
+        'pkgdetailnum', 'serial', '',      '', '', '',
+        'pkgnum',          'int', '',      '', '', '',
+        'detail',      'varchar', '', $char_d, '', '', 
+        'detailtype',     'char', '',       1, '', '', # "I"nvoice or "C"omment
+        'weight',          'int', '',      '', '', '',
+      ],
+      'primary_key' => 'pkgdetailnum',
+      'unique' => [],
+      'index'  => [ [ 'pkgnum', 'detailtype' ] ],
+    },
+
     'cust_pkg_reason' => {
       'columns' => [
         'num',      'serial',    '',   '', '', '', 
@@ -953,7 +999,7 @@ sub tables_hashref {
       ],
       'primary_key' => 'num',
       'unique' => [],
-      'index' => [],
+      'index' => [ [ 'pkgnum' ], [ 'reasonnum' ], ['action'], ],
     },
 
     'cust_refund' => {
@@ -1003,6 +1049,18 @@ sub tables_hashref {
       'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'] ],
     },
 
+    'cust_svc_option' => {
+      'columns' => [
+        'optionnum',   'serial', '', '', '', '', 
+        'svcnum',      'int', '', '', '', '', 
+        'optionname',  'varchar', '', $char_d, '', '', 
+        'optionvalue', 'text', 'NULL', '', '', '', 
+      ],
+      'primary_key' => 'optionnum',
+      'unique'      => [],
+      'index'       => [ [ 'svcnum' ], [ 'optionname' ] ],
+    },
+
     'part_pkg' => {
       'columns' => [
         'pkgpart',       'serial',    '',   '', '', '', 
@@ -1091,6 +1149,7 @@ sub tables_hashref {
         'taxoverridenum', 'serial', '', '', '', '',
         'pkgpart',        'serial', '', '', '', '',
         'taxclassnum',    'serial', '', '', '', '',
+        'usage_class',    'varchar', 'NULL', $char_d, '', '', 
       ],
       'primary_key' => 'taxoverridenum',
       'unique' => [],
@@ -1659,6 +1718,7 @@ sub tables_hashref {
         'min_charge',      'decimal', '', '10,5', '', '', 
         'sec_granularity', 'int',     '', '', '', '', 
         #time period (link to table of periods)?
+        'classnum',        'int',     'NULL', '', '', '', 
       ],
       'primary_key' => 'ratedetailnum',
       'unique'      => [ [ 'ratenum', 'orig_regionnum', 'dest_regionnum' ] ],
@@ -1688,6 +1748,17 @@ sub tables_hashref {
       'index'       => [ [ 'countrycode' ], [ 'regionnum' ] ],
     },
 
+    'usage_class' => {
+      'columns' => [
+        'classnum',    'serial',   '',      '', '', '', 
+        'classname',   'varchar',  '', $char_d, '', '', 
+        'disabled',    'char', 'NULL',       1, '', '', 
+      ],
+      'primary_key' => 'classnum',
+      'unique' => [],
+      'index' => [ ['disabled'] ],
+    },
+
     'reg_code' => {
       'columns' => [
         'codenum',   'serial',    '', '', '', '', 
@@ -1893,10 +1964,12 @@ sub tables_hashref {
         #NULL, done (or something)
         'freesidestatus', 'varchar',   'NULL',     32,   '', '', 
 
+        'cdrbatch', 'varchar', 'NULL', $char_d, '', '',
+
       ],
       'primary_key' => 'acctid',
       'unique' => [],
-      'index' => [ [ 'calldate' ], [ 'dst' ], [ 'accountcode' ], [ 'freesidestatus' ] ],
+      'index' => [ [ 'calldate' ], [ 'dst' ], [ 'accountcode' ], [ 'freesidestatus' ], [ 'cdrbatch' ], ],
     },
 
     'cdr_calltype' => {