Revert "Adding "--value"/"-V" option for balancesheet/incomestatement/cashflow and register (#361)"
This reverts commit b935cd2243.
			
			
This commit is contained in:
		
							parent
							
								
									b935cd2243
								
							
						
					
					
						commit
						a1555ce964
					
				| @ -9,7 +9,6 @@ module Hledger.Reports.PostingsReport ( | |||||||
|   PostingsReport, |   PostingsReport, | ||||||
|   PostingsReportItem, |   PostingsReportItem, | ||||||
|   postingsReport, |   postingsReport, | ||||||
|   postingsReportValue, |  | ||||||
|   mkpostingsReportItem, |   mkpostingsReportItem, | ||||||
| 
 | 
 | ||||||
|   -- * Tests |   -- * Tests | ||||||
| @ -29,7 +28,6 @@ import Test.HUnit | |||||||
| import Hledger.Data | import Hledger.Data | ||||||
| import Hledger.Query | import Hledger.Query | ||||||
| import Hledger.Utils | import Hledger.Utils | ||||||
| import Hledger.Reports.BalanceReport |  | ||||||
| import Hledger.Reports.ReportOptions | import Hledger.Reports.ReportOptions | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -89,31 +87,6 @@ postingsReport opts q j = (totallabel, items) | |||||||
| 
 | 
 | ||||||
| totallabel = "Total" | totallabel = "Total" | ||||||
| 
 | 
 | ||||||
| -- | Convert all the amounts in a postings report to |  | ||||||
| -- their value on the given date in their default valuation |  | ||||||
| -- commodities. |  | ||||||
| postingsReportValue :: Journal -> Day -> PostingsReport -> PostingsReport |  | ||||||
| postingsReportValue j d r = r' |  | ||||||
|   where |  | ||||||
|     (label,items) = r |  | ||||||
|     r' = dbg8 "postingsReportValue" $ |  | ||||||
|          (label,[(pb,pe,pd,postingValue j d pp,mixedAmountValue j d a) | (pb,pe,pd,pp,a) <- items]) |  | ||||||
| 
 |  | ||||||
| postingValue :: Journal -> Day -> Posting -> Posting |  | ||||||
| postingValue j d p = p' |  | ||||||
|   where |  | ||||||
|     Posting {pamount = pa, pbalanceassertion = pb, ptransaction = pt} = p |  | ||||||
|     p' = p{pamount = mixedAmountValue j d pa |  | ||||||
|           ,pbalanceassertion = mixedAmountValue j d <$> pb |  | ||||||
|           ,ptransaction = transactionValue j d <$> pt |  | ||||||
|           } |  | ||||||
| 
 |  | ||||||
| transactionValue :: Journal -> Day -> Transaction -> Transaction |  | ||||||
| transactionValue j d t = t' |  | ||||||
|   where |  | ||||||
|     Transaction {tpostings = tp} = t |  | ||||||
|     t' = t{tpostings = map (postingValue j d) tp} |  | ||||||
| 
 |  | ||||||
| -- | Adjust report start/end dates to more useful ones based on | -- | Adjust report start/end dates to more useful ones based on | ||||||
| -- journal data and report intervals. Ie: | -- journal data and report intervals. Ie: | ||||||
| -- 1. If the start date is unspecified, use the earliest date in the journal (if any) | -- 1. If the start date is unspecified, use the earliest date in the journal (if any) | ||||||
|  | |||||||
| @ -11,7 +11,6 @@ module Hledger.Cli.Balancesheet ( | |||||||
|  ,tests_Hledger_Cli_Balancesheet |  ,tests_Hledger_Cli_Balancesheet | ||||||
| ) where | ) where | ||||||
| 
 | 
 | ||||||
| import Data.Maybe (fromMaybe) |  | ||||||
| import qualified Data.Text.Lazy.IO as LT | import qualified Data.Text.Lazy.IO as LT | ||||||
| import System.Console.CmdArgs.Explicit | import System.Console.CmdArgs.Explicit | ||||||
| import Test.HUnit | import Test.HUnit | ||||||
| @ -29,7 +28,6 @@ balancesheetmode = (defCommandMode $ ["balancesheet"]++aliases) { | |||||||
|      groupUnnamed = [ |      groupUnnamed = [ | ||||||
|       flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show accounts as a list" |       flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show accounts as a list" | ||||||
|      ,flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts" |      ,flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts" | ||||||
|      ,flagNone ["value","V"] (setboolopt "value") "show amounts as their current market value in their default valuation commodity" |  | ||||||
|      ] |      ] | ||||||
|     ,groupHidden = [] |     ,groupHidden = [] | ||||||
|     ,groupNamed = [generalflagsgroup1] |     ,groupNamed = [generalflagsgroup1] | ||||||
| @ -43,23 +41,18 @@ balancesheet CliOpts{reportopts_=ropts} j = do | |||||||
|   -- let lines = case lineFormatFromOpts ropts of Left err, Right ... |   -- let lines = case lineFormatFromOpts ropts of Left err, Right ... | ||||||
|   d <- getCurrentDay |   d <- getCurrentDay | ||||||
|   let q = queryFromOpts d (withoutBeginDate ropts) |   let q = queryFromOpts d (withoutBeginDate ropts) | ||||||
|       valuedate = fromMaybe d $ queryEndDate False $ queryFromOpts d ropts |  | ||||||
|       assetreport@(_,assets)          = balanceReport ropts (And [q, journalAssetAccountQuery j]) j |       assetreport@(_,assets)          = balanceReport ropts (And [q, journalAssetAccountQuery j]) j | ||||||
|       liabilityreport@(_,liabilities) = balanceReport ropts (And [q, journalLiabilityAccountQuery j]) j |       liabilityreport@(_,liabilities) = balanceReport ropts (And [q, journalLiabilityAccountQuery j]) j | ||||||
|       total = assets + liabilities |       total = assets + liabilities | ||||||
|       convertReport | value_ ropts = balanceReportValue j valuedate |  | ||||||
|                     | otherwise    = id |  | ||||||
|       convertTotal  | value_ ropts = mixedAmountValue j valuedate |  | ||||||
|                     | otherwise    = id |  | ||||||
|   LT.putStr $ [lt|Balance Sheet |   LT.putStr $ [lt|Balance Sheet | ||||||
| 
 | 
 | ||||||
| Assets: | Assets: | ||||||
| #{balanceReportAsText ropts (convertReport assetreport)} | #{balanceReportAsText ropts assetreport} | ||||||
| Liabilities: | Liabilities: | ||||||
| #{balanceReportAsText ropts (convertReport liabilityreport)} | #{balanceReportAsText ropts liabilityreport} | ||||||
| Total: | Total: | ||||||
| -------------------- | -------------------- | ||||||
| #{padleft 20 $ showMixedAmountWithoutPrice (convertTotal total)} | #{padleft 20 $ showMixedAmountWithoutPrice total} | ||||||
| |] | |] | ||||||
| 
 | 
 | ||||||
| withoutBeginDate :: ReportOpts -> ReportOpts | withoutBeginDate :: ReportOpts -> ReportOpts | ||||||
|  | |||||||
| @ -14,7 +14,6 @@ module Hledger.Cli.Cashflow ( | |||||||
|  ,tests_Hledger_Cli_Cashflow |  ,tests_Hledger_Cli_Cashflow | ||||||
| ) where | ) where | ||||||
| 
 | 
 | ||||||
| import Data.Maybe (fromMaybe) |  | ||||||
| import qualified Data.Text.Lazy.IO as LT | import qualified Data.Text.Lazy.IO as LT | ||||||
| import System.Console.CmdArgs.Explicit | import System.Console.CmdArgs.Explicit | ||||||
| import Test.HUnit | import Test.HUnit | ||||||
| @ -32,7 +31,6 @@ cashflowmode = (defCommandMode ["cashflow","cf"]) { | |||||||
|      groupUnnamed = [ |      groupUnnamed = [ | ||||||
|       flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show accounts as a list" |       flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show accounts as a list" | ||||||
|      ,flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts" |      ,flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts" | ||||||
|      ,flagNone ["value","V"] (setboolopt "value") "show amounts as their current market value in their default valuation commodity" |  | ||||||
|      ] |      ] | ||||||
|     ,groupHidden = [] |     ,groupHidden = [] | ||||||
|     ,groupNamed = [generalflagsgroup1] |     ,groupNamed = [generalflagsgroup1] | ||||||
| @ -45,23 +43,18 @@ cashflow CliOpts{reportopts_=ropts} j = do | |||||||
|   -- let lines = case lineFormatFromOpts ropts of Left err, Right ... |   -- let lines = case lineFormatFromOpts ropts of Left err, Right ... | ||||||
|   d <- getCurrentDay |   d <- getCurrentDay | ||||||
|   let q = queryFromOpts d ropts |   let q = queryFromOpts d ropts | ||||||
|       valuedate = fromMaybe d $ queryEndDate False $ queryFromOpts d ropts |  | ||||||
|       cashreport@(_,total) = balanceReport ropts (And [q, journalCashAccountQuery j]) j |       cashreport@(_,total) = balanceReport ropts (And [q, journalCashAccountQuery j]) j | ||||||
|       -- operatingreport@(_,operating) = balanceReport ropts (And [q, journalOperatingAccountMatcher j]) j |       -- operatingreport@(_,operating) = balanceReport ropts (And [q, journalOperatingAccountMatcher j]) j | ||||||
|       -- investingreport@(_,investing) = balanceReport ropts (And [q, journalInvestingAccountMatcher j]) j |       -- investingreport@(_,investing) = balanceReport ropts (And [q, journalInvestingAccountMatcher j]) j | ||||||
|       -- financingreport@(_,financing) = balanceReport ropts (And [q, journalFinancingAccountMatcher j]) j |       -- financingreport@(_,financing) = balanceReport ropts (And [q, journalFinancingAccountMatcher j]) j | ||||||
|       -- total = operating + investing + financing |       -- total = operating + investing + financing | ||||||
|       convertReport | value_ ropts = balanceReportValue j valuedate |  | ||||||
|                     | otherwise    = id |  | ||||||
|       convertTotal  | value_ ropts = mixedAmountValue j valuedate |  | ||||||
|                     | otherwise    = id |  | ||||||
|   LT.putStr $ [lt|Cashflow Statement |   LT.putStr $ [lt|Cashflow Statement | ||||||
| 
 | 
 | ||||||
| Cash flows: | Cash flows: | ||||||
| #{balanceReportAsText ropts (convertReport cashreport)} | #{balanceReportAsText ropts cashreport} | ||||||
| Total: | Total: | ||||||
| -------------------- | -------------------- | ||||||
| #{padleft 20 $ showMixedAmountWithoutPrice (convertTotal total)} | #{padleft 20 $ showMixedAmountWithoutPrice total} | ||||||
| |] | |] | ||||||
| 
 | 
 | ||||||
| tests_Hledger_Cli_Cashflow :: Test | tests_Hledger_Cli_Cashflow :: Test | ||||||
|  | |||||||
| @ -11,7 +11,6 @@ module Hledger.Cli.Incomestatement ( | |||||||
|  ,tests_Hledger_Cli_Incomestatement |  ,tests_Hledger_Cli_Incomestatement | ||||||
| ) where | ) where | ||||||
| 
 | 
 | ||||||
| import Data.Maybe (fromMaybe) |  | ||||||
| import qualified Data.Text.Lazy.IO as LT | import qualified Data.Text.Lazy.IO as LT | ||||||
| import System.Console.CmdArgs.Explicit | import System.Console.CmdArgs.Explicit | ||||||
| import Test.HUnit | import Test.HUnit | ||||||
| @ -29,7 +28,6 @@ incomestatementmode = (defCommandMode $ ["incomestatement"]++aliases) { | |||||||
|      groupUnnamed = [ |      groupUnnamed = [ | ||||||
|       flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show accounts as a list" |       flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show accounts as a list" | ||||||
|      ,flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts" |      ,flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts" | ||||||
|      ,flagNone ["value","V"] (setboolopt "value") "show amounts as their current market value in their default valuation commodity" |  | ||||||
|      ] |      ] | ||||||
|     ,groupHidden = [] |     ,groupHidden = [] | ||||||
|     ,groupNamed = [generalflagsgroup1] |     ,groupNamed = [generalflagsgroup1] | ||||||
| @ -42,23 +40,18 @@ incomestatement :: CliOpts -> Journal -> IO () | |||||||
| incomestatement CliOpts{reportopts_=ropts} j = do | incomestatement CliOpts{reportopts_=ropts} j = do | ||||||
|   d <- getCurrentDay |   d <- getCurrentDay | ||||||
|   let q = queryFromOpts d ropts |   let q = queryFromOpts d ropts | ||||||
|       valuedate = fromMaybe d $ queryEndDate False $ queryFromOpts d ropts |  | ||||||
|       incomereport@(_,income)    = balanceReport ropts (And [q, journalIncomeAccountQuery j]) j |       incomereport@(_,income)    = balanceReport ropts (And [q, journalIncomeAccountQuery j]) j | ||||||
|       expensereport@(_,expenses) = balanceReport ropts (And [q, journalExpenseAccountQuery j]) j |       expensereport@(_,expenses) = balanceReport ropts (And [q, journalExpenseAccountQuery j]) j | ||||||
|       total = income + expenses |       total = income + expenses | ||||||
|       convertReport | value_ ropts = balanceReportValue j valuedate |  | ||||||
|                     | otherwise    = id |  | ||||||
|       convertTotal  | value_ ropts = mixedAmountValue j valuedate |  | ||||||
|                     | otherwise    = id |  | ||||||
|   LT.putStr $ [lt|Income Statement |   LT.putStr $ [lt|Income Statement | ||||||
| 
 | 
 | ||||||
| Revenues: | Revenues: | ||||||
| #{balanceReportAsText ropts (convertReport incomereport)} | #{balanceReportAsText ropts incomereport} | ||||||
| Expenses: | Expenses: | ||||||
| #{balanceReportAsText ropts (convertReport expensereport)} | #{balanceReportAsText ropts expensereport} | ||||||
| Total: | Total: | ||||||
| -------------------- | -------------------- | ||||||
| #{padleft 20 $ showMixedAmountWithoutPrice (convertTotal total)} | #{padleft 20 $ showMixedAmountWithoutPrice total} | ||||||
| |] | |] | ||||||
| 
 | 
 | ||||||
| tests_Hledger_Cli_Incomestatement :: Test | tests_Hledger_Cli_Incomestatement :: Test | ||||||
|  | |||||||
| @ -39,7 +39,6 @@ registermode = (defCommandMode $ ["register"] ++ aliases) { | |||||||
|      ,flagNone ["average","A"] (\opts -> setboolopt "average" opts) |      ,flagNone ["average","A"] (\opts -> setboolopt "average" opts) | ||||||
|         "show running average of posting amounts instead of total (implies --empty)" |         "show running average of posting amounts instead of total (implies --empty)" | ||||||
|      ,flagNone ["related","r"] (\opts -> setboolopt "related" opts) "show postings' siblings instead" |      ,flagNone ["related","r"] (\opts -> setboolopt "related" opts) "show postings' siblings instead" | ||||||
|      ,flagNone ["value","V"] (setboolopt "value") "show amounts as their current market value in their default valuation commodity" |  | ||||||
|      ,flagReq  ["width","w"] (\s opts -> Right $ setopt "width" s opts) "N" |      ,flagReq  ["width","w"] (\s opts -> Right $ setopt "width" s opts) "N" | ||||||
|       ("set output width (default: " ++ |       ("set output width (default: " ++ | ||||||
| #ifdef mingw32_HOST_OS | #ifdef mingw32_HOST_OS | ||||||
| @ -62,12 +61,9 @@ register :: CliOpts -> Journal -> IO () | |||||||
| register opts@CliOpts{reportopts_=ropts} j = do | register opts@CliOpts{reportopts_=ropts} j = do | ||||||
|   d <- getCurrentDay |   d <- getCurrentDay | ||||||
|   let fmt = outputFormatFromOpts opts |   let fmt = outputFormatFromOpts opts | ||||||
|       valuedate = fromMaybe d $ queryEndDate False $ queryFromOpts d ropts |       render | fmt=="csv" = const ((++"\n") . printCSV . postingsReportAsCsv) | ||||||
|       convert | value_ ropts = postingsReportValue j valuedate |              | otherwise  = postingsReportAsText | ||||||
|               | otherwise    = id |   writeOutput opts $ render opts $ postingsReport ropts (queryFromOpts d ropts) j | ||||||
|       render  | fmt=="csv" = const ((++"\n") . printCSV . postingsReportAsCsv) |  | ||||||
|               | otherwise  = postingsReportAsText |  | ||||||
|   writeOutput opts $ render opts $ convert $ postingsReport ropts (queryFromOpts d ropts) j |  | ||||||
| 
 | 
 | ||||||
| postingsReportAsCsv :: PostingsReport -> CSV | postingsReportAsCsv :: PostingsReport -> CSV | ||||||
| postingsReportAsCsv (_,is) = | postingsReportAsCsv (_,is) = | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user