invoices with details in separate section but usage not separated
authorjeff <jeff>
Mon, 5 Oct 2009 01:00:32 +0000 (01:00 +0000)
committerjeff <jeff>
Mon, 5 Oct 2009 01:00:32 +0000 (01:00 +0000)
FS/FS/cust_bill.pm
FS/FS/cust_main.pm
FS/FS/part_pkg/voip_cdr.pm

index eefcc80..57066b4 100644 (file)
@@ -3179,7 +3179,8 @@ sub _items_cust_bill_pkg {
         {
 
           my $is_summary = $display->summary;
-          my $description = $is_summary ? "Usage charges" : $desc;
+          my $description = ($is_summary && $type && $type eq 'U')
+                            ? "Usage charges" : $desc;
 
           unless ( $conf->exists('disable_line_item_date_ranges') ) {
             $description .= " (" . time2str("%x", $cust_bill_pkg->sdate).
@@ -3201,7 +3202,7 @@ sub _items_cust_bill_pkg {
             unless $cust_pkg->part_pkg->hide_svc_detail
                 || $cust_bill_pkg->itemdesc
                 || $cust_bill_pkg->hidden
-                || $is_summary;
+                || $is_summary && $type && $type eq 'U';
 
           push @d, $cust_bill_pkg->details(%details_opt)
             unless ($is_summary || $type && $type eq 'R');
index 16ab0ee..501fca4 100644 (file)
@@ -3147,7 +3147,9 @@ sub _handle_taxes {
   }
  
   my @display = ();
-  if ( $conf->exists('separate_usage') || $cust_bill_pkg->hidden ) {
+  my $separate = $conf->exists('separate_usage');
+  my $usage_mandate = $cust_pkg->part_pkg->option('usage_mandate', 'Hush!');
+  if ( $separate || $cust_bill_pkg->hidden || $usage_mandate ) {
 
     my $temp_pkg = new FS::cust_pkg { pkgpart => $real_pkgpart };
     my %hash = $cust_bill_pkg->hidden  # maybe for all bill linked?
@@ -3156,18 +3158,28 @@ sub _handle_taxes {
 
     my $section = $cust_pkg->part_pkg->option('usage_section', 'Hush!');
     my $summary = $cust_pkg->part_pkg->option('summarize_usage', 'Hush!');
-    push @display, new FS::cust_bill_pkg_display { type => 'S', %hash };
-    push @display, new FS::cust_bill_pkg_display { type => 'R', %hash };
+    if ( $separate ) {
+      push @display, new FS::cust_bill_pkg_display { type => 'S', %hash };
+      push @display, new FS::cust_bill_pkg_display { type => 'R', %hash };
+    } else {
+      push @display, new FS::cust_bill_pkg_display
+                       { type => '',
+                         %hash,
+                         ( ( $usage_mandate ) ? ( 'summary' => 'Y' ) : () ),
+                       };
+    }
 
-    if ($section && $summary) {
+    if ($separate && $section && $summary) {
       push @display, new FS::cust_bill_pkg_display { type    => 'U',
                                                      summary => 'Y',
                                                      %hash,
                                                    };
+    }
+    if ($usage_mandate || $section && $summary) {
       $hash{post_total} = 'Y';
     }
 
-    $hash{section} = $section if $conf->exists('separate_usage');
+    $hash{section} = $section if ($separate || $usage_mandate);
     push @display, new FS::cust_bill_pkg_display { type => 'U', %hash };
 
   }
index f851b41..eccf2c1 100644 (file)
@@ -163,12 +163,16 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
                          'default'        => 'default', #XXX test
                        },
 
-    'usage_section' => { 'name' => 'Section in which to place separate usage charges',
+    'usage_section' => { 'name' => 'Section in which to place usage charges (whether separated or not)',
                        },
 
     'summarize_usage' => { 'name' => 'Include usage summary with recurring charges when usage is in separate section',
                           'type' => 'checkbox',
                         },
+
+    'usage_mandate' => { 'name' => 'Always put usage details in separate section',
+                          'type' => 'checkbox',
+                       },
     #eofalse
 
     'bill_every_call' => { 'name' => 'Generate an invoice immediately for every call.  Useful for prepaid.',
@@ -218,7 +222,7 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
                        skip_dst_length_less skip_lastapp
                        use_duration
                        411_rewrite
-                       output_format summarize_usage usage_section
+                       output_format usage_mandate summarize_usage usage_section
                        bill_every_call
                        count_available_phones
                      )