From: ivan Date: Wed, 26 Jun 2002 08:12:52 +0000 (+0000) Subject: add type_pkgs record if necessary for one-time charges X-Git-Tag: freeside_1_4_0_beta1~55 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=4329b50ca24073d39e16ce808ee49286309150e9;ds=sidebyside add type_pkgs record if necessary for one-time charges --- diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index b68bf9e8f..efe94027d 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -27,6 +27,7 @@ use FS::part_pkg; use FS::part_bill_event; use FS::cust_bill_event; use FS::cust_tax_exempt; +use FS::type_pkgs; use FS::Msgcat qw(gettext); @ISA = qw( FS::Record ); @@ -1769,9 +1770,20 @@ sub charge { return $error; } + my $pkgpart = $part_pkg->pkgpart; + my %type_pkgs = ( 'typenum' => $self->agent->typenum, 'pkgpart' => $pkgpart ); + unless ( qsearchs('type_pkgs', \%type_pkgs ) ) { + my $type_pkgs = new FS::type_pkgs \%type_pkgs; + $error = $type_pkgs->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + my $cust_pkg = new FS::cust_pkg ( { 'custnum' => $self->custnum, - 'pkgpart' => $part_pkg->pkgpart, + 'pkgpart' => $pkgpart, } ); $error = $cust_pkg->insert;