Don't print a blank line for ledger or beancount when there are no prices.
This commit is contained in:
parent
5fdbb480e7
commit
925ed42b86
2 changed files with 6 additions and 6 deletions
|
@ -5,7 +5,7 @@ from .baseoutput import BaseOutput
|
|||
|
||||
class Beancount(BaseOutput):
|
||||
def format(self, series, source=None, fmt=Format()):
|
||||
lines = []
|
||||
output = ""
|
||||
for price in series.prices:
|
||||
# TODO warn if fmt settings make an invalid number (not . for decimal)
|
||||
# TODO warn if fmt settings make an invalid quote (not right/rightspace)
|
||||
|
@ -13,8 +13,8 @@ class Beancount(BaseOutput):
|
|||
base = fmt.base or series.base
|
||||
quote = fmt.quote or series.quote
|
||||
quote_amount = fmt.format_quote_amount(quote, price.amount)
|
||||
lines.append(f"{date} price {base} {quote_amount}")
|
||||
return "\n".join(lines) + "\n"
|
||||
output += f"{date} price {base} {quote_amount}\n"
|
||||
return output
|
||||
|
||||
|
||||
# NOTE: Beancount always has commodity to the right. It seems to be possible to
|
||||
|
|
|
@ -5,14 +5,14 @@ from .baseoutput import BaseOutput
|
|||
|
||||
class Ledger(BaseOutput):
|
||||
def format(self, series, source=None, fmt=Format()):
|
||||
lines = []
|
||||
output = ""
|
||||
for price in series.prices:
|
||||
date = fmt.format_date(price.date)
|
||||
base = fmt.base or series.base
|
||||
quote = fmt.quote or series.quote
|
||||
quote_amount = fmt.format_quote_amount(quote, price.amount)
|
||||
lines.append(f"P {date} {fmt.time} {base} {quote_amount}")
|
||||
return "\n".join(lines) + "\n"
|
||||
output += f"P {date} {fmt.time} {base} {quote_amount}\n"
|
||||
return output
|
||||
|
||||
# https://www.ledger-cli.org/3.0/doc/ledger3.html#Commodities-and-Currencies
|
||||
# > The commodity may be any non-numeric string that does not contain a
|
||||
|
|
Loading…
Add table
Reference in a new issue