Complete get_tax_rate() method on EUVAT class

This commit is contained in:
Kumi 2022-01-04 17:20:00 +01:00
parent 054df92134
commit eec28e2697

View file

@ -71,8 +71,6 @@ class EUVAT:
return cls(COUNTRIES, COMMENTS)
@classmethod
def from_net(cls, date=datetime.today().date()):
payload = dict()
@ -96,3 +94,12 @@ class EUVAT:
xlsx = urlopen(EXPORT_URL, urlencode(payload).encode()).read()
return cls.from_excel(BytesIO(xlsx))
def get_tax_rate(self, country, category="E-Services", ratetype="STANDARD", default=Decimal(0), fallback=True):
for c in self.countries:
if country in (c.name, c.code):
if rate := c.get_tax_rate(category, ratetype, fallback):
return rate
break
return default