From: Rob Van Dam Date: Thu, 7 Nov 2013 22:27:24 +0000 (-0700) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=df1ebf662a9fc3f89503036e0dbf6833c1b95f9e;hp=a180208786cccb72ab017e39fff0cb128aa6ba01 Merge remote-tracking branch 'upstream/master' Conflicts: FS/FS/cust_pkg.pm --- diff --git a/FS/FS/cust_main/Packages.pm b/FS/FS/cust_main/Packages.pm index 152c496d1..f819970fd 100644 --- a/FS/FS/cust_main/Packages.pm +++ b/FS/FS/cust_main/Packages.pm @@ -1,7 +1,6 @@ package FS::cust_main::Packages; use strict; -use vars qw( $DEBUG $me ); use List::Util qw( min ); use FS::UID qw( dbh ); use FS::Record qw( qsearch qsearchs ); @@ -10,8 +9,7 @@ use FS::cust_svc; use FS::contact; # for attach_pkgs use FS::cust_location; # -$DEBUG = 0; -$me = '[FS::cust_main::Packages]'; +our ($DEBUG, $me) = (0, '[FS::cust_main::Packages]'); =head1 NAME @@ -228,7 +226,7 @@ Services can be new, in which case they are inserted, or existing unaudited services, in which case they are linked to the newly-created package. Currently available options are: I, I, I, -I, I, and I. +I, I, I, and I. If I is set, all provisioning jobs will have a dependancy on the supplied jobnum (they will not run until the specific job completes). @@ -245,6 +243,8 @@ If I, I, I, or I is provided, the scalars (provided by references) will be incremented by the values of the prepaid card.` +I is passed to L->insert. + =cut sub order_pkgs { @@ -277,7 +277,7 @@ sub order_pkgs { 'cust_pkg' => $cust_pkg, 'svcs' => $cust_pkgs->{$cust_pkg}, map { $_ => $options{$_} } - qw( seconds_ref upbytes_ref downbytes_ref totalbytes_ref depend_jobnum ) + qw( seconds_ref upbytes_ref downbytes_ref totalbytes_ref depend_jobnum allow_pkgpart ) ); if ( $error ) { $dbh->rollback if $oldAutoCommit; diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 771d3ec75..5abdbe2ee 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -4,7 +4,6 @@ use base qw( FS::otaker_Mixin FS::cust_main_Mixin FS::Sales_Mixin FS::m2m_Common FS::option_Common ); use strict; -use vars qw( $disable_agentcheck $DEBUG $me $upgrade ); use Carp qw(cluck); use Scalar::Util qw( blessed ); use List::Util qw(min max); @@ -49,12 +48,9 @@ use FS::svc_forward; # for sending cancel emails in sub cancel use FS::Conf; -$DEBUG = 0; -$me = '[FS::cust_pkg]'; +our ($disable_agentcheck, $DEBUG, $me, $import) = (0, 0, '[FS::cust_pkg]', 0); -$disable_agentcheck = 0; - -$upgrade = 0; #go away after setup+start dates cleaned up for old customers +our $upgrade = 0; #go away after setup+start dates cleaned up for old customers sub _cache { my $self = shift; @@ -298,37 +294,40 @@ sub insert { my $part_pkg = $self->part_pkg; - # if the package def says to start only on the first of the month: - if ( $part_pkg->option('start_1st', 1) && !$self->start_date ) { - my ($sec,$min,$hour,$mday,$mon,$year) = (localtime(time) )[0,1,2,3,4,5]; - $mon += 1 unless $mday == 1; - until ( $mon < 12 ) { $mon -= 12; $year++; } - $self->start_date( timelocal_nocheck(0,0,0,1,$mon,$year) ); - } - - # set up any automatic expire/adjourn/contract_end timers - # based on the start date - foreach my $action ( qw(expire adjourn contract_end) ) { - my $months = $part_pkg->option("${action}_months",1); - if($months and !$self->$action) { - my $start = $self->start_date || $self->setup || time; - $self->$action( $part_pkg->add_freq($start, $months) ); + if (! $import) { + # if the package def says to start only on the first of the month: + if ( $part_pkg->option('start_1st', 1) && !$self->start_date ) { + my ($sec,$min,$hour,$mday,$mon,$year) = (localtime(time) )[0,1,2,3,4,5]; + $mon += 1 unless $mday == 1; + until ( $mon < 12 ) { $mon -= 12; $year++; } + $self->start_date( timelocal_nocheck(0,0,0,1,$mon,$year) ); } - } - # if this package has "free days" and delayed setup fee, tehn - # set start date that many days in the future. - # (this should have been set in the UI, but enforce it here) - if ( ! $options{'change'} - && ( my $free_days = $part_pkg->option('free_days',1) ) - && $part_pkg->option('delay_setup',1) - #&& ! $self->start_date - ) - { - $self->start_date( $part_pkg->default_start_date ); + # set up any automatic expire/adjourn/contract_end timers + # based on the start date + foreach my $action ( qw(expire adjourn contract_end) ) { + my $months = $part_pkg->option("${action}_months",1); + if($months and !$self->$action) { + my $start = $self->start_date || $self->setup || time; + $self->$action( $part_pkg->add_freq($start, $months) ); + } + } + + # if this package has "free days" and delayed setup fee, tehn + # set start date that many days in the future. + # (this should have been set in the UI, but enforce it here) + if ( ! $options{'change'} + && ( my $free_days = $part_pkg->option('free_days',1) ) + && $part_pkg->option('delay_setup',1) + #&& ! $self->start_date + ) + { + $self->start_date( $part_pkg->default_start_date ); + } } - $self->order_date(time); + # set order date unless it was specified as part of an import + $self->order_date(time) unless $import && $self->order_date; local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; @@ -364,7 +363,7 @@ sub insert { my $conf = new FS::Conf; - if ( $conf->config('ticket_system') && $options{ticket_subject} ) { + if ( ! $import && $conf->config('ticket_system') && $options{ticket_subject} ) { #this init stuff is still inefficient, but at least its limited to # the small number (any?) folks using ticket emailing on pkg order @@ -394,7 +393,7 @@ sub insert { ); } - if ($conf->config('welcome_letter') && $self->cust_main->num_pkgs == 1) { + if (! $import && $conf->config('welcome_letter') && $self->cust_main->num_pkgs == 1) { my $queue = new FS::queue { 'job' => 'FS::cust_main::queueable_print', };