communigate provisioning phase 2: Domain:Account Defaults:Settings: RulesAllowed...
[freeside.git] / FS / FS / cust_tax_adjustment.pm
1 package FS::cust_tax_adjustment;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::cust_main;
7 use FS::cust_bill_pkg;
8
9 =head1 NAME
10
11 FS::cust_tax_adjustment - Object methods for cust_tax_adjustment records
12
13 =head1 SYNOPSIS
14
15   use FS::cust_tax_adjustment;
16
17   $record = new FS::cust_tax_adjustment \%hash;
18   $record = new FS::cust_tax_adjustment { '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::cust_tax_adjustment object represents an taxation adjustment.
31 FS::cust_tax_adjustment inherits from FS::Record.  The following fields are
32 currently supported:
33
34 =over 4
35
36 =item adjustmentnum
37
38 primary key
39
40 =item custnum
41
42 custnum
43
44 =item taxname
45
46 taxname
47
48 =item amount
49
50 amount
51
52 =item comment
53
54 comment
55
56 =item billpkgnum
57
58 billpkgnum
59
60
61 =back
62
63 =head1 METHODS
64
65 =over 4
66
67 =item new HASHREF
68
69 Creates a new record.  To add the record to the database, see L<"insert">.
70
71 Note that this stores the hash reference, not a distinct copy of the hash it
72 points to.  You can ask the object for a copy with the I<hash> method.
73
74 =cut
75
76 # the new method can be inherited from FS::Record, if a table method is defined
77
78 sub table { 'cust_tax_adjustment'; }
79
80 =item insert
81
82 Adds this record to the database.  If there is an error, returns the error,
83 otherwise returns false.
84
85 =cut
86
87 # the insert method can be inherited from FS::Record
88
89 =item delete
90
91 Delete this record from the database.
92
93 =cut
94
95 # the delete method can be inherited from FS::Record
96
97 =item replace OLD_RECORD
98
99 Replaces the OLD_RECORD with this one in the database.  If there is an error,
100 returns the error, otherwise returns false.
101
102 =cut
103
104 # the replace method can be inherited from FS::Record
105
106 =item check
107
108 Checks all fields to make sure this is a valid record.  If there is
109 an error, returns the error, otherwise returns false.  Called by the insert
110 and replace methods.
111
112 =cut
113
114 # the check method should currently be supplied - FS::Record contains some
115 # data checking routines
116
117 sub check {
118   my $self = shift;
119
120   my $error = 
121     $self->ut_numbern('adjustmentnum')
122     || $self->ut_foreign_key('custnum', 'cust_main', 'custnum' )
123     || $self->ut_text('taxname')
124     || $self->ut_money('amount')
125     || $self->ut_textn('comment')
126     || $self->ut_foreign_keyn('billpkgnum', 'cust_bill_pkg', 'billpkgnum' )
127   ;
128   return $error if $error;
129
130   $self->SUPER::check;
131 }
132
133 sub cust_bill_pkg {
134   my $self = shift;
135   qsearchs('cust_bill_pkg', { 'billpkgnum' => $self->billpkgnum } );
136 }
137
138 =back
139
140 =head1 BUGS
141
142 =head1 SEE ALSO
143
144 L<FS::Record>, schema.html from the base documentation.
145
146 =cut
147
148 1;
149