mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 20:02:27 +03:00
imp:print:beancount: also convert cost amounts
This commit is contained in:
parent
0bf0c30b8d
commit
0b8e920810
@ -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.
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user