fix 'Can't call method "setup" on an undefined value' error when using into rates...
[freeside.git] / FS / FS / cust_pkg_discount.pm
index d41f497..a207940 100644 (file)
@@ -171,6 +171,9 @@ sub check {
   ;
   return $error if $error;
 
+  return "Discount does not apply to setup fees, and package has no recurring"
+    if ! $self->discount->setup && $self->cust_pkg->part_pkg->freq =~ /^0/;
+
   $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum;
 
   $self->SUPER::check;