X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FTemplate_Mixin.pm;h=00cea1a211d74a60d8fda7028a8b614d9a22673b;hb=fa298c55a9e276ef714f1e6dbf11ae3931ad8684;hp=1fed7f1b92f7cb87efe27ac08b0e3d8e1603030a;hpb=03c12b4dabfcaabc218f39ee13557edebc13931d;p=freeside.git diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 1fed7f1b9..00cea1a21 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -347,8 +347,8 @@ sub print_generic { if ( $format eq 'latex' && grep { /^%%Detail/ } @invoice_template ) { #change this to a die when the old code is removed - # it's been almost ten years, changing it to a die on the next release. - warn "old-style invoice template $templatefile; ". + # it's been almost ten years, changing it to a die + die "old-style invoice template $templatefile; ". "patch with conf/invoice_latex.diff or use new conf/invoice_latex*\n"; #$old_latex = 'true'; #@invoice_template = _translate_old_latex_format(@invoice_template); @@ -3448,8 +3448,29 @@ sub _items_cust_bill_pkg { ext_description => \@ext, }; foreach my $cust_bill_pkg_discount (@discounts) { - my $def = $cust_bill_pkg_discount->cust_pkg_discount->discount; - push @ext, &{$escape_function}( $def->description ); + my $discount = $cust_bill_pkg_discount->cust_pkg_discount->discount; + my $discount_desc = $discount->description_short; + + if ($discount->months) { + + # calculate months remaining after this invoice + my $used = FS::Record->scalar_sql( + 'SELECT SUM(months) FROM cust_bill_pkg_discount + JOIN cust_bill_pkg USING (billpkgnum) + JOIN cust_bill USING (invnum) + WHERE pkgdiscountnum = ? AND _date <= ?', + $cust_bill_pkg_discount->pkgdiscountnum, + $self->_date + ); + $used ||= 0; + my $remaining = sprintf('%.2f', $discount->months - $used); + # append "for X months (Y months remaining)" + $discount_desc .= $self->mt(' for [quant,_1,month] ([quant,_2,month] remaining)', + $cust_bill_pkg_discount->months, + $remaining + ); + } # else it's not time-limited + push @ext, &{$escape_function}($discount_desc); } }