1 package FS::cust_bill_event;
5 use FS::Record qw( qsearch qsearchs );
7 use FS::part_bill_event;
13 FS::cust_bill_event - Object methods for cust_bill_event records
17 use FS::cust_bill_event;
19 $record = new FS::cust_bill_event \%hash;
20 $record = new FS::cust_bill_event { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
32 An FS::cust_bill_event object represents an complete invoice event.
33 FS::cust_bill_event inherits from FS::Record. The following fields are
38 =item eventnum - primary key
40 =item invnum - invoice (see L<FS::cust_bill>)
42 =item eventpart - event definition (see L<FS::part_bill_event>)
44 =item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
45 L<Time::Local> and L<Date::Parse> for conversion functions.
47 =item status - event status: B<done> or B<failed>
49 =item statustext - additional status detail (i.e. error message)
59 Creates a new completed invoice event. To add the compelted invoice event to
60 the database, see L<"insert">.
62 Note that this stores the hash reference, not a distinct copy of the hash it
63 points to. You can ask the object for a copy with the I<hash> method.
67 # the new method can be inherited from FS::Record, if a table method is defined
69 sub table { 'cust_bill_event'; }
73 Adds this record to the database. If there is an error, returns the error,
74 otherwise returns false.
78 # the insert method can be inherited from FS::Record
82 Delete this record from the database.
86 # the delete method can be inherited from FS::Record
88 =item replace OLD_RECORD
90 Replaces the OLD_RECORD with this one in the database. If there is an error,
91 returns the error, otherwise returns false.
95 # the replace method can be inherited from FS::Record
99 Checks all fields to make sure this is a valid completed invoice event. If
100 there is an error, returns the error, otherwise returns false. Called by the
101 insert and replace methods.
105 # the check method should currently be supplied - FS::Record contains some
106 # data checking routines
111 my $error = $self->ut_numbern('eventnum')
112 || $self->ut_number('invnum')
113 || $self->ut_number('eventpart')
114 || $self->ut_number('_date')
115 || $self->ut_enum('status', [qw( done failed )])
116 || $self->ut_textn('statustext')
119 return "Unknown invnum ". $self->invnum
120 unless qsearchs( 'cust_bill' ,{ 'invnum' => $self->invnum } );
122 return "Unknown eventpart ". $self->eventpart
123 unless qsearchs( 'part_bill_event' ,{ 'eventpart' => $self->eventpart } );
128 =item part_bill_event
130 Returns the invoice event definition (see L<FS::part_bill_event>) for this
131 completed invoice event.
135 sub part_bill_event {
137 qsearchs( 'part_bill_event', { 'eventpart' => $self->eventpart } );
142 Returns the invoice (see L<FS::cust_bill>) for this completed invoice event.
148 qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
153 Changes the status of this event from B<done> to B<failed>, allowing it to be
160 return '' unless $self->status eq 'done';
161 my $old = ref($self)->new( { $self->hash } );
162 $self->status('failed');
163 $self->replace($old);
170 Far too early in the morning.
174 L<FS::part_bill_event>, L<FS::cust_bill>, L<FS::Record>, schema.html from the