modify total items for balance below line and current charges above line with configu...
authorjeff <jeff>
Fri, 9 Apr 2010 08:09:48 +0000 (08:09 +0000)
committerjeff <jeff>
Fri, 9 Apr 2010 08:09:48 +0000 (08:09 +0000)
FS/FS/Conf.pm
FS/FS/cust_bill.pm
conf/invoice_html

index 53c2d13..3adf455 100644 (file)
@@ -2911,11 +2911,18 @@ worry that config_items is freeside-specific and icky.
   {
     'key'         => 'disable_previous_balance',
     'section'     => 'invoicing',
   {
     'key'         => 'disable_previous_balance',
     'section'     => 'invoicing',
-    'description' => 'Disable inclusion of previous balancem payment, and credit lines on invoices',
+    'description' => 'Disable inclusion of previous balance, payment, and credit lines on invoices',
     'type'        => 'checkbox',
   },
 
   {
     'type'        => 'checkbox',
   },
 
   {
+    'key'         => 'previous_balance-exclude_from_total',
+    'section'     => 'invoicing',
+    'description' => 'Do not include previous balance in the \'Total\' line.  Only meaningful when invoice_sections is false.  Optionally provide text to override the Total New Charges description',
+    'type'        => [ qw(checkbox text) ],
+  },
+
+  {
     'key'         => 'previous_balance-summary_only',
     'section'     => 'invoicing',
     'description' => 'Only show a single line summarizing the total previous balance rather than one line per invoice.',
     'key'         => 'previous_balance-summary_only',
     'section'     => 'invoicing',
     'description' => 'Only show a single line summarizing the total previous balance rather than one line per invoice.',
@@ -2923,6 +2930,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
   },
 
   {
+    'key'         => 'balance_due_below_line',
+    'section'     => 'invoicing',
+    'description' => 'Place the balance due message below a line.  Only meaningful when when invoice_sections is false.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'usps_webtools-userid',
     'section'     => 'UI',
     'description' => 'Production UserID for USPS web tools.   Enables USPS address standardization.  See the <a href="http://www.usps.com/webtools/">USPS website</a>, register and agree not to use the tools for batch purposes.',
     'key'         => 'usps_webtools-userid',
     'section'     => 'UI',
     'description' => 'Production UserID for USPS web tools.   Enables USPS address standardization.  See the <a href="http://www.usps.com/webtools/">USPS website</a>, register and agree not to use the tools for batch purposes.',
index b2cad50..8cc84e5 100644 (file)
@@ -2329,6 +2329,7 @@ sub print_generic {
     'unitprices'      => $conf->exists('invoice-unitprice'),
     'smallernotes'    => $conf->exists('invoice-smallernotes'),
     'smallerfooter'   => $conf->exists('invoice-smallerfooter'),
     'unitprices'      => $conf->exists('invoice-unitprice'),
     'smallernotes'    => $conf->exists('invoice-smallernotes'),
     'smallerfooter'   => $conf->exists('invoice-smallerfooter'),
+    'balance_due_below_line' => $conf->exists('balance_due_below_line'),
    
     # better hang on to conf_dir for a while (for old templates)
     'conf_dir'        => "$FS::UID::conf_dir/conf.$FS::UID::datasrc",
    
     # better hang on to conf_dir for a while (for old templates)
     'conf_dir'        => "$FS::UID::conf_dir/conf.$FS::UID::datasrc",
@@ -2513,6 +2514,7 @@ sub print_generic {
 
   my $unsquelched = $params{unsquelch_cdr} || $cust_main->squelch_cdr ne 'Y';
   my $multisection = $conf->exists('invoice_sections', $cust_main->agentnum);
 
   my $unsquelched = $params{unsquelch_cdr} || $cust_main->squelch_cdr ne 'Y';
   my $multisection = $conf->exists('invoice_sections', $cust_main->agentnum);
+  $invoice_data{'multisection'} = $multisection;
   my $late_sections = [];
   my $extra_sections = [];
   my $extra_lines = ();
   my $late_sections = [];
   my $extra_sections = [];
   my $extra_lines = ();
@@ -2721,17 +2723,19 @@ sub print_generic {
 
   {
     my $total = {};
 
   {
     my $total = {};
-    $total->{'total_item'} = &$embolden_function('Total');
+    my $item = 'Total';
+    $item = $conf->config('previous_balance-exclude_from_total')
+         || 'Total New Charges'
+      if $conf->exists('previous_balance-exclude_from_total');
+    my $amount = $self->charged +
+                   ( $conf->exists('disable_previous_balance') ||
+                     $conf->exists('previous_balance-exclude_from_total')
+                     ? 0
+                     : $pr_total
+                   );
+    $total->{'total_item'} = &$embolden_function($item);
     $total->{'total_amount'} =
     $total->{'total_amount'} =
-      &$embolden_function(
-        $other_money_char.
-        sprintf( '%.2f',
-                 $self->charged + ( $conf->exists('disable_previous_balance')
-                                    ? 0
-                                    : $pr_total
-                                  )
-               )
-      );
+      &$embolden_function( $other_money_char.  sprintf( '%.2f', $amount ) );
     if ( $multisection ) {
       if ( $adjust_section->{'sort_weight'} ) {
         $adjust_section->{'posttotal'} = 'Balance Forward '. $other_money_char.
     if ( $multisection ) {
       if ( $adjust_section->{'sort_weight'} ) {
         $adjust_section->{'posttotal'} = 'Balance Forward '. $other_money_char.
@@ -2744,14 +2748,9 @@ sub print_generic {
       push @total_items, $total;
     }
     push @buf,['','-----------'];
       push @total_items, $total;
     }
     push @buf,['','-----------'];
-    push @buf,['Total Charges',
+    push @buf,[$item,
                $money_char.
                $money_char.
-               sprintf( '%10.2f', $self->charged +
-                                    ( $conf->exists('disable_previous_balance')
-                                        ? 0
-                                        : $pr_total
-                                    )
-                      )
+               sprintf( '%10.2f', $amount )
               ];
     push @buf,['',''];
   }
               ];
     push @buf,['',''];
   }
index df4674b..fe2a9a9 100644 (file)
   </table>
   <%= $summary %>
   <%=
   </table>
   <%= $summary %>
   <%=
+      my $notfirst = 0;
       foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
         if ($section->{'pretotal'} && !$summary) {
       foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
         if ($section->{'pretotal'} && !$summary) {
+          $OUT .= '</table>' if $notfirst;
           $OUT .=
             '<table width="100%"><tr><td>'.
             '<p align="right"><b><font size="+1">'.
           $OUT .=
             '<table width="100%"><tr><td>'.
             '<p align="right"><b><font size="+1">'.
             '</font><font size="+0">'. uc(substr($section->{'pretotal'},1)).
             '</font></b>'.
             '<p>'.
             '</font><font size="+0">'. uc(substr($section->{'pretotal'},1)).
             '</font></b>'.
             '<p>'.
-            '</td></tr></table>';
+            '</td></tr>';
         }
         unless ($section->{'summarized'}) {
         }
         unless ($section->{'summarized'}) {
+          $OUT .= '</table>' if ( $notfirst || $section->{'pretotal'} && !$summary );
           $OUT .= '<table><tr><td>';
           if ($section->{'description'}) {
             $OUT .=
           $OUT .= '<table><tr><td>';
           if ($section->{'description'}) {
             $OUT .=
                         ). 
                       '<th align="right">Amount</th>';
           }
                         ). 
                       '<th align="right">Amount</th>';
           }
-            '</tr>';
+            $OUT .= '</tr>';
 
           my $lastref = 0;
           foreach my $line (
 
           my $lastref = 0;
           foreach my $line (
           }
 
 
           }
 
 
-          if (scalar(@sections) > 1) {
+          if ($section->{'description'} || $multisection) {
             my $style = 'border-top: 3px solid #000000;'.
                         'border-bottom: 3px solid #000000;';
             $OUT .=
             my $style = 'border-top: 3px solid #000000;'.
                         'border-bottom: 3px solid #000000;';
             $OUT .=
           $OUT .= '</td></tr>';
         }
 
           $OUT .= '</td></tr>';
         }
 
+        $notfirst++;
+
       }
 
       my $style = 'border-top: 3px solid #000000;';
       }
 
       my $style = 'border-top: 3px solid #000000;';
       foreach my $line ( @total_items ) {
 
         $style .= 'border-bottom: 3px solid #000000;'
       foreach my $line ( @total_items ) {
 
         $style .= 'border-bottom: 3px solid #000000;'
-          if ++$linenum == scalar(@total_items);
+          if ++$linenum == scalar(@total_items) - ( $balance_due_below_line ? 1 : 0 );
 
         $OUT .=
           '<tr class="invoice_totaldesc">';
 
         $OUT .=
           '<tr class="invoice_totaldesc">';