summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2002-09-17 00:33:17 +0000
committerivan <ivan>2002-09-17 00:33:17 +0000
commitbc7312f2a83c76674aa3478ba989d6f9fb7a5cb3 (patch)
tree30e78c991c32370c9994295cb87cb18581701c05 /FS
parent3548c2951a51ece84687e3bfb5e435008191a713 (diff)
- "emailinvoiceauto" implementation rewritten to work properly, stop
overwriting existing invoice destinations
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Conf.pm2
-rw-r--r--FS/FS/cust_bill.pm4
-rw-r--r--FS/FS/cust_main.pm25
-rw-r--r--FS/FS/svc_acct.pm15
4 files changed, 33 insertions, 13 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index e93eaf3fc..e50cb29b9 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -369,7 +369,7 @@ httemplate/docs/config.html
{
'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',
},
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index d49657e2e..65c41d5c9 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -623,7 +623,7 @@ sub realtime_card {
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];
@@ -1114,7 +1114,7 @@ sub print_text {
=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
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index cfa6b8bb6..84fd3d150 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -1584,7 +1584,6 @@ sub invoicing_list {
}
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 ( {
@@ -1626,24 +1625,36 @@ sub check_invoicing_list {
'';
}
-=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
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 9032e20c1..f73ab82da 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -341,11 +341,20 @@ sub insert {
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 {