From 5c59829b853cf3fdce42b45e57192fd8ca30dd65 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Dec 2011 00:04:08 +0000 Subject: [PATCH] fix discount display after mysql schema change fix --- FS/FS/discount.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/FS/FS/discount.pm b/FS/FS/discount.pm index 6fc3391ca..88cbdd41c 100644 --- a/FS/FS/discount.pm +++ b/FS/FS/discount.pm @@ -172,7 +172,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 +184,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; } -- 2.11.0