summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Report/FCC_477.pm3
-rw-r--r--FS/FS/Report/Table.pm7
-rw-r--r--FS/FS/cust_pkg.pm70
-rw-r--r--FS/FS/part_event/Condition/has_cust_payby_auto.pm1
-rw-r--r--FS/FS/part_pkg/bulk.pm2
-rw-r--r--FS/FS/part_pkg/bulk_Common.pm24
-rw-r--r--FS/FS/part_pkg/bulk_simple.pm2
7 files changed, 79 insertions, 30 deletions
diff --git a/FS/FS/Report/FCC_477.pm b/FS/FS/Report/FCC_477.pm
index c93c919ea..75ddee0d7 100644
--- a/FS/FS/Report/FCC_477.pm
+++ b/FS/FS/Report/FCC_477.pm
@@ -400,7 +400,8 @@ sub fbs_sql {
my @select = (
"$censustract AS censustract",
- 'technology',
+ '(technology - technology % 10) AS media_type',
+ # media types are multiples of 10
'broadband_downstream',
'broadband_upstream',
"SUM($q)",
diff --git a/FS/FS/Report/Table.pm b/FS/FS/Report/Table.pm
index 69686df9b..479747307 100644
--- a/FS/FS/Report/Table.pm
+++ b/FS/FS/Report/Table.pm
@@ -495,12 +495,17 @@ sub _cust_bill_pkg_recurring {
my @where = (
'(pkgnum != 0 OR feepart IS NOT NULL)',
- $self->with_classnum($opt{'classnum'}, $opt{'use_override'}),
$self->with_report_option(%opt),
$self->with_refnum(%opt),
$self->with_cust_classnum(%opt)
);
+ my $where_classnum = $self->with_classnum($opt{'classnum'}, $opt{'use_override'});
+ if ($opt{'project'}) {
+ $where_classnum =~ s/\bcust_bill_pkg/v_cust_bill_pkg/g;
+ }
+ push @where, $where_classnum;
+
if ( $opt{'distribute'} ) {
$where[0] = 'pkgnum != 0'; # specifically exclude fees
push @where, "cust_main.agentnum = $agentnum" if $agentnum;
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 7678a0295..b64d4dc38 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -784,6 +784,10 @@ to a different pkgpart or location, and probably shouldn't be in any other
case. If it's not set, the 'unused_credit_cancel' part_pkg option will
be used.
+=item delay_cancel - for internal use, to allow proper handling of
+supplemental packages when the main package is flagged to suspend
+before cancelling
+
=back
If there is an error, returns the error, otherwise returns false.
@@ -823,7 +827,7 @@ sub cancel {
my $date = $options{'date'} if $options{'date'}; # expire/cancel later
$date = '' if ($date && $date <= $cancel_time); # complain instead?
- my $delay_cancel = undef;
+ my $delay_cancel = $options{'delay_cancel'};
if ( !$date && $self->part_pkg->option('delay_cancel',1)
&& (($self->status eq 'active') || ($self->status eq 'suspended'))
) {
@@ -901,14 +905,13 @@ sub cancel {
return $error;
}
}
-
} #unless $date
my %hash = $self->hash;
if ( $date ) {
$hash{'expire'} = $date;
if ($delay_cancel) {
- $hash{'susp'} = $cancel_time unless $self->susp;
+ # just to be sure these are clear
$hash{'adjourn'} = undef;
$hash{'resume'} = undef;
}
@@ -935,22 +938,31 @@ sub cancel {
}
foreach my $supp_pkg ( $self->supplemental_pkgs ) {
- if ($delay_cancel) {
- $error = $supp_pkg->suspend(%options, 'from_main' => 1, 'reason' => undef);
- } else {
- $error = $supp_pkg->cancel(%options, 'from_main' => 1);
- }
+ $error = $supp_pkg->cancel(%options,
+ 'from_main' => 1,
+ 'date' => $date, #in case it got changed by delay_cancel
+ 'delay_cancel' => $delay_cancel,
+ );
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return "canceling supplemental pkg#".$supp_pkg->pkgnum.": $error";
}
}
- foreach my $usage ( $self->cust_pkg_usage ) {
- $error = $usage->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "deleting usage pools: $error";
+ if ($delay_cancel && !$options{'from_main'}) {
+ $error = $new->suspend(
+ 'from_cancel' => 1,
+ 'time' => $cancel_time
+ );
+ }
+
+ unless ($date) {
+ foreach my $usage ( $self->cust_pkg_usage ) {
+ $error = $usage->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "deleting usage pools: $error";
+ }
}
}
@@ -1249,6 +1261,9 @@ separately.
=item from_main - allows a supplemental package to be suspended, rather
than redirecting the method call to its main package. For internal use.
+=item from_cancel - used when suspending from the cancel method, forces
+this to skip everything besides basic suspension. For internal use.
+
=back
If there is an error, returns the error, otherwise returns false.
@@ -1291,7 +1306,7 @@ sub suspend {
}
# some false laziness with sub cancel
- if ( !$options{nobill} && !$date &&
+ if ( !$options{nobill} && !$date && !$options{'from_cancel'} &&
$self->part_pkg->option('bill_suspend_as_cancel',1) ) {
# kind of a kludge--'bill_suspend_as_cancel' to avoid having to
# make the entire cust_main->bill path recognize 'suspend' and
@@ -1356,17 +1371,19 @@ sub suspend {
unless ( $date ) { # then we are suspending now
- # credit remaining time if appropriate
- # (if required by the package def, or the suspend reason)
- my $unused_credit = $self->part_pkg->option('unused_credit_suspend',1)
- || ( defined($reason) && $reason->unused_credit );
+ unless ($options{'from_cancel'}) {
+ # credit remaining time if appropriate
+ # (if required by the package def, or the suspend reason)
+ my $unused_credit = $self->part_pkg->option('unused_credit_suspend',1)
+ || ( defined($reason) && $reason->unused_credit );
- if ( $unused_credit ) {
- warn "crediting unused time on pkg#".$self->pkgnum."\n" if $DEBUG;
- my $error = $self->credit_remaining('suspend', $suspend_time);
- if ($error) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
+ if ( $unused_credit ) {
+ warn "crediting unused time on pkg#".$self->pkgnum."\n" if $DEBUG;
+ my $error = $self->credit_remaining('suspend', $suspend_time);
+ if ($error) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
}
}
@@ -1397,7 +1414,7 @@ sub suspend {
}
my $conf = new FS::Conf;
- if ( $conf->config('suspend_email_admin') ) {
+ if ( $conf->config('suspend_email_admin') && !$options{'from_cancel'} ) {
my $error = send_email(
'from' => $conf->config('invoice_from', $self->cust_main->agentnum),
@@ -3381,6 +3398,9 @@ really the whole point of the delay_cancel option.
sub is_status_delay_cancel {
my ($self) = @_;
+ if ( $self->main_pkgnum and $self->pkglinknum ) {
+ return $self->main_pkg->is_status_delay_cancel;
+ }
return 0 unless $self->part_pkg->option('delay_cancel',1);
return 0 unless $self->status eq 'suspended';
return 0 unless $self->expire;
diff --git a/FS/FS/part_event/Condition/has_cust_payby_auto.pm b/FS/FS/part_event/Condition/has_cust_payby_auto.pm
index edfb7eccb..dce97df8f 100644
--- a/FS/FS/part_event/Condition/has_cust_payby_auto.pm
+++ b/FS/FS/part_event/Condition/has_cust_payby_auto.pm
@@ -3,6 +3,7 @@ package FS::part_event::Condition::has_cust_payby_auto;
use strict;
use Tie::IxHash;
use FS::payby;
+use FS::Record qw(qsearch);
use base qw( FS::part_event::Condition );
diff --git a/FS/FS/part_pkg/bulk.pm b/FS/FS/part_pkg/bulk.pm
index 4a55858de..bc42e20d2 100644
--- a/FS/FS/part_pkg/bulk.pm
+++ b/FS/FS/part_pkg/bulk.pm
@@ -27,7 +27,7 @@ $me = '[FS::part_pkg::bulk]';
sub _bulk_cust_svc {
my( $self, $cust_pkg, $sdate ) = @_;
# END START
- $cust_pkg->h_cust_svc( $$sdate, $cust_pkg->last_bill );
+ return $self->_only_svcs_filter($cust_pkg->h_cust_svc( $$sdate, $cust_pkg->last_bill ));
}
sub _bulk_setup {
diff --git a/FS/FS/part_pkg/bulk_Common.pm b/FS/FS/part_pkg/bulk_Common.pm
index 67f2caf44..a9231bc5c 100644
--- a/FS/FS/part_pkg/bulk_Common.pm
+++ b/FS/FS/part_pkg/bulk_Common.pm
@@ -5,6 +5,7 @@ use strict;
use vars qw($DEBUG $me %info);
use Date::Format;
use FS::Conf;
+use FS::Record qw(qsearchs);
$DEBUG = 0;
$me = '[FS::part_pkg::bulk_Common]';
@@ -23,8 +24,17 @@ $me = '[FS::part_pkg::bulk_Common]';
'instead of a detailed list',
'type' => 'checkbox',
},
+ 'only_svcs' => {
+ 'name' => 'Only charge fees for these services',
+ 'type' => 'select_multiple',
+ 'select_table' => 'part_svc',
+ 'select_key' => 'svcpart',
+ 'select_label' => 'svc',
+ 'disable_empty' => 1,
+ 'parse' => sub { @_ }, #should this be the default in /edit/process/part_pkg.cgi?
+ },
},
- 'fieldorder' => [ 'svc_setup_fee', 'svc_recur_fee',
+ 'fieldorder' => [ 'svc_setup_fee', 'svc_recur_fee', 'only_svcs',
'summarize_svcs', 'no_prorate' ],
'weight' => 51,
);
@@ -123,5 +133,17 @@ sub is_free_options {
sub can_usageprice { 0; }
+sub _only_svcs_filter {
+ my ($self, @cust_svc) = @_;
+ my @only_svcs = split(', ',$self->option('only_svcs',1));
+ if (@only_svcs) {
+ @cust_svc = grep {
+ my $svcpart = $_->svcpart;
+ grep(/^$svcpart$/,@only_svcs);
+ } @cust_svc;
+ }
+ return @cust_svc;
+}
+
1;
diff --git a/FS/FS/part_pkg/bulk_simple.pm b/FS/FS/part_pkg/bulk_simple.pm
index 93944cc0a..6ed125022 100644
--- a/FS/FS/part_pkg/bulk_simple.pm
+++ b/FS/FS/part_pkg/bulk_simple.pm
@@ -18,7 +18,7 @@ $me = '[FS::part_pkg::bulk]';
sub _bulk_cust_svc {
my( $self, $cust_pkg, $sdate ) = @_;
- $cust_pkg->cust_svc;
+ return $self->_only_svcs_filter($cust_pkg->cust_svc);
}
sub _bulk_setup {