From eaa4fea245aac492dca2b433448044472c348f00 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Wed, 18 Jun 2014 17:22:05 +0200 Subject: [PATCH] MT#7555 Properly terminate subs on customer edit. Recursively terminate subscribers and everything else if a customer is terminated via the customer edit form. --- lib/NGCP/Panel/Controller/Customer.pm | 9 +++++++++ lib/NGCP/Panel/Controller/Subscriber.pm | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/NGCP/Panel/Controller/Customer.pm b/lib/NGCP/Panel/Controller/Customer.pm index 77686627dd..4e4a8916dd 100644 --- a/lib/NGCP/Panel/Controller/Customer.pm +++ b/lib/NGCP/Panel/Controller/Customer.pm @@ -394,9 +394,18 @@ sub edit :Chained('base') :PathPart('edit') :Args(0) { my $old_bprof_id = $billing_mapping->billing_profile_id; my $old_prepaid = $billing_mapping->billing_profile->prepaid; my $old_ext_id = $contract->external_id // ''; + my $old_status = $contract->status; $contract->update($form->params); my $new_ext_id = $contract->external_id // ''; + # if status changed, populate it down the chain + if($contract->status ne $old_status) { + NGCP::Panel::Utils::Contract::recursively_lock_contract( + c => $c, + contract => $contract, + ); + } + if($old_ext_id ne $new_ext_id) { # undef is '' so we don't bail out here foreach my $sub($contract->voip_subscribers->all) { my $prov_sub = $sub->provisioning_voip_subscriber; diff --git a/lib/NGCP/Panel/Controller/Subscriber.pm b/lib/NGCP/Panel/Controller/Subscriber.pm index 81c03f034b..910f698524 100644 --- a/lib/NGCP/Panel/Controller/Subscriber.pm +++ b/lib/NGCP/Panel/Controller/Subscriber.pm @@ -227,6 +227,14 @@ sub base :Chained('sub_list') :PathPart('') :CaptureArgs(1) { my $contract = $contract_rs->find({ 'me.id' => $c->stash->{contract}->id, }); + unless(defined $contract) { + NGCP::Panel::Utils::Message->error( + c => $c, + error => "subscriber id '$subscriber_id' points to non-existing contract id", + desc => $c->loc('Contract does not exist for subscriber'), + ); + NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for('/subscriber')); + } my $billing_mapping = $contract->billing_mappings->find($contract->get_column('bmid')); $c->stash->{billing_mapping} = $billing_mapping;