use FS::UI::bytecount;
use FS::Conf;
use FS::part_pkg;
+use FS::cust_bill_pkg_discount;
@ISA = qw(FS::part_pkg);
die "error discounting: $error" if $error;
$amount *= $months;
+ $amount = sprintf('%.2f', $amount);
+
+ next unless $amount > 0;
+
+ #record details in cust_bill_pkg_discount
+ my $cust_bill_pkg_discount = new FS::cust_bill_pkg_discount {
+ 'pkgdiscountnum' => $cust_pkg_discount->pkgdiscountnum,
+ 'amount' => $amount,
+ 'months' => $months,
+ };
+ push @{ $param->{'discounts'} }, $cust_bill_pkg_discount;
#add details on discount to invoice
my $conf = new FS::Conf;
my $money_char = $conf->config('money_char') || '$';
+ $months = sprintf('%.2f', $months) if $months =~ /\./;
my $d = 'Includes ';
$d .= $discount->name. ' ' if $discount->name;
$d .= 'discount of '. $discount->description_short;
- $d .= " for $months month". ( $months>1 ? 's' : '' );
+ $d .= " for $months month". ( $months!=1 ? 's' : '' );
$d .= ": $money_char$amount" if $months != 1 || $discount->percent;
push @$details, $d;