1 package FS::sales_pkg_class;
2 use base qw( FS::Commission_Mixin FS::Record );
8 FS::sales_pkg_class - Object methods for sales_pkg_class records
12 use FS::sales_pkg_class;
14 $record = new FS::sales_pkg_class \%hash;
15 $record = new FS::sales_pkg_class { 'column' => 'value' };
17 $error = $record->insert;
19 $error = $new_record->replace($old_record);
21 $error = $record->delete;
23 $error = $record->check;
27 An FS::sales_pkg_class object represents a commission for a specific sales
28 person and package class. FS::sales_pkg_class inherits from FS::Record. The
29 following fields are currently supported:
33 =item salespkgclassnum
45 =item commission_percent
49 =item commission_duration
62 Creates a new record. To add the record to the database, see L<"insert">.
64 Note that this stores the hash reference, not a distinct copy of the hash it
65 points to. You can ask the object for a copy with the I<hash> method.
69 sub table { 'sales_pkg_class'; }
73 Adds this record to the database. If there is an error, returns the error,
74 otherwise returns false.
78 Delete this record from the database.
80 =item replace OLD_RECORD
82 Replaces the OLD_RECORD with this one in the database. If there is an error,
83 returns the error, otherwise returns false.
87 Checks all fields to make sure this is a valid record. If there is
88 an error, returns the error, otherwise returns false. Called by the insert
96 $self->commission_percent(0) unless length($self->commission_percent);
99 $self->ut_numbern('salespkgclassnum')
100 || $self->ut_foreign_key('salesnum', 'sales', 'salesnum')
101 || $self->ut_foreign_keyn('classnum', 'pkg_class', 'classnum')
102 || $self->ut_float('commission_percent')
103 || $self->ut_numbern('commission_duration')
105 return $error if $error;
112 my $pkg_class = $self->pkg_class;
113 $pkg_class ? $pkg_class->classname : '(no package class)';
116 sub cust_credit_search {
118 my $sales = $self->sales;
119 $sales->cust_credit_search(@_, commission_classnum => $self->classnum);
122 sub cust_bill_pkg_search {
124 my $sales = $self->sales;
125 $sales->cust_bill_pkg_search(@_, classnum => $self->classnum);
134 L<FS::sales>, L<FS::pkg_class, L<FS::Record>.