diff --git a/lib/NGCP/Panel/Controller/Contract.pm b/lib/NGCP/Panel/Controller/Contract.pm index 575afb8f78..4993929de3 100644 --- a/lib/NGCP/Panel/Controller/Contract.pm +++ b/lib/NGCP/Panel/Controller/Contract.pm @@ -33,7 +33,9 @@ sub contract_list :Chained('/') :PathPart('contract') :CaptureArgs(0) { my $now = NGCP::Panel::Utils::DateTime::current_local; my $rs = NGCP::Panel::Utils::Contract::get_contract_rs( - schema => $c->model('DB'),now => $now); + schema => $c->model('DB'), + now => $now + ); unless($c->user->is_superuser) { $rs = $rs->search({ 'contact.reseller_id' => $c->user->reseller_id, @@ -450,7 +452,9 @@ sub reseller_ajax_contract_filter :Chained('reseller_list') :PathPart('ajax/cont } my $now = $c->stash->{now}; my $rs = NGCP::Panel::Utils::Contract::get_contract_rs( - schema => $c->model('DB'), now => $now) + schema => $c->model('DB'), + now => $now, + contract_id => $contract_id ) ->search_rs({ 'me.id' => $contract_id, }); diff --git a/lib/NGCP/Panel/Controller/Invoice.pm b/lib/NGCP/Panel/Controller/Invoice.pm index 3ee0b7d453..589bffa922 100644 --- a/lib/NGCP/Panel/Controller/Invoice.pm +++ b/lib/NGCP/Panel/Controller/Invoice.pm @@ -164,7 +164,7 @@ sub create :Chained('inv_list') :PathPart('create') :Args() :Does(ACL) :ACLDetac $schema->set_transaction_isolation('READ COMMITTED'); $schema->txn_do(sub { my $contract_id = $form->values->{contract}{id}; - my $customer_rs = NGCP::Panel::Utils::Contract::get_customer_rs(c => $c); + my $customer_rs = NGCP::Panel::Utils::Contract::get_customer_rs(c => $c, contract_id => $contract_id); my $customer = $customer_rs->find({ 'me.id' => $contract_id }); unless($customer) { NGCP::Panel::Utils::Message::error( diff --git a/lib/NGCP/Panel/Controller/Reseller.pm b/lib/NGCP/Panel/Controller/Reseller.pm index 84a9e6cb25..2a44ae9d5d 100644 --- a/lib/NGCP/Panel/Controller/Reseller.pm +++ b/lib/NGCP/Panel/Controller/Reseller.pm @@ -431,9 +431,9 @@ sub create_defaults :Path('create_defaults') :Args(0) :Does(ACL) :ACLDetachTo('/ contract_id => $r{contracts}->id, }); my $mappings_to_create = []; - my $resource = { $r{contracts}->get_inflated_columns }; - $resource->{billing_profile_id} = 1; - $resource->{type} = 'reseller'; + my $resource = { $r{contracts}->get_inflated_columns }; + $resource->{billing_profile_id} = 1; + $resource->{type} = 'reseller'; NGCP::Panel::Utils::Contract::prepare_billing_mappings( c => $c, resource => $resource, @@ -442,18 +442,18 @@ sub create_defaults :Path('create_defaults') :Args(0) :Does(ACL) :ACLDetachTo('/ err_code => sub { my ($err) = @_; die( [$err, "showdetails"] ); - }); - foreach my $mapping (@$mappings_to_create) { + }); + foreach my $mapping (@$mappings_to_create) { $r{contracts}->billing_mappings->create($mapping); } - $r{contracts} = NGCP::Panel::Utils::Contract::get_contract_rs( - schema => $c->model('DB'))->search(undef, { - '+select' => 'billing_mappings.id', - '+as' => 'bmid', - }) - ->find($r{contracts}->id); - $r{billing_mappings} = $r{contracts}->billing_mappings; - + $r{contracts} = NGCP::Panel::Utils::Contract::get_contract_rs( + schema => $c->model('DB'), + contract_id => $r{contracts}->id )->search(undef, { + '+select' => 'billing_mappings.id', + '+as' => 'bmid', + })->find($r{contracts}->id); + $r{billing_mappings} = $r{contracts}->billing_mappings; + $r{admins} = $billing->resultset('admins')->create({ %{ $defaults{admins} }, reseller_id => $r{resellers}->id, diff --git a/lib/NGCP/Panel/Controller/Sound.pm b/lib/NGCP/Panel/Controller/Sound.pm index 4608f2e67a..7453c9f5bc 100644 --- a/lib/NGCP/Panel/Controller/Sound.pm +++ b/lib/NGCP/Panel/Controller/Sound.pm @@ -40,9 +40,11 @@ sub auto :Private { if($c->user->roles eq "subscriberadmin") { my $contract_id = $c->user->account_id; my $contract_select_rs = NGCP::Panel::Utils::Contract::get_contract_rs( - schema => $c->model('DB')); + schema => $c->model('DB'), + contract_id => $contract_id, + ); $contract_select_rs = $contract_select_rs->search({ 'me.id' => $contract_id }); - my $product_id = $contract_select_rs->first->get_column('product_id'); + my $product_id = $contract_select_rs->first ? $contract_select_rs->first->get_column('product_id') : undef; unless($product_id) { NGCP::Panel::Utils::Message::error( c => $c, diff --git a/lib/NGCP/Panel/Controller/Subscriber.pm b/lib/NGCP/Panel/Controller/Subscriber.pm index d422b1b083..e81a2b94bb 100644 --- a/lib/NGCP/Panel/Controller/Subscriber.pm +++ b/lib/NGCP/Panel/Controller/Subscriber.pm @@ -160,7 +160,7 @@ sub create_list :Chained('sub_list') :PathPart('create') :Args(0) :Does(ACL) :AC $schema->set_transaction_isolation('READ COMMITTED'); $schema->txn_do(sub { my $preferences = {}; - my $contract_rs = NGCP::Panel::Utils::Contract::get_customer_rs(c => $c); + my $contract_rs = NGCP::Panel::Utils::Contract::get_customer_rs(c => $c, contract_id => $form->params->{contract}{id} ); my $contract = $contract_rs->find({ 'me.id' => $form->params->{contract}{id}, }); @@ -234,7 +234,7 @@ sub base :Chained('sub_list') :PathPart('') :CaptureArgs(1) { $c->stash(subscriber => $res); $c->stash->{contract} = $c->stash->{subscriber}->contract; - my $contract_rs = NGCP::Panel::Utils::Contract::get_customer_rs(c => $c); + my $contract_rs = NGCP::Panel::Utils::Contract::get_customer_rs(c => $c, contract_id => $c->stash->{contract}->id ); my $contract = $contract_rs->find({ 'me.id' => $c->stash->{contract}->id, });