1 package FS::quotation_pkg_discount;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
10 FS::quotation_pkg_discount - Object methods for quotation_pkg_discount records
14 use FS::quotation_pkg_discount;
16 $record = new FS::quotation_pkg_discount \%hash;
17 $record = new FS::quotation_pkg_discount { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
29 An FS::quotation_pkg_discount object represents a quotation package discount.
30 FS::quotation_pkg_discount inherits from FS::Record. The following fields are
35 =item quotationpkgdiscountnum
41 quotationpkgnum of the L<FS::quotation_pkg> record that this discount is
46 discountnum (L<FS::discount>)
50 Amount that will be discounted from setup fees, per package quantity.
54 Amount that will be discounted from recurring fees in the first billing
55 cycle, per package quantity.
65 Creates a new quotation package discount. To add the quotation package
66 discount to the database, see L<"insert">.
68 Note that this stores the hash reference, not a distinct copy of the hash it
69 points to. You can ask the object for a copy with the I<hash> method.
73 # the new method can be inherited from FS::Record, if a table method is defined
75 sub table { 'quotation_pkg_discount'; }
79 Adds this record to the database. If there is an error, returns the error,
80 otherwise returns false.
84 # the insert method can be inherited from FS::Record
88 Delete this record from the database.
92 # the delete method can be inherited from FS::Record
94 =item replace OLD_RECORD
96 Replaces the OLD_RECORD with this one in the database. If there is an error,
97 returns the error, otherwise returns false.
101 # the replace method can be inherited from FS::Record
105 Checks all fields to make sure this is a valid quotation package discount.
106 If there is an error, returns the error, otherwise returns false.
107 Called by the insert and replace methods.
111 # the check method should currently be supplied - FS::Record contains some
112 # data checking routines
118 $self->ut_numbern('quotationpkgdiscountnum')
119 || $self->ut_foreign_key('quotationpkgnum', 'quotation_pkg', 'quotationpkgnum' )
120 || $self->ut_foreign_key('discountnum', 'discount', 'discountnum' )
121 || $self->ut_moneyn('setup_amount')
122 || $self->ut_moneyn('recur_amount')
124 return $error if $error;
133 Returns the total amount of this discount (setup + recur), for compatibility
134 with L<FS::cust_bill_pkg_discount>.
140 return $self->get('setup_amount') + $self->get('recur_amount');
145 Returns a string describing the discount (for use on the quotation).
151 my $discount = $self->discount;
152 my $desc = $discount->description_short;
153 # XXX localize to prospect language, once prospects get languages
154 $desc .= mt(' each') if $self->quotation_pkg->quantity > 1;
156 if ($discount->months) {
157 # unlike cust_bill_pkg_discount, there are no "months remaining"; it
158 # hasn't started yet.
159 $desc .= mt(' (for [quant,_1,month])', $discount->months);
168 L<FS::Record>, schema.html from the base documentation.