=item custnum - customer (see L<FS::cust_main>)
-=item dest - Invoice destination: If numeric, a svcnum (see L<FS::svc_acct>), if string, a literal email address, or `POST' to enable mailing (the default if no cust_main_invoice records exist)
+=item dest - Invoice destination: If numeric, a svcnum (see L<FS::svc_acct>), if string, a literal email address, `POST' to enable mailing (the default if no cust_main_invoice records exist), or `FAX' to enable faxing via a HylaFAX server.
=back
Checks all fields to make sure this is a valid invoice destination. If there is
an error, returns the error, otherwise returns false. Called by the insert
-and repalce methods.
+and replace methods.
=cut
my $error = $self->ut_text('dest');
return $error if $error;
- if ( $self->dest eq 'POST' ) {
+ if ( $self->dest =~ /^(POST|FAX)$/ ) {
#contemplate our navel
} elsif ( $self->dest =~ /^(\d+)$/ ) {
return "Unknown local account (specified by svcnum: ". $self->dest. ")"
unless qsearchs( 'svc_acct', { 'svcnum' => $self->dest } );
- } elsif ( $self->dest =~ /^([\w\.\-\&\+]+)\@(([\w\.\-]+\.)+\w+)$/ ) {
+ } elsif ( $self->dest =~ /^\s*([\w\.\-\&\+]+)\@(([\w\.\-]+\.)+\w+)\s*$/ ) {
my($user, $domain) = ($1, $2);
$self->dest("$1\@$2");
} else {
- return gettext("illegal_email_invoice_address");
+ return gettext("illegal_email_invoice_address"). ': '. $self->dest;
}
''; #no error
=item address
-Returns the literal email address for this record (or `POST').
+Returns the literal email address for this record (or `POST' or `FAX').
=cut
}
}
+=item cust_main
+
+Returns the parent customer object (see L<FS::cust_main>).
+
+=cut
+
+sub cust_main {
+ my $self = shift;
+ qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
+}
+
=back
=head1 BUGS