communigate provisioning phase 2: add svc_domain.trailer -> communigate TrailerText...
[freeside.git] / FS / FS / cust_bill_pkg_display.pm
1 package FS::cust_bill_pkg_display;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record qw( qsearch qsearchs );
6
7 @ISA = qw(FS::Record);
8
9 =head1 NAME
10
11 FS::cust_bill_pkg_display - Object methods for cust_bill_pkg_display records
12
13 =head1 SYNOPSIS
14
15   use FS::cust_bill_pkg_display;
16
17   $record = new FS::cust_bill_pkg_display \%hash;
18   $record = new FS::cust_bill_pkg_display { 'column' => 'value' };
19
20   $error = $record->insert;
21
22   $error = $new_record->replace($old_record);
23
24   $error = $record->delete;
25
26   $error = $record->check;
27
28 =head1 DESCRIPTION
29
30 An FS::cust_bill_pkg_display object represents line item display information.
31 FS::cust_bill_pkg_display inherits from FS::Record.  The following fields are
32 currently supported:
33
34 =over 4
35
36 =item billpkgdisplaynum
37
38 primary key
39
40 =item billpkgnum
41
42 billpkgnum
43
44 =item section
45
46 section
47
48 =cut
49
50 sub section {
51   my ( $self, $value ) = @_;
52   if ( defined($value) ) {
53     $self->setfield('section', $value);
54   } else {
55     my $section = $self->getfield('section');
56     unless ($section) {
57       my $cust_bill_pkg = $self->cust_bill_pkg;
58       if ( $cust_bill_pkg->pkgnum > 0 ) {
59         my $part_pkg = $cust_bill_pkg->part_pkg;
60         $section = $part_pkg->categoryname if $part_pkg;
61       }
62     }
63     $section;
64   }
65 }
66
67 =item post_total
68
69 post_total
70
71 =item type
72
73 type
74
75 =item summary
76
77 summary
78
79 =back
80
81 =head1 METHODS
82
83 =over 4
84
85 =item new HASHREF
86
87 Creates a new line item display object.  To add the record to the database, see L<"insert">.
88
89 Note that this stores the hash reference, not a distinct copy of the hash it
90 points to.  You can ask the object for a copy with the I<hash> method.
91
92 =cut
93
94 sub table { 'cust_bill_pkg_display'; }
95
96 =item insert
97
98 Adds this record to the database.  If there is an error, returns the error,
99 otherwise returns false.
100
101 =cut
102
103 =item delete
104
105 Delete this record from the database.
106
107 =cut
108
109 =item replace OLD_RECORD
110
111 Replaces the OLD_RECORD with this one in the database.  If there is an error,
112 returns the error, otherwise returns false.
113
114 =cut
115
116 =item check
117
118 Checks all fields to make sure this is a valid line item display object.
119 If there is an error, returns the error, otherwise returns false.  Called by
120 the insert and replace methods.
121
122 =cut
123
124 sub check {
125   my $self = shift;
126
127   my $error = 
128     $self->ut_numbern('billpkgdisplaynum')
129     || $self->ut_number('billpkgnum')
130     || $self->ut_foreign_key('billpkgnum', 'cust_bill_pkg', 'billpkgnum')
131     || $self->ut_textn('section')
132     || $self->ut_enum('post_total', [ '', 'Y' ])
133     || $self->ut_enum('type', [ '', 'S', 'R', 'U' ])
134     || $self->ut_enum('summary', [ '', 'Y' ])
135   ;
136   return $error if $error;
137
138   $self->SUPER::check;
139 }
140
141 =item cust_bill_pkg
142
143 Returns the associated cust_bill_pkg (see L<FS::cust_bill_pkg>) for this
144 line item display object.
145
146 =cut
147
148 sub cust_bill_pkg {
149   my $self = shift;
150   qsearchs( 'cust_bill_pkg', { 'billpkgnum' => $self->billpkgnum } ) ;
151 }
152
153 =back
154
155 =head1 BUGS
156
157
158
159 =head1 SEE ALSO
160
161 L<FS::Record>, L<FS::cust_bill_pkg>, schema.html from the base documentation.
162
163 =cut
164
165 1;
166