X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=1d234a7657fcf9ce206f93f197bc36b0f002646c;hb=7d0b690f5684cdfdcd68d25568a101f6b088ad98;hp=77e08fe1c373917f3562e4116e655996f69a05d0;hpb=2f0584c5150a5b95556756f9731d70b2a4d37bab;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 77e08fe1c..1d234a765 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,12 @@ sub _handle_taxes { my @taxes = qsearch( 'cust_main_county', \%taxhash ); - unless ( @taxes ) { - $taxhash{'taxclass'} = ''; - @taxes = qsearch( 'cust_main_county', \%taxhash ); - } + my %taxhash_elim = %taxhash; - #one more try at a whole-country tax rate - unless ( @taxes ) { - $taxhash{$_} = '' foreach qw( state county ); - @taxes = qsearch( 'cust_main_county', \%taxhash ); + my @elim = qw( taxclass county state ); + while ( !scalar(@taxes) && scalar(@elim) ) { + $taxhash_elim{ shift(@elim) } = ''; + @taxes = qsearch( 'cust_main_county', \%taxhash_elim ); } if ( $conf->exists('tax-pkg_address') && $cust_pkg->locationnum ) { @@ -2947,16 +2927,6 @@ sub _gather_taxes { }) if scalar(@taxclassnums); - # maybe eliminate this entirely, along with all the 0% records - unless ( @taxes ) { - return - "fatal: can't find tax rate for geocode/taxproduct/pkgpart ". - join('/', $geocode, - $part_pkg->taxproduct_description, - $part_pkg->pkgpart - ); - } - warn "Found taxes ". join(',', map{ ref($_). " ". $_->get($_->primary_key) } @taxes). "\n" if $DEBUG; @@ -7075,7 +7045,7 @@ 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('part_event_condition_option.optionvalue'). " END