imp:print:beancount: also convert cost amounts

This commit is contained in:
Simon Michael 2023-11-22 23:54:10 -10:00
parent 0bf0c30b8d
commit 0b8e920810
2 changed files with 8 additions and 4 deletions

View File

@ -386,12 +386,16 @@ type BeancountAmount = Amount
-- in a way that Beancount can read: forces the commodity symbol to the right,
-- converts $ to USD.
amountToBeancount :: Amount -> BeancountAmount
amountToBeancount a@Amount{acommodity=c,astyle=s} = a{acommodity=c', astyle=s'}
amountToBeancount a@Amount{acommodity=c,astyle=s,aprice=mp} = a{acommodity=c', astyle=s', aprice=mp'}
-- https://beancount.github.io/docs/beancount_language_syntax.html#commodities-currencies
where
s' = s{ascommodityside=R, ascommodityspaced=True}
c' | c=="$" = "USD"
| otherwise = c
s' = s{ascommodityside=R, ascommodityspaced=True}
mp' = costToBeancount <$> mp
where
costToBeancount (TotalPrice amt) = TotalPrice $ amountToBeancount amt
costToBeancount (UnitPrice amt) = UnitPrice $ amountToBeancount amt
-- | Like showAccountName for Beancount journal format.
-- Calls accountNameToBeancount first.

View File

@ -121,8 +121,8 @@ The output formats supported are
The `beancount` format tries to produce Beancount-compatible output.
It is very basic and may require additional manual fixups:
- Transaction and postings with unmarked status are converted to cleared (`*``) status.
- Transactions' payee and or note are wrapped in double quotes.
- Transaction and postings with unmarked status are converted to cleared (`*`) status.
- Transactions' payee and note are wrapped in double quotes.
- Transaction tags are copied to Beancount #tag format.
- Account name parts are capitalised, and if the first account name part
is not one of Assets, Liabilities, Equity, Income, or Expenses, "Equity:" is prepended.