[freeside-commits] freeside/FS/FS Schema.pm, 1.239.2.4, 1.239.2.5 cust_bill.pm, 1.299, 1.299.2.1 cust_pkg.pm, 1.179, 1.179.2.1 part_pkg.pm, 1.111, 1.111.2.1 pkg_svc.pm, 1.7, 1.7.10.1

Mark Wells mark at wavetail.420.am
Sat Nov 13 15:24:05 PST 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv6603/FS/FS

Modified Files:
      Tag: FREESIDE_2_1_BRANCH
	Schema.pm cust_bill.pm cust_pkg.pm part_pkg.pm pkg_svc.pm 
Log Message:
hidden pkg_svc flag, RT#9871

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.239.2.4
retrieving revision 1.239.2.5
diff -u -w -d -r1.239.2.4 -r1.239.2.5
--- Schema.pm	12 Nov 2010 01:17:24 -0000	1.239.2.4
+++ Schema.pm	13 Nov 2010 23:24:03 -0000	1.239.2.5
@@ -1601,6 +1601,7 @@
         'svcpart',    'int',    '',   '', '', '', 
         'quantity',   'int',    '',   '', '', '', 
         'primary_svc','char', 'NULL',  1, '', '', 
+        'hidden',     'char', 'NULL',  1, '', '',
       ],
       'primary_key' => 'pkgsvcnum',
       'unique' => [ ['pkgpart', 'svcpart'] ],

Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.299
retrieving revision 1.299.2.1
diff -u -w -d -r1.299 -r1.299.2.1
--- cust_bill.pm	4 Nov 2010 23:07:18 -0000	1.299
+++ cust_bill.pm	13 Nov 2010 23:24:03 -0000	1.299.2.1
@@ -4102,7 +4102,7 @@
           {
 
             push @d, map &{$escape_function}($_),
-                         $cust_pkg->h_labels_short($self->_date)
+                         $cust_pkg->h_labels_short($self->_date, undef, 'I')
               unless $cust_bill_pkg->pkgpart_override; #don't redisplay services
 
             if ( $multilocation ) {
@@ -4164,7 +4164,7 @@
           {
 
             push @d, map &{$escape_function}($_),
-                         $cust_pkg->h_labels_short(@dates)
+                         $cust_pkg->h_labels_short(@dates, 'I')
                                                    #$cust_bill_pkg->edate,
                                                    #$cust_bill_pkg->sdate)
               unless $cust_bill_pkg->pkgpart_override; #don't redisplay services

Index: part_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg.pm,v
retrieving revision 1.111
retrieving revision 1.111.2.1
diff -u -w -d -r1.111 -r1.111.2.1
--- part_pkg.pm	12 Oct 2010 20:58:02 -0000	1.111
+++ part_pkg.pm	13 Nov 2010 23:24:03 -0000	1.111.2.1
@@ -144,7 +144,9 @@
 I<custnum_ref> and I<options>.
 
 If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
-values, appropriate FS::pkg_svc records will be inserted.
+values, appropriate FS::pkg_svc records will be inserted.  I<hidden_svc> can 
+be set to a hashref of svcparts and flag values ('Y' or '') to set the 
+'hidden' field in these records.
 
 If I<primary_svc> is set to the svcpart of the primary service, the appropriate
 FS::pkg_svc record will be updated.
@@ -230,6 +232,7 @@
 
     warn "  inserting pkg_svc records" if $DEBUG;
     my $pkg_svc = $options{'pkg_svc'} || {};
+    my $hidden_svc = $options{'hidden_svc'} || {};
     foreach my $part_svc ( qsearch('part_svc', {} ) ) {
       my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
       my $primary_svc =
@@ -242,6 +245,7 @@
         'svcpart'     => $part_svc->svcpart,
         'quantity'    => $quantity, 
         'primary_svc' => $primary_svc,
+        'hidden'      => $hidden_svc->{$part_svc->svcpart},
       } );
       my $error = $pkg_svc->insert;
       if ( $error ) {
@@ -293,10 +297,13 @@
 Replaces OLD_RECORD with this one in the database.  If there is an error,
 returns the error, otherwise returns false.
 
-Currently available options are: I<pkg_svc>, I<primary_svc> and I<options>
+Currently available options are: I<pkg_svc>, I<hidden_svc>, I<primary_svc> 
+and I<options>
 
 If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
-values, the appropriate FS::pkg_svc records will be replaced.
+values, the appropriate FS::pkg_svc records will be replaced.  I<hidden_svc>
+can be set to a hashref of svcparts and flag values ('Y' or '') to set the 
+'hidden' field in these records.
 
 If I<primary_svc> is set to the svcpart of the primary service, the appropriate
 FS::pkg_svc record will be updated.
@@ -379,8 +386,10 @@
 
   warn "  replacing pkg_svc records" if $DEBUG;
   my $pkg_svc = $options->{'pkg_svc'} || {};
+  my $hidden_svc = $options->{'hidden_svc'} || {};
   foreach my $part_svc ( qsearch('part_svc', {} ) ) {
     my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
+    my $hidden = $hidden_svc->{$part_svc->svcpart} || '';
     my $primary_svc =
       ( defined($options->{'primary_svc'}) && $options->{'primary_svc'}
         && $options->{'primary_svc'} == $part_svc->svcpart
@@ -388,17 +397,24 @@
         ? 'Y'
         : '';
 
-
     my $old_pkg_svc = qsearchs('pkg_svc', {
       'pkgpart' => $old->pkgpart,
       'svcpart' => $part_svc->svcpart,
-    } );
-    my $old_quantity = $old_pkg_svc ? $old_pkg_svc->quantity : 0;
-    my $old_primary_svc =
-      ( $old_pkg_svc && $old_pkg_svc->dbdef_table->column('primary_svc') )
-        ? $old_pkg_svc->primary_svc
-        : '';
-    next unless $old_quantity != $quantity || $old_primary_svc ne $primary_svc;
+      }
+    );
+    my $old_quantity = 0;
+    my $old_primary_svc = '';
+    my $old_hidden = '';
+    if ( $old_pkg_svc ) {
+      $old_quantity = $old_pkg_svc->quantity;
+      $old_primary_svc = $old_pkg_svc->primary_svc 
+        if $old_pkg_svc->dbdef_table->column('primary_svc'); # is this needed?
+      $old_hidden = $old_pkg_svc->hidden;
+    }
+ 
+    next unless $old_quantity != $quantity || 
+                $old_primary_svc ne $primary_svc ||
+                $old_hidden ne $hidden;
   
     my $new_pkg_svc = new FS::pkg_svc( {
       'pkgsvcnum'   => ( $old_pkg_svc ? $old_pkg_svc->pkgsvcnum : '' ),
@@ -406,6 +422,7 @@
       'svcpart'     => $part_svc->svcpart,
       'quantity'    => $quantity, 
       'primary_svc' => $primary_svc,
+      'hidden'      => $hidden,
     } );
     my $error = $old_pkg_svc
                   ? $new_pkg_svc->replace($old_pkg_svc)

Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.179
retrieving revision 1.179.2.1
diff -u -w -d -r1.179 -r1.179.2.1
--- cust_pkg.pm	3 Nov 2010 19:51:14 -0000	1.179
+++ cust_pkg.pm	13 Nov 2010 23:24:03 -0000	1.179.2.1
@@ -1638,23 +1638,32 @@
   grep { $_->overlimit } $self->cust_svc(@_);
 }
 
-=item h_cust_svc END_TIMESTAMP [ START_TIMESTAMP ] 
+=item h_cust_svc END_TIMESTAMP [ START_TIMESTAMP ] [ MODE ]
 
 Returns historical services for this package created before END TIMESTAMP and
 (optionally) not cancelled before START_TIMESTAMP, as FS::h_cust_svc objects
-(see L<FS::h_cust_svc>).
+(see L<FS::h_cust_svc>).  If MODE is 'I' (for 'invoice'), services with the 
+I<pkg_svc.hidden> flag will be omitted.
 
 =cut
 
 sub h_cust_svc {
   my $self = shift;
+  my ($end, $start, $mode) = @_;
+  my %search = (
+    'table'   => 'h_cust_svc',
+    'hashref' => { 'pkgnum' => $self->pkgnum }
+  );
+  @search{'select', 'extra_sql', 'cache_obj', 'addl_from'} = 
+    FS::h_cust_svc->sql_h_search($end, $start);
+  if ( $mode eq 'I' ) {
+    $search{'addl_from'} .= ' JOIN cust_pkg USING (pkgnum)
+    JOIN pkg_svc USING (pkgpart, svcpart)';
+    $search{'extra_sql'} = ' AND pkg_svc.hidden IS NULL '.$search{'extra_sql'};
+  }
 
   $self->_sort_cust_svc(
-    [ qsearch( 'h_cust_svc',
-               { 'pkgnum' => $self->pkgnum, },
-               FS::h_cust_svc->sql_h_search(@_),
-             )
-    ]
+    [ qsearch(\%search) ]
   );
 }
 
@@ -1973,11 +1982,12 @@
   map { [ $_->label ] } $self->cust_svc;
 }
 
-=item h_labels END_TIMESTAMP [ START_TIMESTAMP ] 
+=item h_labels END_TIMESTAMP [ START_TIMESTAMP ] [ MODE ]
 
 Like the labels method, but returns historical information on services that
 were active as of END_TIMESTAMP and (optionally) not cancelled before
-START_TIMESTAMP.
+START_TIMESTAMP.  If MODE is 'I' (for 'invoice'), services with the 
+I<pkg_svc.hidden> flag will be omitted.
 
 Returns a list of lists, calling the label method for all (historical) services
 (see L<FS::h_cust_svc>) of this billing item.

Index: pkg_svc.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/pkg_svc.pm,v
retrieving revision 1.7
retrieving revision 1.7.10.1
diff -u -w -d -r1.7 -r1.7.10.1
--- pkg_svc.pm	29 Dec 2006 08:51:32 -0000	1.7
+++ pkg_svc.pm	13 Nov 2010 23:24:03 -0000	1.7.10.1
@@ -50,6 +50,8 @@
 
 =item primary_svc - primary flag, empty or 'Y'
 
+=item hidden - 'Y' to hide this service on invoices, null otherwise.
+
 =back
 
 =head1 METHODS
@@ -109,6 +111,7 @@
     || $self->ut_number('pkgpart')
     || $self->ut_number('svcpart')
     || $self->ut_number('quantity')
+    || $self->ut_enum('hidden', [ '', 'Y' ] )
   ;
   return $error if $error;
 



More information about the freeside-commits mailing list