- return '0.00' if $self->{'_NO_RECUR_KLUDGE'};
- my $part_pkg = $self->part_pkg;
- my $recur = $part_pkg->can('base_recur') ? $part_pkg->base_recur($self)
- : $part_pkg->option('recur_fee');
- #XXX discounts
- $recur *= $self->quantity if $self->quantity;
- sprintf('%.2f', $recur);
+ my %options = @_;
+ my $setuprecur = $options{'setuprecur'};
+
+ # kind of silly treating this as multiple records, but it works, and will
+ # work if we allow multiple discounts at some point
+ my @pkg_discounts = $self->pkg_discount;
+ return if @pkg_discounts == 0;
+
+ my @ext;
+ my $d = {
+ _is_discount => 1,
+ description => $self->mt('Discount'),
+ amount => 0,
+ ext_description => \@ext,
+ # maybe should show quantity/unit discount?
+ };
+ foreach my $pkg_discount (@pkg_discounts) {
+ push @ext, $pkg_discount->description;
+ my $amount = $pkg_discount->get($setuprecur.'_amount');
+ $d->{amount} -= $amount;
+ }
+ $d->{amount} = sprintf('%.2f', $d->{amount} * $self->quantity);
+
+ return $d;