[freeside-commits] freeside/FS/FS Record.pm, 1.192, 1.193 Schema.pm, 1.162, 1.163 cust_bill.pm, 1.250, 1.251 cust_bill_pkg.pm, 1.37, 1.38 cust_bill_pkg_detail.pm, 1.7, 1.8 cust_svc.pm, 1.80, 1.81
Jeff Finucane,420,,
jeff at wavetail.420.am
Mon Aug 17 13:48:29 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv16265/FS/FS
Modified Files:
Record.pm Schema.pm cust_bill.pm cust_bill_pkg.pm
cust_bill_pkg_detail.pm cust_svc.pm
Log Message:
improve emailed cdr csv file (#5727 again)
Index: cust_bill_pkg_detail.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg_detail.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cust_bill_pkg_detail.pm 19 Jun 2009 21:49:03 -0000 1.7
+++ cust_bill_pkg_detail.pm 17 Aug 2009 20:48:27 -0000 1.8
@@ -4,6 +4,7 @@
use vars qw( @ISA $me $DEBUG %GetInfoType );
use FS::Record qw( qsearch qsearchs dbdef dbh );
use FS::cust_bill_pkg;
+use FS::Conf;
@ISA = qw(FS::Record);
$me = '[ FS::cust_bill_pkg_detail ]';
@@ -102,10 +103,26 @@
sub check {
my $self = shift;
+ my $conf = new FS::Conf;
+
+ my $phonenum = $self->phonenum;
+ my $phonenum_check_method;
+ if ( $conf->exists('svc_phone-allow_alpha_phonenum') ) {
+ $phonenum =~ s/\W//g;
+ $phonenum_check_method = 'ut_alphan';
+ } else {
+ $phonenum =~ s/\D//g;
+ $phonenum_check_method = 'ut_numbern';
+ }
+ $self->phonenum($phonenum);
+
$self->ut_numbern('detailnum')
|| $self->ut_foreign_key('billpkgnum', 'cust_bill_pkg', 'billpkgnum')
+ || $self->ut_moneyn('amount')
|| $self->ut_enum('format', [ '', 'C' ] )
|| $self->ut_text('detail')
+ || $self->ut_foreign_keyn('classnum', 'usage_class', 'classnum')
+ || $self->$phonenum_check_method('phonenum')
|| $self->SUPER::check
;
Index: cust_svc.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_svc.pm,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- cust_svc.pm 18 May 2009 09:55:29 -0000 1.80
+++ cust_svc.pm 17 Aug 2009 20:48:27 -0000 1.81
@@ -741,7 +741,8 @@
qsearch( {
'table' => 'cdr',
'hashref' => \%hash,
- 'extra_sql' => "$extra_sql $for_update",
+ 'extra_sql' => $extra_sql,
+ 'order_by' => "ORDER BY startdate $for_update",
} );
@cdrs;
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.250
retrieving revision 1.251
diff -u -d -r1.250 -r1.251
--- cust_bill.pm 30 Jul 2009 06:42:31 -0000 1.250
+++ cust_bill.pm 17 Aug 2009 20:48:26 -0000 1.251
@@ -794,8 +794,11 @@
push @otherparts, build MIME::Entity
'Type' => 'text/csv',
'Encoding' => '7bit',
- 'Data' => [ map { "$_\n" } $self->call_details ],
+ 'Data' => [ map { "$_\n" }
+ $self->call_details('prepend_billed_number' => 1)
+ ],
'Disposition' => 'attachment',
+ 'Filename' => 'usage-'. $self->invnum. '.csv',
;
}
@@ -3129,20 +3132,36 @@
}
-=item call_details
+=item call_details [ OPTION => VALUE ... ]
Returns an array of CSV strings representing the call details for this invoice
+The only option available is the boolean prepend_billed_number
=cut
sub call_details {
- my $self = shift;
- map { $_->details( 'format_function' => sub{ shift },
- 'escape_function' => sub{ return() },
- )
- }
- grep { $_->pkgnum }
- $self->cust_bill_pkg;
+ my ($self, %opt) = @_;
+
+ my $format_function = sub { shift };
+
+ if ($opt{prepend_billed_number}) {
+ $format_function = sub {
+ my $detail = shift;
+ my $row = shift;
+
+ $row->amount ? $row->phonenum. ",". $detail : '"Billed number",'. $detail;
+
+ };
+ }
+
+ my @details = map { $_->details( 'format_function' => $format_function,
+ 'escape_function' => sub{ return() },
+ )
+ }
+ grep { $_->pkgnum }
+ $self->cust_bill_pkg;
+ my $header = $details[0];
+ ( $header, grep { $_ ne $header } @details );
}
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -d -r1.192 -r1.193
--- Record.pm 9 Aug 2009 09:05:38 -0000 1.192
+++ Record.pm 17 Aug 2009 20:48:26 -0000 1.193
@@ -1988,6 +1988,22 @@
'';
}
+=item ut_moneyn COLUMN
+
+Check/untaint monetary numbers. May be negative. If there
+is an error, returns the error, otherwise returns false.
+
+=cut
+
+sub ut_moneyn {
+ my($self,$field)=@_;
+ if ($self->getfield($field) eq '') {
+ $self->setfield($field, '');
+ return '';
+ }
+ $self->ut_money($field);
+}
+
=item ut_text COLUMN
Check/untaint text. Alphanumerics, spaces, and the following punctuation
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -d -r1.162 -r1.163
--- Schema.pm 9 Aug 2009 09:05:38 -0000 1.162
+++ Schema.pm 17 Aug 2009 20:48:26 -0000 1.163
@@ -550,6 +550,7 @@
'amount', @money_typen, '', '',
'format', 'char', 'NULL', 1, '', '',
'classnum', 'int', 'NULL', '', '', '',
+ 'phonenum', 'varchar', 'NULL', 15, '', '',
'detail', 'varchar', '', 255, '', '',
],
'primary_key' => 'detailnum',
Index: cust_bill_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg.pm,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- cust_bill_pkg.pm 9 Aug 2009 22:47:57 -0000 1.37
+++ cust_bill_pkg.pm 17 Aug 2009 20:48:27 -0000 1.38
@@ -119,6 +119,7 @@
'detail' => (ref($detail) ? $detail->[1] : $detail ),
'amount' => (ref($detail) ? $detail->[2] : '' ),
'classnum' => (ref($detail) ? $detail->[3] : '' ),
+ 'phonenum' => (ref($detail) ? $detail->[4] : '' ),
};
$error = $cust_bill_pkg_detail->insert;
if ( $error ) {
@@ -371,7 +372,7 @@
$format_sub = $opt{format_function} if $opt{format_function};
map { ( $_->format eq 'C'
- ? &{$format_sub}( $_->detail )
+ ? &{$format_sub}( $_->detail, $_ )
: &{$escape_function}( $_->detail )
)
}
More information about the freeside-commits
mailing list