Skip to content

Instantly share code, notes, and snippets.

@peti
Created October 21, 2018 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peti/a872301806a2073827e6efbe6702c436 to your computer and use it in GitHub Desktop.
Save peti/a872301806a2073827e6efbe6702c436 to your computer and use it in GitHub Desktop.
How to show an hledger transaction
showTransaction:

2018/10/19 Joe Doe | Test
    Account 1         €388.00 = €2913.00
    Account 2
    Account 3

showTransactionUnelided:

2018/10/19 Joe Doe | Test
    Account 1         €388.00 = €2913.00
    Account 2
    Account 3          $10.00
    Account 3         €-96.00

showTransactionUnelidedOneLineAmounts:

2018/10/19 Joe Doe | Test
    Account 1         €388.00 = €2913.00
    Account 2
    Account 3    $10.00, €-96.00
{-# LANGUAGE OverloadedStrings #-}
import Hledger.Data
import Data.Time
t :: Transaction
t = nulltransaction
{ tdate = fromGregorian 2018 10 19
, tdescription = "Joe Doe | Test"
, tpostings = [tp1, tp2, tp3]
}
tp1 :: Posting
tp1 = nullposting
{ paccount="Account 1"
, pamount = mixed [eur 388]
, pbalanceassertion = Just (eur 2913, nullsourcepos)
}
tp2 :: Posting
tp2 = nullposting
{ paccount="Account 2"
, pamount = missingmixedamt
}
tp3 :: Posting
tp3 = nullposting
{ paccount="Account 3"
, pamount = mixed [eur (-96), usd (10)]
}
main :: IO ()
main = do
putStrLn "showTransaction:\n"
putStr (showTransaction t)
putStrLn "showTransactionUnelided:\n"
putStr (showTransactionUnelided t)
putStrLn "showTransactionUnelidedOneLineAmounts:\n"
putStr (showTransactionUnelidedOneLineAmounts t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment