From fcf1f7c94755d739d39d10b3f7272c46177044b5 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Tue, 12 Apr 2016 22:51:42 +0300 Subject: [PATCH] MT#19035 Don't save billing_fee_raw data We will not need to insert lower id from billing_fees_raw as we have it already in billing_fees Change-Id: I03dbe5fcf02a63d1a66f4106afe86d8f8b261019 --- lib/NGCP/Panel/Utils/Billing.pm | 10 ++++++++++ t/api-rest/api-billingfees.t | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/lib/NGCP/Panel/Utils/Billing.pm b/lib/NGCP/Panel/Utils/Billing.pm index ebf248b985..79a6bd3076 100644 --- a/lib/NGCP/Panel/Utils/Billing.pm +++ b/lib/NGCP/Panel/Utils/Billing.pm @@ -250,7 +250,17 @@ sub insert_unique_billing_fees{ my(%params) = @_; my($c,$schema,$profile,$fees,$return_created) = @params{qw/c schema profile fees return_created/}; $return_created //= 0; + + #while we use lower id we don't need insert records from billing_fees, they are already contain in billing_fees with lower id + $profile->billing_fees_raw->delete(); + + $schema->storage->dbh_do(sub{ + my ($storage, $dbh) = @_; + (my ($auto_increment)) = $dbh->selectrow_array('select `AUTO_INCREMENT` from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = "billing" AND TABLE_NAME = "billing_fees"'); + $dbh->do('alter table billing.billing_fees_raw auto_increment='.$auto_increment); + }); my $created_fees_raw = $profile->billing_fees_raw->populate($fees); + $schema->storage->dbh_do(sub{ my ($storage, $dbh) = @_; $c->log->debug('call billing.fill_billing_fees('.$profile->id.')'); diff --git a/t/api-rest/api-billingfees.t b/t/api-rest/api-billingfees.t index d24c8aede4..981d36674a 100644 --- a/t/api-rest/api-billingfees.t +++ b/t/api-rest/api-billingfees.t @@ -116,6 +116,9 @@ $test_machine->check_bundle(); { my($res,$item_put,$req) = $test_machine->check_get2put(); $test_machine->check_embedded($item_put->{content}); + #check create after edit + #19035 + $test_machine->check_create_correct( 1, sub{ $_[0]->{destination} .= $_[1]->{i} + 3 ; } ); } { my($res,$mod_fee) = $test_machine->check_patch_correct( [ { op => 'replace', path => '/direction', value => 'in' } ] ); @@ -139,6 +142,7 @@ $test_machine->check_bundle(); } $test_machine->clear_test_data_all(); +$fake_data->created({}); { my $uri = $test_machine->normalize_uri('/api/billingzones/'.$test_machine->DATA_ITEM->{billing_zone_id});