X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=6c985cf197a35df3948a7e7ab108b3924c5ee52d;hb=ee953407088b8f71cf671aeb88fa6f227a4f109c;hp=09b46292e06f8f1fc867e282453d74fbb7796d50;hpb=07578e9926188648e7f26fca5cd9e99b5dc2db16;p=freeside.git diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 09b46292e..6c985cf19 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -194,6 +194,8 @@ Previous pkgpart Previous locationnum +=item waive_setup + =back Note: setup, last_bill, bill, adjourn, susp, expire, cancel and change_date @@ -594,9 +596,14 @@ sub check { || $self->ut_numbern('adjourn') || $self->ut_numbern('expire') || $self->ut_enum('no_auto', [ '', 'Y' ]) + || $self->ut_enum('waive_setup', [ '', 'Y' ]) + || $self->ut_numbern('agent_pkgid') ; return $error if $error; + return "A package with both start date (future start) and setup date (already started) will never bill" + if $self->start_date && $self->setup; + $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum; if ( $self->dbdef_table->column('manual_flag') ) { @@ -757,6 +764,8 @@ sub cancel { map { [ $_, $_->svc_x->table_info->{'cancel_weight'} ]; } qsearch( 'cust_svc', { 'pkgnum' => $self->pkgnum } ) ) { + my $part_svc = $cust_svc->part_svc; + next if ( defined($part_svc) and $part_svc->preserve ); my $error = $cust_svc->cancel( %svc_cancel_opt ); if ( $error ) { @@ -1770,7 +1779,7 @@ I flag will be omitted. sub h_cust_svc { my $self = shift; warn "$me _h_cust_svc called on $self\n" - if $DEBUG > 1; + if $DEBUG; my ($end, $start, $mode) = @_; my @cust_svc = $self->_sort_cust_svc( @@ -2125,7 +2134,7 @@ Returns a list of lists, calling the label method for all (historical) services sub h_labels { my $self = shift; warn "$me _h_labels called on $self\n" - if $DEBUG > 1; + if $DEBUG; map { [ $_->label(@_) ] } $self->h_cust_svc(@_); } @@ -2159,13 +2168,13 @@ sub _labels_short { my( $self, $method ) = ( shift, shift ); warn "$me _labels_short called on $self with $method method\n" - if $DEBUG > 1; + if $DEBUG; my $conf = new FS::Conf; my $max_same_services = $conf->config('cust_bill-max_same_services') || 5; warn "$me _labels_short populating \%labels\n" - if $DEBUG > 1; + if $DEBUG; my %labels; #tie %labels, 'Tie::IxHash'; @@ -2173,26 +2182,38 @@ sub _labels_short { foreach $self->$method(@_); warn "$me _labels_short populating \@labels\n" - if $DEBUG > 1; + if $DEBUG; my @labels; foreach my $label ( keys %labels ) { my %seen = (); my @values = grep { ! $seen{$_}++ } @{ $labels{$label} }; my $num = scalar(@values); + warn "$me _labels_short $num items for $label\n" + if $DEBUG; + if ( $num > $max_same_services ) { + warn "$me _labels_short more than $max_same_services, so summarizing\n" + if $DEBUG; push @labels, "$label ($num)"; } else { if ( $conf->exists('cust_bill-consolidate_services') ) { + warn "$me _labels_short consolidating services\n" + if $DEBUG; # push @labels, "$label: ". join(', ', @values); while ( @values ) { my $detail = "$label: "; $detail .= shift(@values). ', ' - while @values && length($detail.$values[0]) < 78; + while @values + && ( length($detail.$values[0]) < 78 || $detail eq "$label: " ); $detail =~ s/, $//; push @labels, $detail; } + warn "$me _labels_short done consolidating services\n" + if $DEBUG; } else { + warn "$me _labels_short adding service data\n" + if $DEBUG; push @labels, map { "$label: $_" } @values; } }