diff options
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/AccessRight.pm | 1 | ||||
| -rw-r--r-- | FS/FS/Cron/bill.pm | 7 | ||||
| -rw-r--r-- | FS/FS/Cron/notify.pm | 5 | ||||
| -rw-r--r-- | FS/FS/Schema.pm | 1 | ||||
| -rw-r--r-- | FS/FS/cust_main.pm | 2 | ||||
| -rw-r--r-- | FS/FS/cust_pkg.pm | 28 | 
6 files changed, 31 insertions, 13 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index f67614aac..7a8bfc2c4 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -106,6 +106,7 @@ assigned to users and/or groups.    'Edit customer package dates',    'Customize customer package',    'Suspend customer package', +  'Suspend customer package later',    'Unsuspend customer package',    'Cancel customer package immediately',    'Cancel customer package later', diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm index 967e6a8d8..e6c0c067d 100644 --- a/FS/FS/Cron/bill.pm +++ b/FS/FS/Cron/bill.pm @@ -34,6 +34,7 @@ sub bill {                and (    setup is null or setup =  0                      or bill  is null or bill  <= $time                       or ( expire is not null and expire <= $^T ) +                    or ( adjourn is not null and adjourn <= $^T )                    )          )  END @@ -91,8 +92,10 @@ END      }      # $^T not $time because -d is for pre-printing invoices      foreach my $cust_pkg ( -      grep { $_->part_pkg->is_prepaid -             && $_->bill && $_->bill < $^T && ! $_->susp +      grep { (    $_->part_pkg->is_prepaid && $_->bill && $_->bill < $^T +               || $_->adjourn && $_->adjourn <= $^T +             ) +             && ! $_->susp             }             $cust_main->ncancelled_pkgs      ) { diff --git a/FS/FS/Cron/notify.pm b/FS/FS/Cron/notify.pm index 371065094..622f15f6b 100644 --- a/FS/FS/Cron/notify.pm +++ b/FS/FS/Cron/notify.pm @@ -42,6 +42,11 @@ sub notify_flat_delay {                                  or  cust_pkg.expire > $time                                    + cast(part_pkg_option.optionvalue as integer)                                      * 86400 +/*                            and ( cust_pkg.adjourn is null +                                or  cust_pkg.adjourn > $time +-- Should notify suspended ones   + cast(part_pkg_option.optionvalue as integer) +                                    * 86400 +*/                                    )                          )            ) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index b0677be68..4a7f8ab16 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -650,6 +650,7 @@ sub tables_hashref {          'bill',      @date_type, '', '',           'last_bill', @date_type, '', '',           'susp',      @date_type, '', '',  +        'adjourn',   @date_type, '', '',           'cancel',    @date_type, '', '',           'expire',    @date_type, '', '',           'manual_flag', 'char', 'NULL', 1, '', '',  diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index ddfdbfcaa..6374b84c9 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -4732,7 +4732,7 @@ sub batch_import {      my %svc_acct = ();      foreach my $field ( @fields ) { -      if ( $field =~ /^cust_pkg\.(pkgpart|setup|bill|susp|expire|cancel)$/ ) { +      if ( $field =~ /^cust_pkg\.(pkgpart|setup|bill|susp|adjourn|expire|cancel)$/ ) {          #$cust_pkg{$1} = str2time( shift @$columns );          if ( $1 eq 'pkgpart' ) { diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 055b87b61..45a5380aa 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -111,6 +111,8 @@ inherits from FS::Record.  The following fields are currently supported:  =item last_bill - last bill date +=item adjourn - date +  =item susp - date  =item expire - date @@ -124,7 +126,7 @@ unsuspension of this package when using the B<unsuspendauto> config file.  =back -Note: setup, bill, susp, expire and cancel are specified as UNIX timestamps; +Note: setup, bill, adjourn, susp, expire and cancel are specified as UNIX timestamps;  see L<perlfunc/"time">.  Also see L<Time::Local> and L<Date::Parse> for  conversion functions. @@ -264,7 +266,7 @@ the customer ever purchased the item.  Instead, see the cancel method.  Replaces the OLD_RECORD with this one in the database.  If there is an error,  returns the error, otherwise returns false. -Currently, custnum, setup, bill, susp, expire, and cancel may be changed. +Currently, custnum, setup, bill, adjourn, susp, expire, and cancel may be changed.  Changing pkgpart may have disasterous effects.  See the order subroutine. @@ -310,13 +312,15 @@ sub replace {    local $FS::UID::AutoCommit = 0;    my $dbh = dbh; -  if ($options{'reason'} && $new->expire && $old->expire ne $new->expire) { -    my $error = $new->insert_reason( 'reason' => $options{'reason'}, -                                     'date'      => $new->expire, -		                    ); -    if ( $error ) { -      dbh->rollback if $oldAutoCommit; -      return "Error inserting cust_pkg_reason: $error"; +  foreach my $method ( qw(adjourn expire) ) {  # How many reasons? +    if ($options{'reason'} && $new->$method && $old->$method ne $new->$method) { +      my $error = $new->insert_reason( 'reason' => $options{'reason'}, +                                       'date'      => $new->$method, +                                     ); +      if ( $error ) { +        dbh->rollback if $oldAutoCommit; +        return "Error inserting cust_pkg_reason: $error"; +      }      }    } @@ -377,6 +381,8 @@ sub check {      || $self->ut_numbern('bill')      || $self->ut_numbern('susp')      || $self->ut_numbern('cancel') +    || $self->ut_numbern('adjourn') +    || $self->ut_numbern('expire')    ;    return $error if $error; @@ -601,7 +607,8 @@ sub suspend {  =item unsuspend [ OPTION => VALUE ... ]  Unsuspends all services (see L<FS::cust_svc> and L<FS::part_svc>) in this -package, then unsuspends the package itself (clears the susp field). +package, then unsuspends the package itself (clears the susp field and the +adjourn field if it is in the past).  Available options are: I<adjust_next_bill>. @@ -666,6 +673,7 @@ sub unsuspend {        && $inactive > 0 && ( $hash{'bill'} || $hash{'setup'} );      $hash{'susp'} = ''; +    $hash{'adjourn'} = '' if $hash{'adjourn'} < time;      my $new = new FS::cust_pkg ( \%hash );      $error = $new->replace( $self, options => { $self->options } );      if ( $error ) {  | 
