MT#13717 fix journal tests - reseller constraint

..and cosmetics in the profile schedule lists in the panel UI

Change-Id: Ieb6fe62351b0cc31be2fcaa92686bfc74e50a035
changes/25/2025/1
Rene Krenn 10 years ago
parent 45cd24c468
commit 68d8e459c8

@ -93,7 +93,7 @@ sub base :Chained('contract_list') :PathPart('') :CaptureArgs(1) {
}
my $now = NGCP::Panel::Utils::DateTime::current_local;
my $billing_mappings_ordered = NGCP::Panel::Utils::Contract::billing_mappings_ordered($contract_rs->first->billing_mappings,$now);
my $billing_mappings_ordered = NGCP::Panel::Utils::Contract::billing_mappings_ordered($contract_rs->first->billing_mappings,$now,$contract_first->get_column('bmid'));
my $future_billing_mappings = NGCP::Panel::Utils::Contract::billing_mappings_ordered(NGCP::Panel::Utils::Contract::future_billing_mappings($contract_rs->first->billing_mappings,$now));
$c->stash(contract => $contract_first);

@ -253,7 +253,7 @@ sub base :Chained('list_customer') :PathPart('') :CaptureArgs(1) {
}
my $now = NGCP::Panel::Utils::DateTime::current_local;
my $billing_mappings_ordered = NGCP::Panel::Utils::Contract::billing_mappings_ordered($contract_rs->first->billing_mappings,$now);
my $billing_mappings_ordered = NGCP::Panel::Utils::Contract::billing_mappings_ordered($contract_rs->first->billing_mappings,$now,$contract_rs->first->get_column('bmid'));
my $future_billing_mappings = NGCP::Panel::Utils::Contract::billing_mappings_ordered(NGCP::Panel::Utils::Contract::future_billing_mappings($contract_rs->first->billing_mappings,$now));
my $billing_mapping = $contract_rs->first->billing_mappings->find($contract_rs->first->get_column('bmid'));

@ -43,6 +43,11 @@ sub create_contract_balance {
my $profile = $params{profile};
my $schema = $params{schema} // $c->model('DB');
my $package;
if (defined $contract->contact->reseller_id && ($package = $contract->profile_package)) {
}
# first, calculate start and end time of current billing profile
# (we assume billing interval of 1 month)
@ -812,15 +817,24 @@ sub resource_from_mappings {
}
sub billing_mappings_ordered {
my ($rs,$now) = @_;
my ($rs,$now,$actual_bmid) = @_;
my $dtf;
$dtf = $rs->result_source->schema->storage->datetime_parser if defined $now;
my @select = ();
if ($now) {
push(@select,{ '' => \[ 'if(`me`.`start_date` is null,0,`me`.`start_date` > ?)', $dtf->format_datetime($now) ], -as => 'is_future' });
}
if ($actual_bmid) {
push(@select,{ '' => \[ '`me`.`id` = ?', $actual_bmid ], -as => 'is_actual' });
}
return $rs->search_rs(
{},
{ order_by => { '-asc' => ['start_date', 'id']},
(defined $now ? ('+select' => { '' => \[ 'if(`me`.`start_date` is null,0,`me`.`start_date` > ?)', $dtf->format_datetime($now) ], -as => 'is_future' }) : ()),
(scalar @select == 1 ? ('+select' => $select[0]) : ()),
(scalar @select > 1 ? ('+select' => \@select) : ()),
});
}

@ -2,6 +2,7 @@
<table class="table table-bordered table-striped table-highlight table-hover">
<thead>
<tr>
<th>[% c.loc('actual') %]</th>
<th>[% c.loc('Date') %]</th>
<th>[% c.loc('Billing Profile Name') %]</th>
</tr>
@ -10,6 +11,7 @@
[% IF billing_mappings_ordered_result.all -%]
[% FOR mapping IN billing_mappings_ordered_result.all -%]
<tr class="sw_action_row [% IF !mapping.get_column('is_future') -%]ngcp-entry-disabled[% END -%]">
<td>[% IF mapping.get_column('is_actual') -%]*[% END -%]</td>
<td>
[% mapping.start_date ? mapping.start_date : 'NULL' %] - [% mapping.end_date.defined ? mapping.end_date : 'NULL' %]
</td>

@ -2,6 +2,7 @@
<table class="table table-bordered table-striped table-highlight table-hover">
<thead>
<tr>
<th>[% c.loc('actual') %]</th>
<th>[% c.loc('Date') %]</th>
<th>[% c.loc('Billing Profile Name') %]</th>
<th>[% c.loc('Billing Network Name') %]</th>
@ -11,6 +12,7 @@
[% IF billing_mappings_ordered_result.all -%]
[% FOR mapping IN billing_mappings_ordered_result.all -%]
<tr class="sw_action_row [% IF !mapping.get_column('is_future') -%]ngcp-entry-disabled[% END -%]">
<td>[% IF mapping.get_column('is_actual') -%]*[% END -%]</td>
<td>
[% mapping.start_date ? mapping.start_date : 'NULL' %] - [% mapping.end_date.defined ? mapping.end_date : 'NULL' %]
</td>

@ -130,13 +130,14 @@
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#customer_details" href="#collapse_bilprofs">[% c.loc('Billing Profiles') %]</a>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#customer_details" href="#collapse_bilprofs">[% c.loc('Billing Profile Schedule') %]</a>
</div>
<div class="accordion-body collapse" id="collapse_bilprofs">
<div class="accordion-inner">
<table class="table table-bordered table-striped table-highlight table-hover">
<thead>
<tr>
<th>[% c.loc('actual') %]</th>
<th>[% c.loc('Date') %]</th>
<th>[% c.loc('Billing Profile Name') %]</th>
<th>[% c.loc('Billing Network Name') %]</th>
@ -144,7 +145,8 @@
</thead>
<tbody>
[% FOR mapping IN billing_mappings_ordered_result.all -%]
<tr class="sw_action_row">
<tr class="sw_action_row [% IF !mapping.get_column('is_future') -%]ngcp-entry-disabled[% END -%]">
<td>[% IF mapping.get_column('is_actual') -%]*[% END -%]</td>
<td>
[% mapping.start_date ? mapping.start_date : 'NULL' %] - [% mapping.end_date.defined ? mapping.end_date : 'NULL' %]
</td>

@ -17,7 +17,7 @@ my $json = JSON::PP->new();
$json->allow_blessed(1);
$json->convert_blessed(1);
my $is_local_env = 1;
my $is_local_env = 0;
my $mysql_sqlstrict = 1; #https://bugtracker.sipwise.com/view.php?id=12565
my $enable_journal_tests = 1;
@ -1957,11 +1957,23 @@ sub test_reseller {
[ { op => 'replace', path => '/reseller_id', value => $reseller->{id} } ]
));
$res = $ua->request($req);
is($res->code, 200, _get_request_test_message("PATCH test billingprofile"));
is($res->code, 422, _get_request_test_message("try to PATCH test billingprofile - change reseller id"));
$req = HTTP::Request->new('POST', $uri.'/api/billingprofiles/');
$req->header('Content-Type' => 'application/json');
$req->header('Prefer' => 'return=representation');
$req->content(JSON::to_json({
name => "test prof $t res $reseller->{id}",
handle => "testprofile".$t."_res".$reseller->{id},
reseller_id => $reseller->{id},
}));
$res = $ua->request($req);
is($res->code, 201, _get_request_test_message("POST another test billing profile"));
$billingprofile_uri = $uri.'/'.$res->header('Location');
$req = HTTP::Request->new('GET', $billingprofile_uri);
$res = $ua->request($req);
is($res->code, 200, _get_request_test_message("fetch PATCHed test billingprofile"));
my $billingprofile = JSON::from_json($res->decoded_content);
is($res->code, 200, _get_request_test_message("fetch POSTed billing profile"));
my $billingprofile = JSON::from_json($res->decoded_content);
return ($reseller,$billingprofile);

Loading…
Cancel
Save