communigate provisioning phase 2: add svc_domain.trailer -> communigate TrailerText...
[freeside.git] / FS / FS / discount.pm
index 457c9d6..8afeb2e 100644 (file)
@@ -113,6 +113,16 @@ and replace methods.
 sub check {
   my $self = shift;
 
+  if ( $self->_type eq 'Select discount type' ) {
+    return 'Please select a discount type';
+  } elsif ( $self->_type eq 'Amount' ) {
+    $self->percent('0');
+    return 'Amount must be greater than 0' unless $self->amount > 0;
+  } elsif ( $self->_type eq 'Percentage' ) {
+    $self->amount('0.00');
+    return 'Percentage must be greater than 0' unless $self->percent > 0;
+  }
+
   my $error = 
     $self->ut_numbern('discountnum')
     || $self->ut_textn('name')
@@ -142,7 +152,7 @@ sub description_short {
   my $conf = new FS::Conf;
   my $money_char = $conf->config('money_char') || '$';  
 
-  my $desc = '';
+  my $desc = $self->name ? $self->name.': ' : '';
   $desc .= $money_char. sprintf('%.2f/month ', $self->amount)
     if $self->amount > 0;
   $desc .= $self->percent. '% '