From 1d2c5120add6c4c63723c7ef896b5d0b8fe962df Mon Sep 17 00:00:00 2001 From: jeff Date: Mon, 2 Jun 2008 11:16:09 +0000 Subject: [PATCH] typeset tear-off remittance coupon --- FS/FS/Conf.pm | 23 ++++++++--------------- FS/FS/Conf_compat17.pm | 7 +++++++ FS/FS/cust_bill.pm | 22 +++++++++++++--------- conf/invoice_latex | 33 +++++++++++++++++++++++++++------ conf/invoice_latexcoupon | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 30 deletions(-) create mode 100644 conf/invoice_latexcoupon diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 2b47bf0b5..2750124ed 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -533,21 +533,7 @@ worry that config_items is freeside-specific and icky. invoice_latexfooter invoice_latexsmallfooter invoice_latexnotes - invoice_html - invoice_htmlreturnaddress - invoice_htmlfooter - invoice_htmlnotes - logo.png - logo.eps - ); - -@base_items = qw ( - invoice_template - invoice_latex - invoice_latexreturnaddress - invoice_latexfooter - invoice_latexsmallfooter - invoice_latexnotes + invoice_latexcoupon invoice_html invoice_htmlreturnaddress invoice_htmlfooter @@ -830,6 +816,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/Conf_compat17.pm b/FS/FS/Conf_compat17.pm index e9e25bb13..19e2e5d41 100644 --- a/FS/FS/Conf_compat17.pm +++ b/FS/FS/Conf_compat17.pm @@ -693,6 +693,13 @@ httemplate/docs/config.html }, { + '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 1f837de84..69c572200 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1671,6 +1671,7 @@ sub print_generic { 'footer' => sub { map "$_", @_ }, 'smallfooter' => sub { map "$_", @_ }, 'returnaddress' => sub { map "$_", @_ }, + 'coupon' => sub { map "$_", @_ }, }, 'html' => { 'notes' => @@ -1702,6 +1703,7 @@ sub print_generic { $_; } @_ }, + 'coupon' => sub { "" }, }, 'template' => { 'notes' => @@ -1731,6 +1733,7 @@ sub print_generic { $_; } @_ }, + 'coupon' => sub { "" }, }, ); @@ -1872,8 +1875,17 @@ sub print_generic { push @address, '' while (scalar(@address) < 5); + $invoice_data{'logo_file'} = $params{'logo_file'} + if $params{'logo_file'}; + + my( $pr_total, @pr_cust_bill ) = $self->previous; #previous balance +# my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits + #my $balance_due = $self->owed + $pr_total - $cr_total; + my $balance_due = $self->owed + $pr_total; + $invoice_data{'balance'} = $balance_due; + #do variable substitution in notes, footer, smallfooter - foreach my $include (qw( notes footer smallfooter )) { + foreach my $include (qw( notes footer smallfooter coupon )) { my $inc_file = $conf->key_orbase("invoice_${format}$include", $template); my @inc_src; @@ -1919,11 +1931,6 @@ sub print_generic { ? &$escape_function("Purchase Order #". $cust_main->payinfo) : $nbsp; - my( $pr_total, @pr_cust_bill ) = $self->previous; #previous balance -# my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits - #my $balance_due = $self->owed + $pr_total - $cr_total; - my $balance_due = $self->owed + $pr_total; - my %money_chars = ( 'latex' => '', 'html' => $conf->config('money_char') || '$', 'template' => '', @@ -2233,9 +2240,6 @@ sub print_generic { } } - $invoice_data{'logo_file'} = $params{'logo_file'} - if $params{'logo_file'}; - $invoice_lines = 0; my $wasfunc = 0; foreach ( grep /invoice_lines\(\d*\)/, @invoice_template ) { #kludgy diff --git a/conf/invoice_latex b/conf/invoice_latex index aadd326c5..7e5ecdd81 100644 --- a/conf/invoice_latex +++ b/conf/invoice_latex @@ -19,7 +19,7 @@ \documentclass[letterpaper]{article} -\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage,caption} +\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage,caption,multirow,bigstrut} \usepackage{graphicx} % required for logo graphic \addtolength{\voffset}{-0.0cm} % top margin to top of header @@ -40,6 +40,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}} @@ -62,9 +75,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{ @@ -167,6 +187,7 @@ % % % +[@-- $coupon ? '\enlargethispage{-\extracouponspace}' : '' --@] \begin{tabular}{ll} \addressinset \rule{0cm}{0cm} & \makebox{ @@ -227,12 +248,12 @@ Terms: [@-- $terms --@]\\ '{' . $section->{'subtotal'} . '}' . "\n"; } - if ($section == $sections[$#sections]) { - foreach my $line (@total_items) { + #if ($section == $sections[$#sections]) { + foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) { $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' . '{' . $line->{'total_amount'} . '}' . "\n"; } - } + #} $OUT .= '\hline'; $OUT .= '\endlastfoot'; diff --git a/conf/invoice_latexcoupon b/conf/invoice_latexcoupon new file mode 100644 index 000000000..8cbdb5239 --- /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{[@-- $logo_file --@]}} & + \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}\\ -- 2.11.0