my ($file, $lfile) = $self->print_latex(@_);
my $ps = generate_ps($file);
+ unlink($file.'.tex');
unlink($lfile);
$ps;
my ($file, $lfile) = $self->print_latex(@_);
my $pdf = generate_pdf($file);
+ unlink($file.'.tex');
unlink($lfile);
$pdf;
'fields' => [
sub { shift->{description} },
sub { shift->{quantity} },
- sub { shift->{amount} },
+ sub { my($href, %opt) = @_;
+ ($opt{dollar} || ''). $href->{amount};
+ },
],
'align' => [ qw( l r r ) ],
'span' => [ qw( 5 1 1 ) ], # unitprices?
my ( $f, $prefix, $suffix, $separator, $column ) =
_condensed_generator_defaults($format);
+ my $money_char = '$';
if ($format eq 'latex') {
$prefix = "\\hline\n\\multicolumn{1}{c}{\\rule{0pt}{2.5ex}~} &\n";
$suffix = '\\\\';
sub { my ($d,$a,$s,$w) = @_;
return "\\multicolumn{$s}{$a}{\\makebox[$w][$a]{\\textbf{$d}}}";
};
+ $money_char = '\\dollar';
}elsif ( $format eq 'html' ) {
$prefix = '"><td align="center"></td>';
$suffix = '';
sub { my ($d,$a,$s,$w) = @_;
return qq!<td align="$html_align{$a}">$d</td>!;
};
+ #$money_char = $conf->config('money_char') || '$';
+ $money_char = ''; # this is madness
}
sub {
- my @args = @_;
+ #my @args = @_;
+ my $href = shift;
my @result = ();
foreach (my $i = 0; $f->{label}->[$i]; $i++) {
- push @result, &{$column}( &{$f->{fields}->[$i]}(@args),
- map { $f->{$_}->[$i] } qw(align span width)
- );
+ my $dollar = '';
+ $dollar = $money_char if $i == scalar(@{$f->{label}})-1;
+ push @result,
+ &{$column}( &{$f->{fields}->[$i]}($href, 'dollar' => $dollar),
+ map { $f->{$_}->[$i] } qw(align span width)
+ );
}
$prefix. join( $separator, @result ). $suffix;
foreach my $cust_bill_pkg ( $self->cust_bill_pkg ) {
next unless $cust_bill_pkg->pkgnum > 0;
+ my @header = $cust_bill_pkg->details_header;
+ next unless scalar(@header);
+
foreach my $detail ( $cust_bill_pkg->cust_bill_pkg_detail ) {
my $phonenum = $detail->phonenum;
'duration' => 0,
'sort_weight' => $usage_class{$detail->classnum}->weight,
'phonenum' => $phonenum,
+ 'header' => [ @header ],
};
$sections{"$phonenum $line"}{amount} += $amount; #subtotal
$sections{"$phonenum $line"}{calls}++;
my %sectionmap = ();
my $simple = new FS::usage_class { format => 'simple' }; #bleh
- my $usage_simple = new FS::usage_class { format => 'usage_simple' }; #bleh
foreach ( keys %sections ) {
+ my @header = @{ $sections{$_}{header} || [] };
+ my $usage_simple =
+ new FS::usage_class { format => 'usage_'. (scalar(@header) || 6). 'col' };
my $summary = $sections{$_}{sort_weight} < 0 ? 1 : 0;
my $usage_class = $summary ? $simple : $usage_simple;
my $ending = $summary ? ' usage charges' : '';
+ my %gen_opt = ();
+ unless ($summary) {
+ $gen_opt{label} = [ map{ &{$escape}($_) } @header ];
+ }
$sectionmap{$_} = { 'description' => &{$escape}($_. $ending),
'amount' => $sections{$_}{amount}, #subtotal
'calls' => $sections{$_}{calls},
'sort_weight' => $sections{$_}{sort_weight},
'post_total' => $summary, #inspire pagebreak
(
- ( map { $_ => $usage_class->$_($format) }
+ ( map { $_ => $usage_class->$_($format, %gen_opt) }
qw( description_generator
header_generator
total_generator
}
sub _taxsort {
- return 0 unless $a cmp $b;
- return -1 if $b eq 'Tax';
- return 1 if $a eq 'Tax';
- return -1 if $b eq 'Other surcharges';
- return 1 if $a eq 'Other surcharges';
- $a cmp $b;
+ return 0 unless $a->itemdesc cmp $b->itemdesc;
+ return -1 if $b->itemdesc eq 'Tax';
+ return 1 if $a->itemdesc eq 'Tax';
+ return -1 if $b->itemdesc eq 'Other surcharges';
+ return 1 if $a->itemdesc eq 'Other surcharges';
+ $a->itemdesc cmp $b->itemdesc;
}
sub _items_tax {