1 package FS::quotation_pkg;
4 use base qw( FS::TemplateItem_Mixin FS::Record );
5 use FS::Record qw( qsearchs ); #qsearch
8 use FS::quotation_pkg_discount; #so its loaded when TemplateItem_Mixin needs it
12 FS::quotation_pkg - Object methods for quotation_pkg records
16 use FS::quotation_pkg;
18 $record = new FS::quotation_pkg \%hash;
19 $record = new FS::quotation_pkg { '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 object represents a quotation package.
32 FS::quotation_pkg inherits from FS::Record. The following fields are currently
74 Creates a new quotation package. To add the quotation package to the database,
77 Note that this stores the hash reference, not a distinct copy of the hash it
78 points to. You can ask the object for a copy with the I<hash> method.
82 sub table { 'quotation_pkg'; }
84 sub display_table { 'quotation_pkg'; }
85 sub display_table_orderby { 'quotationpkgnum'; } # something else?
86 # (for invoice display order)
87 sub discount_table { 'quotation_pkg_discount'; }
91 Adds this record to the database. If there is an error, returns the error,
92 otherwise returns false.
96 Delete this record from the database.
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 Checks all fields to make sure this is a valid quotation package. If there is
106 an error, returns the error, otherwise returns false. Called by the insert
115 $self->ut_numbern('quotationpkgnum')
116 || $self->ut_foreign_key('pkgpart', 'part_pkg', 'pkgpart' )
117 || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum' )
118 || $self->ut_numbern('start_date')
119 || $self->ut_numbern('contract_end')
120 || $self->ut_numbern('quantity')
121 || $self->ut_enum('waive_setup', [ '', 'Y'] )
123 return $error if $error;
130 qsearchs('part_pkg', { 'pkgpart' => $self->pkgpart } );
135 $self->part_pkg->pkg;
140 return '0.00' if $self->waive_setup eq 'Y';
141 my $part_pkg = $self->part_pkg;
142 #my $setup = $part_pkg->can('base_setup') ? $part_pkg->base_setup
143 # : $part_pkg->option('setup_fee');
144 my $setup = $part_pkg->option('setup_fee');
146 $setup *= $self->quantity if $self->quantity;
147 sprintf('%.2f', $setup);
153 my $part_pkg = $self->part_pkg;
154 my $recur = $part_pkg->can('base_recur') ? $part_pkg->base_recur
155 : $part_pkg->option('recur_fee');
157 $recur *= $self->quantity if $self->quantity;
158 sprintf('%.2f', $recur);
167 L<FS::Record>, schema.html from the base documentation.