4 use vars qw( @ISA %plans $DEBUG );
5 use Carp qw(carp cluck confess);
6 use Time::Local qw( timelocal_nocheck );
9 use FS::Record qw( qsearch qsearchs dbh dbdef );
15 use FS::part_pkg_option;
18 @ISA = qw( FS::m2m_Common FS::Record ); # FS::option_Common ); # this can use option_Common
19 # when all the plandata bs is
26 FS::part_pkg - Object methods for part_pkg objects
32 $record = new FS::part_pkg \%hash
33 $record = new FS::part_pkg { 'column' => 'value' };
35 $custom_record = $template_record->clone;
37 $error = $record->insert;
39 $error = $new_record->replace($old_record);
41 $error = $record->delete;
43 $error = $record->check;
45 @pkg_svc = $record->pkg_svc;
47 $svcnum = $record->svcpart;
48 $svcnum = $record->svcpart( 'svc_acct' );
52 An FS::part_pkg object represents a package definition. FS::part_pkg
53 inherits from FS::Record. The following fields are currently supported:
57 =item pkgpart - primary key (assigned automatically for new package definitions)
59 =item pkg - Text name of this package definition (customer-viewable)
61 =item comment - Text name of this package definition (non-customer-viewable)
63 =item classnum - Optional package class (see L<FS::pkg_class>)
65 =item promo_code - Promotional code
67 =item setup - Setup fee expression (deprecated)
69 =item freq - Frequency of recurring fee
71 =item recur - Recurring fee expression (deprecated)
73 =item setuptax - Setup fee tax exempt flag, empty or `Y'
75 =item recurtax - Recurring fee tax exempt flag, empty or `Y'
77 =item taxclass - Tax class
79 =item plan - Price plan
81 =item plandata - Price plan data (deprecated - see L<FS::part_pkg_option> instead)
83 =item disabled - Disabled flag, empty or `Y'
85 =item pay_weight - Weight (relative to credit_weight and other package definitions) that controls payment application to specific line items.
87 =item credit_weight - Weight (relative to other package definitions) that controls credit application to specific line items.
97 Creates a new package definition. To add the package definition to
98 the database, see L<"insert">.
102 sub table { 'part_pkg'; }
106 An alternate constructor. Creates a new package definition by duplicating
107 an existing definition. A new pkgpart is assigned and `(CUSTOM) ' is prepended
108 to the comment field. To add the package definition to the database, see
115 my $class = ref($self);
116 my %hash = $self->hash;
117 $hash{'pkgpart'} = '';
118 $hash{'comment'} = "(CUSTOM) ". $hash{'comment'}
119 unless $hash{'comment'} =~ /^\(CUSTOM\) /;
120 #new FS::part_pkg ( \%hash ); # ?
121 new $class ( \%hash ); # ?
124 =item insert [ , OPTION => VALUE ... ]
126 Adds this package definition to the database. If there is an error,
127 returns the error, otherwise returns false.
129 Currently available options are: I<pkg_svc>, I<primary_svc>, I<cust_pkg>,
130 I<custnum_ref> and I<options>.
132 If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
133 values, appropriate FS::pkg_svc records will be inserted.
135 If I<primary_svc> is set to the svcpart of the primary service, the appropriate
136 FS::pkg_svc record will be updated.
138 If I<cust_pkg> is set to a pkgnum of a FS::cust_pkg record (or the FS::cust_pkg
139 record itself), the object will be updated to point to this package definition.
141 In conjunction with I<cust_pkg>, if I<custnum_ref> is set to a scalar reference,
142 the scalar will be updated with the custnum value from the cust_pkg record.
144 If I<options> is set to a hashref of options, appropriate FS::part_pkg_option
145 records will be inserted.
152 warn "FS::part_pkg::insert called on $self with options ".
153 join(', ', map "$_=>$options{$_}", keys %options)
156 local $SIG{HUP} = 'IGNORE';
157 local $SIG{INT} = 'IGNORE';
158 local $SIG{QUIT} = 'IGNORE';
159 local $SIG{TERM} = 'IGNORE';
160 local $SIG{TSTP} = 'IGNORE';
161 local $SIG{PIPE} = 'IGNORE';
163 my $oldAutoCommit = $FS::UID::AutoCommit;
164 local $FS::UID::AutoCommit = 0;
167 warn " saving legacy plandata" if $DEBUG;
168 my $plandata = $self->get('plandata');
169 $self->set('plandata', '');
171 warn " inserting part_pkg record" if $DEBUG;
172 my $error = $self->SUPER::insert;
174 $dbh->rollback if $oldAutoCommit;
180 warn " inserting part_pkg_option records for plandata" if $DEBUG;
181 foreach my $part_pkg_option (
182 map { /^(\w+)=(.*)$/ or do { $dbh->rollback if $oldAutoCommit;
183 return "illegal plandata: $plandata";
185 new FS::part_pkg_option {
186 'pkgpart' => $self->pkgpart,
191 split("\n", $plandata)
193 my $error = $part_pkg_option->insert;
195 $dbh->rollback if $oldAutoCommit;
200 } elsif ( $options{'options'} ) {
202 warn " inserting part_pkg_option records for options hashref" if $DEBUG;
203 foreach my $optionname ( keys %{$options{'options'}} ) {
205 my $part_pkg_option =
206 new FS::part_pkg_option {
207 'pkgpart' => $self->pkgpart,
208 'optionname' => $optionname,
209 'optionvalue' => $options{'options'}->{$optionname},
212 my $error = $part_pkg_option->insert;
214 $dbh->rollback if $oldAutoCommit;
222 my $conf = new FS::Conf;
223 if ( $conf->exists('agent_defaultpkg') ) {
224 warn " agent_defaultpkg set; allowing all agents to purchase package"
226 foreach my $agent_type ( qsearch('agent_type', {} ) ) {
227 my $type_pkgs = new FS::type_pkgs({
228 'typenum' => $agent_type->typenum,
229 'pkgpart' => $self->pkgpart,
231 my $error = $type_pkgs->insert;
233 $dbh->rollback if $oldAutoCommit;
239 warn " inserting pkg_svc records" if $DEBUG;
240 my $pkg_svc = $options{'pkg_svc'} || {};
241 foreach my $part_svc ( qsearch('part_svc', {} ) ) {
242 my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
244 ( $options{'primary_svc'} && $options{'primary_svc'}==$part_svc->svcpart )
248 my $pkg_svc = new FS::pkg_svc( {
249 'pkgpart' => $self->pkgpart,
250 'svcpart' => $part_svc->svcpart,
251 'quantity' => $quantity,
252 'primary_svc' => $primary_svc,
254 my $error = $pkg_svc->insert;
256 $dbh->rollback if $oldAutoCommit;
261 if ( $options{'cust_pkg'} ) {
262 warn " updating cust_pkg record " if $DEBUG;
264 ref($options{'cust_pkg'})
265 ? $options{'cust_pkg'}
266 : qsearchs('cust_pkg', { pkgnum => $options{'cust_pkg'} } );
267 ${ $options{'custnum_ref'} } = $old_cust_pkg->custnum
268 if $options{'custnum_ref'};
269 my %hash = $old_cust_pkg->hash;
270 $hash{'pkgpart'} = $self->pkgpart,
271 my $new_cust_pkg = new FS::cust_pkg \%hash;
272 local($FS::cust_pkg::disable_agentcheck) = 1;
273 my $error = $new_cust_pkg->replace($old_cust_pkg);
275 $dbh->rollback if $oldAutoCommit;
276 return "Error modifying cust_pkg record: $error";
280 warn " commiting transaction" if $DEBUG;
281 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
288 Currently unimplemented.
293 return "Can't (yet?) delete package definitions.";
294 # check & make sure the pkgpart isn't in cust_pkg or type_pkgs?
297 =item replace OLD_RECORD [ , OPTION => VALUE ... ]
299 Replaces OLD_RECORD with this one in the database. If there is an error,
300 returns the error, otherwise returns false.
302 Currently available options are: I<pkg_svc> and I<primary_svc>
304 If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
305 values, the appropriate FS::pkg_svc records will be replace.
307 If I<primary_svc> is set to the svcpart of the primary service, the appropriate
308 FS::pkg_svc record will be updated.
313 my( $new, $old ) = ( shift, shift );
316 # We absolutely have to have an old vs. new record to make this work.
317 if (!defined($old)) {
318 $old = qsearchs( 'part_pkg', { 'pkgpart' => $new->pkgpart } );
321 warn "FS::part_pkg::replace called on $new to replace $old ".
322 "with options %options"
325 local $SIG{HUP} = 'IGNORE';
326 local $SIG{INT} = 'IGNORE';
327 local $SIG{QUIT} = 'IGNORE';
328 local $SIG{TERM} = 'IGNORE';
329 local $SIG{TSTP} = 'IGNORE';
330 local $SIG{PIPE} = 'IGNORE';
332 my $oldAutoCommit = $FS::UID::AutoCommit;
333 local $FS::UID::AutoCommit = 0;
336 warn " saving legacy plandata" if $DEBUG;
337 my $plandata = $new->get('plandata');
338 $new->set('plandata', '');
340 warn " deleting old part_pkg_option records" if $DEBUG;
341 foreach my $part_pkg_option ( $old->part_pkg_option ) {
342 my $error = $part_pkg_option->delete;
344 $dbh->rollback if $oldAutoCommit;
349 warn " replacing part_pkg record" if $DEBUG;
350 my $error = $new->SUPER::replace($old);
352 $dbh->rollback if $oldAutoCommit;
356 warn " inserting part_pkg_option records for plandata" if $DEBUG;
357 foreach my $part_pkg_option (
358 map { /^(\w+)=(.*)$/ or do { $dbh->rollback if $oldAutoCommit;
359 return "illegal plandata: $plandata";
361 new FS::part_pkg_option {
362 'pkgpart' => $new->pkgpart,
367 split("\n", $plandata)
369 my $error = $part_pkg_option->insert;
371 $dbh->rollback if $oldAutoCommit;
376 warn " replacing pkg_svc records" if $DEBUG;
377 my $pkg_svc = $options{'pkg_svc'} || {};
378 foreach my $part_svc ( qsearch('part_svc', {} ) ) {
379 my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
381 ( defined($options{'primary_svc'})
382 && $options{'primary_svc'} == $part_svc->svcpart
387 my $old_pkg_svc = qsearchs('pkg_svc', {
388 'pkgpart' => $old->pkgpart,
389 'svcpart' => $part_svc->svcpart,
391 my $old_quantity = $old_pkg_svc ? $old_pkg_svc->quantity : 0;
392 my $old_primary_svc =
393 ( $old_pkg_svc && $old_pkg_svc->dbdef_table->column('primary_svc') )
394 ? $old_pkg_svc->primary_svc
396 next unless $old_quantity != $quantity || $old_primary_svc ne $primary_svc;
398 my $new_pkg_svc = new FS::pkg_svc( {
399 'pkgsvcnum' => ( $old_pkg_svc ? $old_pkg_svc->pkgsvcnum : '' ),
400 'pkgpart' => $new->pkgpart,
401 'svcpart' => $part_svc->svcpart,
402 'quantity' => $quantity,
403 'primary_svc' => $primary_svc,
405 my $error = $old_pkg_svc
406 ? $new_pkg_svc->replace($old_pkg_svc)
407 : $new_pkg_svc->insert;
409 $dbh->rollback if $oldAutoCommit;
414 warn " commiting transaction" if $DEBUG;
415 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
421 Checks all fields to make sure this is a valid package definition. If
422 there is an error, returns the error, otherwise returns false. Called by the
423 insert and replace methods.
429 warn "FS::part_pkg::check called on $self" if $DEBUG;
431 for (qw(setup recur plandata)) {
432 #$self->set($_=>0) if $self->get($_) =~ /^\s*$/; }
433 return "Use of $_ field is deprecated; set a plan and options"
434 if length($self->get($_));
438 if ( $self->dbdef_table->column('freq')->type =~ /(int)/i ) {
439 my $error = $self->ut_number('freq');
440 return $error if $error;
442 $self->freq =~ /^(\d+[hdw]?)$/
443 or return "Illegal or empty freq: ". $self->freq;
447 my $error = $self->ut_numbern('pkgpart')
448 || $self->ut_text('pkg')
449 || $self->ut_text('comment')
450 || $self->ut_textn('promo_code')
451 || $self->ut_alphan('plan')
452 || $self->ut_enum('setuptax', [ '', 'Y' ] )
453 || $self->ut_enum('recurtax', [ '', 'Y' ] )
454 || $self->ut_textn('taxclass')
455 || $self->ut_enum('disabled', [ '', 'Y' ] )
456 || $self->ut_floatn('pay_weight')
457 || $self->ut_floatn('credit_weight')
458 || $self->SUPER::check
460 return $error if $error;
462 if ( $self->classnum !~ /^$/ ) {
463 my $error = $self->ut_foreign_key('classnum', 'pkg_class', 'classnum');
464 return $error if $error;
469 return 'Unknown plan '. $self->plan
470 unless exists($plans{$self->plan});
472 my $conf = new FS::Conf;
473 return 'Taxclass is required'
474 if ! $self->taxclass && $conf->exists('require_taxclasses');
481 Returns an (internal) string representing this package. Currently,
482 "pkgpart: pkg - comment", is returned. "pkg - comment" may be returned in the
483 future, omitting pkgpart.
490 #$self->pkg. ' - '. $self->comment;
491 #$self->pkg. ' ('. $self->comment. ')';
492 $self->pkgpart. ': '. $self->pkg. ' - '. $self->comment;
497 Returns the package class, as an FS::pkg_class object, or the empty string
498 if there is no package class.
504 if ( $self->classnum ) {
505 qsearchs('pkg_class', { 'classnum' => $self->classnum } );
513 Returns the package class name, or the empty string if there is no package
520 my $pkg_class = $self->pkg_class;
522 ? $pkg_class->classname
528 Returns all FS::pkg_svc objects (see L<FS::pkg_svc>) for this package
529 definition (with non-zero quantity).
535 #sort { $b->primary cmp $a->primary }
536 grep { $_->quantity }
537 qsearch( 'pkg_svc', { 'pkgpart' => $self->pkgpart } );
540 =item svcpart [ SVCDB ]
542 Returns the svcpart of the primary service definition (see L<FS::part_svc>)
543 associated with this package definition (see L<FS::pkg_svc>). Returns
544 false if there not a primary service definition or exactly one service
545 definition with quantity 1, or if SVCDB is specified and does not match the
546 svcdb of the service definition,
552 my $svcdb = scalar(@_) ? shift : '';
554 grep { ( $svcdb eq $_->part_svc->svcdb || !$svcdb ) } $self->pkg_svc;
556 @pkg_svc = grep { $_->primary_svc =~ /^Y/i } @svcdb_pkg_svc
557 if dbdef->table('pkg_svc')->column('primary_svc');
558 @pkg_svc = grep {$_->quantity == 1 } @svcdb_pkg_svc
560 return '' if scalar(@pkg_svc) != 1;
561 $pkg_svc[0]->svcpart;
566 Returns a list of the acceptable payment types for this package. Eventually
567 this should come out of a database table and be editable, but currently has the
568 following logic instead:
570 If the package is free, the single item B<BILL> is
571 returned, otherwise, the single item B<CARD> is returned.
573 (CHEK? LEC? Probably shouldn't accept those by default, prone to abuse)
579 if ( $self->is_free ) {
588 Returns true if this package is free.
594 unless ( $self->plan ) {
595 $self->setup =~ /^\s*0+(\.0*)?\s*$/
596 && $self->recur =~ /^\s*0+(\.0*)?\s*$/;
597 } elsif ( $self->can('is_free_options') ) {
598 not grep { $_ !~ /^\s*0*(\.0*)?\s*$/ }
599 map { $self->option($_) }
600 $self->is_free_options;
602 warn "FS::part_pkg::is_free: FS::part_pkg::". $self->plan. " subclass ".
603 "provides neither is_free_options nor is_free method; returning false";
610 #method, class method or sub? #my $self = shift;
612 tie my %freq, 'Tie::IxHash',
613 '0' => '(no recurring fee)',
616 '2d' => 'every two days',
617 '3d' => 'every three days',
619 '2w' => 'biweekly (every 2 weeks)',
621 '45d' => 'every 45 days',
622 '2' => 'bimonthly (every 2 months)',
623 '3' => 'quarterly (every 3 months)',
624 '4' => 'every 4 months',
625 '137d' => 'every 4 1/2 months (137 days)',
626 '6' => 'semiannually (every 6 months)',
628 '13' => 'every 13 months (annually +1 month)',
629 '24' => 'biannually (every 2 years)',
630 '36' => 'triannually (every 3 years)',
631 '48' => '(every 4 years)',
632 '60' => '(every 5 years)',
633 '120' => '(every 10 years)',
642 Returns an english representation of the I<freq> field, such as "monthly",
643 "weekly", "semi-annually", etc.
649 my $freq = $self->freq;
651 #my $freqs_href = $self->freqs_href;
652 my $freqs_href = freqs_href();
654 if ( exists($freqs_href->{$freq}) ) {
655 $freqs_href->{$freq};
657 my $interval = 'month';
658 if ( $freq =~ /^(\d+)([hdw])$/ ) {
659 my %interval = ( 'h' => 'hour', 'd'=>'day', 'w'=>'week' );
660 $interval = $interval{$2};
665 "every $freq ${interval}s";
670 =item add_freq TIMESTAMP
672 Adds the frequency of this package to the provided timestamp and returns
673 the resulting timestamp, or -1 if the frequency of this package could not be
674 parsed (shouldn't happen).
679 my( $self, $date ) = @_;
680 my $freq = $self->freq;
682 #change this bit to use Date::Manip? CAREFUL with timezones (see
683 # mailing list archive)
684 my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($date) )[0,1,2,3,4,5];
686 if ( $self->freq =~ /^\d+$/ ) {
688 until ( $mon < 12 ) { $mon -= 12; $year++; }
689 } elsif ( $self->freq =~ /^(\d+)w$/ ) {
692 } elsif ( $self->freq =~ /^(\d+)d$/ ) {
695 } elsif ( $self->freq =~ /^(\d+)h$/ ) {
702 timelocal_nocheck($sec,$min,$hour,$mday,$mon,$year);
707 For backwards compatibility, returns the plandata field as well as all options
708 from FS::part_pkg_option.
714 carp "plandata is deprecated";
716 $self->SUPER::plandata(@_);
718 my $plandata = $self->get('plandata');
719 my %options = $self->options;
720 $plandata .= join('', map { "$_=$options{$_}\n" } keys %options );
725 =item part_pkg_option
727 Returns all options as FS::part_pkg_option objects (see
728 L<FS::part_pkg_option>).
732 sub part_pkg_option {
734 qsearch('part_pkg_option', { 'pkgpart' => $self->pkgpart } );
739 Returns a list of option names and values suitable for assigning to a hash.
745 map { $_->optionname => $_->optionvalue } $self->part_pkg_option;
748 =item option OPTIONNAME
750 Returns the option value for the given name, or the empty string.
755 my( $self, $opt, $ornull ) = @_;
756 my $part_pkg_option =
757 qsearchs('part_pkg_option', {
758 pkgpart => $self->pkgpart,
761 return $part_pkg_option->optionvalue if $part_pkg_option;
762 my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
763 split("\n", $self->get('plandata') );
764 return $plandata{$opt} if exists $plandata{$opt};
765 cluck "WARNING: (pkgpart ". $self->pkgpart. ") Package def option $opt ".
766 "not found in options or plandata!\n"
773 Reblesses the object into the FS::part_pkg::PLAN class (if available), where
774 PLAN is the object's I<plan> field. There should be better docs
775 on how to create new price plans, but until then, see L</NEW PLAN CLASSES>.
781 my $plan = $self->plan;
783 confess "no price plan found for pkgpart ". $self->pkgpart. "\n"
787 return $self if ref($self) =~ /::$plan$/; #already blessed into plan subclass
788 my $class = ref($self). "::$plan";
789 warn "reblessing $self into $class" if $DEBUG;
792 bless($self, $class) unless $@;
796 #fallbacks that eval the setup and recur fields, for backwards compat
800 warn 'no price plan class for '. $self->plan. ", eval-ing setup\n";
801 $self->_calc_eval('setup', @_);
806 warn 'no price plan class for '. $self->plan. ", eval-ing recur\n";
807 $self->_calc_eval('recur', @_);
810 use vars qw( $sdate @details );
812 #my( $self, $field, $cust_pkg ) = @_;
813 my( $self, $field, $cust_pkg, $sdateref, $detailsref ) = @_;
815 *details = $detailsref;
816 $self->$field() =~ /^(.*)$/
817 or die "Illegal $field (pkgpart ". $self->pkgpart. '): '.
818 $self->$field(). "\n";
820 return 0 if $prog =~ /^\s*$/;
821 my $value = eval $prog;
826 #fallback that return 0 for old legacy packages with no plan
828 sub calc_remain { 0; }
829 sub calc_cancel { 0; }
837 # Used by FS::Upgrade to migrate to a new database.
839 sub _upgrade_data { # class method
840 my($class, %opts) = @_;
842 warn "[FS::part_pkg] upgrading $class\n" if $DEBUG;
844 my @part_pkg = qsearch({
845 'table' => 'part_pkg',
846 'extra_sql' => "WHERE ". join(' OR ',
847 ( map "($_ IS NOT NULL AND $_ != '' )",
848 qw( plandata setup recur ) ),
849 'plan IS NULL', "plan = '' ",
853 foreach my $part_pkg (@part_pkg) {
855 unless ( $part_pkg->plan ) {
857 $part_pkg->plan('flat');
859 if ( $part_pkg->setup =~ /^\s*([\d\.]+)\s*$/ ) {
861 my $opt = new FS::part_pkg_option {
862 'pkgpart' => $part_pkg->pkgpart,
863 'optionname' => 'setup_fee',
866 my $error = $opt->insert;
867 die $error if $error;
869 $part_pkg->setup('');
872 die "Can't parse part_pkg.setup for fee; convert pkgnum ".
873 $part_pkg->pkgnum. " manually: ". $part_pkg->setup. "\n";
876 if ( $part_pkg->recur =~ /^\s*([\d\.]+)\s*$/ ) {
878 my $opt = new FS::part_pkg_option {
879 'pkgpart' => $part_pkg->pkgpart,
880 'optionname' => 'recur_fee',
883 my $error = $opt->insert;
884 die $error if $error;
886 $part_pkg->recur('');
889 die "Can't parse part_pkg.setup for fee; convert pkgnum ".
890 $part_pkg->pkgnum. " manually: ". $part_pkg->setup. "\n";
895 $part_pkg->replace; #this should take care of plandata, right?
910 foreach my $INC ( @INC ) {
911 warn "globbing $INC/FS/part_pkg/*.pm\n" if $DEBUG;
912 foreach my $file ( glob("$INC/FS/part_pkg/*.pm") ) {
913 warn "attempting to load plan info from $file\n" if $DEBUG;
914 $file =~ /\/(\w+)\.pm$/ or do {
915 warn "unrecognized file in $INC/FS/part_pkg/: $file\n";
919 my $info = eval "use FS::part_pkg::$mod; ".
920 "\\%FS::part_pkg::$mod\::info;";
922 die "error using FS::part_pkg::$mod (skipping): $@\n" if $@;
925 unless ( keys %$info ) {
926 warn "no %info hash found in FS::part_pkg::$mod, skipping\n"
927 unless $mod =~ /^(passwdfile|null)$/; #hack but what the heck
930 warn "got plan info from FS::part_pkg::$mod: $info\n" if $DEBUG;
931 if ( exists($info->{'disabled'}) && $info->{'disabled'} ) {
932 warn "skipping disabled plan FS::part_pkg::$mod" if $DEBUG;
939 tie %plans, 'Tie::IxHash',
940 map { $_ => $info{$_} }
941 sort { $info{$a}->{'weight'} <=> $info{$b}->{'weight'} }
948 #fallback for everything except bulk.pm
949 sub hide_svc_detail { 0; }
951 =item format OPTION DATA
953 Returns data formatted according to the function 'format' described
954 in the plan info. Returns DATA if no such function exists.
959 my ($self, $option, $data) = (shift, shift, shift);
960 if (exists($plans{$self->plan}->{fields}->{$option}{format})) {
961 &{$plans{$self->plan}->{fields}->{$option}{format}}($data);
967 =item parse OPTION DATA
969 Returns data parsed according to the function 'parse' described
970 in the plan info. Returns DATA if no such function exists.
975 my ($self, $option, $data) = (shift, shift, shift);
976 if (exists($plans{$self->plan}->{fields}->{$option}{parse})) {
977 &{$plans{$self->plan}->{fields}->{$option}{parse}}($data);
986 =head1 NEW PLAN CLASSES
988 A module should be added in FS/FS/part_pkg/ Eventually, an example may be
989 found in eg/plan_template.pm. Until then, it is suggested that you use the
990 other modules in FS/FS/part_pkg/ as a guide.
994 The delete method is unimplemented.
996 setup and recur semantics are not yet defined (and are implemented in
997 FS::cust_bill. hmm.). now they're deprecated and need to go.
1003 L<FS::Record>, L<FS::cust_pkg>, L<FS::type_pkgs>, L<FS::pkg_svc>, L<Safe>.
1004 schema.html from the base documentation.