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( qsearchs ); #qsearch );
7 use FS::cust_statement;
12 FS::cust_bill_void - Object methods for cust_bill_void records
16 use FS::cust_bill_void;
18 $record = new FS::cust_bill_void \%hash;
19 $record = new FS::cust_bill_void { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::cust_bill_void object represents a voided invoice. FS::cust_bill_void
32 inherits from FS::Record. The following fields are currently supported:
56 =item previous_balance
101 Creates a new voided invoice. To add the voided invoice to the database, see L<"insert">.
103 Note that this stores the hash reference, not a distinct copy of the hash it
104 points to. You can ask the object for a copy with the I<hash> method.
108 sub table { 'cust_bill_void'; }
109 sub notice_name { 'VOIDED Invoice'; }
110 #XXXsub template_conf { 'quotation_'; }
114 Adds this record to the database. If there is an error, returns the error,
115 otherwise returns false.
119 # the insert method can be inherited from FS::Record
123 Delete this record from the database.
127 # the delete method can be inherited from FS::Record
129 =item replace OLD_RECORD
131 Replaces the OLD_RECORD with this one in the database. If there is an error,
132 returns the error, otherwise returns false.
136 # the replace method can be inherited from FS::Record
140 Checks all fields to make sure this is a valid voided invoice. If there is
141 an error, returns the error, otherwise returns false. Called by the insert
146 # the check method should currently be supplied - FS::Record contains some
147 # data checking routines
153 $self->ut_number('invnum')
154 || $self->ut_foreign_key('custnum', 'cust_main', 'custnum' )
155 || $self->ut_numbern('_date')
156 || $self->ut_money('charged')
157 || $self->ut_textn('invoice_terms')
158 || $self->ut_moneyn('previous_balance')
159 || $self->ut_moneyn('billing_balance')
160 || $self->ut_enum('closed', [ '', 'Y' ])
161 || $self->ut_foreign_keyn('statementnum', 'cust_statement', 'statementnum')
162 || $self->ut_numbern('agent_invid')
163 || $self->ut_numbern('promised_date')
164 || $self->ut_numbern('void_date')
165 || $self->ut_textn('reason')
166 || $self->ut_numbern('void_usernum')
168 return $error if $error;
170 $self->void_date(time) unless $self->void_date;
172 $self->void_usernum($FS::CurrentUser::CurrentUser->usernum)
173 unless $self->void_usernum;
180 Returns the displayed invoice number for this invoice: agent_invid if
181 cust_bill-default_agent_invid is set and it has a value, invnum otherwise.
187 my $conf = $self->conf;
188 if ( $conf->exists('cust_bill-default_agent_invid') && $self->agent_invid ){
189 return $self->agent_invid;
191 return $self->invnum;
195 =item void_access_user
197 Returns the voiding employee object (see L<FS::access_user>).
201 sub void_access_user {
203 qsearchs('access_user', { 'usernum' => $self->void_usernum } );
212 L<FS::Record>, schema.html from the base documentation.