warn "$rate replacing $old (". $param->{'ratenum'}. ")\n" if $DEBUG;
my @param = ( 'job'=>$job );
- push @param, 'rate_detail'=>\@rate_detail
- unless $param->{'preserve_rate_detail'};
+ if ($param->{'preserve_rate_detail'}) {
+ $rate->default_detailnum($old->default_detailnum);
+ } else {
+ push @param, 'rate_detail'=>\@rate_detail;
+ }
$error = $rate->replace( $old, @param );
#!/usr/bin/perl
use strict;
-use vars qw( $opt_a $opt_p $opt_t $opt_k );
+use vars qw( $opt_a $opt_p $opt_t $opt_k $opt_c );
use Getopt::Std;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch qsearchs);
use FS::cust_tag;
use FS::cust_pkg;
-getopts('a:p:t:k:');
+getopts('a:p:t:k:c:');
my $user = shift or &usage;
adminsuidsetup $user;
}
}
+ if ( $opt_c ) {
+ my @error = $cust_main->cancel( 'reason' => $opt_c );
+ die join(' / ', @error). "\n" if @error;
+ }
+
}
sub usage {
=head1 SYNOPSIS
- cust_main-bulk_change [ -a agentnum ] [ -p NEW_PAYBY ] [ -t tagnum ] [ -k old_pkgpart:new_pkgpart,... ] username <custnums.txt
+ cust_main-bulk_change [ -a agentnum ] [ -p NEW_PAYBY ] [ -t tagnum ] [ -k old_pkgpart:new_pkgpart,... ] [ -c reasonnum ] username <custnums.txt
=head1 DESCRIPTION
-k: old_pkgpart:new_pkgpart, for example, I<5:4>. Multiple entries can be comma-separated.
+-c: Cancel customer
+
user: Employee username
=head1 BUGS
my $set_default_detail = sub {
my ($cgi, $rate_detail) = @_;
-warn Dumper $rate_detail;
if (!$rate_detail->dest_regionnum) {
# then this is a global default rate
my $rate = $rate_detail->rate;
<& /elements/select-table.html,
table => 'tower',
name_col => 'towername',
+ hashref => { 'disabled' => '', },
id => 'towernum',
field => 'towernum',
onchange => 'change_towernum(this.value);',
% 'hashref' => { 'custnum' => $cust_main->custnum, },
% 'extra_sql' => 'AND ( cancel IS NULL OR cancel = 0 )
% AND freq = '. dbh->quote($freq),
+% 'order_by' => 'ORDER BY pkgnum', # to ensure old pkgs come before change_to_pkg
% }) or next;
%
% my $freq_pretty = $cust_pkg[0]->part_pkg->freq_pretty;
%
% my $amount = 0;
+% my $skip_pkg = {};
% foreach my $cust_pkg (@cust_pkg) {
% my $part_pkg = $cust_pkg->part_pkg;
% next if $cust_pkg->susp
% || $cust_pkg->option('no_suspend_bill')
% );
%
+% #pkg change handling
+% next if $skip_pkg->{$cust_pkg->pkgnum};
+% if ($cust_pkg->change_to_pkgnum) {
+% #if change is on or before next bill date, use new pkg
+% next if $cust_pkg->expire <= $cust_pkg->bill;
+% #if change is after next bill date, use old (this) pkg
+% $skip_pkg->{$cust_pkg->change_to_pkgnum} = 1;
+% }
+%
% my $pkg_amount = 0;
%
% #add recurring amounts for this package and its billing add-ons