cln: Flatten dependency tree by removing dependencies of Hledger.Reports
on Hledger.Read. This is done by using equivalent functions/types defined elsewhere instead.
This commit is contained in:
parent
315e92c08b
commit
1e766e481e
@ -22,7 +22,6 @@ where
|
|||||||
import Data.Time.Calendar
|
import Data.Time.Calendar
|
||||||
|
|
||||||
import Hledger.Data
|
import Hledger.Data
|
||||||
import Hledger.Read (mamountp')
|
|
||||||
import Hledger.Query
|
import Hledger.Query
|
||||||
import Hledger.Utils
|
import Hledger.Utils
|
||||||
import Hledger.Reports.MultiBalanceReport (multiBalanceReport)
|
import Hledger.Reports.MultiBalanceReport (multiBalanceReport)
|
||||||
@ -119,46 +118,46 @@ tests_BalanceReport = testGroup "BalanceReport" [
|
|||||||
,testCase "no args, sample journal" $
|
,testCase "no args, sample journal" $
|
||||||
(defreportspec, samplejournal) `gives`
|
(defreportspec, samplejournal) `gives`
|
||||||
([
|
([
|
||||||
("assets:bank:checking","assets:bank:checking",0, mamountp' "$1.00")
|
("assets:bank:checking","assets:bank:checking",0, mixedAmount (usd 1))
|
||||||
,("assets:bank:saving","assets:bank:saving",0, mamountp' "$1.00")
|
,("assets:bank:saving","assets:bank:saving",0, mixedAmount (usd 1))
|
||||||
,("assets:cash","assets:cash",0, mamountp' "$-2.00")
|
,("assets:cash","assets:cash",0, mixedAmount (usd (-2)))
|
||||||
,("expenses:food","expenses:food",0, mamountp' "$1.00")
|
,("expenses:food","expenses:food",0, mixedAmount (usd 1))
|
||||||
,("expenses:supplies","expenses:supplies",0, mamountp' "$1.00")
|
,("expenses:supplies","expenses:supplies",0, mixedAmount (usd 1))
|
||||||
,("income:gifts","income:gifts",0, mamountp' "$-1.00")
|
,("income:gifts","income:gifts",0, mixedAmount (usd (-1)))
|
||||||
,("income:salary","income:salary",0, mamountp' "$-1.00")
|
,("income:salary","income:salary",0, mixedAmount (usd (-1)))
|
||||||
],
|
],
|
||||||
mixedAmount (usd 0))
|
mixedAmount (usd 0))
|
||||||
|
|
||||||
,testCase "with --tree" $
|
,testCase "with --tree" $
|
||||||
(defreportspec{_rsReportOpts=defreportopts{accountlistmode_=ALTree}}, samplejournal) `gives`
|
(defreportspec{_rsReportOpts=defreportopts{accountlistmode_=ALTree}}, samplejournal) `gives`
|
||||||
([
|
([
|
||||||
("assets","assets",0, mamountp' "$0.00")
|
("assets","assets",0, mixedAmount (usd 0))
|
||||||
,("assets:bank","bank",1, mamountp' "$2.00")
|
,("assets:bank","bank",1, mixedAmount (usd 2))
|
||||||
,("assets:bank:checking","checking",2, mamountp' "$1.00")
|
,("assets:bank:checking","checking",2, mixedAmount (usd 1))
|
||||||
,("assets:bank:saving","saving",2, mamountp' "$1.00")
|
,("assets:bank:saving","saving",2, mixedAmount (usd 1))
|
||||||
,("assets:cash","cash",1, mamountp' "$-2.00")
|
,("assets:cash","cash",1, mixedAmount (usd (-2)))
|
||||||
,("expenses","expenses",0, mamountp' "$2.00")
|
,("expenses","expenses",0, mixedAmount (usd 2))
|
||||||
,("expenses:food","food",1, mamountp' "$1.00")
|
,("expenses:food","food",1, mixedAmount (usd 1))
|
||||||
,("expenses:supplies","supplies",1, mamountp' "$1.00")
|
,("expenses:supplies","supplies",1, mixedAmount (usd 1))
|
||||||
,("income","income",0, mamountp' "$-2.00")
|
,("income","income",0, mixedAmount (usd (-2)))
|
||||||
,("income:gifts","gifts",1, mamountp' "$-1.00")
|
,("income:gifts","gifts",1, mixedAmount (usd (-1)))
|
||||||
,("income:salary","salary",1, mamountp' "$-1.00")
|
,("income:salary","salary",1, mixedAmount (usd (-1)))
|
||||||
],
|
],
|
||||||
mixedAmount (usd 0))
|
mixedAmount (usd 0))
|
||||||
|
|
||||||
,testCase "with --depth=N" $
|
,testCase "with --depth=N" $
|
||||||
(defreportspec{_rsReportOpts=defreportopts{depth_=Just 1}}, samplejournal) `gives`
|
(defreportspec{_rsReportOpts=defreportopts{depth_=Just 1}}, samplejournal) `gives`
|
||||||
([
|
([
|
||||||
("expenses", "expenses", 0, mamountp' "$2.00")
|
("expenses", "expenses", 0, mixedAmount (usd 2))
|
||||||
,("income", "income", 0, mamountp' "$-2.00")
|
,("income", "income", 0, mixedAmount (usd (-2)))
|
||||||
],
|
],
|
||||||
mixedAmount (usd 0))
|
mixedAmount (usd 0))
|
||||||
|
|
||||||
,testCase "with depth:N" $
|
,testCase "with depth:N" $
|
||||||
(defreportspec{_rsQuery=Depth 1}, samplejournal) `gives`
|
(defreportspec{_rsQuery=Depth 1}, samplejournal) `gives`
|
||||||
([
|
([
|
||||||
("expenses", "expenses", 0, mamountp' "$2.00")
|
("expenses", "expenses", 0, mixedAmount (usd 2))
|
||||||
,("income", "income", 0, mamountp' "$-2.00")
|
,("income", "income", 0, mixedAmount (usd (-2)))
|
||||||
],
|
],
|
||||||
mixedAmount (usd 0))
|
mixedAmount (usd 0))
|
||||||
|
|
||||||
@ -169,27 +168,27 @@ tests_BalanceReport = testGroup "BalanceReport" [
|
|||||||
,testCase "with date2:" $
|
,testCase "with date2:" $
|
||||||
(defreportspec{_rsQuery=Date2 $ DateSpan (Just $ fromGregorian 2009 01 01) (Just $ fromGregorian 2010 01 01)}, samplejournal2) `gives`
|
(defreportspec{_rsQuery=Date2 $ DateSpan (Just $ fromGregorian 2009 01 01) (Just $ fromGregorian 2010 01 01)}, samplejournal2) `gives`
|
||||||
([
|
([
|
||||||
("assets:bank:checking","assets:bank:checking",0,mamountp' "$1.00")
|
("assets:bank:checking","assets:bank:checking",0,mixedAmount (usd 1))
|
||||||
,("income:salary","income:salary",0,mamountp' "$-1.00")
|
,("income:salary","income:salary",0,mixedAmount (usd (-1)))
|
||||||
],
|
],
|
||||||
mixedAmount (usd 0))
|
mixedAmount (usd 0))
|
||||||
|
|
||||||
,testCase "with desc:" $
|
,testCase "with desc:" $
|
||||||
(defreportspec{_rsQuery=Desc $ toRegexCI' "income"}, samplejournal) `gives`
|
(defreportspec{_rsQuery=Desc $ toRegexCI' "income"}, samplejournal) `gives`
|
||||||
([
|
([
|
||||||
("assets:bank:checking","assets:bank:checking",0,mamountp' "$1.00")
|
("assets:bank:checking","assets:bank:checking",0,mixedAmount (usd 1))
|
||||||
,("income:salary","income:salary",0, mamountp' "$-1.00")
|
,("income:salary","income:salary",0, mixedAmount (usd (-1)))
|
||||||
],
|
],
|
||||||
mixedAmount (usd 0))
|
mixedAmount (usd 0))
|
||||||
|
|
||||||
,testCase "with not:desc:" $
|
,testCase "with not:desc:" $
|
||||||
(defreportspec{_rsQuery=Not . Desc $ toRegexCI' "income"}, samplejournal) `gives`
|
(defreportspec{_rsQuery=Not . Desc $ toRegexCI' "income"}, samplejournal) `gives`
|
||||||
([
|
([
|
||||||
("assets:bank:saving","assets:bank:saving",0, mamountp' "$1.00")
|
("assets:bank:saving","assets:bank:saving",0, mixedAmount (usd 1))
|
||||||
,("assets:cash","assets:cash",0, mamountp' "$-2.00")
|
,("assets:cash","assets:cash",0, mixedAmount (usd (-2)))
|
||||||
,("expenses:food","expenses:food",0, mamountp' "$1.00")
|
,("expenses:food","expenses:food",0, mixedAmount (usd 1))
|
||||||
,("expenses:supplies","expenses:supplies",0, mamountp' "$1.00")
|
,("expenses:supplies","expenses:supplies",0, mixedAmount (usd 1))
|
||||||
,("income:gifts","income:gifts",0, mamountp' "$-1.00")
|
,("income:gifts","income:gifts",0, mixedAmount (usd (-1)))
|
||||||
],
|
],
|
||||||
mixedAmount (usd 0))
|
mixedAmount (usd 0))
|
||||||
|
|
||||||
@ -197,8 +196,8 @@ tests_BalanceReport = testGroup "BalanceReport" [
|
|||||||
(defreportspec{_rsReportOpts=defreportopts{period_= PeriodBetween (fromGregorian 2008 1 1) (fromGregorian 2008 1 2)}}, samplejournal) `gives`
|
(defreportspec{_rsReportOpts=defreportopts{period_= PeriodBetween (fromGregorian 2008 1 1) (fromGregorian 2008 1 2)}}, samplejournal) `gives`
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
("assets:bank:checking","assets:bank:checking",0, mamountp' "$1.00")
|
("assets:bank:checking","assets:bank:checking",0, mixedAmount (usd 1))
|
||||||
,("income:salary","income:salary",0, mamountp' "$-1.00")
|
,("income:salary","income:salary",0, mixedAmount (usd (-1)))
|
||||||
],
|
],
|
||||||
mixedAmount (usd 0))
|
mixedAmount (usd 0))
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,6 @@ import Text.Tabular.AsciiWide as Tab
|
|||||||
|
|
||||||
import Hledger.Data
|
import Hledger.Data
|
||||||
import Hledger.Utils
|
import Hledger.Utils
|
||||||
import Hledger.Read.CsvReader (CSV)
|
|
||||||
import Hledger.Reports.ReportOptions
|
import Hledger.Reports.ReportOptions
|
||||||
import Hledger.Reports.ReportTypes
|
import Hledger.Reports.ReportTypes
|
||||||
import Hledger.Reports.MultiBalanceReport
|
import Hledger.Reports.MultiBalanceReport
|
||||||
@ -401,7 +400,7 @@ budgetReportAsTable
|
|||||||
-- XXX generalise this with multiBalanceReportAsCsv ?
|
-- XXX generalise this with multiBalanceReportAsCsv ?
|
||||||
-- | Render a budget report as CSV. Like multiBalanceReportAsCsv,
|
-- | Render a budget report as CSV. Like multiBalanceReportAsCsv,
|
||||||
-- but includes alternating actual and budget amount columns.
|
-- but includes alternating actual and budget amount columns.
|
||||||
budgetReportAsCsv :: ReportOpts -> BudgetReport -> CSV
|
budgetReportAsCsv :: ReportOpts -> BudgetReport -> [[Text]]
|
||||||
budgetReportAsCsv
|
budgetReportAsCsv
|
||||||
ReportOpts{..}
|
ReportOpts{..}
|
||||||
(PeriodicReport colspans items tr)
|
(PeriodicReport colspans items tr)
|
||||||
|
|||||||
@ -59,7 +59,6 @@ import Hledger.Data
|
|||||||
import Hledger.Query
|
import Hledger.Query
|
||||||
import Hledger.Utils hiding (dbg3,dbg4,dbg5)
|
import Hledger.Utils hiding (dbg3,dbg4,dbg5)
|
||||||
import qualified Hledger.Utils
|
import qualified Hledger.Utils
|
||||||
import Hledger.Read (mamountp')
|
|
||||||
import Hledger.Reports.ReportOptions
|
import Hledger.Reports.ReportOptions
|
||||||
import Hledger.Reports.ReportTypes
|
import Hledger.Reports.ReportTypes
|
||||||
|
|
||||||
@ -606,10 +605,10 @@ tests_MultiBalanceReport = testGroup "MultiBalanceReport" [
|
|||||||
,testCase "with -H on a populated period" $
|
,testCase "with -H on a populated period" $
|
||||||
(defreportspec{_rsReportOpts=defreportopts{period_= PeriodBetween (fromGregorian 2008 1 1) (fromGregorian 2008 1 2), balanceaccum_=Historical}}, samplejournal) `gives`
|
(defreportspec{_rsReportOpts=defreportopts{period_= PeriodBetween (fromGregorian 2008 1 1) (fromGregorian 2008 1 2), balanceaccum_=Historical}}, samplejournal) `gives`
|
||||||
(
|
(
|
||||||
[ PeriodicReportRow (flatDisplayName "assets:bank:checking") [mamountp' "$1.00"] (mamountp' "$1.00") (mixedAmount amt0{aquantity=1})
|
[ PeriodicReportRow (flatDisplayName "assets:bank:checking") [mixedAmount $ usd 1] (mixedAmount $ usd 1) (mixedAmount amt0{aquantity=1})
|
||||||
, PeriodicReportRow (flatDisplayName "income:salary") [mamountp' "$-1.00"] (mamountp' "$-1.00") (mixedAmount amt0{aquantity=(-1)})
|
, PeriodicReportRow (flatDisplayName "income:salary") [mixedAmount $ usd (-1)] (mixedAmount $ usd (-1)) (mixedAmount amt0{aquantity=(-1)})
|
||||||
],
|
],
|
||||||
mamountp' "$0.00")
|
mixedAmount $ usd 0)
|
||||||
|
|
||||||
-- ,testCase "a valid history on an empty period" $
|
-- ,testCase "a valid history on an empty period" $
|
||||||
-- (defreportopts{period_= PeriodBetween (fromGregorian 2008 1 2) (fromGregorian 2008 1 3), balanceaccum_=Historical}, samplejournal) `gives`
|
-- (defreportopts{period_= PeriodBetween (fromGregorian 2008 1 2) (fromGregorian 2008 1 3), balanceaccum_=Historical}, samplejournal) `gives`
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user