diff options
author | jeff <jeff> | 2008-06-02 11:17:20 +0000 |
---|---|---|
committer | jeff <jeff> | 2008-06-02 11:17:20 +0000 |
commit | f7f6eb47c07f0280cb7f73f3dd42ffa423931a7d (patch) | |
tree | 83f62e2a3e9f79f8d17e3b60210a1edfbd69333e | |
parent | dde013cbccc4599212ef9e0ed13a30deb6583a43 (diff) |
typeset tear-off remittance coupon
-rw-r--r-- | FS/FS/Conf.pm | 7 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 23 | ||||
-rw-r--r-- | conf/invoice_latex | 27 | ||||
-rw-r--r-- | conf/invoice_latexcoupon | 33 |
4 files changed, 87 insertions, 3 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index c36ce5ee5..4a1760fd1 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -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.', diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 35daea726..db811c50b 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -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+$//; diff --git a/conf/invoice_latex b/conf/invoice_latex index e3feeef33..442965a3c 100644 --- a/conf/invoice_latex +++ b/conf/invoice_latex @@ -19,7 +19,7 @@ \documentclass[letterpaper]{article}
-\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage}
+\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage,multirow,bigstrut}
\usepackage{graphicx} % required for logo graphic
\addtolength{\voffset}{-0.0cm} % top margin to top of header
@@ -38,6 +38,19 @@ \renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{1pt}
+\renewcommand{\footrule}{
+[@--
+ $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';
+--@]
+ {
+ }
+ {
+ \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}
+ }
+}
+
+\newcommand{\extracouponspace}{4.8cm}
+
% Adjust the inset of the mailing address
\newcommand{\addressinset}[1][]{\hspace{1.0cm}}
@@ -60,9 +73,16 @@ \fancyfoot[C]{
\ifthenelse{\equal{\thepage}{1}}
{ % First page
- \small{
+[@--
+ if ($coupon) {
+ $OUT .= '\vspace{-\extracouponspace}';
+ $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';
+ $OUT .= $coupon;
+ }
+ '';
+--@] \small{
[@-- $footer --@]
- }
+ }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]
}
{ % ... pages
\small{
@@ -165,6 +185,7 @@ %
%
%
+[@-- $coupon ? '\enlargethispage{-\extracouponspace}' : '' --@]
\begin{tabular}{ll}
\addressinset \rule{0cm}{0cm} &
\makebox{
diff --git a/conf/invoice_latexcoupon b/conf/invoice_latexcoupon new file mode 100644 index 000000000..e7c5dee6e --- /dev/null +++ b/conf/invoice_latexcoupon @@ -0,0 +1,33 @@ +Detach and return this remittance form with your your payment.\\
+\begin{tabular}{ll}
+\returninset
+\begin{tabular}{ll}
+ \makebox{ \includegraphics{[@-- $conf_dir --@]/logo.eps}} &
+ \begin{minipage}[b]{5.5cm}
+[@-- $returnaddress --@]
+ \end{minipage}
+\end{tabular}&
+\begin{tabular}{r@{: }lr}
+Invoice date & \textbf{[@-- $date --@]} & \multirow{4}*{
+\makebox{
+\begin{minipage}[t]{5.0cm}
+\textbf{[@-- $payname --@]}\\
+\addressline{[@-- $company --@]}
+\addressline{[@-- $address1 --@]}
+\addressline{[@-- $address2 --@]}
+\addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}
+\addressline{[@-- $country --@]}
+\end{minipage}}}\\
+Customer\#& \textbf{[@-- $custnum --@]} & \\
+Total Due & \textbf{[@-- $balance --@]} & \\
+\rule{0pt}{2.25em}Amount Enclosed & \rule{2cm}{1pt}& \\
+\end{tabular}\\
+\rule{0pt}{1cm} &\\
+\begin{tabular}{ll}
+\addressinset \rule{0.5cm}{0cm} &
+\makebox{
+\begin{minipage}[t]{5.0cm}
+[@-- $returnaddress --@]
+\end{minipage}}
+\end{tabular}\\
+\end{tabular}\\
|