add customer fields option with agent, display_custnum, status and name, RT#73721
[freeside.git] / FS / FS / discount_class.pm
1 package FS::discount_class;
2 use base qw( FS::class_Common );
3
4 use strict;
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::discount_class - Object methods for discount_class records
10
11 =head1 SYNOPSIS
12
13   use FS::discount_class;
14
15   $record = new FS::discount_class \%hash;
16   $record = new FS::discount_class { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::discount_class object represents a discount class.  FS::discount_class
29 inherits from FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item classnum
34
35 primary key
36
37 =item classname
38
39 classname
40
41 =item disabled
42
43 disabled
44
45 =back
46
47 =head1 METHODS
48
49 =over 4
50
51 =item new HASHREF
52
53 Creates a new discount class.  To add the discount class to the database, see
54 L<"insert">.
55
56 Note that this stores the hash reference, not a distinct copy of the hash it
57 points to.  You can ask the object for a copy with the I<hash> method.
58
59 =cut
60
61 sub table { 'discount_class'; }
62
63 =item insert
64
65 Adds this record to the database.  If there is an error, returns the error,
66 otherwise returns false.
67
68 =item delete
69
70 Delete this record from the database.
71
72 =item replace OLD_RECORD
73
74 Replaces the OLD_RECORD with this one in the database.  If there is an error,
75 returns the error, otherwise returns false.
76
77 =item check
78
79 Checks all fields to make sure this is a valid discount class.  If there is
80 an error, returns the error, otherwise returns false.  Called by the insert
81 and replace methods.
82
83 =cut
84
85 sub check {
86   my $self = shift;
87
88   my $error = 
89     $self->ut_numbern('classnum')
90     || $self->ut_text('classname')
91     || $self->ut_enum('disabled', [ '', 'Y' ])
92   ;
93   return $error if $error;
94
95   $self->SUPER::check;
96 }
97
98 =back
99
100 =head1 BUGS
101
102 =head1 SEE ALSO
103
104 L<FS::discount>, L<FS::Record>, schema.html from the base documentation.
105
106 =cut
107
108 1;
109