{
'key' => 'emailinvoiceauto',
'section' => 'billing',
- 'description' => 'Automatically adds new accounts to the email invoice list upon customer creation',
+ 'description' => 'Automatically adds new accounts to the email invoice list',
'type' => 'checkbox',
},
my @invoicing_list = grep { $_ ne 'POST' } $cust_main->invoicing_list;
if ( $conf->exists('emailinvoiceauto')
|| ( $conf->exists('emailinvoiceonly') && ! @invoicing_list ) ) {
- push @invoicing_list, $cust_main->default_invoicing_list;
+ push @invoicing_list, $cust_main->all_emails;
}
my $email = $invoicing_list[0];
=head1 VERSION
-$Id: cust_bill.pm,v 1.42 2002-09-10 03:31:00 ivan Exp $
+$Id: cust_bill.pm,v 1.43 2002-09-17 00:33:17 ivan Exp $
=head1 BUGS
}
my %seen = map { $_->address => 1 } @cust_main_invoice;
foreach my $address ( @{$arrayref} ) {
- #unless ( grep { $address eq $_->address } @cust_main_invoice ) {
next if exists $seen{$address} && $seen{$address};
$seen{$address} = 1;
my $cust_main_invoice = new FS::cust_main_invoice ( {
'';
}
-=item default_invoicing_list
+=item set_default_invoicing_list
-Sets the invoicing list to all accounts associated with this customer.
+Sets the invoicing list to all accounts associated with this customer,
+overwriting any previous invoicing list.
=cut
-sub default_invoicing_list {
+sub set_default_invoicing_list {
my $self = shift;
- my @list = ();
+ $self->invoicing_list($self->all_emails);
+}
+
+=item all_emails
+
+Returns the email addresses of all accounts provisioned for this customer.
+
+=cut
+
+sub all_emails {
+ my $self = shift;
+ my %list;
foreach my $cust_pkg ( $self->all_pkgs ) {
my @cust_svc = qsearch('cust_svc', { 'pkgnum' => $cust_pkg->pkgnum } );
my @svc_acct =
map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) }
grep { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) }
@cust_svc;
- push @list, map { $_->email } @svc_acct;
+ $list{$_}=1 foreach map { $_->email } @svc_acct;
}
- $self->invoicing_list(\@list);
+ keys %list;
}
=item invoicing_list_addpost
return "queueing job (transaction rolled back): $error";
}
- #welcome email
my $cust_pkg = $self->cust_svc->cust_pkg;
- my( $cust_main, $to ) = ( '', '' );
+ my $cust_main = $cust_pkg->cust_main;
+
+ my $cust_pkg = $self->cust_svc->cust_pkg;
+
+ if ( $conf->exists('emailinvoiceauto') ) {
+ my @invoicing_list = $cust_main->invoicing_list;
+ push @invoicing_list, $self->email;
+ $cust_main->invoicing_list(@invoicing_list);
+ }
+
+ #welcome email
+ my $to = '';
if ( $welcome_template && $cust_pkg ) {
- my $cust_main = $cust_pkg->cust_main;
my $to = join(', ', grep { $_ ne 'POST' } $cust_main->invoicing_list );
if ( $to ) {
my $wqueue = new FS::queue {