1 package FS::commission_rate;
2 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
9 FS::commission_rate - Object methods for commission_rate records
13 use FS::commission_rate;
15 $record = new FS::commission_rate \%hash;
16 $record = new FS::commission_rate { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::commission_rate object represents a commission rate (a percentage or a
29 flat amount) that will be paid on a customer's N-th invoice. The sequence of
30 commissions that will be paid on consecutive invoices is the parent object,
31 L<FS::commission_schedule>.
33 FS::commission_rate inherits from FS::Record. The following fields are
38 =item commissionratenum - primary key
40 =item schedulenum - L<FS::commission_schedule> foreign key
42 =item cycle - the ordinal of the billing cycle this commission will apply
43 to. cycle = 1 applies to the customer's first invoice, cycle = 2 to the
46 =item amount - the flat amount to pay per invoice in commission
48 =item percent - the percentage of the invoice amount to pay in
59 Creates a new commission rate. To add it to the database, see L<"insert">.
63 sub table { 'commission_rate'; }
67 Adds this record to the database. If there is an error, returns the error,
68 otherwise returns false.
72 Delete this record from the database.
74 =item replace OLD_RECORD
76 Replaces the OLD_RECORD with this one in the database. If there is an error,
77 returns the error, otherwise returns false.
81 Checks all fields to make sure this is a valid commission rate. If there is
82 an error, returns the error, otherwise returns false. Called by the insert
90 $self->set('amount', '0.00')
91 if $self->get('amount') eq '';
92 $self->set('percent', '0')
93 if $self->get('percent') eq '';
96 $self->ut_numbern('commissionratenum')
97 || $self->ut_number('schedulenum')
98 || $self->ut_number('cycle')
99 || $self->ut_money('amount')
100 || $self->ut_decimal('percent')
102 return $error if $error;