Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorMark Wells <mark@freeside.biz>
Fri, 18 Sep 2015 17:18:16 +0000 (10:18 -0700)
committerMark Wells <mark@freeside.biz>
Fri, 18 Sep 2015 17:18:16 +0000 (10:18 -0700)
FS/FS/rate.pm
bin/cust_main-bulk_change
httemplate/edit/process/rate_detail.html
httemplate/elements/select-tower_sector.html
httemplate/view/cust_main/billing.html

index 8ee9a83..03dde04 100644 (file)
@@ -469,8 +469,11 @@ sub process {
     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 );
 
index 32a6d7b..e039012 100755 (executable)
@@ -1,7 +1,7 @@
 #!/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);
@@ -9,7 +9,7 @@ use FS::cust_main;
 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;
@@ -64,6 +64,11 @@ while (<STDIN>) {
     }
   }
 
+  if ( $opt_c ) {
+    my @error = $cust_main->cancel( 'reason' => $opt_c );
+    die join(' / ', @error). "\n" if @error;
+  }
+
 }
 
 sub usage {
@@ -76,7 +81,7 @@ cust_main-bulk_change
 
 =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
 
@@ -90,6 +95,8 @@ Command-line tool to make bulk changes to a group of customers.
 
 -k: old_pkgpart:new_pkgpart, for example, I<5:4>.  Multiple entries can be comma-separated.
 
+-c: Cancel customer
+
 user: Employee username
 
 =head1 BUGS
index 0709d50..f8a7444 100644 (file)
@@ -12,7 +12,6 @@ die "access denied"
 
 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;
index 59b0163..458bcdd 100644 (file)
@@ -11,6 +11,7 @@
 <& /elements/select-table.html,
     table       => 'tower',
     name_col    => 'towername',
+    hashref     => { 'disabled' => '', },
     id          => 'towernum',
     field       => 'towernum',
     onchange    => 'change_towernum(this.value);',
index c031ce9..f7ea68a 100644 (file)
 %       '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