typeset tear-off remittance coupon
authorjeff <jeff>
Mon, 2 Jun 2008 11:17:20 +0000 (11:17 +0000)
committerjeff <jeff>
Mon, 2 Jun 2008 11:17:20 +0000 (11:17 +0000)
FS/FS/Conf.pm
FS/FS/cust_bill.pm
conf/invoice_latex
conf/invoice_latexcoupon [new file with mode: 0644]

index c36ce5e..4a1760f 100644 (file)
@@ -698,6 +698,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'invoice_latexcoupon',
+    'section'     => 'billing',
+    'description' => 'Remittance coupon for LaTeX typeset PostScript invoices.',
+    'type'        => 'textarea',
+  },
+
+  {
     'key'         => 'invoice_latexreturnaddress',
     'section'     => 'billing',
     'description' => 'Return address for LaTeX typeset PostScript invoices.',
index 35daea7..db811c5 100644 (file)
@@ -1810,6 +1810,7 @@ sub print_latex {
     'terms'        => $conf->config('invoice_default_terms') || 'Payable upon receipt',
     #'notes'        => join("\n", $conf->config('invoice_latexnotes') ),
     'conf_dir'     => "$FS::UID::conf_dir/conf.$FS::UID::datasrc",
+    'balance'      => $balance_due,
   );
 
   my $countrydefault = $conf->config('countrydefault') || 'US';
@@ -1828,6 +1829,28 @@ sub print_latex {
   warn "invoice notes: ". $invoice_data{'notes'}. "\n"
     if $DEBUG;
 
+  #do variable substitution in coupon
+  foreach my $include (qw( coupon )) {
+
+    my @inc_src = $conf->config_orbase("invoice_latex$include", $template);
+
+    my $inc_tt = new Text::Template (
+      TYPE       => 'ARRAY',
+      SOURCE     => [ map "$_\n", @inc_src ],
+      DELIMITERS => [ '[@--', '--@]' ],
+    ) or die "Can't create new Text::Template object: $Text::Template::ERROR";
+
+    unless ( $inc_tt->compile() ) {
+      my $error = "Can't compile $include template: $Text::Template::ERROR\n";
+      warn $error. "Template:\n". join('', map "$_\n", @inc_src);
+      die $error;
+    }
+
+    $invoice_data{$include} = $inc_tt->fill_in( HASH => \%invoice_data );
+
+    $invoice_data{$include} =~ s/\n+$//
+  }
+
   $invoice_data{'footer'} =~ s/\n+$//;
   $invoice_data{'smallfooter'} =~ s/\n+$//;
   $invoice_data{'notes'} =~ s/\n+$//;
index e3feeef..442965a 100644 (file)
@@ -19,7 +19,7 @@
 \r
 \documentclass[letterpaper]{article}\r
 \r
-\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage}\r
+\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage,multirow,bigstrut}\r
 \usepackage{graphicx}                  % required for logo graphic\r
 \r
 \addtolength{\voffset}{-0.0cm}         % top margin to top of header\r
 \renewcommand{\headrulewidth}{0pt}\r
 \renewcommand{\footrulewidth}{1pt}\r
 \r
+\renewcommand{\footrule}{\r
+[@--\r
+  $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';\r
+--@]\r
+  {\r
+  }\r
+  {\r
+    \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}\r
+  }\r
+}\r
+\r
+\newcommand{\extracouponspace}{4.8cm}\r
+\r
 % Adjust the inset of the mailing address\r
 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}\r
 \r
 \fancyfoot[C]{\r
   \ifthenelse{\equal{\thepage}{1}}\r
   { % First page\r
-    \small{\r
+[@--\r
+  if ($coupon) {\r
+    $OUT .= '\vspace{-\extracouponspace}';\r
+    $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';\r
+    $OUT .= $coupon;\r
+  }\r
+  '';\r
+--@] \small{\r
 [@-- $footer --@]\r
-    }\r
+    }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]\r
   }\r
   { % ... pages\r
     \small{\r
 %\r
 %\r
 %\r
+[@-- $coupon ? '\enlargethispage{-\extracouponspace}' : '' --@]\r
 \begin{tabular}{ll}\r
 \addressinset \rule{0cm}{0cm} &\r
 \makebox{\r
diff --git a/conf/invoice_latexcoupon b/conf/invoice_latexcoupon
new file mode 100644 (file)
index 0000000..e7c5dee
--- /dev/null
@@ -0,0 +1,33 @@
+Detach and return this remittance form with your your payment.\\\r
+\begin{tabular}{ll}\r
+\returninset\r
+\begin{tabular}{ll}\r
+  \makebox{ \includegraphics{[@-- $conf_dir --@]/logo.eps}} &\r
+  \begin{minipage}[b]{5.5cm}\r
+[@-- $returnaddress --@]\r
+    \end{minipage}\r
+\end{tabular}&\r
+\begin{tabular}{r@{: }lr}\r
+Invoice date & \textbf{[@-- $date --@]} & \multirow{4}*{\r
+\makebox{\r
+\begin{minipage}[t]{5.0cm}\r
+\textbf{[@-- $payname --@]}\\\r
+\addressline{[@-- $company --@]}\r
+\addressline{[@-- $address1 --@]}\r
+\addressline{[@-- $address2 --@]}\r
+\addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}\r
+\addressline{[@-- $country --@]}\r
+\end{minipage}}}\\\r
+Customer\#& \textbf{[@-- $custnum --@]} & \\\r
+Total Due & \textbf{[@-- $balance --@]} & \\\r
+\rule{0pt}{2.25em}Amount Enclosed & \rule{2cm}{1pt}& \\\r
+\end{tabular}\\\r
+\rule{0pt}{1cm} &\\\r
+\begin{tabular}{ll}\r
+\addressinset \rule{0.5cm}{0cm} &\r
+\makebox{\r
+\begin{minipage}[t]{5.0cm}\r
+[@-- $returnaddress --@]\r
+\end{minipage}}\r
+\end{tabular}\\\r
+\end{tabular}\\\r