1 package FS::quotation_pkg;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearchs ); #qsearch
11 FS::quotation_pkg - Object methods for quotation_pkg records
15 use FS::quotation_pkg;
17 $record = new FS::quotation_pkg \%hash;
18 $record = new FS::quotation_pkg { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::quotation_pkg object represents a quotation package.
31 FS::quotation_pkg inherits from FS::Record. The following fields are currently
73 Creates a new quotation package. To add the quotation package to the database,
76 Note that this stores the hash reference, not a distinct copy of the hash it
77 points to. You can ask the object for a copy with the I<hash> method.
81 sub table { 'quotation_pkg'; }
85 Adds this record to the database. If there is an error, returns the error,
86 otherwise returns false.
90 Delete this record from the database.
92 =item replace OLD_RECORD
94 Replaces the OLD_RECORD with this one in the database. If there is an error,
95 returns the error, otherwise returns false.
99 Checks all fields to make sure this is a valid quotation package. If there is
100 an error, returns the error, otherwise returns false. Called by the insert
109 $self->ut_numbern('quotationpkgnum')
110 || $self->ut_foreign_key('pkgpart', 'part_pkg', 'pkgpart' )
111 || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum' )
112 || $self->ut_numbern('start_date')
113 || $self->ut_numbern('contract_end')
114 || $self->ut_numbern('quantity')
115 || $self->ut_enum('waive_setup', [ '', 'Y'] )
117 return $error if $error;
124 qsearchs('part_pkg', { 'pkgpart' => $self->pkgpart } );
129 $self->part_pkg->pkg;
134 return '0.00' if $self->waive_setup eq 'Y';
135 my $part_pkg = $self->part_pkg;
136 #my $setup = $part_pkg->can('base_setup') ? $part_pkg->base_setup
137 # : $part_pkg->option('setup_fee');
138 my $setup = $part_pkg->option('setup_fee');
140 $setup *= $self->quantity if $self->quantity;
141 sprintf('%.2f', $setup);
147 my $part_pkg = $self->part_pkg;
148 my $recur = $part_pkg->can('base_recur') ? $part_pkg->base_recur
149 : $part_pkg->option('recur_fee');
151 $recur *= $self->quantity if $self->quantity;
152 sprintf('%.2f', $recur);
161 L<FS::Record>, schema.html from the base documentation.