X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FBilling.pm;h=cd1d2bd46e9c6a43c8a1d3cd70466e7272ced053;hb=b7858740e458e761b173f0e38f547c0e2f75b240;hp=96ffe41f4ee935c895c6a4c2fee081aa2cb360fe;hpb=5c9d03cf63378dbca8fc062ed25e781f9c7bb61b;p=freeside.git diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index 96ffe41f4..cd1d2bd46 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -309,7 +309,7 @@ sub bill { return '' if $self->payby eq 'COMP'; - local($DEBUG) = $cust_main::DEBUG if $cust_main::DEBUG > $DEBUG; + local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; warn "$me bill customer ". $self->custnum. "\n" if $DEBUG; @@ -435,8 +435,8 @@ sub bill { next unless @cust_bill_pkg; #don't create an invoice w/o line items - warn "$me billing pass $pass\n". - Dumper(\@cust_bill_pkg)."\n" + warn "$me billing pass $pass\n" + #.Dumper(\@cust_bill_pkg)."\n" if $DEBUG > 2; if ( scalar( grep { $_->recur && $_->recur > 0 } @cust_bill_pkg) || @@ -641,10 +641,10 @@ jurisdictions (i.e. Texas) have tax exemptions which are date sensitive. sub calculate_taxes { my ($self, $cust_bill_pkg, $taxlisthash, $invoice_time) = @_; - local($DEBUG) = $cust_main::DEBUG if $cust_main::DEBUG > $DEBUG; + local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; - warn "$me calculate_taxes\n". - Dumper($self, $cust_bill_pkg, $taxlisthash, $invoice_time). "\n" + warn "$me calculate_taxes\n" + #.Dumper($self, $cust_bill_pkg, $taxlisthash, $invoice_time). "\n" if $DEBUG > 2; my @tax_line_items = (); @@ -720,7 +720,6 @@ sub calculate_taxes { foreach my $tax ( keys %$taxlisthash ) { foreach ( @{ $taxlisthash->{$tax} }[1 ... scalar(@{ $taxlisthash->{$tax} })] ) { next unless ref($_) eq 'FS::cust_bill_pkg'; - push @{ $packagemap{$_->pkgnum}->_cust_tax_exempt_pkg }, splice( @{ $_->_cust_tax_exempt_pkg } ); } @@ -786,7 +785,7 @@ sub calculate_taxes { sub _make_lines { my ($self, %params) = @_; - local($DEBUG) = $cust_main::DEBUG if $cust_main::DEBUG > $DEBUG; + local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; my $part_pkg = $params{part_pkg} or die "no part_pkg specified"; my $cust_pkg = $params{cust_pkg} or die "no cust_pkg specified"; @@ -857,15 +856,14 @@ sub _make_lines { my $recur = 0; my $unitrecur = 0; my $sdate; - if ( ! $cust_pkg->get('susp') - and ! $cust_pkg->get('start_date') - and ( $part_pkg->getfield('freq') ne '0' - && ( $cust_pkg->getfield('bill') || 0 ) <= $time - ) - || ( $part_pkg->plan eq 'voip_cdr' - && $part_pkg->option('bill_every_call') - ) - || ( $options{cancel} ) + if ( ! $cust_pkg->start_date + and ( ! $cust_pkg->susp || $part_pkg->option('suspend_bill') ) + and + ( $part_pkg->freq ne '0' && ( $cust_pkg->bill || 0 ) <= $time ) + || ( $part_pkg->plan eq 'voip_cdr' + && $part_pkg->option('bill_every_call') + ) + || $options{cancel} ) { # XXX should this be a package event? probably. events are called @@ -932,7 +930,7 @@ sub _make_lines { # If $cust_pkg has been modified, update it (if we're a real pkgpart) ### - if ( $lineitems || $options{has_hidden} ) { + if ( $lineitems ) { if ( $cust_pkg->modified && $cust_pkg->pkgpart == $real_pkgpart ) { # hmm.. and if just the options are modified in some weird price plan? @@ -1029,7 +1027,7 @@ sub _handle_taxes { my $real_pkgpart = shift; my $options = shift; - local($DEBUG) = $cust_main::DEBUG if $cust_main::DEBUG > $DEBUG; + local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; my %cust_bill_pkg = (); my %taxes = (); @@ -1049,18 +1047,14 @@ sub _handle_taxes { ) { - if ( $conf->exists('tax-pkg_address') && $cust_pkg->locationnum ) { - return "fatal: Can't (yet) use tax-pkg_address with taxproducts"; - } - foreach my $class (@classes) { - my $err_or_ref = $self->_gather_taxes( $part_pkg, $class ); + my $err_or_ref = $self->_gather_taxes( $part_pkg, $class, $cust_pkg ); return $err_or_ref unless ref($err_or_ref); $taxes{$class} = $err_or_ref; } unless (exists $taxes{''}) { - my $err_or_ref = $self->_gather_taxes( $part_pkg, '' ); + my $err_or_ref = $self->_gather_taxes( $part_pkg, '', $cust_pkg ); return $err_or_ref unless ref($err_or_ref); $taxes{''} = $err_or_ref; } @@ -1227,11 +1221,18 @@ sub _gather_taxes { my $self = shift; my $part_pkg = shift; my $class = shift; + my $cust_pkg = shift; - local($DEBUG) = $cust_main::DEBUG if $cust_main::DEBUG > $DEBUG; + local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; + + my $geocode; + if ( $cust_pkg->locationnum && $conf->exists('tax-pkg_address') ) { + $geocode = $cust_pkg->cust_location->geocode('cch'); + } else { + $geocode = $self->geocode('cch'); + } my @taxes = (); - my $geocode = $self->geocode('cch'); my @taxclassnums = map { $_->taxclassnum } $part_pkg->part_pkg_taxoverride($class); @@ -1310,7 +1311,7 @@ Debugging level. Default is 0 (no debugging), or can be set to 1 (passed-in opt sub collect { my( $self, %options ) = @_; - local($DEBUG) = $cust_main::DEBUG if $cust_main::DEBUG > $DEBUG; + local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; my $invoice_time = $options{'invoice_time'} || time; @@ -1496,7 +1497,7 @@ Debugging level. Default is 0 (no debugging), or can be set to 1 (passed-in opt sub do_cust_event { my( $self, %options ) = @_; - local($DEBUG) = $cust_main::DEBUG if $cust_main::DEBUG > $DEBUG; + local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; my $time = $options{'time'} || time; @@ -1711,7 +1712,7 @@ sub discount_term_values { my $self = shift; my $term = shift; - local($DEBUG) = $cust_main::DEBUG if $cust_main::DEBUG > $DEBUG; + local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; warn "$me discount_term_values called with $term\n" if $DEBUG; @@ -1805,7 +1806,7 @@ sub due_cust_event { #my $DEBUG = $opt{'debug'} local($DEBUG) = $opt{'debug'} if defined($opt{'debug'}) && $opt{'debug'} > $DEBUG; - $DEBUG = $cust_main::DEBUG if $cust_main::DEBUG > $DEBUG; + $DEBUG = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; warn "$me due_cust_event called with options ". join(', ', map { "$_: $opt{$_}" } keys %opt). "\n"