summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeff <jeff>2010-06-23 08:38:58 +0000
committerjeff <jeff>2010-06-23 08:38:58 +0000
commit4010185511b3f3fdd4756ff11e856a0cd46f372c (patch)
treecb9a6e8bc9be15daf0347830305962f5203d1abe
parenta09d2584f08b0215e25b01f013acb99b8abce2ee (diff)
add config variables to position invoice addresses in envelope windows RT8384
-rw-r--r--FS/FS/Conf.pm112
-rw-r--r--FS/FS/cust_bill.pm21
-rw-r--r--conf/invoice_latex15
-rw-r--r--conf/invoice_latexcoupon12
4 files changed, 143 insertions, 17 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index cf79b1f..5435aba 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -968,6 +968,55 @@ worry that config_items is freeside-specific and icky.
},
{
+ 'key' => 'invoice_latextopmargin',
+ 'section' => 'invoicing',
+ 'description' => 'Optional LaTeX invoice topmargin setting. Include units.',
+ 'type' => 'text',
+ 'per_agent' => 1,
+ 'validate' => sub { shift =~
+ /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+ ? '' : 'Invalid LaTex length';
+ },
+ },
+
+ {
+ 'key' => 'invoice_latexheadsep',
+ 'section' => 'invoicing',
+ 'description' => 'Optional LaTeX invoice headsep setting. Include units.',
+ 'type' => 'text',
+ 'per_agent' => 1,
+ 'validate' => sub { shift =~
+ /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+ ? '' : 'Invalid LaTex length';
+ },
+ },
+
+ {
+ 'key' => 'invoice_latexaddresssep',
+ 'section' => 'invoicing',
+ 'description' => 'Optional LaTeX invoice separation between invoice header
+and customer address. Include units.',
+ 'type' => 'text',
+ 'per_agent' => 1,
+ 'validate' => sub { shift =~
+ /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+ ? '' : 'Invalid LaTex length';
+ },
+ },
+
+ {
+ 'key' => 'invoice_latextextheight',
+ 'section' => 'invoicing',
+ 'description' => 'Optional LaTeX invoice textheight setting. Include units.',
+ 'type' => 'text',
+ 'per_agent' => 1,
+ 'validate' => sub { shift =~
+ /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+ ? '' : 'Invalid LaTex length';
+ },
+ },
+
+ {
'key' => 'invoice_latexnotes',
'section' => 'invoicing',
'description' => 'Notes section for LaTeX typeset PostScript invoices.',
@@ -1000,6 +1049,53 @@ worry that config_items is freeside-specific and icky.
},
{
+ 'key' => 'invoice_latexextracouponspace',
+ 'section' => 'invoicing',
+ 'description' => 'Optional LaTeX invoice textheight space to reserve for a tear off coupon. Include units.',
+ 'type' => 'text',
+ 'per_agent' => 1,
+ 'validate' => sub { shift =~
+ /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+ ? '' : 'Invalid LaTex length';
+ },
+ },
+
+ {
+ 'key' => 'invoice_latexcouponfootsep',
+ 'section' => 'invoicing',
+ 'description' => 'Optional LaTeX invoice separation between tear off coupon and footer. Include units.',
+ 'type' => 'text',
+ 'per_agent' => 1,
+ 'validate' => sub { shift =~
+ /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+ ? '' : 'Invalid LaTex length';
+ },
+ },
+
+ {
+ 'key' => 'invoice_latexcouponamountenclosedsep',
+ 'section' => 'invoicing',
+ 'description' => 'Optional LaTeX invoice separation between total due and amount enclosed line. Include units.',
+ 'type' => 'text',
+ 'per_agent' => 1,
+ 'validate' => sub { shift =~
+ /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+ ? '' : 'Invalid LaTex length';
+ },
+ },
+ {
+ 'key' => 'invoice_latexcoupontoaddresssep',
+ 'section' => 'invoicing',
+ 'description' => 'Optional LaTeX invoice separation between invoice data and the to address (usually invoice_latexreturnaddress). Include units.',
+ 'type' => 'text',
+ 'per_agent' => 1,
+ 'validate' => sub { shift =~
+ /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+ ? '' : 'Invalid LaTex length';
+ },
+ },
+
+ {
'key' => 'invoice_latexreturnaddress',
'section' => 'invoicing',
'description' => 'Return address for LaTeX typeset PostScript invoices.',
@@ -1007,6 +1103,22 @@ worry that config_items is freeside-specific and icky.
},
{
+ 'key' => 'invoice_latexverticalreturnaddress',
+ 'section' => 'invoicing',
+ 'description' => 'Place the return address under the company logo rather than beside it.',
+ 'type' => 'checkbox',
+ 'per_agent' => 1,
+ },
+
+ {
+ 'key' => 'invoice_latexcouponaddcompanytoaddress',
+ 'section' => 'invoicing',
+ 'description' => 'Add the company name to the To address on the remittance coupon because the return address does not contain it.',
+ 'type' => 'checkbox',
+ 'per_agent' => 1,
+ },
+
+ {
'key' => 'invoice_latexsmallfooter',
'section' => 'invoicing',
'description' => 'Optional small footer for multi-page LaTeX typeset PostScript invoices.',
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index c5bc8af..46c591e 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -2278,11 +2278,13 @@ sub print_generic {
}
+ my $agentnum = $self->cust_main->agentnum;
+
my %invoice_data = (
#invoice from info
- 'company_name' => scalar( $conf->config('company_name', $self->cust_main->agentnum) ),
- 'company_address' => join("\n", $conf->config('company_address', $self->cust_main->agentnum) ). "\n",
+ 'company_name' => scalar( $conf->config('company_name', $agentnum) ),
+ 'company_address' => join("\n", $conf->config('company_address', $agentnum) ). "\n",
'returnaddress' => $returnaddress,
'agent' => &$escape_function($cust_main->agent->agent),
@@ -2310,6 +2312,19 @@ sub print_generic {
'smallerfooter' => $conf->exists('invoice-smallerfooter'),
'balance_due_below_line' => $conf->exists('balance_due_below_line'),
+ #layout info -- would be fancy to calc some of this and bury the template
+ # here in the code
+ 'topmargin' => scalar($conf->config('invoice_latextopmargin', $agentnum)),
+ 'headsep' => scalar($conf->config('invoice_latexheadsep', $agentnum)),
+ 'textheight' => scalar($conf->config('invoice_latextextheight', $agentnum)),
+ 'extracouponspace' => scalar($conf->config('invoice_latexextracouponspace', $agentnum)),
+ 'couponfootsep' => scalar($conf->config('invoice_latexcouponfootsep', $agentnum)),
+ 'verticalreturnaddress' => $conf->exists('invoice_latexverticalreturnaddress', $agentnum),
+ 'addresssep' => scalar($conf->config('invoice_latexaddresssep', $agentnum)),
+ 'amountenclosedsep' => scalar($conf->config('invoice_latexcouponamountenclosedsep', $agentnum)),
+ 'coupontoaddresssep' => scalar($conf->config('invoice_latexcoupontoaddresssep', $agentnum)),
+ 'addcompanytoaddress' => $conf->exists('invoice_latexcouponaddcompanytoaddress', $agentnum),
+
# better hang on to conf_dir for a while (for old templates)
'conf_dir' => "$FS::UID::conf_dir/conf.$FS::UID::datasrc",
@@ -2378,8 +2393,6 @@ sub print_generic {
$invoice_data{'previous_balance'} = sprintf("%.2f", $pr_total);
$invoice_data{'balance'} = sprintf("%.2f", $balance_due);
- my $agentnum = $self->cust_main->agentnum;
-
my $summarypage = '';
if ( $conf->exists('invoice_usesummary', $agentnum) ) {
$summarypage = 1;
diff --git a/conf/invoice_latex b/conf/invoice_latex
index d37eeba..29a901d 100644
--- a/conf/invoice_latex
+++ b/conf/invoice_latex
@@ -24,14 +24,14 @@
\addtolength{\voffset}{-0.0cm} % top margin to top of header
\addtolength{\hoffset}{-0.6cm} % left margin on page
-\addtolength{\topmargin}{-1.25cm} % top margin to top of header
+\addtolength{\topmargin}{[@-- defined($topmargin) ? $topmargin : '-1.25cm' --@]}
\setlength{\headheight}{2.0cm} % height of header
-\setlength{\headsep}{1.0cm} % between header and text
+\setlength{\headsep}{[@-- defined($headsep) ? $headsep : '1.0cm' --@]}
\setlength{\footskip}{1.0cm} % bottom of footer from bottom of text
%\addtolength{\textwidth}{2.1in} % width of text
\setlength{\textwidth}{19.5cm}
-\setlength{\textheight}{19.5cm}
+\setlength{\textheight}{[@-- defined($textheight) ? $textheight : '19.5cm' --@]}
\setlength{\oddsidemargin}{-0.9cm} % odd page left margin
\setlength{\evensidemargin}{-0.9cm} % even page left margin
@@ -51,7 +51,7 @@
}
}
-\newcommand{\extracouponspace}{3.6cm}
+\newcommand{\extracouponspace}{[@-- defined($extracouponspace) ? $extracouponspace : '3.6cm' --@]}
% Adjust the inset of the mailing address
\newcommand{\addressinset}[1][]{\hspace{1.0cm}}
@@ -80,6 +80,7 @@
$OUT .= '\vspace{-\extracouponspace}';
$OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';
$OUT .= $coupon;
+ $OUT .= '\vspace{'. $couponfootsep. '}' if defined($couponfootsep);
}
'';
--@] [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
@@ -108,10 +109,10 @@
\returninset
\makebox{
\begin{tabular}{ll}
- \includegraphics{[@-- $logo_file --@]} &
+ \includegraphics{[@-- $logo_file --@]} & [@-- $verticalreturnaddress ? '\\\\' : '' --@]
\begin{minipage}[b]{5.5cm}
[@-- $returnaddress --@]
- \end{minipage}
+ \end{minipage}\\
\end{tabular}
}
}
@@ -201,7 +202,7 @@
\addressinset \rule{0.5cm}{0cm}
\makebox{
\begin{minipage}[t]{7.0cm}
-\vspace{0.25cm}
+\vspace{[@-- defined($addresssep) ? $addresssep : '0.25cm' --@]}
\textbf{[@-- $payname --@]}\\
\addressline{[@-- $company --@]}
\addressline{[@-- $address1 --@]}
diff --git a/conf/invoice_latexcoupon b/conf/invoice_latexcoupon
index 327c121..a4ccddd 100644
--- a/conf/invoice_latexcoupon
+++ b/conf/invoice_latexcoupon
@@ -3,13 +3,13 @@ Detach and return this remittance form with your your payment.\\
\begin{tabular}{ll}
\returninset
\begin{tabular}{ll}
- \makebox{ \includegraphics{[@-- $logo_file --@]}} &
+ \makebox{ \includegraphics{[@-- $logo_file --@]}} & [@-- $verticalreturnaddress ? '\\\\' : '' --@]
\begin{minipage}[b]{5.5cm}
[@-- $returnaddress --@]
- \end{minipage}
+ \end{minipage}\\
\end{tabular}&
\begin{tabular}{r@{: }lr}
-Invoice date & \textbf{[@-- $date --@]} & \multirow{4}*{
+Invoice date & \textbf{[@-- $date --@]} & \multirow{4}*{[@-- $verticalreturnaddress ? '\\rule{1.5cm}{0cm}' : '' --@]
\makebox{
\begin{minipage}[t]{7.0cm}
\textbf{[@-- $payname --@]}\\
@@ -21,15 +21,15 @@ Invoice date & \textbf{[@-- $date --@]} & \multirow{4}*{
\end{minipage}}}\\
Customer\#& \textbf{[@-- $custnum --@]} & \\
Total Due & \textbf{[@-- $balance --@]} & \\
-\rule{0pt}{2.25em}Amount Enclosed & \rule{2cm}{1pt}& \\
+\rule{0pt}{[@-- defined($amountenclosedsep) ? $amountenclosedsep : '2.25em' --@]}Amount Enclosed & \rule{2cm}{1pt}& \\
\end{tabular}\\
-\rule{0pt}{1cm} &\\
+\rule{0pt}{[@-- defined($coupontoaddresssep) ? $coupontoaddresssep : '1cm' --@]} &\\
\end{tabular}\\
\begin{tabular}{ll}
\addressinset \rule{0.5cm}{0cm} &
\makebox{
\begin{minipage}[t]{7.0cm}
-[@-- $returnaddress --@]
+[@-- $addcompanytoaddress ? $company_name. '\\\\' : '' --@][@-- $returnaddress --@]
\end{minipage}}
\hfill
\end{tabular}\\