summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2006-01-26 15:27:10 +0000
committerivan <ivan>2006-01-26 15:27:10 +0000
commitb782294eb91805f708a7776fe67f1c0863f4096b (patch)
tree3c6987f38b65a72118b8a369869719a12d8cf141 /FS
parentcbbd0225b07269209c674733bcf70f1c1308e84a (diff)
whew, FINALLY can fix monthly exemption columns to work correctly. also make them agent-specific. also fix package exemption columns, they were bunk too, sheesh. start adding package classes for package class tax reporting.
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Schema.pm11
-rw-r--r--FS/FS/cust_tax_exempt_pkg.pm3
-rw-r--r--FS/FS/part_pkg.pm7
-rw-r--r--FS/FS/pkg_class.pm111
-rw-r--r--FS/MANIFEST2
-rw-r--r--FS/t/pkg_class.t5
6 files changed, 138 insertions, 1 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index d502a12be..a0637f50c 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -625,6 +625,7 @@ sub tables_hashref {
'plandata', 'text', 'NULL', '',
'disabled', 'char', 'NULL', 1,
'taxclass', 'varchar', 'NULL', $char_d,
+ 'classnum', 'int', 'NULL', '',
],
'primary_key' => 'pkgpart',
'unique' => [],
@@ -1277,6 +1278,16 @@ sub tables_hashref {
'index' => [ [ 'disabled' ] ],
},
+ 'pkg_class' => {
+ 'columns' => [
+ 'classnum', 'serial', '', '',
+ 'classname', 'varchar', '', $char_d,
+ ],
+ 'primary_key' => 'classnum',
+ 'unique' => [],
+ 'index' => [],
+ },
+
};
}
diff --git a/FS/FS/cust_tax_exempt_pkg.pm b/FS/FS/cust_tax_exempt_pkg.pm
index 7193ace74..28fa24327 100644
--- a/FS/FS/cust_tax_exempt_pkg.pm
+++ b/FS/FS/cust_tax_exempt_pkg.pm
@@ -3,10 +3,11 @@ package FS::cust_tax_exempt_pkg;
use strict;
use vars qw( @ISA );
use FS::Record qw( qsearch qsearchs );
+use FS::cust_main_Mixin;
use FS::cust_bill_pkg;
use FS::cust_main_county;
-@ISA = qw(FS::Record);
+@ISA = qw( FS::cust_main_Mixin FS::Record );
=head1 NAME
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index 73f3bae04..a5e3c2170 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -438,6 +438,13 @@ sub check {
;
return $error if $error;
+ if ( $self->classnum !~ /^$/ ) {
+ my $error = $self->ut_foreign_key('classnum', 'pkg_class', 'classnum');
+ return $error if $error;
+ } else {
+ $self->classnum('');
+ }
+
return 'Unknown plan '. $self->plan
unless exists($plans{$self->plan});
diff --git a/FS/FS/pkg_class.pm b/FS/FS/pkg_class.pm
new file mode 100644
index 000000000..0fa6e4810
--- /dev/null
+++ b/FS/FS/pkg_class.pm
@@ -0,0 +1,111 @@
+package FS::pkg_class;
+
+use strict;
+use vars qw( @ISA );
+use FS::Record qw( qsearch );
+use FS::part_pkg;
+
+@ISA = qw( FS::Record );
+
+=head1 NAME
+
+FS::pkg_class - Object methods for pkg_class records
+
+=head1 SYNOPSIS
+
+ use FS::pkg_class;
+
+ $record = new FS::pkg_class \%hash;
+ $record = new FS::pkg_class { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::pkg_class object represents an package class. Every package definition
+(see L<FS::part_pkg>) has, optionally, a package class. FS::pkg_class inherits
+from FS::Record. The following fields are currently supported:
+
+=over 4
+
+=item classnum - primary key (assigned automatically for new package classes)
+
+=item classname - Text name of this package class
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new package class. To add the package class to the database, see
+L<"insert">.
+
+=cut
+
+sub table { 'pkg_class'; }
+
+=item insert
+
+Adds this package class to the database. If there is an error, returns the
+error, otherwise returns false.
+
+=item delete
+
+Deletes this package class from the database. Only package classes with no
+associated package definitions can be deleted. If there is an error, returns
+the error, otherwise returns false.
+
+=cut
+
+sub delete {
+ my $self = shift;
+
+ return "Can't delete an pkg_class with part_pkg records!"
+ if qsearch( 'part_pkg', { 'classnum' => $self->classnum } );
+
+ $self->SUPER::delete;
+}
+
+=item replace OLD_RECORD
+
+Replaces OLD_RECORD with this one in the database. If there is an error,
+returns the error, otherwise returns false.
+
+=item check
+
+Checks all fields to make sure this is a valid package class. If there is an
+error, returns the error, otherwise returns false. Called by the insert and
+replace methods.
+
+=cut
+
+sub check {
+ my $self = shift;
+
+ $self->ut_numbern('classnum')
+ or $self->ut_text('classname')
+ or $self->SUPER::check;
+
+}
+
+=back
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::Record>, L<FS::part_pkg>, schema.html from the base documentation.
+
+=cut
+
+1;
+
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 54ea52555..c8f10f291 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -125,6 +125,7 @@ FS/part_svc.pm
FS/part_svc_column.pm
FS/part_svc_router.pm
FS/part_virtual_field.pm
+FS/pkg_class.pm
FS/pkg_svc.pm
FS/rate.pm
FS/rate_detail.pm
@@ -258,6 +259,7 @@ t/part_pop_local.t
t/part_referral.t
t/part_svc.t
t/part_svc_column.t
+t/pkg_class.t
t/pkg_svc.t
t/port.t
t/prepay_credit.t
diff --git a/FS/t/pkg_class.t b/FS/t/pkg_class.t
new file mode 100644
index 000000000..fb3774f8c
--- /dev/null
+++ b/FS/t/pkg_class.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::pkg_class;
+$loaded=1;
+print "ok 1\n";