1 package FS::cust_pkg_discount;
4 use base qw( FS::Record );
5 use FS::Record; # qw( qsearch qsearchs );
11 FS::cust_pkg_discount - Object methods for cust_pkg_discount records
15 use FS::cust_pkg_discount;
17 $record = new FS::cust_pkg_discount \%hash;
18 $record = new FS::cust_pkg_discount { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::cust_pkg_discount object represents the application of a discount to a
31 customer package. FS::cust_pkg_discount inherits from FS::Record. The
32 following fields are currently supported:
42 Customer package (see L<FS::cust_pkg>)
46 Discount (see L<FS::discount>)
69 Creates a new discount application. To add the record to the database, see
72 Note that this stores the hash reference, not a distinct copy of the hash it
73 points to. You can ask the object for a copy with the I<hash> method.
77 # the new method can be inherited from FS::Record, if a table method is defined
79 sub table { 'cust_pkg_discount'; }
83 Adds this record to the database. If there is an error, returns the error,
84 otherwise returns false.
88 # the insert method can be inherited from FS::Record
92 Delete this record from the database.
96 # the delete method can be inherited from FS::Record
98 =item replace OLD_RECORD
100 Replaces the OLD_RECORD with this one in the database. If there is an error,
101 returns the error, otherwise returns false.
105 # the replace method can be inherited from FS::Record
109 Checks all fields to make sure this is a valid discount applciation. If there
110 is an error, returns the error, otherwise returns false. Called by the insert
115 # the check method should currently be supplied - FS::Record contains some
116 # data checking routines
122 $self->ut_numbern('pkgdiscountnum')
123 || $self->ut_foreign_key('pkgnum', 'cust_pkg', 'pkgnum')
124 || $self->ut_foreign_key('discountnum', 'discount', 'discountnum' )
125 || $self->ut_float('months_used') #actually decimal, but this will do
126 || $self->ut_numbern('end_date')
127 || $self->ut_text('otaker')
129 return $error if $error;
140 L<FS::discount>, L<FS::cust_pkg>, L<FS::Record>, schema.html from the base documentation.