def default_tax_rate(self) -> float: """ Returns average tax rate from historic invoices """ if not self._default_tax_rate_calculated: today = date.today() invoices = get_invoices_of_last_year() invoice_sum = 0 for invoice in invoices: home_amount = self._converter.convert_to_local_currency( invoice["amount"], invoice["currency"]) inv_date = parse_json_date(invoice["invoice_date"]) if inv_date.year < today.year: home_amount *= 1 + (config.CONSTANTS["TUFE_RATE"] / 100) invoice_sum += home_amount annual_tax = self._calc_annual_tax(invoice_sum) self._default_tax_rate = (annual_tax / invoice_sum) * 100 self._default_tax_rate_calculated = True return self._default_tax_rate
def invoice_date(self) -> datetime: """ Invoice date """ return date_time.parse_json_date(self._invoice["invoice_date"])
def date(self) -> datetime: """ Activity dateclient """ return date_time.parse_json_date(self._activity["date"])