Skip to content
Permalink
Browse files

;lib: clean out showTransactionUnelided

Keep aliases until next major release.
  • Loading branch information...
ony committed Nov 16, 2019
1 parent aca214b commit ab9c150759d9aa34284cb82af0bfd77070795ae1
@@ -38,7 +38,7 @@ main = do
q = queryFromOpts d ropts
ts = filter (q `matchesTransaction`) $ jtxns $ journalSelectingAmountFromOpts ropts j
ts' = map transactionSwapDates ts
mapM_ (putStrLn . showTransactionUnelided) ts'
mapM_ (putStrLn . showTransaction) ts'

transactionSwapDates :: Transaction -> Transaction
transactionSwapDates t@Transaction{tdate2=Nothing} = t
@@ -62,7 +62,7 @@ tsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
where
maincontent = Widget Greedy Greedy $ do
render $ defaultLayout toplabel bottomlabel $ str $
showTransactionUnelidedOneLineAmounts $
showTransactionOneLineAmounts $
-- (if real_ ropts then filterTransactionPostings (Real True) else id) -- filter postings by --real
t
where
@@ -371,7 +371,7 @@ showDefault s = " [" ++ s ++ "]"
journalAddTransaction :: Journal -> CliOpts -> Transaction -> IO Journal
journalAddTransaction j@Journal{jtxns=ts} opts t = do
let f = journalFilePath j
appendToJournalFileOrStdout f $ showTransactionUnelided t
appendToJournalFileOrStdout f $ showTransaction t
-- unelided shows all amounts explicitly, in case there's a price, cf #283
when (debug_ opts > 0) $ do
putStrLn $ printf "\nAdded transaction to %s:" f
@@ -45,7 +45,7 @@ checkdates CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do
(show $ date previous)
(show $ date error)
(show $ tsourcepos error)
(showTransactionUnelided error)
(showTransaction error)

data FoldAcc a b = FoldAcc
{ fa_error :: Maybe a
@@ -21,7 +21,6 @@ closemode = hledgerCommandMode
$(embedFileRelative "Hledger/Cli/Commands/Close.txt")
[flagNone ["opening"] (setboolopt "opening") "show just opening transaction"
,flagNone ["closing"] (setboolopt "closing") "show just closing transaction"
-- ,flagNone ["explicit","x"] (setboolopt "explicit") "show all amounts explicitly"
]
[generalflagsgroup1]
hiddenflags
@@ -88,12 +87,6 @@ close CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do
}
]

-- With -x, show all amounts explicitly (ie, also in the balancing equity posting(s)).
-- print also does it for -B; I think that isn't needed here.
-- showtxn | boolopt "explicit" rawopts = showTransactionUnelided
-- | otherwise = showTransaction
showtxn = showTransactionUnelided

when closing $ putStr $ showtxn (nulltransaction{tdate=closingdate, tdescription="closing balances", tpostings=closingps})
when opening $ putStr $ showtxn (nulltransaction{tdate=openingdate, tdescription="opening balances", tpostings=openingps})
when closing $ putStr $ showTransaction (nulltransaction{tdate=closingdate, tdescription="closing balances", tpostings=closingps})
when opening $ putStr $ showTransaction (nulltransaction{tdate=openingdate, tdescription="opening balances", tpostings=openingps})

@@ -50,7 +50,7 @@ importcmd opts@CliOpts{rawopts_=rawopts,inputopts_=iopts} j = do
printf "; would import %d new transactions from %s:\n\n" (length newts) inputstr
-- TODO how to force output here ?
-- length (jtxns newj) `seq` print' opts{rawopts_=("explicit",""):rawopts} newj
mapM_ (putStr . showTransactionUnelided) newts
mapM_ (putStr . showTransaction) newts
newts | catchup -> do
printf "marked %s as caught up, skipping %d unimported transactions\n\n" inputstr (length newts)
newts -> do
@@ -59,7 +59,7 @@ printEntries opts@CliOpts{reportopts_=ropts} j = do
writeOutput opts $ render $ entriesReport ropts' q j

entriesReportAsText :: CliOpts -> EntriesReport -> String
entriesReportAsText opts = concatMap (showTransactionUnelided . gettxn)
entriesReportAsText opts = concatMap (showTransaction . gettxn)
where
gettxn | useexplicittxn = id -- use fully inferred amounts & txn prices
| otherwise = originalTransaction -- use original as-written amounts/txn prices
@@ -162,7 +162,7 @@ printMatch CliOpts{reportopts_=ropts} j desc = do
let q = queryFromOpts d ropts
case similarTransaction' j q desc of
Nothing -> putStrLn "no matches found."
Just t -> putStr $ showTransactionUnelided t
Just t -> putStr $ showTransaction t

where
-- Identify the closest recent match for this description in past transactions.
@@ -132,7 +132,7 @@ diffTxn j t t' =
diffs = map mapDiff $ D.getDiff source changed'
source | Just contents <- lookup fp $ jfiles j = map T.unpack . drop (line-1) . take line' $ T.lines contents
| otherwise = []
changed = lines $ showTransactionUnelided t'
changed = lines $ showTransaction t'
changed' | null changed = changed
| null $ last changed = init changed
| otherwise = changed

0 comments on commit ab9c150

Please sign in to comment.
You can’t perform that action at this time.