From: ivan Date: Sat, 4 May 2002 15:00:18 +0000 (+0000) Subject: schema changes for proper texas tax X-Git-Tag: freeside_1_4_0_pre12~9 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=f36b6a178c9811357ff5d5291874aa239d22bc2a;hp=8af9903c96ca6a3d78e7779cbc4c5e773aaf3ae0 schema changes for proper texas tax --- diff --git a/FS/FS.pm b/FS/FS.pm index 287e50c67..3a9c9f336 100644 --- a/FS/FS.pm +++ b/FS/FS.pm @@ -48,6 +48,8 @@ L - Referral class L - Locale (tax rate) class +L - Tax exemption record class + L - Service base class L - Account (shell, RADIUS, POP3) class diff --git a/FS/FS/cust_main_county.pm b/FS/FS/cust_main_county.pm index 56d29da94..a9a4a85bd 100644 --- a/FS/FS/cust_main_county.pm +++ b/FS/FS/cust_main_county.pm @@ -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 index 000000000..ab873c0a7 --- /dev/null +++ b/FS/FS/cust_tax_exempt.pm @@ -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) + +=item taxnum - tax rate (see L) + +=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 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, L, L, schema.html from the +base documentation. + +=cut + +1; + diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 8ab8ad452..1f3106544 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -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 diff --git a/FS/MANIFEST b/FS/MANIFEST index 86516e3d9..2e72d5af8 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -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 index 000000000..8af13e3aa --- /dev/null +++ b/FS/t/cust_tax_exempt.pm @@ -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"; diff --git a/README.1.4.0pre12 b/README.1.4.0pre12 index 7de0619cc..8b883d4df 100644 --- a/README.1.4.0pre12 +++ b/README.1.4.0pre12 @@ -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 diff --git a/bin/fs-setup b/bin/fs-setup index 37ecf1b87..e05d44531 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -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; diff --git a/httemplate/docs/admin.html b/httemplate/docs/admin.html index 0093fd2b7..50beafe78 100755 --- a/httemplate/docs/admin.html +++ b/httemplate/docs/admin.html @@ -12,7 +12,7 @@ "your_host" with the name or network address of your web server.
  • Select Configuration from the main menu and update your configuration values.
  • 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 View/Edit service definitions and Add a new service definition with Table svc_domain (and no modifiers). diff --git a/httemplate/docs/schema.dia b/httemplate/docs/schema.dia index 4a5465285..148c1dfbc 100644 Binary files a/httemplate/docs/schema.dia and b/httemplate/docs/schema.dia differ diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html index 07fcb908e..3f627448f 100644 --- a/httemplate/docs/schema.html +++ b/httemplate/docs/schema.html @@ -47,6 +47,7 @@
  • plan - eventcode plan
  • plandata - additional plan data
  • disabled - Disabled flag, empty or `Y' +
  • taxclass - Texas tax class flag, empty or "none", "access", or "hosting"
  • cust_bill_pkg - Invoice line items
      @@ -130,6 +131,16 @@
    • county
    • country
    • tax - % rate +
    • taxclass +
    • exempt_amount +
    +
  • cust_tax_exempt - Tax exemption record +
      +
    • exemptnum - primary key +
    • taxnum - tax rate +
    • year +
    • month +
    • amount
  • cust_pay - Payments. Money being transferred from a customer.
      diff --git a/httemplate/docs/upgrade8.html b/httemplate/docs/upgrade8.html index 841a053ed..97758fdb2 100644 --- a/httemplate/docs/upgrade8.html +++ b/httemplate/docs/upgrade8.html @@ -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 );