B #5368: Solved bug with costs

This commit is contained in:
juanmont committed 2017-09-14 12:27:49 +02:00
1 parent d785ca94c0
commit e3e6ae7b61
4 files changed
+10 -19

No files matched your search

@@ -98,20 +98,18 @@ define(function(require) {
}
function convertCostNumber(number){
if(number >= 1000000){
number = (number/1000000).toFixed(2)
number = (number/1000000).toFixed(6)
return number.toString()+"M";
}
else if(number >= 1000){
number = (number/1000).toFixed(2)
number = (number/1000).toFixed(6)
return number.toString()+"K";
}
return number;
return number.toFixed(6);
}
function caculatedTotalMemory(context){
var memory = document.getElementById('MEMORY_COST').value;
var type = document.getElementById('MEMORY_UNIT_COST').value;
if(type == "GB")
memory *= 1024;
memory = memory * 24 * 30; //24 hours and 30 days
document.getElementById('total_value_memory').textContent = convertCostNumber(memory);
$(".total_memory_cost", context).show();
@@ -143,7 +141,7 @@ define(function(require) {
context.on("change", "#DISK_COST", function() {
var disk = document.getElementById('DISK_COST').value;
document.getElementById('total_value_disk').textContent = convertCostNumber(disk * 1024 * 24 * 30);
document.getElementById('total_value_disk').textContent = convertCostNumber(disk * 24 * 30);
$(".total_disk_cost", context).show();
});
@@ -182,14 +180,6 @@ define(function(require) {
function _retrieve(context) {
var templateJSON = WizardFields.retrieve(context);
if(templateJSON["DISK_COST"]){
templateJSON["DISK_COST"] = templateJSON["DISK_COST"] * 1024;
}
else{
delete templateJSON["MEMORY_UNIT_COST"];
}
if(templateJSON["MEMORY_UNIT_COST"] == "GB")
templateJSON["MEMORY_COST"] = templateJSON["MEMORY_COST"] * 1024;
if (templateJSON["HYPERVISOR"] == 'vcenter') {
templateJSON["VCENTER_TEMPLATE_REF"] = WizardFields.retrieveInput($("#vcenter_template_ref", context));
templateJSON["VCENTER_CCR_REF"] = WizardFields.retrieveInput($("#vcenter_ccr_ref", context));
@@ -102,7 +102,7 @@ define(function(require) {
var type_cost = document.getElementById('MEMORY_UNIT_COST').value;
var memory = document.getElementById('MEMORY').value;
var type = document.getElementById('memory_unit').value;
if(type_cost == "GB" && type == "MB")
if(type_cost == "GB")
memory = (memory/1024)*memory_cost*24*30;
else
memory = memory*memory_cost*24*30;
@@ -210,7 +210,7 @@ define(function(require) {
if (total != 0 && Config.isFeatureEnabled("showback")) {
$(".total_cost_div", $(this)).show();
$(".total_cost_div .cost_value", $(this)).text( (capacity_val + disk_val).toFixed(2) );
$(".total_cost_div .cost_value", $(this)).text( (capacity_val + disk_val).toFixed(6) );
}
});
}
@@ -505,7 +505,7 @@ define(function(require) {
memoryCost = Config.onedConf.DEFAULT_COST.MEMORY_COST;
} else {
if (memoryUnitCost == "GB"){
memoryCost = memoryCost / 1024;
memoryCost = memoryCost / 1024 / 1024;
}
}
@@ -523,7 +523,7 @@ define(function(require) {
cost += cpuCost * values.CPU;
}
$(".cost_value", capacityContext).html(cost.toFixed(2));
$(".cost_value", capacityContext).html(cost.toFixed(6));
_calculateCost(context);
});
@@ -30,6 +30,7 @@ define(function(require){
function _calculateCost(context, disk_cost, callback){
var cost = 0;
disk_cost = disk_cost / 1024 / 1024;
$(".diskContainer", context).each(function(){
var size = 0;
@@ -50,7 +51,7 @@ define(function(require){
cost += $(this).data('disk_snapshot_total_cost');
});
$(".cost_value", context).text(cost.toFixed(2));
$(".cost_value", context).text(cost.toFixed(6));
if(callback != undefined){
callback();