X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=038577a9b0844c12eb37cf49b1bf16eef3451435;hb=c8436a358075a901c8d7b3d47919de8c4d6f6f46;hp=7544b80e0dc8f1f577c8f8d91d35acc2ab6e587e;hpb=6397a30ca9f53c90a503da8786925ec75535a699;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 7544b80e0..038577a9b 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -9,7 +9,7 @@ use Safe; use Carp; use Exporter; use Scalar::Util qw( blessed ); -use Time::Local qw(timelocal timelocal_nocheck); +use Time::Local qw(timelocal); use Data::Dumper; use Tie::IxHash; use Digest::MD5 qw(md5_base64); @@ -2662,36 +2662,19 @@ sub _make_lines { if ( $@ ); if ( $increment_next_bill ) { - - #change this bit to use Date::Manip? CAREFUL with timezones (see - # mailing list archive) - my ($sec,$min,$hour,$mday,$mon,$year) = - (localtime($sdate) )[0,1,2,3,4,5]; - #pro-rating magic - if $recur_prog fiddles $sdate, want to use that + my $next_bill = $part_pkg->add_freq($sdate); + return "unparsable frequency: ". $part_pkg->freq + if $next_bill == -1; + + #pro-rating magic - if $recur_prog fiddled $sdate, want to use that # only for figuring next bill date, nothing else, so, reset $sdate again # here $sdate = $cust_pkg->bill || $cust_pkg->setup || $time; #no need, its in $hash{last_bill}# my $last_bill = $cust_pkg->last_bill; $cust_pkg->last_bill($sdate); - if ( $part_pkg->freq =~ /^\d+$/ ) { - $mon += $part_pkg->freq; - until ( $mon < 12 ) { $mon -= 12; $year++; } - } elsif ( $part_pkg->freq =~ /^(\d+)w$/ ) { - my $weeks = $1; - $mday += $weeks * 7; - } elsif ( $part_pkg->freq =~ /^(\d+)d$/ ) { - my $days = $1; - $mday += $days; - } elsif ( $part_pkg->freq =~ /^(\d+)h$/ ) { - my $hours = $1; - $hour += $hours; - } else { - return "unparsable frequency: ". $part_pkg->freq; - } - $cust_pkg->setfield('bill', - timelocal_nocheck($sec,$min,$hour,$mday,$mon,$year)); + $cust_pkg->setfield('bill', $next_bill ); } @@ -2844,15 +2827,24 @@ sub _handle_taxes { my @taxes = qsearch( 'cust_main_county', \%taxhash ); + my %taxhash_elim = %taxhash; + + # no, unexpected change in behavior. + #my @elim = qw( taxclass county state ); + #while ( !scalar(@taxes) && scalar(@elim) ) { + # $taxhash_elim{ shift(@elim) } = ''; + # @taxes = qsearch( 'cust_main_county', \%taxhash_elim ); + #} + + #just try taxclass first, then state+county, not county in the middle unless ( @taxes ) { - $taxhash{'taxclass'} = ''; - @taxes = qsearch( 'cust_main_county', \%taxhash ); + $taxhash_elim{'taxclass'} = ''; + @taxes = qsearch( 'cust_main_county', \%taxhash_elim ); } - #one more try at a whole-country tax rate unless ( @taxes ) { - $taxhash{$_} = '' foreach qw( state county ); - @taxes = qsearch( 'cust_main_county', \%taxhash ); + $taxhash_elim{$_} = '' foreach qw( state county ); + @taxes = qsearch( 'cust_main_county', \%taxhash_elim ); } if ( $conf->exists('tax-pkg_address') && $cust_pkg->locationnum ) { @@ -7057,9 +7049,13 @@ sub _agent_plandata { AND peo_agentnum.optionname = 'agentnum' AND peo_agentnum.optionvalue }. $regexp. q{ '(^|,)}. $agentnum. q{(,|$)' ) - LEFT JOIN part_event_option AS peo_cust_bill_age - ON ( part_event.eventpart = peo_cust_bill_age.eventpart - AND peo_cust_bill_age.optionname = 'cust_bill_age' + LEFT JOIN part_event_condition + ON ( part_event.eventpart = part_event_condition.eventpart + AND part_event_condition.conditionname = 'cust_bill_age' + ) + LEFT JOIN part_event_condition_option + ON ( part_event_condition.eventconditionnum = part_event_condition_option.eventconditionnum + AND part_event_condition_option.optionname = 'age' ) }, #'hashref' => { 'optionname' => $option }, @@ -7071,9 +7067,9 @@ sub _agent_plandata { " AND peo_agentnum.optionname = 'agentnum' ". " AND ( agentnum IS NULL OR agentnum = $agentnum ) ". " ORDER BY - CASE WHEN peo_cust_bill_age.optionname != 'cust_bill_age' + CASE WHEN part_event_condition_option.optionname IS NULL THEN -1 - ELSE ". FS::part_event::Condition->age2seconds_sql('peo_cust_bill_age.optionvalue'). + ELSE ". FS::part_event::Condition->age2seconds_sql('part_event_condition_option.optionvalue'). " END , part_event.weight". " LIMIT 1"