TT#32602 fix perlcritic error ValuesAndExpressions::ProhibitImplicitNewlines

this is to clean the Sipwise TAP tests for this repo

Change-Id: Iebc9d128b992a0ea5576e3dcc7477e885d5b2294
changes/68/21368/2
Gerhard Jungwirth 8 years ago
parent 11d8813da1
commit 02e3e040b5

@ -223,28 +223,32 @@ sub panasonic_directory_list :Chained('base') :PathPart('pbx/directory/panasonic
$self->add_phonebook_entries($c, $dev, \@entries, \%entries);
my $data =
'<?xml version="1.0" encoding="utf-8"?>
my $data = <<'EOS_XML';
<?xml version="1.0" encoding="utf-8"?>
<ppxml xmlns="http://panasonic/sip_phone"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://panasonic/sip_phone sip_phone.xsd">
<Screen version="2.0">
<PhoneBook version="2.0">
';
my $person_id = 1;
EOS_XML
my $person_id = 0;
$data .= join '', map {
"<Personnel id=\"".($person_id++)."\">
$person_id++;
<<EOS_XMLLOOP;
<Personnel id="$person_id">
<Name>$$_{name}</Name>
<PhoneNums>
<PhoneNum type=\"ext\">$$_{ext}</PhoneNum>
<PhoneNum type="ext">$$_{ext}</PhoneNum>
</PhoneNums>
</Personnel>
"} @entries;
EOS_XMLLOOP
} @entries;
$data .=
' </PhoneBook>
$data .= <<EOS_XML;
</PhoneBook>
</Screen>
</ppxml>';
</ppxml>
EOS_XML
$c->log->debug("providing config to $id");
@ -307,20 +311,22 @@ sub yealink_directory_list :Chained('base') :PathPart('pbx/directory/yealink') :
$self->add_phonebook_entries($c, $dev, \@entries, \%entries);
my $data =
'<?xml version="1.0" encoding="utf-8"?>
my $req_uri = $c->req->uri;
my $data = <<EOS_XML;
<?xml version="1.0" encoding="utf-8"?>
<SipwiseIPPhoneDirectory>
<SoftKeyItem>
<Name>0</Name>
<URL>'.$c->req->uri.'</URL>
<URL>$req_uri</URL>
</SoftKeyItem>
';
$data .= join '', map {
"<DirectoryEntry>
EOS_XML
$data .= join '', map { <<EOS_XMLLOOP;
<DirectoryEntry>
<Name>$$_{name}</Name>
<Telephone>$$_{ext}</Telephone>
</DirectoryEntry>
"} @entries;
EOS_XMLLOOP
} @entries;
$data .= '</SipwiseIPPhoneDirectory>';
@ -389,27 +395,25 @@ sub polycom_directory_list :Chained('base') :PathPart('pbx/directory/polycom') :
$entry->{lname} = $lname;
}
my $data =
'<?xml version="1.0" encoding="utf-8"?>
my $data = <<EOS_XML;
<?xml version="1.0" encoding="utf-8"?>
<directory>
<item_list>
';
=pod
ln last name
fn first name
ct contact
sd speed-dial index
rt ring type
dc divert contact for auto divert
ad auto divert
ar auto reject
bw buddy watching
bb buddy block
=cut
$data .= join '', map {
"<item>
EOS_XML
# ln last name
# fn first name
# ct contact
# sd speed-dial index
# rt ring type
# dc divert contact for auto divert
# ad auto divert
# ar auto reject
# bw buddy watching
# bb buddy block
$data .= join '', map { <<EOS_XMLLOOP;
<item>
<ln>$$_{lname}</ln>
<fn>$$_{fname}</fn>
<ct>$$_{ext}</ct>
@ -421,7 +425,8 @@ bb buddy block
<bw>0</bw>
<bb>0</bb>
</item>
"} @entries;
EOS_XMLLOOP
} @entries;
$data .= '</item_list></directory>';
$c->log->debug("providing config to $id");

@ -38,8 +38,8 @@ has_field 'body' => (
rows => 10,
maxlength => '67108864', # 64MB
element_class => [qw/ngcp-autoconf-area/],
default =>
'Dear Customer,
default => <<'EOS_DEFAULT_TEXT',
Dear Customer,
A new subscriber [% subscriber %] has been created for you.
@ -48,7 +48,8 @@ Please go to [% url %] to set your password and log into your self-care interfac
Your faithful Sipwise system
--
This is an automatically generated message. Do not reply. '
This is an automatically generated message. Do not reply.
EOS_DEFAULT_TEXT
);
has_field 'save' => (

@ -21,27 +21,34 @@ sub rpc_server_params{
sub register_content {
my $self = shift;
my $mac_param = $self->content_params->{mac};
my $uri_param = $self->content_params->{uri};
#<param><value><string>".URI::Escape::uri_escape($self->content_params->{uri})."</string></value></param>
$self->{register_content} = "<?xml version=\"1.0\"?>
<methodCall>
<methodName>ipredirect.registerPhone</methodName>
<params>
<param><value><string>".$self->content_params->{mac}."</string></value></param>
<param><value><string><![CDATA[".$self->content_params->{uri}."]]></string></value></param>
</params>
</methodCall>";
$self->{register_content} = <<EOS_XML;
<?xml version="1.0"?>
<methodCall>
<methodName>ipredirect.registerPhone</methodName>
<params>
<param><value><string>$mac_param</string></value></param>
<param><value><string><![CDATA[$uri_param]]></string></value></param>
</params>
</methodCall>;
EOS_XML
return $self->{register_content};
}
sub unregister_content {
my $self = shift;
$self->{unregister_content} = "<?xml version=\"1.0\"?>
<methodCall>
<methodName>ipredirect.unregisterPhone</methodName>
<params>
<param><value><string>".($self->content_params->{mac_old} // '')."</string></value></param>
</params>
</methodCall>";
my $param_macold = $self->content_params->{mac_old} // '';
$self->{unregister_content} = <<EOS_XML;
<?xml version="1.0"?>
<methodCall>
<methodName>ipredirect.unregisterPhone</methodName>
<params>
<param><value><string>$param_macold</string></value></param>
</params>
</methodCall>
EOS_XML
return $self->{unregister_content};
}

@ -39,52 +39,73 @@ sub register_model{
sub register_package_content {
my $self = shift;
#.'_'.$self->content_params->{mac}
$self->{register_package_content} ||= "<?xml version='1.0' encoding='UTF-8'?>
<request userid='".$self->params->{credentials}->{user}."' password='".$self->params->{credentials}->{password}."' message-id='1001'>
<add-package account-id='".uri_escape($self->params->{redirect_params}->{profile})."'>
<package-data>
<base-package-name>default</base-package-name>
</package-data>
</add-package>
</request>";
my $param_user = $self->params->{credentials}->{user};
my $param_password = $self->params->{credentials}->{password};
my $param_profile = uri_escape($self->params->{redirect_params}->{profile});
$self->{register_package_content} ||= <<EOS_XML;
<?xml version='1.0' encoding='UTF-8'?>
<request userid='$param_user' password='$param_password' message-id='1001'>
<add-package account-id='$param_profile'>
<package-data>
<base-package-name>default</base-package-name>
</package-data>
</add-package>
</request>
EOS_XML
return $self->{register_package_content};
}
sub register_content {
my $self = shift;
#.'_'.$self->content_params->{mac}
$self->{register_content} ||= "<?xml version='1.0' encoding='UTF-8'?>
<request userid='".$self->params->{credentials}->{user}."' password='".$self->params->{credentials}->{password}."' message-id='1001'>
<add-sip-device account-id='".uri_escape($self->params->{redirect_params}->{profile})."'>
<device-params><deviceId>".$self->content_params->{mac}."</deviceId>
<serialNo>".$self->content_params->{mac}."</serialNo>
<vendor>Polycom</vendor>
<vendorModel>Polycom_UCS_Device</vendorModel>
</device-params>
<sip-device-common-params>
<templateCriteria>".uri_escape($self->params->{redirect_params}->{profile})."</templateCriteria>
</sip-device-common-params>
<package-data><base-package-name>default</base-package-name></package-data>
<vendor-extensions/>
</add-sip-device>
</request>";
my $param_user = $self->params->{credentials}->{user};
my $param_password = $self->params->{credentials}->{password};
my $param_profile = uri_escape($self->params->{redirect_params}->{profile});
my $param_mac = $self->content_params->{mac};
$self->{register_content} ||= <<EOS_XML;
<?xml version='1.0' encoding='UTF-8'?>
<request userid='$param_user' password='$param_password' message-id='1001'>
<add-sip-device account-id='$param_profile'>
<device-params>
<deviceId>$param_mac</deviceId>
<serialNo>$param_mac</serialNo>
<vendor>Polycom</vendor>
<vendorModel>Polycom_UCS_Device</vendorModel>
</device-params>
<sip-device-common-params>
<templateCriteria>$param_profile</templateCriteria>
</sip-device-common-params>
<package-data><base-package-name>default</base-package-name></package-data>
<vendor-extensions/>
</add-sip-device>
</request>
EOS_XML
return $self->{register_content};
}
sub unregister_content {
my $self = shift;
#.'_'.$self->content_params->{mac}
$self->{unregister_content} ||= "<?xml version='1.0' encoding='UTF-8'?>
<request userid='".$self->params->{credentials}->{user}."' password='".$self->params->{credentials}->{password}."' message-id='1001' >
<delete-sip-device account-id='".uri_escape($self->params->{redirect_params}->{profile})."'>
<device-params>
<deviceId>".$self->content_params->{mac}."</deviceId>
<serialNo>".$self->content_params->{mac}."</serialNo>
<vendor>Polycom</vendor>
<vendorModel>Polycom_UCS_Device</vendorModel>
</device-params>
</delete-sip-device>
</request>";
my $param_user = $self->params->{credentials}->{user};
my $param_password = $self->params->{credentials}->{password};
my $param_profile = uri_escape($self->params->{redirect_params}->{profile});
my $param_mac = $self->content_params->{mac};
$self->{unregister_content} ||= <<EOS_XML;
<?xml version='1.0' encoding='UTF-8'?>
<request userid='$param_user' password='$param_password' message-id='1001' >
<delete-sip-device account-id='$param_profile'>
<device-params>
<deviceId>$param_mac</deviceId>
<serialNo>$param_mac</serialNo>
<vendor>Polycom</vendor>
<vendorModel>Polycom_UCS_Device</vendorModel>
</device-params>
</delete-sip-device>
</request>
EOS_XML
return $self->{unregister_content};
}

@ -20,34 +20,46 @@ sub rpc_server_params{
sub register_content {
my $self = shift;
my $param_mac = $self->content_params->{mac};
my $param_uri = $self->content_params->{uri};
#<param><value><string>".URI::Escape::uri_escape($self->content_params->{uri})."</string></value></param>
#http://fox.snom.com/prv2.php?mac={mac}
$self->{register_content} = "<?xml version='1.0'?>
$self->{register_content} = <<EOS_XML;
<?xml version='1.0'?>
<methodCall>
<methodName>redirect.registerPhone</methodName>
<params>
<param>
<value><string>".$self->content_params->{mac}."</string></value>
</param>
<param>
<value><string>".$self->content_params->{uri}."</string></value>
</param>
</params>
</methodCall>";
<methodName>redirect.registerPhone</methodName>
<params>
<param>
<value><string>$param_mac</string></value>
</param>
<param>
<value><string>$param_uri</string></value>
</param>
</params>
</methodCall>
EOS_XML
return $self->{register_content};
}
sub unregister_content {
my $self = shift;
$self->{unregister_content} = "<?xml version='1.0'?>
my $param_macold = $self->content_params->{mac_old} // '';
$self->{unregister_content} = <<EOS_XML;
<?xml version='1.0'?>
<methodCall>
<methodName>redirect.deregisterPhone</methodName>
<params>
<param>
<value><string>".($self->content_params->{mac_old} // '')."</string></value>
</param>
</params>
</methodCall>";
<methodName>redirect.deregisterPhone</methodName>
<params>
<param>
<value><string>$param_macold</string></value>
</param>
</params>
</methodCall>
EOS_XML
return $self->{unregister_content};
}
around 'extract_response_description' => sub {

@ -26,52 +26,69 @@ sub rpc_server_params{
sub register_content {
my $self = shift;
$self->{register_content} ||= "<?xml version='1.0' encoding='UTF-8'?>
my $param_servername = $self->content_params->{server_name};
my $param_mac = $self->content_params->{mac};
$self->{register_content} ||= <<EOS_XML;
<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
<methodName>redirect.registerDevice</methodName>
<params>
<param>
<value><string>".$self->content_params->{mac}."</string></value>
</param>
<param>
<value><string><![CDATA[".$self->content_params->{server_name}."]]></string></value>
</param>
</params>
</methodCall>";
<methodName>redirect.registerDevice</methodName>
<params>
<param>
<value><string>$param_mac</string></value>
</param>
<param>
<value><string><![CDATA[$param_servername]]></string></value>
</param>
</params>
</methodCall>
EOS_XML
return $self->{register_content};
}
sub unregister_content {
my $self = shift;
$self->{unregister_content} ||= "<?xml version='1.0' encoding='UTF-8'?>
my $param_macold = $self->content_params->{mac_old} // '';
$self->{unregister_content} ||= <<EOS_XML;
<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
<methodName>redirect.deRegisterDevice</methodName>
<params>
<param>
<value><string>".($self->content_params->{mac_old} // '')."</string></value>
</param>
</params>
</methodCall>";
<methodName>redirect.deRegisterDevice</methodName>
<params>
<param>
<value><string>$param_macold</string></value>
</param>
</params>
</methodCall>
EOS_XML
return $self->{unregister_content};
}
sub register_model_content {
my $self = shift;
$self->{register_model_content} ||= "<?xml version='1.0' encoding='UTF-8'?>
my $param_servername = $self->content_params->{server_name};
my $param_uri = $self->content_params->{uri};
$self->{register_model_content} ||= <<EOS_XML;
<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
<methodName>redirect.addServer</methodName>
<params>
<param>
<value>
<string><![CDATA[".$self->content_params->{server_name}."]]></string>
</value>
</param>
<param>
<value>
<string><![CDATA[".$self->content_params->{uri}."]]></string>
</value>
</param>
</params>
</methodCall>";
<methodName>redirect.addServer</methodName>
<params>
<param>
<value>
<string><![CDATA[$param_servername]]></string>
</value>
</param>
<param>
<value>
<string><![CDATA[$param_uri]]></string>
</value>
</param>
</params>
</methodCall>
EOS_XML
return $self->{register_model_content};
}

@ -9,11 +9,13 @@ use Tie::IxHash;
# try using the db directly ...
my $schema = undef;
eval '
eval <<'EVALLINE' ;
use lib "/home/rkrenn/sipwise/git/ngcp-schema/lib";
use lib "/home/rkrenn/sipwise/git/sipwise-base/lib";
use NGCP::Schema;
';
EVALLINE
print $@;
unless ($@) {
diag("connecting to ngcp db");

@ -38,19 +38,20 @@ sub test_timeout {
'path' => $cfg->{path},
'headers' => $cfg->{headers},
'Content-Type' => 'text/xml',
'content' => "<?xml version='1.0' encoding='UTF-8'?>
'content' => <<EOFCONTENT } );
<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
<methodName>redirect.registerDevice</methodName>
<params>
<param>
<value><string>"."0080f0d4dbf1"."</string></value>
</param>
<param>
<value><string><![CDATA["."0080f0d4dbf10080f0d4"."]]></string></value>
</param>
</params>
</methodCall>",
},);
<methodName>redirect.registerDevice</methodName>
<params>
<param>
<value><string>"."0080f0d4dbf1"."</string></value>
</param>
<param>
<value><string><![CDATA["."0080f0d4dbf10080f0d4"."]]></string></value>
</param>
</params>
</methodCall>
EOFCONTENT
#if ( $page ) {
# print "qqq;\n";
#} else {

@ -74,11 +74,12 @@ my @opt_spec = (
}
return $res." ";
};
open CONFIG, "$config_file" or die "Program stopping, couldn't open the configuration file '$config_file'.\n";
open my $config_fh, '<', "$config_file"
or die "Program stopping, couldn't open the configuration file '$config_file'.\n";
#can try CONFIG::Hash, Env::Sourced
my $opt_str = '';
while (<CONFIG>) {
while (<$config_fh>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
@ -91,7 +92,7 @@ my @opt_spec = (
$opt_str .= $cfg2opt->($opt_key,$value);
#$opt->{lc $var} = $value;
}
close CONFIG;
close $config_fh;
GetOptionsFromString($opt_str, $opt_cfg, @opt_spec);
}
}
@ -203,15 +204,15 @@ sub process_invoices{
$logger->debug( "No billing profile;\n");
}
}else{
$invoices->{$client_contract->{id}} = $dbh->selectall_arrayref('select invoices.id from invoices where invoices.generator="auto"
'.ifp(' and ',
join(' and ',
!$opt->{resend}?' invoices.sent_date is null ':(),
(ify(' invoices.contract_id ', (@{$opt->{client_contract_id}}, $client_contract->{id}) )),
(ifk(' date(invoices.period_start) >= ? ', v2a($stime ? $stime->ymd : undef))),
(ifk(' date(invoices.period_start) <= ? ', v2a($etime ? $etime->ymd : undef))),
)
), { Slice => {} }, @{$opt->{client_contract_id}}, v2a($client_contract->{id}), v2a($stime->ymd),v2a($etime->ymd) );
$invoices->{$client_contract->{id}} = $dbh->selectall_arrayref('select invoices.id from invoices where invoices.generator="auto" '
. ifp(' and ',
join(' and ',
!$opt->{resend}?' invoices.sent_date is null ':(),
(ify(' invoices.contract_id ', (@{$opt->{client_contract_id}}, $client_contract->{id}) )),
(ifk(' date(invoices.period_start) >= ? ', v2a($stime ? $stime->ymd : undef))),
(ifk(' date(invoices.period_start) <= ? ', v2a($etime ? $etime->ymd : undef))),
)
), { Slice => {} }, @{$opt->{client_contract_id}}, v2a($client_contract->{id}), v2a($stime->ymd),v2a($etime->ymd) );
}
if($opt->{send} || $opt->{sendonly}){
my $email_template = get_email_template($provider_contract,$client_contract);
@ -246,10 +247,10 @@ sub get_provider_clients_contacts{
}
sub get_client_contracts{
my($client_contact,$stime,$etime) = @_;
my $contacts = $dbh->selectall_arrayref('select contracts.*
from contracts
left join invoices on contracts.id=invoices.contract_id and invoices.generator="auto" '
.ifp(' and ',
my $contacts = $dbh->selectall_arrayref('select contracts.* ' .
'from contracts ' .
'left join invoices on contracts.id=invoices.contract_id and invoices.generator="auto" '
. ifp(' and ',
join(' and ',
(ifk(' date(invoices.period_start) >= ? ', v2a($stime ? $stime->ymd : undef))),
(ifk(' date(invoices.period_start) <= ? ', v2a($etime ? $etime->ymd : undef ))),
@ -270,22 +271,22 @@ sub get_client_contracts{
sub get_billing_profile{
my($client_contract, $stime, $etime) = @_;
my $billing_profile;
if(my $actual_billing_mapping = $dbh->selectrow_hashref('select * FROM billing_mappings
where contract_id = ?
and (billing_mappings.start_date <= ? OR billing_mappings.start_date is null)
and (billing_mappings.end_date >= ? OR billing_mappings.end_date is null)
order by billing_mappings.start_date desc, billing_mappings.id desc limit 1'
, undef, $client_contract->{id}, $etime->epoch, $stime->epoch)){
if(my $actual_billing_mapping = $dbh->selectrow_hashref('select * FROM billing_mappings ' .
'where contract_id = ? ' .
'and (billing_mappings.start_date <= ? OR billing_mappings.start_date is null) ' .
'and (billing_mappings.end_date >= ? OR billing_mappings.end_date is null) ' .
'order by billing_mappings.start_date desc, billing_mappings.id desc limit 1',
undef, $client_contract->{id}, $etime->epoch, $stime->epoch)){
#don't allow auto-generation for terminated contracts
$billing_profile = $dbh->selectrow_hashref('select distinct billing_profiles.*
from billing_mappings
inner join billing_profiles on billing_mappings.billing_profile_id=billing_profiles.id
inner join contracts on contracts.id=billing_mappings.contract_id
inner join products on billing_mappings.product_id=products.id and products.class in("sipaccount","pbxaccount")
where billing_mappings.id=? '
.( ( !$opt->{allow_terminated} ) ? ' and contracts.status != "terminated" ':'' )
, undef, $actual_billing_mapping->{id}
$billing_profile = $dbh->selectrow_hashref('select distinct billing_profiles.* ' .
'from billing_mappings ' .
'inner join billing_profiles on billing_mappings.billing_profile_id=billing_profiles.id ' .
'inner join contracts on contracts.id=billing_mappings.contract_id ' .
'inner join products on billing_mappings.product_id=products.id and products.class in("sipaccount","pbxaccount") ' .
'where billing_mappings.id=? ' .
( ( !$opt->{allow_terminated} ) ? ' and contracts.status != "terminated" ':'' ),
undef, $actual_billing_mapping->{id}
);
}
return $billing_profile;
@ -295,37 +296,37 @@ sub get_invoice_data_raw{
$opt_local //= {};
my ($invoice_details_calls,$invoice_details_zones);
if(!$opt_local->{count_contract_balance}){
$invoice_details_calls = $dbh->selectall_arrayref('select cdr.*,from_unixtime(cdr.start_time) as start_time,bzh.zone, bzh.detail as zone_detail
from accounting.cdr
LEFT JOIN billing.billing_zones_history bzh ON bzh.id = cdr.source_customer_billing_zone_id
where
cdr.source_user_id != "0"
and cdr.call_status="ok"
and cdr.rating_status="ok"
and cdr.source_account_id=?
and cdr.start_time >= ?
and cdr.start_time <= ?
order by cdr.start_time '
, { Slice => {} }
, $client_contract->{id},$stime->epoch,$etime->epoch
$invoice_details_calls = $dbh->selectall_arrayref('select cdr.*,from_unixtime(cdr.start_time) as start_time,bzh.zone, bzh.detail as zone_detail ' .
'from accounting.cdr ' .
'LEFT JOIN billing.billing_zones_history bzh ON bzh.id = cdr.source_customer_billing_zone_id ' .
'where ' .
'cdr.source_user_id != "0" ' .
'and cdr.call_status="ok" ' .
'and cdr.rating_status="ok" ' .
'and cdr.source_account_id=? ' .
'and cdr.start_time >= ? ' .
'and cdr.start_time <= ? ' .
'order by cdr.start_time ',
{ Slice => {} },
$client_contract->{id},$stime->epoch,$etime->epoch
);
}
$invoice_details_zones = $dbh->selectall_arrayref('select SUM(cdr.source_customer_cost) AS customercost, COUNT(*) AS number, SUM(cdr.duration) AS duration,sum(cdr.source_customer_free_time) as free_time '
.(!$opt_local->{count_contract_balance}?', bzh.zone':'')
.'
from accounting.cdr '
.(!$opt_local->{count_contract_balance}?'LEFT JOIN billing.billing_zones_history bzh ON bzh.id = cdr.source_customer_billing_zone_id ':'')
.' where
cdr.source_user_id != "0"
and cdr.call_status="ok"
and cdr.rating_status="ok"
and cdr.source_account_id=?
and cdr.start_time >= ?
and cdr.start_time <= ?'
.(!$opt_local->{count_contract_balance}?'group by bzh.zone
order by bzh.zone':'')
, {Slice => {} }
, $client_contract->{id},$stime->epoch,$etime->epoch
$invoice_details_zones = $dbh->selectall_arrayref('select SUM(cdr.source_customer_cost) AS customercost, COUNT(*) AS number, SUM(cdr.duration) AS duration,sum(cdr.source_customer_free_time) as free_time ' .
(!$opt_local->{count_contract_balance}?', bzh.zone':'') .
' from accounting.cdr ' .
(!$opt_local->{count_contract_balance}?'LEFT JOIN billing.billing_zones_history bzh ON bzh.id = cdr.source_customer_billing_zone_id ':'') .
' where ' .
'cdr.source_user_id != "0" ' .
'and cdr.call_status="ok" ' .
'and cdr.rating_status="ok" ' .
'and cdr.source_account_id=? ' .
'and cdr.start_time >= ? ' .
'and cdr.start_time <= ?' .
(!$opt_local->{count_contract_balance}
? 'group by bzh.zone order by bzh.zone'
: ''),
{Slice => {} },
$client_contract->{id},$stime->epoch,$etime->epoch
);
#/data for invoice generation
@ -348,18 +349,18 @@ sub check_unrated_calls{
if($opt->{force_unrated}){
return 1;
}
my $unrated_calls_info = $dbh->selectall_arrayref('select cdr.source_account_id, from_unixtime(min(cdr.start_time)) as start_time_min, from_unixtime(max(cdr.start_time)) as start_time_max, count(*) as calls_number
from accounting.cdr
where
cdr.source_user_id != "0"
and cdr.call_status="ok"
and cdr.rating_status != "ok"
and cdr.start_time >= ?
and cdr.start_time <= ?
group by cdr.source_account_id
order by cdr.source_account_id '
, { Slice => {} }
, $stime->epoch,$etime->epoch
my $unrated_calls_info = $dbh->selectall_arrayref('select cdr.source_account_id, from_unixtime(min(cdr.start_time)) as start_time_min, from_unixtime(max(cdr.start_time)) as start_time_max, count(*) as calls_number ' .
'from accounting.cdr ' .
'where ' .
'cdr.source_user_id != "0" ' .
'and cdr.call_status="ok" ' .
'and cdr.rating_status != "ok" ' .
'and cdr.start_time >= ? ' .
'and cdr.start_time <= ? ' .
'group by cdr.source_account_id ' .
'order by cdr.source_account_id ',
{ Slice => {} },
$stime->epoch,$etime->epoch
);
if(@$unrated_calls_info){
my $msg = "\n\n\n\n".'There are '.@$unrated_calls_info.' customers which have unrated calls in the '.$stime->ymd.' - '.$etime->ymd.' period. Run '.__FILE__.' script with option --force_unrated to generate invoices anyway.'."\n\n\n\n";

@ -46,8 +46,10 @@ $test_machine->DATA_ITEM_STORE($data);
{
#test "upload csv" interface variant
$test_machine->DATA_ITEM($data);
my $csv_data = "aaa,111,222,2221,2016-10-02,2016-10-31,1,1
aaa,111,333,3331,2016-10-01,2016-10-31,1,1\n";
my $csv_data = <<EOS_CSV;
aaa,111,222,2221,2016-10-02,2016-10-31,1,1
aaa,111,333,3331,2016-10-01,2016-10-31,1,1
EOS_CSV
my $csv_upload_url = '/api/lnpnumbers/';
my $csv_download_url = '/api/lnpnumbers/';
$test_machine->resource_fill_file($test_machine->DATA_ITEM->{file}->[0], $csv_data);

Loading…
Cancel
Save