my( $self, $method ) = @_;
my $cust_main = $self->cust_main;
- my $amount = $self->owed;
+ my $balance = $cust_main->balance;
+ my $amount = ( $balance < $self->owed ) ? $balance : $self->owed;
+ $amount = sprintf("%.2f", $amount);
+ return "not run (balance $balance)" unless $amount > 0;
my $description = 'Internet Services';
if ( $conf->exists('business-onlinepayment-description') ) {
system('pslatex', "$file.tex");
system('pslatex', "$file.tex");
#system('dvips', '-t', 'letter', "$file.dvi", "$file.ps");
- system('dvips', '-t', 'letter', "$file.dvi" );
+ system('dvips', '-t', 'letter', "$file.dvi", '-o', "$file.ps" );
open(POSTSCRIPT, "<$file.ps") or die "can't open $file.ps (probable error in LaTeX template): $!\n";
}
+# quick subroutine for print_ps
+#
+# There are ten characters that LaTeX treats as special characters, which
+# means that they do not simply typeset themselves:
+# # $ % & ~ _ ^ \ { }
+#
+# TeX ignores blanks following an escaped character; if you want a blank (as
+# in "10% of ..."), you have to "escape" the blank as well ("10\%\ of ...").
+
+sub _latex_escape {
+ my $value = shift;
+ $value =~ s/([#\$%&~_\^{}])( )?/"\\$1". ( length($2) ? "\\$2" : '' )/ge;
+ $value;
+}
+
#utility methods for print_*
sub balance_due_msg {
my $self = shift;
my $msg = 'Balance Due';
+ return $msg unless $conf->exists('invoice_default_terms');
if ( $conf->config('invoice_default_terms') =~ /^\s*Net\s*(\d+)\s*$/ ) {
$msg .= ' - Please pay by '. time2str("%x", $self->_date + ($1*86400) );
} elsif ( $conf->config('invoice_default_terms') ) {