summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2017-08-01 10:33:45 -0400
committerChristopher Burger <burgerc@freeside.biz>2017-08-03 16:05:41 -0400
commitaf68bdd4980052b8ce8c7b4c9b8547341d556133 (patch)
treed41157679729e3cd6501a50b2cf63ad5b9d5de8f
parent184b8e2c118ef3bd17f36b59f2a3f9690bf3d1bc (diff)
RT# 75595 - Add billing event condition that will trigger when the contract end date is coming up
-rw-r--r--FS/FS/part_event/Condition/pkg_contract_date.pm38
1 files changed, 38 insertions, 0 deletions
diff --git a/FS/FS/part_event/Condition/pkg_contract_date.pm b/FS/FS/part_event/Condition/pkg_contract_date.pm
new file mode 100644
index 000000000..2bf791aba
--- /dev/null
+++ b/FS/FS/part_event/Condition/pkg_contract_date.pm
@@ -0,0 +1,38 @@
+package FS::part_event::Condition::pkg_contract_date;
+use base qw( FS::part_event::Condition );
+
+use strict;
+
+sub description {
+ 'Package contract date nearing';
+}
+
+sub eventtable_hashref {
+ { 'cust_main' => 1,
+ 'cust_bill' => 1,
+ 'cust_pkg' => 1,
+ 'cust_pay' => 1,
+ 'cust_pay_batch' => 1,
+ 'cust_statement' => 1,
+ };
+}
+
+sub option_fields {
+ my $class = shift;
+ (
+ 'within' => { 'label' => 'Package contract date with in',
+ 'type' => 'freq',
+ },
+ );
+}
+
+sub condition {
+ my( $self, $cust_pkg, %opt ) = @_;
+
+ my $contract_end_date = $cust_pkg->contract_end ? $cust_pkg->contract_end : 0;
+ my $contract_within_time = $self->option_age_from('within', $contract_end_date );
+
+ $opt{'time'} >= $contract_within_time and $contract_within_time > 0;
+}
+
+1; \ No newline at end of file