Fix round up calculations

This commit is contained in:
PCoder 2020-01-29 16:58:47 +05:30
parent ad606c2c55
commit 8ee4081f60

View file

@ -112,10 +112,12 @@ def get_vm_price_for_given_vat(cpu, memory, ssd_size, hdd_size=0,
cents = decimal.Decimal('.01')
price = price.quantize(cents, decimal.ROUND_HALF_UP)
vat = vat.quantize(cents, decimal.ROUND_HALF_UP)
discount_amount_with_vat = decimal.Decimal(discount_amount) * (1 + decimal.Decimal(vat_rate) * decimal.Decimal(0.01))
discount_amount_with_vat = discount_amount_with_vat.quantize(cents, decimal.ROUND_HALF_UP)
discount = {
'name': discount_name,
'amount': discount_amount,
'amount_with_vat': round(discount_amount * (1 + vat_rate * 0.01), 2)
'amount_with_vat': round(float(discount_amount_with_vat), 2)
}
return (round(float(price), 2), round(float(vat), 2),
round(float(vat_percent), 2), discount)