1 package FS::quotation_pkg;
2 use base qw( FS::TemplateItem_Mixin FS::Record );
5 use FS::quotation_pkg_discount; #so its loaded when TemplateItem_Mixin needs it
9 FS::quotation_pkg - Object methods for quotation_pkg records
13 use FS::quotation_pkg;
15 $record = new FS::quotation_pkg \%hash;
16 $record = new FS::quotation_pkg { '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 object represents a quotation package.
29 FS::quotation_pkg inherits from FS::Record. The following fields are currently
71 Creates a new quotation package. To add the quotation package to the database,
74 Note that this stores the hash reference, not a distinct copy of the hash it
75 points to. You can ask the object for a copy with the I<hash> method.
79 sub table { 'quotation_pkg'; }
81 sub display_table { 'quotation_pkg'; }
83 #forget it, just overriding cust_bill_pkg_display entirely
84 #sub display_table_orderby { 'quotationpkgnum'; } # something else?
85 # # (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( 'quotationnum', 'quotation', 'quotationnum' )
117 || $self->ut_foreign_key( 'pkgpart', 'part_pkg', 'pkgpart' )
118 || $self->ut_foreign_keyn( 'locationnum', 'cust_location', 'locationnum' )
119 || $self->ut_numbern('start_date')
120 || $self->ut_numbern('contract_end')
121 || $self->ut_numbern('quantity')
122 || $self->ut_enum('waive_setup', [ '', 'Y'] )
124 return $error if $error;
131 $self->part_pkg->pkg;
136 return '0.00' if $self->waive_setup eq 'Y' || $self->{'_NO_SETUP_KLUDGE'};
137 my $part_pkg = $self->part_pkg;
138 #my $setup = $part_pkg->can('base_setup') ? $part_pkg->base_setup
139 # : $part_pkg->option('setup_fee');
140 my $setup = $part_pkg->option('setup_fee');
142 $setup *= $self->quantity if $self->quantity;
143 sprintf('%.2f', $setup);
149 return '0.00' if $self->{'_NO_RECUR_KLUDGE'};
150 my $part_pkg = $self->part_pkg;
151 my $recur = $part_pkg->can('base_recur') ? $part_pkg->base_recur
152 : $part_pkg->option('recur_fee');
154 $recur *= $self->quantity if $self->quantity;
155 sprintf('%.2f', $recur);
158 =item cust_bill_pkg_display [ type => TYPE ]
162 sub cust_bill_pkg_display {
163 my ( $self, %opt ) = @_;
165 my $type = $opt{type} if exists $opt{type};
166 return () if $type eq 'U'; #quotations don't have usage
168 if ( $self->get('display') ) {
169 return ( grep { defined($type) ? ($type eq $_->type) : 1 }
170 @{ $self->get('display') }
175 my $setup = $self->new($self->hashref);
176 $setup->{'_NO_RECUR_KLUDGE'} = 1;
177 $setup->{'type'} = 'S';
178 my $recur = $self->new($self->hashref);
179 $recur->{'_NO_SETUP_KLUDGE'} = 1;
180 $recur->{'type'} = 'R';
182 if ( $type eq 'S' ) {
184 } elsif ( $type eq 'R' ) {
187 #return ($setup, $recur);
201 L<FS::Record>, schema.html from the base documentation.