X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fvoip_inbound.pm;h=6358af2003a9d4f23c93b7965bf01a393b8bb775;hb=57bb423fe457ba4e13726877f53bcdf944f828f8;hp=e911439c8fec023328852cd4a08a190058872aaa;hpb=a2ecb1cf6a6c084c521710f1256da082f70ba9e5;p=freeside.git diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm index e911439c8..6358af200 100644 --- a/FS/FS/part_pkg/voip_inbound.pm +++ b/FS/FS/part_pkg/voip_inbound.pm @@ -64,9 +64,13 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); }, 'use_cdrtypenum' => { 'name' => 'Only charge for CDRs where the CDR Type is set to this cdrtypenum: ', + 'validate' => \&FS::part_pkg::validate_number_blank, + 'js_validate' => 'digits: true', }, 'ignore_cdrtypenum' => { 'name' => 'Do not charge for CDRs where the CDR Type is set to this cdrtypenum: ', + 'validate' => \&FS::part_pkg::validate_number_blank, + 'js_validate' => 'digits: true', }, 'use_calltypenum' => { 'name' => 'Only charge for CDRs where the CDR Call Type is set to this cdrtypenum: ', @@ -120,6 +124,10 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); 'type' => 'checkbox', }, + 'bill_only_pkg_dates' => { 'name' => 'Only bill CDRs with a date during the package billing period', + 'type' => 'checkbox', + }, + #XXX also have option for an external db # 'cdr_location' => { 'name' => 'CDR database location' # 'type' => 'select', @@ -160,6 +168,7 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); use_duration output_format usage_mandate summarize_usage usage_section bill_every_call + bill_only_pkg_dates ) ], 'weight' => 42, @@ -206,9 +215,6 @@ sub calc_usage { if $self->recur_temporality eq 'preceding' && ( $last_bill eq '' || $last_bill == 0 ); - my $spool_cdr = $cust_pkg->cust_main->spool_cdr; - - my $charges = 0; # my $downstream_cdr = ''; @@ -239,12 +245,18 @@ sub calc_usage { ) { my $svc_phone = $cust_svc->svc_x; - my $cdr_search = $svc_phone->psearch_cdrs( + my %options = ( 'inbound' => 1, 'default_prefix' => $self->option('default_prefix'), 'status' => '', # unprocessed only 'for_update' => 1, ); + if ( $self->option('bill_only_pkg_dates') ) { + $options{'begin'} = $last_bill; + $options{'end'} = $$sdate; + } + + my $cdr_search = $svc_phone->psearch_cdrs(%options); $cdr_search->limit(1000); $cdr_search->increment(0); while ( my $cdr = $cdr_search->fetch ) { @@ -399,15 +411,5 @@ sub is_free { 0; } -# This equates svc_phone records; perhaps svc_phone should have a field -# to indicate it represents a line -# #XXX no count_available_phones? -sub calc_units { - my($self, $cust_pkg ) = @_; - my $count = - scalar(grep { $_->part_svc->svcdb eq 'svc_phone' } $cust_pkg->cust_svc); - $count; -} - 1;