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.
55 Creates a new completed invoice event. To add the compelted invoice event to
56 the database, see L<"insert">.
58 Note that this stores the hash reference, not a distinct copy of the hash it
59 points to. You can ask the object for a copy with the I<hash> method.
63 # the new method can be inherited from FS::Record, if a table method is defined
65 sub table { 'cust_bill_event'; }
69 Adds this record to the database. If there is an error, returns the error,
70 otherwise returns false.
74 # the insert method can be inherited from FS::Record
78 Delete this record from the database.
82 # the delete method can be inherited from FS::Record
84 =item replace OLD_RECORD
86 Replaces the OLD_RECORD with this one in the database. If there is an error,
87 returns the error, otherwise returns false.
91 # the replace method can be inherited from FS::Record
95 Checks all fields to make sure this is a valid completed invoice event. If
96 there is an error, returns the error, otherwise returns false. Called by the
97 insert and replace methods.
101 # the check method should currently be supplied - FS::Record contains some
102 # data checking routines
107 my $error = $self->ut_numbern('eventnum')
108 || $self->ut_number('invnum')
109 || $self->ut_number('eventpart')
110 || $self->ut_number('_date')
111 || $self->ut_enum('status', [qw( done failed )])
112 || $self->ut_textn('statustext')
115 return "Unknown invnum ". $self->invnum
116 unless qsearchs( 'cust_bill' ,{ 'invnum' => $self->invnum } );
118 return "Unknown eventpart ". $self->eventpart
119 unless qsearchs( 'part_bill_event' ,{ 'eventpart' => $self->eventpart } );
124 =item part_bill_event
126 Returns the invoice event definition (see L<FS::part_bill_event>) for this
127 completed invoice event.
131 sub part_bill_event {
133 qsearchs( 'part_bill_event', { 'eventpart' => $self->eventpart } );
138 Returns the invoice (see L<FS::cust_bill>) for this completed invoice event.
144 qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
149 Changes the status of this event from B<done> to B<failed>, allowing it to be
156 return '' unless $self->status eq 'done';
157 my $old = ref($self)->new( { $self->hash } );
158 $self->status('failed');
159 $self->replace($old);
166 Far too early in the morning.
170 L<FS::part_bill_event>, L<FS::cust_bill>, L<FS::Record>, schema.html from the