X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_event_condition.pm;h=200049da7a4f339bb0af9929a27a4c788d8f9dcf;hp=ac2ee822c889454e9db5ad6367950ddeaa27d04e;hb=a4d4d3df88b33a6db30b565921f6d62efb252351;hpb=6615733676adb431ae48c78ce24758fe571614c1 diff --git a/FS/FS/part_event_condition.pm b/FS/FS/part_event_condition.pm index ac2ee822c..200049da7 100644 --- a/FS/FS/part_event_condition.pm +++ b/FS/FS/part_event_condition.pm @@ -354,6 +354,45 @@ sub order_conditions_sql { } +sub _upgrade_data { #class method + my ($class, %opts) = @_; + + foreach my $part_event_condition ( + qsearch('part_event_condition', { 'conditionname' => 'payby' } ) + ) { + + my $payby = $part_event_condition->option('payby'); + + if ( scalar( keys %$payby ) == 1 ) { + + if ( $payby->{'CARD'} ) { + + $part_event_condition->conditionname('has_cust_payby_auto'); + + } elsif ( $payby->{'CHEK'} ) { + + $part_event_condition->conditionname('has_cust_payby_auto'); + + } + + } elsif ( $payby->{'BILL'} && ! $payby->{'CARD'} && ! $payby->{'CHEK'} ) { + + $part_event_condition->conditionname('hasnt_cust_payby_auto'); + + } else { + + die 'Unable to automatically convert payby condition for event #'. + $part_event_condition->eventpart. "\n"; + + } + + my $error = $part_event_condition->replace; + die $error if $error; + + } + +} + =back =head1 BUGS