diff --git a/oxrlib/commands/historical.py b/oxrlib/commands/historical.py index b887f3675479738d5d0a419ccedd33cadd416f5b..828054b7f9b5b7d12726cdddf7aad0e61b7e98dc 100644 --- a/oxrlib/commands/historical.py +++ b/oxrlib/commands/historical.py @@ -71,19 +71,15 @@ class Formatter: ) -class LedgerFormatter(Formatter): - COST_FMT = '{{={}}}' +class BeancountFormatter(Formatter): + COST_FMT = '{{{}}}' PRICE_FMT = ' @ {}' def price_rate(self, from_amt, from_curr, to_curr): if self.price_rates is None: - rates = self.cost_rates + return None else: - rates = self.price_rates - return rates.convert(from_amt, from_curr, to_curr) - - def can_sign_currency(self, code): - return len(babel.numbers.get_currency_symbol(code)) == 1 + return self.price_rates.convert(from_amt, from_curr, to_curr) def normalize_rate(self, rate, prec=None): if prec is None: @@ -172,26 +168,18 @@ class LedgerFormatter(Formatter): ) -class BeancountFormatter(LedgerFormatter): - COST_FMT = '{{{}}}' +class LedgerFormatter(BeancountFormatter): + COST_FMT = '{{={}}}' - def __init__(self, cost_rates, price_rates=None, - signed_currencies=(), base_fmt='#,##0.###', - rate_precision=5, denomination=None): - super().__init__( - cost_rates, - price_rates, - (), - base_fmt, - rate_precision, - denomination, - ) + def can_sign_currency(self, code): + return len(babel.numbers.get_currency_symbol(code)) == 1 def price_rate(self, from_amt, from_curr, to_curr): if self.price_rates is None: - return None + rates = self.cost_rates else: - return self.price_rates.convert(from_amt, from_curr, to_curr) + rates = self.price_rates + return rates.convert(from_amt, from_curr, to_curr) class Formats(enum.Enum):