add postal.pm condition, RT#12557
authorivan <ivan>
Mon, 25 Apr 2011 17:36:03 +0000 (17:36 +0000)
committerivan <ivan>
Mon, 25 Apr 2011 17:36:03 +0000 (17:36 +0000)
FS/FS/part_event/Condition/postal.pm [new file with mode: 0644]

diff --git a/FS/FS/part_event/Condition/postal.pm b/FS/FS/part_event/Condition/postal.pm
new file mode 100644 (file)
index 0000000..d0bd419
--- /dev/null
@@ -0,0 +1,26 @@
+package FS::part_event::Condition::postal;
+use base qw( FS::part_event::Condition );
+use strict;
+
+sub description {
+  'Customer receives a postal mail invoice';
+}
+
+sub condition {
+  my( $self, $object ) = @_;
+  my $cust_main = $self->cust_main($object);
+
+  scalar( grep { $_ eq 'POST' } $cust_main->invoicing_list );
+}
+
+sub condition_sql {
+  my( $self, $table ) = @_;
+
+  " EXISTS( SELECT 1 FROM cust_main_invoice
+              WHERE cust_main_invoice.custnum = cust_main.custnum
+                AND cust_main_invoice.dest    = 'POST'
+          )
+  ";
+}
+
+1;