support multiple primary keys
[freeside.git] / FS / FS / part_pkg.pm
1 package FS::part_pkg;
2
3 use strict;
4 use vars qw( @ISA %freq %plans $DEBUG );
5 use Carp qw(carp cluck);
6 use Tie::IxHash;
7 use FS::Conf;
8 use FS::Record qw( qsearch qsearchs dbh dbdef );
9 use FS::pkg_svc;
10 use FS::part_svc;
11 use FS::cust_pkg;
12 use FS::agent_type;
13 use FS::type_pkgs;
14 use FS::part_pkg_option;
15
16 @ISA = qw( FS::Record );
17
18 $DEBUG = 0;
19
20 =head1 NAME
21
22 FS::part_pkg - Object methods for part_pkg objects
23
24 =head1 SYNOPSIS
25
26   use FS::part_pkg;
27
28   $record = new FS::part_pkg \%hash
29   $record = new FS::part_pkg { 'column' => 'value' };
30
31   $custom_record = $template_record->clone;
32
33   $error = $record->insert;
34
35   $error = $new_record->replace($old_record);
36
37   $error = $record->delete;
38
39   $error = $record->check;
40
41   @pkg_svc = $record->pkg_svc;
42
43   $svcnum = $record->svcpart;
44   $svcnum = $record->svcpart( 'svc_acct' );
45
46 =head1 DESCRIPTION
47
48 An FS::part_pkg object represents a package definition.  FS::part_pkg
49 inherits from FS::Record.  The following fields are currently supported:
50
51 =over 4
52
53 =item pkgpart - primary key (assigned automatically for new package definitions)
54
55 =item pkg - Text name of this package definition (customer-viewable)
56
57 =item comment - Text name of this package definition (non-customer-viewable)
58
59 =item promo_code - Promotional code
60
61 =item setup - Setup fee expression (deprecated)
62
63 =item freq - Frequency of recurring fee
64
65 =item recur - Recurring fee expression (deprecated)
66
67 =item setuptax - Setup fee tax exempt flag, empty or `Y'
68
69 =item recurtax - Recurring fee tax exempt flag, empty or `Y'
70
71 =item taxclass - Tax class 
72
73 =item plan - Price plan
74
75 =item plandata - Price plan data (deprecated - see L<FS::part_pkg_option> instead)
76
77 =item disabled - Disabled flag, empty or `Y'
78
79 =back
80
81 =head1 METHODS
82
83 =over 4 
84
85 =item new HASHREF
86
87 Creates a new package definition.  To add the package definition to
88 the database, see L<"insert">.
89
90 =cut
91
92 sub table { 'part_pkg'; }
93
94 =item clone
95
96 An alternate constructor.  Creates a new package definition by duplicating
97 an existing definition.  A new pkgpart is assigned and `(CUSTOM) ' is prepended
98 to the comment field.  To add the package definition to the database, see
99 L<"insert">.
100
101 =cut
102
103 sub clone {
104   my $self = shift;
105   my $class = ref($self);
106   my %hash = $self->hash;
107   $hash{'pkgpart'} = '';
108   $hash{'comment'} = "(CUSTOM) ". $hash{'comment'}
109     unless $hash{'comment'} =~ /^\(CUSTOM\) /;
110   #new FS::part_pkg ( \%hash ); # ?
111   new $class ( \%hash ); # ?
112 }
113
114 =item insert [ , OPTION => VALUE ... ]
115
116 Adds this package definition to the database.  If there is an error,
117 returns the error, otherwise returns false.
118
119 Currently available options are: I<pkg_svc>, I<primary_svc>, I<cust_pkg>, 
120 I<custnum_ref> and I<options>.
121
122 If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
123 values, appropriate FS::pkg_svc records will be inserted.
124
125 If I<primary_svc> is set to the svcpart of the primary service, the appropriate
126 FS::pkg_svc record will be updated.
127
128 If I<cust_pkg> is set to a pkgnum of a FS::cust_pkg record (or the FS::cust_pkg
129 record itself), the object will be updated to point to this package definition.
130
131 In conjunction with I<cust_pkg>, if I<custnum_ref> is set to a scalar reference,
132 the scalar will be updated with the custnum value from the cust_pkg record.
133
134 If I<options> is set to a hashref of options, appropriate FS::part_pkg_option
135 records will be inserted.
136
137 =cut
138
139 sub insert {
140   my $self = shift;
141   my %options = @_;
142   warn "FS::part_pkg::insert called on $self with options ".
143        join(', ', map "$_=>$options{$_}", keys %options)
144     if $DEBUG;
145
146   local $SIG{HUP} = 'IGNORE';
147   local $SIG{INT} = 'IGNORE';
148   local $SIG{QUIT} = 'IGNORE';
149   local $SIG{TERM} = 'IGNORE';
150   local $SIG{TSTP} = 'IGNORE';
151   local $SIG{PIPE} = 'IGNORE';
152
153   my $oldAutoCommit = $FS::UID::AutoCommit;
154   local $FS::UID::AutoCommit = 0;
155   my $dbh = dbh;
156
157   warn "  saving legacy plandata" if $DEBUG;
158   my $plandata = $self->get('plandata');
159   $self->set('plandata', '');
160
161   warn "  inserting part_pkg record" if $DEBUG;
162   my $error = $self->SUPER::insert;
163   if ( $error ) {
164     $dbh->rollback if $oldAutoCommit;
165     return $error;
166   }
167
168   if ( $plandata ) {
169
170     warn "  inserting part_pkg_option records for plandata" if $DEBUG;
171     foreach my $part_pkg_option ( 
172       map { /^(\w+)=(.*)$/ or do { $dbh->rollback if $oldAutoCommit;
173                                    return "illegal plandata: $plandata";
174                                  };
175             new FS::part_pkg_option {
176               'pkgpart'     => $self->pkgpart,
177               'optionname'  => $1,
178               'optionvalue' => $2,
179             };
180           }
181       split("\n", $plandata)
182     ) {
183       my $error = $part_pkg_option->insert;
184       if ( $error ) {
185         $dbh->rollback if $oldAutoCommit;
186         return $error;
187       }
188     }
189
190   } elsif ( $options{'options'} ) {
191
192     warn "  inserting part_pkg_option records for options hashref" if $DEBUG;
193     foreach my $optionname ( keys %{$options{'options'}} ) {
194
195       my $part_pkg_option =
196         new FS::part_pkg_option {
197           'pkgpart'     => $self->pkgpart,
198           'optionname'  => $optionname,
199           'optionvalue' => $options{'options'}->{$optionname},
200         };
201
202       my $error = $part_pkg_option->insert;
203       if ( $error ) {
204         $dbh->rollback if $oldAutoCommit;
205         return $error;
206       }
207
208     }
209
210   }
211
212   my $conf = new FS::Conf;
213   if ( $conf->exists('agent_defaultpkg') ) {
214     warn "  agent_defaultpkg set; allowing all agents to purchase package"
215       if $DEBUG;
216     foreach my $agent_type ( qsearch('agent_type', {} ) ) {
217       my $type_pkgs = new FS::type_pkgs({
218         'typenum' => $agent_type->typenum,
219         'pkgpart' => $self->pkgpart,
220       });
221       my $error = $type_pkgs->insert;
222       if ( $error ) {
223         $dbh->rollback if $oldAutoCommit;
224         return $error;
225       }
226     }
227   }
228
229   warn "  inserting pkg_svc records" if $DEBUG;
230   my $pkg_svc = $options{'pkg_svc'} || {};
231   foreach my $part_svc ( qsearch('part_svc', {} ) ) {
232     my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
233     my $primary_svc =
234       ( $options{'primary_svc'} && $options{'primary_svc'}==$part_svc->svcpart )
235         ? 'Y'
236         : '';
237
238     my $pkg_svc = new FS::pkg_svc( {
239       'pkgpart'     => $self->pkgpart,
240       'svcpart'     => $part_svc->svcpart,
241       'quantity'    => $quantity, 
242       'primary_svc' => $primary_svc,
243     } );
244     my $error = $pkg_svc->insert;
245     if ( $error ) {
246       $dbh->rollback if $oldAutoCommit;
247       return $error;
248     }
249   }
250
251   if ( $options{'cust_pkg'} ) {
252     warn "  updating cust_pkg record " if $DEBUG;
253     my $old_cust_pkg =
254       ref($options{'cust_pkg'})
255         ? $options{'cust_pkg'}
256         : qsearchs('cust_pkg', { pkgnum => $options{'cust_pkg'} } );
257     ${ $options{'custnum_ref'} } = $old_cust_pkg->custnum
258       if $options{'custnum_ref'};
259     my %hash = $old_cust_pkg->hash;
260     $hash{'pkgpart'} = $self->pkgpart,
261     my $new_cust_pkg = new FS::cust_pkg \%hash;
262     local($FS::cust_pkg::disable_agentcheck) = 1;
263     my $error = $new_cust_pkg->replace($old_cust_pkg);
264     if ( $error ) {
265       $dbh->rollback if $oldAutoCommit;
266       return "Error modifying cust_pkg record: $error";
267     }
268   }
269
270   warn "  commiting transaction" if $DEBUG;
271   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
272
273   '';
274 }
275
276 =item delete
277
278 Currently unimplemented.
279
280 =cut
281
282 sub delete {
283   return "Can't (yet?) delete package definitions.";
284 # check & make sure the pkgpart isn't in cust_pkg or type_pkgs?
285 }
286
287 =item replace OLD_RECORD [ , OPTION => VALUE ... ]
288
289 Replaces OLD_RECORD with this one in the database.  If there is an error,
290 returns the error, otherwise returns false.
291
292 Currently available options are: I<pkg_svc> and I<primary_svc>
293
294 If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
295 values, the appropriate FS::pkg_svc records will be replace.
296
297 If I<primary_svc> is set to the svcpart of the primary service, the appropriate
298 FS::pkg_svc record will be updated.
299
300 =cut
301
302 sub replace {
303   my( $new, $old ) = ( shift, shift );
304   my %options = @_;
305   warn "FS::part_pkg::replace called on $new to replace $old ".
306        "with options %options"
307     if $DEBUG;
308
309   local $SIG{HUP} = 'IGNORE';
310   local $SIG{INT} = 'IGNORE';
311   local $SIG{QUIT} = 'IGNORE';
312   local $SIG{TERM} = 'IGNORE';
313   local $SIG{TSTP} = 'IGNORE';
314   local $SIG{PIPE} = 'IGNORE';
315
316   my $oldAutoCommit = $FS::UID::AutoCommit;
317   local $FS::UID::AutoCommit = 0;
318   my $dbh = dbh;
319
320   warn "  saving legacy plandata" if $DEBUG;
321   my $plandata = $new->get('plandata');
322   $new->set('plandata', '');
323
324   warn "  deleting old part_pkg_option records" if $DEBUG;
325   foreach my $part_pkg_option ( $old->part_pkg_option ) {
326     my $error = $part_pkg_option->delete;
327     if ( $error ) {
328       $dbh->rollback if $oldAutoCommit;
329       return $error;
330     }
331   }
332
333   warn "  replacing part_pkg record" if $DEBUG;
334   my $error = $new->SUPER::replace($old);
335   if ( $error ) {
336     $dbh->rollback if $oldAutoCommit;
337     return $error;
338   }
339
340   warn "  inserting part_pkg_option records for plandata" if $DEBUG;
341   foreach my $part_pkg_option ( 
342     map { /^(\w+)=(.*)$/ or do { $dbh->rollback if $oldAutoCommit;
343                                  return "illegal plandata: $plandata";
344                                };
345           new FS::part_pkg_option {
346             'pkgpart'     => $new->pkgpart,
347             'optionname'  => $1,
348             'optionvalue' => $2,
349           };
350         }
351     split("\n", $plandata)
352   ) {
353     my $error = $part_pkg_option->insert;
354     if ( $error ) {
355       $dbh->rollback if $oldAutoCommit;
356       return $error;
357     }
358   }
359
360   warn "  replacing pkg_svc records" if $DEBUG;
361   my $pkg_svc = $options{'pkg_svc'} || {};
362   foreach my $part_svc ( qsearch('part_svc', {} ) ) {
363     my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
364     my $primary_svc = $options{'primary_svc'} == $part_svc->svcpart ? 'Y' : '';
365
366     my $old_pkg_svc = qsearchs('pkg_svc', {
367       'pkgpart' => $old->pkgpart,
368       'svcpart' => $part_svc->svcpart,
369     } );
370     my $old_quantity = $old_pkg_svc ? $old_pkg_svc->quantity : 0;
371     my $old_primary_svc =
372       ( $old_pkg_svc && $old_pkg_svc->dbdef_table->column('primary_svc') )
373         ? $old_pkg_svc->primary_svc
374         : '';
375     next unless $old_quantity != $quantity || $old_primary_svc ne $primary_svc;
376   
377     my $new_pkg_svc = new FS::pkg_svc( {
378       'pkgpart'     => $new->pkgpart,
379       'svcpart'     => $part_svc->svcpart,
380       'quantity'    => $quantity, 
381       'primary_svc' => $primary_svc,
382     } );
383     my $error = $old_pkg_svc
384                   ? $new_pkg_svc->replace($old_pkg_svc)
385                   : $new_pkg_svc->insert;
386     if ( $error ) {
387       $dbh->rollback if $oldAutoCommit;
388       return $error;
389     }
390   }
391
392   warn "  commiting transaction" if $DEBUG;
393   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
394   '';
395 }
396
397 =item check
398
399 Checks all fields to make sure this is a valid package definition.  If
400 there is an error, returns the error, otherwise returns false.  Called by the
401 insert and replace methods.
402
403 =cut
404
405 sub check {
406   my $self = shift;
407   warn "FS::part_pkg::check called on $self" if $DEBUG;
408
409   for (qw(setup recur plandata)) {
410     #$self->set($_=>0) if $self->get($_) =~ /^\s*$/; }
411     return "Use of $_ field is deprecated; set a plan and options"
412       if length($self->get($_));
413     $self->set($_, '');
414   }
415
416   if ( $self->dbdef_table->column('freq')->type =~ /(int)/i ) {
417     my $error = $self->ut_number('freq');
418     return $error if $error;
419   } else {
420     $self->freq =~ /^(\d+[dw]?)$/
421       or return "Illegal or empty freq: ". $self->freq;
422     $self->freq($1);
423   }
424
425   my $error = $self->ut_numbern('pkgpart')
426     || $self->ut_text('pkg')
427     || $self->ut_text('comment')
428     || $self->ut_textn('promo_code')
429     || $self->ut_alphan('plan')
430     || $self->ut_enum('setuptax', [ '', 'Y' ] )
431     || $self->ut_enum('recurtax', [ '', 'Y' ] )
432     || $self->ut_textn('taxclass')
433     || $self->ut_enum('disabled', [ '', 'Y' ] )
434     || $self->SUPER::check
435   ;
436   return $error if $error;
437
438   return 'Unknown plan '. $self->plan
439     unless exists($plans{$self->plan});
440
441   '';
442 }
443
444 =item pkg_svc
445
446 Returns all FS::pkg_svc objects (see L<FS::pkg_svc>) for this package
447 definition (with non-zero quantity).
448
449 =cut
450
451 sub pkg_svc {
452   my $self = shift;
453   #sort { $b->primary cmp $a->primary } 
454     grep { $_->quantity }
455       qsearch( 'pkg_svc', { 'pkgpart' => $self->pkgpart } );
456 }
457
458 =item svcpart [ SVCDB ]
459
460 Returns the svcpart of the primary service definition (see L<FS::part_svc>)
461 associated with this package definition (see L<FS::pkg_svc>).  Returns
462 false if there not a primary service definition or exactly one service
463 definition with quantity 1, or if SVCDB is specified and does not match the
464 svcdb of the service definition, 
465
466 =cut
467
468 sub svcpart {
469   my $self = shift;
470   my $svcdb = scalar(@_) ? shift : '';
471   my @svcdb_pkg_svc =
472     grep { ( $svcdb eq $_->part_svc->svcdb || !$svcdb ) } $self->pkg_svc;
473   my @pkg_svc = ();
474   @pkg_svc = grep { $_->primary_svc =~ /^Y/i } @svcdb_pkg_svc
475     if dbdef->table('pkg_svc')->column('primary_svc');
476   @pkg_svc = grep {$_->quantity == 1 } @svcdb_pkg_svc
477     unless @pkg_svc;
478   return '' if scalar(@pkg_svc) != 1;
479   $pkg_svc[0]->svcpart;
480 }
481
482 =item payby
483
484 Returns a list of the acceptable payment types for this package.  Eventually
485 this should come out of a database table and be editable, but currently has the
486 following logic instead:
487
488 If the package is free, the single item B<BILL> is
489 returned, otherwise, the single item B<CARD> is returned.
490
491 (CHEK?  LEC?  Probably shouldn't accept those by default, prone to abuse)
492
493 =cut
494
495 sub payby {
496   my $self = shift;
497   if ( $self->is_free ) {
498     ( 'BILL' );
499   } else {
500     ( 'CARD' );
501   }
502 }
503
504 =item is_free
505
506 Returns true if this package is free.  
507
508 =cut
509
510 sub is_free {
511   my $self = shift;
512   unless ( $self->plan ) {
513     $self->setup =~ /^\s*0+(\.0*)?\s*$/
514       && $self->recur =~ /^\s*0+(\.0*)?\s*$/;
515   } elsif ( $self->can('is_free_options') ) {
516     not grep { $_ !~ /^\s*0*(\.0*)?\s*$/ }
517          map { $self->option($_) } 
518              $self->is_free_options;
519   } else {
520     warn "FS::part_pkg::is_free: FS::part_pkg::". $self->plan. " subclass ".
521          "provides neither is_free_options nor is_free method; returning false";
522     0;
523   }
524 }
525
526 =item freq_pretty
527
528 Returns an english representation of the I<freq> field, such as "monthly",
529 "weekly", "semi-annually", etc.
530
531 =cut
532
533 tie %freq, 'Tie::IxHash', 
534   '0'  => '(no recurring fee)',
535   '1d' => 'daily',
536   '1w' => 'weekly',
537   '2w' => 'biweekly (every 2 weeks)',
538   '1'  => 'monthly',
539   '2'  => 'bimonthly (every 2 months)',
540   '3'  => 'quarterly (every 3 months)',
541   '6'  => 'semiannually (every 6 months)',
542   '12' => 'annually',
543   '24' => 'biannually (every 2 years)',
544   '36' => 'triannually (every 3 years)',
545   '48' => '(every 4 years)',
546   '60' => '(every 5 years)',
547   '120' => '(every 10 years)',
548 ;
549
550 sub freq_pretty {
551   my $self = shift;
552   my $freq = $self->freq;
553   if ( exists($freq{$freq}) ) {
554     $freq{$freq};
555   } else {
556     my $interval = 'month';
557     if ( $freq =~ /^(\d+)([dw])$/ ) {
558       my %interval = ( 'd'=>'day', 'w'=>'week' );
559       $interval = $interval{$2};
560     }
561     if ( $1 == 1 ) {
562       "every $interval";
563     } else {
564       "every $freq ${interval}s";
565     }
566   }
567 }
568
569 =item plandata
570
571 For backwards compatibility, returns the plandata field as well as all options
572 from FS::part_pkg_option.
573
574 =cut
575
576 sub plandata {
577   my $self = shift;
578   carp "plandata is deprecated";
579   if ( @_ ) {
580     $self->SUPER::plandata(@_);
581   } else {
582     my $plandata = $self->get('plandata');
583     my %options = $self->options;
584     $plandata .= join('', map { "$_=$options{$_}\n" } keys %options );
585     $plandata;
586   }
587 }
588
589 =item part_pkg_option
590
591 Returns all options as FS::part_pkg_option objects (see
592 L<FS::part_pkg_option>).
593
594 =cut
595
596 sub part_pkg_option {
597   my $self = shift;
598   qsearch('part_pkg_option', { 'pkgpart' => $self->pkgpart } );
599 }
600
601 =item options 
602
603 Returns a list of option names and values suitable for assigning to a hash.
604
605 =cut
606
607 sub options {
608   my $self = shift;
609   map { $_->optionname => $_->optionvalue } $self->part_pkg_option;
610 }
611
612 =item option OPTIONNAME
613
614 Returns the option value for the given name, or the empty string.
615
616 =cut
617
618 sub option {
619   my( $self, $opt, $ornull ) = @_;
620   my $part_pkg_option =
621     qsearchs('part_pkg_option', {
622       pkgpart    => $self->pkgpart,
623       optionname => $opt,
624   } );
625   return $part_pkg_option->optionvalue if $part_pkg_option;
626   my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
627                      split("\n", $self->get('plandata') );
628   return $plandata{$opt} if exists $plandata{$opt};
629   cluck "Package definition option $opt not found in options or plandata!\n"
630     unless $ornull;
631   '';
632 }
633
634 =item _rebless
635
636 Reblesses the object into the FS::part_pkg::PLAN class (if available), where
637 PLAN is the object's I<plan> field.  There should be better docs
638 on how to create new price plans, but until then, see L</NEW PLAN CLASSES>.
639
640 =cut
641
642 sub _rebless {
643   my $self = shift;
644   my $plan = $self->plan;
645   my $class = ref($self). "::$plan";
646   eval "use $class;";
647   #die $@ if $@;
648   bless($self, $class) unless $@;
649   $self;
650 }
651
652 #fallbacks that eval the setup and recur fields, for backwards compat
653
654 sub calc_setup {
655   my $self = shift;
656   warn 'no price plan class for '. $self->plan. ", eval-ing setup\n";
657   $self->_calc_eval('setup', @_);
658 }
659
660 sub calc_recur {
661   my $self = shift;
662   warn 'no price plan class for '. $self->plan. ", eval-ing recur\n";
663   $self->_calc_eval('recur', @_);
664 }
665
666 use vars qw( $sdate @details );
667 sub _calc_eval {
668   #my( $self, $field, $cust_pkg ) = @_;
669   my( $self, $field, $cust_pkg, $sdateref, $detailsref ) = @_;
670   *sdate = $sdateref;
671   *details = $detailsref;
672   $self->$field() =~ /^(.*)$/
673     or die "Illegal $field (pkgpart ". $self->pkgpart. '): '.
674             $self->$field(). "\n";
675   my $prog = $1;
676   return 0 if $prog =~ /^\s*$/;
677   my $value = eval $prog;
678   die $@ if $@;
679   $value;
680 }
681
682 #fallback that return 0 for old legacy packages with no plan
683
684 sub calc_remain { 0; }
685 sub calc_cancel { 0; }
686
687 =back
688
689 =head1 SUBROUTINES
690
691 =over 4
692
693 =item plan_info
694
695 =cut
696
697 my %info;
698 foreach my $INC ( @INC ) {
699   foreach my $file ( glob("$INC/FS/part_pkg/*.pm") ) {
700     warn "attempting to load plan info from $file\n" if $DEBUG;
701     $file =~ /\/(\w+)\.pm$/ or do {
702       warn "unrecognized file in $INC/FS/part_pkg/: $file\n";
703       next;
704     };
705     my $mod = $1;
706     my $info = eval "use FS::part_pkg::$mod; ".
707                     "\\%FS::part_pkg::$mod\::info;";
708     if ( $@ ) {
709       die "error using FS::part_pkg::$mod (skipping): $@\n" if $@;
710       next;
711     }
712     unless ( keys %$info ) {
713       warn "no %info hash found in FS::part_pkg::$mod, skipping\n"
714         unless $mod =~ /^(passwdfile|null)$/; #hack but what the heck
715       next;
716     }
717     warn "got plan info from FS::part_pkg::$mod: $info\n" if $DEBUG;
718     if ( exists($info->{'disabled'}) && $info->{'disabled'} ) {
719       warn "skipping disabled plan FS::part_pkg::$mod" if $DEBUG;
720       next;
721     }
722     $info{$mod} = $info;
723   }
724 }
725
726 tie %plans, 'Tie::IxHash',
727   map { $_ => $info{$_} }
728   sort { $info{$a}->{'weight'} <=> $info{$b}->{'weight'} }
729   keys %info;
730
731 sub plan_info {
732   \%plans;
733 }
734
735 =back
736
737 =head1 NEW PLAN CLASSES
738
739 A module should be added in FS/FS/part_pkg/ (an example may be found in
740 eg/plan_template.pm)
741
742 =head1 BUGS
743
744 The delete method is unimplemented.
745
746 setup and recur semantics are not yet defined (and are implemented in
747 FS::cust_bill.  hmm.).
748
749 =head1 SEE ALSO
750
751 L<FS::Record>, L<FS::cust_pkg>, L<FS::type_pkgs>, L<FS::pkg_svc>, L<Safe>.
752 schema.html from the base documentation.
753
754 =cut
755
756 1;
757