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