File diff 7c11ae408cc8 → 3a3afb79786b
oxrlib/commands/historical.py
Show inline comments
...
 
@@ -172,9 +172,32 @@ class LedgerFormatter(Formatter):
 
        )
 

	
 

	
 
class BeancountFormatter(LedgerFormatter):
 
    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.replace(',', ''),
 
            rate_precision,
 
            denomination,
 
        )
 

	
 
    def price_rate(self, from_amt, from_curr, to_curr):
 
        if self.price_rates is None:
 
            return None
 
        else:
 
            return self.price_rates.convert(from_amt, from_curr, to_curr)
 

	
 

	
 
class Formats(enum.Enum):
 
    RAW = Formatter
 
    LEDGER = LedgerFormatter
 
    BEANCOUNT = BeancountFormatter
 

	
 
    @classmethod
 
    def from_arg(cls, s):