summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorlevinse <levinse>2011-02-19 16:21:23 +0000
committerlevinse <levinse>2011-02-19 16:21:23 +0000
commit37f2b3d1570e849aefd64d5af1c1986d5f2ab368 (patch)
treeb85ac429671f37bdc78506cec33505d788fb6201 /FS
parenta58792bfb6896c4dfa60bdb15b0f6248c4610f7e (diff)
invoice customizations, RT11467
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Conf.pm21
-rw-r--r--FS/FS/cust_bill.pm80
-rw-r--r--FS/FS/usage_class.pm13
3 files changed, 114 insertions, 0 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 1a457219b..53a0b095c 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1263,6 +1263,27 @@ 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' => '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' => '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 e44747b8a..81d60bf4c 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -2515,6 +2515,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') ) {
@@ -4143,6 +4156,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 ) ],