1 package FS::part_bill_event;
5 use FS::Record qw( qsearch qsearchs );
12 FS::part_bill_event - Object methods for part_bill_event records
16 use FS::part_bill_event;
18 $record = new FS::part_bill_event \%hash;
19 $record = new FS::part_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::part_bill_event object represents an invoice event definition -
32 a callback which is triggered when an invoice is a certain amount of time
33 overdue. FS::part_bill_event inherits from
34 FS::Record. The following fields are currently supported:
38 =item eventpart - primary key
40 =item payby - CARD, CHEK, LECB, BILL, or COMP
42 =item event - event name
44 =item eventcode - event action
46 =item seconds - how long after the invoice date events of this type are triggered
48 =item weight - ordering for events with identical seconds
50 =item plan - eventcode plan
52 =item plandata - additional plan data
54 =item disabled - Disabled flag, empty or `Y'
64 Creates a new invoice event definition. To add the example to the database,
67 Note that this stores the hash reference, not a distinct copy of the hash it
68 points to. You can ask the object for a copy with the I<hash> method.
72 # the new method can be inherited from FS::Record, if a table method is defined
74 sub table { 'part_bill_event'; }
78 Adds this record to the database. If there is an error, returns the error,
79 otherwise returns false.
83 # the insert method can be inherited from FS::Record
87 Delete this record from the database.
91 # the delete method can be inherited from FS::Record
93 =item replace OLD_RECORD
95 Replaces the OLD_RECORD with this one in the database. If there is an error,
96 returns the error, otherwise returns false.
100 # the replace method can be inherited from FS::Record
104 Checks all fields to make sure this is a valid invoice event definition. If
105 there is an error, returns the error, otherwise returns false. Called by the
106 insert and replace methods.
110 # the check method should currently be supplied - FS::Record contains some
111 # data checking routines
116 $self->weight(0) unless $self->weight;
118 my $conf = new FS::Conf;
119 if ( $conf->exists('safe-part_bill_event') ) {
120 my $error = $self->ut_anything('eventcode');
121 return $error if $error;
123 my $c = $self->eventcode;
125 $c =~ /^\s*\$cust_main\->(suspend|cancel|invoicing_list_addpost|bill|collect)\(\);\s*("";)?\s*$/
127 or $c =~ /^\s*\$cust_bill\->(comp|realtime_(card|ach|lec)|realtime_card_cybercash|batch_card|send)\(\);\s*$/
129 or $c =~ /^\s*\$cust_bill\->send\(\'\w+\'\);\s*$/
131 or $c =~ /^\s*\$cust_main\->apply_payments; \$cust_main->apply_credits; "";\s*$/
133 or $c =~ /^\s*\$cust_main\->charge\( \s*\d*\.?\d*\s*,\s*\'[\w \!\@\#\$\%\&\(\)\-\+\;\:\"\,\.\?\/]*\'\s*\);\s*$/
137 return "illegal eventcode: $c";
142 my $error = $self->ut_numbern('eventpart')
143 || $self->ut_enum('payby', [qw( CARD CHEK LECB BILL COMP )] )
144 || $self->ut_text('event')
145 || $self->ut_anything('eventcode')
146 || $self->ut_number('seconds')
147 || $self->ut_enum('disabled', [ '', 'Y' ] )
148 || $self->ut_number('weight')
149 || $self->ut_textn('plan')
150 || $self->ut_anything('plandata')
152 return $error if $error;
155 if ( $self->plandata =~ /^templatename\s+(.*)$/ ) {
157 unless ( $conf->exists("invoice_template_$name") ) {
159 "invoice_template_$name" =>
160 join("\n", $conf->config('invoice_template') )
177 L<FS::cust_bill>, L<FS::cust_bill_event>, L<FS::Record>, schema.html from the