1 package FS::quotation_pkg_discount;
2 use base qw( FS::Record );
3 use FS::Maketext 'mt'; # XXX not really correct
9 FS::quotation_pkg_discount - Object methods for quotation_pkg_discount records
13 use FS::quotation_pkg_discount;
15 $record = new FS::quotation_pkg_discount \%hash;
16 $record = new FS::quotation_pkg_discount { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
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
34 =item quotationpkgdiscountnum
40 quotationpkgnum of the L<FS::quotation_pkg> record that this discount is
45 discountnum (L<FS::discount>)
49 Amount that will be discounted from setup fees, per package quantity.
53 Amount that will be discounted from recurring fees in the first billing
54 cycle, per package quantity.
64 Creates a new quotation package discount. To add the quotation package
65 discount to the database, see L<"insert">.
67 Note that this stores the hash reference, not a distinct copy of the hash it
68 points to. You can ask the object for a copy with the I<hash> method.
72 # the new method can be inherited from FS::Record, if a table method is defined
74 sub table { 'quotation_pkg_discount'; }
78 Adds this record to the database. If there is an error, returns the error,
79 otherwise returns false.
83 # the insert method can be inherited from FS::Record
87 Delete this record from the database.
91 # the delete method can be inherited from FS::Record
93 =item replace OLD_RECORD
95 Replaces the OLD_RECORD with this one in the database. If there is an error,
96 returns the error, otherwise returns false.
100 # the replace method can be inherited from FS::Record
104 Checks all fields to make sure this is a valid quotation package discount.
105 If there is an error, returns the error, otherwise returns false.
106 Called by the insert and replace methods.
110 # the check method should currently be supplied - FS::Record contains some
111 # data checking routines
117 $self->ut_numbern('quotationpkgdiscountnum')
118 || $self->ut_foreign_key('quotationpkgnum', 'quotation_pkg', 'quotationpkgnum' )
119 || $self->ut_foreign_key('discountnum', 'discount', 'discountnum' )
120 || $self->ut_moneyn('setup_amount')
121 || $self->ut_moneyn('recur_amount')
123 return $error if $error;
132 Returns the total amount of this discount (setup + recur), for compatibility
133 with L<FS::cust_bill_pkg_discount>.
139 return $self->get('setup_amount') + $self->get('recur_amount');
144 Returns a string describing the discount (for use on the quotation).
150 my $discount = $self->discount;
151 my $desc = $discount->description_short;
152 # XXX localize to prospect language, once prospects get languages
153 $desc .= mt(' each') if $self->quotation_pkg->quantity > 1;
155 if ($discount->months) {
156 # unlike cust_bill_pkg_discount, there are no "months remaining"; it
157 # hasn't started yet.
158 $desc .= mt(' (for [quant,_1,month])', $discount->months);
167 L<FS::Record>, schema.html from the base documentation.