implement bill for at least 24 hours

This commit is contained in:
forest 2020-05-16 23:21:09 -05:00
parent 4f002458b3
commit 4b169e9886
2 changed files with 7 additions and 3 deletions

View File

@ -274,7 +274,10 @@ def get_account_balance(vms, payments, as_of):
vm_cost_dollars = 0.0 vm_cost_dollars = 0.0
for vm in vms: for vm in vms:
end_datetime = vm["deleted"] if vm["deleted"] else as_of 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"]) 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)) ) payment_dollars_total = float( sum(map(lambda x: 0 if x["invalidated"] else x["dollars"], payments)) )

View File

@ -25,7 +25,7 @@
<pre> <pre>
CAPSUL SIZES CAPSUL SIZES
============ ============
type monthly cpus mem ssd net* type monthly* cpus mem ssd net*
----- ------- ---- --- --- --- ----- ------- ---- --- --- ---
f1-s $5.33 1 512M 25G .5TB f1-s $5.33 1 512M 25G .5TB
f1-m $7.16 1 1024M 25G 1TB f1-m $7.16 1 1024M 25G 1TB
@ -35,6 +35,7 @@
f1-xxx $57.58 8 16G 25G 16TB f1-xxx $57.58 8 16G 25G 16TB
* net is calculated as a per-month average * 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</pre> * all VMs come standard with one public IPv4 addr</pre>
<pre> <pre>
Your <a href="/console/account-balance">account balance</a>: ${{ account_balance }} Your <a href="/console/account-balance">account balance</a>: ${{ account_balance }}