File diff c3fd55ec15b7 → 8dede9d1398c
oxrlib/commands/historical.py
Show inline comments
...
 
@@ -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):