-\section*{\textsc{Charges}}\r
-\begin{longtable}{|c|l|c|r|r|}\r
-\hline\r
-\rule{0pt}{2.5ex}\r
-\makebox[1.4cm]{\textbf{Ref}} & \r
-\makebox[7.9cm][l]{\textbf{Description}} & \r
-\makebox[1.3cm][c]{\textbf{Quantity}} & \r
-\makebox[2.5cm][r]{\textbf{Unit Price}} & \r
-\makebox[2.5cm][r]{\textbf{Amount}} \\\r
-\hline\r
-\endfirsthead\r
-\multicolumn{5}{r}{\rule{0pt}{2.5ex}Continued from previous page}\\\r
-\hline\r
-\rule{0pt}{2.5ex}\r
-\makebox[1.4cm]{\textbf{Ref}} & \r
-\makebox[7.9cm][l]{\textbf{Description}} & \r
-\makebox[1.3cm][c]{\textbf{Quantity}} & \r
-\makebox[2.5cm][r]{\textbf{Unit Price}} & \r
-\makebox[2.5cm][r]{\textbf{Amount}} \\\r
-\hline\r
-\endhead\r
-\multicolumn{5}{r}{\rule{0pt}{2.5ex}/cont...}\\\r
-\endfoot\r
-%%TotalDetails\r
- & \multicolumn{3}{l}{$total_item} & $total_amount\\\r
-%%EndTotalDetails\r
-\hline\r
-\endlastfoot\r
-%%Detail\r
-\rule{0pt}{2.5ex}$ref & \r
-\begin{tabular}{l}\r
-$description\tabularnewline\r
-\end{tabular}\r
-& $quantity & \dollar $amount & \dollar $amount\\\hline\r
-%%EndDetail\r
-\end{longtable}\r
+[@-- $summary --@]\r
+%\r
+\section*{}\r
+[@--\r
+ foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {\r
+ if ($section->{'pretotal'} && !$summary) {\r
+ $OUT .= '\begin{flushright}';\r
+ $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';\r
+ $OUT .= '\\end{flushright}';\r
+ }\r
+ $OUT .= '\pagebreak' if $section->{'post_total'};\r
+ unless ($section->{'summarized'} ) {\r
+ $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';\r
+ $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'\r
+ if $coupon;\r
+ $OUT .= '\begin{longtable}{cllllllr}';\r
+ $OUT .= '\caption*{ ';\r
+ if ($section->{'location'}) {\r
+ $OUT .= $section->{'location'}{'label_prefix'}. ': '\r
+ if length($section->{'location'}{'label_prefix'});\r
+ $OUT .= $section->{'location'}{'address1'};\r
+ $OUT .= ', ' . $section->{'location'}{'address2'}\r
+ if length($section->{'location'}{'address2'});\r
+ $OUT .= ', ' .\r
+ $section->{'location'}{'city'} . ', ' .\r
+ $section->{'location'}{'state'} . '~' .\r
+ $section->{'location'}{'zip'};\r
+ } elsif ( $section->{'description'} ) {\r
+ $OUT .= ($section->{'description'});\r
+ } else {\r
+ $OUT .= emt('Charges');\r
+ }\r
+ $OUT .= '}\\\\';\r
+ if ($section->{header_generator}) {\r
+ $OUT .= &{$section->{header_generator}}();\r
+ } elsif ( $section->{usage_section} ) {\r
+ $OUT .= '\FSusagehead';\r
+ } else {\r
+ $OUT .= '\FShead';\r
+ }\r
+ $OUT .= '\endfirsthead';\r
+ $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued from previous page').'}\\\\';\r
+ if ($section->{header_generator}) {\r
+ $OUT .= &{$section->{header_generator}}();\r
+ } elsif ( $section->{usage_section} ) {\r
+ $OUT .= '\FSusagehead';\r
+ } else {\r
+ $OUT .= '\FShead';\r
+ }\r
+ $OUT .= '\endhead';\r
+ $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued on next page...').'}\\\\';\r
+ $OUT .= '\endfoot';\r
+ $OUT .= '\hline';\r
+\r
+ if (scalar(@sections) > 1 and !$section->{no_subtotal}) {\r
+ if ($section->{total_generator}) {\r
+ $OUT .= &{$section->{total_generator}}($section);\r
+ } else {\r
+ $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .\r
+ '{' . $section->{'subtotal'} . '}' . "\n";\r
+ }\r
+ }\r
+\r
+ #if ($section == $sections[$#sections]) {\r
+ foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {\r
+ if ($section->{total_line_generator}) {\r
+ $OUT .= &{$section->{total_line_generator}}($line);\r
+ } else {\r
+ $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .\r
+ '{' . $line->{'total_amount'} . '}' . "\n";\r
+ }\r
+ }\r
+ #}\r
+\r
+ $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
+ : 1\r
+ ) }\r
+ @detail_items )\r
+ {\r
+ my $ext_description = $line->{'ext_description'};\r
+ \r
+ # Don't break-up small packages.\r
+ my $rowbreak = @$ext_description < 5 ? '*' : '';\r
+ \r
+ $OUT .= "\\hline\n" if (($line->{'ref'} || 0) ne $lastref);\r
+ if ($section->{description_generator}) {\r
+ $OUT .= &{$section->{description_generator}}($line);\r
+ } elsif ($section->{usage_section}) {\r
+ my $minutes = sprintf('%d', $line->{'duration'} / 60);\r
+ my $seconds = $line->{'duration'} % 60;\r
+ $OUT .= '\FSusagedesc\r
+ {' . $line->{'description'} . '}\r
+ {' . $line->{'quantity'} . '}\r
+ {' . $minutes . 'm ' . $seconds . 's' . '}\r
+ {' . $line->{'amount'} . '}';\r
+ } else {\r
+ $OUT .= '\FSdesc'.\r
+ '{}'.\r
+ '{' . $line->{'description'} . '}' ;\r
+ if ( $unitprices and length($line->{'unit_amount'}) ) {\r
+ # then show the unit amount and quantity\r
+ $OUT .= \r
+ '{\\dollar' . $line->{'unit_amount'} . '}'.\r
+ '{' . $line->{'quantity'} . '}';\r
+ } else {\r
+ # leave those columns blank\r
+ $OUT .= '{}{}';\r
+ }\r
+ $OUT .= '{\\dollar' . $line->{'amount'} . "}${rowbreak}\n";\r
+ }\r
+ $lastref = $line->{'ref'} || 0;\r
+\r
+ foreach my $ext_desc (@$ext_description) {\r
+ if ($section->{extended_description_generator}) {\r
+ $OUT .= &{$section->{extended_description_generator}}($ext_desc);\r
+ } elsif ( $ext_desc !~ /[^\\]&/ ) {\r
+ $OUT .= '\FSextdesc{' . $ext_desc . "}$rowbreak\n";\r
+ } else { # call detail\r
+ $OUT .= '\FScalldetail{' . $ext_desc . "}$rowbreak\n";\r
+ }\r
+ }\r
+\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