1 package FS::quotation_pkg_discount;
4 use base qw( FS::pkg_discount_Mixin FS::Record );
5 use FS::Record qw( qsearch qsearchs );
12 FS::quotation_pkg_discount - Object methods for quotation_pkg_discount records
16 use FS::quotation_pkg_discount;
18 $record = new FS::quotation_pkg_discount \%hash;
19 $record = new FS::quotation_pkg_discount { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::quotation_pkg_discount object represents a quotation package discount.
32 FS::quotation_pkg_discount inherits from FS::Record. The following fields are
37 =item quotationpkgdiscountnum
43 quotationpkgnum of the L<FS::quotation_pkg> record that this discount is
48 discountnum (L<FS::discount>)
52 Amount that will be discounted from setup fees, per package quantity.
56 Amount that will be discounted from recurring fees in the first billing
57 cycle, per package quantity.
67 Creates a new quotation package discount. To add the quotation package
68 discount to the database, see L<"insert">.
70 Note that this stores the hash reference, not a distinct copy of the hash it
71 points to. You can ask the object for a copy with the I<hash> method.
75 # the new method can be inherited from FS::Record, if a table method is defined
77 sub table { 'quotation_pkg_discount'; }
81 Adds this record to the database. If there is an error, returns the error,
82 otherwise returns false.
86 Delete this record from the database.
88 =item replace OLD_RECORD
90 Replaces the OLD_RECORD with this one in the database. If there is an error,
91 returns the error, otherwise returns false.
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.
101 # the check method should currently be supplied - FS::Record contains some
102 # data checking routines
108 $self->ut_numbern('quotationpkgdiscountnum')
109 || $self->ut_foreign_key('quotationpkgnum', 'quotation_pkg', 'quotationpkgnum' )
110 || $self->ut_foreign_key('discountnum', 'discount', 'discountnum' )
111 || $self->ut_moneyn('setup_amount')
112 || $self->ut_moneyn('recur_amount')
114 return $error if $error;
123 Returns a string describing the discount (for use on the quotation).
129 my $discount = $self->discount;
130 my $desc = $discount->description_short;
131 # XXX localize to prospect language, once prospects get languages
132 $desc .= mt(' each') if $self->quotation_pkg->quantity > 1;
134 if ($discount->months) {
135 # unlike cust_bill_pkg_discount, there are no "months remaining"; it
136 # hasn't started yet.
137 $desc .= mt(' (for [quant,_1,month])', $discount->months);
145 FS::quotation_pkg->by_key($self->quotationpkgnum);
150 FS::discount->by_key($self->discountnum);
157 L<FS::Record>, schema.html from the base documentation.