MT#5661 change selection of customers when bprof is updated

only those customers which have this billing profile
currently active are considered
this concerns the change of the prepaid flag
gjungwirth/test_sleeps
Gerhard Jungwirth 12 years ago committed by Andreas Granig
parent f31c2fcc88
commit 029c51fad1

@ -13,6 +13,7 @@ use NGCP::Panel::Form::BillingZone;
use NGCP::Panel::Form::BillingPeaktimeWeekdays;
use NGCP::Panel::Form::BillingPeaktimeSpecial;
use NGCP::Panel::Form::BillingFeeUpload;
use NGCP::Panel::Utils::Contract;
use NGCP::Panel::Utils::Message;
use NGCP::Panel::Utils::Navigation;
use NGCP::Panel::Utils::Datatables;
@ -138,20 +139,16 @@ sub edit :Chained('base') :PathPart('edit') {
# if prepaid flag changed, update all subscribers for customers
# who currently have the billing profile active
my $rs = $schema->resultset('billing_mappings')->search({
start_date => [ -or =>
{ '<=' => NGCP::Panel::Utils::DateTime::current_local },
{ -is => undef },
],
end_date => [ -or =>
{ '>=' => NGCP::Panel::Utils::DateTime::current_local },
{ -is => undef },
],
billing_profile_id => $c->stash->{profile_result}->id,
});
my $contract_rs = NGCP::Panel::Utils::Contract::get_contract_rs(
schema => $c->model('DB'));
if($old_prepaid && !$c->stash->{profile_result}->prepaid) {
foreach my $map($rs->all) {
my $contract = $map->contract;
next unless($contract->contact->reseller_id); # skip non-customers
my $chosen_contract = $contract_rs->find({id => $contract->id});
next unless( defined $chosen_contract && $chosen_contract->get_column('billing_mapping_id') == $map->id ); # is not current mapping
foreach my $sub($contract->voip_subscribers->all) {
my $prov_sub = $sub->provisioning_voip_subscriber;
next unless($sub->provisioning_voip_subscriber);
@ -166,6 +163,8 @@ sub edit :Chained('base') :PathPart('edit') {
foreach my $map($rs->all) {
my $contract = $map->contract;
next unless($contract->contact->reseller_id); # skip non-customers
my $chosen_contract = $contract_rs->find({id => $contract->id});
next unless( defined $chosen_contract && $chosen_contract->get_column('billing_mapping_id') == $map->id ); # is not current mapping
foreach my $sub($contract->voip_subscribers->all) {
my $prov_sub = $sub->provisioning_voip_subscriber;
next unless($prov_sub);

@ -193,7 +193,6 @@ sub create_list :Chained('sub_list') :PathPart('create') :Args(0) :Does(ACL) :AC
my $rs = NGCP::Panel::Utils::Contract::get_contract_rs(
schema => $c->model('DB'));
my $billing_contract = $rs->find($contract->id);
use Data::Printer; p $billing_contract;
my $billing_mapping = $c->model('DB')->resultset('billing_mappings')->find(
$billing_contract->get_column('billing_mapping_id'));

Loading…
Cancel
Save