summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorjeff <jeff>2008-09-26 03:54:25 +0000
committerjeff <jeff>2008-09-26 03:54:25 +0000
commitf411189684b0ca7cc1b4b3e9be1895607245b595 (patch)
tree8d219fe11c5554a304b8d6c56407a1922cb370ca /FS
parente2d78a94d7806862da7fcea0025cd380d49d5a75 (diff)
push out event triggered suspensions
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/AccessRight.pm1
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_main.pm16
-rw-r--r--FS/FS/part_bill_event.pm5
-rw-r--r--FS/FS/part_event/Condition/dundate.pm26
5 files changed, 43 insertions, 6 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 9ef35249c..b016d1885 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -119,6 +119,7 @@ tie my %rights, 'Tie::IxHash',
'Unsuspend customer package',
'Cancel customer package immediately',
'Cancel customer package later',
+ 'Delay suspension events',
'Add on-the-fly cancel reason', #NEW
'Add on-the-fly suspend reason', #NEW
'Edit customer package invoice details', #NEW
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index b3cce9a93..5c9f6248c 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -605,6 +605,7 @@ sub tables_hashref {
'stateid_state', 'varchar', 'NULL', $char_d, '', '',
'birthdate' ,@date_type, '', '',
'signupdate',@date_type, '', '',
+ 'dundate', @date_type, '', '',
'company', 'varchar', 'NULL', $char_d, '', '',
'address1', 'varchar', '', $char_d, '', '',
'address2', 'varchar', 'NULL', $char_d, '', '',
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index ec2ac3c61..b348aaa7b 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -227,6 +227,8 @@ Card Verification Value, "CVV2" (also known as CVC2 or CID), the 3 or 4 digit nu
=item spool_cdr - Enable individual CDR spooling, empty or `Y'
+=item dundate - a suggestion to events (see L<FS::part_bill_event">) to delay until this unix timestamp
+
=item squelch_cdr - Discourage individual CDR printing, empty or `Y'
=back
@@ -2976,14 +2978,16 @@ sub due_cust_event {
# 3: insert
##
- foreach my $cust_event ( @cust_event ) {
+ unless( $opt{testonly} ) {
+ foreach my $cust_event ( @cust_event ) {
- my $error = $cust_event->insert();
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
+ my $error = $cust_event->insert();
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
}
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
diff --git a/FS/FS/part_bill_event.pm b/FS/FS/part_bill_event.pm
index 1d48af9fc..4e7aa52f2 100644
--- a/FS/FS/part_bill_event.pm
+++ b/FS/FS/part_bill_event.pm
@@ -5,6 +5,8 @@ use vars qw( @ISA $DEBUG @EXPORT_OK );
use Carp qw(cluck confess);
use FS::Record qw( dbh qsearch qsearchs );
use FS::Conf;
+use FS::cust_main;
+use FS::cust_bill;
@ISA = qw( FS::Record );
@EXPORT_OK = qw( due_events );
@@ -244,6 +246,9 @@ sub due_events {
sort { $a->seconds <=> $b->seconds
|| $a->weight <=> $b->weight
|| $a->eventpart <=> $b->eventpart }
+ grep { ref($record) ne 'FS::cust_bill' || $_->eventcode !~ /honor_dundate/
+ || $event_time > $record->cust_main->dundate
+ }
grep { $_->seconds <= ( $interval )
&& ! qsearch( 'cust_bill_event', {
'invnum' => $record->get($record->dbdef_table->primary_key),
diff --git a/FS/FS/part_event/Condition/dundate.pm b/FS/FS/part_event/Condition/dundate.pm
new file mode 100644
index 000000000..ee2a95f0b
--- /dev/null
+++ b/FS/FS/part_event/Condition/dundate.pm
@@ -0,0 +1,26 @@
+package FS::part_event::Condition::dundate;
+
+use strict;
+
+use base qw( FS::part_event::Condition );
+
+sub description {
+ "Skip until customer dun date is reached";
+}
+
+sub condition {
+ my($self, $object, %opt) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ $cust_main->dundate <= $opt{time};
+
+}
+
+#sub condition_sql {
+# my( $self, $table ) = @_;
+#
+# 'true';
+#}
+
+1;