schema changes for proper texas tax
authorivan <ivan>
Sat, 4 May 2002 15:00:18 +0000 (15:00 +0000)
committerivan <ivan>
Sat, 4 May 2002 15:00:18 +0000 (15:00 +0000)
12 files changed:
FS/FS.pm
FS/FS/cust_main_county.pm
FS/FS/cust_tax_exempt.pm [new file with mode: 0644]
FS/FS/part_pkg.pm
FS/MANIFEST
FS/t/cust_tax_exempt.pm [new file with mode: 0644]
README.1.4.0pre12
bin/fs-setup
httemplate/docs/admin.html
httemplate/docs/schema.dia
httemplate/docs/schema.html
httemplate/docs/upgrade8.html

index 287e50c..3a9c9f3 100644 (file)
--- a/FS/FS.pm
+++ b/FS/FS.pm
@@ -48,6 +48,8 @@ L<FS::part_referral> - Referral class
 
 L<FS::cust_main_county> - Locale (tax rate) class
 
+L<FS::cust_tax_exempt> - Tax exemption record class
+
 L<FS::svc_Common> - Service base class
 
 L<FS::svc_acct> - Account (shell, RADIUS, POP3) class
index 56d29da..a9a4a85 100644 (file)
@@ -57,6 +57,10 @@ currently supported:
 
 =item tax - percentage
 
+=item taxclass
+
+=item exempt_amount
+
 =back
 
 =head1 METHODS
@@ -97,11 +101,15 @@ methods.
 sub check {
   my $self = shift;
 
+  $self->amount(0) unless $self->amount;
+
   $self->ut_numbern('taxnum')
     || $self->ut_textn('state')
     || $self->ut_textn('county')
     || $self->ut_text('country')
     || $self->ut_float('tax')
+    || $self->ut_textn('taxclass') # ...
+    || $self->ut_money('amount')
   ;
 
 }
diff --git a/FS/FS/cust_tax_exempt.pm b/FS/FS/cust_tax_exempt.pm
new file mode 100644 (file)
index 0000000..ab873c0
--- /dev/null
@@ -0,0 +1,131 @@
+package FS::cust_tax_exempt;
+
+use strict;
+use vars qw( @ISA );
+use FS::Record qw( qsearch qsearchs );
+
+@ISA = qw(FS::Record);
+
+=head1 NAME
+
+FS::cust_tax_exempt - Object methods for cust_tax_exempt records
+
+=head1 SYNOPSIS
+
+  use FS::cust_tax_exempt;
+
+  $record = new FS::cust_tax_exempt \%hash;
+  $record = new FS::cust_tax_exempt { 'column' => 'value' };
+
+  $error = $record->insert;
+
+  $error = $new_record->replace($old_record);
+
+  $error = $record->delete;
+
+  $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::cust_tax_exempt object represents a historical record of a customer tax
+exemption.  Currently this is only used for "texas tax".  FS::cust_tax_exempt
+inherits from FS::Record.  The following fields are currently supported:
+
+=over 4
+
+=item exemptnum - primary key
+
+=item custnum - customer (see L<FS::cust_main>)
+
+=item taxnum - tax rate (see L<FS::cust_main_county>)
+
+=item year
+
+=item month
+
+=item amount
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new exemption record.  To add the example to the database, see
+L<"insert">.
+
+Note that this stores the hash reference, not a distinct copy of the hash it
+points to.  You can ask the object for a copy with the I<hash> method.
+
+=cut
+
+# the new method can be inherited from FS::Record, if a table method is defined
+
+sub table { 'cust_tax_exempt'; }
+
+=item insert
+
+Adds this record to the database.  If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+# the insert method can be inherited from FS::Record
+
+=item delete
+
+Delete this record from the database.
+
+=cut
+
+# the delete method can be inherited from FS::Record
+
+=item replace OLD_RECORD
+
+Replaces the OLD_RECORD with this one in the database.  If there is an error,
+returns the error, otherwise returns false.
+
+=cut
+
+# the replace method can be inherited from FS::Record
+
+=item check
+
+Checks all fields to make sure this is a valid example.  If there is
+an error, returns the error, otherwise returns false.  Called by the insert
+and replace methods.
+
+=cut
+
+# the check method should currently be supplied - FS::Record contains some
+# data checking routines
+
+sub check {
+  my $self = shift;
+
+  $self->ut_numbern('exemptnum')
+    || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
+    || $self->ut_foreign_key('taxnum', 'cust_main_county', 'taxnum')
+    || $self->ut_number('year') #check better
+    || $self->ut_number('month') #check better
+    || $self->ut_money('amount')
+  ;
+}
+
+=back
+
+=head1 BUGS
+
+Texas tax is a royal pain in the ass.
+
+=head1 SEE ALSO
+
+L<FS::cust_main_county>, L<FS::cust_main>, L<FS::Record>, schema.html from the
+base documentation.
+
+=cut
+
+1;
+
index 8ab8ad4..1f31065 100644 (file)
@@ -235,7 +235,7 @@ sub check {
       || $self->ut_anything('plandata')
       || $self->ut_enum('setuptax', [ '', 'Y' ] )
       || $self->ut_enum('recurtax', [ '', 'Y' ] )
-      || $self->ut_enum('texastax', [ '', 'none', 'access', 'hosting' ] )
+      || $self->ut_enum('taxclass', [ '', 'none', 'access', 'hosting' ] )
       || $self->ut_enum('disabled', [ '', 'Y' ] )
     ;
 }
@@ -297,7 +297,7 @@ sub payby {
 
 =head1 VERSION
 
-$Id: part_pkg.pm,v 1.12 2002-04-25 10:37:08 ivan Exp $
+$Id: part_pkg.pm,v 1.13 2002-05-04 15:00:18 ivan Exp $
 
 =head1 BUGS
 
index 86516e3..2e72d5a 100644 (file)
@@ -79,6 +79,7 @@ FS/radius_usergroup.pm
 FS/queue.pm
 FS/queue_arg.pm
 FS/msgcat.pm
+FS/cust_tax_exempt.pm
 t/agent.t
 t/agent_type.t
 t/CGI.t
@@ -136,3 +137,4 @@ t/queue.t
 t/queue_arg.t
 t/msgcat.t
 t/raddb.t
+t/cust_tax_exempt.t
diff --git a/FS/t/cust_tax_exempt.pm b/FS/t/cust_tax_exempt.pm
new file mode 100644 (file)
index 0000000..8af13e3
--- /dev/null
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::cust_tax_exempt;
+$loaded=1;
+print "ok 1\n";
index 7de0619..8b883d4 100644 (file)
@@ -44,6 +44,21 @@ CREATE INDEX export_svc3 ON export_svc ( svcpart );
 
 ALTER TABLE part_export RENAME svcpart TO deprecated;
 
+ALTER TABLE part_pkg ADD taxclass varchar(80) NULL;
+
+CREATE TABLE cust_tax_exempt (
+  exemptnum int primary key,
+  custnum int not null,
+  taxnum int not null,
+  year int not null,
+  month int not null,
+  amount decimal(10,2)
+);
+CREATE UNIQUE INDEX cust_tax_exempt1 ON cust_tax_exempt ( custnum, taxnum, year, month );
+
+ALTER TABLE cust_main_county ADD taxclass varchar(80) NULL;
+ALTER TABLE cust_main_county ADD exempt_amount decimal(10,2);
+
 Run bin/dbdef-create
 
 Run bin/create-history-tables
index 37ecf1b..e05d445 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: fs-setup,v 1.89 2002-04-20 06:33:03 ivan Exp $
+# $Id: fs-setup,v 1.90 2002-05-04 15:00:18 ivan Exp $
 
 #to delay loading dbdef until we're ready
 BEGIN { $FS::Record::setup_hack = 1; }
@@ -518,6 +518,8 @@ sub tables_hash_hack {
         'state',    'varchar',  'NULL',    $char_d,
         'county',   'varchar',  'NULL',    $char_d,
         'country',  'char',  '', 2, 
+        'taxclass',   'varchar', 'NULL', $char_d,
+        'exempt_amount', @money_type,
         'tax',      'real',  '',    '', #tax %
       ],
       'primary_key' => 'taxnum',
@@ -659,6 +661,7 @@ sub tables_hash_hack {
         'plan',       'varchar', 'NULL', $char_d,
         'plandata',   'text', 'NULL', '',
         'disabled',   'char', 'NULL', 1,
+        'taxclass',   'varchar', 'NULL', $char_d,
       ],
       'primary_key' => 'pkgpart',
       'unique' => [ [] ],
@@ -989,6 +992,22 @@ sub tables_hash_hack {
       'index'       => [],
     },
 
+    'cust_tax_exempt' => {
+      'columns' => [
+        'exemptnum', 'int', '', '',
+        'custnum',   'int', '', '',
+        'taxnum',    'int', '', '',
+        'year',      'int', '', '',
+        'month',     'int', '', '',
+        'amount',   @money_type,
+      ],
+      'primary_key' => 'exemptnum',
+      'unique'      => [ [ 'custnum', 'taxnum', 'year', 'month' ] ],
+      'index'       => [],
+    },
+
+
+
   );
 
   %tables;
index 0093fd2..50beafe 100755 (executable)
@@ -12,7 +12,7 @@
   "your_host" with the name or network address of your web server.
   <li>Select <u>Configuration</u> from the main menu and update your configuration values.
   <li>Next you must create a service definition.  An example of a service
-  definition would be a dial-up account or a domain.  For starters, it is
+  definition would be a dial-up account or a domain.  First, it is
   necessary to create a domain definition.  Click on <u>View/Edit service
   definitions</u> and <u>Add a new service definition</u> with <i>Table</i>
   <b>svc_domain</b> (and no modifiers).
index 4a54652..148c1df 100644 (file)
Binary files a/httemplate/docs/schema.dia and b/httemplate/docs/schema.dia differ
index 07fcb90..3f62744 100644 (file)
@@ -47,6 +47,7 @@
         <li>plan - eventcode plan
         <li>plandata - additional plan data
         <li>disabled - Disabled flag, empty or `Y'
+        <li>taxclass - Texas tax class flag, empty or "none", "access", or "hosting"
       </ul>
     <li><a name="cust_bill_pkg" href="man/FS/cust_bill_pkg.html">cust_bill_pkg</a> - Invoice line items
       <ul>
         <li>county
         <li>country
         <li>tax - % rate
+        <li>taxclass
+        <li>exempt_amount
+      </ul>
+    <li><a name="cust_tax_exempt" href="man/FS/cust_tax_exempt.html">cust_tax_exempt</a> - Tax exemption record
+      <ul>
+        <li>exemptnum - primary key
+        <li>taxnum - <a href="#cust_main_county">tax rate</a>
+        <li>year
+        <li>month
+        <li>amount
       </ul>
     <li><a name="cust_pay" href="man/FS/cust_pay.html">cust_pay</a> - Payments.  Money being transferred from a customer.
       <ul>
index 841a053..97758fd 100644 (file)
@@ -195,6 +195,16 @@ CREATE TABLE msgcat (
 );
 CREATE INDEX msgcat1 ON msgcat ( msgcode, locale );
 
+CREATE TABLE cust_tax_exempt (
+  exemptnum int primary key,
+  custnum int not null,
+  taxnum int not null,
+  year int not null,
+  month int not null,
+  amount decimal(10,2)
+);
+CREATE UNIQUE INDEX cust_tax_exempt1 ON cust_tax_exempt ( taxnum, year, month );
+
 ALTER TABLE svc_acct ADD domsvc integer NOT NULL;
 ALTER TABLE svc_domain ADD catchall integer NULL;
 ALTER TABLE cust_main ADD referral_custnum integer NULL;
@@ -215,6 +225,9 @@ ALTER TABLE cust_refund ADD closed char(1) NULL;
 ALTER TABLE cust_bill_event ADD status varchar(80);
 ALTER TABLE cust_bill_event ADD statustext text NULL;
 ALTER TABLE svc_acct ADD sec_phrase varchar(80) NULL;
+ALTER TABLE part_pkg ADD taxclass varchar(80) NULL;
+ALTER TABLE cust_main_county ADD taxclass varchar(80) NULL;
+ALTER TABLE cust_main_county ADD exempt_amount decimal(10,2);
 CREATE INDEX cust_main3 ON cust_main ( referral_custnum );
 CREATE INDEX cust_credit_bill1 ON cust_credit_bill ( crednum );
 CREATE INDEX cust_credit_bill2 ON cust_credit_bill ( invnum );