diff --git a/lib/NGCP/Panel/Controller/API/BillingProfilesItem.pm b/lib/NGCP/Panel/Controller/API/BillingProfilesItem.pm index 8e70f12371..62d42b785e 100644 --- a/lib/NGCP/Panel/Controller/API/BillingProfilesItem.pm +++ b/lib/NGCP/Panel/Controller/API/BillingProfilesItem.pm @@ -164,6 +164,7 @@ sub DELETE :Allow { my $billing_profile = $self->item_by_id($c, $id); last unless $self->resource_exists($c, billingprofile => $billing_profile); + $billing_profile = $self->_load_profile_usage_columns($c, $billing_profile); last unless NGCP::Panel::Utils::Reseller::check_reseller_delete_item($c, $billing_profile->reseller_id, sub { my ($err) = @_; $self->error($c, HTTP_UNPROCESSABLE_ENTITY, $err); diff --git a/lib/NGCP/Panel/Utils/Billing.pm b/lib/NGCP/Panel/Utils/Billing.pm index 8c4d14e993..5dcc436fea 100644 --- a/lib/NGCP/Panel/Utils/Billing.pm +++ b/lib/NGCP/Panel/Utils/Billing.pm @@ -31,19 +31,24 @@ sub check_profile_update_item { # return 0 unless &{$err_code}("The prepaid rating library is mandatory for a prepaid profile.",'prepaid_library'); #} - my $contract_exists = $old_item->get_column('contract_exists'); - my $contract_cnt = $old_item->get_column('contract_cnt'); + my $contract_exists = $old_item->has_column_loaded('contract_exists') + ? $old_item->get_column('contract_exists') : undef; + my $contract_cnt = $old_item->has_column_loaded('contract_cnt') + ? $old_item->get_column('contract_cnt') : undef; #my $package_cnt = $old_item->get_column('package_cnt'); if ($contract_exists + && $new_resource && defined $new_resource->{interval_charge} && $old_item->interval_charge != $new_resource->{interval_charge}) { return 0 unless &{$err_code}("Interval charge cannot be changed (profile linked to $contract_cnt contracts).",'interval_charge'); } if ($contract_exists + && $new_resource && defined $new_resource->{interval_free_time} && $old_item->interval_free_time != $new_resource->{interval_free_time}) { return 0 unless &{$err_code}("Interval free time cannot be changed (profile linked to $contract_cnt contracts).",'interval_free_time'); } if ($contract_exists + && $new_resource && defined $new_resource->{interval_free_cash} && $old_item->interval_free_cash != $new_resource->{interval_free_cash}) { return 0 unless &{$err_code}("Interval free cash cannot be changed (profile linked to $contract_cnt contracts).",'interval_free_cash'); }