2 use base qw( FS::Agent_Mixin FS::Record );
5 use FS::Record qw( qsearchs ); #qsearch qsearchs );
11 FS::sales - Object methods for sales records
17 $record = new FS::sales \%hash;
18 $record = new FS::sales { '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 object represents a sales person. FS::sales inherits from
31 FS::Record. The following fields are currently supported:
56 Creates a new sales person. To add the sales person to the database, see
59 Note that this stores the hash reference, not a distinct copy of the hash it
60 points to. You can ask the object for a copy with the I<hash> method.
64 # the new method can be inherited from FS::Record, if a table method is defined
66 sub table { 'sales'; }
70 Adds this record to the database. If there is an error, returns the error,
71 otherwise returns false.
75 # the insert method can be inherited from FS::Record
79 Delete this record from the database.
83 # the delete method can be inherited from FS::Record
85 =item replace OLD_RECORD
87 Replaces the OLD_RECORD with this one in the database. If there is an error,
88 returns the error, otherwise returns false.
92 # the replace method can be inherited from FS::Record
96 Checks all fields to make sure this is a valid sales person. If there is
97 an error, returns the error, otherwise returns false. Called by the insert
102 # the check method should currently be supplied - FS::Record contains some
103 # data checking routines
109 $self->ut_numbern('salesnum')
110 || $self->ut_text('salesperson')
111 || $self->ut_foreign_key('agentnum', 'agent', 'agentnum')
112 || $self->ut_foreign_keyn('sales_custnum', 'cust_main', 'custnum')
113 || $self->ut_enum('disabled', [ '', 'Y' ])
115 return $error if $error;
120 =item sales_cust_main
122 Returns the FS::cust_main object (see L<FS::cust_main>), if any, for this
127 sub sales_cust_main {
129 qsearchs( 'cust_main', { 'custnum' => $self->sales_custnum } );
138 L<FS::Record>, schema.html from the base documentation.