[freeside-commits] branch FREESIDE_4_BRANCH updated. 81e69f7d093e9df23e814e15ed35b6c6e6545ae7

Ivan Kohler ivan at freeside.biz
Mon Feb 12 21:04:07 PST 2018


The branch, FREESIDE_4_BRANCH has been updated
       via  81e69f7d093e9df23e814e15ed35b6c6e6545ae7 (commit)
      from  00f058e191f1c2450fad45eecf31fb7b17fc4e76 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 81e69f7d093e9df23e814e15ed35b6c6e6545ae7
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Feb 12 21:04:05 2018 -0800

    auto-create package class from string name on import, RT#79383

diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index bb8c6bc6c..4492c4023 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -232,6 +232,19 @@ sub insert {
   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 ) {

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/part_pkg.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)




More information about the freeside-commits mailing list