mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-27 04:13:11 +03:00
lib: new generic PeriodicReport, and some report-related type aliases
This commit is contained in:
parent
d2f5d7101e
commit
4b3c6afe75
@ -10,6 +10,7 @@ javascript, or whatever.
|
||||
|
||||
module Hledger.Reports (
|
||||
module Hledger.Reports.ReportOptions,
|
||||
module Hledger.Reports.ReportTypes,
|
||||
module Hledger.Reports.EntriesReport,
|
||||
module Hledger.Reports.PostingsReport,
|
||||
module Hledger.Reports.TransactionsReports,
|
||||
@ -25,6 +26,7 @@ where
|
||||
import Test.HUnit
|
||||
|
||||
import Hledger.Reports.ReportOptions
|
||||
import Hledger.Reports.ReportTypes
|
||||
import Hledger.Reports.EntriesReport
|
||||
import Hledger.Reports.PostingsReport
|
||||
import Hledger.Reports.TransactionsReports
|
||||
|
40
hledger-lib/Hledger/Reports/ReportTypes.hs
Normal file
40
hledger-lib/Hledger/Reports/ReportTypes.hs
Normal file
@ -0,0 +1,40 @@
|
||||
{- |
|
||||
New common report types, used by the BudgetReport for now, perhaps all reports later.
|
||||
-}
|
||||
|
||||
module Hledger.Reports.ReportTypes
|
||||
where
|
||||
|
||||
import Data.Decimal
|
||||
import Hledger.Data
|
||||
|
||||
type Percentage = Decimal
|
||||
|
||||
type Change = MixedAmount -- ^ A change in balance during a certain period.
|
||||
type Balance = MixedAmount -- ^ An ending balance as of some date.
|
||||
type Total = MixedAmount -- ^ The sum of 'Change's in a report or a report row. Does not make sense for 'Balance's.
|
||||
type Average = MixedAmount -- ^ The average of 'Change's or 'Balance's in a report or report row.
|
||||
|
||||
-- | A generic tabular report of some value, where each row corresponds to an account
|
||||
-- and each column is a date period. The column periods are usually consecutive subperiods
|
||||
-- formed by splitting the overall report period by some report interval (daily, weekly, etc.)
|
||||
-- Depending on the value type, this can be a report of balance changes, ending balances,
|
||||
-- budget performance, etc. Successor to MultiBalanceReport.
|
||||
data PeriodicReport a =
|
||||
PeriodicReport
|
||||
( [DateSpan] -- ^ The subperiods formed by spliting the overall report period by the report interval.
|
||||
-- For ending-balance reports, only the end date is significant.
|
||||
-- Usually displayed as report columns.
|
||||
, [PeriodicReportRow a] -- ^ One row per account in the report.
|
||||
, PeriodicReportRow a -- ^ The grand totals row. The account name in this row is always empty.
|
||||
)
|
||||
deriving (Show)
|
||||
|
||||
type PeriodicReportRow a =
|
||||
( AccountName -- ^ A full account name.
|
||||
, AccountName -- ^ Shortened form of the account name to display in tree mode. Usually the leaf name, possibly with parent accounts prefixed.
|
||||
, Int -- ^ Indent level for displaying this account name in tree mode. 0, 1, 2...
|
||||
, [a] -- ^ The data value for each subperiod.
|
||||
, a -- ^ The total of this row's values.
|
||||
, a -- ^ The average of this row's values.
|
||||
)
|
@ -131,6 +131,8 @@ library
|
||||
Hledger.Utils.UTF8IOCompat
|
||||
Text.Megaparsec.Compat
|
||||
other-modules:
|
||||
Hledger.Reports.BudgetReport
|
||||
Hledger.Reports.ReportTypes
|
||||
Paths_hledger_lib
|
||||
default-language: Haskell2010
|
||||
|
||||
@ -209,10 +211,12 @@ test-suite doctests
|
||||
Hledger.Reports
|
||||
Hledger.Reports.BalanceHistoryReport
|
||||
Hledger.Reports.BalanceReport
|
||||
Hledger.Reports.BudgetReport
|
||||
Hledger.Reports.EntriesReport
|
||||
Hledger.Reports.MultiBalanceReports
|
||||
Hledger.Reports.PostingsReport
|
||||
Hledger.Reports.ReportOptions
|
||||
Hledger.Reports.ReportTypes
|
||||
Hledger.Reports.TransactionsReports
|
||||
Hledger.Utils
|
||||
Hledger.Utils.Color
|
||||
@ -301,10 +305,12 @@ test-suite easytests
|
||||
Hledger.Reports
|
||||
Hledger.Reports.BalanceHistoryReport
|
||||
Hledger.Reports.BalanceReport
|
||||
Hledger.Reports.BudgetReport
|
||||
Hledger.Reports.EntriesReport
|
||||
Hledger.Reports.MultiBalanceReports
|
||||
Hledger.Reports.PostingsReport
|
||||
Hledger.Reports.ReportOptions
|
||||
Hledger.Reports.ReportTypes
|
||||
Hledger.Reports.TransactionsReports
|
||||
Hledger.Utils
|
||||
Hledger.Utils.Color
|
||||
@ -394,10 +400,12 @@ test-suite hunittests
|
||||
Hledger.Reports
|
||||
Hledger.Reports.BalanceHistoryReport
|
||||
Hledger.Reports.BalanceReport
|
||||
Hledger.Reports.BudgetReport
|
||||
Hledger.Reports.EntriesReport
|
||||
Hledger.Reports.MultiBalanceReports
|
||||
Hledger.Reports.PostingsReport
|
||||
Hledger.Reports.ReportOptions
|
||||
Hledger.Reports.ReportTypes
|
||||
Hledger.Reports.TransactionsReports
|
||||
Hledger.Utils
|
||||
Hledger.Utils.Color
|
||||
|
@ -122,8 +122,10 @@ library:
|
||||
- Hledger.Read.TimeclockReader
|
||||
- Hledger.Reports
|
||||
- Hledger.Reports.ReportOptions
|
||||
- Hledger.Reports.ReportTypes
|
||||
- Hledger.Reports.BalanceHistoryReport
|
||||
- Hledger.Reports.BalanceReport
|
||||
- Hledger.Reports.BudgetReport
|
||||
- Hledger.Reports.EntriesReport
|
||||
- Hledger.Reports.MultiBalanceReports
|
||||
- Hledger.Reports.PostingsReport
|
||||
|
Loading…
Reference in New Issue
Block a user