1 package FS::cust_bill_void;
2 use base qw( FS::Template_Mixin FS::cust_main_Mixin FS::otaker_Mixin FS::Record );
5 use FS::Record qw( qsearch qsearchs );
7 use FS::cust_statement;
9 use FS::cust_bill_pkg_void;
13 FS::cust_bill_void - Object methods for cust_bill_void records
17 use FS::cust_bill_void;
19 $record = new FS::cust_bill_void \%hash;
20 $record = new FS::cust_bill_void { '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_void object represents a voided invoice. FS::cust_bill_void
33 inherits from FS::Record. The following fields are currently supported:
57 =item previous_balance
102 Creates a new voided invoice. To add the voided invoice to the database, see L<"insert">.
104 Note that this stores the hash reference, not a distinct copy of the hash it
105 points to. You can ask the object for a copy with the I<hash> method.
109 sub table { 'cust_bill_void'; }
110 sub notice_name { 'VOIDED Invoice'; }
111 #XXXsub template_conf { 'quotation_'; }
115 Adds this record to the database. If there is an error, returns the error,
116 otherwise returns false.
120 # the insert method can be inherited from FS::Record
124 Delete this record from the database.
128 # the delete method can be inherited from FS::Record
130 =item replace OLD_RECORD
132 Replaces the OLD_RECORD with this one in the database. If there is an error,
133 returns the error, otherwise returns false.
137 # the replace method can be inherited from FS::Record
141 Checks all fields to make sure this is a valid voided invoice. If there is
142 an error, returns the error, otherwise returns false. Called by the insert
147 # the check method should currently be supplied - FS::Record contains some
148 # data checking routines
154 $self->ut_number('invnum')
155 || $self->ut_foreign_key('custnum', 'cust_main', 'custnum' )
156 || $self->ut_numbern('_date')
157 || $self->ut_money('charged')
158 || $self->ut_textn('invoice_terms')
159 || $self->ut_moneyn('previous_balance')
160 || $self->ut_moneyn('billing_balance')
161 || $self->ut_enum('closed', [ '', 'Y' ])
162 || $self->ut_foreign_keyn('statementnum', 'cust_statement', 'statementnum')
163 || $self->ut_numbern('agent_invid')
164 || $self->ut_numbern('promised_date')
165 || $self->ut_numbern('void_date')
166 || $self->ut_textn('reason')
167 || $self->ut_numbern('void_usernum')
169 return $error if $error;
171 $self->void_date(time) unless $self->void_date;
173 $self->void_usernum($FS::CurrentUser::CurrentUser->usernum)
174 unless $self->void_usernum;
181 Returns the displayed invoice number for this invoice: agent_invid if
182 cust_bill-default_agent_invid is set and it has a value, invnum otherwise.
188 my $conf = $self->conf;
189 if ( $conf->exists('cust_bill-default_agent_invid') && $self->agent_invid ){
190 return $self->agent_invid;
192 return $self->invnum;
196 =item void_access_user
198 Returns the voiding employee object (see L<FS::access_user>).
202 sub void_access_user {
204 qsearchs('access_user', { 'usernum' => $self->void_usernum } );
213 qsearchs('cust_main', { 'custnum' => $self->custnum } );
220 sub cust_bill_pkg { #actually cust_bill_pkg_void objects
222 qsearch('cust_bill_pkg_void', { invnum=>$self->invnum });
227 =item enable_previous
231 sub enable_previous { 0 }
240 L<FS::Record>, schema.html from the base documentation.