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,
|
-- in a way that Beancount can read: forces the commodity symbol to the right,
|
||||||
-- converts $ to USD.
|
-- converts $ to USD.
|
||||||
amountToBeancount :: Amount -> BeancountAmount
|
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
|
-- https://beancount.github.io/docs/beancount_language_syntax.html#commodities-currencies
|
||||||
where
|
where
|
||||||
s' = s{ascommodityside=R, ascommodityspaced=True}
|
|
||||||
c' | c=="$" = "USD"
|
c' | c=="$" = "USD"
|
||||||
| otherwise = c
|
| 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.
|
-- | Like showAccountName for Beancount journal format.
|
||||||
-- Calls accountNameToBeancount first.
|
-- Calls accountNameToBeancount first.
|
||||||
|
|||||||
@ -121,8 +121,8 @@ The output formats supported are
|
|||||||
The `beancount` format tries to produce Beancount-compatible output.
|
The `beancount` format tries to produce Beancount-compatible output.
|
||||||
It is very basic and may require additional manual fixups:
|
It is very basic and may require additional manual fixups:
|
||||||
|
|
||||||
- Transaction and postings with unmarked status are converted to cleared (`*``) status.
|
- Transaction and postings with unmarked status are converted to cleared (`*`) status.
|
||||||
- Transactions' payee and or note are wrapped in double quotes.
|
- Transactions' payee and note are wrapped in double quotes.
|
||||||
- Transaction tags are copied to Beancount #tag format.
|
- Transaction tags are copied to Beancount #tag format.
|
||||||
- Account name parts are capitalised, and if the first account name part
|
- 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.
|
is not one of Assets, Liabilities, Equity, Income, or Expenses, "Equity:" is prepended.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user