1 package FS::sales_pkg_class;
2 use base qw( FS::Record );
5 use FS::Record qw( qsearchs ); # qsearch qsearchs );
11 FS::sales_pkg_class - Object methods for sales_pkg_class records
15 use FS::sales_pkg_class;
17 $record = new FS::sales_pkg_class \%hash;
18 $record = new FS::sales_pkg_class { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::sales_pkg_class object represents a commission for a specific sales
31 person and package class. FS::sales_pkg_class inherits from FS::Record. The
32 following fields are currently supported:
36 =item salespkgclassnum
48 =item commission_percent
52 =item commission_duration
65 Creates a new record. To add the record to the database, see L<"insert">.
67 Note that this stores the hash reference, not a distinct copy of the hash it
68 points to. You can ask the object for a copy with the I<hash> method.
72 sub table { 'sales_pkg_class'; }
76 Adds this record to the database. If there is an error, returns the error,
77 otherwise returns false.
81 Delete this record from the database.
83 =item replace OLD_RECORD
85 Replaces the OLD_RECORD with this one in the database. If there is an error,
86 returns the error, otherwise returns false.
90 Checks all fields to make sure this is a valid record. If there is
91 an error, returns the error, otherwise returns false. Called by the insert
99 $self->commission_percent(0) unless length($self->commission_percent);
102 $self->ut_numbern('salespkgclassnum')
103 || $self->ut_foreign_key('salesnum', 'sales', 'salesnum')
104 || $self->ut_foreign_keyn('classnum', 'pkg_class', 'classnum')
105 || $self->ut_float('commission_percent')
106 || $self->ut_numbern('commission_duration')
108 return $error if $error;
115 qsearchs('pkg_class', { 'classnum' => $self->classnum });
120 my $pkg_class = $self->pkg_class;
121 $pkg_class ? $pkg_class->classname : '(no package class)';
130 L<FS::sales>, L<FS::pkg_class, L<FS::Record>.