X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fdiscount.pm;h=43ad4909e46374dff6279673c8065a61ef139636;hb=b7c25d5e38e6459efe5d1c2f09f437b79798038e;hp=f6f9945998f2ef9dc2e1e86488e7513d6b6da324;hpb=0af38652da3b3be7da2d35b048285ef6f2194e1a;p=freeside.git diff --git a/FS/FS/discount.pm b/FS/FS/discount.pm index f6f994599..43ad4909e 100644 --- a/FS/FS/discount.pm +++ b/FS/FS/discount.pm @@ -1,8 +1,7 @@ package FS::discount; +use base qw( FS::Record ); use strict; -use base qw( FS::Record ); -use FS::Record qw( qsearch qsearchs ); =head1 NAME @@ -130,6 +129,7 @@ sub check { my $error = $self->ut_numbern('discountnum') + || $self->ut_foreign_keyn('classnum', 'discount_class', 'classnum') || $self->ut_textn('name') || $self->ut_money('amount') || $self->ut_float('percent') #actually decimal, but this will do @@ -140,16 +140,19 @@ sub check { ; return $error if $error; - #discourage non-integer months for package discounts - if ($self->discountnum) { - my $sql = - "SELECT count(*) FROM part_pkg_discount WHERE part_pkg_discount.discountnum = ". - $self->discountnum; - - my $count = $self->scalar_sql($sql); - return "months must be integers greater than 1" - if ( $count && ($self->ut_number('months') || $self->months < 2) ); - } +#causes "months must be integers greater than 1" errors when you go back and +# try to edit an existing discount (because the months format as NN.000) +#not worth whatever reason it came in with "prepayment discounts rt#5318" for +# #discourage non-integer months for package discounts +# if ($self->discountnum) { +# my $sql = +# "SELECT count(*) FROM part_pkg_discount WHERE part_pkg_discount.discountnum = ". +# $self->discountnum; +# +# my $count = $self->scalar_sql($sql); +# return "months must be integers greater than 1" +# if ( $count && ($self->ut_number('months') || $self->months < 2) ); +# } $self->SUPER::check; } @@ -195,6 +198,12 @@ sub description { $desc; } +sub classname { + my $self = shift; + my $discount_class = $self->discount_class; + $discount_class ? $discount_class->classname : '(none)'; +} + =back =head1 BUGS