From eec28e26973f8db5c91a6f8702852fa9562f978f Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Tue, 4 Jan 2022 17:20:00 +0100 Subject: [PATCH] Complete get_tax_rate() method on EUVAT class --- classes/euvat.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/classes/euvat.py b/classes/euvat.py index 355bbb3..451c8ea 100644 --- a/classes/euvat.py +++ b/classes/euvat.py @@ -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 \ No newline at end of file