X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_pkg.pm;h=5861ee47f0b24c2678cb4e670dafb99e4eb63b0e;hb=88ed72cdd96321a0eeaacc3107da413ab6e9dc98;hp=b6e439552d4cde9a1807c2f873802ec8a7078b00;hpb=f27cc902969814f2c11a49ebaadccc9ca31cfe8d;p=freeside.git diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index b6e439552..5861ee47f 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -820,6 +820,8 @@ quantity. sub _item_discount { my $self = shift; + my %options = @_; + my @pkg_discounts = $self->pkg_discount; return if @pkg_discounts == 0; # special case: if there are old "discount details" on this line item, don't @@ -832,15 +834,20 @@ sub _item_discount { my $d = { _is_discount => 1, description => $self->mt('Discount'), - amount => 0, + setup_amount => 0, + recur_amount => 0, ext_description => \@ext, + pkgpart => $self->pkgpart, + feepart => $self->feepart, # maybe should show quantity/unit discount? }; foreach my $pkg_discount (@pkg_discounts) { push @ext, $pkg_discount->description; - $d->{amount} -= $pkg_discount->amount; + my $setuprecur = $pkg_discount->cust_pkg_discount->setuprecur; + $d->{$setuprecur.'_amount'} -= $pkg_discount->amount; } - $d->{amount} *= $self->quantity || 1; + $d->{setup_amount} *= $self->quantity || 1; # ?? + $d->{recur_amount} *= $self->quantity || 1; # ?? return $d; } @@ -1122,7 +1129,10 @@ sub tax_locationnum { if ( $self->pkgnum ) { # normal sales return $self->cust_pkg->tax_locationnum; } elsif ( $self->feepart ) { # fees - return $self->cust_bill->cust_main->ship_locationnum; + my $custnum = $self->fee_origin->custnum; + if ( $custnum ) { + return FS::cust_main->by_key($custnum)->ship_locationnum; + } } else { # taxes return ''; } @@ -1133,7 +1143,10 @@ sub tax_location { if ( $self->pkgnum ) { # normal sales return $self->cust_pkg->tax_location; } elsif ( $self->feepart ) { # fees - return $self->cust_bill->cust_main->ship_location; + my $custnum = $self->fee_origin->custnum; + if ( $custnum ) { + return FS::cust_main->by_key($custnum)->ship_location; + } } else { # taxes return; } @@ -1275,7 +1288,7 @@ sub upgrade_tax_location { local $FS::cust_location::import = 1; my $conf = FS::Conf->new; # h_conf? - return if $conf->exists('enable_taxproducts'); #don't touch this case + return if $conf->config('tax_data_vendor'); #don't touch this case my $use_ship = $conf->exists('tax-ship_address'); my $use_pkgloc = $conf->exists('tax-pkg_address');