bundled package presentation improvements
authorjeff <jeff>
Sat, 2 Aug 2008 04:20:22 +0000 (04:20 +0000)
committerjeff <jeff>
Sat, 2 Aug 2008 04:20:22 +0000 (04:20 +0000)
FS/FS/Conf.pm
FS/FS/Schema.pm
FS/FS/cust_bill.pm
FS/FS/cust_bill_pkg.pm
FS/FS/cust_main.pm
FS/FS/part_pkg/voip_cdr.pm
conf/invoice_html
conf/invoice_latex
httemplate/edit/cust_main.cgi
httemplate/edit/cust_main/billing.html
httemplate/view/cust_main/billing.html

index 8684a5a..3c4c6ee 100644 (file)
@@ -1893,6 +1893,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'voip-cust_cdr_squelch',
+    'section'     => '',
+    'description' => 'Enable the per-customer option for not printing CDR on invoices.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'svc_forward-arbitrary_dst',
     'section'     => '',
     'description' => "Allow forwards to point to arbitrary strings that don't necessarily look like email addresses.  Only used when using forwards for weird, non-email things.",
index 06816ef..9a1ce9f 100644 (file)
@@ -621,6 +621,7 @@ sub tables_hashref {
         'referral_custnum', 'int',  'NULL', '', '', '', 
         'comments', 'text', 'NULL', '', '', '', 
         'spool_cdr','char', 'NULL', 1, '', '', 
+        'squelch_cdr','char', 'NULL', 1, '', '', 
         'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
       ],
       'primary_key' => 'custnum',
index 3aed5a4..96c1db7 100644 (file)
@@ -1631,6 +1631,8 @@ L<Time::Local> and L<Date::Parse> for conversion functions.
 
 cid - 
 
+unsquelch_cdr - overrides any per customer cdr squelching when true
+
 =cut
 
 sub print_generic {
@@ -2054,6 +2056,8 @@ sub print_generic {
     $options{'section'} = $section if $multisection;
     $options{'format'} = $format;
     $options{'escape_function'} = $escape_function;
+    $options{'format_function'} = sub { () }
+      unless $params{unsquelch_cdr} || $cust_main->squelch_cdr ne 'Y';
 
     foreach my $line_item ( $self->_items_pkg(%options) ) {
       my $detail = {
@@ -2638,6 +2642,7 @@ sub _items_cust_bill_pkg {
 
   my $format = $opt{format} || '';
   my $escape_function = $opt{escape_function} || sub { shift };
+  my $format_function = $opt{format_function} || '';
 
   my @b = ();
   foreach my $cust_bill_pkg ( @$cust_bill_pkg ) {
@@ -2648,6 +2653,7 @@ sub _items_cust_bill_pkg {
 
     my %details_opt = ( 'format'          => $format,
                         'escape_function' => $escape_function,
+                        'format_function' => $format_function,
                       );
 
     if ( $cust_bill_pkg->pkgnum > 0 ) {
index 62c0d58..638e707 100644 (file)
@@ -285,6 +285,8 @@ sub details {
                     }
     if $format eq 'latex';
 
+  $format_sub = $opt{format_function} if $opt{format_function};
+
   map { ( $_->format eq 'C'
           ? &{$format_sub}( $_->detail )
           : &{$escape_function}( $_->detail )
index e7235ff..b74c75d 100644 (file)
@@ -223,6 +223,8 @@ Card Verification Value, "CVV2" (also known as CVC2 or CID), the 3 or 4 digit nu
 
 =item spool_cdr - Enable individual CDR spooling, empty or `Y'
 
+=item squelch_cdr - Discourage individual CDR printing, empty or `Y'
+
 =back
 
 =head1 METHODS
@@ -1530,7 +1532,7 @@ sub check {
     $self->payname($1);
   }
 
-  foreach my $flag (qw( tax spool_cdr )) {
+  foreach my $flag (qw( tax spool_cdr squelch_cdr )) {
     $self->$flag() =~ /^(Y?)$/ or return "Illegal $flag: ". $self->$flag();
     $self->$flag($1);
   }
index a14db2b..a7c1903 100644 (file)
@@ -158,6 +158,10 @@ sub calc_usage {
   my $output_format = $self->option('output_format', 'Hush!')
                       || 'simple';
 
+  eval "use Text::CSV_XS;";
+  die $@ if $@;
+  my $csv = new Text::CSV_XS;
+
   foreach my $cust_svc (
     grep { $_->part_svc->svcdb eq 'svc_phone' } $cust_pkg->cust_svc
   ) {
@@ -298,7 +302,7 @@ sub calc_usage {
 
           $charge = sprintf('%.2f', $cdr->upstream_price);
           $charges += $charge;
-
           @call_details = (
             #time2str("%Y %b %d - %r", $cdr->calldate_unix ),
             time2str("%c", $cdr->calldate_unix),  #XXX this should probably be a config option dropdown so they can select US vs- rest of world dates or whatnot
@@ -383,10 +387,9 @@ sub calc_usage {
           if ( $self->option('rating_method') eq 'upstream_simple' ) {
             $call_details = [ 'C', $call_details[0] ];
           }else{
-            $call_details = join(' - ', @call_details );
+            $csv->combine(@call_details);
+            $call_details = [ 'C', $csv->string ];
           }
-          warn "  adding details on charge to invoice: $call_details"
-            if ( $DEBUG && !ref($call_details) );
           warn "  adding details on charge to invoice: [ ".
               join(', ', @{$call_details} ). " ]"
             if ( $DEBUG && ref($call_details) );
@@ -476,7 +479,7 @@ sub append_cust_bill_pkgs {
     'quantity'  => $cust_pkg->quantity,
     'sdate'     => $$sdate,
     'edate'     => $cust_pkg->bill,             # already fiddled
-    'itemdesc'  => 'Call details',              # configurable?
+    'itemdesc'  => 'Usage charges',             # configurable?
     'details'   => \@details,
   };
 
index 06980b0..806c5de 100644 (file)
@@ -6,6 +6,7 @@
 .invoice_longtable table { cellspacing: none }
 .invoice_longtable TH { border-top: 2px solid #000000; border-bottom: 1px solid #000000; padding-left: none; padding-right: none; font-size: 10pt }
 .invoice_desc TD { border-top: 2px solid #000000; font-weight: bold; font-size: 10pt }
+.invoice_desc_more TD { font-weight: bold; font-size: 10pt }
 .invoice_extdesc TD { font-size: 8pt }
 .invoice_totaldesc TD { font-size: 10pt; empty-cells: show }
 </STYLE>
             '<th align="right">Amount</th>'.
           '</tr>';
 
+        my $lastref = 0;
         foreach my $line (
           grep { ( scalar(@sections) > 1 
                  ? $section->{'description'} eq $_->{'section'}->{'description'}
           @detail_items )
         {
           $OUT .=
-            '<tr class="invoice_desc">'.
-              '<td align="center">'. $line->{'ref'}. '</td>'.
+            '<tr class="invoice_desc'.
+              ( ($line->{'ref'} && $line->{'ref'} ne $lastref) ? '' : '_more' ).
+              '">'.
+              '<td align="center">'. 
+              ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ). '</td>'.
               '<td align="left">'. $line->{'description'}. '</td>'.
               ( $unitprices 
                   ? '<td align="left">'. $line->{'unit_amount'}. '</td>'.
               '<td align="right">'. $line->{'amount'}. '</td>'.
             '</tr>'
           ;
+          $lastref = $line->{'ref'};
           if ( @{$line->{'ext_description'} } ) {
             $OUT .= '<tr class="invoice_extdesc"><td></td><td';
             $OUT .= $unitprices ? ' colspan=3>' : '>';
index 6bfc41d..ddd068e 100644 (file)
@@ -284,6 +284,7 @@ Terms: [@-- $terms --@]\\
     $OUT .= '\hline';\r
     $OUT .= '\endlastfoot';\r
 \r
+    my $lastref = 0;\r
     foreach my $line (\r
       grep { ( scalar( @sections ) > 1 \r
              ? $section->{'description'} eq $_->{'section'}->{'description'}\r
@@ -296,11 +297,14 @@ Terms: [@-- $terms --@]\\
       # Don't break-up small packages.\r
       my $rowbreak = @$ext_description < 5 ? '*' : '';\r
   \r
-      $OUT .= "\\hline\n";\r
-      $OUT .= '\FSdesc{' . $line->{'ref'} . '}{' . $line->{'description'} . '}' .\r
+      $OUT .= "\\hline\n" if ($line->{'ref'} && $line->{'ref'} ne $lastref);\r
+      $OUT .= '\FSdesc'.\r
+              '{' . ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ) . '}'.\r
+              '{' . $line->{'description'} . '}' .\r
               '{' . ( $unitprices ? $line->{'unit_amount'} : '' ) . '}'.\r
               '{' . ( $unitprices ? $line->{'quantity'} : ''  ) . '}' .\r
               '{' . $line->{'amount'} . "}${rowbreak}\n";\r
+      $lastref = $line->{'ref'};\r
 \r
       foreach my $ext_desc (@$ext_description) {\r
         if ( $ext_desc !~ /[^\\]&/ ) {\r
index f0d719c..10086a4 100755 (executable)
@@ -265,7 +265,8 @@ function bottomfixup(what) {
     'tax',
     'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
     'invoice_terms',
-    'spool_cdr'
+    'spool_cdr',
+    'squelch_cdr'
   );
 
   for ( f=0; f < topvars.length; f++ ) {
@@ -501,7 +502,8 @@ function copyelement(from, to) {
 %     'tax',
 %     'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
 %     'invoice_terms',
-%     'spool_cdr'
+%     'spool_cdr',
+%     'squelch_cdr'
 %   ) {
 %
 
index 6b1c2a8..d4c5034 100644 (file)
       <INPUT TYPE="hidden" NAME="spool_cdr" VALUE="<% $cust_main->spool_cdr %>">
 % } 
 
+% if ( $conf->exists('voip-cust_cdr_squelch') ) { 
+      <TR>
+       <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="squelch_cdr" VALUE="Y" <% $cust_main->squelch_cdr eq "Y" ? 'CHECKED' : '' %>> Omit CDRs from invoices</TD>
+      </TR>
+% } else { 
+
+      <INPUT TYPE="hidden" NAME="squelch_cdr" VALUE="<% $cust_main->squelch_cdr %>">
+% } 
+
   </TABLE>
 
   </FORM>
index 2f05c1a..aea90e8 100644 (file)
@@ -196,6 +196,13 @@ Billing information
   </TR>
 % } 
 
+% if ( $conf->exists('voip-cust_cdr_squelch') ) { 
+  <TR>
+    <TD ALIGN="right">Print&nbsp;CDRs</TD>
+    <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? 'no' : 'yes' %></TD>
+  </TR>
+% } 
+
 </TABLE></TD></TR></TABLE>
 <%once>