RT# 75595 - Add billing event condition that will trigger when the contract end date...
authorChristopher Burger <burgerc@freeside.biz>
Tue, 1 Aug 2017 14:33:45 +0000 (10:33 -0400)
committerChristopher Burger <burgerc@freeside.biz>
Thu, 3 Aug 2017 20:05:41 +0000 (16:05 -0400)
FS/FS/part_event/Condition/pkg_contract_date.pm [new file with mode: 0644]

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 (file)
index 0000000..2bf791a
--- /dev/null
@@ -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