Include free router and network credit into total cost
Two small fix including in this patch: 1. Including the free router and free network into the current month quotation. 2. Fix small typo Change-Id: I0e2e1ae321687211ee79c304e9a2ade709441a4c
This commit is contained in:
parent
91dcb51d28
commit
3bcd260b27
|
@ -109,6 +109,7 @@ def _wash_details(current_details):
|
||||||
else:
|
else:
|
||||||
washed_details.append(u)
|
washed_details.append(u)
|
||||||
|
|
||||||
|
total_free_router_network_cost = 0
|
||||||
free_network_hours_left = free_hours
|
free_network_hours_left = free_hours
|
||||||
for region, hours in six.iteritems(network_hours):
|
for region, hours in six.iteritems(network_hours):
|
||||||
free_network_hours = (hours if hours <= free_network_hours_left
|
free_network_hours = (hours if hours <= free_network_hours_left
|
||||||
|
@ -116,13 +117,14 @@ def _wash_details(current_details):
|
||||||
if not free_network_hours:
|
if not free_network_hours:
|
||||||
break
|
break
|
||||||
line_name = 'Free Network Tier in %s' % region
|
line_name = 'Free Network Tier in %s' % region
|
||||||
|
cost = round(free_network_hours * -rate_network, 2)
|
||||||
|
total_free_router_network_cost += cost
|
||||||
washed_details.append({'product': region + '.n1.network',
|
washed_details.append({'product': region + '.n1.network',
|
||||||
'resource_name': line_name,
|
'resource_name': line_name,
|
||||||
'quantity': free_network_hours,
|
'quantity': free_network_hours,
|
||||||
'resource_id': '',
|
'resource_id': '',
|
||||||
'unit': 'hour', 'rate': -rate_network,
|
'unit': 'hour', 'rate': -rate_network,
|
||||||
'cost': round(free_network_hours *
|
'cost': cost})
|
||||||
-rate_network, 2)})
|
|
||||||
free_network_hours_left -= free_network_hours
|
free_network_hours_left -= free_network_hours
|
||||||
|
|
||||||
free_router_hours_left = free_hours
|
free_router_hours_left = free_hours
|
||||||
|
@ -132,13 +134,14 @@ def _wash_details(current_details):
|
||||||
if not free_router_hours:
|
if not free_router_hours:
|
||||||
break
|
break
|
||||||
line_name = 'Free Router Tier in %s' % region
|
line_name = 'Free Router Tier in %s' % region
|
||||||
|
cost = round(free_router_hours * -rate_router, 2)
|
||||||
|
total_free_router_network_cost += cost
|
||||||
washed_details.append({'product': region + '.n1.router',
|
washed_details.append({'product': region + '.n1.router',
|
||||||
'resource_name': line_name,
|
'resource_name': line_name,
|
||||||
'quantity': free_router_hours,
|
'quantity': free_router_hours,
|
||||||
'resource_id': '',
|
'resource_id': '',
|
||||||
'unit': 'hour', 'rate': -rate_router,
|
'unit': 'hour', 'rate': -rate_router,
|
||||||
'cost': round(free_router_hours *
|
'cost': cost})
|
||||||
-rate_router, 2)})
|
|
||||||
free_router_hours_left -= free_router_hours
|
free_router_hours_left -= free_router_hours
|
||||||
|
|
||||||
region_count = 0
|
region_count = 0
|
||||||
|
@ -161,6 +164,13 @@ def _wash_details(current_details):
|
||||||
(region_count - 1) * (object_cost / region_count))
|
(region_count - 1) * (object_cost / region_count))
|
||||||
current_details["total_cost"] = (current_details["total_cost"] -
|
current_details["total_cost"] = (current_details["total_cost"] -
|
||||||
dup_object_cost)
|
dup_object_cost)
|
||||||
|
|
||||||
|
# NOTE(flwang): Apply the free router and network to reflect correct cost.
|
||||||
|
# The total_free_router_network_cost is negative value.
|
||||||
|
current_details["total_cost"] += total_free_router_network_cost
|
||||||
|
current_details["total_cost"] = (current_details["total_cost"] if
|
||||||
|
current_details["total_cost"] > 0 else 0)
|
||||||
|
|
||||||
return current_details
|
return current_details
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,7 @@
|
||||||
} else {
|
} else {
|
||||||
$("#credits_div").show();
|
$("#credits_div").show();
|
||||||
for(i=0;i<CREDITS["credits"].length;i++){
|
for(i=0;i<CREDITS["credits"].length;i++){
|
||||||
$("#credits_list").append('<li><i class="fa-li fa fa-credit-card"></i> Balance of ' + CREDITS["credits"][i].type + ' is $' + CREDITS["credits"][i].balance + ' will expired at ' + CREDITS["credits"][i].expiry_date + '</li>');
|
$("#credits_list").append('<li><i class="fa-li fa fa-credit-card"></i> Balance of ' + CREDITS["credits"][i].type + ' is $' + CREDITS["credits"][i].balance + '. This will expire on ' + CREDITS["credits"][i].expiry_date + '</li>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue