lib: drop TransactionsReport, BalanceHistoryReport
They seem unused.
This commit is contained in:
parent
04a30fa084
commit
54c1529638
@ -13,12 +13,10 @@ module Hledger.Reports (
|
|||||||
module Hledger.Reports.ReportTypes,
|
module Hledger.Reports.ReportTypes,
|
||||||
module Hledger.Reports.EntriesReport,
|
module Hledger.Reports.EntriesReport,
|
||||||
module Hledger.Reports.PostingsReport,
|
module Hledger.Reports.PostingsReport,
|
||||||
module Hledger.Reports.TransactionsReport,
|
|
||||||
module Hledger.Reports.AccountTransactionsReport,
|
module Hledger.Reports.AccountTransactionsReport,
|
||||||
module Hledger.Reports.BalanceReport,
|
module Hledger.Reports.BalanceReport,
|
||||||
module Hledger.Reports.MultiBalanceReports,
|
module Hledger.Reports.MultiBalanceReports,
|
||||||
module Hledger.Reports.BudgetReport,
|
module Hledger.Reports.BudgetReport,
|
||||||
-- module Hledger.Reports.BalanceHistoryReport,
|
|
||||||
-- * Tests
|
-- * Tests
|
||||||
tests_Reports
|
tests_Reports
|
||||||
)
|
)
|
||||||
@ -26,23 +24,20 @@ where
|
|||||||
|
|
||||||
import Hledger.Reports.ReportOptions
|
import Hledger.Reports.ReportOptions
|
||||||
import Hledger.Reports.ReportTypes
|
import Hledger.Reports.ReportTypes
|
||||||
|
import Hledger.Reports.AccountTransactionsReport
|
||||||
import Hledger.Reports.EntriesReport
|
import Hledger.Reports.EntriesReport
|
||||||
import Hledger.Reports.PostingsReport
|
import Hledger.Reports.PostingsReport
|
||||||
import Hledger.Reports.TransactionsReport
|
|
||||||
import Hledger.Reports.AccountTransactionsReport
|
|
||||||
import Hledger.Reports.BalanceReport
|
import Hledger.Reports.BalanceReport
|
||||||
import Hledger.Reports.MultiBalanceReports
|
import Hledger.Reports.MultiBalanceReports
|
||||||
import Hledger.Reports.BudgetReport
|
import Hledger.Reports.BudgetReport
|
||||||
-- import Hledger.Reports.BalanceHistoryReport
|
|
||||||
import Hledger.Utils.Test
|
import Hledger.Utils.Test
|
||||||
|
|
||||||
tests_Reports = tests "Reports" [
|
tests_Reports = tests "Reports" [
|
||||||
tests_BalanceReport
|
tests_BalanceReport
|
||||||
,tests_BudgetReport
|
,tests_BudgetReport
|
||||||
|
,tests_AccountTransactionsReport
|
||||||
,tests_EntriesReport
|
,tests_EntriesReport
|
||||||
,tests_MultiBalanceReports
|
,tests_MultiBalanceReports
|
||||||
,tests_PostingsReport
|
,tests_PostingsReport
|
||||||
,tests_ReportOptions
|
,tests_ReportOptions
|
||||||
,tests_TransactionsReport
|
|
||||||
,tests_AccountTransactionsReport
|
|
||||||
]
|
]
|
||||||
|
|||||||
@ -117,7 +117,7 @@ accountTransactionsReport opts j reportq thisacctq = (label, items)
|
|||||||
mstartdate = queryStartDate (date2_ opts) reportq'
|
mstartdate = queryStartDate (date2_ opts) reportq'
|
||||||
datelessreportq = filterQuery (not . queryIsDateOrDate2) reportq'
|
datelessreportq = filterQuery (not . queryIsDateOrDate2) reportq'
|
||||||
|
|
||||||
items = reverse $ -- see also registerChartHtml
|
items = reverse $
|
||||||
accountTransactionsReportItems reportq' thisacctq startbal negate ts
|
accountTransactionsReportItems reportq' thisacctq startbal negate ts
|
||||||
|
|
||||||
-- | Generate transactions report items from a list of transactions,
|
-- | Generate transactions report items from a list of transactions,
|
||||||
|
|||||||
@ -1,31 +0,0 @@
|
|||||||
{-# LANGUAGE RecordWildCards, DeriveDataTypeable, FlexibleInstances #-}
|
|
||||||
{-|
|
|
||||||
|
|
||||||
Account balance history report.
|
|
||||||
|
|
||||||
-}
|
|
||||||
-- XXX not used
|
|
||||||
|
|
||||||
module Hledger.Reports.BalanceHistoryReport (
|
|
||||||
accountBalanceHistory
|
|
||||||
)
|
|
||||||
where
|
|
||||||
|
|
||||||
import Data.Time.Calendar
|
|
||||||
|
|
||||||
import Hledger.Data
|
|
||||||
import Hledger.Query
|
|
||||||
import Hledger.Reports.ReportOptions
|
|
||||||
import Hledger.Reports.TransactionsReport
|
|
||||||
|
|
||||||
|
|
||||||
-- | Get the historical running inclusive balance of a particular account,
|
|
||||||
-- from earliest to latest posting date.
|
|
||||||
accountBalanceHistory :: ReportOpts -> Journal -> Account -> [(Day, MixedAmount)]
|
|
||||||
accountBalanceHistory ropts j a = [(getdate t, bal) | (t,_,_,_,_,bal) <- items]
|
|
||||||
where
|
|
||||||
(_,items) = transactionsReport ropts j acctquery
|
|
||||||
inclusivebal = True
|
|
||||||
acctquery = Acct $ (if inclusivebal then accountNameToAccountRegex else accountNameToAccountOnlyRegex) $ aname a
|
|
||||||
getdate = if date2_ ropts then transactionDate2 else tdate
|
|
||||||
|
|
||||||
@ -1,110 +0,0 @@
|
|||||||
{-# LANGUAGE OverloadedStrings, RecordWildCards, DeriveDataTypeable, FlexibleInstances #-}
|
|
||||||
{-|
|
|
||||||
|
|
||||||
A transactions report. Like an EntriesReport, but with more
|
|
||||||
information such as a running balance.
|
|
||||||
|
|
||||||
-}
|
|
||||||
|
|
||||||
module Hledger.Reports.TransactionsReport (
|
|
||||||
TransactionsReport,
|
|
||||||
TransactionsReportItem,
|
|
||||||
transactionsReport,
|
|
||||||
transactionsReportByCommodity,
|
|
||||||
triOrigTransaction,
|
|
||||||
triDate,
|
|
||||||
triAmount,
|
|
||||||
triBalance,
|
|
||||||
triCommodityAmount,
|
|
||||||
triCommodityBalance,
|
|
||||||
tests_TransactionsReport
|
|
||||||
)
|
|
||||||
where
|
|
||||||
|
|
||||||
import Data.List
|
|
||||||
import Data.Ord
|
|
||||||
|
|
||||||
import Hledger.Data
|
|
||||||
import Hledger.Query
|
|
||||||
import Hledger.Reports.ReportOptions
|
|
||||||
import Hledger.Reports.AccountTransactionsReport
|
|
||||||
import Hledger.Utils
|
|
||||||
|
|
||||||
|
|
||||||
-- | A transactions report includes a list of transactions touching multiple accounts
|
|
||||||
-- (posting-filtered and unfiltered variants), a running balance, and some
|
|
||||||
-- other information helpful for rendering a register view (a flag
|
|
||||||
-- indicating multiple other accounts and a display string describing
|
|
||||||
-- them) with or without a notion of current account(s).
|
|
||||||
-- Two kinds of report use this data structure, see transactionsReport
|
|
||||||
-- and accountTransactionsReport below for details.
|
|
||||||
type TransactionsReport = (String -- label for the balance column, eg "balance" or "total"
|
|
||||||
,[TransactionsReportItem] -- line items, one per transaction
|
|
||||||
)
|
|
||||||
type TransactionsReportItem = (Transaction -- the original journal transaction, unmodified
|
|
||||||
,Transaction -- the transaction as seen from a particular account, with postings maybe filtered
|
|
||||||
,Bool -- is this a split, ie more than one other account posting
|
|
||||||
,String -- a display string describing the other account(s), if any
|
|
||||||
,MixedAmount -- the amount posted to the current account(s) by the filtered postings (or total amount posted)
|
|
||||||
,MixedAmount -- the running total of item amounts, starting from zero;
|
|
||||||
-- or with --historical, the running total including items
|
|
||||||
-- (matched by the report query) preceding the report period
|
|
||||||
)
|
|
||||||
|
|
||||||
triOrigTransaction (torig,_,_,_,_,_) = torig
|
|
||||||
triDate (_,tacct,_,_,_,_) = tdate tacct
|
|
||||||
triAmount (_,_,_,_,a,_) = a
|
|
||||||
triBalance (_,_,_,_,_,a) = a
|
|
||||||
triCommodityAmount c = filterMixedAmountByCommodity c . triAmount
|
|
||||||
triCommodityBalance c = filterMixedAmountByCommodity c . triBalance
|
|
||||||
|
|
||||||
-- | Select transactions from the whole journal. This is similar to a
|
|
||||||
-- "postingsReport" except with transaction-based report items which
|
|
||||||
-- are ordered most recent first. XXX Or an EntriesReport - use that instead ?
|
|
||||||
-- This is used by hledger-web's journal view.
|
|
||||||
transactionsReport :: ReportOpts -> Journal -> Query -> TransactionsReport
|
|
||||||
transactionsReport opts j q = (totallabel, items)
|
|
||||||
where
|
|
||||||
-- XXX items' first element should be the full transaction with all postings
|
|
||||||
items = reverse $ accountTransactionsReportItems q None nullmixedamt id ts
|
|
||||||
ts = sortBy (comparing date) $ filter (q `matchesTransaction`) $ jtxns $ journalSelectingAmountFromOpts opts j
|
|
||||||
date = transactionDateFn opts
|
|
||||||
|
|
||||||
-- | Split a transactions report whose items may involve several commodities,
|
|
||||||
-- into one or more single-commodity transactions reports.
|
|
||||||
transactionsReportByCommodity :: TransactionsReport -> [(CommoditySymbol, TransactionsReport)]
|
|
||||||
transactionsReportByCommodity tr =
|
|
||||||
[(c, filterTransactionsReportByCommodity c tr) | c <- transactionsReportCommodities tr]
|
|
||||||
where
|
|
||||||
transactionsReportCommodities (_,items) =
|
|
||||||
nub $ sort $ map acommodity $ concatMap (amounts . triAmount) items
|
|
||||||
|
|
||||||
-- Remove transaction report items and item amount (and running
|
|
||||||
-- balance amount) components that don't involve the specified
|
|
||||||
-- commodity. Other item fields such as the transaction are left unchanged.
|
|
||||||
filterTransactionsReportByCommodity :: CommoditySymbol -> TransactionsReport -> TransactionsReport
|
|
||||||
filterTransactionsReportByCommodity c (label,items) =
|
|
||||||
(label, fixTransactionsReportItemBalances $ concat [filterTransactionsReportItemByCommodity c i | i <- items])
|
|
||||||
where
|
|
||||||
filterTransactionsReportItemByCommodity c (t,t2,s,o,a,bal)
|
|
||||||
| c `elem` cs = [item']
|
|
||||||
| otherwise = []
|
|
||||||
where
|
|
||||||
cs = map acommodity $ amounts a
|
|
||||||
item' = (t,t2,s,o,a',bal)
|
|
||||||
a' = filterMixedAmountByCommodity c a
|
|
||||||
|
|
||||||
fixTransactionsReportItemBalances [] = []
|
|
||||||
fixTransactionsReportItemBalances [i] = [i]
|
|
||||||
fixTransactionsReportItemBalances items = reverse $ i:(go startbal is)
|
|
||||||
where
|
|
||||||
i:is = reverse items
|
|
||||||
startbal = filterMixedAmountByCommodity c $ triBalance i
|
|
||||||
go _ [] = []
|
|
||||||
go bal ((t,t2,s,o,amt,_):is) = (t,t2,s,o,amt,bal'):go bal' is
|
|
||||||
where bal' = bal + amt
|
|
||||||
|
|
||||||
-- tests
|
|
||||||
|
|
||||||
tests_TransactionsReport = tests "TransactionsReport" [
|
|
||||||
]
|
|
||||||
@ -4,7 +4,7 @@ cabal-version: 1.12
|
|||||||
--
|
--
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
--
|
--
|
||||||
-- hash: f11088bf1233291fabff38353e1bb342fafd2586510fc84418e17a1eebda505d
|
-- hash: 953c47a260da3c57cb7ec2aa2a10e868e3986c38241785fec87ffadc3583fadb
|
||||||
|
|
||||||
name: hledger-lib
|
name: hledger-lib
|
||||||
version: 1.14.99
|
version: 1.14.99
|
||||||
@ -78,14 +78,12 @@ library
|
|||||||
Hledger.Reports
|
Hledger.Reports
|
||||||
Hledger.Reports.ReportOptions
|
Hledger.Reports.ReportOptions
|
||||||
Hledger.Reports.ReportTypes
|
Hledger.Reports.ReportTypes
|
||||||
Hledger.Reports.BalanceHistoryReport
|
Hledger.Reports.AccountTransactionsReport
|
||||||
Hledger.Reports.BalanceReport
|
Hledger.Reports.BalanceReport
|
||||||
Hledger.Reports.BudgetReport
|
Hledger.Reports.BudgetReport
|
||||||
Hledger.Reports.EntriesReport
|
Hledger.Reports.EntriesReport
|
||||||
Hledger.Reports.MultiBalanceReports
|
Hledger.Reports.MultiBalanceReports
|
||||||
Hledger.Reports.PostingsReport
|
Hledger.Reports.PostingsReport
|
||||||
Hledger.Reports.TransactionsReport
|
|
||||||
Hledger.Reports.AccountTransactionsReport
|
|
||||||
Hledger.Utils
|
Hledger.Utils
|
||||||
Hledger.Utils.Color
|
Hledger.Utils.Color
|
||||||
Hledger.Utils.Debug
|
Hledger.Utils.Debug
|
||||||
@ -179,7 +177,6 @@ test-suite doctests
|
|||||||
Hledger.Read.TimedotReader
|
Hledger.Read.TimedotReader
|
||||||
Hledger.Reports
|
Hledger.Reports
|
||||||
Hledger.Reports.AccountTransactionsReport
|
Hledger.Reports.AccountTransactionsReport
|
||||||
Hledger.Reports.BalanceHistoryReport
|
|
||||||
Hledger.Reports.BalanceReport
|
Hledger.Reports.BalanceReport
|
||||||
Hledger.Reports.BudgetReport
|
Hledger.Reports.BudgetReport
|
||||||
Hledger.Reports.EntriesReport
|
Hledger.Reports.EntriesReport
|
||||||
@ -187,7 +184,6 @@ test-suite doctests
|
|||||||
Hledger.Reports.PostingsReport
|
Hledger.Reports.PostingsReport
|
||||||
Hledger.Reports.ReportOptions
|
Hledger.Reports.ReportOptions
|
||||||
Hledger.Reports.ReportTypes
|
Hledger.Reports.ReportTypes
|
||||||
Hledger.Reports.TransactionsReport
|
|
||||||
Hledger.Utils
|
Hledger.Utils
|
||||||
Hledger.Utils.Color
|
Hledger.Utils.Color
|
||||||
Hledger.Utils.Debug
|
Hledger.Utils.Debug
|
||||||
@ -282,7 +278,6 @@ test-suite easytests
|
|||||||
Hledger.Read.TimedotReader
|
Hledger.Read.TimedotReader
|
||||||
Hledger.Reports
|
Hledger.Reports
|
||||||
Hledger.Reports.AccountTransactionsReport
|
Hledger.Reports.AccountTransactionsReport
|
||||||
Hledger.Reports.BalanceHistoryReport
|
|
||||||
Hledger.Reports.BalanceReport
|
Hledger.Reports.BalanceReport
|
||||||
Hledger.Reports.BudgetReport
|
Hledger.Reports.BudgetReport
|
||||||
Hledger.Reports.EntriesReport
|
Hledger.Reports.EntriesReport
|
||||||
@ -290,7 +285,6 @@ test-suite easytests
|
|||||||
Hledger.Reports.PostingsReport
|
Hledger.Reports.PostingsReport
|
||||||
Hledger.Reports.ReportOptions
|
Hledger.Reports.ReportOptions
|
||||||
Hledger.Reports.ReportTypes
|
Hledger.Reports.ReportTypes
|
||||||
Hledger.Reports.TransactionsReport
|
|
||||||
Hledger.Utils
|
Hledger.Utils
|
||||||
Hledger.Utils.Color
|
Hledger.Utils.Color
|
||||||
Hledger.Utils.Debug
|
Hledger.Utils.Debug
|
||||||
|
|||||||
@ -131,14 +131,12 @@ library:
|
|||||||
- Hledger.Reports
|
- Hledger.Reports
|
||||||
- Hledger.Reports.ReportOptions
|
- Hledger.Reports.ReportOptions
|
||||||
- Hledger.Reports.ReportTypes
|
- Hledger.Reports.ReportTypes
|
||||||
- Hledger.Reports.BalanceHistoryReport
|
- Hledger.Reports.AccountTransactionsReport
|
||||||
- Hledger.Reports.BalanceReport
|
- Hledger.Reports.BalanceReport
|
||||||
- Hledger.Reports.BudgetReport
|
- Hledger.Reports.BudgetReport
|
||||||
- Hledger.Reports.EntriesReport
|
- Hledger.Reports.EntriesReport
|
||||||
- Hledger.Reports.MultiBalanceReports
|
- Hledger.Reports.MultiBalanceReports
|
||||||
- Hledger.Reports.PostingsReport
|
- Hledger.Reports.PostingsReport
|
||||||
- Hledger.Reports.TransactionsReport
|
|
||||||
- Hledger.Reports.AccountTransactionsReport
|
|
||||||
- Hledger.Utils
|
- Hledger.Utils
|
||||||
- Hledger.Utils.Color
|
- Hledger.Utils.Color
|
||||||
- Hledger.Utils.Debug
|
- Hledger.Utils.Debug
|
||||||
|
|||||||
@ -38,20 +38,20 @@ getRegisterR = do
|
|||||||
setTitle "register - hledger-web"
|
setTitle "register - hledger-web"
|
||||||
$(widgetFile "register")
|
$(widgetFile "register")
|
||||||
|
|
||||||
-- | Generate javascript/html for a register balance line chart based on
|
-- -- | Generate javascript/html for a register balance line chart based on
|
||||||
-- the provided "TransactionsReportItem"s.
|
-- -- the provided "TransactionsReportItem"s.
|
||||||
registerChartHtml :: [(CommoditySymbol, (String, [TransactionsReportItem]))] -> HtmlUrl AppRoute
|
-- registerChartHtml :: [(CommoditySymbol, (String, [TransactionsReportItem]))] -> HtmlUrl AppRoute
|
||||||
registerChartHtml percommoditytxnreports = $(hamletFile "templates/chart.hamlet")
|
-- registerChartHtml percommoditytxnreports = $(hamletFile "templates/chart.hamlet")
|
||||||
-- have to make sure plot is not called when our container (maincontent)
|
-- -- have to make sure plot is not called when our container (maincontent)
|
||||||
-- is hidden, eg with add form toggled
|
-- -- is hidden, eg with add form toggled
|
||||||
where
|
-- where
|
||||||
charttitle = case maybe "" (fst . snd) $ listToMaybe percommoditytxnreports of
|
-- charttitle = case maybe "" (fst . snd) $ listToMaybe percommoditytxnreports of
|
||||||
"" -> ""
|
-- "" -> ""
|
||||||
s -> s <> ":"
|
-- s -> s <> ":"
|
||||||
colorForCommodity = fromMaybe 0 . flip lookup commoditiesIndex
|
-- colorForCommodity = fromMaybe 0 . flip lookup commoditiesIndex
|
||||||
commoditiesIndex = zip (map fst percommoditytxnreports) [0..] :: [(CommoditySymbol,Int)]
|
-- commoditiesIndex = zip (map fst percommoditytxnreports) [0..] :: [(CommoditySymbol,Int)]
|
||||||
simpleMixedAmountQuantity = maybe 0 aquantity . listToMaybe . amounts
|
-- simpleMixedAmountQuantity = maybe 0 aquantity . listToMaybe . amounts
|
||||||
shownull c = if null c then " " else c
|
-- shownull c = if null c then " " else c
|
||||||
|
|
||||||
dayToJsTimestamp :: Day -> Integer
|
dayToJsTimestamp :: Day -> Integer
|
||||||
dayToJsTimestamp d =
|
dayToJsTimestamp d =
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user