continue sales person work: customer and package selection, commissions, reporting...
[freeside.git] / FS / FS / sales.pm
1 package FS::sales;
2 use base qw( FS::Agent_Mixin FS::Record );
3
4 use strict;
5 use FS::agent;
6
7 =head1 NAME
8
9 FS::sales - Object methods for sales records
10
11 =head1 SYNOPSIS
12
13   use FS::sales;
14
15   $record = new FS::sales \%hash;
16   $record = new FS::sales { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::sales object represents a sales person.  FS::sales inherits from
29 FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item salesnum
34
35 primary key
36
37 =item agentnum
38
39 agentnum
40
41 =item disabled
42
43 disabled
44
45
46 =back
47
48 =head1 METHODS
49
50 =over 4
51
52 =item new HASHREF
53
54 Creates a new sales person.  To add the sales person to the database, see
55 L<"insert">.
56
57 Note that this stores the hash reference, not a distinct copy of the hash it
58 points to.  You can ask the object for a copy with the I<hash> method.
59
60 =cut
61
62 # the new method can be inherited from FS::Record, if a table method is defined
63
64 sub table { 'sales'; }
65
66 =item insert
67
68 Adds this record to the database.  If there is an error, returns the error,
69 otherwise returns false.
70
71 =cut
72
73 # the insert method can be inherited from FS::Record
74
75 =item delete
76
77 Delete this record from the database.
78
79 =cut
80
81 # the delete method can be inherited from FS::Record
82
83 =item replace OLD_RECORD
84
85 Replaces the OLD_RECORD with this one in the database.  If there is an error,
86 returns the error, otherwise returns false.
87
88 =cut
89
90 # the replace method can be inherited from FS::Record
91
92 =item check
93
94 Checks all fields to make sure this is a valid sales person.  If there is
95 an error, returns the error, otherwise returns false.  Called by the insert
96 and replace methods.
97
98 =cut
99
100 # the check method should currently be supplied - FS::Record contains some
101 # data checking routines
102
103 sub check {
104   my $self = shift;
105
106   my $error = 
107     $self->ut_numbern('salesnum')
108     || $self->ut_text('salesperson')
109     || $self->ut_foreign_key('agentnum', 'agent', 'agentnum')
110     || $self->ut_enum('disabled', [ '', 'Y' ])
111   ;
112   return $error if $error;
113
114   $self->SUPER::check;
115 }
116
117 =back
118
119 =head1 BUGS
120
121 =head1 SEE ALSO
122
123 L<FS::Record>, schema.html from the base documentation.
124
125 =cut
126
127 1;
128