#resolved by performing a change package instead (which unprovisions) and
#later cancelling
if ( !$options{nobill} && !$date && $conf->exists('bill_usage_on_cancel') ) {
+ my $copy = $self->new({$self->hash});
my $error =
- $self->cust_main->bill( pkg_list => [ $self ], cancel => 1 );
+ $copy->cust_main->bill( pkg_list => [ $copy ], cancel => 1 );
warn "Error billing during cancel, custnum ".
#$self->cust_main->custnum. ": $error"
": $error"
if ( $num > $max_same_services ) {
push @labels, "$label ($num)";
} else {
- push @labels, map { "$label: $_" } @values;
+ if ( $conf->exists('cust_bill-consolidate_services') ) {
+ # push @labels, "$label: ". join(', ', @values);
+ while ( @values ) {
+ my $detail = "$label: ";
+ $detail .= shift(@values). ', '
+ while @values && length($detail.$values[0]) < 78;
+ $detail =~ s/, $//;
+ push @labels, $detail;
+ }
+ } else {
+ push @labels, map { "$label: $_" } @values;
+ }
}
}
=item pkgpart
-list specified how?
+pkgpart or arrayref or hashref of pkgparts
=item setup
"cust_main.agentnum = $1";
}
+ ##
+ # parse custnum
+ ##
+
+ if ( $params->{'custnum'} =~ /^(\d+)$/ and $1 ) {
+ push @where,
+ "cust_pkg.custnum = $1";
+ }
+
##
# parse status
##
# parse part_pkg
###
- my $pkgpart = join (' OR pkgpart=',
- grep {$_} map { /^(\d+)$/; } ($params->{'pkgpart'}));
- push @where, '(pkgpart=' . $pkgpart . ')' if $pkgpart;
+ if ( ref($params->{'pkgpart'}) ) {
+
+ my @pkgpart = ();
+ if ( ref($params->{'pkgpart'}) eq 'HASH' ) {
+ @pkgpart = grep $params->{'pkgpart'}{$_}, keys %{ $params->{'pkgpart'} };
+ } elsif ( ref($params->{'pkgpart'}) eq 'ARRAY' ) {
+ @pkgpart = @{ $params->{'pkgpart'} };
+ } else {
+ die 'unhandled pkgpart ref '. $params->{'pkgpart'};
+ }
+
+ @pkgpart = grep /^(\d+)$/, @pkgpart;
+
+ push @where, 'pkgpart IN ('. join(',', @pkgpart). ')' if scalar(@pkgpart);
+
+ } elsif ( $params->{'pkgpart'} =~ /^(\d+)$/ ) {
+ push @where, "pkgpart = $1";
+ }
###
# parse dates
my $addl_from = 'LEFT JOIN cust_main USING ( custnum ) '.
'LEFT JOIN part_pkg USING ( pkgpart ) '.
- 'LEFT JOIN pkg_class USING ( classnum ) ';
+ 'LEFT JOIN pkg_class ON ( part_pkg.classnum = pkg_class.classnum ) ';
my $count_query = "SELECT COUNT(*) FROM cust_pkg $addl_from $extra_sql";