bring some sanity to address block selection in svc_broadband service definition...
[freeside.git] / FS / FS / cust_main.pm
index 09a0cfd..b58a52c 100644 (file)
@@ -3169,7 +3169,7 @@ sub realtime_bop {
     'gatewaynum' => ( $payment_gateway ? $payment_gateway->gatewaynum : '' ),
   };
   $cust_pay_pending->payunique( $options{payunique} )
-    if length($options{payunique});
+    if defined($options{payunique}) && length($options{payunique});
   my $cpp_new_err = $cust_pay_pending->insert; #mutex lost when this is inserted
   return $cpp_new_err if $cpp_new_err;
 
@@ -3322,7 +3322,8 @@ sub realtime_bop {
        'paydate'  => $paydate,
     } );
     #doesn't hurt to know, even though the dup check is in cust_pay_pending now
-    $cust_pay->payunique( $options{payunique} ) if length($options{payunique});
+    $cust_pay->payunique( $options{payunique} )
+      if defined($options{payunique}) && length($options{payunique});
 
     my $oldAutoCommit = $FS::UID::AutoCommit;
     local $FS::UID::AutoCommit = 0;
@@ -4632,13 +4633,14 @@ the error, otherwise returns false.
 
 sub charge {
   my $self = shift;
-  my ( $amount, $pkg, $comment, $taxclass, $additional );
+  my ( $amount, $pkg, $comment, $taxclass, $additional, $classnum );
   if ( ref( $_[0] ) ) {
     $amount     = $_[0]->{amount};
     $pkg        = exists($_[0]->{pkg}) ? $_[0]->{pkg} : 'One-time charge';
     $comment    = exists($_[0]->{comment}) ? $_[0]->{comment}
                                            : '$'. sprintf("%.2f",$amount);
     $taxclass   = exists($_[0]->{taxclass}) ? $_[0]->{taxclass} : '';
+    $classnum   = exists($_[0]->{classnum}) ? $_[0]->{classnum} : '';
     $additional = $_[0]->{additional};
   }else{
     $amount     = shift;
@@ -4665,6 +4667,7 @@ sub charge {
     'plan'     => 'flat',
     'freq'     => 0,
     'disabled' => 'Y',
+    'classnum' => $classnum ? $classnum : '',
     'taxclass' => $taxclass,
   } );
 
@@ -5190,8 +5193,8 @@ sub _money_table_where {
   my @where = ();
   push @where, "cust_main.custnum = $table.custnum" unless $opt{'total'};
   if ( $table eq 'cust_bill' || $opt{'unapplied_date'} ) {
-    push @where, "$table._date <= $start" if length($start);
-    push @where, "$table._date >  $end"   if length($end);
+    push @where, "$table._date <= $start" if defined($start) && length($start);
+    push @where, "$table._date >  $end"   if defined($end)   && length($end);
   }
   push @where, @{$opt{'where'}} if $opt{'where'};
   my $where = scalar(@where) ? 'WHERE '. join(' AND ', @where ) : '';