From 8ee4081f6011af7c4506c42ec7c3b5b41c611a1e Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 29 Jan 2020 16:58:47 +0530 Subject: [PATCH] Fix round up calculations --- utils/hosting_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py index da2540d6..5d898b0a 100644 --- a/utils/hosting_utils.py +++ b/utils/hosting_utils.py @@ -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)