Handle DoesNotExist better
This commit is contained in:
parent
582e952187
commit
d399fe6e79
1 changed files with 8 additions and 5 deletions
|
@ -151,17 +151,20 @@ def ping_ok(host_ipv6):
|
||||||
|
|
||||||
|
|
||||||
def get_vat_rate_for_country(country):
|
def get_vat_rate_for_country(country):
|
||||||
|
vat_rate = None
|
||||||
|
try:
|
||||||
vat_rate = VATRates.objects.get(
|
vat_rate = VATRates.objects.get(
|
||||||
territory_codes=country, start_date__isnull=False, stop_date=None
|
territory_codes=country, start_date__isnull=False, stop_date=None
|
||||||
)
|
)
|
||||||
if vat_rate:
|
|
||||||
logger.debug("VAT rate for %s is %s" % (country, vat_rate.rate))
|
logger.debug("VAT rate for %s is %s" % (country, vat_rate.rate))
|
||||||
return vat_rate.rate
|
return vat_rate.rate
|
||||||
else:
|
except VATRates.DoesNotExist as dne:
|
||||||
|
logger.debug(str(dne))
|
||||||
logger.debug("Did not find VAT rate for %s, returning 0" % country)
|
logger.debug("Did not find VAT rate for %s, returning 0" % country)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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