1 package FS::cust_bill_event;
5 use FS::Record qw( qsearch qsearchs );
6 use FS::part_bill_event;
12 FS::cust_bill_event - Object methods for cust_bill_event records
16 use FS::cust_bill_event;
18 $record = new FS::cust_bill_event \%hash;
19 $record = new FS::cust_bill_event { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::cust_bill_event object represents an complete invoice event.
32 FS::cust_bill_event inherits from FS::Record. The following fields are
37 =item eventnum - primary key
39 =item invnum - invoice (see L<FS::cust_bill>)
41 =item eventpart - event definition (see L<FS::part_bill_event>)
43 =item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
44 L<Time::Local> and L<Date::Parse> for conversion functions.
54 Creates a new completed invoice event. To add the compelted invoice event to
55 the database, see L<"insert">.
57 Note that this stores the hash reference, not a distinct copy of the hash it
58 points to. You can ask the object for a copy with the I<hash> method.
62 # the new method can be inherited from FS::Record, if a table method is defined
64 sub table { 'cust_bill_event'; }
68 Adds this record to the database. If there is an error, returns the error,
69 otherwise returns false.
73 # the insert method can be inherited from FS::Record
77 Delete this record from the database.
81 # the delete method can be inherited from FS::Record
83 =item replace OLD_RECORD
85 Replaces the OLD_RECORD with this one in the database. If there is an error,
86 returns the error, otherwise returns false.
90 # the replace method can be inherited from FS::Record
94 Checks all fields to make sure this is a valid completed invoice event. If
95 there is an error, returns the error, otherwise returns false. Called by the
96 insert and replace methods.
100 # the check method should currently be supplied - FS::Record contains some
101 # data checking routines
106 my $error = $self->ut_numbern('eventnum')
107 || $self->ut_number('invnum')
108 || $self->ut_number('eventpart')
109 || $self->ut_number('_date')
110 || $self->ut_enum('status', [qw( done failed )])
111 || $self->ut_textn('statustext')
114 return "Unknown invnum"
115 unless qsearchs( 'cust_bill' ,{ 'invnum' => $self->invnum } );
117 return "Unknown eventpart"
118 unless qsearchs( 'part_bill_event' ,{ 'eventpart' => $self->eventpart } );
123 =item part_bill_event
125 Returns the invoice event definition (see L<FS::part_bill_event>) for this
126 completed invoice event.
130 sub part_bill_event {
132 qsearchs( 'part_bill_event', { 'eventpart' => $self->eventpart } );
137 Returns the invoice (see L<FS::cust_bill>) for this completed invoice event.
143 qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
150 Far too early in the morning.
154 L<FS::part_bill_event>, L<FS::cust_bill>, L<FS::Record>, schema.html from the