summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevinse <levinse>2011-02-19 16:21:20 +0000
committerlevinse <levinse>2011-02-19 16:21:20 +0000
commit4fc9163c63678a4fd19ed0b31f25f97cc0ac2748 (patch)
tree46894cf193c47b752545982c95c68bd3866be758
parent60f799ab3b8458dcd88d1c5a9dd2f75581fcbbd5 (diff)
invoice customizations, RT11467
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/cust_bill.pm80
-rw-r--r--FS/FS/usage_class.pm13
3 files changed, 100 insertions, 0 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 82ea49056..3f5398959 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1270,6 +1270,13 @@ and customer address. Include units.',
},
{
+ 'key' => 'phone_usage_class_summary',
+ 'section' => 'invoicing',
+ 'description' => 'Summarize usage per DID by usage class and display all CDRs together regardless of usage class. Only valid when svc_phone_sections is enabled.',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'svc_phone_sections',
'section' => 'invoicing',
'description' => 'Create a section for each svc_phone when enabled. Only valid when invoice_sections is enabled.',
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 84ef08962..7f162c95c 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -2546,6 +2546,19 @@ sub print_generic {
'total_pages' => 1,
);
+
+ my $min_sdate = 999999999999;
+ my $max_edate = 0;
+ foreach my $cust_bill_pkg ( $self->cust_bill_pkg ) {
+ next unless $cust_bill_pkg->pkgnum > 0;
+ $min_sdate = $cust_bill_pkg->sdate if $cust_bill_pkg->sdate < $min_sdate;
+ $max_edate = $cust_bill_pkg->edate if $cust_bill_pkg->edate > $max_edate;
+ }
+
+ $invoice_data{'bill_period'} = '';
+ $invoice_data{'bill_period'} = time2str('%e %h', $min_sdate)
+ . " to " . time2str('%e %h', $max_edate)
+ if ($max_edate != 0 && $min_sdate != 999999999999);
$invoice_data{finance_section} = '';
if ( $conf->config('finance_pkgclass') ) {
@@ -4174,6 +4187,73 @@ sub _items_svc_phone_sections {
push @lines, $l;
}
}
+
+ if($conf->exists('phone_usage_class_summary')) {
+ # this only works with Latex
+ my @newlines;
+ my @newsections;
+ foreach my $section ( @sections ) {
+ if($section->{'post_total'}) {
+ $section->{'description'} = 'Calls Summary: '.$section->{'phonenum'};
+ $section->{'total_line_generator'} = sub { '' };
+ $section->{'total_generator'} = sub { '' };
+ $section->{'header_generator'} = sub { '' };
+ $section->{'description_generator'} = '';
+ push @newsections, $section;
+ my %calls_detail = %$section;
+ $calls_detail{'post_total'} = '';
+ $calls_detail{'sort_weight'} = '';
+ $calls_detail{'description_generator'} = sub { '' };
+ $calls_detail{'header_generator'} = sub {
+ return ' & Date/Time & Called Number & Duration & Price'
+ if $format eq 'latex';
+ '';
+ };
+ $calls_detail{'description'} = 'Calls Detail: '
+ . $section->{'phonenum'};
+ push @newsections, \%calls_detail;
+ }
+ }
+ foreach my $newsection ( @newsections ) {
+ if($newsection->{'post_total'}) {
+ foreach my $section ( @sections ) {
+ next unless ($section->{'phonenum'} eq $newsection->{'phonenum'}
+ && !$section->{'post_total'});
+ my $newdesc = $section->{'description'};
+ my $tn = $section->{'phonenum'};
+ $newdesc =~ s/$tn//g;
+ my $line = { ext_description => [],
+ pkgnum => '',
+ ref => '',
+ quantity => '',
+ calls => $section->{'calls'},
+ section => $newsection,
+ duration => $section->{'duration'},
+ description => $newdesc,
+ amount => $section->{'amount'},
+ product_code => 'N/A',
+ };
+ push @newlines, $line;
+ }
+ }
+ }
+ foreach my $newsection ( @newsections ) {
+ if(!$newsection->{'post_total'}) {
+ foreach my $line ( @lines ) {
+ next unless (scalar(@{$line->{'ext_description'}}) &&
+ $line->{'section'}->{'phonenum'} eq $newsection->{'phonenum'}
+ );
+ my @extdesc = @{$line->{'ext_description'}};
+ my $extdesc = $extdesc[0];
+ $extdesc =~ s/scriptsize/normalsize/g if $format eq 'latex';
+ $line->{'ext_description'} = [ $extdesc ];
+ $line->{'section'} = $newsection;
+ push @newlines, $line;
+ }
+ }
+ }
+ return(\@newsections, \@newlines);
+ }
return(\@sections, \@lines);
diff --git a/FS/FS/usage_class.pm b/FS/FS/usage_class.pm
index 7b73c611f..62beeb4a2 100644
--- a/FS/FS/usage_class.pm
+++ b/FS/FS/usage_class.pm
@@ -181,6 +181,19 @@ my %summary_formats = (
'span' => [ qw( 1 1 1 1 1 2 ) ], # unitprices?
'width' => [ qw( 4.3cm 1.4cm 2.5cm 2.5cm 1.4cm 1.6cm ) ],# don't like this
'show' => 0,
+ },
+ 'usage_4col' => {
+ 'label' => [ qw( col1 col2 col3 col4 ) ],
+ 'fields' => [
+ sub { ' ' },
+ sub { ' ' },
+ sub { ' ' },
+ sub { ' ' },
+ ],
+ 'align' => [ qw( l l l l r r ) ],
+ 'span' => [ qw( 1 1 1 1 1 2 ) ],
+ 'width' => [ qw( 4.3cm 1.4cm 2.5cm 2.5cm ) ],
+ 'show' => 0,
},
'usage_7col' => {
'label' => [ qw( col1 col2 col3 col4 col5 col6 col7 ) ],