more schema changes: part_bill_event and cust_bill_event tables
[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 disabled - Disabled flag, empty or `Y'
48
49 =back
50
51 =head1 METHODS
52
53 =over 4
54
55 =item new HASHREF
56
57 Creates a new invoice event definition.  To add the example to the database,
58 see L<"insert">.
59
60 Note that this stores the hash reference, not a distinct copy of the hash it
61 points to.  You can ask the object for a copy with the I<hash> method.
62
63 =cut
64
65 # the new method can be inherited from FS::Record, if a table method is defined
66
67 sub table { 'part_bill_event'; }
68
69 =item insert
70
71 Adds this record to the database.  If there is an error, returns the error,
72 otherwise returns false.
73
74 =cut
75
76 # the insert method can be inherited from FS::Record
77
78 =item delete
79
80 Delete this record from the database.
81
82 =cut
83
84 # the delete method can be inherited from FS::Record
85
86 =item replace OLD_RECORD
87
88 Replaces the OLD_RECORD with this one in the database.  If there is an error,
89 returns the error, otherwise returns false.
90
91 =cut
92
93 # the replace method can be inherited from FS::Record
94
95 =item check
96
97 Checks all fields to make sure this is a valid invoice event definition.  If
98 there is an error, returns the error, otherwise returns false.  Called by the
99 insert and replace methods.
100
101 =cut
102
103 # the check method should currently be supplied - FS::Record contains some
104 # data checking routines
105
106 sub check {
107   my $self = shift;
108
109   $self->ut_numbern('eventpart')
110     || $self->ut_enum('payby', [qw( CARD BILL COMP )] )
111     || $self->ut_text('event')
112     || $self->ut_anything('eventcode')
113     || $self->ut_number('seconds')
114     || $self->ut_enum('disabled', [ '', 'Y' ] )
115   ;
116 }
117
118 =back
119
120 =head1 BUGS
121
122 Alas.
123
124 =head1 SEE ALSO
125
126 L<FS::cust_bill>, L<FS::cust_bill_event>, L<FS::Record>, schema.html from the
127 base documentation.
128
129 =cut
130
131 1;
132