[freeside-commits] freeside/FS/FS Conf.pm, 1.304, 1.305 Schema.pm, 1.158, 1.159 cust_bill.pm, 1.248, 1.249 cust_main.pm, 1.445, 1.446

Jeff Finucane,420,, jeff at wavetail.420.am
Tue Jul 28 15:21:41 PDT 2009


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

Modified Files:
	Conf.pm Schema.pm cust_bill.pm cust_main.pm 
Log Message:
feature to email CSV of CDRs with invoices #5727

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -d -r1.158 -r1.159
--- Schema.pm	21 Jul 2009 18:44:56 -0000	1.158
+++ Schema.pm	28 Jul 2009 22:21:39 -0000	1.159
@@ -698,6 +698,7 @@
         'cdr_termination_percentage', 'decimal', 'NULL', '', '', '',
         'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
         'archived', 'char', 'NULL', 1, '', '',
+        'email_csv_cdr', 'char', 'NULL', 1, '', '',
       ],
       'primary_key' => 'custnum',
       'unique' => [ [ 'agentnum', 'agent_custid' ] ],

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.304
retrieving revision 1.305
diff -u -d -r1.304 -r1.305
--- Conf.pm	28 Jul 2009 21:17:44 -0000	1.304
+++ Conf.pm	28 Jul 2009 22:21:39 -0000	1.305
@@ -2169,6 +2169,13 @@
   },
 
   {
+    'key'         => 'voip-cust_email_csv_cdr',
+    'section'     => '',
+    'description' => 'Enable the per-customer option for including CDR information as a CSV attachment on emailed invoices.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'svc_forward-arbitrary_dst',
     'section'     => '',
     'description' => "Allow forwards to point to arbitrary strings that don't necessarily look like email addresses.  Only used when using forwards for weird, non-email things.",

Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.248
retrieving revision 1.249
diff -u -d -r1.248 -r1.249
--- cust_bill.pm	20 Jul 2009 23:01:12 -0000	1.248
+++ cust_bill.pm	28 Jul 2009 22:21:39 -0000	1.249
@@ -704,6 +704,18 @@
       #'Filename'    => 'invoice.pdf',
     );
 
+    my @otherparts = ();
+    if ( $self->cust_main->email_csv_cdr ) {
+
+      push @otherparts, build MIME::Entity
+        'Type'        => 'text/csv',
+        'Encoding'    => '7bit',
+        'Data'        => [ map { "$_\n" } $self->call_details ],
+        'Disposition' => 'attachment',
+      ;
+
+    }
+
     if ( $conf->exists('invoice_email_pdf') ) {
 
       #attaching pdf too:
@@ -731,7 +743,7 @@
 
       my $pdf = build MIME::Entity $self->mimebuild_pdf('', $args{'template'}, %cdrs);
 
-      $return{'mimeparts'} = [ $related, $pdf ];
+      $return{'mimeparts'} = [ $related, $pdf, @otherparts ];
 
     } else {
 
@@ -743,7 +755,7 @@
       #   image/png
 
       $return{'content-type'} = 'multipart/related';
-      $return{'mimeparts'} = [ $alternative, $image ];
+      $return{'mimeparts'} = [ $alternative, $image, @otherparts ];
       $return{'type'} = 'multipart/alternative'; #Content-Type of first part...
       #$return{'disposition'} = 'inline';
 
@@ -3033,6 +3045,22 @@
 
 }
 
+=item call_details
+
+Returns an array of CSV strings representing the call details for this invoice
+
+=cut
+
+sub call_details {
+  my $self = shift;
+  map { $_->details( 'format_function' => sub{ shift },
+                     'escape_function' => sub{ return() },
+                   )
+      }
+    grep { $_->pkgnum }
+    $self->cust_bill_pkg;
+}
+
 
 =back
 

Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.445
retrieving revision 1.446
diff -u -d -r1.445 -r1.446
--- cust_main.pm	27 Jul 2009 03:26:46 -0000	1.445
+++ cust_main.pm	28 Jul 2009 22:21:39 -0000	1.446
@@ -1869,7 +1869,7 @@
     $self->payname($1);
   }
 
-  foreach my $flag (qw( tax spool_cdr squelch_cdr archived )) {
+  foreach my $flag (qw( tax spool_cdr squelch_cdr archived email_csv_cdr )) {
     $self->$flag() =~ /^(Y?)$/ or return "Illegal $flag: ". $self->$flag();
     $self->$flag($1);
   }



More information about the freeside-commits mailing list