weight, plan and plandata fields in part_bill_event
[freeside.git] / FS / FS / part_bill_event.pm
1 package FS::part_bill_event;
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::part_bill_event - Object methods for part_bill_event records
12
13 =head1 SYNOPSIS
14
15   use FS::part_bill_event;
16
17   $record = new FS::part_bill_event \%hash;
18   $record = new FS::part_bill_event { '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::part_bill_event object represents an invoice event definition -
31 a callback which is triggered when an invoice is a certain amount of time
32 overdue.  FS::part_bill_event inherits from
33 FS::Record.  The following fields are currently supported:
34
35 =over 4
36
37 =item eventpart - primary key
38
39 =item payby - CARD, BILL, or COMP
40
41 =item event - event name
42
43 =item eventcode - event action
44
45 =item seconds - how long after the invoice date events of this type are triggered
46
47 =item weight - ordering for events with identical seconds
48
49 =item plan - eventcode plan
50
51 =item plandata - additional plan data
52
53 =item disabled - Disabled flag, empty or `Y'
54
55 =back
56
57 =head1 METHODS
58
59 =over 4
60
61 =item new HASHREF
62
63 Creates a new invoice event definition.  To add the example to the database,
64 see L<"insert">.
65
66 Note that this stores the hash reference, not a distinct copy of the hash it
67 points to.  You can ask the object for a copy with the I<hash> method.
68
69 =cut
70
71 # the new method can be inherited from FS::Record, if a table method is defined
72
73 sub table { 'part_bill_event'; }
74
75 =item insert
76
77 Adds this record to the database.  If there is an error, returns the error,
78 otherwise returns false.
79
80 =cut
81
82 # the insert method can be inherited from FS::Record
83
84 =item delete
85
86 Delete this record from the database.
87
88 =cut
89
90 # the delete method can be inherited from FS::Record
91
92 =item replace OLD_RECORD
93
94 Replaces the OLD_RECORD with this one in the database.  If there is an error,
95 returns the error, otherwise returns false.
96
97 =cut
98
99 # the replace method can be inherited from FS::Record
100
101 =item check
102
103 Checks all fields to make sure this is a valid invoice event definition.  If
104 there is an error, returns the error, otherwise returns false.  Called by the
105 insert and replace methods.
106
107 =cut
108
109 # the check method should currently be supplied - FS::Record contains some
110 # data checking routines
111
112 sub check {
113   my $self = shift;
114
115   $self->weight(0) unless $self->weight;
116
117   $self->ut_numbern('eventpart')
118     || $self->ut_enum('payby', [qw( CARD BILL COMP )] )
119     || $self->ut_text('event')
120     || $self->ut_anything('eventcode')
121     || $self->ut_number('seconds')
122     || $self->ut_enum('disabled', [ '', 'Y' ] )
123     || $self->ut_number('weight')
124     || $self->ut_alphan('plan')
125     || $self->ut_anything('plandata')
126   ;
127 }
128
129 =back
130
131 =head1 BUGS
132
133 Alas.
134
135 =head1 SEE ALSO
136
137 L<FS::cust_bill>, L<FS::cust_bill_event>, L<FS::Record>, schema.html from the
138 base documentation.
139
140 =cut
141
142 1;
143