summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorjeff <jeff>2006-10-19 14:29:27 +0000
committerjeff <jeff>2006-10-19 14:29:27 +0000
commitce98306f315a53f2ac4b8c010341c4f84bf728a8 (patch)
tree284731e6ad5daf4580b3afdfa3812a864e136b89 /FS
parentcdffa6e5fe5c8cf0755a3f3497ae71170bbe4cea (diff)
suspension and cancellation reasons
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_pkg_reason.pm122
-rw-r--r--FS/FS/reason.pm (renamed from FS/FS/cancel_reason.pm)51
-rw-r--r--FS/FS/reason_type.pm135
-rw-r--r--FS/t/cust_pkg_reason.t5
-rw-r--r--FS/t/reason.t (renamed from FS/t/cancel_reason.t)2
-rw-r--r--FS/t/reason_type.t5
6 files changed, 294 insertions, 26 deletions
diff --git a/FS/FS/cust_pkg_reason.pm b/FS/FS/cust_pkg_reason.pm
new file mode 100644
index 0000000..2f92740
--- /dev/null
+++ b/FS/FS/cust_pkg_reason.pm
@@ -0,0 +1,122 @@
+package FS::cust_pkg_reason;
+
+use strict;
+use vars qw( @ISA );
+use FS::Record qw( qsearch qsearchs );
+
+@ISA = qw(FS::Record);
+
+=head1 NAME
+
+FS::cust_pkg_reason - Object methods for cust_pkg_reason records
+
+=head1 SYNOPSIS
+
+ use FS::cust_pkg_reason;
+
+ $record = new FS::cust_pkg_reason \%hash;
+ $record = new FS::cust_pkg_reason { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::cust_pkg_reason object represents a relationship between a cust_pkg
+and a reason, for example cancellation or suspension reasons.
+FS::cust_pkg_reason inherits from FS::Record. The following fields are
+currently supported:
+
+=over 4
+
+=item num - primary key
+
+=item pkgnum -
+
+=item reasonnum -
+
+=item otaker -
+
+=item date -
+
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new cust_pkg_reason. 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
+
+sub table { 'cust_pkg_reason'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+=item delete
+
+Delete this record from the database.
+
+=cut
+
+=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
+
+=item check
+
+Checks all fields to make sure this is a valid cust_pkg_reason. If there is
+an error, returns the error, otherwise returns false. Called by the insert
+and replace methods.
+
+=cut
+
+sub check {
+ my $self = shift;
+
+ my $error =
+ $self->ut_numbern('num')
+ || $self->ut_number('pkgnum')
+ || $self->ut_number('reasonnum')
+ || $self->ut_text('otaker')
+ || $self->ut_numbern('date')
+ ;
+ return $error if $error;
+
+ $self->SUPER::check;
+}
+
+=back
+
+=head1 BUGS
+
+Here be termites. Don't use on wooden computers.
+
+=head1 SEE ALSO
+
+L<FS::Record>, schema.html from the base documentation.
+
+=cut
+
+1;
+
diff --git a/FS/FS/cancel_reason.pm b/FS/FS/reason.pm
index 19cc721..b2d2e9d 100644
--- a/FS/FS/cancel_reason.pm
+++ b/FS/FS/reason.pm
@@ -1,4 +1,4 @@
-package FS::cancel_reason;
+package FS::reason;
use strict;
use vars qw( @ISA );
@@ -8,14 +8,14 @@ use FS::Record qw( qsearch qsearchs );
=head1 NAME
-FS::cancel_reason - Object methods for cancel_reason records
+FS::reason - Object methods for reason records
=head1 SYNOPSIS
- use FS::cancel_reason;
+ use FS::reason;
- $record = new FS::cancel_reason \%hash;
- $record = new FS::cancel_reason { 'column' => 'value' };
+ $record = new FS::reason \%hash;
+ $record = new FS::reason { 'column' => 'value' };
$error = $record->insert;
@@ -27,17 +27,19 @@ FS::cancel_reason - Object methods for cancel_reason records
=head1 DESCRIPTION
-An FS::cancel_reason object represents an cancellation reason.
-FS::cancel_reason inherits from FS::Record. The following fields are
-currently supported:
+An FS::reason object represents a reason message. FS::reason inherits from
+FS::Record. The following fields are currently supported:
=over 4
=item reasonnum - primary key
-=item reason -
+=item reason_type - index into FS::reason_type
+
+=item reason - text of the reason
+
+=item disabled - 'Y' or ''
-=item disabled - empty or "Y"
=back
@@ -47,17 +49,14 @@ currently supported:
=item new HASHREF
-Creates a new cancellation reason. To add the reason to the database, see
-L<"insert">.
+Creates a new reason. 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 { 'cancel_reason'; }
+sub table { 'reason'; }
=item insert
@@ -66,16 +65,12 @@ 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,
@@ -83,8 +78,6 @@ 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 reason. If there is
@@ -93,26 +86,34 @@ and replace methods.
=cut
-# the check method should currently be supplied - FS::Record contains some
-# data checking routines
-
sub check {
my $self = shift;
my $error =
$self->ut_numbern('reasonnum')
|| $self->ut_text('reason')
- || $self->ut_enum('disabled', [ '', 'Y' ] )
;
return $error if $error;
$self->SUPER::check;
}
+=item reasontype
+
+Returns the reason_type (see <I>FS::reason_type</I>) associated with this reason.
+
+=cut
+
+sub reasontype {
+ qsearchs( 'reason_type', { 'typenum' => shift->reason_type } );
+}
+
=back
=head1 BUGS
+Here be termintes. Don't use on wooden computers.
+
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
diff --git a/FS/FS/reason_type.pm b/FS/FS/reason_type.pm
new file mode 100644
index 0000000..89278d0
--- /dev/null
+++ b/FS/FS/reason_type.pm
@@ -0,0 +1,135 @@
+package FS::reason_type;
+
+use strict;
+use vars qw( @ISA );
+use FS::Record qw( qsearch qsearchs );
+
+@ISA = qw(FS::Record);
+
+=head1 NAME
+
+FS::reason_type - Object methods for reason_type records
+
+=head1 SYNOPSIS
+
+ use FS::reason_type;
+
+ $record = new FS::reason_type \%hash;
+ $record = new FS::reason_type { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::reason_type object represents a grouping of reasons. FS::reason_type
+inherits from FS::Record. The following fields are currently supported:
+
+=over 4
+
+=item typenum - primary key
+
+=item class - currently 'C' or 'S' for cancel or suspend
+
+=item type - name of the type of reason
+
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new reason_type. 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
+
+sub table { 'reason_type'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+=item delete
+
+Delete this record from the database.
+
+=cut
+
+=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
+
+=item check
+
+Checks all fields to make sure this is a valid reason_type. If there is
+an error, returns the error, otherwise returns false. Called by the insert
+and replace methods.
+
+=cut
+
+sub check {
+ my $self = shift;
+
+ my $error =
+ $self->ut_numbern('typenum')
+ || $self->ut_enum('class', [ 'C', 'S' ] )
+ || $self->ut_text('type')
+ ;
+ return $error if $error;
+
+ $self->SUPER::check;
+}
+
+=item reasons
+
+Returns a list of all reasons associated with this type.
+
+=cut
+
+sub reasons {
+ qsearch( 'reason', { 'reason_type' => shift->typenum } );
+}
+
+=item enabled_reasons
+
+Returns a list of enabled reasons associated with this type.
+
+=cut
+
+sub enabled_reasons {
+ qsearch( 'reason', { 'reason_type' => shift->typenum,
+ 'enabled' => '',
+ } );
+}
+
+=back
+
+=head1 BUGS
+
+Here be termintes. Don't use on wooden computers.
+
+=head1 SEE ALSO
+
+L<FS::Record>, schema.html from the base documentation.
+
+=cut
+
+1;
+
diff --git a/FS/t/cust_pkg_reason.t b/FS/t/cust_pkg_reason.t
new file mode 100644
index 0000000..2f0a4fa
--- /dev/null
+++ b/FS/t/cust_pkg_reason.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::cust_pkg_reason;
+$loaded=1;
+print "ok 1\n";
diff --git a/FS/t/cancel_reason.t b/FS/t/reason.t
index a5948f6..d5e4dc9 100644
--- a/FS/t/cancel_reason.t
+++ b/FS/t/reason.t
@@ -1,5 +1,5 @@
BEGIN { $| = 1; print "1..1\n" }
END {print "not ok 1\n" unless $loaded;}
-use FS::cancel_reason;
+use FS::reason;
$loaded=1;
print "ok 1\n";
diff --git a/FS/t/reason_type.t b/FS/t/reason_type.t
new file mode 100644
index 0000000..279d5b9
--- /dev/null
+++ b/FS/t/reason_type.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::reason_type;
+$loaded=1;
+print "ok 1\n";