invoice cosmetic improvements
authorjeff <jeff>
Sat, 31 May 2008 14:49:03 +0000 (14:49 +0000)
committerjeff <jeff>
Sat, 31 May 2008 14:49:03 +0000 (14:49 +0000)
FS/FS/cust_bill.pm
conf/invoice_html
conf/invoice_latex

index b96b097..0906c5d 100644 (file)
@@ -1951,6 +1951,14 @@ sub print_generic {
                                             sprintf('%.2f', $pr_total),
                          };
 
                                             sprintf('%.2f', $pr_total),
                          };
 
+  my $taxtotal = 0;
+  my $tax_section = { 'description' => 'Taxes, Surcharges, and Fees',
+                      'subtotal'    => $taxtotal }; # adjusted below
+
+  my $adjusttotal = 0;
+  my $adjust_section = { 'description' => 'Credits, Payments, and Adjustments',
+                         'subtotal'    => 0 }; # adjusted below
+
   my $multisection = $conf->exists('invoice_sections', $cust_main->agentnum);
   if ( $multisection ) {
     push @sections, $self->_items_sections;
   my $multisection = $conf->exists('invoice_sections', $cust_main->agentnum);
   if ( $multisection ) {
     push @sections, $self->_items_sections;
@@ -2048,16 +2056,28 @@ sub print_generic {
   }
   
   if ( $multisection && !$conf->exists('disable_previous_balance') ) {
   }
   
   if ( $multisection && !$conf->exists('disable_previous_balance') ) {
-    unshift @sections, $previous_section;
+    unshift @sections, $previous_section if $pr_total;
   }
 
   }
 
-  my $taxtotal = 0;
   foreach my $tax ( $self->_items_tax ) {
     my $total = {};
     $total->{'total_item'} = &$escape_function($tax->{'description'});
     $taxtotal += $tax->{'amount'};
     $total->{'total_amount'} = $other_money_char. $tax->{'amount'};
   foreach my $tax ( $self->_items_tax ) {
     my $total = {};
     $total->{'total_item'} = &$escape_function($tax->{'description'});
     $taxtotal += $tax->{'amount'};
     $total->{'total_amount'} = $other_money_char. $tax->{'amount'};
-    push @total_items, $total;
+    if ( $multisection ) {
+      my $money = $old_latex ? '' : $money_char;
+      push @detail_items, {
+        ext_description => [],
+        ref          => '',
+        quantity     => '',
+        description  => &$escape_function($tax->{'description'}),
+        amount       => $money. $tax->{'amount'},
+        product_code => '',
+        section      => $tax_section,
+      };
+    }else{
+      push @total_items, $total;
+    }
     push @buf,[ $total->{'total_item'},
                 $money_char. sprintf("%10.2f", $total->{'total_amount'}),
               ];
     push @buf,[ $total->{'total_item'},
                 $money_char. sprintf("%10.2f", $total->{'total_amount'}),
               ];
@@ -2066,14 +2086,19 @@ sub print_generic {
   
   if ( $taxtotal ) {
     my $total = {};
   
   if ( $taxtotal ) {
     my $total = {};
+    $total->{'total_item'} = 'Sub-total';
+    $total->{'total_amount'} =
+      $other_money_char. sprintf('%.2f', $self->charged - $taxtotal );
+
     if ( $multisection ) {
     if ( $multisection ) {
-      $total->{'total_item'} = 'New charges sub-total';
+      $tax_section->{'subtotal'} = $other_money_char.
+                                   sprintf('%.2f', $taxtotal);
+      $tax_section->{'pretotal'} = 'New charges sub-total '.
+                                   $total->{'total_amount'};
+      push @sections, $tax_section if $taxtotal;
     }else{
     }else{
-      $total->{'total_item'} = 'Sub-total';
+      unshift @total_items, $total;
     }
     }
-    $total->{'total_amount'} =
-      $other_money_char. sprintf('%.2f', $self->charged - $taxtotal );
-    unshift @total_items, $total;
   }
   
   push @buf,['','-----------'];
   }
   
   push @buf,['','-----------'];
@@ -2097,7 +2122,12 @@ sub print_generic {
                                   )
                )
       );
                                   )
                )
       );
-    push @total_items, $total;
+    if ( $multisection ) {
+      $adjust_section->{'pretotal'} = 'New charges total '.
+                                      $total->{'total_amount'};
+    }else{
+      push @total_items, $total;
+    }
     push @buf,['','-----------'];
     push @buf,['Total Charges',
                $money_char.
     push @buf,['','-----------'];
     push @buf,['Total Charges',
                $money_char.
@@ -2120,7 +2150,21 @@ sub print_generic {
       $total->{'total_item'} = &$escape_function($credit->{'description'});
       #$credittotal
       $total->{'total_amount'} = '-'. $other_money_char. $credit->{'amount'};
       $total->{'total_item'} = &$escape_function($credit->{'description'});
       #$credittotal
       $total->{'total_amount'} = '-'. $other_money_char. $credit->{'amount'};
-      push @total_items, $total;
+      $adjusttotal += $credit->{'amount'};
+      if ( $multisection ) {
+        my $money = $old_latex ? '' : $money_char;
+        push @detail_items, {
+          ext_description => [],
+          ref          => '',
+          quantity     => '',
+          description  => &$escape_function($credit->{'description'}),
+          amount       => $money. $credit->{'amount'},
+          product_code => '',
+          section      => $adjust_section,
+        };
+      }else{
+        push @total_items, $total;
+      }
     }
   
     # credits (again)
     }
   
     # credits (again)
@@ -2143,12 +2187,32 @@ sub print_generic {
       $total->{'total_item'} = &$escape_function($payment->{'description'});
       #$paymenttotal
       $total->{'total_amount'} = '-'. $other_money_char. $payment->{'amount'};
       $total->{'total_item'} = &$escape_function($payment->{'description'});
       #$paymenttotal
       $total->{'total_amount'} = '-'. $other_money_char. $payment->{'amount'};
-      push @total_items, $total;
+      $adjusttotal += $payment->{'amount'};
+      if ( $multisection ) {
+        my $money = $old_latex ? '' : $money_char;
+        push @detail_items, {
+          ext_description => [],
+          ref          => '',
+          quantity     => '',
+          description  => &$escape_function($payment->{'description'}),
+          amount       => $money. $payment->{'amount'},
+          product_code => '',
+          section      => $adjust_section,
+        };
+      }else{
+        push @total_items, $total;
+      }
       push @buf, [ $payment->{'description'},
                    $money_char. sprintf("%10.2f", $payment->{'amount'}),
                  ];
     }
   
       push @buf, [ $payment->{'description'},
                    $money_char. sprintf("%10.2f", $payment->{'amount'}),
                  ];
     }
   
+    if ( $multisection ) {
+      $adjust_section->{'subtotal'} = $other_money_char.
+                                      sprintf('%.2f', $adjusttotal);
+      push @sections, $adjust_section;
+    }
+
     { 
       my $total;
       $total->{'total_item'} = &$embolden_function($self->balance_due_msg);
     { 
       my $total;
       $total->{'total_item'} = &$embolden_function($self->balance_due_msg);
@@ -2156,7 +2220,12 @@ sub print_generic {
         &$embolden_function(
           $other_money_char. sprintf('%.2f', $self->owed + $pr_total )
         );
         &$embolden_function(
           $other_money_char. sprintf('%.2f', $self->owed + $pr_total )
         );
-      push @total_items, $total;
+      if ( $multisection ) {
+        $adjust_section->{'posttotal'} = $total->{'total_item'}. ' '.
+                                         $total->{'total_amount'};
+      }else{
+        push @total_items, $total;
+      }
       push @buf,['','-----------'];
       push @buf,[$self->balance_due_msg, $money_char. 
         sprintf("%10.2f", $balance_due ) ];
       push @buf,['','-----------'];
       push @buf,[$self->balance_due_msg, $money_char. 
         sprintf("%10.2f", $balance_due ) ];
index 14b25c6..ae6910d 100644 (file)
 
   <%=
       foreach my $section ( @sections ) {
 
   <%=
       foreach my $section ( @sections ) {
+        if ($section->{'pretotal'}) {
+          $OUT .=
+            '<table width="100%"><tr><td>'.
+            '<p align="right"><b><font size="+1">'.
+            uc(substr($section->{'pretotal'},0,1)).
+            '</font><font size="+0">'. uc(substr($section->{'pretotal'},1)).
+            '</font></b>'.
+            '<p>'.
+            '</td></tr></table>';
+        }
         $OUT .= '<table><tr><td>';
         if ($section->{'description'}) {
           $OUT .=
         $OUT .= '<table><tr><td>';
         if ($section->{'description'}) {
           $OUT .=
             '</tr>'
         ;
         }
             '</tr>'
         ;
         }
+
+        if ($section->{'posttotal'}) {
+          $OUT .= '<tr><td align="right" colspan=3>';
+          $OUT .=
+            '<p><font size="+1">'. $section->{'posttotal'}.
+            '</font>'.
+            '<p>';
+          $OUT .= '</td></tr>';
+        }
+
       }
 
       my $style = 'border-top: 3px solid #000000;';
       }
 
       my $style = 'border-top: 3px solid #000000;';
index ece0897..aadd326 100644 (file)
@@ -19,7 +19,7 @@
 \r
 \documentclass[letterpaper]{article}\r
 \r
 \r
 \documentclass[letterpaper]{article}\r
 \r
-\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage}\r
+\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage,caption}\r
 \usepackage{graphicx}                  % required for logo graphic\r
 \r
 \addtolength{\voffset}{-0.0cm}         % top margin to top of header\r
 \usepackage{graphicx}                  % required for logo graphic\r
 \r
 \addtolength{\voffset}{-0.0cm}         % top margin to top of header\r
@@ -35,6 +35,8 @@
 \setlength{\oddsidemargin}{-0.9cm}     % odd page left margin\r
 \setlength{\evensidemargin}{-0.9cm}    % even page left margin\r
 \r
 \setlength{\oddsidemargin}{-0.9cm}     % odd page left margin\r
 \setlength{\evensidemargin}{-0.9cm}    % even page left margin\r
 \r
+\LTchunksize=40\r
+\r
 \renewcommand{\headrulewidth}{0pt}\r
 \renewcommand{\footrulewidth}{1pt}\r
 \r
 \renewcommand{\headrulewidth}{0pt}\r
 \renewcommand{\footrulewidth}{1pt}\r
 \r
@@ -188,11 +190,19 @@ Terms: [@-- $terms --@]\\
 \end{minipage}}\r
 \vspace{1.5cm}\r
 %\r
 \end{minipage}}\r
 \vspace{1.5cm}\r
 %\r
+\section*{}\r
 [@--\r
   foreach my $section ( @sections ) {\r
 [@--\r
   foreach my $section ( @sections ) {\r
-    $OUT .= '\section*{\textsc{';\r
-    $OUT .= ($section->{'description'}) ? $section->{'description'} : 'Charges';\r
-    $OUT .= '}}\begin{longtable}{cllllllr}';\r
+    if ($section->{'pretotal'}) {\r
+      $OUT .= '\begin{flushright}';\r
+      $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';\r
+      $OUT .= '\\end{flushright}';\r
+    }\r
+    $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';\r
+    $OUT .= '\begin{longtable}{cllllllr}';\r
+    $OUT .= '\caption*{ ';\r
+    $OUT .= ($section->{'description'}) ? $section->{'description'}: 'Charges';\r
+    $OUT .= '}\\\\';\r
     $OUT .= '\hline';\r
     $OUT .= '\rule{0pt}{2.5ex}';\r
     $OUT .= '\makebox[1.4cm]{\textbf{Ref}} & ';\r
     $OUT .= '\hline';\r
     $OUT .= '\rule{0pt}{2.5ex}';\r
     $OUT .= '\makebox[1.4cm]{\textbf{Ref}} & ';\r
@@ -256,6 +266,11 @@ Terms: [@-- $terms --@]\\
 \r
     $OUT .= '\end{longtable}';\r
 \r
 \r
     $OUT .= '\end{longtable}';\r
 \r
+    if ($section->{'posttotal'}) {\r
+      $OUT .= '\begin{flushright}';\r
+      $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';\r
+      $OUT .= '\\end{flushright}';\r
+    }\r
   }\r
 \r
 --@]\r
   }\r
 \r
 --@]\r