correctly void invoices with fees, #32862
[freeside.git] / FS / FS / Schema.pm
index 378a521..a048d3e 100644 (file)
@@ -947,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',
                           },
@@ -1078,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',     '',      '', '', '',
@@ -1119,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' ],
+                          #},
                         ],
     },
 
@@ -1150,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' ],
+                          #},
                         ],
     },
 
@@ -1177,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, '', '', 
@@ -1286,10 +1301,10 @@ sub tables_hashref {
                           { 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' ],
+                          #},
                         ],
     },