From 88afea8c44bb205683a2fa0b76bb19b5208883b1 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 17 Apr 2012 02:28:30 +0000 Subject: [PATCH] balancesheet: ignore start dates, always show the accurate balance from all transactions up to the specified end date --- hledger/Hledger/Cli/Balancesheet.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hledger/Hledger/Cli/Balancesheet.hs b/hledger/Hledger/Cli/Balancesheet.hs index fc0ccbb0b..487a5000e 100644 --- a/hledger/Hledger/Cli/Balancesheet.hs +++ b/hledger/Hledger/Cli/Balancesheet.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE QuasiQuotes #-} +{-# LANGUAGE QuasiQuotes, RecordWildCards #-} {-| The @balancesheet@ command prints a fairly standard balance sheet. @@ -27,7 +27,7 @@ balancesheet :: CliOpts -> Journal -> IO () balancesheet CliOpts{reportopts_=ropts} j = do -- let lines = case formatFromOpts ropts of Left err, Right ... d <- getCurrentDay - let m = queryFromOpts ropts d + let m = queryFromOpts (withoutBeginDate ropts) d assetreport@(_,assets) = accountsReport2 ropts (And [m, journalAssetAccountQuery j]) j liabilityreport@(_,liabilities) = accountsReport2 ropts (And [m, journalLiabilityAccountQuery j]) j equityreport@(_,equity) = accountsReport2 ropts (And [m, journalEquityAccountQuery j]) j @@ -46,6 +46,11 @@ Total: #{padleft 20 $ showMixedAmountWithoutPrice total} |] +withoutBeginDate :: ReportOpts -> ReportOpts +withoutBeginDate ropts@ReportOpts{..} = ropts{begin_=Nothing, period_=p} + where p = case period_ of Nothing -> Nothing + Just (i, DateSpan _ e) -> Just (i, DateSpan Nothing e) + tests_Hledger_Cli_Balancesheet = TestList [ ]