Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / FS / FS / quotation_pkg_discount.pm
1 package FS::quotation_pkg_discount;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::quotation_pkg_discount - Object methods for quotation_pkg_discount records
10
11 =head1 SYNOPSIS
12
13   use FS::quotation_pkg_discount;
14
15   $record = new FS::quotation_pkg_discount \%hash;
16   $record = new FS::quotation_pkg_discount { '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::quotation_pkg_discount object represents a quotation package discount.
29 FS::quotation_pkg_discount inherits from FS::Record.  The following fields are
30 currently supported:
31
32 =over 4
33
34 =item quotationpkgdiscountnum
35
36 primary key
37
38 =item quotationpkgnum
39
40 quotationpkgnum
41
42 =item discountnum
43
44 discountnum
45
46
47 =back
48
49 =head1 METHODS
50
51 =over 4
52
53 =item new HASHREF
54
55 Creates a new quotation package discount.  To add the quotation package
56 discount to the database, see L<"insert">.
57
58 Note that this stores the hash reference, not a distinct copy of the hash it
59 points to.  You can ask the object for a copy with the I<hash> method.
60
61 =cut
62
63 # the new method can be inherited from FS::Record, if a table method is defined
64
65 sub table { 'quotation_pkg_discount'; }
66
67 =item insert
68
69 Adds this record to the database.  If there is an error, returns the error,
70 otherwise returns false.
71
72 =cut
73
74 # the insert method can be inherited from FS::Record
75
76 =item delete
77
78 Delete this record from the database.
79
80 =cut
81
82 # the delete method can be inherited from FS::Record
83
84 =item replace OLD_RECORD
85
86 Replaces the OLD_RECORD with this one in the database.  If there is an error,
87 returns the error, otherwise returns false.
88
89 =cut
90
91 # the replace method can be inherited from FS::Record
92
93 =item check
94
95 Checks all fields to make sure this is a valid quotation package discount.
96 If there is an error, returns the error, otherwise returns false.
97 Called by the insert and replace methods.
98
99 =cut
100
101 # the check method should currently be supplied - FS::Record contains some
102 # data checking routines
103
104 sub check {
105   my $self = shift;
106
107   my $error = 
108     $self->ut_numbern('quotationpkgdiscountnum')
109     || $self->ut_foreign_key('quotationpkgnum', 'quotation_pkg', 'quotationpkgnum' )
110     || $self->ut_foreign_key('discountnum', 'discount', 'discountnum' )
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