1 package FS::cust_main_invoice;
4 use vars qw(@ISA $conf);
6 use FS::Record; # qw(qsearch qsearchs);
12 my $mydomain = $conf->config('domain');
16 FS::cust_main_invoice - Object methods for cust_main_invoice records
20 use FS::cust_main_invoice;
22 $record = create FS::cust_main_invoice \%hash;
23 $record = create FS::cust_main_invoice { 'column' => 'value' };
25 $error = $record->insert;
27 $error = $new_record->replace($old_record);
29 $error = $record->delete;
31 $error = $record->check;
35 An FS::cust_main_invoice object represents an invoice destination. FS::cust_main_invoice inherits from
36 FS::Record. The following fields are currently supported:
40 =item destnum - primary key
42 =item custnum - customer (see L<FS::cust_main>)
44 =item dest - Invoice destination: If numeric, a <a href="#svc_acct">svcnum</a>, if string, a literal email address, or `POST' to enable mailing (the default if no cust_main_invoice records exist)
54 Creates a new invoice destination. To add the invoice destination to the database, see L<"insert">.
56 Note that this stores the hash reference, not a distinct copy of the hash it
57 points to. You can ask the object for a copy with the I<hash> method.
62 my($proto,$hashref)=@_;
64 $proto->new('cust_main_invoice',$hashref);
70 Adds this record to the database. If there is an error, returns the error,
71 otherwise returns false.
78 #local $SIG{HUP} = 'IGNORE';
79 #local $SIG{INT} = 'IGNORE';
80 #local $SIG{QUIT} = 'IGNORE';
81 #local $SIG{TERM} = 'IGNORE';
82 #local $SIG{TSTP} = 'IGNORE';
90 Delete this record from the database.
100 =item replace OLD_RECORD
102 Replaces the OLD_RECORD with this one in the database. If there is an error,
103 returns the error, otherwise returns false.
109 return "(Old) Not a cust_main_invoice record!" unless $old->table eq "cust_main_invoice";
111 return "Can't change destnum!"
112 unless $old->getfield('destnum') eq $new->getfield('destnum');
113 return "Can't change custnum!"
114 unless $old->getfield('custnum') eq $new->getfield('custnum');
123 Checks all fields to make sure this is a valid invoice destination. If there is
124 an error, returns the error, otherwise returns false. Called by the insert
131 return "Not a cust_main_invoice record!" unless $self->table eq "cust_main_invoice";
133 my $error = $self->ut_number('destnum')
134 or $self->ut_number('custnum')
135 or $self->ut_text('dest')
137 return $error if $error;
139 return "Unknown customer"
140 unless qsearchs('cust_main',{ 'custnum' => $self->custnum });
142 if ( $self->dest eq 'POST' ) {
143 #contemplate our navel
144 } elsif ( $self->dest =~ /^(\d+)$/ ) {
145 return "Unknown local account (specified by svcnum)"
146 unless qsearchs('svc_acct', { 'svcnum' => $self->dest } );
147 } elsif ( $self->dest =~ /^([\w\.\-]+)\@(([\w\.\-]\.)+\w+)$/ ) {
148 my($user, $domain) = ($1, $2);
149 if ( $domain eq $mydomain ) {
150 my $svc_acct = qsearchs('svc_acct', { 'username' => $user } );
151 return "Unknown local account (specified literally)" unless $svc_acct;
152 $svc_acct->svcnum =~ /^(\d+)$/ or die "Non-numeric svcnum?!";
156 return "Illegal destination!";
166 $Id: cust_main_invoice.pm,v 1.1 1998-12-16 07:40:02 ivan Exp $
172 L<FS::Record>, L<FS::cust_main>
176 ivan@voicenet.com 97-jul-1
179 ivan@sisd.com 97-nov-13
181 $Log: cust_main_invoice.pm,v $
182 Revision 1.1 1998-12-16 07:40:02 ivan
185 Revision 1.3 1998/11/15 04:33:00 ivan
186 updates for newest versoin
188 Revision 1.2 1998/11/15 03:48:49 ivan
189 update for current version