MT#13903 disable applying profile package

This is a patcht introducing a variable to disable
setting profile_package_id's in in the contracts
table. The code should therefore behave as before,
as long rate-o-mat and libswrate are ready.

Not once set to 1 and contract balances are written
to a database once, disabling this constant will
mess up contract_balances!

Change-Id: I080460395627202f3f5a386022de643577f4f3c2
changes/05/2305/2
Rene Krenn 10 years ago
parent b9271ec5d8
commit f3b711a050

@ -218,6 +218,7 @@ sub POST :Allow {
form => $form,
exceptions => [ "contact_id", "billing_profile_id", "profile_package_id" ],
);
$resource->{profile_package_id} = undef unless NGCP::Panel::Utils::ProfilePackages::ENABLE_PROFILE_PACKAGES;
my $mappings_to_create = [];
last unless NGCP::Panel::Utils::Contract::prepare_billing_mappings(

@ -153,6 +153,7 @@ sub create :Chained('list_customer') :PathPart('create') :Args(0) {
$form->values->{$_.'_id'} = $form->values->{$_}{id} || undef;
delete $form->values->{$_};
}
$form->values->{profile_package_id} = undef unless NGCP::Panel::Utils::ProfilePackages::ENABLE_PROFILE_PACKAGES;
$form->values->{create_timestamp} = $form->values->{modify_timestamp} = NGCP::Panel::Utils::DateTime::current_local;
$form->values->{external_id} = $form->field('external_id')->value;
unless($form->values->{max_subscribers} && length($form->values->{max_subscribers})) {
@ -455,6 +456,7 @@ sub edit :Chained('base_restricted') :PathPart('edit') :Args(0) {
$form->values->{$_.'_id'} = $form->values->{$_}{id} || undef;
delete $form->values->{$_};
}
$form->values->{profile_package_id} = undef unless NGCP::Panel::Utils::ProfilePackages::ENABLE_PROFILE_PACKAGES;
$form->values->{modify_timestamp} = $now;
$form->values->{external_id} = $form->field('external_id')->value;
unless($form->values->{max_subscribers} && length($form->values->{max_subscribers})) {

@ -162,6 +162,7 @@ sub update_customer {
resource => $resource,
exceptions => [ "contact_id", "billing_profile_id", "profile_package_id" ],
);
$resource->{profile_package_id} = undef unless NGCP::Panel::Utils::ProfilePackages::ENABLE_PROFILE_PACKAGES;
#my $now = NGCP::Panel::Utils::DateTime::current_local;

@ -36,6 +36,7 @@ use constant _DEFAULT_PROFILE_FREE_TIME => 0;
use constant _DEFAULT_PROFILE_FREE_CASH => 0.0;
#use constant _DEFAULT_NOTOPUP_DISCARD_INTERVALS => undef;
use constant ENABLE_PROFILE_PACKAGES => 0;
sub get_contract_balance {
my %params = @_;
@ -256,7 +257,10 @@ sub topup_contract_balance {
my $old_package = $contract->profile_package;
$package = $voucher_package // $old_package;
my $topup_amount = ($voucher ? $voucher->amount : $amount) // 0.0;
$voucher_package = undef unless ENABLE_PROFILE_PACKAGES;
$package = undef unless ENABLE_PROFILE_PACKAGES;
my $mappings_to_create = [];
if ($package) { #always apply (old or new) topup profiles
$topup_amount -= $package->service_charge;

@ -26,9 +26,10 @@ BEGIN {
unshift(@INC,'../lib');
}
use NGCP::Panel::Utils::DateTime qw();
use NGCP::Panel::Utils::ProfilePackages qw();
my $is_local_env = 0;
my $enable_profile_packages = NGCP::Panel::Utils::ProfilePackages::ENABLE_PROFILE_PACKAGES;
use Config::General;
my $catalyst_config;
@ -166,7 +167,7 @@ my $billingprofile = _create_billing_profile("test_default");
my $tb; my $tb_cnt;
if (_get_allow_fake_client_time()) {
if (_get_allow_fake_client_time() && $enable_profile_packages) {
{
#_start_recording();
@ -427,7 +428,7 @@ if (_get_allow_fake_client_time()) {
_set_time(NGCP::Panel::Utils::DateTime::from_string($ts));
$customer = _switch_package($customer,$prof_package_topup);
sleep(1); #sigh
_check_interval_history($customer,[
{ start => '2014-10-01 00:00:00', stop => '~2014-10-04 13:00:00'},
{ start => '~2014-10-04 13:00:00', stop => $infinite_future},
@ -517,7 +518,7 @@ if (_get_allow_fake_client_time()) {
my $intervals_a = $t_a->join();
my $intervals_b = $t_b->join();
my $t2 = time;
is_deeply([ sort { $a->{id} cmp $b->{id} } @{ $intervals_b->{_embedded}->{'ngcp:balanceintervals'} } ],$intervals_a->{_embedded}->{'ngcp:balanceintervals'},'compare interval collection results of threaded requests deeply');
is_deeply([ sort { $a->{id} <=> $b->{id} } @{ $intervals_b->{_embedded}->{'ngcp:balanceintervals'} } ],$intervals_a->{_embedded}->{'ngcp:balanceintervals'},'compare interval collection results of threaded requests deeply');
ok($t2 - $t1 > 2*$delay,'expected delay to assume requests were processed after another');
} else {
@ -528,7 +529,7 @@ if (_get_allow_fake_client_time()) {
}
{ #test balanceintervals root collection and item
_create_customers_threaded(3) unless _get_allow_fake_client_time();
_create_customers_threaded(3) unless _get_allow_fake_client_time() && $enable_profile_packages;
my $total_count = (scalar keys %customer_map);
my $nexturi = $uri.'/api/balanceintervals/?page=1&rows=' . ((not defined $total_count or $total_count <= 2) ? 2 : $total_count - 1) . '&contact_id='.$custcontact->{id};

@ -10,7 +10,13 @@ use DateTime qw();
use DateTime::Format::Strptime qw();
use DateTime::Format::ISO8601 qw();
BEGIN {
unshift(@INC,'../lib');
}
use NGCP::Panel::Utils::ProfilePackages qw();
my $is_local_env = 0;
my $enable_profile_packages = NGCP::Panel::Utils::ProfilePackages::ENABLE_PROFILE_PACKAGES;
my $uri = $ENV{CATALYST_SERVER} || ('https://'.hostfqdn.':4443');
@ -737,7 +743,7 @@ my @allcustomers = ();
}
{
if ($enable_profile_packages) {
$req = HTTP::Request->new('POST', $uri.'/api/billingprofiles/');
$req->header('Content-Type' => 'application/json');

@ -9,7 +9,13 @@ use URI::Escape qw();
use JSON::PP;
use LWP::Debug;
BEGIN {
unshift(@INC,'../lib');
}
use NGCP::Panel::Utils::ProfilePackages qw();
my $is_local_env = 0;
my $enable_profile_packages = NGCP::Panel::Utils::ProfilePackages::ENABLE_PROFILE_PACKAGES;
my $uri = $ENV{CATALYST_SERVER} || ('https://'.hostfqdn.':4443');
@ -91,7 +97,7 @@ $res = $ua->request($req);
is($res->code, 200, "fetch POSTed billingnetwork");
my $billingnetwork = JSON::from_json($res->decoded_content);
{
if ($enable_profile_packages) {
$req = HTTP::Request->new('POST', $uri.'/api/profilepackages/');
$req->header('Content-Type' => 'application/json');
$req->header('Prefer' => 'return=representation');
@ -152,7 +158,7 @@ my $billingnetwork = JSON::from_json($res->decoded_content);
}
{
if ($enable_profile_packages) {
my @profile_packages = ();

Loading…
Cancel
Save