4 use vars qw( @ISA %plans $DEBUG );
5 use Carp qw(carp cluck confess);
6 use Scalar::Util qw( blessed );
9 use FS::Record qw( qsearch qsearchs dbh dbdef );
15 use FS::part_pkg_option;
18 use FS::part_pkg_taxoverride;
19 use FS::part_pkg_taxproduct;
20 use FS::part_pkg_link;
22 @ISA = qw( FS::m2m_Common FS::option_Common );
27 FS::part_pkg - Object methods for part_pkg objects
33 $record = new FS::part_pkg \%hash
34 $record = new FS::part_pkg { 'column' => 'value' };
36 $custom_record = $template_record->clone;
38 $error = $record->insert;
40 $error = $new_record->replace($old_record);
42 $error = $record->delete;
44 $error = $record->check;
46 @pkg_svc = $record->pkg_svc;
48 $svcnum = $record->svcpart;
49 $svcnum = $record->svcpart( 'svc_acct' );
53 An FS::part_pkg object represents a package definition. FS::part_pkg
54 inherits from FS::Record. The following fields are currently supported:
58 =item pkgpart - primary key (assigned automatically for new package definitions)
60 =item pkg - Text name of this package definition (customer-viewable)
62 =item comment - Text name of this package definition (non-customer-viewable)
64 =item classnum - Optional package class (see L<FS::pkg_class>)
66 =item promo_code - Promotional code
68 =item setup - Setup fee expression (deprecated)
70 =item freq - Frequency of recurring fee
72 =item recur - Recurring fee expression (deprecated)
74 =item setuptax - Setup fee tax exempt flag, empty or `Y'
76 =item recurtax - Recurring fee tax exempt flag, empty or `Y'
78 =item taxclass - Tax class
80 =item plan - Price plan
82 =item plandata - Price plan data (deprecated - see L<FS::part_pkg_option> instead)
84 =item disabled - Disabled flag, empty or `Y'
86 =item pay_weight - Weight (relative to credit_weight and other package definitions) that controls payment application to specific line items.
88 =item credit_weight - Weight (relative to other package definitions) that controls credit application to specific line items.
90 =item agentnum - Optional agentnum (see L<FS::agent>)
100 Creates a new package definition. To add the package definition to
101 the database, see L<"insert">.
105 sub table { 'part_pkg'; }
109 An alternate constructor. Creates a new package definition by duplicating
110 an existing definition. A new pkgpart is assigned and `(CUSTOM) ' is prepended
111 to the comment field. To add the package definition to the database, see
118 my $class = ref($self);
119 my %hash = $self->hash;
120 $hash{'pkgpart'} = '';
121 $hash{'comment'} = "(CUSTOM) ". $hash{'comment'}
122 unless $hash{'comment'} =~ /^\(CUSTOM\) /;
123 #new FS::part_pkg ( \%hash ); # ?
124 new $class ( \%hash ); # ?
127 =item insert [ , OPTION => VALUE ... ]
129 Adds this package definition to the database. If there is an error,
130 returns the error, otherwise returns false.
132 Currently available options are: I<pkg_svc>, I<primary_svc>, I<cust_pkg>,
133 I<custnum_ref> and I<options>.
135 If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
136 values, appropriate FS::pkg_svc records will be inserted.
138 If I<primary_svc> is set to the svcpart of the primary service, the appropriate
139 FS::pkg_svc record will be updated.
141 If I<cust_pkg> is set to a pkgnum of a FS::cust_pkg record (or the FS::cust_pkg
142 record itself), the object will be updated to point to this package definition.
144 In conjunction with I<cust_pkg>, if I<custnum_ref> is set to a scalar reference,
145 the scalar will be updated with the custnum value from the cust_pkg record.
147 If I<options> is set to a hashref of options, appropriate FS::part_pkg_option
148 records will be inserted.
155 warn "FS::part_pkg::insert called on $self with options ".
156 join(', ', map "$_=>$options{$_}", keys %options)
159 local $SIG{HUP} = 'IGNORE';
160 local $SIG{INT} = 'IGNORE';
161 local $SIG{QUIT} = 'IGNORE';
162 local $SIG{TERM} = 'IGNORE';
163 local $SIG{TSTP} = 'IGNORE';
164 local $SIG{PIPE} = 'IGNORE';
166 my $oldAutoCommit = $FS::UID::AutoCommit;
167 local $FS::UID::AutoCommit = 0;
170 warn " inserting part_pkg record" if $DEBUG;
171 my $error = $self->SUPER::insert( $options{options} );
173 $dbh->rollback if $oldAutoCommit;
177 my $conf = new FS::Conf;
178 if ( $conf->exists('agent_defaultpkg') ) {
179 warn " agent_defaultpkg set; allowing all agents to purchase package"
181 foreach my $agent_type ( qsearch('agent_type', {} ) ) {
182 my $type_pkgs = new FS::type_pkgs({
183 'typenum' => $agent_type->typenum,
184 'pkgpart' => $self->pkgpart,
186 my $error = $type_pkgs->insert;
188 $dbh->rollback if $oldAutoCommit;
194 warn " inserting pkg_svc records" if $DEBUG;
195 my $pkg_svc = $options{'pkg_svc'} || {};
196 foreach my $part_svc ( qsearch('part_svc', {} ) ) {
197 my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
199 ( $options{'primary_svc'} && $options{'primary_svc'}==$part_svc->svcpart )
203 my $pkg_svc = new FS::pkg_svc( {
204 'pkgpart' => $self->pkgpart,
205 'svcpart' => $part_svc->svcpart,
206 'quantity' => $quantity,
207 'primary_svc' => $primary_svc,
209 my $error = $pkg_svc->insert;
211 $dbh->rollback if $oldAutoCommit;
216 if ( $options{'cust_pkg'} ) {
217 warn " updating cust_pkg record " if $DEBUG;
219 ref($options{'cust_pkg'})
220 ? $options{'cust_pkg'}
221 : qsearchs('cust_pkg', { pkgnum => $options{'cust_pkg'} } );
222 ${ $options{'custnum_ref'} } = $old_cust_pkg->custnum
223 if $options{'custnum_ref'};
224 my %hash = $old_cust_pkg->hash;
225 $hash{'pkgpart'} = $self->pkgpart,
226 my $new_cust_pkg = new FS::cust_pkg \%hash;
227 local($FS::cust_pkg::disable_agentcheck) = 1;
228 my $error = $new_cust_pkg->replace($old_cust_pkg);
230 $dbh->rollback if $oldAutoCommit;
231 return "Error modifying cust_pkg record: $error";
235 warn " commiting transaction" if $DEBUG;
236 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
243 Currently unimplemented.
248 return "Can't (yet?) delete package definitions.";
249 # check & make sure the pkgpart isn't in cust_pkg or type_pkgs?
252 =item replace OLD_RECORD [ , OPTION => VALUE ... ]
254 Replaces OLD_RECORD with this one in the database. If there is an error,
255 returns the error, otherwise returns false.
257 Currently available options are: I<pkg_svc> and I<primary_svc>
259 If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
260 values, the appropriate FS::pkg_svc records will be replace.
262 If I<primary_svc> is set to the svcpart of the primary service, the appropriate
263 FS::pkg_svc record will be updated.
270 my $old = ( blessed($_[0]) && $_[0]->isa('FS::Record') )
275 ( ref($_[0]) eq 'HASH' )
279 warn "FS::part_pkg::replace called on $new to replace $old with options".
280 join(', ', map "$_ => ". $options->{$_}, keys %$options)
283 local $SIG{HUP} = 'IGNORE';
284 local $SIG{INT} = 'IGNORE';
285 local $SIG{QUIT} = 'IGNORE';
286 local $SIG{TERM} = 'IGNORE';
287 local $SIG{TSTP} = 'IGNORE';
288 local $SIG{PIPE} = 'IGNORE';
290 my $oldAutoCommit = $FS::UID::AutoCommit;
291 local $FS::UID::AutoCommit = 0;
294 #plandata shit stays in replace for upgrades until after 2.0 (or edit
296 warn " saving legacy plandata" if $DEBUG;
297 my $plandata = $new->get('plandata');
298 $new->set('plandata', '');
300 warn " deleting old part_pkg_option records" if $DEBUG;
301 foreach my $part_pkg_option ( $old->part_pkg_option ) {
302 my $error = $part_pkg_option->delete;
304 $dbh->rollback if $oldAutoCommit;
309 warn " replacing part_pkg record" if $DEBUG;
310 my $error = $new->SUPER::replace($old, $options->{options} );
312 $dbh->rollback if $oldAutoCommit;
316 warn " inserting part_pkg_option records for plandata: $plandata|" if $DEBUG;
317 foreach my $part_pkg_option (
318 map { /^(\w+)=(.*)$/ or do { $dbh->rollback if $oldAutoCommit;
319 return "illegal plandata: $plandata";
321 new FS::part_pkg_option {
322 'pkgpart' => $new->pkgpart,
327 split("\n", $plandata)
329 my $error = $part_pkg_option->insert;
331 $dbh->rollback if $oldAutoCommit;
336 warn " replacing pkg_svc records" if $DEBUG;
337 my $pkg_svc = $options->{'pkg_svc'} || {};
338 foreach my $part_svc ( qsearch('part_svc', {} ) ) {
339 my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
340 my $primary_svc = $options->{'primary_svc'} == $part_svc->svcpart ? 'Y' : '';
342 my $old_pkg_svc = qsearchs('pkg_svc', {
343 'pkgpart' => $old->pkgpart,
344 'svcpart' => $part_svc->svcpart,
346 my $old_quantity = $old_pkg_svc ? $old_pkg_svc->quantity : 0;
347 my $old_primary_svc =
348 ( $old_pkg_svc && $old_pkg_svc->dbdef_table->column('primary_svc') )
349 ? $old_pkg_svc->primary_svc
351 next unless $old_quantity != $quantity || $old_primary_svc ne $primary_svc;
353 my $new_pkg_svc = new FS::pkg_svc( {
354 'pkgsvcnum' => ( $old_pkg_svc ? $old_pkg_svc->pkgsvcnum : '' ),
355 'pkgpart' => $new->pkgpart,
356 'svcpart' => $part_svc->svcpart,
357 'quantity' => $quantity,
358 'primary_svc' => $primary_svc,
360 my $error = $old_pkg_svc
361 ? $new_pkg_svc->replace($old_pkg_svc)
362 : $new_pkg_svc->insert;
364 $dbh->rollback if $oldAutoCommit;
369 warn " commiting transaction" if $DEBUG;
370 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
376 Checks all fields to make sure this is a valid package definition. If
377 there is an error, returns the error, otherwise returns false. Called by the
378 insert and replace methods.
384 warn "FS::part_pkg::check called on $self" if $DEBUG;
386 for (qw(setup recur plandata)) {
387 #$self->set($_=>0) if $self->get($_) =~ /^\s*$/; }
388 return "Use of $_ field is deprecated; set a plan and options: ".
390 if length($self->get($_));
394 if ( $self->dbdef_table->column('freq')->type =~ /(int)/i ) {
395 my $error = $self->ut_number('freq');
396 return $error if $error;
398 $self->freq =~ /^(\d+[hdw]?)$/
399 or return "Illegal or empty freq: ". $self->freq;
403 my $error = $self->ut_numbern('pkgpart')
404 || $self->ut_text('pkg')
405 || $self->ut_text('comment')
406 || $self->ut_textn('promo_code')
407 || $self->ut_alphan('plan')
408 || $self->ut_enum('setuptax', [ '', 'Y' ] )
409 || $self->ut_enum('recurtax', [ '', 'Y' ] )
410 || $self->ut_textn('taxclass')
411 || $self->ut_enum('disabled', [ '', 'Y' ] )
412 || $self->ut_floatn('pay_weight')
413 || $self->ut_floatn('credit_weight')
414 || $self->ut_agentnum_acl('agentnum', 'Edit global package definitions')
415 || $self->SUPER::check
417 return $error if $error;
419 if ( $self->classnum !~ /^$/ ) {
420 my $error = $self->ut_foreign_key('classnum', 'pkg_class', 'classnum');
421 return $error if $error;
426 return 'Unknown plan '. $self->plan
427 unless exists($plans{$self->plan});
429 my $conf = new FS::Conf;
430 return 'Taxclass is required'
431 if ! $self->taxclass && $conf->exists('require_taxclasses');
438 Returns an (internal) string representing this package. Currently,
439 "pkgpart: pkg - comment", is returned. "pkg - comment" may be returned in the
440 future, omitting pkgpart.
447 #$self->pkg. ' - '. $self->comment;
448 #$self->pkg. ' ('. $self->comment. ')';
449 $self->pkgpart. ': '. $self->pkg. ' - '. $self->comment;
454 Returns the package class, as an FS::pkg_class object, or the empty string
455 if there is no package class.
461 if ( $self->classnum ) {
462 qsearchs('pkg_class', { 'classnum' => $self->classnum } );
470 Returns the package class name, or the empty string if there is no package
477 my $pkg_class = $self->pkg_class;
479 ? $pkg_class->classname
485 Returns the associated agent for this event, if any, as an FS::agent object.
491 qsearchs('agent', { 'agentnum' => $self->agentnum } );
496 Returns all FS::pkg_svc objects (see L<FS::pkg_svc>) for this package
497 definition (with non-zero quantity).
503 #sort { $b->primary cmp $a->primary }
504 grep { $_->quantity }
505 qsearch( 'pkg_svc', { 'pkgpart' => $self->pkgpart } );
508 =item svcpart [ SVCDB ]
510 Returns the svcpart of the primary service definition (see L<FS::part_svc>)
511 associated with this package definition (see L<FS::pkg_svc>). Returns
512 false if there not a primary service definition or exactly one service
513 definition with quantity 1, or if SVCDB is specified and does not match the
514 svcdb of the service definition,
520 my $svcdb = scalar(@_) ? shift : '';
522 grep { ( $svcdb eq $_->part_svc->svcdb || !$svcdb ) } $self->pkg_svc;
524 @pkg_svc = grep { $_->primary_svc =~ /^Y/i } @svcdb_pkg_svc
525 if dbdef->table('pkg_svc')->column('primary_svc');
526 @pkg_svc = grep {$_->quantity == 1 } @svcdb_pkg_svc
528 return '' if scalar(@pkg_svc) != 1;
529 $pkg_svc[0]->svcpart;
534 Returns a list of the acceptable payment types for this package. Eventually
535 this should come out of a database table and be editable, but currently has the
536 following logic instead:
538 If the package is free, the single item B<BILL> is
539 returned, otherwise, the single item B<CARD> is returned.
541 (CHEK? LEC? Probably shouldn't accept those by default, prone to abuse)
547 if ( $self->is_free ) {
556 Returns true if this package is free.
562 unless ( $self->plan ) {
563 $self->setup =~ /^\s*0+(\.0*)?\s*$/
564 && $self->recur =~ /^\s*0+(\.0*)?\s*$/;
565 } elsif ( $self->can('is_free_options') ) {
566 not grep { $_ !~ /^\s*0*(\.0*)?\s*$/ }
567 map { $self->option($_) }
568 $self->is_free_options;
570 warn "FS::part_pkg::is_free: FS::part_pkg::". $self->plan. " subclass ".
571 "provides neither is_free_options nor is_free method; returning false";
578 #method, class method or sub? #my $self = shift;
580 tie my %freq, 'Tie::IxHash',
581 '0' => '(no recurring fee)',
584 '2d' => 'every two days',
585 '3d' => 'every three days',
587 '2w' => 'biweekly (every 2 weeks)',
589 '45d' => 'every 45 days',
590 '2' => 'bimonthly (every 2 months)',
591 '3' => 'quarterly (every 3 months)',
592 '4' => 'every 4 months',
593 '137d' => 'every 4 1/2 months (137 days)',
594 '6' => 'semiannually (every 6 months)',
596 '13' => 'every 13 months (annually +1 month)',
597 '24' => 'biannually (every 2 years)',
598 '36' => 'triannually (every 3 years)',
599 '48' => '(every 4 years)',
600 '60' => '(every 5 years)',
601 '120' => '(every 10 years)',
610 Returns an english representation of the I<freq> field, such as "monthly",
611 "weekly", "semi-annually", etc.
617 my $freq = $self->freq;
619 #my $freqs_href = $self->freqs_href;
620 my $freqs_href = freqs_href();
622 if ( exists($freqs_href->{$freq}) ) {
623 $freqs_href->{$freq};
625 my $interval = 'month';
626 if ( $freq =~ /^(\d+)([hdw])$/ ) {
627 my %interval = ( 'h' => 'hour', 'd'=>'day', 'w'=>'week' );
628 $interval = $interval{$2};
633 "every $freq ${interval}s";
640 For backwards compatibility, returns the plandata field as well as all options
641 from FS::part_pkg_option.
647 carp "plandata is deprecated";
649 $self->SUPER::plandata(@_);
651 my $plandata = $self->get('plandata');
652 my %options = $self->options;
653 $plandata .= join('', map { "$_=$options{$_}\n" } keys %options );
658 =item part_pkg_option
660 Returns all options as FS::part_pkg_option objects (see
661 L<FS::part_pkg_option>).
665 sub part_pkg_option {
667 qsearch('part_pkg_option', { 'pkgpart' => $self->pkgpart } );
672 Returns a list of option names and values suitable for assigning to a hash.
678 map { $_->optionname => $_->optionvalue } $self->part_pkg_option;
681 =item option OPTIONNAME
683 Returns the option value for the given name, or the empty string.
688 my( $self, $opt, $ornull ) = @_;
689 my $part_pkg_option =
690 qsearchs('part_pkg_option', {
691 pkgpart => $self->pkgpart,
694 return $part_pkg_option->optionvalue if $part_pkg_option;
695 my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
696 split("\n", $self->get('plandata') );
697 return $plandata{$opt} if exists $plandata{$opt};
698 cluck "WARNING: (pkgpart ". $self->pkgpart. ") Package def option $opt ".
699 "not found in options or plandata!\n"
704 =item bill_part_pkg_link
706 Returns the associated part_pkg_link records (see L<FS::part_pkg_link).
710 sub bill_part_pkg_link {
711 shift->_part_pkg_link('bill', @_);
714 =item svc_part_pkg_link
718 sub svc_part_pkg_link {
719 shift->_part_pkg_link('svc', @_);
723 my( $self, $type ) = @_;
724 qsearch('part_pkg_link', { 'src_pkgpart' => $self->pkgpart,
725 'link_type' => $type,
730 =item part_pkg_taxoverride
732 Returns all associated FS::part_pkg_taxoverride objects (see
733 L<FS::part_pkg_taxoverride>).
737 sub part_pkg_taxoverride {
739 qsearch('part_pkg_taxoverride', { 'pkgpart' => $self->pkgpart } );
742 =item taxproduct_description
744 Returns the description of the associated tax product for this package
745 definition (see L<FS::part_pkg_taxproduct>).
749 sub taxproduct_description {
751 my $part_pkg_taxproduct =
752 qsearchs( 'part_pkg_taxproduct',
753 { 'taxproductnum' => $self->taxproductnum }
755 $part_pkg_taxproduct ? $part_pkg_taxproduct->description : '';
758 =item part_pkg_taxrate DATA_PROVIDER, GEOCODE
760 Returns the package to taxrate m2m records for this package in the location
761 specified by GEOCODE (see L<FS::part_pkg_taxrate> and ).
765 sub part_pkg_taxrate {
767 my ($data_vendor, $geocode) = @_;
771 my $extra_sql = 'AND ('.
772 join(' OR ', map{ 'geocode = '. $dbh->quote(substr($geocode, 0, $_)) }
776 my $order_by = 'ORDER BY taxclassnum, length(geocode) desc';
777 my $select = 'DISTINCT ON(taxclassnum) *';
779 qsearch( { 'table' => 'part_pkg_taxrate',
780 'select' => 'distinct on(taxclassnum) *',
781 'hashref' => { 'data_vendor' => $data_vendor,
782 'taxproductnum' => $self->taxproductnum,
784 'extra_sql' => $extra_sql,
785 'order_by' => $order_by,
791 Reblesses the object into the FS::part_pkg::PLAN class (if available), where
792 PLAN is the object's I<plan> field. There should be better docs
793 on how to create new price plans, but until then, see L</NEW PLAN CLASSES>.
799 my $plan = $self->plan;
801 cluck "no price plan found for pkgpart ". $self->pkgpart. "\n"
805 return $self if ref($self) =~ /::$plan$/; #already blessed into plan subclass
806 my $class = ref($self). "::$plan";
807 warn "reblessing $self into $class" if $DEBUG;
810 bless($self, $class) unless $@;
814 #fallbacks that eval the setup and recur fields, for backwards compat
818 warn 'no price plan class for '. $self->plan. ", eval-ing setup\n";
819 $self->_calc_eval('setup', @_);
824 warn 'no price plan class for '. $self->plan. ", eval-ing recur\n";
825 $self->_calc_eval('recur', @_);
828 use vars qw( $sdate @details );
830 #my( $self, $field, $cust_pkg ) = @_;
831 my( $self, $field, $cust_pkg, $sdateref, $detailsref ) = @_;
833 *details = $detailsref;
834 $self->$field() =~ /^(.*)$/
835 or die "Illegal $field (pkgpart ". $self->pkgpart. '): '.
836 $self->$field(). "\n";
838 return 0 if $prog =~ /^\s*$/;
839 my $value = eval $prog;
844 #fallback that return 0 for old legacy packages with no plan
846 sub calc_remain { 0; }
847 sub calc_cancel { 0; }
855 # Used by FS::Upgrade to migrate to a new database.
857 sub _upgrade_data { # class method
858 my($class, %opts) = @_;
860 warn "[FS::part_pkg] upgrading $class\n" if $DEBUG;
862 my @part_pkg = qsearch({
863 'table' => 'part_pkg',
864 'extra_sql' => "WHERE ". join(' OR ',
865 ( map "($_ IS NOT NULL AND $_ != '' )",
866 qw( plandata setup recur ) ),
867 'plan IS NULL', "plan = '' ",
871 foreach my $part_pkg (@part_pkg) {
873 unless ( $part_pkg->plan ) {
875 $part_pkg->plan('flat');
877 if ( $part_pkg->setup =~ /^\s*([\d\.]+)\s*$/ ) {
879 my $opt = new FS::part_pkg_option {
880 'pkgpart' => $part_pkg->pkgpart,
881 'optionname' => 'setup_fee',
884 my $error = $opt->insert;
885 die $error if $error;
887 $part_pkg->setup('');
890 die "Can't parse part_pkg.setup for fee; convert pkgnum ".
891 $part_pkg->pkgnum. " manually: ". $part_pkg->setup. "\n";
894 if ( $part_pkg->recur =~ /^\s*([\d\.]+)\s*$/ ) {
896 my $opt = new FS::part_pkg_option {
897 'pkgpart' => $part_pkg->pkgpart,
898 'optionname' => 'recur_fee',
901 my $error = $opt->insert;
902 die $error if $error;
904 $part_pkg->recur('');
907 die "Can't parse part_pkg.setup for fee; convert pkgnum ".
908 $part_pkg->pkgnum. " manually: ". $part_pkg->setup. "\n";
913 $part_pkg->replace; #this should take care of plandata, right?
928 foreach my $INC ( @INC ) {
929 warn "globbing $INC/FS/part_pkg/*.pm\n" if $DEBUG;
930 foreach my $file ( glob("$INC/FS/part_pkg/*.pm") ) {
931 warn "attempting to load plan info from $file\n" if $DEBUG;
932 $file =~ /\/(\w+)\.pm$/ or do {
933 warn "unrecognized file in $INC/FS/part_pkg/: $file\n";
937 my $info = eval "use FS::part_pkg::$mod; ".
938 "\\%FS::part_pkg::$mod\::info;";
940 die "error using FS::part_pkg::$mod (skipping): $@\n" if $@;
943 unless ( keys %$info ) {
944 warn "no %info hash found in FS::part_pkg::$mod, skipping\n"
945 unless $mod =~ /^(passwdfile|null)$/; #hack but what the heck
948 warn "got plan info from FS::part_pkg::$mod: $info\n" if $DEBUG;
949 if ( exists($info->{'disabled'}) && $info->{'disabled'} ) {
950 warn "skipping disabled plan FS::part_pkg::$mod" if $DEBUG;
957 tie %plans, 'Tie::IxHash',
958 map { $_ => $info{$_} }
959 sort { $info{$a}->{'weight'} <=> $info{$b}->{'weight'} }
966 =item format OPTION DATA
968 Returns data formatted according to the function 'format' described
969 in the plan info. Returns DATA if no such function exists.
974 my ($self, $option, $data) = (shift, shift, shift);
975 if (exists($plans{$self->plan}->{fields}->{$option}{format})) {
976 &{$plans{$self->plan}->{fields}->{$option}{format}}($data);
982 =item parse OPTION DATA
984 Returns data parsed according to the function 'parse' described
985 in the plan info. Returns DATA if no such function exists.
990 my ($self, $option, $data) = (shift, shift, shift);
991 if (exists($plans{$self->plan}->{fields}->{$option}{parse})) {
992 &{$plans{$self->plan}->{fields}->{$option}{parse}}($data);
1001 =head1 NEW PLAN CLASSES
1003 A module should be added in FS/FS/part_pkg/ Eventually, an example may be
1004 found in eg/plan_template.pm. Until then, it is suggested that you use the
1005 other modules in FS/FS/part_pkg/ as a guide.
1009 The delete method is unimplemented.
1011 setup and recur semantics are not yet defined (and are implemented in
1012 FS::cust_bill. hmm.). now they're deprecated and need to go.
1018 L<FS::Record>, L<FS::cust_pkg>, L<FS::type_pkgs>, L<FS::pkg_svc>, L<Safe>.
1019 schema.html from the base documentation.