summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_bill.pm6
-rw-r--r--FS/FS/cust_bill_pkg.pm2
-rw-r--r--FS/FS/cust_main.pm4
-rw-r--r--FS/FS/part_pkg/voip_cdr.pm13
-rw-r--r--conf/invoice_html10
-rw-r--r--conf/invoice_latex8
-rwxr-xr-xhttemplate/edit/cust_main.cgi6
-rw-r--r--httemplate/edit/cust_main/billing.html9
-rw-r--r--httemplate/view/cust_main/billing.html7
11 files changed, 61 insertions, 12 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 8684a5aa4..3c4c6eebe 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1893,6 +1893,13 @@ worry that config_items is freeside-specific and icky.
},
{
+ 'key' => 'voip-cust_cdr_squelch',
+ 'section' => '',
+ 'description' => 'Enable the per-customer option for not printing CDR on 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.",
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 06816effe..9a1ce9fc0 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -621,6 +621,7 @@ sub tables_hashref {
'referral_custnum', 'int', 'NULL', '', '', '',
'comments', 'text', 'NULL', '', '', '',
'spool_cdr','char', 'NULL', 1, '', '',
+ 'squelch_cdr','char', 'NULL', 1, '', '',
'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'custnum',
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 3aed5a44a..96c1db7fb 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1631,6 +1631,8 @@ L<Time::Local> and L<Date::Parse> for conversion functions.
cid -
+unsquelch_cdr - overrides any per customer cdr squelching when true
+
=cut
sub print_generic {
@@ -2054,6 +2056,8 @@ sub print_generic {
$options{'section'} = $section if $multisection;
$options{'format'} = $format;
$options{'escape_function'} = $escape_function;
+ $options{'format_function'} = sub { () }
+ unless $params{unsquelch_cdr} || $cust_main->squelch_cdr ne 'Y';
foreach my $line_item ( $self->_items_pkg(%options) ) {
my $detail = {
@@ -2638,6 +2642,7 @@ sub _items_cust_bill_pkg {
my $format = $opt{format} || '';
my $escape_function = $opt{escape_function} || sub { shift };
+ my $format_function = $opt{format_function} || '';
my @b = ();
foreach my $cust_bill_pkg ( @$cust_bill_pkg ) {
@@ -2648,6 +2653,7 @@ sub _items_cust_bill_pkg {
my %details_opt = ( 'format' => $format,
'escape_function' => $escape_function,
+ 'format_function' => $format_function,
);
if ( $cust_bill_pkg->pkgnum > 0 ) {
diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm
index 62c0d583a..638e707c4 100644
--- a/FS/FS/cust_bill_pkg.pm
+++ b/FS/FS/cust_bill_pkg.pm
@@ -285,6 +285,8 @@ sub details {
}
if $format eq 'latex';
+ $format_sub = $opt{format_function} if $opt{format_function};
+
map { ( $_->format eq 'C'
? &{$format_sub}( $_->detail )
: &{$escape_function}( $_->detail )
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index e7235ffcc..b74c75d50 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -223,6 +223,8 @@ Card Verification Value, "CVV2" (also known as CVC2 or CID), the 3 or 4 digit nu
=item spool_cdr - Enable individual CDR spooling, empty or `Y'
+=item squelch_cdr - Discourage individual CDR printing, empty or `Y'
+
=back
=head1 METHODS
@@ -1530,7 +1532,7 @@ sub check {
$self->payname($1);
}
- foreach my $flag (qw( tax spool_cdr )) {
+ foreach my $flag (qw( tax spool_cdr squelch_cdr )) {
$self->$flag() =~ /^(Y?)$/ or return "Illegal $flag: ". $self->$flag();
$self->$flag($1);
}
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index a14db2b2c..a7c1903e6 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -158,6 +158,10 @@ sub calc_usage {
my $output_format = $self->option('output_format', 'Hush!')
|| 'simple';
+ eval "use Text::CSV_XS;";
+ die $@ if $@;
+ my $csv = new Text::CSV_XS;
+
foreach my $cust_svc (
grep { $_->part_svc->svcdb eq 'svc_phone' } $cust_pkg->cust_svc
) {
@@ -298,7 +302,7 @@ sub calc_usage {
$charge = sprintf('%.2f', $cdr->upstream_price);
$charges += $charge;
-
+
@call_details = (
#time2str("%Y %b %d - %r", $cdr->calldate_unix ),
time2str("%c", $cdr->calldate_unix), #XXX this should probably be a config option dropdown so they can select US vs- rest of world dates or whatnot
@@ -383,10 +387,9 @@ sub calc_usage {
if ( $self->option('rating_method') eq 'upstream_simple' ) {
$call_details = [ 'C', $call_details[0] ];
}else{
- $call_details = join(' - ', @call_details );
+ $csv->combine(@call_details);
+ $call_details = [ 'C', $csv->string ];
}
- warn " adding details on charge to invoice: $call_details"
- if ( $DEBUG && !ref($call_details) );
warn " adding details on charge to invoice: [ ".
join(', ', @{$call_details} ). " ]"
if ( $DEBUG && ref($call_details) );
@@ -476,7 +479,7 @@ sub append_cust_bill_pkgs {
'quantity' => $cust_pkg->quantity,
'sdate' => $$sdate,
'edate' => $cust_pkg->bill, # already fiddled
- 'itemdesc' => 'Call details', # configurable?
+ 'itemdesc' => 'Usage charges', # configurable?
'details' => \@details,
};
diff --git a/conf/invoice_html b/conf/invoice_html
index 06980b021..806c5deb4 100644
--- a/conf/invoice_html
+++ b/conf/invoice_html
@@ -6,6 +6,7 @@
.invoice_longtable table { cellspacing: none }
.invoice_longtable TH { border-top: 2px solid #000000; border-bottom: 1px solid #000000; padding-left: none; padding-right: none; font-size: 10pt }
.invoice_desc TD { border-top: 2px solid #000000; font-weight: bold; font-size: 10pt }
+.invoice_desc_more TD { font-weight: bold; font-size: 10pt }
.invoice_extdesc TD { font-size: 8pt }
.invoice_totaldesc TD { font-size: 10pt; empty-cells: show }
</STYLE>
@@ -123,6 +124,7 @@
'<th align="right">Amount</th>'.
'</tr>';
+ my $lastref = 0;
foreach my $line (
grep { ( scalar(@sections) > 1
? $section->{'description'} eq $_->{'section'}->{'description'}
@@ -131,8 +133,11 @@
@detail_items )
{
$OUT .=
- '<tr class="invoice_desc">'.
- '<td align="center">'. $line->{'ref'}. '</td>'.
+ '<tr class="invoice_desc'.
+ ( ($line->{'ref'} && $line->{'ref'} ne $lastref) ? '' : '_more' ).
+ '">'.
+ '<td align="center">'.
+ ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ). '</td>'.
'<td align="left">'. $line->{'description'}. '</td>'.
( $unitprices
? '<td align="left">'. $line->{'unit_amount'}. '</td>'.
@@ -143,6 +148,7 @@
'<td align="right">'. $line->{'amount'}. '</td>'.
'</tr>'
;
+ $lastref = $line->{'ref'};
if ( @{$line->{'ext_description'} } ) {
$OUT .= '<tr class="invoice_extdesc"><td></td><td';
$OUT .= $unitprices ? ' colspan=3>' : '>';
diff --git a/conf/invoice_latex b/conf/invoice_latex
index 6bfc41d5a..ddd068ed6 100644
--- a/conf/invoice_latex
+++ b/conf/invoice_latex
@@ -284,6 +284,7 @@ Terms: [@-- $terms --@]\\
$OUT .= '\hline';
$OUT .= '\endlastfoot';
+ my $lastref = 0;
foreach my $line (
grep { ( scalar( @sections ) > 1
? $section->{'description'} eq $_->{'section'}->{'description'}
@@ -296,11 +297,14 @@ Terms: [@-- $terms --@]\\
# Don't break-up small packages.
my $rowbreak = @$ext_description < 5 ? '*' : '';
- $OUT .= "\\hline\n";
- $OUT .= '\FSdesc{' . $line->{'ref'} . '}{' . $line->{'description'} . '}' .
+ $OUT .= "\\hline\n" if ($line->{'ref'} && $line->{'ref'} ne $lastref);
+ $OUT .= '\FSdesc'.
+ '{' . ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ) . '}'.
+ '{' . $line->{'description'} . '}' .
'{' . ( $unitprices ? $line->{'unit_amount'} : '' ) . '}'.
'{' . ( $unitprices ? $line->{'quantity'} : '' ) . '}' .
'{' . $line->{'amount'} . "}${rowbreak}\n";
+ $lastref = $line->{'ref'};
foreach my $ext_desc (@$ext_description) {
if ( $ext_desc !~ /[^\\]&/ ) {
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index f0d719c2e..10086a4dd 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -265,7 +265,8 @@ function bottomfixup(what) {
'tax',
'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
'invoice_terms',
- 'spool_cdr'
+ 'spool_cdr',
+ 'squelch_cdr'
);
for ( f=0; f < topvars.length; f++ ) {
@@ -501,7 +502,8 @@ function copyelement(from, to) {
% 'tax',
% 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
% 'invoice_terms',
-% 'spool_cdr'
+% 'spool_cdr',
+% 'squelch_cdr'
% ) {
%
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index 6b1c2a86f..d4c503412 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -446,6 +446,15 @@
<INPUT TYPE="hidden" NAME="spool_cdr" VALUE="<% $cust_main->spool_cdr %>">
% }
+% if ( $conf->exists('voip-cust_cdr_squelch') ) {
+ <TR>
+ <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="squelch_cdr" VALUE="Y" <% $cust_main->squelch_cdr eq "Y" ? 'CHECKED' : '' %>> Omit CDRs from invoices</TD>
+ </TR>
+% } else {
+
+ <INPUT TYPE="hidden" NAME="squelch_cdr" VALUE="<% $cust_main->squelch_cdr %>">
+% }
+
</TABLE>
</FORM>
diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html
index 2f05c1ae2..aea90e8b3 100644
--- a/httemplate/view/cust_main/billing.html
+++ b/httemplate/view/cust_main/billing.html
@@ -196,6 +196,13 @@ Billing information
</TR>
% }
+% if ( $conf->exists('voip-cust_cdr_squelch') ) {
+ <TR>
+ <TD ALIGN="right">Print&nbsp;CDRs</TD>
+ <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? 'no' : 'yes' %></TD>
+ </TR>
+% }
+
</TABLE></TD></TR></TABLE>
<%once>