more flexible package suspend/unsuspend fees, #26828
[freeside.git] / FS / FS / Schema.pm
index 9c2e9ba..fc56d90 100644 (file)
@@ -200,6 +200,7 @@ sub dbdef_dist {
     grep {    ! /^(clientapi|access_user)_session/
            && ! /^h_/
            && ! /^log(_context)?$/
+           && ! /^legacy_cust_history$/
            && ( ! /^queue(_arg|_depend|_stat)?$/ || ! $opt->{'queue-no_history'} )
            && ! $tables_hashref_torrus->{$_}
          }
@@ -778,6 +779,31 @@ sub tables_hashref {
                         ],
     },
 
+    'legacy_cust_history' => {
+      'columns' => [
+        'legacyhistorynum', 'serial',     '',        '', '', '',
+        'custnum',             'int',     '',        '', '', '',
+        'history_action',  'varchar',     '',   $char_d, '', '',
+        'history_date',           @date_type,            '', '',
+        'history_usernum',     'int', 'NULL',        '', '', '',
+        'item',            'varchar', 'NULL',   $char_d, '', '',
+        'description',     'varchar', 'NULL', 2*$char_d, '', '',
+        'change_data',        'text', 'NULL',        '', '', '',
+      ],
+      'primary_key'  => 'legacyhistorynum',
+      'unique'       => [],
+      'index'        => [ ['custnum'], ['history_date'], ],
+      'foreign_keys' => [
+                          { columns    => [ 'custnum' ],
+                            table      => 'cust_main',
+                          },
+                          { columns    => [ 'history_usernum' ],
+                            table      => 'access_user',
+                            references => [ 'usernum' ],
+                          },
+                        ],
+    },
+
     'cust_statement' => {
       'columns' => [
         'statementnum', 'serial', '', '', '', '',
@@ -921,9 +947,9 @@ sub tables_hashref {
                           { columns => [ 'eventnum' ],
                             table   => 'cust_event',
                           },
-                          { columns => [ 'billpkgnum' ],
-                            table   => 'cust_bill_pkg',
-                          },
+                          #{ columns => [ 'billpkgnum' ],
+                          #  table   => 'cust_bill_pkg',
+                          #},
                           { columns => [ 'feepart' ],
                             table   => 'part_fee',
                           },
@@ -1052,17 +1078,31 @@ sub tables_hashref {
                           { columns     => [ 'billpkgnum' ],
                             table       => 'cust_bill_pkg',
                           },
-                          { columns     => [ 'base_billpkgnum' ],
-                            table       => 'cust_bill_pkg',
-                            references  => [ 'billpkgnum' ],
-                          },
-                          { columns     => [ 'base_invnum' ],
-                            table       => 'cust_bill',
-                            references  => [ 'invnum' ],
+                        ],
+    },
+
+    'cust_bill_pkg_fee_void' => {
+      'columns' => [
+        'billpkgfeenum',    'serial', '', '', '', '',
+        'billpkgnum',          'int', '', '', '', '',
+        'base_invnum',       'int', '', '', '', '',
+        'base_billpkgnum',   'int', 'NULL', '', '', '',
+        'amount',        @money_type,         '', '',
+      ],
+      'primary_key' => 'billpkgfeenum',
+      'unique'      => [],
+      'index'       => [ ['billpkgnum'],
+                         ['base_invnum'],
+                         ['base_billpkgnum'],
+                       ],
+      'foreign_keys' => [
+                          { columns     => [ 'billpkgnum' ],
+                            table       => 'cust_bill_pkg_void',
                           },
                         ],
     },
 
+
     'cust_bill_pkg_tax_location' => {
       'columns' => [
         'billpkgtaxlocationnum', 'serial',     '',      '', '', '',
@@ -1093,10 +1133,10 @@ sub tables_hashref {
                           { columns    => [ 'locationnum' ],
                             table      => 'cust_location',
                           },
-                          { columns    => [ 'taxable_billpkgnum' ],
-                            table      => 'cust_bill_pkg',
-                            references => [ 'billpkgnum' ],
-                          },
+                          #{ columns    => [ 'taxable_billpkgnum' ],
+                          #  table      => 'cust_bill_pkg',
+                          #  references => [ 'billpkgnum' ],
+                          #},
                         ],
     },
 
@@ -1124,10 +1164,10 @@ sub tables_hashref {
                           { columns    => [ 'taxratelocationnum' ],
                             table      => 'tax_rate_location',
                           },
-                          { columns    => [ 'taxable_billpkgnum' ],
-                            table      => 'cust_bill_pkg',
-                            references => [ 'billpkgnum' ],
-                          },
+                          #{ columns    => [ 'taxable_billpkgnum' ],
+                          #  table      => 'cust_bill_pkg',
+                          #  references => [ 'billpkgnum' ],
+                          #},
                         ],
     },
 
@@ -1151,6 +1191,7 @@ sub tables_hashref {
         'unitsetup',           @money_typen,            '', '', 
         'unitrecur',           @money_typen,            '', '', 
         'hidden',              'char', 'NULL',       1, '', '',
+        'feepart',              'int', 'NULL',      '', '', '',
         #void fields
         'void_date', @date_type, '', '', 
         'reason',    'varchar',   'NULL', $char_d, '', '', 
@@ -1257,16 +1298,13 @@ sub tables_hashref {
                           { columns    => [ 'billpkgnum' ],
                             table      => 'cust_bill_pkg_void',
                           },
-                          { columns    => [ 'pkgnum' ],
-                            table      => 'cust_pkg',
-                          },
                           { columns    => [ 'locationnum' ],
                             table      => 'cust_location',
                           },
-                          { columns    => [ 'taxable_billpkgnum' ],
-                            table      => 'cust_bill_pkg_void',
-                            references => [ 'billpkgnum' ],
-                          },
+                          #{ columns    => [ 'taxable_billpkgnum' ],
+                          #  table      => 'cust_bill_pkg_void',
+                          #  references => [ 'billpkgnum' ],
+                          #},
                         ],
     },
 
@@ -1607,6 +1645,7 @@ sub tables_hashref {
         'complimentary', 'char', 'NULL', 1, '', '',
         'po_number', 'varchar', 'NULL', $char_d, '', '',
         'invoice_attn', 'varchar', 'NULL', $char_d, '', '',
+        'invoice_ship_address', 'char', 'NULL', 1, '', '',
       ],
       'primary_key'  => 'custnum',
       'unique'       => [ [ 'agentnum', 'agent_custid' ] ],
@@ -1941,6 +1980,26 @@ sub tables_hashref {
                         ],
     },
 
+    'quotation_pkg_tax' => {
+      'columns' => [
+        'quotationtaxnum',  'serial',     '',      '', '', '',
+        'quotationpkgnum',     'int',     '',      '', '', '',
+        'itemdesc',        'varchar',     '', $char_d, '', '',
+        'taxnum',              'int',     '',      '', '', '', 
+        'taxtype',         'varchar',     '', $char_d, '', '',
+        'setup_amount',    @money_type,                '', '',
+        'recur_amount',    @money_type,                '', '',
+      ],
+      'primary_key' => 'quotationtaxnum',,
+      'unique' => [],
+      'index'  => [ [ 'quotationpkgnum' ] ],
+      'foreign_keys' => [
+                          { columns    => [ 'quotationpkgnum' ],
+                            table      => 'quotation_pkg',
+                          },
+                        ],
+},
+
     'cust_location' => { #'location' now that its prospects too, but...
       'columns' => [
         'locationnum',      'serial',     '',      '', '', '',
@@ -2750,11 +2809,11 @@ sub tables_hashref {
 
     'cust_pkg_detail' => {
       'columns' => [
-        'pkgdetailnum', 'serial', '',      '', '', '',
-        'pkgnum',          'int', '',      '', '', '',
-        'detail',      'varchar', '', $char_d, '', '', 
-        'detailtype',     'char', '',       1, '', '', # "I"nvoice or "C"omment
-        'weight',          'int', '',      '', '', '',
+        'pkgdetailnum', 'serial', '',        '', '', '',
+        'pkgnum',          'int', '',        '', '', '',
+        'detail',      'varchar', '', 2*$char_d, '', '', 
+        'detailtype',     'char', '',         1, '', '', #"I"nvoice or "C"omment
+        'weight',          'int', '',        '', '', '',
       ],
       'primary_key'  => 'pkgdetailnum',
       'unique'       => [],
@@ -2792,6 +2851,29 @@ sub tables_hashref {
                         ],
     },
 
+    'cust_pkg_reason_fee' => {
+      'columns' => [
+        'pkgreasonfeenum', 'serial', '', '', '', '',
+        'pkgreasonnum',       'int', '', '', '', '',
+        'billpkgnum',         'int', 'NULL', '', '', '',
+        'feepart',            'int', '', '', '', '',
+        'nextbill',          'char', 'NULL',  1, '', '',
+      ],
+      'primary_key'  => 'pkgreasonfeenum',
+      'unique' => [ [ 'billpkgnum' ], [ 'pkgreasonnum' ] ], # one-to-one link
+      'index'  => [ [ 'feepart' ] ],
+      'foreign_keys' => [
+                          { columns     => [ 'pkgreasonnum' ],
+                            table       => 'cust_pkg_reason',
+                            references  => [ 'num' ],
+                          },
+                          { columns     => [ 'feepart' ],
+                            table       => 'part_fee',
+                          },
+                          # can't link billpkgnum, because of voids
+      ],
+    },
+
     'cust_pkg_discount' => {
       'columns' => [
         'pkgdiscountnum', 'serial', '',        '', '', '',
@@ -5925,6 +6007,9 @@ sub tables_hashref {
         'unsuspend_pkgpart', 'int',  'NULL', '', '', '',
         'unsuspend_hold','char',    'NULL', 1, '', '',
         'unused_credit', 'char',    'NULL', 1, '', '',
+        'feepart',        'int', 'NULL', '', '', '',
+        'fee_on_unsuspend','char',  'NULL', 1, '', '',
+        'fee_hold',      'char',    'NULL', 1, '', '',
       ],
       'primary_key'  => 'reasonnum',
       'unique'       => [],