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
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;
}
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 '';
}
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;
}