add svc_external
[freeside.git] / FS / FS / cust_bill.pm
index 353ab49..e5c1966 100644 (file)
@@ -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') ) {
@@ -1110,6 +1113,7 @@ sub _latex_escape {
 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') ) {