summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorjayce <jayce>2007-09-26 19:27:23 +0000
committerjayce <jayce>2007-09-26 19:27:23 +0000
commit5ca42e2aa31bf595a076f8c6a721c9c74fc51840 (patch)
treee5076a352432231d7ebc04a35d99130e30e06847 /FS
parent84fbfcfd5c664a6c05939b2c79997f16eded5efa (diff)
Initial import.
Condition tests to see if the Invoice bills for a particular service.
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/part_event/Condition/cust_bill_has_service.pm51
1 files changed, 51 insertions, 0 deletions
diff --git a/FS/FS/part_event/Condition/cust_bill_has_service.pm b/FS/FS/part_event/Condition/cust_bill_has_service.pm
new file mode 100644
index 000000000..c28047cdd
--- /dev/null
+++ b/FS/FS/part_event/Condition/cust_bill_has_service.pm
@@ -0,0 +1,51 @@
+package FS::part_event::Condition::cust_bill_has_service;
+
+use strict;
+use FS::cust_bill;
+
+use base qw( FS::part_event::Condition );
+
+sub description {
+ 'Invoice is billing for a certain service type';
+}
+
+sub eventtable_hashref {
+ { 'cust_main' => 0,
+ 'cust_bill' => 1,
+ 'cust_pkg' => 0,
+ };
+}
+
+sub option_fields {
+ (
+ 'has_service' => { 'label' => 'Has service',
+ 'type' => 'select-part_svc',
+ },
+ );
+}
+
+sub condition {
+ #my($self, $cust_bill, %opt) = @_;
+ my($self, $cust_bill) = @_;
+
+ my $servicenum = $self->option('has_service');
+ grep { $servicenum == $_->svcnum }
+ map { $_->cust_pkg->cust_svc }
+ $cust_bill->cust_bill_pkg ;
+}
+
+sub condition_sql {
+ my( $class, $table ) = @_;
+
+ my $servicenum = $class->condition_sql_option('has_service');
+ my $sql = qq| 0 < ( SELECT COUNT(cs.svcpart)
+ FROM cust_bill_pkg cbp, cust_svc cs
+ WHERE cbp.invnum = cust_bill.invnum
+ AND cs.pkgnum = cbp.pkgnum
+ AND cs.svcpart = $servicenum
+ )
+ |;
+ return $sql;
+}
+
+1;