X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fdiscount.pm;h=f6f9945998f2ef9dc2e1e86488e7513d6b6da324;hb=fc8d730d0a7b31b617c963c5619bd3f45c5c3eb6;hp=6fc3391caec21acffc19e5af8a1bd4d0fd2bdd06;hpb=e774555a6ae69da65e7774c701232fdf9dd052b1;p=freeside.git diff --git a/FS/FS/discount.pm b/FS/FS/discount.pm index 6fc3391ca..f6f994599 100644 --- a/FS/FS/discount.pm +++ b/FS/FS/discount.pm @@ -136,6 +136,7 @@ sub check { || $self->ut_floatn('months') #actually decimal, but this will do || $self->ut_enum('disabled', [ '', 'Y' ]) || $self->ut_enum('setup', [ '', 'Y' ]) + #|| $self->ut_enum('linked', [ '', 'Y' ]) ; return $error if $error; @@ -172,7 +173,10 @@ sub description_short { my $desc = $self->name ? $self->name.': ' : ''; $desc .= $money_char. sprintf('%.2f/month ', $self->amount) if $self->amount > 0; - $desc .= $self->percent. '% ' + + ( my $percent = $self->percent ) =~ s/\.0+$//; + $percent =~ s/(\.\d*[1-9])0+$/$1/; + $desc .= $percent. '% ' if $self->percent > 0; $desc; @@ -181,8 +185,13 @@ sub description_short { sub description { my $self = shift; my $desc = $self->description_short; - $desc .= ' for '. $self->months. ' months' if $self->months; + + ( my $months = $self->months ) =~ s/\.0+$//; + $months =~ s/(\.\d*[1-9])0+$/$1/; + $desc .= " for $months months" if $months; + $desc .= ', applies to setup' if $self->setup; + $desc; }