show credit balance on invoices, #11564
[freeside.git] / FS / FS / part_tag.pm
1 package FS::part_tag;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::part_tag - Object methods for part_tag records
10
11 =head1 SYNOPSIS
12
13   use FS::part_tag;
14
15   $record = new FS::part_tag \%hash;
16   $record = new FS::part_tag { '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::part_tag object represents a tag.  FS::part_tag inherits from
29 FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item tagnum
34
35 primary key
36
37 =item tagname
38
39 tagname
40
41 =item tagdesc
42
43 tagdesc
44
45 =item tagcolor
46
47 tagcolor
48
49
50 =back
51
52 =head1 METHODS
53
54 =over 4
55
56 =item new HASHREF
57
58 Creates a new tag.  To add the tag to the database, see L<"insert">.
59
60 Note that this stores the hash reference, not a distinct copy of the hash it
61 points to.  You can ask the object for a copy with the I<hash> method.
62
63 =cut
64
65 # the new method can be inherited from FS::Record, if a table method is defined
66
67 sub table { 'part_tag'; }
68
69 =item insert
70
71 Adds this record to the database.  If there is an error, returns the error,
72 otherwise returns false.
73
74 =cut
75
76 # the insert method can be inherited from FS::Record
77
78 =item delete
79
80 Delete this record from the database.
81
82 =cut
83
84 # the delete method can be inherited from FS::Record
85
86 =item replace OLD_RECORD
87
88 Replaces the OLD_RECORD with this one in the database.  If there is an error,
89 returns the error, otherwise returns false.
90
91 =cut
92
93 # the replace method can be inherited from FS::Record
94
95 =item check
96
97 Checks all fields to make sure this is a valid tag.  If there is
98 an error, returns the error, otherwise returns false.  Called by the insert
99 and replace methods.
100
101 =cut
102
103 # the check method should currently be supplied - FS::Record contains some
104 # data checking routines
105
106 sub check {
107   my $self = shift;
108
109   my $error = 
110     $self->ut_numbern('tagnum')
111     || $self->ut_text('tagname')
112     || $self->ut_textn('tagdesc')
113     || $self->ut_textn('tagcolor')
114     || $self->ut_enum('disabled', [ '', 'Y' ] )
115   ;
116   return $error if $error;
117
118   $self->SUPER::check;
119 }
120
121 =back
122
123 =head1 BUGS
124
125 =head1 SEE ALSO
126
127 L<FS::Record>, schema.html from the base documentation.
128
129 =cut
130
131 1;
132