From: ivan Date: Sun, 19 Sep 2010 03:02:09 +0000 (+0000) Subject: another (hopefully significant) billing optimization, RT#6802 X-Git-Tag: TORRUS_1_0_9~297 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=71863412e2d2fd3c48c9c1220e6bf49122db270b another (hopefully significant) billing optimization, RT#6802 --- 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;