Use round_up method
This commit is contained in:
parent
2058c660c0
commit
c43afb7c59
2 changed files with 11 additions and 5 deletions
|
@ -29,7 +29,7 @@ from utils.forms import (
|
||||||
)
|
)
|
||||||
from utils.hosting_utils import (
|
from utils.hosting_utils import (
|
||||||
get_vm_price_with_vat, get_all_public_keys, get_vat_rate_for_country,
|
get_vm_price_with_vat, get_all_public_keys, get_vat_rate_for_country,
|
||||||
get_vm_price_for_given_vat
|
get_vm_price_for_given_vat, round_up
|
||||||
)
|
)
|
||||||
from utils.stripe_utils import StripeUtils
|
from utils.stripe_utils import StripeUtils
|
||||||
from utils.tasks import send_plain_email_task
|
from utils.tasks import send_plain_email_task
|
||||||
|
@ -678,10 +678,10 @@ class OrderConfirmationView(DetailView, FormView):
|
||||||
vm_specs["vat_percent"] = vat_percent
|
vm_specs["vat_percent"] = vat_percent
|
||||||
vm_specs["vat_validation_status"] = request.session["vat_validation_status"] if "vat_validation_status" in request.session else ""
|
vm_specs["vat_validation_status"] = request.session["vat_validation_status"] if "vat_validation_status" in request.session else ""
|
||||||
vm_specs["vat_country"] = user_vat_country
|
vm_specs["vat_country"] = user_vat_country
|
||||||
vm_specs["price_with_vat"] = round(price * (1 + vm_specs["vat_percent"] * 0.01), 2)
|
vm_specs["price_with_vat"] = round_up(price * (1 + vm_specs["vat_percent"] * 0.01), 2)
|
||||||
vm_specs["price_after_discount"] = round(price - discount['amount'], 2)
|
vm_specs["price_after_discount"] = round_up(price - discount['amount'], 2)
|
||||||
vm_specs["price_after_discount_with_vat"] = round((price - discount['amount']) * (1 + vm_specs["vat_percent"] * 0.01), 2)
|
vm_specs["price_after_discount_with_vat"] = round_up((price - discount['amount']) * (1 + vm_specs["vat_percent"] * 0.01), 2)
|
||||||
discount["amount_with_vat"] = round(vm_specs["price_with_vat"] - vm_specs["price_after_discount_with_vat"], 2)
|
discount["amount_with_vat"] = round_up(vm_specs["price_with_vat"] - vm_specs["price_after_discount_with_vat"], 2)
|
||||||
vm_specs["total_price"] = vm_specs["price_after_discount_with_vat"]
|
vm_specs["total_price"] = vm_specs["price_after_discount_with_vat"]
|
||||||
vm_specs["discount"] = discount
|
vm_specs["discount"] = discount
|
||||||
request.session['specs'] = vm_specs
|
request.session['specs'] = vm_specs
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import decimal
|
import decimal
|
||||||
import logging
|
import logging
|
||||||
|
import math
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from oca.pool import WrongIdError
|
from oca.pool import WrongIdError
|
||||||
|
@ -214,6 +215,11 @@ def get_ip_addresses(vm_id):
|
||||||
return "--"
|
return "--"
|
||||||
|
|
||||||
|
|
||||||
|
def round_up(n, decimals=0):
|
||||||
|
multiplier = 10 ** decimals
|
||||||
|
return math.ceil(n * multiplier) / multiplier
|
||||||
|
|
||||||
|
|
||||||
class HostingUtils:
|
class HostingUtils:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clear_items_from_list(from_list, items_list):
|
def clear_items_from_list(from_list, items_list):
|
||||||
|
|
Loading…
Reference in a new issue