From ab9c150759d9aa34284cb82af0bfd77070795ae1 Mon Sep 17 00:00:00 2001 From: Mykola Orliuk Date: Sat, 16 Nov 2019 12:46:21 +0100 Subject: [PATCH] ;lib: clean out showTransactionUnelided Keep aliases until next major release. --- bin/hledger-swap-dates.hs | 2 +- hledger-ui/Hledger/UI/TransactionScreen.hs | 2 +- hledger/Hledger/Cli/Commands/Add.hs | 2 +- hledger/Hledger/Cli/Commands/Checkdates.hs | 2 +- hledger/Hledger/Cli/Commands/Close.hs | 11 ++--------- hledger/Hledger/Cli/Commands/Import.hs | 2 +- hledger/Hledger/Cli/Commands/Print.hs | 4 ++-- hledger/Hledger/Cli/Commands/Rewrite.hs | 2 +- 8 files changed, 10 insertions(+), 17 deletions(-) diff --git a/bin/hledger-swap-dates.hs b/bin/hledger-swap-dates.hs index 6efeffc3c..8cf148bab 100755 --- a/bin/hledger-swap-dates.hs +++ b/bin/hledger-swap-dates.hs @@ -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 diff --git a/hledger-ui/Hledger/UI/TransactionScreen.hs b/hledger-ui/Hledger/UI/TransactionScreen.hs index 9f589c1d6..f315d46ad 100644 --- a/hledger-ui/Hledger/UI/TransactionScreen.hs +++ b/hledger-ui/Hledger/UI/TransactionScreen.hs @@ -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 diff --git a/hledger/Hledger/Cli/Commands/Add.hs b/hledger/Hledger/Cli/Commands/Add.hs index 7b8d08cba..7b8ba81f3 100644 --- a/hledger/Hledger/Cli/Commands/Add.hs +++ b/hledger/Hledger/Cli/Commands/Add.hs @@ -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 diff --git a/hledger/Hledger/Cli/Commands/Checkdates.hs b/hledger/Hledger/Cli/Commands/Checkdates.hs index 8084b447a..026ae2476 100755 --- a/hledger/Hledger/Cli/Commands/Checkdates.hs +++ b/hledger/Hledger/Cli/Commands/Checkdates.hs @@ -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 diff --git a/hledger/Hledger/Cli/Commands/Close.hs b/hledger/Hledger/Cli/Commands/Close.hs index 779a21848..335bad08d 100755 --- a/hledger/Hledger/Cli/Commands/Close.hs +++ b/hledger/Hledger/Cli/Commands/Close.hs @@ -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}) diff --git a/hledger/Hledger/Cli/Commands/Import.hs b/hledger/Hledger/Cli/Commands/Import.hs index cc4f585b9..beff429ce 100755 --- a/hledger/Hledger/Cli/Commands/Import.hs +++ b/hledger/Hledger/Cli/Commands/Import.hs @@ -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 diff --git a/hledger/Hledger/Cli/Commands/Print.hs b/hledger/Hledger/Cli/Commands/Print.hs index e04f6b02c..a8c15407c 100644 --- a/hledger/Hledger/Cli/Commands/Print.hs +++ b/hledger/Hledger/Cli/Commands/Print.hs @@ -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. diff --git a/hledger/Hledger/Cli/Commands/Rewrite.hs b/hledger/Hledger/Cli/Commands/Rewrite.hs index 91b5f0203..f29634f61 100755 --- a/hledger/Hledger/Cli/Commands/Rewrite.hs +++ b/hledger/Hledger/Cli/Commands/Rewrite.hs @@ -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