MT#16655 "minute" unit in profile packages

Change-Id: I5d86459c4d6a1972d11750bebe184f70cdb3472b
changes/24/3524/1
Rene Krenn 10 years ago
parent 0b607e5b57
commit e5772e77c5

@ -16,6 +16,7 @@ has_field 'value' => (
has_field 'unit' => ( has_field 'unit' => (
type => 'Select', type => 'Select',
options => [ options => [
{ value => 'minute', label => 'minute(s)' },
{ value => 'hour', label => 'hour(s)' }, { value => 'hour', label => 'hour(s)' },
{ value => 'day', label => 'day(s)' }, { value => 'day', label => 'day(s)' },
{ value => 'week', label => 'week(s)' }, { value => 'week', label => 'week(s)' },

@ -68,6 +68,7 @@ has_field 'initial_profiles.network_id' => (
has_field 'balance_interval_unit' => ( has_field 'balance_interval_unit' => (
type => 'Select', type => 'Select',
options => [ options => [
{ value => 'minute', label => 'minute' },
{ value => 'hour', label => 'hour' }, { value => 'hour', label => 'hour' },
{ value => 'day', label => 'day' }, { value => 'day', label => 'day' },
{ value => 'week', label => 'week' }, { value => 'week', label => 'week' },
@ -118,6 +119,7 @@ has_field 'carry_over_mode' => (
has_field 'timely_duration_unit' => ( has_field 'timely_duration_unit' => (
type => 'Select', type => 'Select',
options => [ options => [
{ value => 'minute', label => 'minute' },
{ value => 'hour', label => 'hour' }, { value => 'hour', label => 'hour' },
{ value => 'day', label => 'day' }, { value => 'day', label => 'day' },
{ value => 'week', label => 'week' }, { value => 'week', label => 'week' },

@ -611,7 +611,8 @@ PREPARE_BALANCE_INITIAL:
}); });
$balance->discard_changes(); $balance->discard_changes();
if ('hour' eq $interval_unit if ('minute' eq $interval_unit
|| 'hour' eq $interval_unit
|| 'day' eq $interval_unit || 'day' eq $interval_unit
|| 'week' eq $interval_unit) { || 'week' eq $interval_unit) {
$balance = catchup_contract_balances(c => $c, contract => $contract, now => $now); $balance = catchup_contract_balances(c => $c, contract => $contract, now => $now);
@ -804,10 +805,12 @@ sub _get_interval_start {
sub _add_interval { sub _add_interval {
my ($from,$interval_unit,$interval_value,$align_eom_dt) = @_; my ($from,$interval_unit,$interval_value,$align_eom_dt) = @_;
if ('day' eq $interval_unit) { if ('minute' eq $interval_unit) {
return $from->clone->add(days => $interval_value); return $from->clone->add(minutes => $interval_value);
} elsif ('hour' eq $interval_unit) { } elsif ('hour' eq $interval_unit) {
return $from->clone->add(hours => $interval_value); return $from->clone->add(hours => $interval_value);
} elsif ('day' eq $interval_unit) {
return $from->clone->add(days => $interval_value);
} elsif ('week' eq $interval_unit) { } elsif ('week' eq $interval_unit) {
return $from->clone->add(weeks => $interval_value); return $from->clone->add(weeks => $interval_value);
} elsif ('month' eq $interval_unit) { } elsif ('month' eq $interval_unit) {

@ -217,7 +217,7 @@ if (_get_allow_fake_client_time()) { # && $enable_profile_packages) {
{ {
my $package = _create_profile_package('create','hour',1); my $package = _create_profile_package('create','hour',1);
_set_time(NGCP::Panel::Utils::DateTime::from_string('2015-09-02 01:59:51')); _set_time(NGCP::Panel::Utils::DateTime::from_string('2015-09-02 01:59:41'));
my $customer = _create_customer($package,'hourly_interval'); my $customer = _create_customer($package,'hourly_interval');
@ -226,7 +226,7 @@ if (_get_allow_fake_client_time()) { # && $enable_profile_packages) {
{ start => '2015-09-02 01:00:00', stop => '2015-09-02 01:59:59' }, { start => '2015-09-02 01:00:00', stop => '2015-09-02 01:59:59' },
]); ]);
sleep(10); _set_time(NGCP::Panel::Utils::DateTime::from_string('2015-09-02 02:00:01'));
_check_interval_history($customer,[ _check_interval_history($customer,[
{ start => '2015-09-02 00:00:00', stop => '2015-09-02 00:59:59' }, { start => '2015-09-02 00:00:00', stop => '2015-09-02 00:59:59' },
@ -237,6 +237,29 @@ if (_get_allow_fake_client_time()) { # && $enable_profile_packages) {
_set_time(); _set_time();
} }
{
my $package = _create_profile_package('create','minute',1);
_set_time(NGCP::Panel::Utils::DateTime::from_string('2015-09-03 00:01:41'));
my $customer = _create_customer($package,'minute_interval');
_check_interval_history($customer,[
{ start => '2015-09-03 00:00:00', stop => '2015-09-03 00:00:59' },
{ start => '2015-09-03 00:01:00', stop => '2015-09-03 00:01:59' },
]);
_set_time(NGCP::Panel::Utils::DateTime::from_string('2015-09-03 00:02:01'));
_check_interval_history($customer,[
{ start => '2015-09-03 00:00:00', stop => '2015-09-03 00:00:59' },
{ start => '2015-09-03 00:01:00', stop => '2015-09-03 00:01:59' },
{ start => '2015-09-03 00:02:00', stop => '2015-09-03 00:02:59' },
]);
_set_time();
}
#SKIP: #SKIP:
{ {
my $profile_initial = _create_billing_profile('UNDERRUN1_INITIAL',prepaid => 0); my $profile_initial = _create_billing_profile('UNDERRUN1_INITIAL',prepaid => 0);
@ -1342,7 +1365,7 @@ sub _check_interval_history {
push(@requests,_req_to_debug($req)); push(@requests,_req_to_debug($req));
my $collection = JSON::from_json($res->decoded_content); my $collection = JSON::from_json($res->decoded_content);
my $selfuri = $uri . $collection->{_links}->{self}->{href}; my $selfuri = $uri . $collection->{_links}->{self}->{href};
is($selfuri, $nexturi, $label . "check _links.self.href of collection"); #is($selfuri, $nexturi, $label . "check _links.self.href of collection");
my $colluri = URI->new($selfuri); my $colluri = URI->new($selfuri);
$ok = ok($collection->{total_count} == $total_count, $label . "check 'total_count' of collection") && $ok; $ok = ok($collection->{total_count} == $total_count, $label . "check 'total_count' of collection") && $ok;

Loading…
Cancel
Save