diff --git a/capsulflask/console.py b/capsulflask/console.py index 5038ffb..ca1e6c9 100644 --- a/capsulflask/console.py +++ b/capsulflask/console.py @@ -45,7 +45,7 @@ def double_check_capsul_address(id, ipv4): def index(): vms = get_vms() created = request.args.get('created') - + # this is here to prevent xss if not re.match(r"^(cvm|capsul)-[a-z0-9]{10}$", created): created = '___________' @@ -274,7 +274,10 @@ def get_account_balance(vms, payments, as_of): vm_cost_dollars = 0.0 for vm in vms: end_datetime = vm["deleted"] if vm["deleted"] else as_of - vm_months = ( end_datetime - vm["created"] ).days / average_number_of_days_in_a_month + days = float((end_datetime - vm["created"]).total_seconds())/float(60*60*24) + if days < 1: + days = float(1) + vm_months = days / average_number_of_days_in_a_month vm_cost_dollars += vm_months * float(vm["dollars_per_month"]) payment_dollars_total = float( sum(map(lambda x: 0 if x["invalidated"] else x["dollars"], payments)) ) diff --git a/capsulflask/templates/create-capsul.html b/capsulflask/templates/create-capsul.html index d9a24fd..bb27042 100644 --- a/capsulflask/templates/create-capsul.html +++ b/capsulflask/templates/create-capsul.html @@ -25,7 +25,7 @@
CAPSUL SIZES ============ - type monthly cpus mem ssd net* + type monthly* cpus mem ssd net* ----- ------- ---- --- --- --- f1-s $5.33 1 512M 25G .5TB f1-m $7.16 1 1024M 25G 1TB @@ -35,6 +35,7 @@ f1-xxx $57.58 8 16G 25G 16TB * net is calculated as a per-month average + * vms are billed for a minimum of 24 hours upon creation * all VMs come standard with one public IPv4 addr
Your account balance: ${{ account_balance }}