-=item available_discounts
-
-Returns a list of details decribing the available prepayment discounts
-for this package.
-
-=cut
-
-sub available_discounts {
- my $self = shift;
- return if $self->freq ne '1';
- my @details;
- my $money_char = FS::Conf->new->config('money_char') || '$';
- my @discounts = map { $_->discount } $self->part_pkg_discount;
- # probably the most logical way to arrange these
- foreach my $discount (sort { $a->months <=> $b->months } @discounts) {
- my $months = $discount->months;
- my $amount;
- if ( $discount->amount > 0 ) {
- $amount = $money_char . sprintf('%.2f', $discount->amount);
- }
- elsif ( $discount->percent ) {
- $amount = $discount->percent .'%';
- }
- else { #?
- next;
- }
- push @details, "Prepay $months months for $amount discount."
- # better way to display this?
- # if it's a problem, we'll add discount.invoice_text or something
- # for the customer-visible text line.
- }
- return @details;
-}
-
-