summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2010-09-19 03:02:09 +0000
committerivan <ivan>2010-09-19 03:02:09 +0000
commit71863412e2d2fd3c48c9c1220e6bf49122db270b (patch)
treee1c0eb967c28884db5902cc5ed6d5668a73a9e0a /FS
parent7863d7a397e90a07d0d5139fa3de872651cc9ac6 (diff)
another (hopefully significant) billing optimization, RT#6802
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/part_event/Condition.pm22
-rw-r--r--FS/FS/part_event/Condition/payby.pm16
2 files changed, 27 insertions, 11 deletions
diff --git a/FS/FS/part_event/Condition.pm b/FS/FS/part_event/Condition.pm
index ddd8a616f..90b83853e 100644
--- a/FS/FS/part_event/Condition.pm
+++ b/FS/FS/part_event/Condition.pm
@@ -306,6 +306,28 @@ sub condition_sql_option {
)";
}
+#c.f. part_event_condition_option.pm / part_event_condition_option_option
+#used for part_event/Condition/payby.pm
+sub condition_sql_option_option {
+ my( $class, $option ) = @_;
+
+ ( my $condname = $class ) =~ s/^.*:://;
+
+ my $optionnum =
+ "( SELECT optionnum FROM part_event_condition_option
+ WHERE part_event_condition_option.eventconditionnum =
+ cond_$condname.eventconditionnum
+ AND part_event_condition_option.optionname = '$option'
+ AND part_event_condition_option.optionvalue = 'HASH'
+ )";
+
+ "( SELECT optionname FROM part_event_condition_option_option
+ WHERE optionnum = $optionnum
+ )";
+
+}
+
+
=item condition_sql_option_age_from OPTION FROM_TIMESTAMP
This is a class method that returns an SQL fragment that will retreive a
diff --git a/FS/FS/part_event/Condition/payby.pm b/FS/FS/part_event/Condition/payby.pm
index d93156828..16bf48003 100644
--- a/FS/FS/part_event/Condition/payby.pm
+++ b/FS/FS/part_event/Condition/payby.pm
@@ -30,21 +30,15 @@ sub condition {
my $cust_main = $self->cust_main($object);
- #uuh.. all right? test this.
my $hashref = $self->option('payby') || {};
$hashref->{ $cust_main->payby };
}
-#sub condition_sql {
-# my( $self, $table ) = @_;
-#
-# #uuh... yeah... something like this. test it for sure.
-#
-# my @payby = keys %{ $self->option('payby') };
-#
-# ' ( '. join(' OR ', map { "cust_main.payby = '$_'" } @payby ). ' ) ';
-#
-#}
+sub condition_sql {
+ my( $self, $table ) = @_;
+
+ 'cust_main.payby IN '. $self->condition_sql_option_option('payby');
+}
1;