local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
+ if ( length($self->classnum) && $self->classnum !~ /^(\d+)$/ ) {
+ my $pkg_class = qsearchs('pkg_class', { 'classname' => $self->classnum } )
+ || new FS::pkg_class { classname => $self->classnum };
+ unless ( $pkg_class->classnum ) {
+ my $error = $pkg_class->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+ $self->classnum( $pkg_class->classnum );
+ }
+
warn " inserting part_pkg record" if $DEBUG;
my $error = $self->SUPER::insert( $options{options} );
if ( $error ) {
=item check_options
-For a passed I<$options> hashref, validates any options that
-have 'validate' subroutines defined in the info hash,
-then validates the entire hashref if the price plan has
-its own 'validate' subroutine defined in the info hash
-(I<$options> values might be altered.)
+Pass an I<$options> hashref that contains the values to be
+inserted or updated for any FS::part_pkg::MODULE.pm.
+
+For each key in I<$options>, validates the value by calling
+the 'validate' subroutine defined for that option e.g.
+FS::part_pkg::MODULE::plan_info()->{$KEY}->{validate}. The
+option validation function is only called when the hashkey for
+that option exists in I<$options>.
+
+Then the module validation function is called, from
+FS::part_pkg::MODULE::plan_info()->{validate}
Returns error message, or empty string if valid.
=cut
1;
-