X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_bill.pm;h=e5c19668d9b4f0e35406257e79be3b6c8985ae4a;hp=64759f9bfd5ff74b13ae21a2bb8687fcc47c0af7;hb=d20581bcbf2809d5c2969d773b16a0c8714a6dec;hpb=d6297be89acbef3cdf9fce4925f797063583b066 diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 64759f9bf..e5c19668d 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -594,7 +594,10 @@ sub realtime_bop { 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') ) { @@ -1071,7 +1074,7 @@ sub print_ps { 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"; @@ -1090,11 +1093,27 @@ sub print_ps { } +# 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') ) {