[freeside-commits] freeside/FS/FS cust_bill.pm, 1.263.2.2, 1.263.2.3 cust_main.pm, 1.464.2.5, 1.464.2.6

Ivan,,, ivan at wavetail.420.am
Sun Nov 15 19:55:29 PST 2009


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

Modified Files:
      Tag: FREESIDE_1_9_BRANCH
	cust_bill.pm cust_main.pm 
Log Message:
add ability to search on ranges of charged, owed to adv. invoice report, RT#6407

Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.263.2.2
retrieving revision 1.263.2.3
diff -u -d -r1.263.2.2 -r1.263.2.3
--- cust_bill.pm	31 Oct 2009 21:22:48 -0000	1.263.2.2
+++ cust_bill.pm	16 Nov 2009 03:55:26 -0000	1.263.2.3
@@ -35,7 +35,7 @@
 
 @ISA = qw( FS::cust_main_Mixin FS::Record );
 
-$DEBUG = 0;
+$DEBUG = 1;
 $me = '[FS::cust_bill]';
 
 #ask FS::UID to run this stuff for us later
@@ -3741,13 +3741,9 @@
 
 =over 4
 
-=item begin
-
-Epoch date (UNIX timestamp) setting a lower bound for _date values
-
-=item end
+=item _date
 
-Epoch date (UNIX timestamp) setting an upper bound for _date values
+List reference of start date, end date, as UNIX timestamps.
 
 =item invnum_min
 
@@ -3755,10 +3751,22 @@
 
 =item agentnum
 
+=item charged
+
+List reference of charged limits (exclusive).
+
 =item owed
 
+List reference of charged limits (exclusive).
+
+=item open
+
+flag, return open invoices only
+
 =item net
 
+flag, return net invoices only
+
 =item days
 
 =item newest_percust
@@ -3778,31 +3786,59 @@
 
   my @search = ();
 
-  if ( $param->{'begin'} =~ /^(\d+)$/ ) {
-    push @search, "cust_bill._date >= $1";
+  #agentnum
+  if ( $param->{'agentnum'} =~ /^(\d+)$/ ) {
+    push @search, "cust_main.agentnum = $1";
   }
-  if ( $param->{'end'} =~ /^(\d+)$/ ) {
-    push @search, "cust_bill._date < $1";
+
+  #_date
+  if ( $param->{_date} ) {
+    my($beginning, $ending) = @{$param->{_date}};
+
+    push @search, "cust_bill._date >= $beginning",
+                  "cust_bill._date <  $ending";
   }
+
+  #invnum
   if ( $param->{'invnum_min'} =~ /^(\d+)$/ ) {
     push @search, "cust_bill.invnum >= $1";
   }
   if ( $param->{'invnum_max'} =~ /^(\d+)$/ ) {
     push @search, "cust_bill.invnum <= $1";
   }
-  if ( $param->{'agentnum'} =~ /^(\d+)$/ ) {
-    push @search, "cust_main.agentnum = $1";
+
+  #charged
+  if ( $param->{charged} ) {
+    my @charged = ref($param->{charged})
+                    ? @{ $param->{charged} }
+                    : ($param->{charged});
+
+    push @search, map { s/^charged/cust_bill.charged/; $_; }
+                      @charged;
   }
 
-  push @search, '0 != '. FS::cust_bill->owed_sql
-    if $param->{'open'};
+  my $owed_sql = FS::cust_bill->owed_sql;
 
+  #owed
+  if ( $param->{owed} ) {
+    my @owed = ref($param->{owed})
+                 ? @{ $param->{owed} }
+                 : ($param->{owed});
+    push @search, map { s/^owed/$owed_sql/; $_; }
+                      @owed;
+  }
+
+  #open/net flags
+  push @search, "0 != $owed_sql"
+    if $param->{'open'};
   push @search, '0 != '. FS::cust_bill->net_sql
     if $param->{'net'};
 
+  #days
   push @search, "cust_bill._date < ". (time-86400*$param->{'days'})
     if $param->{'days'};
 
+  #newest_percust
   if ( $param->{'newest_percust'} ) {
 
     #$distinct = 'DISTINCT ON ( cust_bill.custnum )';
@@ -3826,6 +3862,7 @@
 
   }
 
+  #agent virtualization
   my $curuser = $FS::CurrentUser::CurrentUser;
   if ( $curuser->username eq 'fs_queue'
        && $param->{'CurrentUser'} =~ /^(\w+)$/ ) {
@@ -3840,7 +3877,6 @@
       warn "$me WARNING: (fs_queue) can't find CurrentUser $username\n";
     }
   }
-
   push @search, $curuser->agentnums_sql;
 
   join(' AND ', @search );

Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.464.2.5
retrieving revision 1.464.2.6
diff -u -d -r1.464.2.5 -r1.464.2.6
--- cust_main.pm	14 Nov 2009 00:08:20 -0000	1.464.2.5
+++ cust_main.pm	16 Nov 2009 03:55:26 -0000	1.464.2.6
@@ -8302,8 +8302,10 @@
   #my $balance_sql = $class->balance_sql();
   my $balance_sql = FS::cust_main->balance_sql();
 
+  my @current_balance = @{ $params->{'current_balance'} };
+
   push @where, map { s/current_balance/$balance_sql/; $_ }
-                   @{ $params->{'current_balance'} };
+                   @current_balance;
 
   ##
   # custbatch



More information about the freeside-commits mailing list