-\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
+\section*{}\r
+[@--\r
+ foreach my $section ( @sections ) {\r
+ if ($section->{'pretotal'}) {\r
+ $OUT .= '\begin{flushright}';\r
+ $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';\r
+ $OUT .= '\\end{flushright}';\r
+ }\r
+ $OUT .= '\pagebreak' if $section{'post_total'};\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 .= '\makebox[2.0cm][l]{\textbf{Description}}& ';\r
+ $OUT .= '\makebox[2.0cm][l]{}& ';\r
+ $OUT .= '\makebox[2.0cm][l]{}& ';\r
+ $OUT .= '\makebox[2.0cm][l]{}& ';\r
+ $OUT .= '\makebox[2.0cm][l]{\textbf{'. ($unitprices ? '~~Unit Price' : ''). '}}&';\r
+ $OUT .= '\makebox[2.0cm]{\textbf{'. ($unitprices ? '~Quantity' : ''). '}}&';\r
+ $OUT .= '\makebox[2.0cm][r]{\textbf{Amount}} \\\\';\r
+ $OUT .= '\hline';\r
+ $OUT .= '\endfirsthead';\r
+ $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued from previous page}\\\\';\r
+ $OUT .= '\hline';\r
+ $OUT .= '\rule{0pt}{2.5ex}';\r
+ $OUT .= '\makebox[1.4cm]{\textbf{Ref}} & ';\r
+ $OUT .= '\makebox[2.0cm][l]{\textbf{Description}}& ';\r
+ $OUT .= '\makebox[2.0cm][l]{}& ';\r
+ $OUT .= '\makebox[2.0cm][l]{}& ';\r
+ $OUT .= '\makebox[2.0cm][l]{}& ';\r
+ $OUT .= '\makebox[2.0cm][l]{\textbf{'. ($unitprices ? '~~Unit Price' : ''). '}}&';\r
+ $OUT .= '\makebox[2.0cm]{\textbf{'. ($unitprices ? '~Quantity' : ''). '}}&';\r
+ $OUT .= '\makebox[2.0cm][r]{\textbf{Amount}} \\\\';\r
+ $OUT .= '\hline';\r
+ $OUT .= '\endhead';\r
+ $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued on next page...}\\\\';\r
+ $OUT .= '\endfoot';\r
+ $OUT .= '\hline';\r
+\r
+ if (scalar(@sections) > 1) {\r
+ $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .\r
+ '{' . $section->{'subtotal'} . '}' . "\n";\r
+ }\r
+\r
+ #if ($section == $sections[$#sections]) {\r
+ foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {\r
+ $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .\r
+ '{' . $line->{'total_amount'} . '}' . "\n";\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'} && $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
+ $ext_desc = substr($ext_desc, 0, 80) . '...'\r
+ if (length($ext_desc) > 80);\r
+ $ext_desc = '\multicolumn{6}{l}{\small{~~~'. $ext_desc. '}}';\r
+ }else{\r
+ $ext_desc = "~~~$ext_desc";\r
+ }\r
+ $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";\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