X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=a37abe2397a93084784dd6a75bf154f37998430c;hb=64852c30f3025d1aafa3c9d5c81f6b20dddd1a36;hp=eca3af4889e388efa867c46bf6f828008d9f7356;hpb=51d699639c09bdb34513fb49f4a3769893802640;p=freeside.git diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index eca3af488..a37abe239 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -552,7 +552,7 @@ sub cancel { my $error = send_email( 'from' => $conf->config('invoice_from'), 'to' => \@invoicing_list, - 'subject' => $conf->config('cancelsubject'), + 'subject' => ( $conf->config('cancelsubject') || 'Cancellation Notice' ), 'body' => [ map "$_\n", $conf->config('cancelmessage') ], ); #should this do something on errors? @@ -793,6 +793,18 @@ sub part_pkg { : qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } ); } +=item old_cust_pkg + +Returns the cancelled package this package was changed from, if any. + +=cut + +sub old_cust_pkg { + my $self = shift; + return '' unless $self->change_pkgnum; + qsearchs('cust_pkg', { 'pkgnum' => $self->change_pkgnum } ); +} + =item calc_setup Calls the I of the FS::part_pkg object associated with this billing @@ -1591,9 +1603,17 @@ sub order { my $change = scalar(@old_cust_pkg) != 0; my %hash = (); - if ( scalar(@old_cust_pkg) == 1 ) { + if ( scalar(@old_cust_pkg) == 1 && scalar(@$pkgparts) == 1 ) { + + my $time = time; + #$hash{$_} = $old_cust_pkg[0]->$_() foreach qw( last_bill bill ); - $hash{'setup'} = time; + + #$hash{$_} = $old_cust_pkg[0]->$_() foreach qw( setup ); + $hash{'setup'} = $time if $old_cust_pkg[0]->setup; + + $hash{'change_date'} = $time; + $hash{"change_$_"} = $old_cust_pkg[0]->$_() foreach qw( pkgnum pkgpart ); } # Create the new packages. @@ -1734,6 +1754,26 @@ sub set_usage { } } +=item recharge USAGE_VALUE_HASHREF + +USAGE_VALUE_HASHREF is a hashref of svc_acct usage columns and the amounts +to which they should be set (see L). Currently seconds, +upbytes, downbytes, and totalbytes are appropriate keys. + +All svc_accts which are part of this package have their values incremented. + +=cut + +sub recharge { + my ($self, $valueref) = @_; + + foreach my $cust_svc ($self->cust_svc){ + my $svc_x = $cust_svc->svc_x; + $svc_x->recharge($valueref) + if $svc_x->can("recharge"); + } +} + =back =head1 BUGS