use FS::pkg_class;
use FS::invoice_mode;
use FS::L10N;
+use FS::Log;
$DEBUG = 0;
$me = '[FS::Template_Mixin]';
'amountenclosedsep' => scalar($conf->config('invoice_latexcouponamountenclosedsep', $agentnum)),
'coupontoaddresssep' => scalar($conf->config('invoice_latexcoupontoaddresssep', $agentnum)),
'addcompanytoaddress' => $conf->exists('invoice_latexcouponaddcompanytoaddress', $agentnum),
+ 'couponlocation' => (scalar($conf->config('invoice_latexcouponlocation', $agentnum)) eq "top") ? 'top' : 'bottom',
# better hang on to conf_dir for a while (for old templates)
'conf_dir' => "$FS::UID::conf_dir/conf.$FS::UID::datasrc",
}
} else {
# subtotal sectioning is the same as for the actual invoice sections
- @summary_subtotals = grep $_->{subtotal}, @sections;
+ @summary_subtotals = @sections;
}
# Hereafter, push sections to both @sections and @summary_subtotals
=back
-Returns an argument list to be passed to L<FS::Misc::send_email>.
+Returns an argument list to be passed to L<FS::Misc/send_email>.
=cut
if (!@text) {
- if ( $conf->config($tc.'template') ) {
+ if ( $conf->exists($tc.'template') ) {
warn "$me generating plain text invoice"
if $DEBUG;
sub postal_mail_fsinc {
my ( $self, %opt ) = @_;
+ if ( $FS::Misc::DISABLE_PRINT ) {
+ warn 'postal_mail_fsinc() disabled by $FS::Misc::DISABLE_PRINT' if $DEBUG;
+ return;
+ }
+
my $url = 'https://ws.freeside.biz/print';
my $cust_main = $self->cust_main;
my @cust_bill_pkg = grep { $_->feepart } $self->cust_bill_pkg;
my $escape_function = $options{escape_function};
- my $locale = $self->quotationnum
- ? $self->prospect_main->locale
- : $self->cust_main->locale;
+ my $locale = $self->cust_main
+ ? $self->cust_main->locale
+ : $self->prospect_main->locale;
my @items;
foreach my $cust_bill_pkg (@cust_bill_pkg) {
if $DEBUG > 1;
my $cust_pkg = $cust_bill_pkg->cust_pkg;
+
+ unless ( $cust_pkg ) {
+ # There is no related row in cust_pkg for this cust_bill_pkg.pkgnum.
+ # This invoice may have been broken by an unusual combination
+ # of manually editing package dates, and aborted package changes
+ # when the manually edited dates used are nonsensical.
+
+ my $error = sprintf
+ 'cust_bill_pkg(billpkgnum:%s) '.
+ 'is missing related row in cust_pkg(pkgnum:%s)! '.
+ 'cust_bill(invnum:%s) is corrupted by bad database data, '.
+ 'and should be investigated',
+ $cust_bill_pkg->billpkgnum,
+ $cust_bill_pkg->pkgnum,
+ $cust_bill_pkg->invnum;
+
+ FS::Log->new('FS::cust_bill_pkg')->critical( $error );
+ warn $error;
+ next;
+ }
+
my $part_pkg = $cust_pkg->part_pkg;
# which pkgpart to show for display purposes?