From 782539c26767a1659e1dbfc74fd99332e1f8866c Mon Sep 17 00:00:00 2001 From: Flaviu Mates Date: Thu, 5 Dec 2019 16:49:42 +0200 Subject: [PATCH] TT#70857 - Implement UI and API support for one time fees * Add the new fields to the Billing fees form * Add the new fields to the csv order for download and upload to work * Change tests to include the new fees fields Change-Id: If45bfe4f39ccd0283c72071489f5930eab2c37e9 --- etc/ngcp_panel.conf | 4 +++ lib/NGCP/Panel/Form/BillingFee.pm | 43 +++++++++++++++++++++++++++++++ lib/NGCP/Panel/Utils/Billing.pm | 2 ++ t/api-rest/api-billingfees.t | 4 +++ t/api-rest2/BillingFees.yaml | 12 +++++++++ 5 files changed, 65 insertions(+) diff --git a/etc/ngcp_panel.conf b/etc/ngcp_panel.conf index 664ea542dc..eb91bbed47 100644 --- a/etc/ngcp_panel.conf +++ b/etc/ngcp_panel.conf @@ -123,6 +123,10 @@ log4perl.appender.Default.layout.ConversionPattern=%d{ISO8601} [%p] [%F +%L] %m{ element_order offpeak_follow_interval element_order use_free_time element_order match_mode + element_order onpeak_extra_rate + element_order onpeak_extra_second + element_order offpeak_extra_rate + element_order offpeak_extra_second diff --git a/lib/NGCP/Panel/Form/BillingFee.pm b/lib/NGCP/Panel/Form/BillingFee.pm index 8e2a440b60..24e96e7ceb 100644 --- a/lib/NGCP/Panel/Form/BillingFee.pm +++ b/lib/NGCP/Panel/Form/BillingFee.pm @@ -164,6 +164,48 @@ has_field 'use_free_time' => ( default => 0, ); +has_field 'onpeak_extra_rate' => ( + type => 'Float', + size => 15, + precision => 14, + element_attr => { + rel => ['tooltip'], + title => ['The cost per second of each extra interval during onpeak hours in cents (e.g. 0.70 cents).'] + }, + default => 0, +); + +has_field 'onpeak_extra_second' => ( + type => 'Integer', + element_attr => { + rel => ['tooltip'], + title => ['The length of each extra interval during onpeak hours in seconds (e.g. 30).'] + }, + default => undef, + required => 0, +); + +has_field 'offpeak_extra_rate' => ( + type => 'Float', + size => 15, + precision => 14, + element_attr => { + rel => ['tooltip'], + title => ['The cost per second of each extra interval during offpeak hours in cents (e.g. 0.70 cents).'] + }, + default => 0, +); + +has_field 'offpeak_extra_second' => ( + type => 'Integer', + element_attr => { + rel => ['tooltip'], + title => ['The length of each extra interval during offpeak hours in seconds (e.g. 30).'] + }, + default => undef, + required => 0, +); + has_field 'save' => ( type => 'Submit', value => 'Save', @@ -178,6 +220,7 @@ has_block 'fields' => ( onpeak_init_rate onpeak_init_interval onpeak_follow_rate onpeak_follow_interval offpeak_init_rate offpeak_init_interval offpeak_follow_rate offpeak_follow_interval use_free_time + onpeak_extra_rate onpeak_extra_second offpeak_extra_rate offpeak_extra_second /], ); diff --git a/lib/NGCP/Panel/Utils/Billing.pm b/lib/NGCP/Panel/Utils/Billing.pm index 0ab432e20a..34660f273b 100644 --- a/lib/NGCP/Panel/Utils/Billing.pm +++ b/lib/NGCP/Panel/Utils/Billing.pm @@ -251,6 +251,8 @@ sub process_billing_fees{ push @fails, $linenum; next; } + $row->{onpeak_extra_second} = undef if $row->{onpeak_extra_second} eq ''; + $row->{offpeak_extra_second} = undef if $row->{offpeak_extra_second} eq ''; my $k = $row->{zone}.'__NGCP__'.$row->{zone_detail}; unless(exists $zones{$k}) { my $zone = $profile->billing_zones->find_or_create({ diff --git a/t/api-rest/api-billingfees.t b/t/api-rest/api-billingfees.t index e75e206fdd..bf61e773dc 100644 --- a/t/api-rest/api-billingfees.t +++ b/t/api-rest/api-billingfees.t @@ -23,6 +23,10 @@ $fake_data->set_data_from_script({ offpeak_init_interval => 60, offpeak_follow_rate => 0.5, offpeak_follow_interval => 30, + onpeak_extra_rate => 1, + onpeak_extra_second => 30, + offpeak_extra_rate => 0.5, + offpeak_extra_second => 60, }, 'query' => ['billing_zone_id','destination','direction','billing_profile_id'], }, diff --git a/t/api-rest2/BillingFees.yaml b/t/api-rest2/BillingFees.yaml index 1ab8e975ee..366f24480c 100644 --- a/t/api-rest2/BillingFees.yaml +++ b/t/api-rest2/BillingFees.yaml @@ -38,6 +38,10 @@ offpeak_init_interval: 60 offpeak_follow_rate: 0.5 offpeak_follow_interval: 30 + onpeak_extra_rate: 1 + onpeak_extra_second: 30 + offpeak_extra_rate: 0.5 + offpeak_extra_second: 60 retain: billingfees_path1: header.location conditions: @@ -65,6 +69,10 @@ offpeak_init_interval: 60 offpeak_follow_rate: 0.5 offpeak_follow_interval: 30 + onpeak_extra_rate: 1 + onpeak_extra_second: 30 + offpeak_extra_rate: 0.5 + offpeak_extra_second: 60 retain: billingfees_path2: header.location conditions: @@ -92,6 +100,10 @@ offpeak_init_interval: 60 offpeak_follow_rate: 0.5 offpeak_follow_interval: 30 + onpeak_extra_rate: 1 + onpeak_extra_second: 30 + offpeak_extra_rate: 0.5 + offpeak_extra_second: 60 retain: billingfees_path3: header.location conditions: